Skip to main content

MOSS-TTS Local Transformer v1.5 on TTNN

TTNN inference implementation of OpenMOSS-Team/MOSS-TTS-Local-Transformer-v1.5, including the global transformer, local audio-code generator, and MOSS Audio Tokenizer v2 waveform decoder.

This document is a handoff for running the model from a fresh checkout. Run all commands from the tt-metal-e2 repository root unless stated otherwise.

Prerequisites​

  • A working TT-Metal checkout and TTNN Python environment.
  • A visible TT device, normally device 0.
  • Hugging Face access for the MOSS checkpoints.
  • At least 8 GB of free disk space for the audio-tokenizer safetensor shards, plus space for the main MOSS-TTS checkpoint.

The tested Python package baseline is:

PackageVersion
Transformers>=4.53,<5.0
NumPy1.26.4
Pandas2.2.3
Scikit-learn1.5.2
PyTorch2.7.1
Torchvision0.22.1
Torchaudio2.7.1

On x86_64, the PyTorch packages use the matching +cpu wheels.

Setup​

Activate the repository environment:

cd path/to/tt-metal-e2
source env_set.sh
python --version

Install the model dependencies:

pip install -r models/bos_model/audio/moss-tts-local-transformer-v1.5/requirements.txt

The requirements file reuses packages that already satisfy the requested versions. In the tested repository environment, pandas and scikit-learn may be changed to the model-specific versions, while torchaudio is installed if it is not already present.

Verify the core imports:

python - <<'PY'
import torch
import torchvision
import torchaudio
import transformers
import ttnn

print("torch =", torch.__version__)
print("torchvision =", torchvision.__version__)
print("torchaudio =", torchaudio.__version__)
print("transformers=", transformers.__version__)
print("ttnn import = OK")
PY

Download the Audio Tokenizer Weights​

The audio-tokenizer Python source and configuration are checked in, but its safetensor weight shards must be downloaded separately. From the repository root, run:

hf download OpenMOSS-Team/MOSS-Audio-Tokenizer-v2 \
--include "*.safetensors" \
--local-dir models/bos_model/audio/moss-tts-local-transformer-v1.5/tt/core/audio_tokenizer_v2

Confirm that all three shards are present:

ls -lh models/bos_model/audio/moss-tts-local-transformer-v1.5/tt/core/audio_tokenizer_v2/*.safetensors

The local TTNN runner automatically uses this directory for waveform decoding. No --codec-path argument is required when the weights are stored there.

The main MOSS-TTS checkpoint is downloaded automatically from Hugging Face on the first run. To download it ahead of time, use:

hf download OpenMOSS-Team/MOSS-TTS-Local-Transformer-v1.5 \
--local-dir /path/to/MOSS-TTS-Local-Transformer-v1.5

Pass that local directory to --model and add --local-files-only for an offline run.

Check the TT Device​

python - <<'PY'
import ttnn

device = ttnn.open_device(device_id=0)
print("TTNN device 0 opened successfully")
ttnn.close_device(device)
PY

Resolve device or driver errors before loading the model.

Run TTNN Inference​

Change to the model directory so the commands and local asset paths stay short:

cd models/bos_model/audio/moss-tts-local-transformer-v1.5

python tt/demo_ttnn.py \
--device-id 0 \
--model OpenMOSS-Team/MOSS-TTS-Local-Transformer-v1.5 \
--text="Hello, this is a MOSS-TTS TTNN test." \
--language English \
--reference-audio reference/example_audio/woman2_audio_48k.wav \
--max-new-tokens 64

The first run is slower because it downloads or reads the main checkpoint, converts weights to TTNN tensors, and loads the audio decoder onto the device. The final log should include model-load timing, token metrics, audio length, RTF, and the output WAV path.

When --output is omitted, files are written under outputs/ using the name output_ttnn_<timestamp>.wav.

Offline Run​

python tt/demo_ttnn.py \
--device-id 0 \
--model /path/to/MOSS-TTS-Local-Transformer-v1.5 \
--local-files-only \
--text="Hello, this is a MOSS-TTS TTNN test." \
--language English \
--max-new-tokens 64

The offline command is text-only and does not use --reference-audio.

Voice Cloning​

Pass one local file or URL through --reference-audio:

python tt/demo_ttnn.py \
--device-id 0 \
--model OpenMOSS-Team/MOSS-TTS-Local-Transformer-v1.5 \
--text "This sentence uses the reference voice." \
--language English \
--reference-audio /path/to/reference.wav \
--max-new-tokens 256 \
--output outputs/moss_tts_voice_clone.wav

Voice cloning additionally loads the CPU audio-tokenizer encoder, so it uses more host memory and takes longer to initialize than text-only inference.

Common Command-Line Options​

Input and Generation​

OptionDefaultDescription
--textBuilt-in English test sentenceText to synthesize.
--languageEnglishLanguage label included in the conversation prompt.
--reference-audioNoneOptional reference voice path or URL.
--tokensNoneOptional duration-control token count.
--max-new-tokens32Maximum number of MOSS output frames. This is a cap, not a guaranteed output length.
--greedyDisabledUse deterministic greedy generation instead of sampling.
--audio-temperature1.0Audio-code sampling temperature.
--audio-top-k50Audio top-k value. Only 50 is currently supported.
--audio-top-p1.0Audio top-p value. Only 1.0 is currently supported.
--audio-repetition-penalty1.0Repetition penalty for generated audio codes.
--seed0Random seed used by the runner.

For a reproducible smoke test, add --greedy. For normal quality evaluation, use the generation settings required by the experiment rather than assuming greedy output is representative.

--audio-top-k and --audio-top-p are exposed by the CLI for compatibility and future extension, but the current TTNN implementation only accepts their default values (50 and 1.0, respectively).

TTNN Runtime and Output​

OptionDefaultDescription
--device-id0TT device used for inference.
--batch-size1Batch size. Only batch size 1 is currently supported.
--threadsRuntime defaultOptional host-side PyTorch thread count.
--local-files-onlyDisabledPrevent Hugging Face from downloading missing files.
--outputTimestamped file under outputs/WAV output path.
--summaryDisabledPrint model parameter counts and module information.

The current TTNN implementation supports only --batch-size 1. Other batch sizes are rejected by the command-line parser.

The demo's configurable model dtype is fixed to bfloat16; selected kernels may use internal fixed-precision optimizations.

Run the CPU Reference​

Use the reduced reference implementation to validate prompts or compare audio codes independently of TTNN:

python reference/demo_reference.py \
--device cpu \
--text "Hello, this is a reference inference test." \
--language English \
--max-new-tokens 128 \
--attention eager

CPU inference is intended for correctness checks and can be substantially slower than the TTNN path.

Benchmark​

The standard runner can load the model once, perform warmup runs, and report average end-to-end measurements:

python tt/demo_ttnn.py \
--device-id 0 \
--model OpenMOSS-Team/MOSS-TTS-Local-Transformer-v1.5 \
--text "MOSS-TTS benchmark sentence." \
--language English \
--max-new-tokens 128 \
--benchmark \
--benchmark-warmup 2 \
--benchmark-iterations 10

Unsupported Features​

The following runtime modes are not supported by this handoff:

  • Batch sizes other than 1.
  • Audio top-k values other than 50.
  • Audio top-p values other than 1.0.
  • Two command queues (2CQ).
  • TTNN trace capture or trace replay.
  • Tracy profiling.

Use the default single-command-queue, non-trace execution path shown above.

Troubleshooting​

Audio-tokenizer weights are missing​

Typical errors include No safetensors checkpoint found or a missing shard referenced by model.safetensors.index.json. Re-run the required download:

hf download OpenMOSS-Team/MOSS-Audio-Tokenizer-v2 \
--include "*.safetensors" \
--local-dir models/bos_model/audio/moss-tts-local-transformer-v1.5/tt/core/audio_tokenizer_v2

--local-files-only fails​

This flag applies to the main model and any explicitly selected codec path. Make sure the complete main checkpoint has already been downloaded and pass its local directory through --model.

Unsupported generation arguments​

The current implementation only supports:

--batch-size 1
--audio-top-k 50
--audio-top-p 1.0

Using another value for one of these options is rejected by the command-line parser.

TTNN cannot open the device​

Re-run the device check above in the same shell used for inference. Confirm that source env_set.sh completed successfully and that no other process owns the target device.

Import errors when running Python directly​

After sourcing env_set.sh, run the TTNN entrypoint from the model directory as shown above. Avoid importing files as top-level core.* modules; the TT implementation is packaged under tt.* and uses package-relative imports.

Output is unexpectedly short or long​

--max-new-tokens is only an upper bound. The model may stop earlier. Check the printed Input tokens, Output tokens/frames, Output RVQ tokens, and saved audio duration before treating the maximum as the generated length.

Handoff Checklist​

Before handing the setup to another engineer, verify:

  1. source env_set.sh succeeds.
  2. TTNN device 0 opens and closes successfully.
  3. All audio-tokenizer safetensor shards are present in the required local directory.
  4. The minimal TTNN command creates a WAV file under outputs/.
  5. The run prints MOSS token metrics and completes without entering a fallback debugger.
  6. The TTNN runner rejects unsupported batch-size, audio-top-k, and audio-top-p values.