PagedAttention explained in one sentence: it is a way of storing a language model’s key-value cache in small, fixed-size blocks that can sit anywhere in GPU memory, instead of one large unbroken chunk per request. Should you care about it if you serve large language models? Yes, because the technique behind vLLM removes the memory waste that caps batch sizes, and the paper behind it reports two to four times the serving throughput of the systems it replaced at the same latency.
The problem it solves is easy to picture. Every request a model serves needs a key-value cache, usually called the KV cache, that grows token by token as the model generates text. Older serving systems reserved a single contiguous block of memory for each request, sized for the longest reply it might produce, so most of that reservation sat empty.
Key takeaways
- PagedAttention stores the KV cache in fixed-size blocks that need not sit next to each other in GPU memory, borrowing the paging idea from operating systems.
- It was introduced with vLLM in a 2023 paper from UC Berkeley, and the paper reports two to four times the throughput of FasterTransformer and Orca at the same latency.
- Older systems used only 20.4 to 38.2 per cent of KV cache memory for real token data, according to the paper’s measurements.
- Block-level sharing lets requests reuse cached prefixes, parallel samples and beam-search branches instead of storing the same tokens many times.
- PagedAttention helps most under heavy load, long contexts and shared prompts; it changes memory management, not the model’s answers.
What is PagedAttention?
PagedAttention is an attention algorithm that works on a KV cache held in non-contiguous, paged memory. It borrows its core idea from virtual memory in operating systems, where a process sees one continuous address space while the physical pages behind it are scattered across RAM. PagedAttention gives each request the same illusion: the attention computation sees one logical KV cache, while the blocks holding it can live anywhere in GPU memory.
The algorithm was introduced by Woosuk Kwon and colleagues at UC Berkeley in the paper “Efficient Memory Management for Large Language Model Serving with PagedAttention”, presented at SOSP in October 2023. The team built the vLLM serving engine on top of it.
The KV cache problem PagedAttention solves
To understand why this matters, it helps to see what the KV cache does. When a transformer generates text, it computes a key and a value vector for every token it has seen, and keeps those vectors around so it does not have to recompute them for each new token. The cache grows with every generated token, and for long conversations it can grow very large.
Older serving systems handled this growth by allocating one continuous slab of memory per request. Because nobody knows in advance how long a reply will be, the slab was usually sized for the maximum sequence length, and most requests finished long before filling it. The paper measured this directly: in the systems it compared against, only 20.4 to 38.2 per cent of KV cache memory actually held token states, and the rest was reserved but unused or lost to fragmentation.
That waste had a direct cost. GPU memory is the scarcest resource in model serving, and every gigabyte locked up in empty reservations was a gigabyte that could not hold another request. Batch sizes stayed small, GPUs sat underused, and the cost per request stayed high.
This is the bottleneck that KV cache optimisation work of every kind tries to remove, and PagedAttention attacks it at the memory allocator itself.
How PagedAttention works
PagedAttention divides each request’s KV cache into blocks, each holding the keys and values for a fixed number of tokens. In vLLM the default block size is 16 tokens, so a request that has generated 100 tokens holds seven blocks, six full and one partly filled. As the request grows, the engine allocates one more block at a time, and when the request finishes, its blocks return to a free pool.
A block table maps each request’s logical blocks to physical blocks in GPU memory. The attention kernel reads that table and gathers the right blocks for each token, so the computation never needs the cache to be contiguous. The engine can allocate, free and reuse blocks without ever moving data, which keeps the overhead small.
Because allocation happens in small units, fragmentation almost disappears. A request never reserves memory it has not used yet, and a finished request releases its blocks immediately. Memory that used to sit idle becomes available to other requests, so the engine can run much larger batches on the same GPU, and larger batches are the main lever on serving throughput.
There is one more subtle benefit. Because blocks are the unit of allocation, the engine can pre-empt a request when memory runs short, swapping its blocks out to CPU memory and bringing them back later, rather than killing the request or blocking new ones.

PagedAttention in vLLM
vLLM is the serving engine the paper’s authors built on PagedAttention, and it is where most teams meet the technique in practice. It pairs the paged KV cache with pre-emptive request scheduling and continuous batching, so new requests join a running batch as soon as space frees up. The combination produces the headline result: two to four times the throughput of FasterTransformer and Orca at the same latency in the paper’s evaluations, with the largest gains on long sequences and large models.
Adopting vLLM does not require changing your model. It supports popular open-weight model families, runs on standard GPU servers, and can serve models too large for one GPU by splitting them across several. Teams usually deploy it behind an API server and point existing clients at its OpenAI-compatible endpoint.
The engine also exposes the block machinery through features such as prefix caching, which reuses the KV cache of a repeated prompt prefix across requests. If many of your requests share a long system prompt, prefix caching means that prompt is computed and stored once, not once per request.
Sharing the KV cache across requests
Block sharing is the second half of PagedAttention’s value. In the simplest case, two requests with the same prompt prefix share the blocks holding that prefix, so the memory cost of the shared text is paid once. This is common in practice: system prompts, few-shot examples and document chunks are often identical across many requests.
Sharing also applies within a single request. Parallel sampling, where one prompt produces several candidate replies at once, can share the prompt’s blocks across all samples and allocate separate blocks only where the replies diverge. Beam search works the same way.
Without paging, each sample or branch would need its own full copy of the prompt’s cache.
PagedAttention compared with traditional KV cache management
The table below summarises the differences between the traditional approach and PagedAttention. The contrast is sharpest under load, which is exactly when serving costs bite.
| Aspect | Traditional KV cache | PagedAttention |
|---|---|---|
| Memory layout | One contiguous block per request | Fixed-size blocks, anywhere in memory |
| Allocation | Reserved up front for maximum length | Allocated block by block as tokens arrive |
| Waste | High: most reserved memory sits empty | Near zero: only the final partial block is unused |
| Fragmentation | Grows as requests of mixed lengths churn | Minimal, since all blocks are the same size |
| Prefix sharing | Not possible without copying | Shared blocks referenced by many requests |
| Under memory pressure | Requests queue or fail | Requests are pre-empted and resumed |
| Effect on throughput | Batch size capped by wasted memory | Larger batches on the same hardware |
Best for: teams serving open-weight models at volume, where GPU memory rather than raw compute is the binding constraint on throughput.
When PagedAttention helps most, and its limits
PagedAttention helps most when many requests run at once, when contexts are long, or when prompts share large prefixes. A busy chat service, a retrieval system with repeated document context, or an agent platform with long histories will all see the difference. The paper’s own results point the same way: the throughput gain grows with longer sequences and larger models, because those are the cases where the KV cache dominates memory.
It helps least when serving is quiet. A single request on an otherwise empty GPU gains little, because there is no competition for memory and no batch to grow. If your traffic is a handful of requests per minute, the bottleneck is more likely to be latency or cold starts than memory fragmentation, and you should look there first.
There are also practical limits to keep in mind. PagedAttention is a feature of the serving engine, not something you can bolt onto any stack, so adopting it usually means adopting vLLM or another engine that implements paging. Its benefits also depend on your workload, so measure throughput and cost per request on your own traffic before and after the switch, rather than assuming the paper’s two to four times figure will match your numbers exactly.
Checklist: adopting PagedAttention
Use this checklist before moving a service onto a paged serving engine.
- Confirm your model is supported by the engine you plan to use, including its context length and custom layers.
- Measure your current throughput, latency and cost per request, so the improvement is visible rather than assumed.
- Check how much of your traffic shares prompt prefixes, since prefix caching is a large part of the win for many workloads.
- Test with your longest realistic contexts, not just short prompts, because gains grow with sequence length.
- Set a block size and a memory budget deliberately, and watch for pre-emption under peak load rather than discovering it in production.
- Compare end-to-end latency, not only throughput, since larger batches can raise the time to first token.
- Plan a rollback route, keeping the old serving path available until the new one has run under real traffic for a week.
Frequently asked questions
Does PagedAttention change the model’s answers?
No. It changes how the KV cache is stored, not the arithmetic of attention. The model produces the same tokens with or without paging, given the same prompt and sampling settings.
Is PagedAttention the same thing as vLLM?
No. PagedAttention is the memory-management algorithm, and vLLM is the serving engine built on it. Other engines have since adopted similar paging ideas, but vLLM is the original implementation.
Does PagedAttention help with long-context models?
Yes, and this is one of its strongest cases. Long contexts make the KV cache large, so the waste from reserving maximum-length slabs grows with context length, and paging removes most of it. Pairing it with continuous batching is the standard way to serve long-context workloads.
Can PagedAttention share KV cache between different users?
It can share blocks for identical prompt prefixes, which is safe because the cached values depend only on the prompt text, not on who sent it. Sharing never leaks one user’s private suffix into another user’s request.
Where can I read the original research?
The paper is “Efficient Memory Management for Large Language Model Serving with PagedAttention” by Kwon and colleagues, presented at SOSP 2023. You can read the original PagedAttention paper on arXiv.
PagedAttention is a good example of an old idea solving a new problem. Operating systems learned decades ago that fixed-size pages beat large contiguous allocations, and language model serving has now learned the same lesson. If your GPUs are running out of memory while compute sits idle, paging the KV cache is one of the highest-value changes you can make.







