-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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 deprecation warning for torch.utils._pytree._register_pytree_node in PyTorch 2.2 #7008
Fix deprecation warning for torch.utils._pytree._register_pytree_node in PyTorch 2.2 #7008
Conversation
src/diffusers/utils/outputs.py
Outdated
torch.utils._pytree._dict_flatten, | ||
lambda values, context: cls(**torch.utils._pytree._dict_unflatten(values, context)), | ||
) | ||
if version.parse(get_torch_version()) < version.parse("2.2"): |
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.
Can we not use something like
if device_map is not None and not is_torch_version(">=", "1.9.0"): |
?
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.
Hi @sayakpaul ! I have addressed this, please lmk if it's alright, cheers!
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.
LGTM with one comment. Once that's addressed, I think we can merge.
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. |
…de in PyTorch 2.2
0c1d25c
to
38e7954
Compare
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.
Cool!
What does this PR do?
Fixes issue #7000. The latest PyTorch version (2.2) introduced a deprecation warning for
torch.utils._pytree._register_pytree_node
as used insrc/diffusers/utils/outputs.py
, suggesting the use oftorch.utils._pytree.register_pytree_node
(without the leading underscore). This PR updates the usage to align with the PyTorch recommendation, while also ensuring backward compatibility with older versions of PyTorch.Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
@yiyixuxu