WanToDance: hardcoded `device='cuda'` in music encoder construction crashes model loading on Ascend NPU
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
- 75/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python, pytorch
- Lĩnh vực
- ai-infra-agents
Hướng nghiên cứu
Vấn đề nằm ở diffsynth/models/wan_video_dit.py dòng 462 và diffsynth/models/wantodance.py dòng 156. Hãy xóa đối số được mã hóa cứng device='cuda' khỏi hàm tạo WanToDanceMusicEncoderLayer. Kiểm tra bản sửa lỗi bằng cách chạy một bài kiểm tra tải mô hình trên một thiết bị không phải CUDA, chẳng hạn như CPU hoặc NPU, để đảm bảo không xảy ra lỗi khẳng định.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
WanModel.__init__ builds the WanToDance music encoder with a hardcoded CUDA device (diffsynth/models/wan_video_dit.py:462):
self.music_encoder.append(
WanToDanceMusicEncoderLayer(
d_model=latent_dim,
nhead=nhead,
dim_feedforward=ff_size,
dropout=dropout,
activation=activation,
batch_first=True,
rotary=rotary,
device='cuda',
)
)
WanToDanceMusicEncoderLayer forwards device to nn.MultiheadAttention(..., device=device) (diffsynth/models/wantodance.py:156), so the attention parameters are allocated on CUDA at construction time.
Impact
On any build without CUDA (Ascend NPU, CPU-only, ...) the model cannot be constructed at all, before the surrounding pipeline ever gets a chance to move it to the target device:
AssertionError: Torch not compiled with CUDA enabled
This block is gated by wantodance_enable_global / wantodance_enable_dynamicfps / wantodance_enable_unimodel, i.e. loading a WanToDance model on Ascend fails outright. Every sibling layer in the same block (nn.Linear, nn.Sequential) leaves the device to the caller's .to(device), so the hardcoded argument is also inconsistent with the rest of the file — and with diffsynth.core.device.npu_compatible_device, which the project already ships for NPU support.
Reproduction
# Ascend 910B4, torch 2.15.0.dev + torch_npu 2.15.0.dev
from wantodance import WanToDanceMusicEncoderLayer
WanToDanceMusicEncoderLayer(d_model=256, nhead=4, dim_feedforward=1024,
dropout=0.1, batch_first=True, rotary=None,
device='cuda')
# AssertionError: Torch not compiled with CUDA enabled
Proposed fix
Drop the hardcoded device='cuda'; the module is moved to the real device by the pipeline afterwards, exactly like its sibling layers. Verified on real Ascend 910B4 hardware (construction + forward pass on NPU); I will open a PR referencing this issue.
- Ngôn ngữ chính
- Python
- Star
- 13.1k
- Fork
- 1.3k
- Merge trung bình
- 12 giờ 53 phút
- Pull request đã merge (30 ngày)
- 42
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
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 modelscope/DiffSynth-Studio
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
modelscope/DiffSynth-Studio#1702 ·
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 78/100
modelscope/DiffSynth-Studio#1668 ·
-
bfloat16训练时段错误: 数组越界的一种方案 Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
modelscope/DiffSynth-Studio#1499 · 1 bình luận ·
-
Latest update broke Wan2.2 S2V Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
modelscope/DiffSynth-Studio#1373 · 5 bình luận · 1 reaction ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
modelscope/DiffSynth-Studio#1709 · 1 bình luận ·
Tất cả issue của modelscope/DiffSynth-Studio
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
stephrobert/dsoxlab#238 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
sublimehq/package_control#1780 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
nwg-piotr/nwg-displays#145 ·