Back to Blog
November 22, 2026

The short version: PagedAttention splits each request's KV cache into fixed-size blocks of tokens and stores those blocks anywhere in GPU memory, the way an operating system maps virtual pages to physical frames. A per-request block table maps logical blocks to physical blocks, so vLLM allocates memory only as tokens arrive and wastes at most one partly filled block per sequence. The same table lets sequences share blocks, with copy-on-write, for parallel sampling, beam search and automatic prefix caching.

What problem was PagedAttention built to fix?

Before vLLM, serving systems stored each request's KV cache in one contiguous chunk. The PagedAttention paper (Kwon et al., SOSP 2023) says these systems pre-allocated a chunk sized to the request's maximum length, for example 2,048 tokens. That design wastes memory in three ways:

  • Reservation. Slots held for tokens the request has not generated yet. They get used eventually, but other requests cannot use them in the meantime.
  • Internal fragmentation. Slots reserved for the maximum length that the request never reaches, because it stopped early.
  • External fragmentation. Gaps left by the memory allocator (the paper names the buddy allocator) between chunks of different sizes.

The paper's profiling found that only 20.4% to 38.2% of KV cache memory held actual token states in the systems it measured. In vLLM the same figure was 96.3%. The vLLM launch blog states the same result another way: existing systems "waste 60% - 80% of memory," while PagedAttention wastes "under 4%." Less waste means more requests fit in one batch, which is where the throughput gain comes from. The cache size formula is in our post on KV cache VRAM for a 128K context.

How do blocks and block tables work?

The paper borrows the virtual memory analogy directly: "one can think of blocks as pages, tokens as bytes, and requests as processes." A KV block holds the keys and values for a fixed number of tokens. Each request sees a list of logical blocks that fill left to right. The GPU holds a pool of physical blocks of the same size, carved out of memory when the engine starts.

The block manager keeps a block table for each request. Each entry records which physical block backs a logical block and how many of its slots are filled. Logical blocks that sit next to each other do not need to sit next to each other in GPU memory. The attention kernel is the part that makes this work. It reads keys and values block by block, following the table, instead of assuming one contiguous tensor. Because every block has the same size, external fragmentation disappears. Because a new physical block is allocated only when the previous one is full, the waste for a request stays within one block.

What does a worked example look like?

Take one request with a 40-token prompt and a block size of 16. The physical block numbers below are arbitrary, which is the point.

  1. Prefill. vLLM needs 3 logical blocks for 40 tokens: 16 + 16 + 8. It maps logical block 0 to physical block 7, logical block 1 to physical block 1, and logical block 2 to physical block 3. The block table reads [7, 1, 3], with fill counts [16, 16, 8].
  2. First decode step. The new token's keys and values go into slot 9 of logical block 2. No allocation happens. The fill count for that entry becomes 9.
  3. Decode steps 2 to 8. Tokens 42 to 48 fill the rest of physical block 3. The table is still [7, 1, 3], now with every block full.
  4. Token 49. The last block is full, so vLLM takes a free physical block, say block 12, and appends it. The table becomes [7, 1, 3, 12], with 1 slot filled in the new block.
  5. Finish. When the request ends, blocks 7, 1, 3 and 12 return to the free pool, ready for any other request.

At no point did the request hold memory for a 2,048-token maximum. The most it ever wasted was 15 empty slots in its last block.

How does copy-on-write let sequences share memory?

Because the table is an indirection, two logical blocks can point at one physical block. vLLM keeps a reference count on each physical block. In parallel sampling, several outputs come from one prompt, so all of them map their prompt blocks to the same physical blocks. When a sample needs to write into a shared block whose count is above 1, vLLM copies that one block to a new physical block, writes there, and decrements the count. This is the same copy-on-write trick an OS uses when a process forks. Only the last, partly filled prompt block ever gets copied.

Beam search shares more. Candidates that diverge late share most of their history, and when a candidate drops out of the beam, its blocks are released and any block whose count reaches 0 is freed. In the paper's tests, sharing saved 6.1% to 9.8% of memory for parallel sampling and 37.6% to 55.2% for beam search on the Alpaca trace, and 16.2% to 30.5% and 44.3% to 66.3% on ShareGPT.

What happens when the GPU runs out of blocks?

vLLM preempts requests. The original design used first-come-first-served scheduling and evicted the newest requests first. Since all blocks of a sequence are read together, eviction is all or nothing per sequence, and beams of one request are preempted as a group. The paper offers two ways to bring an evicted request back:

  • Swapping. Copy the evicted blocks to CPU memory and copy them back later. Small blocks make this slow, because many small transfers cannot use the full PCIe bandwidth.
  • Recomputation. Drop the blocks and rebuild them later. The prompt and the tokens generated so far are joined into one new prompt, so the rebuild runs as a single prefill pass.

The paper found recomputation faster at small block sizes, swapping faster at large ones, and the two about equal from 16 to 64. Current vLLM picks one. The optimization docs say: "In vLLM V1, the default preemption mode is RECOMPUTE rather than SWAP."

How big should a block be?

Blocks that are too small leave the GPU underused when the kernel reads the cache. Blocks that are too large bring back internal fragmentation and make sharing less likely. In the paper, sizes 16 to 128 did best on ShareGPT, while only 16 and 32 did well on the shorter Alpaca sequences. The authors wrote that "vLLM sets its default block size as 16."

That default has changed. A pull request merged on November 5, 2026 raised the default --block-size from 16 to 64, citing per-block bookkeeping overhead. The v0.34.0 cache config sets DEFAULT_BLOCK_SIZE to 64. Attention backends that prefer another size still override it, and ROCm keeps 16. The pull request itself notes that a 16 versus 64 throughput benchmark on a real workload was still missing, so treat 64 as a default, not a proven optimum for your traffic.

How does automatic prefix caching build on blocks?

The paper already sketched shared prefixes: map a new request's logical blocks onto cached physical blocks, as an OS shares a library across processes. Current vLLM does this automatically. The prefix caching design doc says vLLM hashes "each kv-cache block by the tokens in the block and the tokens in the prefix before the block," chaining each block's hash to its parent. A new request whose leading blocks hash the same reuses those physical blocks and skips their prefill. Freed blocks with a reference count of 0 stay cached until the least recently used one is evicted. The V1 release post says prefix caching is on by default and costs "less than 1% decrease in throughput even when the cache hit rate is 0%."

Two details matter in practice. First, the design doc says "We only cache full blocks," so the hit granularity is the block size. In our worked example, a shared 40-token prefix gives 32 reusable tokens at block size 16, but none at block size 64. Second, the feature docs say it "does not reduce the time of generating new tokens." For Recursive Language Models, which send many sub-calls that start with the same instructions, this is the mechanism behind cheaper repeated prefixes. Our post on prompt caching for RLM sub-calls covers the cost side, and the RLM-Qwen3-8B on vLLM guide shows a local setup.

The bottom line

PagedAttention is virtual memory for the KV cache. Fixed-size blocks remove external fragmentation, on-demand allocation caps waste at one block per sequence, and a block table with reference counts makes sharing and copy-on-write cheap. The paper credits this design with 2 to 4 times the throughput of FasterTransformer and Orca at the same latency. If you tune anything, look at block size: the default moved from 16 to 64 in late 2026, and it sets both waste per sequence and how finely prefix cache hits can land.

References & Further Reading

  1. Kwon, W., Li, Z., Zhuang, S., et al. "Efficient Memory Management for Large Language Model Serving with PagedAttention." SOSP 2023, arXiv:2309.06180. Block tables, the three waste types, 20.4% to 38.2% vs 96.3% memory use, copy-on-write, swapping vs recomputation, block size study, default of 16, 2 to 4 times throughput. arxiv.org/abs/2309.06180
  2. Kwon, W., Li, Z., Zhuang, S., et al. "vLLM: Easy, Fast, and Cheap LLM Serving with PagedAttention." vLLM blog, June 20, 2023. 60% to 80% waste in existing systems and under 4% with PagedAttention. vllm.ai/blog/2023-06-20-vllm
  3. vLLM Team. "vLLM V1: A Major Upgrade to vLLM's Core Architecture." vLLM blog, January 27, 2025. Prefix caching on by default with under 1% throughput cost at 0% hit rate. vllm.ai/blog/2025-01-27-v1-alpha-release
  4. vLLM project. "Automatic Prefix Caching" design document. docs.vllm.ai, accessed November 2026. Block hashing by prefix and block tokens, full blocks only, reference counts and LRU eviction. docs.vllm.ai/en/latest/design/prefix_caching.html
  5. vLLM project. "Automatic Prefix Caching" feature page. docs.vllm.ai, accessed November 2026. Prefix caching does not reduce decode time. docs.vllm.ai/en/latest/features/automatic_prefix_caching.html
  6. vLLM project. "Optimization and Tuning." docs.vllm.ai, accessed November 2026. V1 default preemption mode is RECOMPUTE, and tuning advice for frequent preemption. docs.vllm.ai/en/latest/configuration/optimization.html
  7. vLLM project. "[Core] Change default --block-size from 16 to 64." GitHub pull request #63231, merged November 5, 2026. New default block size, ROCm exception, missing benchmark. github.com/vllm-project/vllm/pull/63231
  8. vLLM project. vllm/config/cache.py at tag v0.34.0. DEFAULT_BLOCK_SIZE of 64 and enable_prefix_caching defaulting to True. github.com/vllm-project/vllm/blob/v0.34.0/vllm/config/cache.py
  9. Zhang, A. L., Kraska, T., Khattab, O. "Recursive Language Models." arXiv:2512.24601, December 2025. RLMs issue many recursive sub-calls over a long prompt held outside the context window. arxiv.org/abs/2512.24601
FAQ

Frequently asked questions

Does PagedAttention change the model's outputs?

No. The paper says vLLM improves throughput without affecting model accuracy at all. PagedAttention changes where keys and values live in memory and how the kernel reads them, not the attention math.

Is PagedAttention the same thing as prefix caching?

No. PagedAttention is the block-based memory layout and kernel. Automatic prefix caching is a feature built on top of it that hashes full blocks and reuses them across requests that share the same leading tokens.

Why did vLLM move the default block size to 64?

The November 2026 pull request cites per-block bookkeeping overhead as the motivation. It also says a 16 versus 64 benchmark on a real serving workload was still missing, and ROCm keeps 16-token blocks by default.

Should I set the block size back to 16?

Consider it if your requests are short or share short prefixes, since waste and prefix-cache hits both work at block granularity. Pass --block-size 16 and compare throughput and cache hit rate on your own traffic before you decide.

Does vLLM still swap KV blocks to CPU memory?

The original paper supported both swapping and recomputation. The current optimization docs say V1 defaults to recomputation, which rebuilds the evicted cache in one prefill pass when the request resumes.