From 5fbfe8c9fdaa0040301155e2993ce61a26d4a9af Mon Sep 17 00:00:00 2001 From: li-lizhe <147392333@qq.com> Date: Mon, 14 Sep 2026 09:15:19 +0800 Subject: [PATCH] fix(wan): use device-agnostic default for get_i2v_mask The `get_i2v_mask` method had a hardcoded `device="cuda"` default, which crashes on non-CUDA accelerators (Ascend NPU, etc.) with "Torch not compiled with CUDA enabled" when called without an explicit device argument. Change the default to None and resolve via `self._execution_device`, matching the pattern used across other pipeline methods. Verified on Ascend 910B NPU: torch.zeros(device="cuda") crashes, fix with device-agnostic resolution creates tensors on the correct device. --- src/diffusers/pipelines/wan/pipeline_wan_animate.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/diffusers/pipelines/wan/pipeline_wan_animate.py b/src/diffusers/pipelines/wan/pipeline_wan_animate.py index a923219a7550..c2416243f111 100644 --- a/src/diffusers/pipelines/wan/pipeline_wan_animate.py +++ b/src/diffusers/pipelines/wan/pipeline_wan_animate.py @@ -465,8 +465,10 @@ def get_i2v_mask( mask_len: int = 1, mask_pixel_values: torch.Tensor | None = None, dtype: torch.dtype | None = None, - device: str | torch.device = "cuda", + device: str | torch.device | None = None, ) -> torch.Tensor: + device = device or self._execution_device + # mask_pixel_values shape (if supplied): [B, C = 1, T, latent_h, latent_w] if mask_pixel_values is None: mask_lat_size = torch.zeros(