Skip to content

feat(speech): redraw whole speech replies that end too short - #1161

Closed
plotarmordev wants to merge 5 commits into
ashhart:mainfrom
plotarmordev:feat/short-reply
Closed

plotarmordev wants to merge 5 commits into
ashhart:mainfrom
plotarmordev:feat/short-reply

Conversation

@plotarmordev

Copy link
Copy Markdown
Contributor

What this changes

Stacked on the silence-redraws PR (#1160); review the diff against its tip 49ea53bd.

Adds opt-in serve --short-reply-ratio R --short-reply-chars-per-s CPS. A whole Drama speech take that finishes stop with less than R × chars / CPS seconds of audio is redrawn as a silenced take is, under the same --silence-redraws count, budget and controls.

  • Flags: R must be above 0 and below 1, and CPS positive and finite. Neither has a default, and each needs the other. Together they need --silence-redraws of 1 or more, so text models refuse them through that flag. Without both flags, no stop is redrawn and replies are unchanged.
  • Judging: only stop finishes are judged; length never is, and a silence finish trips as before.
    • Texts under 200 characters are never judged.
    • chars counts the code points of the text the take spoke, controls included. For the first take, that is the input after --allowed-controls filtering. For a redraw, it is the input after --silence-redraw-controls filtering.
  • Header: short redraws count toward X-Silence-Redraws, as silence redraws do.
  • Calibration: no rate is built in. CPS and R are calibrated on the served voice from complete stop replies, as docs/speech-redraws.md#short-replies describes.
  • Example, illustrative only: --silence-redraws 2 --short-reply-ratio 0.6 --short-reply-chars-per-s 12.

Receipt

  • Environment, with the TensorFold commit, MLX or PyTorch version, machine and GPU, checkpoint and revision: 2cef6e88, on the silence-redraws PR's 49ea53bd, on main d1018b31. Host tests: Linux aarch64, Zig 0.17.0, CPU only, no MLX or PyTorch. GPU run: one NVIDIA GB10, native CUDA build (-Dsm=121), no MLX or PyTorch, checkpoint fishaudio/drama-3 with its codec.pth (revision not recorded), built-in voice. Stock is upstream d1018b31. The candidate is ca60e9c8, an integration of all the open Drama patches on d1018b31, this one included, not this branch's tip.
  • Exactness, from tools/bench_concurrent.py --alone --serial or token_sha against "draft": false: speech returns PCM, so PCM is compared by SHA-256.
    • GPU setup: 18 server launches, one per arm and seed salt (TENSORFOLD_SEED_SALT 0, 10 and 20), each sent the same 10 public synthetic texts: 180 requests, all complete. Every server ran with --parallel 1 --no-drafts --prompt-cache-gib 0 --context 4096 and TF_DRAMA_PREFILL_ROWS=1, which keeps the candidate on stock's prefill schedule.
    • Arms, with illustrative thresholds that are not calibrated for any voice: stock; the candidate without guard flags ("off"); --silence-floor-dbfs -50 --silence-seconds 8 ("base"); base plus --silence-onset-s 2 --silence-onset-voiced-s 0.4 --silence-mid-s 2 --silence-mid-min-voiced-s 0.4 ("silence"); silence plus --silence-redraws 2 --silence-redraw-budget-s 60 --silence-redraw-controls '' --short-reply-ratio 0.6 --short-reply-chars-per-s 12 ("redraw"); and --register-redraw-st 6 --register-redraw-high 50 --register-high-hz 300 --silence-redraw-budget-s 60 ("register").
    • All checks passed. Off equals stock byte for byte on all 30 replies. Guard headers appear exactly when their option is set. Every guarded reply where no guard fired equals off byte for byte. Each redraw counter equals the redraws that finished with audio. A redraw ran exactly when the silence arm's take ended silence or was judged short. Each of the 22 silenced takes in the base and silence arms is a prefix of the off audio.
    • This PR: the short rule was not exercised. Only one silence-arm take was a stop from a text of 200 characters or more: the trailing text at salt 0, with 12.45 s of audio against a 10.65 s threshold. It was not short, so no short redraw ran. The run shows only that, with the short-reply flags set, redraws ran for silenced takes alone and replies where nothing fired equal off byte for byte.
    • Synthetic socketpair tests against a scripted engine show two things. Without the new flags, a short stop is submitted once, as before. A short take's redraw k uses exactly seedFor(prompt, salt + k).
  • Decode speed before and after, from tools/bench_openai.py: not measured; the GPU run compared PCM, not speed. The check runs once per finished whole take with redraws on. It counts code points only for a stop of 200 bytes or more with both flags set.
  • Prompt speed before and after: the cold first request's ttft_s from tools/bench_cache.py --require-cold on a long prompt, or "n/a" with the reason when the change cannot reach prompt processing: n/a. The check runs after a take finishes and does not reach prompt processing.
  • Tests run, with pass, fail and skip counts:
    • zig build test --summary all: 213/213 steps, 821/823 passed, 2 skipped (steps with unchanged inputs were cached).
    • CUDA_VISIBLE_DEVICES= zig build test-cuda-host --summary all: 131/131 steps, 599/599 passed.
    • An earlier run on the same sources failed only the cortheon fuzz linear-time assertion, in untouched code on a loaded shared host. fuzz-cortheon alone then passed 11/11.
    • test-server-cpu: 532/532.
    • test-kernel-contract: 65/65.
    • test-golden: 306/319 equal, 0 unexpected differences; additional corpus 26/26.
    • The native and drama3-generate build succeeded.
    • tools/zig/test_speech_flags.py: 1 test, OK.
    • Each of sixteen mutations failed a test.
    • After merging the silence-redraws branch at 37079ece:
      • zig fmt --check passed.
      • zig build test --summary all: 213/213 steps, 3003/3017 passed, 14 skipped.
      • CUDA_VISIBLE_DEVICES= zig build test-cuda-host --summary all: 131/131 steps, 1524/1528 passed, 4 skipped.
      • The native build: 98/98 steps.
      • tools/zig/test_speech_flags.py: 1 test, OK.
    • At 40ed23e3, the unsquashed branch tip, after merging the silence-redraws tip 2e6d4858, which changes one plain-speech test input: zig fmt --check passed, and zig build test --summary all passed 213/213 steps, 3003/3017 tests, 14 skipped.
    • At 2cef6e88, which squashes that branch over 49ea53bd: zig fmt --check passed, and zig build test --summary all passed 213/213 steps, 3004/3018 tests, 14 skipped.
  • Not run, and why: Metal compilation, Metal device synthesis and performance measurements, because no Metal host was used and the GPU run measured PCM only. No rate or ratio was measured, because the flags have no default and are calibrated per voice. The new tests do not compile on the base, which lacks the short-reply fields. With the base's silence-only checks restored, they fail. No GPU kernel changed. Frozen test data was not edited.

Checklist

  • 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 precision traded for speed. If the bits change, the description says which sums change and why.
  • A new or changed GPU kernel is registered with the kernel contract (docs/kernel-contract.md); each backend's SUMMARY line is in the receipt.
  • Prompt processing is no slower than the last release.
  • The description says which platforms I ran, Metal M1 to M5 and CUDA, and which I could not.
  • 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. No AI attribution lines.

--allowed-controls keeps listed delivery controls in a normalized form and strips other cue-only brackets before speech input validation; contextual and unknown brackets stay as written. The built-in cue word list holds only words from tags in Fish Audio's public sources.
Add --silence-floor-dbfs and --silence-seconds so native Drama speech can stop after a sustained run below an explicit frame-power floor, keeping the audio and reporting the finish as silence. The guard is off unless both flags are set and is refused for non-speech models.
Bring the opt-in --allowed-controls filter onto the silence guard so silence redraws can reuse its rules. The two changes touch separate flags; only the changelog and the flag parser needed joining.
Add --silence-redraws with an optional --silence-redraw-budget-s and --silence-redraw-controls so a whole reply that ends as silence is drawn again with a salted seed while the budget and X-Deadline-S allow. Streams are never redrawn, and enabled redraws report X-Silence-Redraws.
Add --short-reply-ratio and --short-reply-chars-per-s so a whole reply of 200 characters or more that finishes stop with too little audio for its text is redrawn under the --silence-redraws count, budget and controls. Neither flag has a default, and each needs the other.
@ashhart

ashhart commented Oct 22, 2026

Copy link
Copy Markdown
Owner

Thanks @plotarmordev for keeping the short rule opt-in and paired, judging only stop finishes of at least 200 code points of the text the take actually spoke, and testing the strict duration boundary (zig/src/server/speech_redraw.zig:40, :89-99). The short-reply change raised nothing new for us, so we are carrying it onto current main ourselves on top of #1160, with your commits kept as yours; what it inherits from #1152 and #1157 is fixed once in those PRs, and since #1162 also changes speech_redraw.zig and speech.zig, we will combine the two when the second lands and add a test with both rules set. Since your GPU run notes that no short redraw fired, the device runs on a GB10 and on Metal will include a text that really ends short and compare its redraw with a direct synthesis at the same seed, and then it lands. You need not rebase; if you are in the middle of a change, please tell us so we do not collide.

- Synthema, Ash's AI Assistant.

@ashhart

ashhart commented Oct 24, 2026

Copy link
Copy Markdown
Owner

Landed on main as d091214, thank you @plotarmordev. Whole speech replies that end too short are redrawn. On a GB10, the default Drama output stayed byte-identical to main on six inputs with these options off, repeats were 6/6 equal, and concurrent equalled solo. The speech, Drama, server and golden host suites pass on current main.

- Synthema, Ash's AI Assistant.

@ashhart ashhart closed this Oct 24, 2026
@ashhart

ashhart commented Oct 24, 2026

Copy link
Copy Markdown
Owner

This shipped in TensorFold 1.1.4: https://github.com/ashhart/TensorFold/releases/tag/v1.1.4

Thank you @plotarmordev for the contribution.

- Synthema, Ash's AI Assistant.

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