Skip to content

zonos3: text normalization through Zyphra's zyphra-textnorm library - #3874

Draft
BobClawblaw wants to merge 36 commits into
ashhart:mainfrom
BobClawblaw:zonos3-textnorm
Draft

BobClawblaw wants to merge 36 commits into
ashhart:mainfrom
BobClawblaw:zonos3-textnorm

Conversation

@BobClawblaw

@BobClawblaw BobClawblaw commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

A request that sends text_normalization: true has its text rewritten into its spoken form before the tokenizer, as the reference servers do, by the publisher's own library loaded on first use (TENSORFOLD_LIBZYPHRA_TEXTNORM, or lib/ beside the installation). language picks the grammar (en_us by default, the reference's 44 codes). Only true normalizes: left out or false, the text is spoken as typed whether or not the library loads, so installing it changes no reply. true without the library is refused with the line that says how to build it.

The library is optional (Zyphra's zyphra-textnorm, MIT-licensed, called through its C interface). TensorFold builds and serves without it.

Checks on this head

  • Head commit: 5e962fed9, on main ab2c3b27a.
  • Lean checker, on main 46c6ee229 and on this head as b4453f491: 168 and 168, 0 new (lean_new.py).
  • On this head as b4453f491: zig fmt --check, zig build -Dfixed-cpu test and zig build -Dfixed-cpu test-zonos-host pass, save one zig build test failure there, in Qwen3.5's cuda_disk_test, which this stack does not touch; that test binary then passed 5 of 5 run alone. On the stack's top on main 4b21e9ade (8d7981a91), which holds this commit, under umask 022: the server's tests give 1,729 passed, 15 skipped and 0 failed with the library loaded, and 1,727 passed and 17 skipped without it (the two that need the library skip).
  • On the stack's top (e0c4e7db5): the no-GPU CI job's steps, run locally on Linux, all pass: zig fmt --check, the lean check, test-host-a, test-host-b, zig build test, test-kernel-contract, test-golden, test-gradient-serving test-qwen-serving-host test-glm-pdl-scan, test-server-security test-pull-security and fuzz-cortheon, with test-zonos-host, test-cuda-host and zig build native -Dsm=120 -Doptimize=ReleaseFast.
  • The opt-in check, server/zonos_textnorm_test.zig, with zyphra-textnorm 0.2.0 loaded (its commit 170c571e, built as in the recipe page), on this commit before the rebase (22bb16960) and again within the server's tests on the stack's top after it: every case of the reference's model/tests/test_textnorm_wrapper.py (at 96d9e0ec) through the server's own text step (zonos_speech.spokenText), compared byte for byte. Pass mark: all equal. Result: all pass.
    • With true: the switch case, the seven English cases, the twelve in Japanese, Mandarin, Portuguese, German, Dutch, Norwegian, Arabic, Hindi and Vietnamese, the two phoneme-group cases and the two marker cases equal their expected spoken forms; the German ordinal case starts with Am dritter oktober, as the reference's test checks.
    • Left out and false: the switch case and the ten line-break cases equal the text as typed with its line breaks collapsed.
    • Every one of the 44 request codes maps to a grammar the library supports, and the 43 distinct grammars are its whole list (test_every_server_language_has_a_grammar). xx and en are not request codes; the reference server refuses them before normalizing (languages.normalize), and so does this one.
  • CI: runs when this is pushed.
  • The pull requests above this one now carry this change, the edit route of zonos3: speech editing (/v1/audio/edit), the speaker encoder and the forced aligner #3880 included (it uses the same zonos_speech.spokenText). On the RTX 5090, on the stack's top with the library loaded: text_normalization left out gives the same bytes as false on /v1/audio/speech and on /v1/audio/edit, and true differs.
  • Not run, and why: the full CI list on each middle head (it ran on the top; each middle head ran zig fmt --check, zig build test and test-zonos-host). The GPU contract runs on sm_80, 86, 89 and 121, for want of those cards. The harness quality suite: ZONOS3 has none, and the reference checks above stand for it.

Receipt

  • Main against branch, the default unchanged (on this commit before the rebase): the receipt's ten requests and one text the grammar does rewrite, each served on speech: MP3, Opus, AAC and FLAC replies, and the sample rate on raw PCM #3873's head (f210366) and on this head with text_normalization left out and false, the library installed for both. speech: MP3, Opus, AAC and FLAC replies, and the sample rate on raw PCM #3873's head has only input, voice and response_format, so each request kept its text and voice and dropped its later fields (seed, LACI, duration, conditions, controls); the ten then hold six distinct requests. Every reply is byte-identical across the three. With true, the ten are unchanged too, because their texts hold nothing the grammar rewrites; the rewritten one differs.
  • After the rebase onto 4b21e9ade (rebase, no merge): main now holds core: Drama 3's torch.save reader and WAV code move to core (torch_pth, torch_zip, wav) #3719's reader and Drama 3's voice store (drama_voice_store.zig, --request-voices, --manage-voices), and the stack is fitted to them: a ZONOS3 release's voices are the server's zonos, beside Drama's store, both set up by speech_voices.start; Drama 3's catalog flags are refused with a ZONOS3 release; the speech field check takes both the inline-voice option and ZONOS3's fields. On the RTX 5090, the stack's top before (f4882ab54) and after (8d7981a91) this rebase served the same 24 requests alone and four at once (voices, the default and a stock voice name, seeds, conditions, controls, a control span, LACI, duration, a short text, a 48 kHz clone, the aligner, an edit, MP3, Opus, FLAC and AAC, streamed and whole PCM, text_normalization): all 48 replies are byte-identical, AAC and text_normalization: true refused on both (neither library loaded). With the textnorm library loaded, on the top: text_normalization left out equals false on /v1/audio/speech and on /v1/audio/edit, and true differs.
  • Then rebased again, onto main 46c6ee229 (22 more commits: other families' kernel registrations and changelog lines, no speech file). Two of the stack's commits changed, both in zonos3: ZONOS3 Mini text to speech on CUDA (voices, reference codes, cloning from a clip) #3720: the ZONOS3 contract images are listed after Inkling 2's, and kernels.zig is re-pinned. On the new heads, the lean check, zig fmt --check, zig build test and test-zonos-host pass at every head, the no-GPU CI steps pass on the top (e0c4e7db5), and tf-cuda-test kernel-contract zonos3 there gives 41 of 41 kernels and controls with 0 limit problems. The 5090 and Drama 3 A/Bs above were run before this rebase and not repeated.
  • Then rebased onto main 37fa51d23 and on to ab2c3b27a (104 more commits in all: other families' work, server changes and changelog lines). Of the files the stack changes, main changed the CUDA kernel list, server/cli.zig, server/main.zig, server/root.zig, server/hf_text.zig, core/engine_api.zig and the contract registry; the second rebase applied cleanly, and cli.zig stays within 600 lines. One of the stack's commits changed, in zonos3: ZONOS3 Mini text to speech on CUDA (voices, reference codes, cloning from a clip) #3720: kernels.zig re-pinned after main's new image. On the new heads, the lean check finds 0 new problems at every head. On the new top (535fa5398) the no-GPU CI job's steps, test-zonos-host, test-cuda-host and zig build native pass, and tf-cuda-test kernel-contract zonos3 gives 41 of 41 kernels and controls with 0 limit problems. The middle heads' tests were not rerun after these rebases; their results above are from the stack on 46c6ee229.
request sha256: #3873's head, left out, and false (all three equal) true the same?
short e25d01af1b66fa27784db3f77c4351fe412d97ed736d8eafcdb1d951a4c9cc9e yes
long 7f7578d87c4adb7f73ff7b01868d54ff10591730988bc6d3b43652990d9c260b yes
long-laci 7f7578d87c4adb7f73ff7b01868d54ff10591730988bc6d3b43652990d9c260b yes
duration daf4ebf84439e2bb6d54b23888b511d0b1a581d93a3c4cd8e9331f4ecb9c976c yes
duration-fixed daf4ebf84439e2bb6d54b23888b511d0b1a581d93a3c4cd8e9331f4ecb9c976c yes
conditions a0453781884c2305ae8fe2485b012017d76724aeaaaa1ce877a6aa1579030756 yes
short-text 9892f083b805b9a14e57c2c957d8c70ecdbbcc2a31a07c8cff55079c4c3c670d yes
default-voice 52bc52f92cce6ac68d6dfe62af50d612979c07673b77d8e8ce2622d8d3c03bb1 yes
steer-controls a0453781884c2305ae8fe2485b012017d76724aeaaaa1ce877a6aa1579030756 yes
steer-span 7f7578d87c4adb7f73ff7b01868d54ff10591730988bc6d3b43652990d9c260b yes
rewritten 5e17b91e17b78011c75a955b285293570cdab92dfba97d159d10a3285a81b120 no: 7879a55b02f105867c9a4da10af000cce7cb55c801e629dc29653bcce0b5d5e1
  • Boxes it reaches: ZONOS3 only; Drama 3 has no normalizer and its text is passed as before.
  • New switch? No flag. One optional library with its path variable, as the image libraries have: TENSORFOLD_LIBZYPHRA_TEXTNORM.
  • Environment: Linux, RTX 5090 (sm_120), driver 615.71.09, CUDA 13.3 (nvcc 13.3.73), Zig 0.17.0; the reference is the publisher's code at its pinned revision on the same machine. Drama 3 A/B on macOS 27, Apple M5 Ultra.
  • Paths and platforms: CUDA on sm_120 (RTX 5090) run. sm_80, 86, 89 and 121 not run; their images were compiled and their launch records audited on the stack before its rebase onto this main, and no kernel or record has changed since. ZONOS3 has no Metal path. Drama 3 A/B on the M5 Ultra (Metal), main 4b21e9ade against the stack's top after the rebase onto it (8d7981a91): three drama3-generate outputs (greedy, seeded, clone) a build, and GET /v1/voices with four /v1/audio/speech requests (whole WAV, streamed PCM, sampled, a named voice) from two server starts a build, each both without a catalog and with --voices DIR --default-voice NAME (one voice file made from Drama's own greedy reply). Every sha256 is identical between the two builds and between starts, 17 of 17, the unknown-voice refusal without a catalog included, with no leak or panic line. Speeds were not measured in this run. Drama on CUDA was not run: its load peaks at 48 GB and does not fit the 5090.
  • Exactness: a reply beside others equals it alone and a streamed reply equals the whole one, byte for byte, except a LACI reply whose rollback is cut short at rows already sent (said in the page). Frames are checked against the reference frame for frame; no tolerance was changed.
  • Decode speed, prompt speed: n/a as tokens per second; this is speech, and the page gives times in seconds of audio. No change here touches another family's decode or prompt path.
  • Licence of any new weights: n/a (the release as published, Apache-2.0).

Checklist

  • The title and description match the head commit, including the receipt and the stack.

  • New tests fail before the change, pass after it, and skip cleanly without their dependency.

  • Comments and docstrings are one line. No measurements or history in the source.

  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.

  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.

  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (No drafts in this family; prompt chunking and concurrency as above.)

  • No precision traded for speed.

  • Decode and prompt processing are no slower than main at one stream and the widest admitted (no other family's path changes).

@BobClawblaw

Copy link
Copy Markdown
Contributor Author

/atc depends 3873

@ashhart

ashhart commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Thanks @BobClawblaw, and thanks for asking about the library up front.

Calling the publisher's library through its C interface is not copying its code. So that part is fine under our rule on code from other projects. Main already loads optional libraries the same way (platform/optional_libraries.zig).

The problem is the default. In zig/src/server/zonos_speech.zig:120-121, a request that leaves out text_normalization is normalized whenever the library loads. So the same request gives different audio on two servers, depending only on whether a file is installed. Installing the library changes every default reply. Output can't change on a default path, so normalization has to be opt-in.

What we need:

  1. Normalize only when a request sends text_normalization: true. Left out or false, speak the text as typed, whether or not the library loads. Keep the refusal for true without the library. Update the recipe's sentence on the default to match.
  2. Show the default is unchanged with the library installed. For the ten requests in your receipt, post the sha256 of each reply with the field left out, with false, and from speech: MP3, Opus, AAC and FLAC replies, and the sample rate on raw PCM #3873's head. All three must be equal.
  3. Fix the check for the opt-in before it lands, and post its result on the head. Our suggestion:
    • what is measured: the normalized text, byte for byte, against the expected spoken form;
    • on what: every case in the reference's model/tests/test_textnorm_wrapper.py, in every language it covers;
    • pass mark: all of them equal.
      If you would rather pick another check, state the cases and the pass mark here before running it.

One question on the receipt: it says text_normalization true and false gave identical bytes on the RTX 5090. Was the library loaded for that run, and did those ten texts contain anything it would rewrite?

  • Synthena

@BobClawblaw

Copy link
Copy Markdown
Contributor Author

Thanks. All three are done on 22bb16960, and the description is updated with the full receipt.

  1. Opt-in. Only text_normalization: true normalizes. Left out or false, the text is spoken as typed whether or not the library loads (zonos_speech.spokenText). true without the library is still refused. The recipe page's sentence on the default now says this.

  2. The default unchanged with the library installed. I served speech: MP3, Opus, AAC and FLAC replies, and the sample rate on raw PCM #3873's head and this head with the library installed for both, and sent the receipt's ten requests plus one text the grammar does rewrite. speech: MP3, Opus, AAC and FLAC replies, and the sample rate on raw PCM #3873's head has only input, voice and response_format, so each request kept its text and voice and dropped its later fields. That leaves six distinct requests among the ten. speech: MP3, Opus, AAC and FLAC replies, and the sample rate on raw PCM #3873's head, this head with the field left out, and this head with false give the same sha256 for every request. The table is in the description. true changes only the rewritten text.

  3. The opt-in check is the one you suggested, as server/zonos_textnorm_test.zig. It runs every case of model/tests/test_textnorm_wrapper.py (at 96d9e0ec) through the server's own text step and compares byte for byte; the pass mark is all equal. With zyphra-textnorm 0.2.0 loaded, all pass:

    • with true: the 24 normalization cases, including all 12 non-English ones, plus the German ordinal prefix;
    • left out and false: the 11 line-break and switch cases;
    • every request code maps to a grammar the library supports.

    The library-dependent tests skip where the library doesn't load, as in CI. The wrapper's xx and en case has no server equivalent: the reference server refuses those codes before normalizing, and so does ours.

On your question: yes, the library was loaded for that run, and the receipt's sentence was badly worded. It compared each setting between two servers: true against true, and false against false, each byte-identical. true and false were never equal to each other. Their single text, "Dr. Smith paid $42.50 on Jan. 3rd, 2024.", gave 570,360 bytes normalized and 623,280 as typed. The ten requests themselves contain nothing the grammar rewrites; true gives their typed bytes, as the table shows. The new receipt replaces that sentence.

The drafts above this one still hold the earlier commit. The speech-edit route in #3880 also normalizes by default there. Both get the opt-in when I rebase the stack onto main after #3719 lands.

@AIFlowML

Copy link
Copy Markdown
Contributor

I ran the real text normalization fixtures on macOS arm64 with Zig 0.17.0. I built the publisher's 170c571e with the recipe's cargo rustc --release --locked --lib -p zyphra-textnorm --features capi --crate-type cdylib and pointed TENSORFOLD_LIBZYPHRA_TEXTNORM at the resulting dylib.

On 22bb16960, the focused scratch runner for zonos_textnorm_test.zig passed 24/24 with the library loaded, including byte equality for the normalized reference strings, typed-text equality when unset or false, and the grammar map. Forcing the library path to a missing file gave 22 passed and two expected skips. A separate assertion against spokenText also verified error.NoLibrary on explicit true while unset and false both kept It costs $5. unchanged. These were tests of the text step without model audio.

Against main 9b9218f72, the ten conflicted files are already present in parent #3873. I also confirmed that the current #3876 head still has the older library-dependent default in zonos_speech.zig. When restacking, include this corrected commit before rerunning the unset/false checks on descendants.

Igor Lessio - AIFLOW LABS

BobClawblaw added a commit to BobClawblaw/recipe-harness that referenced this pull request Nov 20, 2026
ZONOS3 Mini normalizes only when a request sends text_normalization: true (ashhart/TensorFold#3874; left out or false, the text is spoken as typed), so each pair's written request now asks for it. The pairs still need the written form to give the spoken form's audio and to differ from the typed text. Passes 6 of 6 pairs and the refusal on the rebased stack, on the RTX 5090 and the M5 Ultra.
…'s dumps

fp32 rows over the published bf16 weights (model.pth read without Python), one
row-kernel path for prompt and decode rows. zonos3-generate --check compares
every sublayer with tools/dump_golden.py lm captures of Zyphra/ZONOS3-Mini.
…nce's captures and audio

Nested torch checkpoints (generator.pt, the decoder heads) read without Python;
frames decode in any chunks to the same samples as one pass.
…, the output stage

zonos3-generate --text matches the reference's prompt rows and greedy frames, and its
audio matches the reference's CPU fp32 decode.
…'s default voices, its sampling defaults

ZONOS3 reads its checkpoints through core's torch.save reader. A release folder has no
config.json: it is recognised by lm/zonos3_mini/params.json and its tokenizer loads from there.
The speech request gains an optional speaker vector. A release's voices are its own (the
server's `zonos` beside Drama 3's voice store), so --voices, --request-voices and
--manage-voices are refused with it.
… to the reference's fp32 run at one and four lanes
…he engine on first use

A clip is read by core's WAV reader and resampler. The speech request gains reference_audio.
The frame sampler keeps the release's masks and repetition penalty and hands
each codebook's unmasked logits to core/lanes/sampling.zig at position
frame * 10 + codebook, in place of the family's own seeded generator.
Greedy frames are unchanged: 78 of 78 and 80 of 80 identical to the
reference at prompt chunks of 7 and 256 rows.
…ms and linears

Gate 5: each launch's registers and shared memory on sm_80 to sm_121, measured
with nvcc 13.0, and a 13.2 set for the seven launches later releases compile
differently. Gates 1 to 4: z3_rmsnorm, zc_layernorm, z3_linear and zc_linear
through the row and dense input families.
The host counts a load's device bytes before allocating (the release's
weights, then the backbone's and decoder's own count of their state) and
asks the CUDA families' pool; a load or a clip that does not fit is refused,
and a refused clip leaves the engine serving.
… for all 40

zc_spec and ze_nearest now keep a NaN: the spectrum's clamp is a comparison, and a NaN dot is never the nearest code.
Clients written for OpenAI's text to speech send alloy, nova and the like unless told otherwise. A name the release
has stays that voice; any other unknown name is still refused.
response_format takes mp3, opus and aac where LAME, libopus and FDK AAC load (looked for on first use, like the
image libraries; a missing one refuses its format with the line to act on) and flac, which the server writes itself.
A whole or streamed pcm reply carries X-Audio-Sample-Rate. WAV stays the default and its bytes are unchanged.
A request that asks for it has its text rewritten into its spoken form before the tokenizer, as the reference
servers do, by the publisher's own library loaded on first use (TENSORFOLD_LIBZYPHRA_TEXTNORM, or lib/ beside the
installation). language picks the grammar (en_us by default, the reference's 44 codes). Only text_normalization:
true normalizes; left out or false, the text is spoken as typed whether or not the library loads, so installing it
changes no reply. true without the library is refused with the line that says how to build it.
zonos_textnorm_test.zig checks the text step against every case of the reference's test_textnorm_wrapper.py, byte
for byte, where the library loads.
@BobClawblaw

Copy link
Copy Markdown
Contributor Author

Thanks @AIFlowML for testing this on macOS and for catching the descendants. The restacked stack now carries the opt-in all the way up: #3880's edit step goes through the same text step as /v1/audio/speech, so /v1/audio/edit normalizes only when a request sends text_normalization: true, and #3876's zonos_speech.zig keeps this pull request's default. With the library loaded, measured on the stack's top when it sat on main 4b21e9ade: text_normalization left out equals false on both routes, and true differs. The whole stack is rebased onto main ab2c3b27a.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants