WanAnimatePipeline.get_i2v_mask() defaults device to "cuda", which raises on non-CUDA accelerators (NPU/XPU/MPS)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 88/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- machine-learning
Hướng nghiên cứu
Bắt đầu tại src/diffusers/pipelines/wan/pipeline_wan_animate.py, ở WanAnimatePipeline.get_i2v_mask(), sau đó so sánh cách xử lý thiết bị của nó với prepare_reference_image_latents và encode_image. Xác minh rằng các lệnh gọi không có thiết bị được chỉ định rõ ràng sử dụng thiết bị thực thi của pipeline và rằng một lần gọi không phải CUDA không còn cố gắng cấp phát CUDA; xem xét riêng helper có tên tương tự trong src/diffusers/modular_pipelines/wan_animate_2/encoders.py.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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).
- Ngôn ngữ chính
- Python
- Star
- 34.6k
- Fork
- 7.4k
- Merge trung bình
- 4 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 50
Chuẩn bị môi trường
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của huggingface/diffusers
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
huggingface/diffusers#14888 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
huggingface/diffusers#14864 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
huggingface/diffusers#14837 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug needs-env-info pipelines
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
huggingface/diffusers#14794 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug needs-code-example needs-env-info pipelines
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
huggingface/diffusers#14780 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của huggingface/diffusers
Issue tương tự
-
ACK_WAITING HELP_WANTED UPDATE_CS
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
OWASP/CheatSheetSeries#2458 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
BasedHardware/omi#19711 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Qwen3_5MoeModel no longer returns router_logits, breaking aux loss with output_router_logits=TrueĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
huggingface/transformers#49172 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
vllm-project/vllm-metal#885 ·
Maintainer thường phản hồi trong vòng 1 ngày