mlboydaisuke commited on
Commit
f1a5159
·
verified ·
1 Parent(s): 233fb41

Replace the language-model graph with a faster one

Browse files

graphs/lm_step_p768.tflite now computes only the two experts that the router picks in each MoE layer; its inputs and outputs are unchanged, and it gave the same codes and WAV as before for the six prepared sentences. The card, HOST.md and kit/MANIFEST.json now describe the new graph.

Files changed (4) hide show
  1. HOST.md +2 -2
  2. README.md +6 -6
  3. graphs/lm_step_p768.tflite +2 -2
  4. kit/MANIFEST.json +3 -3
HOST.md CHANGED
@@ -16,7 +16,7 @@ The last argument must be a new directory. It receives codes.i32, waveform.f32 a
16
 
17
  ## Kit contract
18
 
19
- kit/MANIFEST.json describes the graph form (`"form": "F"` = the fp32 graphs in graphs/), four CPU threads, Savannah, six tagged requests and little-endian byte order. Its files dictionary maps kit-relative payload paths to byte counts and SHA-256. Its graph records carry paths relative to the release root, byte counts and SHA-256. The graph files are external to the kit.
20
 
21
  | Input | On-disk representation |
22
  |---|---|
@@ -25,7 +25,7 @@ kit/MANIFEST.json describes the graph form (`"form": "F"` = the fp32 graphs in g
25
  | takes/TAG/silence.i32 | Three delayed prefill rows of ten little-endian int32 audio IDs. |
26
  | takes/TAG/draws.f32 | One float32 [10,4098] matrix of independent unit-rate exponential draws per sampled row. The stream contains 769−P rows, enough through the last LM position. |
27
  | shared/ | Generation embedding tables [10,4098,1024] plus the text-pad vector [1024], LM RoPE cosine/sine [768,16], ten codec codebooks [10,4096,8], decoder RoPE and five causal window masks, Hann windows, mixer and resampler coefficients. All use contiguous float32 in row-major order. |
28
- | takes/TAG/reference/ | take_codes.npy [frames,10], served waveform.npy and PCM16 waveform.wav at 44100 Hz, made with the fp32 graphs on a Mac CPU, for comparison. |
29
 
30
  These requests use precomputed Savannah voice prefixes. The Android CLI invokes the LM and decoder graphs; a reference-recording frontend can use the separate speaker graph. Keep the full set of inputs together when validating an output against the reference.
31
 
 
16
 
17
  ## Kit contract
18
 
19
+ kit/MANIFEST.json describes the graph form, four CPU threads, Savannah, six tagged requests and little-endian byte order. Its `"form": "M"` names the fp32 graphs in graphs/, whose language model computes only the two experts that the router picks in each MoE layer. Its files dictionary maps kit-relative payload paths to byte counts and SHA-256. Its graph records carry paths relative to the release root, byte counts and SHA-256. The graph files are external to the kit.
20
 
21
  | Input | On-disk representation |
22
  |---|---|
 
25
  | takes/TAG/silence.i32 | Three delayed prefill rows of ten little-endian int32 audio IDs. |
26
  | takes/TAG/draws.f32 | One float32 [10,4098] matrix of independent unit-rate exponential draws per sampled row. The stream contains 769−P rows, enough through the last LM position. |
27
  | shared/ | Generation embedding tables [10,4098,1024] plus the text-pad vector [1024], LM RoPE cosine/sine [768,16], ten codec codebooks [10,4096,8], decoder RoPE and five causal window masks, Hann windows, mixer and resampler coefficients. All use contiguous float32 in row-major order. |
28
+ | takes/TAG/reference/ | take_codes.npy [frames,10], served waveform.npy and PCM16 waveform.wav at 44100 Hz, made on a Mac CPU, for comparison; the fp32 graphs in graphs/ reproduce these codes and WAV files on a Mac CPU. |
29
 
30
  These requests use precomputed Savannah voice prefixes. The Android CLI invokes the LM and decoder graphs; a reference-recording frontend can use the separate speaker graph. Keep the full set of inputs together when validating an output against the reference.
31
 
README.md CHANGED
@@ -10,9 +10,9 @@ tags: [litert, tflite, android, text-to-speech, zonos3]
10
 
11
  # ZONOS3-Mini for LiteRT
12
 
13
- This repository contains [Zyphra/ZONOS3-Mini-hf](https://huggingface.co/Zyphra/ZONOS3-Mini-hf/tree/e39d30df560125d9c434acd5cb0e83e4c2d64e0d), Zyphra's text-to-speech model, as three float32 LiteRT `.tflite` graphs for the CPU, with a prebuilt Android runner and a desktop Python script. On a Pixel 11 Pro's CPU, one prepared sentence of about 4 s took about 37 s from start to WAV, loading the graphs included. Speed still being tuned (updates follow).
14
 
15
- On a Mac's CPU, the graphs gave the same audio codes as the publisher's PyTorch model in 60 of 60 test runs. On a Pixel 11 Pro and a Galaxy S26 (Snapdragon, SM8850), six prepared sentences gave the same codes as on the Mac in every frame.
16
 
17
  On an Android phone, one command of the runner `android/zonos_host` speaks one of the six prepared sentences in `kit/` to a WAV file ([Use it](#use-it)). The runner takes no text, only these prepared inputs. An English sentence of your own goes through `desktop/speak.py`, which needs the publisher's files and which we ran on a Mac. On a GPU, the output was not shown to match: run the graphs on the CPU ([Notes](#notes)).
18
 
@@ -31,7 +31,7 @@ The download is about 4.7 GB.
31
 
32
  ### 2. Speak a prepared sentence on an Android phone
33
 
34
- You need an arm64 Android phone with USB debugging on, `adb`, and about 4.8 GB free on the phone, and the runner's peak memory on both phones was 3.54 GB.
35
 
36
  <!-- usage:android -->
37
  ```bash
@@ -74,7 +74,7 @@ The script loads the publisher's model and code from `$MODEL` (with `trust_remot
74
 
75
  | file | bytes | what |
76
  |---|---|---|
77
- | `graphs/lm_step_p768.tflite` | 3,342,543,296 | the language model |
78
  | `graphs/codec_dec_f150.tflite` | 572,522,276 | the decoder: audio codes in, spectral rows out |
79
  | `graphs/spk_enc_t998.tflite` | 45,122,316 | the speaker encoder: a voice embedding from a recording, used by the desktop script only |
80
  | `android/zonos_host` | 7,139,128 | the Android runner, built for arm64-v8a and Android API level 28; its C++ source is in `host/` and `include/` |
@@ -86,11 +86,11 @@ The script loads the publisher's model and code from `$MODEL` (with `trust_remot
86
 
87
  ## Notes
88
 
89
- - **GPU.** On a Mac's GPU, the language-model graph did not match the publisher's model in 910 of 910 steps, and the phones' GPUs were not tried.
90
  - **Length.** One call of the decoder graph speaks at most 150 frames (10 s, the three silence frames that open the speech included). Longer speech stops with `BucketExceeded`: split longer text and speak each part.
91
  - **Positions.** The prompt and the generated speech share 768 positions of the language-model graph. When they are used up, generation stops with `CapacityReached`.
92
  - **Random draws.** The prepared inputs carry their random draws, which is why both phones gave the same codes as the reference in `kit/takes/<sentence>/reference/`. For each of the six sentences, the WAV from both phones still differs from the reference WAV in 140 to 236 of its 16-bit samples (193 of 182,280 for `s00`), each by 1, because the phones' float32 audio differs from the reference by at most 3.44e-6 before rounding. An app supplies its own draws, and its codes then differ from the reference.
93
- - **How the files were made.** The three graphs were exported in float32 with litert-torch 0.10.0 from the publisher's weights at commit e39d30df.
94
 
95
  ## License
96
 
 
10
 
11
  # ZONOS3-Mini for LiteRT
12
 
13
+ This repository contains [Zyphra/ZONOS3-Mini-hf](https://huggingface.co/Zyphra/ZONOS3-Mini-hf/tree/e39d30df560125d9c434acd5cb0e83e4c2d64e0d), Zyphra's text-to-speech model, as three float32 LiteRT `.tflite` graphs for the CPU, with a prebuilt Android runner and a desktop Python script. On a Pixel 11 Pro's CPU, one prepared sentence of about 4 s took 23.5 to 31.4 s from start to WAV, loading the graphs included. Speed still being tuned (updates follow).
14
 
15
+ On a Mac's CPU, the graphs gave the same audio codes as the publisher's PyTorch model in 60 of 60 test runs. On a Pixel 11 Pro and a Galaxy S26 (Snapdragon, SM8850), six prepared sentences gave the same codes as on the Mac in every frame. The language-model graph has since been replaced by a faster one with the same inputs and outputs. On the Mac and on each phone, it gave the same codes and the same WAV for these six sentences as the earlier one did on the same device.
16
 
17
  On an Android phone, one command of the runner `android/zonos_host` speaks one of the six prepared sentences in `kit/` to a WAV file ([Use it](#use-it)). The runner takes no text, only these prepared inputs. An English sentence of your own goes through `desktop/speak.py`, which needs the publisher's files and which we ran on a Mac. On a GPU, the output was not shown to match: run the graphs on the CPU ([Notes](#notes)).
18
 
 
31
 
32
  ### 2. Speak a prepared sentence on an Android phone
33
 
34
+ You need an arm64 Android phone with USB debugging on, `adb`, and about 4.8 GB free on the phone. The runner's peak memory on both phones was 2.91 to 3.15 GB.
35
 
36
  <!-- usage:android -->
37
  ```bash
 
74
 
75
  | file | bytes | what |
76
  |---|---|---|
77
+ | `graphs/lm_step_p768.tflite` | 3,342,589,152 | the language model |
78
  | `graphs/codec_dec_f150.tflite` | 572,522,276 | the decoder: audio codes in, spectral rows out |
79
  | `graphs/spk_enc_t998.tflite` | 45,122,316 | the speaker encoder: a voice embedding from a recording, used by the desktop script only |
80
  | `android/zonos_host` | 7,139,128 | the Android runner, built for arm64-v8a and Android API level 28; its C++ source is in `host/` and `include/` |
 
86
 
87
  ## Notes
88
 
89
+ - **GPU.** On a Mac's GPU, the earlier language-model graph did not match the publisher's model in 910 of 910 steps. The current one was not tried on a GPU.
90
  - **Length.** One call of the decoder graph speaks at most 150 frames (10 s, the three silence frames that open the speech included). Longer speech stops with `BucketExceeded`: split longer text and speak each part.
91
  - **Positions.** The prompt and the generated speech share 768 positions of the language-model graph. When they are used up, generation stops with `CapacityReached`.
92
  - **Random draws.** The prepared inputs carry their random draws, which is why both phones gave the same codes as the reference in `kit/takes/<sentence>/reference/`. For each of the six sentences, the WAV from both phones still differs from the reference WAV in 140 to 236 of its 16-bit samples (193 of 182,280 for `s00`), each by 1, because the phones' float32 audio differs from the reference by at most 3.44e-6 before rounding. An app supplies its own draws, and its codes then differ from the reference.
93
+ - **How the files were made.** The three graphs were exported in float32 with litert-torch 0.10.0 from the publisher's weights at commit e39d30df. The language-model graph computes only the two experts that the router picks in each of its ten MoE layers, not all 64.
94
 
95
  ## License
96
 
graphs/lm_step_p768.tflite CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:068e500d7daedb2d3b5cf2a1348db4c3cc4ff392d80edb236c258a9ab9c13753
3
- size 3342543296
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5cfffcad44519def1d0a67b0835815cf011408cd20c90fb38b224ac3f22abb53
3
+ size 3342589152
kit/MANIFEST.json CHANGED
@@ -1,5 +1,5 @@
1
  {
2
- "form": "F",
3
  "threads": 4,
4
  "voice": "Savannah",
5
  "byte_order": "little",
@@ -278,8 +278,8 @@
278
  "graphs": [
279
  {
280
  "path": "graphs/lm_step_p768.tflite",
281
- "bytes": 3342543296,
282
- "sha256": "068e500d7daedb2d3b5cf2a1348db4c3cc4ff392d80edb236c258a9ab9c13753"
283
  },
284
  {
285
  "path": "graphs/codec_dec_f150.tflite",
 
1
  {
2
+ "form": "M",
3
  "threads": 4,
4
  "voice": "Savannah",
5
  "byte_order": "little",
 
278
  "graphs": [
279
  {
280
  "path": "graphs/lm_step_p768.tflite",
281
+ "bytes": 3342589152,
282
+ "sha256": "5cfffcad44519def1d0a67b0835815cf011408cd20c90fb38b224ac3f22abb53"
283
  },
284
  {
285
  "path": "graphs/codec_dec_f150.tflite",