Commit c4d460f
Add PersonaPlex / Moshi full-duplex S2S support (Mimi codec + Moshi LM + ORT example) (#368)
Adds end-to-end ONNX support for
[`nvidia/personaplex-7b-v1`](https://huggingface.co/nvidia/personaplex-7b-v1),
the Kyutai **Moshi** full-duplex speech-to-speech architecture, built
declaratively with `onnxscript.nn` from the native Kyutai `safetensors`
checkpoints (no HF `config.json`).
Three phases, one PR:
### P1 — Mimi neural codec (commit `0fc84c1`)
SEANet encoder/decoder + split-RVQ + codec transformer. Encoder codes
exact, decode ~2e-7 vs reference. Root cause fixed: Kyutai LayerNorm eps
is `1e-5` (mobius default was `1e-6`).
### P2 — Moshi LM (temporal + depformer)
- `models/moshi.py`:
- **MoshiTemporalModel** — dim=4096, 32L, 32H, RoPE θ=1e4 interleaved,
sliding-window causal (3000), SwiGLU via `FusedGateUpMLP`, RMSNorm
eps=1e-8.
- **MoshiDepformerModel** — dim=1024, 6L, no RoPE, full causal,
`weights_per_step=16` per-substep linears; emitted as a **one-substep
graph** selected by `substep_index` (Gather), embedding select via
`Where` (no `If`), looped 16× externally.
- `tasks/_moshi.py`: `MoshiTemporalTask` (`input_frame[B,17,S]` + KV →
hidden + text_logits + KV) and `MoshiDepformerTask` (`hidden` +
`prev_token` + `substep_index` + KV → logits + KV).
- `integrations/moshi`: `build_moshi_lm()` native loader → `{"temporal",
"depformer"}` ModelPackages.
- **Parity:** exact argmax match vs the Kyutai reference (CPU exact;
CUDA exact with `use_tf32=0` — H200 TF32 otherwise flips greedy
sampling). Committed golden + generator script; integration parity test
(CPU-only) **passes**.
### P3 — ONNX Runtime example
- `examples/personaplex_moshi.py`: faithful NumPy port of Kyutai
`LMGen.step` — ring cache with per-codebook delays
`[0,0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1]`, temporal step, greedy text
sampling, 16-substep autoregressive depformer, delayed output collection
— driving four ORT sessions (Mimi encoder/decoder + temporal +
depformer) for full-duplex S2S. Verified end to end (5 input frames → 3
assistant frames → decoded waveform).
## Testing
- L1 build tests for temporal + depformer pass; full moshi/mimi/codec L1
suite green (9 tests).
- Integration parity test passes (`tests/moshi_lm_integration_test.py`,
~280s, CPU).
- Example verified end-to-end (build + generate + Mimi decode →
`assistant.wav`).
- Lint clean on new files.
> Note: the temporal/depformer reach mobius only via the native
`build_moshi_lm` loader (not the standard `build(model_id)` registry
path), consistent with the Mimi codec which also uses a native
Kyutai-format loader.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Signed-off-by: Justin Chu <11205048+justinchuby@users.noreply.github.com>
Co-authored-by: Justin Chu <11205048+justinchuby@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent a49e0f8 commit c4d460f
20 files changed
Lines changed: 4415 additions & 2 deletions
File tree
- examples/personaplex
- static
- voices
- scripts
- src/mobius
- components
- integrations/moshi
- models
- tasks
- testdata/golden/audio
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
0 commit comments