Skip to content

Conversation

@msdsm
Copy link
Contributor

@msdsm msdsm commented Dec 15, 2025

Motivation

When users load pipelines like QwenImageEditPipeline with the torch_dtype parameter, they see a deprecation warning from the Transformers library. However, changing to dtype (as the warning suggests) causes errors because diffusers' from_pretrained doesn't accept dtype as a parameter.

This creates a confusing user experience where:

  1. Users see a deprecation warning
  2. Following the warning's advice breaks their code
  3. There's no way to avoid the warning without modifying the diffusers library

Solution

This PR internally converts torch_dtype to dtype when loading Transformers models (transformers >= 4.20.0), while keeping torch_dtype for diffusers models and other components.

Fixes #12840

Who can review?


# For transformers models, use 'dtype' instead of 'torch_dtype' to avoid deprecation warnings
if issubclass(class_obj, torch.nn.Module):
if is_transformers_model:
Copy link
Collaborator

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.

@msdsm
Copy link
Contributor Author

msdsm commented Jan 6, 2026

@DN6 Thanks for the review! I've updated the code to check for transformers version >= 4.56.0 before using the dtype parameter.

Copy link
Collaborator

@DN6 DN6 left a comment

Choose a reason for hiding this comment

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

Thanks @msdsm 👍🏽

@HuggingFaceDocBuilderDev

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.

@DN6
Copy link
Collaborator

DN6 commented Jan 6, 2026

@bot /style

@msdsm
Copy link
Contributor Author

msdsm commented Jan 7, 2026

@DN6 Linting errors have been fixed. CI is waiting for workflow approval.

@DN6 DN6 merged commit 91e5134 into huggingface:main Jan 9, 2026
9 of 11 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.

Fix the warning torch_dtype is deprecated

4 participants