[Bugfix][Ascend] fix npu 310/a5 bugs (#6685)
Signed-off-by: zouyizhou <zouyizhou@huawei.com>
This commit is contained in:
1 parent
038c9b948f
commit
6e79d582e3
8 files changed
+380
-89
No files matched your search
@@ -643,6 +643,10 @@ class Qwen3TTSPromptEmbedsBuilder:
|
||||
|
||||
# -------------------- speaker encoder / codec encoder --------------------
|
||||
|
||||
# Some NPUs (310P, Ascend 950) do not support torch.stft; builders on
|
||||
# such devices set this flag to compute the mel spectrogram on CPU.
|
||||
_mel_spectrogram_on_cpu: bool = False
|
||||
|
||||
def extract_speaker_embedding(self, wav: np.ndarray, sr: int) -> torch.Tensor:
|
||||
# vLLM workers do not automatically move arbitrary torch.nn.Modules to
|
||||
# CUDA. Ensure the speaker encoder is on the same device/dtype as the
|
||||
@@ -666,7 +670,9 @@ class Qwen3TTSPromptEmbedsBuilder:
|
||||
# Follow official implementation: mel_spectrogram expects 24kHz. Move
|
||||
# the waveform first so STFT/mel computation stays on the model device
|
||||
# instead of materializing a CPU mel tensor and copying it per request.
|
||||
wav_tensor = torch.from_numpy(wav).to(device=dev, dtype=torch.float32).unsqueeze(0)
|
||||
# Devices without torch.stft set _mel_spectrogram_on_cpu instead.
|
||||
mel_device = torch.device("cpu") if self._mel_spectrogram_on_cpu else dev
|
||||
wav_tensor = torch.from_numpy(wav).to(device=mel_device, dtype=torch.float32).unsqueeze(0)
|
||||
mels = mel_spectrogram(
|
||||
wav_tensor,
|
||||
n_fft=1024,
|
||||
@@ -677,7 +683,7 @@ class Qwen3TTSPromptEmbedsBuilder:
|
||||
fmin=0,
|
||||
fmax=12000,
|
||||
).transpose(1, 2)
|
||||
spk = self._speaker_encoder(mels.to(dtype=dtype))[0]
|
||||
spk = self._speaker_encoder(mels.to(device=dev, dtype=dtype))[0]
|
||||
return spk.to(dtype=dtype)
|
||||
|
||||
def encode_ref_audio_batch(
|
||||
|
||||
Reference in new issue
Block a user