Paged Attention
Serving a language model wastes memory for a dull reason: nobody knows in advance how long the answer will be. Reserve room for the longest possible reply and most of that room sits empty. Paged Attention borrows the operating system's solution to the very same problem.
Blocks and a block tableThe KV cache for a request is cut into fixed-size blocks, typically 16 tokens each, which can live anywhere in GPU memory. A per-request block table maps logical token positions to physical blocks, exactly as a virtual-memory page table does, and a new block is allocated only once the previous one fills. The attention kernel is rewritten to gather keys and values across scattered blocks instead of assuming one contiguous array. Earlier serving stacks pre-allocated a contiguous buffer sized to the maximum sequence length and lost most of it to fragmentation; paged attention cuts that waste to a few percent.
What the freed memory buys- More sequences fit on one GPU at once, and batch size is what determines throughput in a memory-bound workload — the original work reports several times the throughput at equal latency.
- Blocks can be shared: several samples from one prompt, or thousands of requests behind one long system prompt, point at the same physical blocks with copy-on-write, so the shared prefix is stored once.
- A long context stops being an all-or-nothing allocation, which is what makes continuous batching practical.
It arrived as the central idea in vLLM and is now standard across serving stacks. When a self-hosted model suddenly handles far more concurrent users after a move to vLLM, this is usually the reason.
Paged Attention stores a request's KV cache in fixed-size blocks scattered across GPU memory, with a per-request block table mapping logical token positions to physical blocks — virtual-memory paging applied to inference. It removes the fragmentation of reserving a contiguous maximum-length buffer, lets identical prefixes be shared copy-on-write, and so raises how many sequences a GPU serves at once. It is the core mechanism behind vLLM's throughput.
A chat assistant has to remember the conversation while it writes, and that memory sits on an expensive graphics card. Older systems booked a whole shelf per user, sized for the longest reply they might ever produce — so most shelves sat half empty while new users were turned away. Paged Attention hands out memory in small boxes instead, as they are needed, and keeps a little index of which boxes belong to whom. Almost nothing is wasted, and conversations that start the same way can share a box. The practical result is that the same hardware serves several times as many people at once.