Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto Apto para principiantes
#1,707 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
75/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python, pytorch

Línea de trabajo

El problema está en diffsynth/models/wan_video_dit.py línea 462 y diffsynth/models/wantodance.py línea 156. Elimina el argumento codificado de forma rígida device='cuda' del constructor WanToDanceMusicEncoderLayer. Verifica la corrección ejecutando una prueba que cargue el modelo en un dispositivo que no sea CUDA, como CPU o NPU, para asegurarte de que no se produzca ningún error de aserción.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
13.1k
Forks
1.3k
Merge medio
12 h 53 min
PR fusionados (30 d)
42

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de modelscope/DiffSynth-Studio

Todos los issues de modelscope/DiffSynth-Studio

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.