-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 ModulesToSaveWrapper __getattr__ #1238
Fix ModulesToSaveWrapper __getattr__ #1238
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. Thinking a bit more about it, I think the best course of action would be to actually implement this as a @property
, which allows us to avoid fiddling with __getattr__
.
This should still not affect stuff like state_dict
, so would not break anything.
On top of that, would you be up to implement a unit test?
ok~ |
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM.
Can one of you @pacman100 or @younesbelkada give this a quick look to ensure it doesn't break anything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @zhangsheng377 for adding the weight property when using ModulesToSaveWrapper
! This makes sense and I don't see any issues with this approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! let's run integration tests after merging to see if this didn't break anything
Tests are all green! https://github.com/huggingface/peft/actions/runs/7194802375/job/19596105974 🍏 |
* Update other.py * Update other.py * Update test_low_level_api.py
#1225
We are recently using peft=0.4.0+Megatron to run GPTModel. There is a code of the model
self.language_model.output_layer.weight
, which directly takes theweight
of theoutput_layer
, but theoutput_layer
has already beenmodules_to_save
, so it reported "ModulesToSaveWrapper has no 'weight' attribute" error.So, I returns the weight of the currently active adapter or of the original module of the adapter is deactivated.
And
__getattr__
will be called only when its own class does not have this attribute, so this should not destroy the original scene.