PagedAttention is a way of computing attention that splits the KV cache used during text generation (the keys and values of past tokens) into fixed-size "blocks" so that attention can be computed while the blocks sit in non-contiguous locations in memory. Kwon et al. at UC Berkeley proposed it in 2023 in the paper "Efficient Memory Management for Large Language Model Serving with PagedAttention" (SOSP 2023) and released vLLM, an inference server built on it.
A large language model generates text one token at a time. Each step needs the keys and values of all past tokens, so they are stored in GPU memory to avoid recomputing them. This is the KV cache. The KV cache is very large: in the paper's example, the 13-billion-parameter OPT needs 800 KB per token and up to 1.6 GB for a single request.
Earlier inference servers placed each request's KV cache in contiguous memory and, since the output length is unknown in advance, reserved space for the maximum length (e.g., 2,048 tokens) up front. The paper measured that only 20.4โ38.2% of the reserved memory actually held token states.
PagedAttention brings in the idea of virtual memory and paging from operating systems.
| OS virtual memory | PagedAttention / vLLM |
|---|---|
| Page | KV block (keys and values for a fixed number of tokens) |
| Byte | Token |
| Process | Request |
| Page table | Block table (logical block โ physical block) |
As a bookshelf analogy: instead of emptying an entire shelf for one book (request), the pages are bound into files of a few sheets each and slotted into any free space on any shelf, with a table of contents (the block table) keeping track of their order.
In the figure at the top of the article, the right side shows how the KV cache is laid out, and the left side shows the attention computation when generating one token.

