g
gcw_AVRCax4T/chat-daiyu-sovits
模型介绍文件和版本Pull Requests讨论分析
下载使用量0

chat-daiyu-sovits(昇腾NPU适配)

模型介绍

chat-daiyu-sovits是基于GPT-SoVITS S1自回归(AR)模型进行微调得到的黛玉语音克隆模型。本仓库包含昇腾NPU适配版本,可在华为昇腾910硬件上实现高性能推理。

  • 模型架构:GPT-SoVITS S1 AR(24层Transformer)
  • 参数规模:77,494,787
  • 原始模型:Omelette/chat-daiyu-sovits
  • 任务类型:文本转语义令牌(GPT-SoVITS流水线的S1阶段)
  • 支持语言:中文(zh-CN)
  • 适配目标:昇腾910 NPU(CANN 8.5.1,torch_npu 2.9.0)

快速开始

环境要求

组件版本
CANN8.5.1
torch2.9.0
torch_npu2.9.0.post1
Python3.11
昇腾NPU910

模型下载

pip install modelscope
modelscope download --model Omelette/chat-daiyu-sovits --local_dir ./chat-daiyu-sovits

推理

# Precision evaluation (CPU vs NPU)
python inference.py --mode eval --checkpoint ./chat-daiyu-sovits/daiyu-voice-e12.ckpt

# Performance benchmark
python inference.py --mode benchmark --checkpoint ./chat-daiyu-sovits/daiyu-voice-e12.ckpt

# Single inference demo
python inference.py --mode inference --checkpoint ./chat-daiyu-sovits/daiyu-voice-e12.ckpt

Python API

import torch
from inference import ARModel, build_model_from_checkpoint

# Load model on NPU
model, config = build_model_from_checkpoint(
    "./chat-daiyu-sovits/daiyu-voice-e12.ckpt",
    device="npu:0"
)

# Prepare inputs
bert_features = torch.randn(1, 15, 1024, device="npu:0")  # BERT semantic features
text_tokens = torch.randint(0, 512, (1, 8), device="npu:0")  # Text phoneme tokens

# Generate audio tokens
audio_tokens = model.generate(bert_features, text_tokens, max_new_tokens=100, top_k=5)
print(f"Generated {audio_tokens.shape[1]} audio tokens")

精度评估

NPU 推理精度已针对 CPU(float32)基准进行验证,结果如下:

指标结果阈值状态
前向相对误差0.073%< 1%PASS
余弦相似度1.0000001> 0.9999PASS
Top-1 准确率100.0%> 99%PASS
Top-5 准确率100.0%> 99%PASS
Top-10 准确率100.0%> 99%PASS
贪婪生成匹配度100.0%> 98%PASS
总体精度PASS-PASS

逐层精度

层最大绝对差值
Embedding(Layer 0)1.53e-05
Layer 12(中间层)0.055
Output(Layer 24)0.041

性能基准测试

环境:Ascend 910 NPU x2,CANN 8.5.1

前向传播

指标NPUCPU加速比
平均延迟9.57 ms244.35 ms25.5x
标准差0.10 ms--
吞吐量208.9 samples/s8.2 samples/s25.5x

自回归生成

指标值
平均生成时间(50 个 token)0.41 s
Token 生成速率21.8 tokens/s

内存使用

类型使用量
已分配310.9 MB
已预留328.0 MB

模型架构详情

GPT-SoVITS S1 AR Model (77.5M parameters)
├── BERT Projection: Linear(1024 → 512)
├── Text Embedding: Embedding(512 × 512)
├── Audio Embedding: Embedding(1025 × 512)
├── Sine Positional Encoding (x2, with learnable alpha)
├── Transformer Layers ×24
│   ├── Self-Attention (16 heads, head_dim=32)
│   ├── FFN (Linear 512→2048, GELU, 2048→512)
│   └── Pre-LayerNorm
└── Output Head: Linear(512 → 1025)

目录结构

chat-daiyu-sovits-npu/
├── inference.py          # NPU inference script
├── eval_results.json     # Precision & performance results
├── run_eval.log         # Evaluation run log
└── README.md            # This document

已知问题

  • 警告消息:在当前CANN环境下,torch_npu可能会出现非关键性的权限/所有权警告。这些警告不会影响功能或精度。
  • Top-K采样随机性:当使用top_k > 0时,NPU与CPU之间微小的浮点差异可能导致不同的采样路径。若需确定性输出对比,请使用top_k=0(贪婪模式)。

许可证

本适配版本遵循Apache License 2.0协议发布,与原始模型许可证保持一致。

引用

@misc{chat-daiyu-sovits-npu,
  title = {chat-daiyu-sovits Ascend NPU Adaptation},
  author = {Ascend NPU Adaptation},
  year = {2026},
  url = {https://modelscope.cn/Omelette/chat-daiyu-sovits},
}