AI Hardware & Software Stack
What is the role of the KV cache in LLM inference?
- AIt stores frequent questions and answers to reply instantly to repeats
- BIt places all model weights in the CPU cache
- CIt stores the attention keys and values of already processed tokens so they need not be recomputed for each new token
Show answer and explanation
Answer: C. It stores the attention keys and values of already processed tokens so they need not be recomputed for each new token
In attention, each new token refers to the keys and values of all earlier tokens. Those keys and values do not change, so storing them instead of recomputing means only the new token's share must be computed. That store is the KV cache. It cuts computation dramatically, but the amount of stored keys and values grows in proportion to sequence length and batch size.
- A. It does not store answers.
- B. It is unrelated to CPU caches.
- C. Correct. It trades memory for a large reduction in computation.