Describe the bug
apply_group_offloading(..., use_stream=True) in src/diffusers/hooks/group_offloading.py (~line 675) only builds a stream for CUDA (torch.cuda.Stream()) and Intel XPU (torch.Stream()). On every other accelerator it raises:
ValueError: Using streams for data transfer requires a CUDA device, or an Intel XPU device.
Ascend NPU exposes torch.npu.Stream() through torch_npu, so stream-based group offloading is implementable there — but the dispatch never reaches it, making the feature unusable on NPU even though the backend does support streams.
Reproduction
import torch, torch_npu # Ascend 910B
from diffusers.hooks import apply_group_offloading
print(torch.cuda.is_available(), torch.xpu.is_available(), torch.npu.is_available())
# False False True
apply_group_offloading(module, onload_device=torch.device("npu"), use_stream=True)
# ValueError: Using streams for data transfer requires a CUDA device, or an Intel XPU device.
Environment
- diffusers
main
- Ascend 910B NPU, torch 2.14 + torch_npu
torch.cuda.is_available() == False, torch.xpu.is_available() == False, torch.npu.is_available() == True
Expected behavior
Stream-based onload/offload works on any accelerator that exposes a stream type, or the error message lists the accelerator that is missing.
Fix
Add an npu branch mirroring the existing CUDA/XPU checks and mention Ascend NPU in the error message. PR: #14785
Describe the bug
apply_group_offloading(..., use_stream=True)insrc/diffusers/hooks/group_offloading.py(~line 675) only builds a stream for CUDA (torch.cuda.Stream()) and Intel XPU (torch.Stream()). On every other accelerator it raises:Ascend NPU exposes
torch.npu.Stream()throughtorch_npu, so stream-based group offloading is implementable there — but the dispatch never reaches it, making the feature unusable on NPU even though the backend does support streams.Reproduction
Environment
maintorch.cuda.is_available() == False,torch.xpu.is_available() == False,torch.npu.is_available() == TrueExpected behavior
Stream-based onload/offload works on any accelerator that exposes a stream type, or the error message lists the accelerator that is missing.
Fix
Add an
npubranch mirroring the existing CUDA/XPU checks and mention Ascend NPU in the error message. PR: #14785