Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
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.
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.
What an interviewer would ask next. Try answering before peeking at the approach.
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.