Name two production KV-cache eviction policies and what each prioritizes
When generation pushes the KV cache past its memory budget at long context, the server must evict cache entries to keep going. Name two production-grade eviction policies, describe what each keeps and what each drops, and note the bookkeeping cost of each.
Two production policies: sliding-window (keep last W, free bookkeeping) and heavy-hitter (keep tokens with highest accumulated attention weight, per-token score tracking).
Picture a chef's prep station that can only hold 20 ingredients at a time. As new ingredients come in, old ones have to go. The simple rule is 'whatever has been sitting longest, throw it out',that is sliding-window. The smarter rule is 'whatever the recipes keep reaching for, keep it; whatever has been ignored, throw it out',that is heavy-hitter. The smarter rule needs the chef to keep a tally of how often each ingredient gets used, but it preserves the important stuff better. Production kitchens often blend the two: always keep a few staples like salt at the start, and otherwise rotate the recent and the popular.
Detailed answer & concept explanation~7 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
Name sliding-window eviction (keep last W, free bookkeeping) and heavy-hitter eviction (keep top-k by attention score, per-token bookkeeping). Cite StreamingLLM as the hybrid and explain attention sinks. Close with the production decision rubric: bounded context vs streaming vs extreme long context.
Real products, models, and research that use this idea.
- Mistral 7B: sliding-window attention with W = 4096 is the architectural form of sliding-window eviction.
- H2O (NeurIPS 2023): the canonical heavy-hitter eviction paper; showed near-lossless quality at 20% cache size on long-context QA benchmarks.
- StreamingLLM (Xiao et al., 2024): attention-sink + recent-window hybrid, deployed widely in 2024-2026 long-context serving stacks.
- DeepSeek V4 multi-head latent attention: not eviction but related, compresses KV per token to shrink the budget pressure that eviction tries to address.
- vLLM and SGLang in 2026: support sliding-window and StreamingLLM-style hybrids as configurable serving policies.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy does dropping the first few tokens collapse the attention distribution in long generations?
QHow does heavy-hitter eviction interact with grouped-query attention (GQA) where K and V are shared across query heads?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Treating KV cache eviction as a pure capacity problem with one right answer. Quality varies by eviction policy because not all cached tokens are equally useful for future generation.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.