feat(supertonic): pick a latent-length bucket per piece - #144
Merged
Conversation
The published LiteRT graphs are fixed at L=64 (~4.5 s), so a sentence the window cannot hold is split and the second piece restarts with sentence-initial prosody. A bundle may now ship extra fixed-L exports of the two L-dependent graphs next to the base ones (`vector_estimator_L128.tflite` + `vocoder_L128.tflite`, from speech-models' export_litert.py --latent-frames 64 128). They are discovered at construction and loaded on first use; each piece runs on the smallest bucket whose window holds its predicted duration, so short pieces keep the cheap base graph and a long sentence is generated in one pass. The planner's window becomes the largest bucket, and a split only remains for text longer than that. A bucket that fails to load is skipped with a log line. Without extra graphs the output is unchanged (verified byte-identical).
The converter permutes a graph's input slots away from the signature order,
and differently per toolchain version: the published base graphs bind
[text_mask, text_ids, style_dp] where a current litert-torch export binds
[text_ids, style_dp, text_mask]. The hard-coded slot order therefore broke
any re-exported graph at run time ("Failed to register input tensor buffer"),
including the L=128 bucket. Resolve the slot per role from the tensor names
(`serving_default_args_N`) when a model is loaded, for the duration
predictor, the text encoder and every vector_estimator bucket, and keep the
published order as the fallback. Output for the published bundle is
unchanged (verified byte-identical).
ivan-digital
force-pushed
the
feat/supertonic-latent-buckets
branch
from
August 30, 2026 10:36
d41e996 to
01b8d51
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #141. The published LiteRT graphs are fixed at L=64 latent frames (~4.5 s), so a sentence the window cannot hold is split, and the second piece — a separate generation — restarts with sentence-initial prosody. That residual roughness cannot be fixed on the host; it needs a longer window.
soniqo/Supertonic-3-LiteRTnow ships an L=128 bucket (vector_estimator_L128.tflite+vocoder_L128.tflite, ≈9 s; exported by speech-models'export_litert.py --latent-frames 64 128). This PR teachesLiteRTSupertonicTtsto use it.What changed
*_L{N}.tflitesiblings of the base graphs are discovered at construction (latent_buckets()) and loaded on first use, so memory only grows when a long piece needs one. Each piece runs on the smallest bucket whose window holds its predicted duration (choose_latent_bucket(), pure + unit-tested); the planner's window is the largest bucket. A bucket that fails to load is skipped with a log line and the piece falls back to a smaller window.[text_mask, text_ids, style_dp], a currentlitert-torchexport binds[text_ids, style_dp, text_mask]. Slots are now resolved fromserving_default_args_Nat load for all three multi-input graphs, with the published order as fallback. Without this, any re-export of the bundle would have broken at run time ("Failed to register input tensor buffer").LiteRTSupertonicTtssection indocs/models.md.Test plan
choose_latent_bucketunit test intests/test_supertonic_tokenizer.cpp; LiteRT suite 39/39._L128files): output byte-identical to fix(supertonic): stop stranding sentence tails in their own chunk #141 — both before and after switching to name-based binding.L=90/128,L=97/128) — no seam, no restart;L=112/128.vector_estimator_L128max|Δ| 1.7e-2 (relative 2.7e-3; the published L=64 graph measures 5.4e-3 / 9.2e-4 under the same test),vocoder_L1282.7e-4.Depends on the L=128 files being published to
soniqo/Supertonic-3-LiteRT; without them behaviour is unchanged.