-
Notifications
You must be signed in to change notification settings - Fork 5.9k
allow models to run with a user-provided dtype map instead of a single dtype #10301
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3643246
allow models to run with a user-provided dtype map instead of a singl…
hlky db77006
make style
hlky 2c58c64
Add warning, change `_` to `default`
hlky 2adba04
make style
hlky 156e6db
Merge branch 'main' into dtype-map
hlky 6de7479
Merge branch 'main' into dtype-map
sayakpaul e8ac2dd
Merge branch 'main' into dtype-map
hlky 70ae4b6
Merge branch 'main' into dtype-map
hlky b1237f7
Merge branch 'main' into dtype-map
hlky 1dc755c
Merge remote-tracking branch 'upstream/main' into dtype-map
hlky ec53008
add test
hlky e8aa61b
handle shared tensors
hlky 8f71311
remove warning
hlky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
For https://github.com/huggingface/diffusers/actions/runs/14188807487/job/39748937180?pr=10301#step:6:32518
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.
Do we know why this is erroring out for this test? With the current fix, for a sharded checkpoint, we might end up saving the entire model multiple times no?
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.
From
safetensors
, it doesn't allow saving shared tensors without usingsave_model
. Looks like this is why we're usingsafe_serialization=False
in other tests. If it's an issue like this then the similar issue exists without, as in, we couldn't save a sharded checkpoint that has shared tensors withsafetensors
, IMO asafetensors
problem - it should not be so opinionated about what can or cannot be saved withsave_file
, shared tensors are always minimal and duplicating them would make little difference to the overall size, the documentation on this matter also does not seem to align with our own findings - it mentions that buffers are consumed once we useget_tensor
however we have seen that memory is held during the context ofsafe_open
.https://github.com/huggingface/safetensors/blob/7d5af853631628137a79341ddc5611d18a17f3fe/bindings/python/py_src/safetensors/torch.py#L481-L494
diffusers/tests/models/test_modeling_common.py
Lines 445 to 446 in d8c617c
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.
Hmm I think in this case it would be better to just skip the test for Unidiffuser (it has very low usage) than change the saving logic for all pipelines.
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.
Took a quick look. Issue is with the
text_decoder
component that is a transformerPretrainedModel
wrapped in a ModelMixin class. So the transformers logic for saving shared tensors is never invokedhttps://github.com/huggingface/transformers/blob/ed95493ce05688447d15d9a82d2d70695290ecff/src/transformers/modeling_utils.py#L3464-L3479
We can skip the test and deprecate this pipeline later 👍🏽
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.
#11194 - reverts the change and the test passes with
safe_serialization=False
.