Skip to content

revert swift_from_pretrained #3914

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

Merged
Merged
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
11 changes: 11 additions & 0 deletions swift/tuners/peft.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ 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, lora.Linear)
target_modules = getattr(peft_config, 'target_modules', None)
if target is None:
return

if isinstance(target_modules, str) and not any(
[name in target.__class__.__name__.lower()
for name in all_supported_names]) and not any([isinstance(target, type_) for type_ in all_supported_types]):
return

if target.__class__.__name__ == 'NonDynamicallyQuantizableLinear':
return

Expand Down