Name two recovery moves a serving stack can pull when KV memory runs short mid-request.
A long-context serving job is about to exceed its KV cache budget mid-generation. The scheduler can either kill the request or degrade quality gracefully. Name two attention-side strategies the runtime can apply, and explain the tradeoff each makes.
Eviction (drop tokens, sliding window or H2O) and in-place quantization (FP16 to INT8 or INT4). Both degrade quality gracefully instead of OOM-killing the request.
Picture a bookshelf running out of room while you are still adding books. Two ways to make space without throwing the whole shelf out. First, toss old books you have not opened in a while, you lose some content but you keep reading. Second, photocopy each book into smaller print so each one takes half the space, you keep every book but the print is harder to read. A serving system's short-term memory works the same way: drop notes you probably will not need (call it eviction) or store each note using fewer digits per number (call it compression). Real systems usually do both before giving up and dropping the whole job.
Detailed answer & concept explanation~6 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.
6-8 min: KV memory equation + eviction policies (sliding, H2O, StreamingLLM) + quantization policies (INT8, INT4, FP8) + composition in real serving stacks + the role of PagedAttention.
| Strategy | Axis attacked | Quality tradeoff | Implementation cost |
|---|---|---|---|
| Sliding window | Entry count (T) | Drops oldest context | Trivial |
| H2O | Entry count (T) | Drops low-attention tokens | Per-token running sum |
| StreamingLLM | Entry count (T) | Window + sink tokens | Trivial extension of sliding |
| INT8 KV | Bytes per entry (b) | Compounds across layers | Per-channel scales |
| INT4 KV | Bytes per entry (b) | Stronger precision loss | Per-group scales (KIVI) |
Real products, models, and research that use this idea.
- vLLM with PagedAttention plus INT8 KV cache support combines block-level memory layout with quantization.
- TensorRT-LLM ships INT8 and FP8 KV cache modes targeted at H100 and newer GPUs.
- StreamingLLM (the 'attention sinks' paper, MIT 2023) and H2O (2023) are the canonical eviction references cited in serving stack docs.
- Llama 4 Maverick, DeepSeek V4, and Qwen 3.5 long-context configurations rely on GQA plus FP8 or INT8 KV quantization for fleet-scale serving.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy does pure sliding window degrade quality even when window is generous?
QWhat is PagedAttention and how does it relate to KV cache management?
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.
Forgetting that long-context serving has two orthogonal shrink axes (entry count and bytes per entry) and naming only one. A senior answer mentions both.
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.