WanToDance: hardcoded `device='cuda'` in music encoder construction crashes model loading on Ascend NPU
まだ誰も着手していません。
評価
- 難易度
- 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
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
modelscope/DiffSynth-Studio のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
modelscope/DiffSynth-Studio#1702 ·
-
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
modelscope/DiffSynth-Studio#1668 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
modelscope/DiffSynth-Studio#1499 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
modelscope/DiffSynth-Studio#1373 · コメント 5 件 · リアクション 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
modelscope/DiffSynth-Studio#1709 · コメント 1 件 ·
modelscope/DiffSynth-Studio の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
stephrobert/dsoxlab#238 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
sublimehq/package_control#1780 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
nwg-piotr/nwg-displays#145 ·