-
Notifications
You must be signed in to change notification settings - Fork 27.3k
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
[PEFT] Support low_cpu_mem_usage option for PEFT loading adapters #33725
[PEFT] Support low_cpu_mem_usage option for PEFT loading adapters #33725
Conversation
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. |
@ArthurZucker could you give this a look? |
adapter_kwargs (`Dict[str, Any]`, *optional*): | ||
Additional keyword arguments passed along to the `from_pretrained` method of the adapter config and | ||
`find_adapter_config_file` method. | ||
""" | ||
check_peft_version(min_version=MIN_PEFT_VERSION) | ||
|
||
# peft only supports low_cpu_mem_usage starting from v0.13.0 | ||
peft_load_kwargs = {} |
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.
LGTM, not sure we need all the kwargs as you are not taking them from the kwargs of this function 😉
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.
Not sure if I get you, do you mean this should be merged with adapter_kwargs
? That wouldn't work, as these are kwargs
used for a different purpose.
Or that using a dict for a single argument is overkill?
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.
Or that using a dict for a single argument is overkill?
this 🤗
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.
I found this more readable and extensible than having:
if low_cpu_mem_usage:
inject_adapter_in_model(peft_config, self, adapter_name, low_cpu_mem_usage=low_cpu_mem_usage)
else:
inject_adapter_in_model(peft_config, self, adapter_name)
(same with the set_peft_model_state_dict
call)
If you want me to change it to this instead or have an alternative idea, let me know and I'll change it.
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.
no worries
not sure what's going on with the tests, rebasing should help ! |
@ArthurZucker I still get |
PEFT added support for low_cpu_mem_usage=True when loading adapters in huggingface/peft#1961. This feature is now available when installing PEFT v0.13.0. With this PR, this option is also supported when loading PEFT adapters directly into transformers models. Additionally, with this PR, huggingface/diffusers#9510 will be unblocked, which implements this option in diffusers.
45394a5
to
5236a47
Compare
I had to force push as the rebasing you did went a bit wrong! Should be good now! 🤗 |
Oops, sorry about that. Anything that needs to be done from my side for this PR? |
Nope, I was just waiting for the cis! |
…ggingface#33725) * [PEFT] Support low_cpu_mem_usage for PEFT loading PEFT added support for low_cpu_mem_usage=True when loading adapters in huggingface/peft#1961. This feature is now available when installing PEFT v0.13.0. With this PR, this option is also supported when loading PEFT adapters directly into transformers models. Additionally, with this PR, huggingface/diffusers#9510 will be unblocked, which implements this option in diffusers. * Fix typo
…ggingface#33725) * [PEFT] Support low_cpu_mem_usage for PEFT loading PEFT added support for low_cpu_mem_usage=True when loading adapters in huggingface/peft#1961. This feature is now available when installing PEFT v0.13.0. With this PR, this option is also supported when loading PEFT adapters directly into transformers models. Additionally, with this PR, huggingface/diffusers#9510 will be unblocked, which implements this option in diffusers. * Fix typo
…ggingface#33725) * [PEFT] Support low_cpu_mem_usage for PEFT loading PEFT added support for low_cpu_mem_usage=True when loading adapters in huggingface/peft#1961. This feature is now available when installing PEFT v0.13.0. With this PR, this option is also supported when loading PEFT adapters directly into transformers models. Additionally, with this PR, huggingface/diffusers#9510 will be unblocked, which implements this option in diffusers. * Fix typo
What does this PR do?
PEFT added support for
low_cpu_mem_usage=True
when loading adapters in huggingface/peft#1961. This feature is now available when installing PEFT v0.13.0. With this PR, this option is also supported when loading PEFT adapters directly into transformers models.Additionally, with this PR, huggingface/diffusers#9510 will be unblocked, which implements this option in diffusers.
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.