15m: KV Cache from scratch: Why K and V but never Q
Registration
Past Event
About Event
Something interesting: every LLM caches K and V at inference time, but never Q. Most explanations stop at "you don't need the old queries" without showing why. I worked the whole thing out from a 1-layer, single-head transformer. The smallest setup where the logic is actually visible.
why most of a transformer runs per-token, and attention is the only place tokens mix
working backwards from the output to find the minimum you need to predict the next token
why old keys and values don't change when you append a token (and old queries become useless)