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 multi lora #2711

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion swift/llm/train/tuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def get_multimodal_target_regex(model_arch,
prefix_pattern = '|'.join(modules)
rejected_pattern = '|'.join(rejected_modules)

ignore_pattern = []
ignore_pattern = ['lora_A', 'lora_B', 'base_layer']
if ignore_embedding:
ignore_pattern += ['emb', 'wte', 'shared']
ignore_pattern += model_arch.embedding or []
Expand Down
3 changes: 2 additions & 1 deletion swift/tuners/peft.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
PromptEncoderConfig, PromptLearningConfig, PromptTuningConfig, VeraConfig, VeraModel, get_peft_config,
get_peft_model, get_peft_model_state_dict)
from peft.config import PeftConfigMixin
from peft.tuners import lora
from peft.tuners.lora import Embedding
from transformers import Trainer

Expand Down Expand Up @@ -84,7 +85,7 @@ def from_pretrained(cls, pretrained_model_name_or_path: str, subfolder: Optional

def _create_and_replace_hook(self, peft_config, adapter_name, target, *args, **kwargs):
all_supported_names = ('linear', )
all_supported_types = (torch.nn.Embedding, torch.nn.Conv2d, transformers.pytorch_utils.Conv1D)
all_supported_types = (torch.nn.Embedding, torch.nn.Conv2d, transformers.pytorch_utils.Conv1D, lora.Linear)
target_modules = getattr(peft_config, 'target_modules', None)
if target is None:
return
Expand Down
Loading