Skip to content

zonos3: test-page inputs for every served feature, and speech editing on the page - #3883

Draft
BobClawblaw wants to merge 46 commits into
ashhart:mainfrom
BobClawblaw:zonos3-page
Draft

BobClawblaw wants to merge 46 commits into
ashhart:mainfrom
BobClawblaw:zonos3-page

Conversation

@BobClawblaw

@BobClawblaw BobClawblaw commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

The family's test page (tools/zig/zonos3_test_page.py and .html) sends every request field the stack serves, edits a file or a take on a second tab, and shows the aligner's word times. The pass-through adds the controls, decoders and edit routes and the X-Decoder and X-Finish-Reason headers.

Checks on this head

Receipt

  • Rebuilt without zonos3: the decoder's linear layers through cuBLAS; every request decodes in the stream's chunks #3877 (2026-11-22, measured on the RTX 5090 on the stack's top unless said): no change to the page; the stack under it was rebuilt.
  • 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.
    n/a: the test page and its pass-through do not reach inference. python3 -m py_compile passes on the page script, and the page was driven against the served build for every field it sends.

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.

@BobClawblaw

Copy link
Copy Markdown
Contributor Author

/atc depends 3882

@AIFlowML

Copy link
Copy Markdown
Contributor

I exercised 14702d2be in Chromium using the actual zonos3_test_page.py proxy and a local fake speech endpoint. Speak forwarded the request and displayed the decoder header. “Edit this” forwarded WAV to both the align and edit routes, showed the returned word times, and displayed the edit seed 18446744073709551615 exactly.

One reproducible bug in the steering UI:

  1. Type Hi 🐱 <0.5s> hello world, select only hello, add a hidden-space control for that selection, and click Speak. The wire text contains the pause marker and [7, 12) correctly selects hello.
  2. Replace the text with Yo and click Speak again. The proxy still receives control_spans: [{"start":7,"end":12,"controls":{"bright":1}}]. The real server's span validator refuses a range beyond the text length. If the replacement is long enough, the stale span can instead steer the wrong words.

I verified a scratch guard that saves the wire text when a span is created and checks it against the submitted input after merging the extra JSON fields. The original text still sends the valid request. Editing the text then shows a reselect message and sends no POST until the stale span is addressed.

The exact head and #3882 conflict in the same 13 files against main 9b9218f72. This browser check used generated WAV and fake response payloads.

Igor Lessio - AIFLOW LABS

@BobClawblaw

Copy link
Copy Markdown
Contributor Author

Thanks, Igor. Confirmed and fixed in 70d71de39.

The fix: each steering span now keeps the text it was selected in (as sent: pause markers and phone brackets already turned into the release's markers). Speak compares it with input after the other request fields are merged. If they differ, nothing is posted, and the page says which control to remove and select again. Spans given in the other request fields are the user's own and pass through unchecked. JSON in that box that isn't an object (e.g. 5) was silently ignored; it now gets a message as well.

How it was checked: in headless Chrome, through the real zonos3_test_page.py proxy, against a fake speech endpoint. The fake records each POST and refuses a span past the end of the input, counting code points as the server does. Same caveat as your run: generated WAV and fake replies, no checkpoint. Thirteen checks:

case 14702d2be 70d71de39
Hi 🐱 <0.5s> hello world, span on hello: [7, 12) sent, selecting hello on the wire pass pass
text replaced with Yo: no POST, reselect message posted the stale span (refused upstream) pass
hello changed to jello (same length): no POST posted the stale span pass
original text restored: sent again pass pass
control removed, there reselected in Yo there: [3, 8) sent pass pass
whole-reply control after a text change: sent pass pass
control_spans in the other request fields: sent as written pass pass
input in the other request fields restoring the selected text: sent pass pass
malformed other request fields ({"seed": ): message, no POST pass pass
non-object other request fields (5): message, no POST ignored, request sent pass
no page errors pass pass

The same 13/13 passes on the top of the stack (the page as #3885 and #3732 carry it).

The stack above this PR is restacked on the fix with no other change: #3884 b5f999da7, #3885 f4882ab54, #3732 5e90182d8. Each differs from its previous head only by this commit's lines.

Conflicts with main: noted, thanks. The stack gets rebased from #3720 up once the lower part is settled, and your notes on #3873, #3884 and #3885 (carry the format and PCM header paths through the newer speech route, rerun the non-44.1 kHz speaker and aligner checks with the clip's own --rate, rerun the LACI duration examples) go into that pass.

…'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.
condition_values and condition_buckets set the loudness, fmax and speaking-rate rows (a raw value through the
edges in params.json); speaker_cfg_scale runs the reference's twin, the prompt without its voice, on a second
set of caches and samples each frame from the two logits mixed on the host. Greedy frames equal the reference's
for both, alone and together, on the reference-prefix and the speaker-row paths.
Each request has a lane of the backbone's caches and recurrent state and a lane of the decoder's; one worker
gives every request in progress a turn, a frame each, through the single-stream passes already checked. A reply
beside others is the reply alone, byte for byte. Each request at once past the first adds 1,236,862,976 device
bytes, admitted with the load. Nothing is batched across requests: the total speed is one request's.
Engine.runLanes runs a row of each lane together: the launches that read no lane's state take every row at
once, and the four that do run a lane at a time on that lane's state. A request's reply is still the reply
alone, byte for byte. Four 17.8 s replies at once take 1.71 s where they took 2.42 s; a guided request's two
passes a frame are one.
…en hold, controls guidance, embedding voices

A request's controls name directions of the publisher's steering bundle. Hidden directions add dose times the
vector to Full AttnRes bank sources on every generated frame (z3_combine as one fp32 add, checked by the kernel
contract at that shape); speaker-embedding directions move an embedding voice's vector and keep its norm.
speaker_mode "embedding" and speaker_embedding speak a voice by its speaker row. GET /v1/audio/controls lists the
directions. Against the publisher's code with its bundle, five greedy requests: the host's deltas and moved
embeddings are bit-identical, and the frames are identical at --max-rows 1, 7, 64 and 256.

--voices and --default-voice now parse in voice_cli.zig, unchanged, so cli.zig stays within 600 lines.
…eme, start and pause tokens

LACI reads a request's place in its text from the alignment heads' attention after every row, rolls a skip, a
stall or an early end back to its onset and regenerates under ACI masks; the masked heads run through the same
attention kernel over a closed-up cache. The release's 143 extra text rows load in fp32 and embed exactly; their
markers tokenize as in the reference. A text of a word or two is generated with a pause and a filler sentence and
cut where the filler starts. Against the publisher's code: its seven portable replay fixtures pass; on the model,
thirteen greedy requests (four that retry eight times) give its readings, masks, rows and records; and the three
token requests give its frames.
…forced aligner

- The release's speech-edit adapter (zonos-accent-lora/3) on the backbone: its bf16 factors through z3_linear and
  z3_combine, its span-end and marker rows in fp32 on the host. An edit's fills run on it in a pass of their own;
  other requests never read it.
- edit.zig, edit_plan.zig, difflib.zig: the release's edit prompts, fills, splice, word diff, windows and fill
  lengths. server/speech_edit.zig plans an edit and drives the engine's steps (a clip's codes, a fill's rows, the
  edited codes' audio, words placed in a clip): POST /v1/audio/edit and /v1/audio/edit/align.
- speaker.zig: the release's MECT-B2 speaker encoder in fp32 on the host's cores: a clip's embedding for an edit's
  speaker row, and for speaker_mode "embedding" with ref_audio on /v1/audio/speech.
- cuda/aligner.zig: FuseAlign and its Dia text encoder from the release's web/aligner export, on kernels the
  family already has: every linear is zc_linear.
- No new kernel; the shapes these launch existing kernels at joined the kernel contract's served lists.
- tools/zig/zonos3_reference_edit.py: the reference dumps the checks compare with.
…_follow "reading")

- span_follow.zig: the reference's span follower (a running median of readings, held monotone, a span ramped in
  and out by the reading's place against its tokens), decided once a frame and rolled back with LACI.
- server/zonos_reading.zig: each span's characters as the text positions that spell them, through normalization
  and the release's markers. control_span_lead and control_span_lag.
- The host reads a request's own passes with the language's LACI heads; under LACI the session feeds the follower.
- zonos3-generate --follow-check against the reference's readings, weights and frames; the LACI replay runs the
  publisher's three follower fixtures.
…ention caches as rings

- The decoder head by id (Decoder: keep2_plain, full_mr; their layer counts checked at load). A request names one
  with `decoder` (speech and edits; unknown: the reference's 400), the reply says which in X-Decoder, and
  GET /v1/audio/decoders lists them. --decoders restricts the set; the default loads with the model, another on its
  first request, admitted for its weights and a lane for every request at once.
- zc_attn_prep and zc_attention take the ring size: a stage's K and V caches hold its window and a pass's rows
  (position p at row p % ring), not the whole request. Loop order and sums unchanged: keep2_plain replies are
  byte-identical to before; a request's decoder state falls from 1,236,862,976 to 495,527,936 bytes.
- The kernel contract drives both kernels through rings that wrap.
- zonos3-generate --codec-check takes --decoder; the host's sizes move to native/zonos_sizes.zig.
… on the page

The page sends language and normalization, condition values, speaker guidance, the decoder, LACI, short texts,
start immediately, the voice by its embedding, steering controls on the whole reply or on selected text (spans
counted on the text sent), and any other field as JSON; pauses and pronunciations are typed as <0.5s> and
[[phones]]. A second tab edits a file or a take by its new text or by seconds, and shows the aligner's word
times. The pass-through adds the controls, decoders and edit routes and the X-Decoder and X-Finish-Reason headers.
A span counts code points of the text it was selected in. After the text
changed, Speak still sent the old span: the server refused one past the end,
and one inside a longer text steered other words. Each span now keeps the text
it was selected in, and Speak compares it with the input sent (after the other
request fields are merged) and asks for the words to be selected again.
Spans given in the other request fields are left as written.

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.

2 participants