The problem: memory whose final size is unknown
Serving a large language model (LLM) means handling many requests at once, because that is the only way to stop the chip sitting idle waiting on memory, see Continuous batching for that argument. How many requests you can stack up therefore sets the cost. And that number is fixed by a single resource: the memory available for the attention cache.
The attention cache, or key-value cache (KV cache), holds the attention keys and values already computed for each request, so nothing has to be recomputed at every new token. Its size per request is considerable. The vLLM authors work it out for the 13-billion-parameter OPT model:
The factors, one at a time. The 2 on the left is the number of tensors to keep: the key and the value (why not the query? The answer is in KV cache). The 5,120 is that model's internal dimension. The 40 is its number of layers, each with its own cache. The 2 bytes on the right is the cost of one number in FP16, 16 bits divided by 8 makes 2 bytes. Result: 819,200 bytes, that is about 800 kilobytes for a single token.
That model can produce sequences up to 2,048 tokens long. So a single request's cache can reach 1.6 GB. On a 40 GB A100 GPU serving this model, the authors measure the following split: roughly 65 % of memory for the model weights, which never move, close to 30 % for the caches of in-flight requests, and a small remainder for intermediate computations. In other words: a dozen long requests and the card is full.
Efficient Memory Management for Large Language Model Serving with PagedAttention (Kwon et al., 2023)What makes this memory hard to manage
The attention cache has a property no other array of numbers in a neural network has: it grows as you go, and you do not know how far. You have no idea how many tokens the answer will run to. Fifty? Five hundred? Two thousand?
The systems of the day required each request's cache to occupy a contiguous region of memory, one slab, in one piece. Since the final length is unknown, the only safe move is to reserve room for the longest possible answer the moment the request arrives. It is like booking a table for twenty for every diner walking into a restaurant, in case they turn up with nineteen friends.
The authors distinguish three different wastes, and it is worth naming them separately because they are not cured the same way:
- Slots reserved for later. They may eventually be used, but meanwhile they are tied up and nobody else can touch them.
- Internal fragmentation. The answer stopped after 30 tokens although room for 2,048 had been reserved: the remaining 2,018 slots will never serve anyone, this request or any other, until it releases its slab.
- External fragmentation. Between two reservations of different sizes, gaps are left that are too small to hold the next reservation. They are free, and yet unusable.

The authors measured what the systems of the day actually lost. Their wording: only 20.4 % to 38.2 % of the cache memory was in fact holding tokens. So between 60 % and 80 % of that memory was wasted. Read it carefully, because the confusion is easy and common: this is the memory reserved for the cache, not all the GPU's memory. Since the cache accounted for about 30 % of the card in their example, this corresponds to roughly twenty-odd percent of total memory wasted, substantial, but not 80 %.
The analogy that gives the method its name
This problem is not new. Operating systems ran into it, and solved it, in the 1960s. The solution is called paged virtual memory, and it is worth explaining, because PagedAttention is not vaguely inspired by it: it is very nearly a term-for-term transposition.
The problem operating systems had
Several programs run at once on a machine. Each needs memory, and its appetite changes as it runs. If you require each program to occupy a contiguous region, you land on exactly the three wastes above: space reserved for nothing, unusable gaps between programs, and the impossibility of growing a program whose immediate neighbour already occupies the next slot.
The solution
You stop requiring contiguity. To do that, you introduce two levels of address:
- Physical memory is cut into pages of fixed, identical size, say 4 kilobytes each.
- Each program, for its part, goes on seeing its memory as one tidy continuous run: its page 0, its page 1, its page 2. That is a fiction, maintained for its benefit alone.
- A page table, one per program, ties the two together: it says that the program's page 0 actually lives in physical page 7, its page 1 in physical page 12, and so on. The hardware consults that table on every access.
What this fixes, point by point. External fragmentation disappears: since all pages are the same size, any free page will do for any need, and there are no more wrongly sized gaps. Internal fragmentation collapses: you lose at most one partly filled page per program, instead of an entire oversized reservation. And growing no longer means moving: you just add a line to the page table, taking any free page wherever it happens to be.
The transposition
The PagedAttention authors put it in these very terms: think of blocks as pages, tokens as bytes, and requests as processes.
| Operating system | PagedAttention |
|---|---|
| a process (a running program) | a user request |
| a page of memory | a fixed-size block of cache |
| a byte within a page | one token's cache within a block |
| the process's page table | the request's block table |
| the machine's physical memory | the GPU's memory |
The analogy is not decorative: it carries the finer mechanisms too, as the section on sharing pages between processes will show.
How PagedAttention works
Each request's cache is cut into fixed-size blocks, each holding the keys and values of a fixed number of tokens, 16 in the paper's experiments. The blocks of a single request can sit anywhere in GPU memory.
- Request A, 120 tokens: physical blocks 5, 12, 3, 8, 1, 14, 6, 11.
- Request B, 30 tokens: physical blocks 7, 1.
Each request has its block table, translating "my block number 2" into "physical block number 3". The request itself knows nothing of the scattering.
Allocation happens on demand: a new block is claimed only once the previous one is full. And the instant a request finishes, all its blocks become available again immediately, to any other request.
The remaining waste therefore shrinks to one thing only: each request's last, partly filled block. The authors call that near-zero waste.
A one-token block would eliminate waste entirely. Why not do it? Because the attention computation is more efficient when it handles several consecutive positions in a contiguous region: memory reads coalesce and the hardware works better. The authors say so explicitly: a larger block improves hardware utilization, a smaller one reduces fragmentation. Sixteen is a balance point, not a magic number.
The attention computation, adapted
The attention operation has to learn to read its keys and values from scattered blocks instead of one continuous region. That is the job of the PagedAttention kernel, a kernel here meaning a small program written specifically to run on the GPU. It consults the block table, fetches each block wherever it is, and computes block by block. That is the price of memory flexibility: a slightly more complicated operation, whose overhead is amply repaid by the extra requests it buys.
Sharing, which comes as a bonus
Once you think in pages, a classic operating-system mechanism becomes available: two processes can point at the same physical page. That yields two distinct gains.
Shared beginnings
Many requests start with the same text: the same system instructions, the same examples, the same context document. And the attention cache for that beginning is identical across all those requests. Rather than keeping one copy per request, you compute it once and have every block table point at the same physical blocks.

In the authors' experiment, that sharing of request openings accounted for 12 % of total cache memory. Here is what it comes to for a common case, worked out in the open: a 4,000-token context document, a 7-billion-parameter model whose cache costs about 0.5 MB per token, and a hundred requests sharing that same document.
- Without sharing: of cache.
- With sharing: , once.
To which add the computation saved: processing 4,000 tokens through a 7-billion-parameter model takes roughly operations, about 56 thousand billion. Doing that once instead of a hundred times saves several million billion operations. Prefix sharing is by far the most profitable optimization for systems that reload the same context on every request.
Copy-on-write
The second use of sharing: when you ask the model for several different answers to the same question. At the start the answers are identical (they begin from the same text) so they can share their blocks. For each block you keep a reference count: how many sequences are using it.
The moment a sequence wants to write into a shared block, and only then, a private copy is made for it. That is copy-on-write, exactly the mechanism operating systems use when a program forks. Only what actually diverges gets duplicated.

The authors measure that on beam search (a generation method that explores several continuations in parallel and keeps only the best) this sharing saves up to 55 % of memory. That is the most favourable case, because beam-search branches have long shared openings by construction.
Measured results
The paper's abstract reports 2× to 4× more throughput at equal latency against the best systems of the day, FasterTransformer and Orca. The conditions matter, and the authors give them. On a set of real conversations from ShareGPT, vLLM sustains:
- 1.7× to 2.7× more requests per second than Orca in its most favourable variant (the one that assumes each answer's exact length is known in advance, an oracle, hence an unrealistic and deliberately harsh baseline);
- 2.7× to 8× more than Orca in its realistic variant, which reserves the maximum length;
- up to 22× more than FasterTransformer.
And the cause, measured directly: on OPT-13B, vLLM handles 2.2× more requests concurrently than Orca-oracle and 4.3× more than Orca-maximum. The throughput gain does not come from faster arithmetic, it comes from how many requests you can fit. The authors add that the gap widens with longer sequences, larger models and more complex generation methods, which is consistent, since those are exactly the cases where cache memory weighs most.
The limits
GPU memory is still finite. Past a certain point there are no free blocks left and the server must choose: either swap one request's cache out to the computer's main memory, paying a slow transfer to bring it back, or discard and recompute it later. Either way the affected request slows down markedly. PagedAttention pushes the wall back; it does not remove it.
There is also the block-size trade-off already mentioned: larger blocks make the computation more efficient but waste more in the last block; smaller blocks, the reverse.
PagedAttention does not make the model faster: it does not touch it. It increases how many requests one card can carry at once, hence total throughput and hence cost per token. The response time of a single isolated request is not improved. Size your infrastructure to the expected load, knowing that beyond the saturation point latency does not rise gently: it explodes, because the queue starts growing without ever draining. The authors show precisely that curve.
What came next: RadixAttention
RadixAttention, used by the SGLang engine, pushes block sharing further. Instead of pooling only entirely identical request openings, it files every active cache into a prefix tree (a radix tree): a structure where each branch is a beginning of text, and where two requests automatically share whatever path they have in common, even if they diverge afterwards.
The point: two requests sharing a large part of their context without being identical still benefit from sharing, and finding the longest common opening costs time proportional to the length of the text, not to the number of requests in flight. It is the natural refinement of the original idea.
What to take away
PagedAttention is a textbook case of transferred insight: a problem solved sixty years ago in operating systems, recognized in a new disguise. The full argument runs in four steps.
- The number of concurrent requests sets the cost of inference, because otherwise the chip sits idle waiting on memory.
- That number is capped by attention-cache memory, whose final size is unknown in advance.
- Requiring one contiguous region per request forces you to reserve the worst case, and loses 60 % to 80 % of that memory.
- Cutting it into fixed-size blocks with a translation table removes most of that loss, and opens up sharing between requests as a bonus.
Hence 2× to 4× the throughput at equal latency, without touching the model. This is now the standard way to serve an LLM, and the foundation of the vLLM engine, which also exposes an OpenAI-compatible interface, accounting for a good part of its adoption.
1. Before PagedAttention, servers lost 60 % to 80 % of the memory set aside for the attention cache. Where did that waste come from?
2. The vLLM paper measures that only 20.4 % to 38.2 % of memory was actually holding tokens. What exactly does that figure refer to?
3. Through what mechanism does PagedAttention remove most of that waste?
4. You ask the model for four different answers to the same question. How does vLLM handle their caches?
5. A deployment switches to vLLM and its throughput triples. Will a lone user, alone on the machine on a Sunday morning, see their answer arrive faster?