MOSS-TTS-Nano is an open-source multilingual tiny speech generation model from MOSI.AI and the OpenMOSS team. With only 0.1B parameters, it is designed for realtime speech generation, can run directly on CPU without a GPU, and keeps the deployment stack simple enough for local demos, web serving, and lightweight product integration.
This repository contains the Ascend NPU adapted version of MOSS-TTS-Nano, enabling efficient inference on Huawei Ascend AI processors.
| Attribute | Value |
|---|---|
| Model Name | MOSS-TTS-Nano-100M |
| Architecture | GPT-2 based Causal LM + Audio Tokenizer |
| Parameters | 0.1B (100M) |
| Languages | 20 languages (zh, en, de, es, fr, ja, it, he, ko, ru, fa, ar, pl, pt, cs, da, sv, hu, el, tr) |
| Audio Format | 48 kHz, 2-channel (stereo) |
| Base Model | OpenMOSS-Team/MOSS-TTS-Nano |
| Adaptation Type | PyTorch torch_npu migration |
| Attention Backend | SDPA (on NPU), Flash Attention 2 (on CUDA) |
| Item | Details |
|---|---|
| Original Repository | https://atomgit.com/OpenMOSS/MOSS-TTS-Nano-100M.git |
| Adaptation Date | 2026-05-16 |
| Adaptation Status | Completed |
| NPU Compatibility | Ascend 910B / 910B3 / Atlas 800 A2 / Atlas 800 A3 |
| CANN Version | >= 8.0.RC2 |
| PyTorch Version | >= 2.1.0 |
| torch_npu Version | >= 2.1.0 |
| Precision Mode | FP16 (recommended), FP32, BF16 |
modeling_moss_tts_nano.py and gpt2_decoder.py for CUDA-specific APIs and device assumptions.cuda only to cuda and npu across memory management, attention backend selection, and flash attention validation.torch.npu.memory_stats support for voice-clone batch size resolution on NPU devices.infer_npu.py and verify_npu.py for end-to-end NPU inference and verification.| Configuration | Specification |
|---|---|
| NPU | Ascend 910B3 / 910B (Atlas 800 A2 / A3) |
| NPU Memory | >= 32 GB HBM |
| CPU | >= 8 cores |
| RAM | >= 32 GB |
# 1. Install CANN Toolkit (requires root or sudo)
# Download from: https://www.hiascend.com/software/cann/community
# Follow the official installation guide for your OS.
# 2. Verify CANN environment
source /usr/local/Ascend/ascend-toolkit/set_env.sh
# 3. Install PyTorch and torch_npu
pip install torch==2.1.0
pip install torch_npu==2.1.0 # Match your CANN version
# 4. Install model dependencies
pip install transformers>=4.57.1
pip install torchaudio
pip install numpyexport PYTORCH_NPU_ALLOC_CONF=expandable_segments:True
export TASK_QUEUE_ENABLE=1
export ASCEND_SLOG_PRINT_TO_STDOUT=0
export ASCEND_GLOBAL_LOG_LEVEL=3modeling_moss_tts_nano.pyChange A: NPU Memory Stats for Batch Size Resolution
# Before
if chunk_count <= 1 or max_memory_per_sample_gb <= 0 or resolved_device.type != "cuda":
return 1
free_bytes, _ = torch.cuda.mem_get_info(resolved_device)
# After
if chunk_count <= 1 or max_memory_per_sample_gb <= 0 or resolved_device.type not in ("cuda", "npu"):
return 1
if resolved_device.type == "cuda" and hasattr(torch.cuda, "mem_get_info"):
free_bytes, _ = torch.cuda.mem_get_info(resolved_device)
elif resolved_device.type == "npu" and hasattr(torch.npu, "memory_stats"):
mem_stats = torch.npu.memory_stats(resolved_device)
free_bytes = mem_stats.get("allocated_bytes.all.current", 0)Change B: Attention Backend Fallback for NPU
# Before
return "sdpa" if device.type == "cuda" else "eager"
# After
return "sdpa" if device.type in ("cuda", "npu") else "eager"gpt2_decoder.pyChange C: Flash Attention Device Check
# Before
if query.device.type != "cuda":
raise ValueError("flash_attention_2 requires CUDA tensors.")
# After
if query.device.type not in ("cuda", "npu"):
raise ValueError("flash_attention_2 requires CUDA or NPU tensors.")| File | Purpose |
|---|---|
infer_npu.py | End-to-end NPU inference script with auto device detection |
verify_npu.py | Multi-device (NPU/CUDA/CPU) verification and precision comparison |
# Single voice-clone inference on NPU
python infer_npu.py \
--prompt-audio-path assets/audio/zh_1.wav \
--text "欢迎使用昇腾NPU进行语音合成。" \
--output-path generated_audio/npu_output.wav \
--device npu \
--dtype float16# Automatically picks NPU > CUDA > CPU
python infer_npu.py \
--prompt-audio-path assets/audio/zh_1.wav \
--text "欢迎使用昇腾NPU进行语音合成。" \
--device autopython verify_npu.py \
--model-path . \
--prompt-audio-path assets/audio/zh_1.wav \
--text "欢迎使用昇腾NPU进行语音合成测试。" \
--output-dir ./verification_resultsThe verification script will:
./verification_results/npu_verification_report.jsonSince MOSS-TTS-Nano uses autoregressive sampling with temperature-based decoding, bitwise-identical outputs across devices are not expected. Instead, we verify:
NaN, Inf, or device-side assert errors during generation.| Device | Attention | Dtype | Load Status | Inference Status | Notes |
|---|---|---|---|---|---|
| NPU | SDPA | FP16 | Pass | Pass | Primary target device |
| CUDA | SDPA | FP16 | Pass | Pass | Baseline GPU comparison |
| CPU | Eager | FP32 | Pass | Pass | Reference baseline |
temperature and top_p sampling, audio waveforms will differ slightly across runs and devices. This is expected for generative TTS models.| Metric | CPU (4-core) | CUDA (RTX 4090) | NPU (Ascend 910B) |
|---|---|---|---|
| Model Load | ~2s | ~1s | ~1.5s |
| Voice Clone (short) | ~5-10s | ~1-2s | ~2-3s |
| Realtime Factor | ~0.5x | ~5x | ~3-4x |
| Memory (FP16) | ~2 GB RAM | ~2 GB VRAM | ~2 GB HBM |
Note: Actual NPU performance depends on CANN version, driver, and specific NPU model (910B vs 910B3). The above are estimated ranges based on model size and architecture.
voice_clone_max_text_tokens, voice_clone_max_memory_per_sample_gb).export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True
export TASK_QUEUE_ENABLE=1MOSS-TTS-Nano-100M-NPU/
├── assets/
│ └── images/ # Model architecture diagrams and logos
├── modeling_moss_tts_nano.py # Main model (NPU-compatible)
├── gpt2_decoder.py # GPT-2 decoder (NPU-compatible)
├── configuration_moss_tts_nano.py
├── tokenization_moss_tts_nano.py
├── prompting.py
├── infer_npu.py # NPU inference entrypoint
├── verify_npu.py # Multi-device verification script
├── config.json
├── pytorch_model.bin
├── tokenizer.model
├── tokenizer_config.json
├── special_tokens_map.json
└── README.md # This fileinference_stream() is supported on NPU but has not been benchmarked for latency-optimized streaming.torch.npu.memory_stats; accuracy depends on CANN version.| Issue | Cause | Solution |
|---|---|---|
torch_npu import error | CANN not installed or not sourced | Run source /usr/local/Ascend/ascend-toolkit/set_env.sh |
flash_attention_2 error on NPU | Flash Attention requires CUDA | Use --attn-implementation sdpa or --device auto |
| Out of memory on NPU | Batch size too large | Reduce voice_clone_max_memory_per_sample_gb or use FP16 |
| Slow inference on NPU | Using FP32 or Eager attention | Ensure FP16 + SDPA are active |
| Device-side assert | Incompatible dtype or attention | Check dtype is FP16/BF16; avoid Flash Attention on NPU |
This adaptation is maintained for the Ascend NPU ecosystem. For issues specific to the original model, please refer to the OpenMOSS/MOSS-TTS-Nano repository.
This repository follows the license specified in the root LICENSE file. The original MOSS-TTS-Nano model is licensed under Apache 2.0.
If you use the MOSS-TTS work in your research or product, please cite:
@misc{openmoss2026mossttsnano,
title={MOSS-TTS-Nano},
author={OpenMOSS Team},
year={2026},
howpublished={GitHub repository},
url={https://github.com/OpenMOSS/MOSS-TTS-Nano}
}@misc{gong2026mossttstechnicalreport,
title={MOSS-TTS Technical Report},
author={Yitian Gong and Botian Jiang and Yiwei Zhao and Yucheng Yuan and Kuangwei Chen and Yaozhou Jiang and Cheng Chang and Dong Hong and Mingshu Chen and Ruixiao Li and Yiyang Zhang and Yang Gao and Hanfu Chen and Ke Chen and Songlin Wang and Xiaogui Yang and Yuqian Zhang and Kexin Huang and ZhengYuan Lin and Kang Yu and Ziqi Chen and Jin Wang and Zhaoye Fei and Qinyuan Cheng and Shimin Li and Xipeng Qiu},
year={2026},
eprint={2603.18090},
archivePrefix={arXiv},
primaryClass={cs.SD},
url={https://arxiv.org/abs/2603.18090}
}