Instructions to use mlx-community/Dia2-2B-bf16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use mlx-community/Dia2-2B-bf16 with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] hf download mlx-community/Dia2-2B-bf16 --local-dir Dia2-2B-bf16
- Dia2
How to use mlx-community/Dia2-2B-bf16 with Dia2:
from dia2 import Dia2, GenerationConfig, SamplingConfig dia = Dia2.from_repo("mlx-community/Dia2-2B-bf16", device="cuda", dtype="bfloat16") config = GenerationConfig( cfg_scale=2.0, audio=SamplingConfig(temperature=0.8, top_k=50), use_cuda_graph=True, ) result = dia.generate("[S1] Hello Dia2!", config=config, output_wav="hello.wav", verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Atomic Chat
Dia2-2B β MLX, bf16
nari-labs/Dia2-2B is Nari Labs' two-speaker dialogue TTS: a
script with [S1] / [S2] turns renders as one take in which both speakers trade lines. This repo is that
checkpoint converted for MLX-Swift. It is the weights repo of
mlx-dia2-tts-swift, a Swift port of upstream's runtime and
an MLXEngine tts package.
| file | what | dtype |
|---|---|---|
model.safetensors |
the Dia2 decoder (28 Γ 2048, GQA 16/8) + depformer (4 Γ 1024, 5 weight sets) β upstream's keys, unchanged | bf16 (RMSNorm weights float32 at load) |
mimi.safetensors |
Kyutai's Mimi codec (32 codebooks, 12.5 Hz, 24 kHz), re-keyed onto the module layout of kyutai-labs/moshi-swift |
float32 |
config.json, tokenizer files |
upstream's config (+ "mimi": {"num_codebooks": 32}) and its GPT-2 BPE tokenizer |
β |
Layout note. model.safetensors keeps upstream's keys. mimi.safetensors is in moshi-swift's layout: fused
attention in_proj with q/k back in Kyutai's interleaved RoPE order, and conv weights as MLX (O, K, I). Loaders
expecting transformers' MimiModel keys will not read it.
Conversion
Sources:
nari-labs/Dia2-2B@7abae125471a73b0fc6b9d413cb15f4ae1e771d8kyutai/mimi@89091b3e466eb6a9d11e537bf26b144f194978f7
python Tools/oracle-capture/convert.py Dia2-2B-bf16 --size 2B --dtype bfloat16 # in mlx-dia2-tts-swift
Parity and measurements
The Swift port is gated against upstream's PyTorch runtime (nari-labs/dia2 @ 8687268) in fp32. From the
package's PORTING-SPEC.md / MEASUREMENTS.md:
- Gates: the tokenizer is id-exact; the decoder is within 1.05e-5. Every one of 4 257 sampled distributions matches upstream within total variation 1.1e-5, except one documented near-tie at the CFG filter's boundary. Codes are token-exact under replay; the waveform is within 114β118 dB.
- This tier:
- On upstream's own evaluation jobs it scores within sampling noise of upstream's fp32 run (scenes, single lines, voice prefixes).
- On an M5 Max the package declares 4.5 GB resident + 3.0 GB activation (measured phys_footprint, including MLXEngine's 2 GiB buffer pool). The model's own working set is β€ 1.2 GB, flat over takes of 3β101 s. It runs at β 1.8Γ realtime.
Use (Swift)
import MLXServeCore
import MLXDia2TTS
let engine = MLXServeEngine()
try await engine.register(Dia2TTSPackage.registration, configuration: Dia2TTSConfiguration())
try await engine.prepare(.tts)
let wav = try await engine.run(TTSRequest(
text: "[S1] Did you hear that? [S2] Hear what? It's the wind. [S1] No, it was a voice.",
metaData: ["seed": .int(7)]))
Voice prefixes: voice: .referenceAudio(clip) + referenceTranscript set speaker 1. Speaker 2 is set with
metaData speaker2Audio (a base64 .wav) + speaker2Transcript. Prefix both speakers for a consistent pair; a
single prefix conditions only weakly.
Licence
- Dia2:
model.safetensors,config.jsonand the tokenizer files arenari-labs/Dia2-2B, Apache License 2.0 (LICENSE), Β© Nari Labs. Changes: cast to bfloat16, plus the"mimi"entry inconfig.json. - Mimi:
mimi.safetensorsis Mimi by Kyutai, fromkyutai/mimi, licensed CC-BY-4.0. Changes: re-keyed to the moshi-swift layout, attention q/k un-permuted and re-fused, conv weights transposed, stored float32.
- Downloads last month
- -
Quantized
Model tree for mlx-community/Dia2-2B-bf16
Base model
nari-labs/Dia2-2B