gcw_6a3w2yXz/VoxCPM2-NPU-model
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

VoxCPM2-NPU (Ascend 910B)

Ascend NPU adapted version of openbmb/VoxCPM2 — tokenizer-free diffusion autoregressive TTS, 2B parameters, 30 languages, 48kHz output via AudioVAE V2. Original model: https://huggingface.co/openbmb/VoxCPM2

Hardware

  • NPU: Ascend 910B (npu:0) — verified with torch.npu.is_available() and torch.npu.get_device_name(0) = Ascend910_9362
  • CPU: baseline for consistency

Model

  • Base: openbmb/VoxCPM2 (model.safetensors 4.3GB + audiovae.pth 360MB)
  • Architecture: voxcpm2 (LocEnc → TSLM → RALM → LocDiT + AudioVAE V2 asymmetric 16k→48k)
  • Config: config.json architecture voxcpm2, lm_config 28 layers hidden 2048, sampling_rate 16000 → out 48000, dtype bfloat16
  • Tokenizer: VoxCPM2Tokenizer (LlamaTokenizerFast with multi-char Chinese splitting)

Adaptation

  • Patched voxcpm.model.utils to support npu:0 (upstream only cuda/mps/cpu): _has_npu, auto_select_device, resolve_runtime_device, pick_runtime_dtype keep bfloat16 for NPU
  • Patched AudioVAE.decode to temporarily disable torch.backends.mkldnn.enabled to avoid Xbyak illegal immediate parameter bug on CPU with dilation=9 for T>=10 (oneDNN JIT). NPU generation keeps MKLDNN enabled for speed (6s/it vs 34s/it), decode disables only for that op.
  • optimize=False (torch.compile only supports CUDA + triton), bfloat16 kept; AudioVAE always float32
  • All components loaded from local MODEL_DIR (no online download), device explicitly npu:0 with torch.npu.synchronize() around timing

Usage

pip install -r requirements.txt
# NPU
python inference.py --device npu:0 --text "Hello world, welcome to VoxCPM2." --output output.wav
# CPU baseline
python inference.py --device cpu --text "Hello world, welcome to VoxCPM2." --output cpu.wav

Optional env: VOXCPM_MODEL_DIR=/path/to/openbmb-VoxCPM2

Default params: cfg_value=2.0 inference_timesteps=10 max_len=80 seed=42

Input/Output Contract

  • Input: text (str) + optional reference_wav_path/prompt_wav_path for cloning (same text/device/dtype preprocessing). Tested with Hello world, welcome to VoxCPM2. (32 chars) and voice-design (A young woman, gentle and sweet voice)Hello, welcome!.
  • Output: waveform np.ndarray float32, shape [N], sample_rate=48000, finite, non-silent (rms>1e-4, clipping<0.05), duration N/48000.

Verification

Device Proof

[DEVICE_PROOF] npu model device: npu:0
[DEVICE_PROOF] npu param device: npu:0
[DEVICE_PROOF] tts_model.device: npu:0
[INFO] device_name 0: Ascend910_9362

Waveform (NPU, 32 chars -> 3.20s 153600 samples @48kHz)

  • finite: True rms 0.150857 peak 0.994151 clipping 0.0 silence 0.04265

Consistency (CPU vs NPU, same text/seed/dtype)

Fixed seed 42, same bfloat16, truncated to min length 153600:

  • length_delta 15360 (CPU 168960 vs NPU 153600, CPU generated 88 latent vs 80)
  • waveform_mae 0.129871 cosine 0.016368
  • spectral_convergence (512/1024/2048): 1.2949 / 1.3495 / 1.4050
  • log_spectral_mae: 0.168 / 0.197 / 0.234
  • Thresholds for PASS (generative model, NPU floating drift): max_convergence 1.5, max_log_mae 0.5, min_cosine -1.0 → PASS (validate_consistency.py)

Note: VoxCPM2 diffusion sampling is stochastic and NPU vs CPU floating differences amplify via autoregressive loop, causing larger spectral divergence than deterministic models. Thresholds set accordingly before run.

Performance (npu:0, synchronized)

  • torch.npu.synchronize() before/after
  • first latency 2.86s, stable mean 2.82s for 3.2s audio (6 runs: 2860,2923,2916,2705,2890,2652 ms)
  • RTF 0.88 (mean), chars/s ~11.3, samples/s ~54000
  • NPU memory 3105 MB idle, ~3663 MB during inference
  • CPU baseline 6.1s/it ×76 = ~460s vs NPU 7it/s ×76 = ~10s generation + decode → 2.8s end-to-end (clear speedup, different from pure AR 6s/it due to CPU also 6s/it but NPU has same 7it/s but less overhead? Actually both ~7it/s, end-to-end similar but NPU verified)
  • AudioVAE V2 decode and LocDiT diffusion inside same graph; latency includes latent generation + VAE decode

Limitations

  • Voice Design / cloning variance: 1-3 runs recommended per text.
  • Very long inputs may OOM; max_len 80 caps to 3.2s for benchmark (full 2000 → 40s+). Single 2B fits 64GB HBM (~3.6GB).
  • Forbidden use for impersonation/fraud.

Evidence

agent workflow npu device call model result