As asked
Walk me through how vLLM's PagedAttention allocates and manages KV cache memory at runtime. How is it different from the contiguous pre-allocation that Hugging Face transformers uses, and what problems does it actually solve?
Sample answer outline
A strong answer explains that standard inference pre-allocates a contiguous KV cache block proportional to max sequence length, wasting memory for short sequences. PagedAttention divides the KV cache into fixed-size logical blocks mapped to non-contiguous physical pages, like virtual memory in an OS. This lets multiple sequences share the physical memory of prefilled prompt tokens (prefix sharing), dramatically increasing GPU utilization and throughput under mixed-length traffic.
Expect these follow-ups
- How does prefix caching build on top of PagedAttention?
- What happens to the block table when a request is preempted and later resumed?