perf(voxtral): O(1)-per-chunk conv-stem for streaming (no more O(n²) prefix recompute)#17
Merged
Merged
Conversation
The stream session recomputed mel + conv stem over the ENTIRE accumulated audio on every chunk — O(n) per chunk, O(n^2) per stream — including a CPU reflect-pad round-trip of the whole buffer. Mid-stream chunks now derive the padded-audio geometry arithmetically and compute only the new conv rows from a bounded raw-sample window. Bit-exactness: conv row f needs mel frames [2f-3, 2f+1]; a mel frame covers [m*hop - win/2, m*hop + win/2) of the left-padded audio; the STFT reflect pad resolves to zeros (left pad >= win/2 zeros) and frozen frames never reach the right pad (covered by frozenGuardTokens — the dropped-partial-frame token count guarantees >= 40 samples of slack for any chunk size). First chunk and finish() keep the full stem so the final transcript stays equal to offline generate(). WER(stream vs offline) = 0.0000 on conversational_a at 90/333/480/730ms chunks, intention, conversational_fr, and a 12-min stream (1520 chunks, median step 0.193s, end-to-end realtime).
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 #16.
VoxtralRealtimeStreamSessionrecomputed mel + conv stem over the entire accumulated audio on every chunk (O(n²) per stream, plus a CPU reflect-pad round-trip of the whole buffer each step). Mid-stream chunks now derive padded-audio geometry arithmetically and compute only the new conv rows from a bounded raw-sample window — O(1) per chunk regardless of stream length.Why it's bit-exact
[2f-3, 2f+1]; a mel frame covers[m·hop − win/2, m·hop + win/2)of the left-padded audio — bounded lookback/lookahead.finish()keep the full stem, so the final transcript stays equal to offlinegenerate().Verification
WER(stream vs offline) = 0.0000 on:
swift build+swift build --build-testsclean.