forked from huggingface/peft
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix target_modules type in config.from_pretrained
Fixes huggingface#1045, supersedes huggingface#1041 Description When loading a config from a file, we currently set the loaded attributes on the config directly. However, this sidesteps the __post_init__ call, which is required to convert the target_modules to a set. This PR fixes this by avoiding to set attributes on the config class directly, instead of going through __init__. Other changes While working on this, I did a slight refactor of the config tests. 1. All config classes are included now (some where missing before). 2. Use parameterized instead of looping through the classes. 3. Added a unit test for the aforementioned bug. Notes This fix is based on my comment here: huggingface#1041 (review) Normally, I'd just wait for Sourab to reply, but since he's off for a few days, I created a separate PR. Another way we could achieve this is to override __setattr__ on the config class which explicitly converts target_modules to a set. This would cover the case where a user does something like: config = ... config.target_modules = ["a", "b", "c"] Then we don't need to rely on __post_init__. However, I would propose to save the heavy guns for when absolutely necessary.
- Loading branch information
1 parent
aaa7e9f
commit 4f3cef2
Showing
2 changed files
with
94 additions
and
82 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