179 questions
No questions match those filters.
← All questions
Inference & ServingMedium· KV Cache· Inference Optimization· GPU Utilization
Explain the KV cache and why generation has different GPU utilization characteristics than prefill.
This is one of the questions in the full AI/ML interview bank. Pro unlocks all 1789 questions; Premium includes the same bank plus the highest daily Practice limit.
See plansDuring prefill, the GPU processes all prompt tokens in parallel using large matrix multiplications, making it compute-rooflined. During generation, the model produces one token at a time while attending to cached KV pairs, resulting in matrix-vector multiplications that are memory-bandwidth-rooflined. The KV cache stores projections for every prior token, with size scaling based on sequence length, head count, and head dimension.