-
Notifications
You must be signed in to change notification settings - Fork 6.7k
fix the warning torch_dtype is deprecated #12841
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
Conversation
|
|
||
| # For transformers models, use 'dtype' instead of 'torch_dtype' to avoid deprecation warnings | ||
| if issubclass(class_obj, torch.nn.Module): | ||
| if is_transformers_model: |
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.
Think we would also need to check if transformers version is greater than 4.56.0.
…fusers into feature/fix-warning-deprecated
|
@DN6 Thanks for the review! I've updated the code to check for transformers version >= 4.56.0 before using the |
DN6
left a comment
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.
Thanks @msdsm 👍🏽
|
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. |
|
@bot /style |
|
@DN6 Linting errors have been fixed. CI is waiting for workflow approval. |
Motivation
When users load pipelines like
QwenImageEditPipelinewith thetorch_dtypeparameter, they see a deprecation warning from the Transformers library. However, changing todtype(as the warning suggests) causes errors because diffusers'from_pretraineddoesn't acceptdtypeas a parameter.This creates a confusing user experience where:
Solution
This PR internally converts
torch_dtypetodtypewhen loading Transformers models (transformers >= 4.20.0), while keepingtorch_dtypefor diffusers models and other components.Fixes #12840
Who can review?