Skip to content

Fix the warning torch_dtype is deprecated #12840

@msdsm

Description

@msdsm

Description

When loading QwenImageEditPipeline (or other pipelines with Transformers models) using torch_dtype parameter, a deprecation warning is displayed:

pipeline = QwenImageEditPipeline.from_pretrained(
    "Qwen/Qwen-Image-Edit",
    torch_dtype=torch.bfloat16,
)

Warning message:

`torch_dtype` is deprecated! Use `dtype` instead!

However, if users try to use dtype instead of torch_dtype as suggested by the warning, it causes an error because the diffusers' from_pretrained method doesn't accept dtype as a parameter.

Root Cause

The deprecation warning originates from the Transformers library, which has deprecated torch_dtype in favor of dtype. When diffusers loads Transformers models (like text encoders in QwenImageEditPipeline), it passes torch_dtype to the Transformers' from_pretrained method, triggering this warning.

Proposed Solution

Internally convert torch_dtype to dtype when loading Transformers models within diffusers, so users can continue using the existing API without warnings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions