Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta Adatta ai principianti
#1,707 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

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

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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di modelscope/DiffSynth-Studio

Tutte le issue di modelscope/DiffSynth-Studio

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.