WanAnimatePipeline.get_i2v_mask() defaults device to "cuda", which raises on non-CUDA accelerators (NPU/XPU/MPS)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 88/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
调研方向
从 src/diffusers/pipelines/wan/pipeline_wan_animate.py 中的 WanAnimatePipeline.get_i2v_mask() 开始,然后将其设备处理方式与 prepare_reference_image_latents 和 encode_image 进行比较。验证未显式指定设备的调用会使用 pipeline 的执行设备,并且非 CUDA 调用不再尝试进行 CUDA 分配;单独考虑 src/diffusers/modular_pipelines/wan_animate_2/encoders.py 中名称相似的辅助函数。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
WanAnimatePipeline.get_i2v_mask() (src/diffusers/pipelines/wan/pipeline_wan_animate.py, line ~471) declares its device parameter with a hard-coded CUDA default:
def get_i2v_mask(
self,
batch_size: int,
latent_t: int,
latent_h: int,
latent_w: int,
mask_len: int = 1,
mask_pixel_values: torch.Tensor | None = None,
dtype: torch.dtype | None = None,
device: str | torch.device = "cuda", # <-- here
) -> torch.Tensor:
The mask is allocated with torch.zeros(..., device=device) / .to(device=device), so any call that does not pass device explicitly allocates on CUDA. On builds without CUDA (Ascend NPU via torch_npu, Intel XPU, Apple MPS) that raises immediately:
AssertionError: Torch not compiled with CUDA enabled
Every sibling helper on the same pipeline uses the device-agnostic convention instead (prepare_reference_image_latents, encode_image, ... carry device: torch.device | None = None and resolve it with device = device or self._execution_device), so the "cuda" default is inconsistent with the rest of the file and is a trap for any device-agnostic caller.
Reproduction
On a non-CUDA accelerator (verified on Ascend 910B2, torch 2.14.0a0/2.15.0.dev+cpu build with torch_npu):
import torch
torch.zeros(1, device="cuda")
# AssertionError: Torch not compiled with CUDA enabled
Calling the pipeline method without an explicit device hits the same path:
pipe.get_i2v_mask(batch_size=1, latent_t=1, latent_h=8, latent_w=8)
Expected behaviour
The default should resolve to the pipeline's execution device instead of assuming CUDA, matching the convention already used by the neighbouring helpers: device: str | torch.device | None = None plus device = device or self._execution_device at the top of the method.
Scope (for transparency)
The two in-tree call sites in the same file (prepare_reference_image_latents, prepare_prev_segment_cond_latents) both pass device explicitly, so nothing in the current in-tree path crashes today - this is a latent/API-hygiene defect for external callers and for future call sites. The module-level helper get_i2v_mask(lat_t, lat_h, lat_w, mask_len=1, device="cuda") in src/diffusers/modular_pipelines/wan_animate_2/encoders.py carries the same CUDA default; happy to cover it in the linked PR or in a follow-up, whichever the maintainers prefer.
System Info
- diffusers: main
- hardware: Ascend 910B2 NPU (torch 2.14.0a0 / 2.15.0.dev20260917+cpu +
torch_npu); the same failure applies to any CUDA-less build (XPU, MPS).
- 主要语言
- Python
- 星标
- 34.6k
- 派生
- 7.4k
- 平均合并
- 4 天 11 小时
- 30 天内合并 PR
- 48
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
huggingface/diffusers 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
huggingface/diffusers#14888 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
huggingface/diffusers#14864 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
huggingface/diffusers#14837 ·
维护者通常 1 天内回复
-
bug needs-env-info pipelines
难度 2/5 1-3 小时 新手友好度 72/100
huggingface/diffusers#14794 ·
维护者通常 1 天内回复
-
bug needs-code-example needs-env-info pipelines
难度 1/5 1 小时以内 新手友好度 86/100
huggingface/diffusers#14780 · 1 条评论 ·
维护者通常 1 天内回复
查看 huggingface/diffusers 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 86/100
维护者通常 1 天内回复
-
难度 2/5 1-2 天 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 7 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
lmstudio-ai/mlx-engine#376 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
pyiron/bagofholding#166 ·