Repository navigation
Add experimental selective full-attention KV working sets - #295
Draft
Gajesh2007 wants to merge 2 commits into
Draft
Gajesh2007 wants to merge 2 commits into
Gajesh2007 wants to merge 2 commits into
Conversation
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.
Full-attention rows currently retain every native K/V entry through decode. Add an explicit experimental working-set policy that preserves dense prefill, initial anchors, at least 512 recent tokens, and half of older history in chronological 16-token chunks. Attention mass from at most four queries ranks chunks; one quarter of the retained chunk budget supplies evenly spaced coverage.
The row's absolute RoPE clock remains independent of retained count, native dtype/value geometry stays intact, and configured sliding windows stay native. Unknown prefix identity fences exact cache export/adoption. MTP is disabled because assistant snapshots lack sparse absolute positions. The companion provider PR #1412 restricts activation to explicit Gemma/GPT-OSS singleton benchmarks.
This remains draft: real generation found a reproducible GPT capped-completion regression. Six frozen-binary native replays finish correctly in 164 tokens; six selective replays exhaust the matched 256-token cap before a final answer. Serving remains rejected. Gemma matches all 14 native output arrays in the measured matrix, including its existing native errors; that is limited parity evidence, not general quality qualification.
Before
After
The dedicated refactor removes a redundant gather-to-new-row copy. One gather includes bounded spare slots; the owned row adopts those buffers and overwrites each spare before exposing it. Tests cover native and unequal value widths, spare capacity, rollback, GQA/sinks, chronological selection, Gemma borrowing, and real allocator release.
Validation:
46477f0.Full native-model results, artifact hashes, raw reports, refactor evidence and limitations.
The score matrix uses at most four query rows, but non-FP32 key histories are still cast in full to FP32. Gemma 26B's 32K global layer has two KV heads and D512: 128 MiB of key-cast payload per layer, in addition to score/normalization scratch and compact destination overlap. Dense prefill still determines peak prompt memory, and no additional admission capacity is claimed. Fused native-key scoring and protected instruction spans require separate, newly qualified cohorts.