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

fix: allow load_adapter to use different device #1631

Merged
merged 1 commit into from
Apr 10, 2024

Conversation

yhZhai
Copy link
Contributor

@yhZhai yhZhai commented Apr 8, 2024

Problem

In the multi-GPU DDP setting, the load_adapter function will always map the state_dict to "cuda", This causes all processes load the parameters to the first GPU, potentially causing OOM error.

Changes

Add an optional "torch_device" argument to the load_adapter function, so that by assigning it to "cpu", the parameters will not occupy memory on the first GPU.

@HuggingFaceDocBuilderDev

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.

@BenjaminBossan
Copy link
Member

Could you please run make style on your code?

@yhZhai
Copy link
Contributor Author

yhZhai commented Apr 9, 2024

Hi Benjamin, I just ran make style and made a force push. Please take a look. Thank you!

Copy link
Member

@BenjaminBossan BenjaminBossan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great PR, thanks for adding this useful parameter.

@BenjaminBossan BenjaminBossan merged commit 31c884e into huggingface:main Apr 10, 2024
14 checks passed
DTennant pushed a commit to DTennant/peft that referenced this pull request Apr 16, 2024
DTennant pushed a commit to DTennant/peft that referenced this pull request Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants