-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH Raise error when applying modules_to_save on tuner layer (#2028)
Relates to #2027 Normally, when selecting the layers for fine-tuning, PEFT already ensures that the same layer is not targeted for both parameter-efficient fine-tuning (e.g. LoRA layer) and full fine-tuning (via modules_to_save), as that makes no sense. However, there is a loophole when the modules_to_save is applied ex post. This happens for instance when having a task type like sequence classification, where PEFT will automatically add the classfication head to modules_to_save for the user. This loophole is now closed by adding a check to ModulesToSaveWrapper that validates that the targeted layer is not a tuner layer. This does not fully resolve #2027 but will raise an early error in the future to avoid confusion. On top of this, the error message inside of ModulesToSaveWrapper.check_module has been slightly adjusted. Previously, the class name would be used, which can be confusing. E.g. for LoRA, the class name of the linear LoRA layer is just "Linear", which looks the same as nn.Linear. Therefore, the full name is now shown.
- Loading branch information
1 parent
8fcb195
commit f3c7c6e
Showing
3 changed files
with
28 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters