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

[Big model loading] Correct GPU only loading #1121

Merged
merged 6 commits into from
Mar 1, 2023

Conversation

patrickvonplaten
Copy link
Contributor

@patrickvonplaten patrickvonplaten commented Feb 27, 2023

There was a bug when loading safetensors directly on GPU via device_map="auto" in diffusers.

The test shows the failure case.

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Feb 27, 2023

The documentation is not available anymore as the PR was closed or merged.

Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

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

Thanks for fixing the bug! I left a couple of comments.

src/accelerate/utils/modeling.py Outdated Show resolved Hide resolved
src/accelerate/utils/modeling.py Outdated Show resolved Hide resolved
Comment on lines 433 to 435
for k, v in device_map.items():
v = v if v != "disk" else "cpu"
self.assertEqual(loaded_state_dict[k].device, torch.device(v))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's use proper names here instead of k, v (like param, device).

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
@patrickvonplaten
Copy link
Contributor Author

patrickvonplaten commented Mar 1, 2023

Merging as Sylvain has ✔️ -ed

@patrickvonplaten patrickvonplaten merged commit b2ea1c7 into main Mar 1, 2023
@patrickvonplaten patrickvonplaten deleted the correct_safetensors_on_gpu branch March 1, 2023 15:22
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