PagedAttention manages the KV cache the way an operating system manages memory pages. This is how the blocks, block tables, sharing and preemption actually work, and what changed in current vLLM.
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.
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:
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.
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.
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.
[7, 1, 3], with fill counts [16, 16, 8].[7, 1, 3], now with every block full.[7, 1, 3, 12], with 1 slot filled in the new block.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.
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.
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:
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."
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.
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.
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.
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.
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.
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.
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.
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.