Skip to content

Kandinsky5TimeEmbeddings hardcodes 'cuda' in @torch.autocast decorator, causing warning on non-CUDA systems #12809

Description

@knd0331

Body:

Describe the bug

When importing diffusers on a non-CUDA system (e.g., Apple Silicon Mac with MPS), a warning is
emitted:

/torch/amp/autocast_mode.py:270: UserWarning: User provided device_type of 'cuda', but CUDA is not
available. Disabling
warnings.warn(

This occurs because Kandinsky5TimeEmbeddings class has a hardcoded "cuda" device type in the
@torch.autocast decorator.

Location

File: diffusers/models/transformers/transformer_kandinsky.py
Line: 168

@torch.autocast(device_type="cuda", dtype=torch.float32)defforward(self, timestep):
RootCauseThedecoratorisevaluatedatimporttime, notatruntime. OnsystemswithoutCUDA (likeAppleSiliconMacsusingMPS), thistriggersthewarningeventhoughtheKandinskymodelmayneverbeused.
Reproduction# On a Mac with Apple Silicon (no CUDA)fromdiffusersimportZImagePipeline# or any pipeline# Warning appears immediately on importExpectedbehaviorNowarningshouldappearwhenimportingdiffusersonnon-CUDAsystems.
Environment-OS: macOS (AppleSiliconM-series)
-Python: 3.13-PyTorch: 2.x (MPSbackend)
-Diffusers: latest

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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