Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン 初心者向け
#1,707 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
75/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python, pytorch

調査の方向性

問題は diffsynth/models/wan_video_dit.py の 462 行目と diffsynth/models/wantodance.py の 156 行目にあります。WanToDanceMusicEncoderLayer コンストラクターからハードコードされた引数 device='cuda' を削除してください。修正を確認するには、CPU や NPU などの非 CUDA デバイスでモデルをロードするテストを実行し、アサーションエラーが発生しないことを確認します。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
13.1k
フォーク
1.3k
平均マージ
12時間 53分
マージ済み PR(30日)
42

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

modelscope/DiffSynth-Studio のほかの issue

modelscope/DiffSynth-Studio の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。