Skip to content

Pipeline.to() offload guards only cover cuda/xpu: Ascend NPU misses the sequential-offload conflict error and the model-offload warning #14878

Description

@li-lizhe

Describe the bug

In src/diffusers/modular_pipelines/modular_pipeline.py, two guards in Pipeline.to() are written as device_type in ["cuda", "xpu"]:

  • line ~2691 — the sequential offload conflict check (raises the "you activated sequential model offloading … but are now attempting to move the pipeline to device" error)
  • line ~2704 — the model offload warning (the operation succeeds but the offload benefit is silently lost)

Ascend NPU is also an accelerator where explicit device placement conflicts with offloading, but device_type == "npu" matches neither guard, so NPU users get silently broken offload behavior instead of the same clear error/warning CUDA and XPU users get.

device_type Current guard Expected
"cuda" fires fires
"xpu" fires fires
"npu" silently skipped should fire
"cpu" skipped skipped

Reproduction

import torch, torch_npu  # Ascend 910B
pipe = SomePipeline.from_pretrained(...)
pipe.enable_sequential_cpu_offload()
pipe.to("npu")   # no error raised, although the pipeline is sequentially offloaded

Environment

  • diffusers main
  • Ascend 910B NPU, torch 2.14 + torch_npu
  • device_type resolves to "npu" for torch.device("npu")

Fix

Extend both guard lists to ["cuda", "xpu", "npu"]. PR: #14786

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