WanToDance: hardcoded `device='cuda'` in music encoder construction crashes model loading on Ascend NPU
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 75/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- python, pytorch
- Ambito
- ai-infra-agents
Direzione di ricerca
Il problema si trova in diffsynth/models/wan_video_dit.py riga 462 e diffsynth/models/wantodance.py riga 156. Rimuovi l'argomento hardcoded device='cuda' dal costruttore WanToDanceMusicEncoderLayer. Verifica la correzione eseguendo un test che carica il modello su un dispositivo non CUDA, come CPU o NPU, per assicurarsi che non si verifichi alcun errore di asserzione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 13.1k
- Fork
- 1.3k
- Merge medio
- 12h 53m
- PR unite (30g)
- 42
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di modelscope/DiffSynth-Studio
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
modelscope/DiffSynth-Studio#1702 ·
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 78/100
modelscope/DiffSynth-Studio#1668 ·
-
bfloat16训练时段错误: 数组越界的一种方案 Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
modelscope/DiffSynth-Studio#1499 · 1 commento ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
modelscope/DiffSynth-Studio#1373 · 5 commenti · 1 reazione ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
modelscope/DiffSynth-Studio#1709 · 1 commento ·
Tutte le issue di modelscope/DiffSynth-Studio
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
browser-use/browser-use#5905 ·
-
type: enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
ynput/ayon-python-api#363 ·
-
bug needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
modelscope/FunASR#3728 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
open-compass/opencompass#2655 ·