Repository navigation
feat(#33): experimental Quest block-sparse decode attention behind serve --quest-top-k - #281
Merged
Merged
Conversation
…rve --quest-top-k On a decode step, a full-attention layer attends to 128 sink tokens, the last 256 or more, and the top-k 64-token blocks between them, picked per KV head from per-block key maxima and minima. Prefill stays dense. Models whose attention reads the whole cache through cache.update (Gemma 4) are refused at load with a warning and stay dense. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012cicgudpVmSKaQgaioocQ1
Owner
Author
|
Passkey added after the merge on the MoE models, at commit c8abc66 (same tree as 289ea74). Log:
🤖 Generated with Claude Code |
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.
Part of #33 (Quest). The rest of #33 shipped in #276. The ≥ 2× attention target moves to #280.
What
basalt serve --quest-top-k N(also inPerformanceBenchmark). It is experimental.Σ_d max(q·max, q·min)over per-block key bounds, summed over the GQA group.QuestKVCachereplaces theKVCacheSimplelayers only. Hybrid models keep their recurrent layers.KVCacheAttentionProtocol.updateAndAttend. Gemma 4 reads the whole cache throughcache.update, so it is refused with a warning and stays dense.--kv-bits,--kv-zones,--kv-head-splitor prompt-cache namespaces.Found while measuring: the block bounds have to be evaluated with the cache (
innerState). Without that, a 30k prefill keeps every intermediate key buffer alive and runs out of Metal memory.Measured
Apple M4 Pro, 24 GB.
logs/quest-passkey.log,logs/quest-passkey-2.log,logs/quest-passkey-gemma.log.Passkey
Greedy, corpus37, 5 depths (0.1, 0.3, 0.5, 0.7, 0.9).
Decode speed
Release build, ~30k-token prompt (120,000 characters of corpus37), 256 tokens, T=0.7, seed 7.
Checks
swift build -Xswiftc -warnings-as-errors(debug and release) passes.swift test --parallel: 1243 tests, all pass.check_no_new_comments.py: no comments added.QuestKVCacheTestsreports only MLX-internal allocator and scheduler races, not code in this PR.🤖 Generated with Claude Code
https://claude.ai/code/session_012cicgudpVmSKaQgaioocQ1