[model][NPU]:Wan model rope use torch.complex64 in NPU

This commit is contained in:
feng0w0
2026-01-13 11:17:51 +08:00
parent 6be244233a
commit d16877e695
2 changed files with 3 additions and 4 deletions

View File

@@ -5,7 +5,6 @@ import math
from typing import Tuple, Optional
from einops import rearrange
from .wan_video_camera_controller import SimpleAdapter
from ..core.device.npu_compatible_device import IS_NPU_AVAILABLE
try:
import flash_attn_interface
@@ -94,7 +93,7 @@ def rope_apply(x, freqs, num_heads):
x = rearrange(x, "b s (n d) -> b s n d", n=num_heads)
x_out = torch.view_as_complex(x.to(torch.float64).reshape(
x.shape[0], x.shape[1], x.shape[2], -1, 2))
freqs = freqs.to(torch.complex64) if IS_NPU_AVAILABLE else freqs
freqs = freqs.to(torch.complex64) if freqs.device == "npu" else freqs
x_out = torch.view_as_real(x_out * freqs).flatten(2)
return x_out.to(x.dtype)