Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(model): Linear detected and added to target module with rope linear #738

Merged
merged 2 commits into from
Oct 19, 2023

Conversation

NanoCode012
Copy link
Collaborator

Discussion: https://discord.com/channels/1104757954588196865/1110594519226925137/1163762312247787570

ValueError: Target module LlamaLinearScalingRotaryEmbedding() is not supported. Currently, only the following modules are supported: torch.nn.Linear, torch.nn.Embedding, torch.nn.Conv2d, transformers.pytorch_utils.Conv1D

when lora + rope_scaling: linear. dynamic is ok.

This condition check must've included the linear layer from the name.

Alternative solution: add blacklist for this module.

Note: I'm not sure if by removing this would affect any current run, but the linear layers listed in cls seems to be inclusive.

@Napuh
Copy link
Contributor

Napuh commented Oct 18, 2023

This PR works for Llama-2-7B.

However I can't confirm for other models.
Maybe it's safer to do something like:

if isinstance(module, cls) or "Linear" in module.__class__.__name__ and module.__class__ not in (LlamaLinearScalingRotaryEmbedding):
  names = name.split(".")
  lora_module_names.add(names[0] if len(names) == 1 else names[-1])

or:

if isinstance(module, cls) or "Linear" in module.__class__.__name__ and "Scaling" not in module.__class__.__name__:
  names = name.split(".")
  lora_module_names.add(names[0] if len(names) == 1 else names[-1])

@Napuh
Copy link
Contributor

Napuh commented Oct 18, 2023

This works fine on Llama-2, Llama-2 based models and OpenLlama3B.

@NanoCode012 NanoCode012 marked this pull request as ready for review October 19, 2023 01:42
@NanoCode012
Copy link
Collaborator Author

Thanks @Napuh

@winglian winglian merged commit 440c3ab into main Oct 19, 2023
4 checks passed
@winglian winglian deleted the NanoCode012-rope-linear-conflict branch October 19, 2023 02:13
@NanoCode012
Copy link
Collaborator Author

I just realized a code smell. I should've wrapped the and condition separately from or.

mkeoliya pushed a commit to mkeoliya/axolotl that referenced this pull request Dec 15, 2023
…ar (axolotl-ai-cloud#738)

* Fix(model): Linear detected and added to target module with rope linear

* fix: exclude layer instead
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants