Skip to content

fix: apply torchfix to set weights_only=True#3497

Merged
SunMarc merged 2 commits into
huggingface:mainfrom
bzhong-solink:main
Apr 15, 2025
Merged

fix: apply torchfix to set weights_only=True#3497
SunMarc merged 2 commits into
huggingface:mainfrom
bzhong-solink:main

Conversation

@bzhong-solink
Copy link
Copy Markdown
Contributor

Since accelerate depends on PyTorch >= 2.0 at the minimum, this was introduced in 2.0 which is backward compatible since then. 🎉

@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

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.

Comment thread src/accelerate/utils/other.py Outdated
else:
kwargs.pop("weights_only", None)
loaded_obj = torch.load(f, map_location=map_location, **kwargs)
loaded_obj = torch.load(f, map_location=map_location, **kwargs, weights_only=True)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some tests are failing with

TypeError: torch.serialization.load() got multiple values for keyword argument 'weights_only'

Probably, weights_only needs to be added to kwargs here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oops, sorry. Thanks for the catch!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in c1e4fc9

👍

Copy link
Copy Markdown
Member

@SunMarc SunMarc left a comment

Choose a reason for hiding this comment

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

Thanks !

@SunMarc SunMarc merged commit 4a3cbcb into huggingface:main Apr 15, 2025
25 checks passed
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.

4 participants