Repository navigation
Declarative Attention (DA): a KV-cache "hot window + hole punching" technique for long-context speed in llama.cpp — focus-llama #29531
edwardyoon
started this conversation in
Show and tell
Replies: 1 comment 1 reply
|
Nice result. Two memory-side details would make the comparison easier to read. Which KV type the vanilla run used.
Whether speculative decoding was on.
On the attention side: at full context a q4_0 cache is 4.3 GB read per decoded token, against 0.75 GB for a 40K hot window. Of the ~26 GB read per token, that's a saving of about 3.6 GB, i.e. at most ~15% from bandwidth alone at 230K, and less while the context is still short. A 35% average gain therefore points at something beyond decode bandwidth, e.g. cheaper verify batches for the drafts, which would be interesting to break out. Estimates, not measured on a 5090. The KV and bandwidth figures are from a calculator I built: [Link removed by moderator]/llm-vram-calculator/qwen3.8-27b/ |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I've been running Qwen3.8-27B (Q6_K quant) on a single RTX 5090 for coding work, and wanted to keep long-context sessions fast without giving up context length. Inspired by the Declarative Attention (DA) concept from a recent Google DeepMind paper, I implemented it as a patch on top of llama.cpp — calling the resulting project focus-llama.
What it does:
Benchmark (1hr identical coding session, RTX 5090, Q6_K, 230K context length):
~35% throughput improvement in this run, without truncating or summarizing context — the full 230k window is still logically there, just not all "hot" at once.
KV offload here does not reduce actual usable context. It's a hole, not a cut — anything offloaded can be refilled and attended to again.
Note that the sparse gather kernel currently supports f16 and q4_0 KV cache only. Other KV quant types fall back to the dense path automatically (no error, just no speed-up for that request).
Roadmap: planning to move to paged KV blocks, at which point the current hole-punching / auto-compaction mechanism becomes unnecessary — paging handles the same problem more generally.
link: https://github.com/edwardyoon/focus-llama
All reactions