d
dingdang666/sarashina2.2-tts-NPU
模型介绍文件和版本Pull Requests讨论分析
下载使用量0

sarashina2.2-tts 在昇腾 NPU 上的部署

1. 简介

本文档记录 sarashina2.2-tts(Sarashina2.2 TTS 模型)在昇腾 NPU(Ascend 910B3)环境的适配部署与精度验证结果。

Sarashina2.2-TTS 基于 LlamaForCausalLM 架构,参数量约 810M,支持日语文本到语音合成。本项目完成该模型在昇腾 NPU 上的推理适配,验证 NPU 与 CPU 结果的精度误差 < 1%。

相关地址:

  • 权重下载地址(HuggingFace):https://huggingface.co/sarashina/sarashina2.2-tts
  • 适配仓库:https://gitcode.com/dingdang666/sarashina2.2-tts-NPU

2. 验证环境

组件版本
Python3.11.x
PyTorch2.10.0+cpu
torch_npu2.10.0
transformers5.8.1
CANN8.5.1
NPU 硬件Ascend 910B3

3. 模型信息

项目值
模型架构LlamaForCausalLM
参数量~810M
隐藏维度2048
Layers24
Attention Heads32
词表大小108986
权重格式safetensors
框架PyTorch (transformers)

4. Conda 环境安装

conda create -n sarashina-tts python=3.11 -y
conda activate sarashina-tts
pip install torch==2.10.0 torchvision==0.25.0 --index-url https://repo.huaweicloud.com/repository/pypi/simple/
pip install torch_npu==2.10.0 --index-url https://repo.huaweicloud.com/repository/pypi/simple/
pip install transformers safetensors --index-url https://repo.huaweicloud.com/repository/pypi/simple/

5. 推理执行

python3 inference.py --model_path /path/to/sarashina2.2-tts
python3 inference.py ... --device cpu --text "こんにちは"
python3 benchmark.py --model_path /path/to/sarashina2.2-tts

6. 参数说明

脚本参数默认值
inference.py--devicenpu:0
inference.py--textNone (随机输入)
benchmark.py--npu_devicenpu:0
benchmark.py--num_warmup3

7. 精度评测结果

评测方法

随机 token 输入(batch=1, seq=128),对比 CPU(FP32)和 NPU(FP32)输出 logits。

多维度精度指标

指标类别指标实测值阈值状态
Overall向量级相对误差0.000114%< 1%PASS ✅
余弦相似度1.0000001192> 0.99PASS ✅
SNR (dB)117.51——
Absolute ErrorMax1.43e-04——
Mean1.28e-05——
P953.15e-05——
P993.91e-05——
Element-wise RelMax139.84%——
Mean0.0002%——
P950.0002%——
Per-PositionMax Pos Error2.82e-05——
Mean Pos Error1.28e-05——

判定结论

指标实测值阈值状态
向量级相对误差0.0001%< 1%PASS ✅

8. 性能数据

操作耗时
CPU(FP32)4.14s
NPU(FP32,3轮预热)0.04s
加速比97.30x

9. 注意事项

  1. 使用 AutoModelForCausalLM 标准 transformers 接口。
  2. 模型为日语 TTS,输入文本需为日文。
  3. 精度接近无损(FP32),向量级相对误差极小。