Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

WanToDance: hardcoded `device='cuda'` in music encoder construction crashes model loading on Ascend NPU

Đang mở Phù hợp với người mới
#1,707 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

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

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của modelscope/DiffSynth-Studio

Tất cả issue của modelscope/DiffSynth-Studio

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.