Skip to content
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

Add device parameter for PEFT load_adapter #30339

Closed
uwu-420 opened this issue Apr 19, 2024 · 2 comments · Fixed by #30397
Closed

Add device parameter for PEFT load_adapter #30339

uwu-420 opened this issue Apr 19, 2024 · 2 comments · Fixed by #30397
Labels
Feature request Request for a new feature

Comments

@uwu-420
Copy link

uwu-420 commented Apr 19, 2024

Feature request

Hello,

the function load_adapter of the PeftAdapterMixin class currently doesn't have a device parameter but a device_map parameter which isn't being used by the load_peft_weights function. Instead, the load_peft_weights function will use infer_device to figure out some device.

See
https://github.com/huggingface/transformers/blob/30b453206d224ee5f747afa33ff216671558e6a0/src/transformers/integrations/peft.py#L193C13-L193C97
and
https://github.com/huggingface/peft/blob/5a4b9cade64bac8afdff5006ee9dd815c90b5469/src/peft/utils/save_and_load.py#L392C9-L392C32

Can it be changed to use the device of the model we want to add the adapter to by default?

Motivation

I stumbled over this when I had a model on CPU and the loaded adapter was loaded onto the MPS device which caused other issues for me. I think it would be more intuitive if the adapter is directly loaded to the same device as the model.

Your contribution

Sorry, nothing here. But happy to provide more context.

@amyeroberts amyeroberts added the Feature request Request for a new feature label Apr 19, 2024
@amyeroberts
Copy link
Collaborator

cc @younesbelkada

@younesbelkada
Copy link
Contributor

Hi @uwu-420
Thanks for the feature request !
Currently you can pass the device through adapter_kwargs={"device": device} but I agree we should use the same device as the model if possible. I will work on that and provide a fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature request Request for a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants