Serving a large language model in production is rarely bottlenecked by math speed. It is bottlenecked by how you pack short-lived conversation memory into expensive GPU RAM. This guide breaks down the vLLM paper into five interactive labs—no advanced math required.
Generating text happens in two phases. First, the prompt phase reads your entire input at once using fast parallel matrix math. Second, the generation phase predicts one new word (token) at a time. To avoid re-reading earlier words on every step, the GPU stores a scratchpad of previous key and value vectors called the KV cache.
Because model weights are locked in memory and never shrink, the remaining slice left for the KV cache strictly limits how many users you can batch together. Pick a real hardware setup from the vLLM benchmarks below to see how much room is left for user requests.
Pre-allocates 2,048 tokens per request; only ~20.4% of KV space stores real tokens.
96.3% effective KV cache utilization—fitting roughly 3×–4× more concurrent users.
Same GPUs, same weights—just zero wasted memory between requests.
Deep learning frameworks normally expect each tensor to sit in one unbroken, contiguous line of memory. Because a server cannot predict when a chatbot will emit an end-of-sequence token, older systems pre-allocate a chunk big enough for the worst case. That creates three distinct leaks:
64 total GPU KV slots. Each request locks a contiguous slice up to its max limit (16 or 32 slots).
Same 64 GPU KV slots, split into 16 blocks of 4 tokens. New blocks are allocated only as tokens arrive.
In 1970, computer scientist Peter Denning summarized how operating systems solve fragmentation: give every program a clean, continuous list of logical addresses, and let a lookup table—the page table—map each piece to wherever free space actually lives in physical RAM.
vLLM brings this exact pattern to attention. Your prompt and output fill Logical KV Blocks strictly from left to right. Behind the scenes, the Block Table maps each logical block to any free Physical KV Block on the GPU. Step through the paper's exact example below.
Tip: Click any filled token above to trace how the PagedAttention kernel reads its history across scattered blocks.
| Logical | Physical # | Filled |
|---|
If blocks are tiny (1–2 tokens), the GPU wastes time hopping through block table lookups instead of reading memory in big parallel bursts. If blocks are huge (128–256 tokens), short prompts leave most of the block empty—bringing back internal fragmentation. Slide the block size below to see how latency reacts across short and long workloads.
Because every request reads memory through a Block Table, two different requests can point to the exact same Physical KV Blocks without knowing it. Think of two developers branching off the same starter repository: neither duplicates the shared files unless they edit a line.
Each physical block tracks a reference count. When two samples share a block (ref_count = 2) and Sample A1 needs to append a different word, vLLM uses Copy-on-Write (CoW): it copies just that one block into a free physical slot, lowers the old reference count to 1, and lets Sample A2 write directly to the original block with zero extra copying.
Even with zero fragmentation, a sudden traffic spike or runaway conversation can fill 100% of your physical KV blocks. When that happens, vLLM uses a First-Come, First-Served (FCFS) rule: it pauses the newest request so older requests can finish and free their blocks.
Because every token in a sequence needs all previous tokens to continue, vLLM evicts all or none of a request's blocks. Once space clears up, it can recover that paused request in two ways: Swapping the blocks to CPU RAM over PCIe, or Recomputing the KV cache in one fast parallel prompt pass. Test how block size changes the winner below.
Waiting for preemption event.
By packing 96.3% of KV memory with real tokens, sharing prompt blocks via Copy-on-Write, and recovering gracefully under spikes, vLLM fits dramatically larger batches on the same GPUs. Explore the paper's measured batch capacity and check your intuition below.
Test what you have explored. Click the best engineering choice for each production scenario.
| Paper Term | Plain-English Meaning | Why It Matters in Production |
|---|---|---|
| KV Cache | Saved intermediate memory of earlier tokens in a conversation. | Takes ~30%+ of GPU RAM and grows unpredictably with every word generated. |
| Logical vs. Physical Block | Continuous sequence order vs. scattered fixed-size chunks in GPU RAM. | Eliminates pre-allocation waste and external fragmentation. |
| Block Table | A lightweight index mapping each sequence's logical blocks to GPU block IDs. | Lets the attention kernel read scattered memory as if it were contiguous. |
| Copy-on-Write (CoW) | Sharing physical blocks until a branch writes a different token, then copying one block. | Cuts memory up to 55% in beam search and speeds up shared system prompts by 3.58×. |
| Recomputation vs. Swap | Drop KV cache and re-run prompt math vs. offload blocks to CPU RAM over PCIe. | Recomputation beats swapping at small block sizes and stays predictable (~20 ms). |