GO TO A SECTION

↑ ↓ to navigate · Enter to openExplore all sections →
FDEInterviews logo
← LLM & GenAI Fundamentals / 52
medium★ EssentialNVIDIAOpenAIGoogle

KV-caching in autoregressive decoding: what does it store, why does it cut latency, and how does its memory cost scale?

Without a KV cache, generating token N re-attends over all N-1 prior tokens from scratch every step, turning decoding quadratic. The cache stores each layer's past keys and values so each new token costs one forward step, and its size is what caps your batch and context.

Updated Aug 2026 · Grounded in real Forward Deployed Engineer interview loops and written to a senior-engineer editorial bar.

Without a KV cache, generating token N re-attends over all N-1 prior tokens from scratch every step, turning decoding quadratic. The cache stores each layer's past keys and values so each new token costs one forward step, and its size is what caps your batch and context.

20 answers per topic instead of 10, plus saved progress and bookmarks · no cardor unlock all 548 remaining answers · ₹2,000 / $25

Every answer, concept and course, every paper breakdown, all published video lessons, hands-on FDE Lab missions, Premium PDF guides and companion files, the full practice-test bank and work-sample downloads. Referral Premium excludes guide PDFs and their companion files.

6 months · One payment · No auto-renewal

Study alongside free video lessons.

Keep practising

FEDITOR'S NOTE

The screen is whether the candidate knows the cache stores per-layer attention keys and values for all prior tokens (not the activations, not the logits), why that turns per-token cost from re-processing the whole sequence into a single new-token step, and the scaling law: memory ~ 2 * batch * seq_len * layers * kv_heads * head_dim * bytes. The reserved follow-up: 'so how do you shrink it' (GQA/MQA, quantizing the cache, paged attention). Saying it 'caches the output' or forgetting the linear growth with sequence and batch is the tell.

DISCUSSION · 0

No comments yet — be the first to share your approach.