Repository navigation
Protect a bounded instruction prefix in selective KV retention - #297
Draft
Gajesh2007 wants to merge 1 commit into
Draft
Gajesh2007 wants to merge 1 commit into
Gajesh2007 wants to merge 1 commit into
Conversation
javiech1
pushed a commit
to javiech1/mlx-swift-lm
that referenced
this pull request
Oct 24, 2026
This branch has not been deployed
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.
This adds a bounded, explicit instruction prefix to the existing selective full-attention KV experiment. A caller can protect at most 256 initial tokens; the separate provider candidate fixes this to 128. The default remains zero, preserving the original four-anchor policy. A read-only diagnostics accessor records the actual configured policy.
The physical compaction path, absolute-position clock, chronological retained order, recent band, speculative rollback and conservative native reservation are unchanged. This is a stacked draft on #295. It does not enable production serving or change quantization.
Before
After
Validation: two
CBv2InstructionPrefixRetentionTestspass on rebuilt native products, including a regression where the ordinary policy loses early entries, repeated pruning, chronology, recent512, absolute clock, speculative rejection and identical dense reservation. Provider integration tests pass separately. Strict Swift formatting and diff checks pass. The required dedicated refactor found and fixed a provider harness environment-injection mismatch in the companion PR; SDK arithmetic remained unchanged. Both published figures were visually verified on GitHub. Full hosted checks are tracked separately.Quality is not qualified by these unit tests. The companion experiment preregisters one fixed candidate, six recovery observations per arm and twelve new arithmetic/code/tool cases. Full FP32 K-history casts and source/destination overlap still need bounded scratch and serving qualification. No admission credit is taken from logical or observed allocator savings.
The companion fixed campaign is now complete in provider PR #1417: both arms pass 10/12 new cases, but the original recovery regression remains native 6/6 versus candidate 0/6. This candidate remains draft and is not qualified for serving. No repeated tuning followed the result.