Use encoder sliding_window in encode_step KV cache init#4
Open
artuskg wants to merge 1 commit into
Open
Conversation
bpcnpz
added a commit
to bpcnpz/voxmlx
that referenced
this pull request
Mar 28, 2026
Two bugs caused the encoder to produce garbage embeddings once audio exceeded the sliding window size: 1. Encoder KV cache was initialized with hardcoded 100_000 instead of the actual encoder.sliding_window (750). This meant the cache never rotated, growing unbounded until memory or attention degraded. 2. RotatingKVCache._update_concat trim calculation didn't account for the size of the appended keys, trimming one entry too few. Fixes awni#7. Based on patches from PRs awni#3 and awni#4. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Bug fix: use encoder
sliding_windowfor streaming encoder KV cacheProblem
VoxtralRealtime.encode_step()initialized encoder cache with a large hardcoded size (100000) instead of the model-configured encoder sliding window.Resolution
RotatingKVCache(int(self.encoder.sliding_window))Why this helps
Regression test
tests/test_bugfix_encoder_window_optional.py::test_encode_step_uses_encoder_sliding_windowHow to run