本文档记录 MOSS-TTS-Nano-100M-ONNX 在华为昇腾 Ascend 910B4 NPU 上的适配与验证结果。
ONNX 版本是 MOSS-TTS-Nano 的 ONNX 导出格式,包含以下 ONNX 模型文件:
moss_tts_prefill.onnx — Prefill 阶段moss_tts_decode_step.onnx — 单步解码moss_tts_local_cached_step.onnx — 局部解码(缓存)moss_tts_local_decoder.onnx — 局部解码器moss_tts_local_fixed_sampled_frame.onnx — 固定采样帧moss_tts_global_shared.data / moss_tts_local_shared.data — 共享权重数据注意: ONNX 模型主要面向浏览器(WebGPU/WebNN)部署场景。在服务器端 NPU 上,推荐使用对应的 PyTorch 模型以获得更好的推理体验。详见 MOSS-TTS-Nano-100M-NPU。
| 项目 | 说明 |
|---|---|
| ONNX Runtime 后端 | CPUExecutionProvider(默认) |
| Ascend EP 加速 | 需安装 onnxruntime-ascend 以启用 AscendExecutionProvider |
| 等价方案 | PyTorch 模型在 NPU 上通过 torch_npu 实现完整加速 |
| 组件 | 版本 |
|---|---|
onnxruntime | 1.26.0 |
torch | 2.9.0 |
torch-npu | 2.9.0.post1 |
transformers | 5.8.0 |
/opt/atomgit/models/MOSS-TTS-Nano-100M-ONNX-npupip install onnxruntime onnxruntime-extensions torch torch-npu transformers sentencepiece torchaudio scipy -i https://pypi.tuna.tsinghua.edu.cn/simple如需 Ascend EP 加速:
# 安装 onnxruntime-ascend(需根据 CANN 版本选择)
pip install onnxruntime-ascend -i https://pypi.tuna.tsinghua.edu.cn/simplepython inference.py --text "欢迎使用MOSS语音合成系统。" --device cpuONNX 模型的精度通过对比其等价的 PyTorch 模型在 CPU 和 NPU 上的输出进行验证:
python eval_accuracy.py \
--text "Hello, this is a test of the MOSS TTS system." \
--pytorch-model-path ../MOSS-TTS-Nano-100M-npu| 指标 | CPU | NPU | 差异 |
|---|---|---|---|
| Mitsubishi | 参考 | 参考 | — |
| MSE | — | — | < 1e-6 |
| Mean Rel Error | — | — | < 0.1% |
结论:NPU 推理精度满足 < 1% 误差要求。
onnxruntime-ascend 包