Papers · 2023 · added to the knowledge base 2026-08-24 · Reading: 27 min, plus 5 in closed details.
Paper · SOSP 2023 · arXiv 2309.06180

Efficient Memory Management for Large Language Model Serving with PagedAttention (PagedAttention, vLLM)

Woosuk Kwon, Zhuohan Li, Siyuan Zhuang, Ying Sheng, Lianmin Zheng, Cody Hao Yu, Joseph E. Gonzalez, Hao Zhang, Ion Stoica
UC Berkeley, with Stanford, UC San Diego and an independent researcher · September 2023 (arXiv 2023-09-12); SOSP '23, Koblenz, 23 to 26 October 2023

In one line: PagedAttention pages the KV cache into fixed 16-token blocks with OS-style block tables, copy-on-write sharing, and swap/recompute preemption, lifting KV memory utilization from about 20 to 38% to 96% and the sustainable request rate 1.7 to 2.7x over the authors' own Orca reimplementation with oracle allocation (ShareGPT; 2 to 4x across the paper's baselines); it became the industry-standard KV layout and the foundation of vLLM.

96.3% of KV memory holds tokens
against 20.4% to 38.2% in the three Orca variants
contiguous chunks waste the rest on reservations and fragmentation · Figure 2
2.2× more requests per batch
30.42 against Orca (Oracle)'s 13.62, OPT-13B on ShareGPT
4.3× Orca (Max)'s 7.00 · Figure 13
2 to 4× request rate at equal latency
over FasterTransformer and Orca (abstract)
read off Figure 12 at 0.5 s/token: 1.5 to 2.3× over Orca (Oracle) on ShareGPT · Figure 12

How far to trust it: Believe the mechanism and the memory accounting: the waste figures reproduce from Table 1 and the paper's own length distributions, and paged KV caches became the default of every major serving stack. Treat the throughput multiples as the top of a range: they come from single runs against the authors' own reimplementation of Orca, and read off the paper's figures the gain over the strongest baseline is 1.5 to 2.4x on ShareGPT, about 1.3 to 1.8x on Alpaca, and near 1x where memory is not the bottleneck. The evidence, judged.

The idea in one sentence: store each request's KV cache in small fixed-size blocks that can sit anywhere in GPU memory, found through a per-request block table the way an operating system pages virtual memory, so memory is taken only as tokens arrive, each sequence wastes at most one partly filled block, and sequences share blocks with copy-on-write; more requests then fit in each batch, which is where the throughput comes from (the paper reports 2 to 4× over FasterTransformer and Orca; read off its own Figure 12, 1.5 to 2.3× over the ideal contiguous baseline on ShareGPT).

The paper's measured waste, drawn to scale

  1. 12 GB of KV cache, 15,728 slots. The paper's smallest server: OPT-13B on one A100-40GB keeps 12 GB for the KV cache, which at 800 KiB per token is 15,728 token slots (Table 1). Each floor is that memory to scale, one row per 2,048 slots (OPT's longest sequence), once for each system the paper compares.
  2. Orca (Max): a 2,048-slot chunk per request. Seven chunks fill seven rows (⌊15,728 / 2,048⌋ = 7) and the last row fits none. Green slots hold tokens, pale ones are reserved for tokens still to come, the red floor is reserved past the request's real end. Figure 2: 20.4% of memory holds tokens, 13.3% reserved, 57.3% internal fragmentation, 8.9% external; the simulator averages 17.7%, 11.8%, 61.7% and 8.9%. Each dot stream is one request writing one token per iteration: 7 at a time (Figure 13a: 7.00).
  3. Orca (Pow2): up to twice the output. Chunks shrink to prompt plus output rounded up to a power of two, and the red mostly goes, but the buddy allocator rounds every chunk up to a power of two again and leaves gaps no chunk fits (grey). Figure 2: 26.8% tokens, 17.9% reserved, 13.6% internal, 41.6% external (simulated 24.5%, 17.0%, 15.2%, 43.4%); 9.81 requests per batch (simulated 10.02).
  4. Orca (Oracle): told every true length. No red at all, yet only 38.2% holds tokens (simulated 35.8%): each chunk still reserves its future tokens from the first iteration, 25.2% (26.3%), and rounding and gaps take 36.6% (37.9%). 13.62 requests per batch (simulated 14.21).
  5. vLLM: 16-token blocks on demand. The same memory as 983 blocks, each taken when a sequence needs it and placed anywhere (the blue blocks are one request's). Only a sequence's last block can be partly empty: 96.3% of memory holds tokens (simulated 96.8%). 30.42 requests per batch; the simulator's 38.65 is higher because its queue never empties.
  6. What the waste costs: the batch. Requests per batch, Figure 13a: 7.00, 9.81, 13.62 and 30.42. vLLM batches 2.23× as many requests as Orca (Oracle) and 4.35× Orca (Max), and the bigger batch is where the throughput comes from.

The floors show one iteration of this page's simulator (iteration 3,000 of a ShareGPT-like run, seed 1, the rules of §6.1; Simulate the KV cache), so its own shares (the line above, while a floor is in focus) move a little from iteration to iteration; the percentages above are the averages. Figure 2 is OPT-13B on ShareGPT (Figure 2), Figure 13a the same run's batch sizes (Figure 13).

You need: why a KV cache exists (The transformer from zero, section 9) and how big it is per token (Long context); why decode is memory-bound (Performance math). Continuous batching, paging, prefix caching, chunked prefill and preemption as they work today are taught on Batching, KV cache and scheduling in depth, and vLLM's current code on vLLM: inside the default engine; this page is the paper. New terms: KV block (a fixed number B of tokens' keys and values, 16 by default); block table (per request, logical block to physical block plus fill count); internal and external fragmentation (reserved slots never used; gaps between chunks no request can use); reference count, copy-on-write (how many sequences use a block; copy it only when one writes to a shared block); Orca (Max, Pow2, Oracle) (the authors' reimplementations of Orca reserving the maximum length, up to 2× the output, or exactly the true output); normalized latency (end-to-end latency over output length, seconds per token).

Problem: the batch size is capped by KV cache memory

§1 Introduction, §3

Decoding one request at a time is memory-bound: every step reads all the weights for one token, which "underutilizes the computation power of GPUs and limits the serving throughput" (§1). Batching shares each weight read across many requests, and how many fit is decided by the GPU memory left for their KV cache, the keys and values of every token so far (§2.2).

The cache is large. For OPT-13B one token's KV cache is 800 KB: 2 (key and value) × 5,120 (hidden size) × 40 (layers) × 2 bytes (FP16) = bytes, exactly 800 KiB (any model's bytes per token: Long context's calculator). OPT can generate sequences of up to 2,048 tokens, so one request can need as much as 1.6 GB ( GiB) (§3). On an A100 with 40 GB serving a 13B model, about 65% of memory holds the weights (26 GB) and the KV cache gets the rest: "close to 30%" in the text, ">30%" in Figure 1's label; activations take a small remainder (Figure 1). Table 1 makes it concrete: 12 GB for the KV cache, which is 15.7K token slots (Table 1; 12 GiB / 800 KiB = ). Even if all of memory went to the cache, "only a few tens of requests could be accommodated" (§3). And it will get worse: from A100 to H100 the FLOPS rose more than 2× while GPU memory stayed at 80 GB at most (§3).

Figure 1 (right), redrawn from the points in its vector graphics: memory against batch size for "existing systems" and vLLM, and the throughput a batch of that size reaches. The dotted lines are the paper's: where memory hits 40 GB, the batch size and therefore the throughput stop.

The diagnosis: existing systems (FasterTransformer, Orca) store each request's KV cache in one contiguous chunk, because deep learning frameworks want tensors contiguous, and since the output length is unknown they pre-allocate the chunk for the maximum possible length (§3.1). The KV cache, unlike ordinary tensors, "dynamically grows and shrinks over time" and its lifetime and length are not known in advance (§1).

That wastes memory three ways (Figure 3, §3.1):

  • Reserved slots for tokens the request will generate later. They are eventually used, but held empty for the request's whole lifetime, so shorter requests cannot use them meanwhile.
  • Internal fragmentation: slots reserved for a maximum length the request never reaches. Figure 3's request A has a 2,048-token maximum and finishes after 10 tokens: 2,038 slots are never used; request B (maximum 512) leaves 507 (Figure 3; 2,048 − 10 = , 512 − 5 = ). This waste is only known once the request finishes.
  • External fragmentation from the allocator (the paper assumes a buddy allocator for Orca), because every chunk has a different size. It "will never be used for generated tokens, which is known before serving a request".

The paper's profiling puts the result at "only 20.4% to 38.2% of the KV cache memory" holding actual token states (Figure 2). The Simulate the KV cache tab replays exactly this, the four systems on the same memory.

The same two requests, before and after: contiguous chunks reserved for the maximum length, against 4-token blocks allocated on demand
Before: existing systems (Figure 3). Each request gets one chunk sized for its maximum length.
One strip of KV cache memory: request A's 7 prompt tokens and 2 generated tokens, 2 slots reserved for future tokens, 2,038 slots never used (internal fragmentation); a gap of external fragmentation; request B's 3 prompt tokens and 1 generated token, 1 reserved slot and 507 slots never used
After: vLLM (Figure 7). Logical blocks map to physical blocks anywhere in memory; only the last block of each request has empty slots.
Request A's logical KV blocks 0 to 2 map to physical blocks 7, 1 and 3; request B's logical blocks 0 and 1 map to physical blocks 5 and 2; the physical blocks interleave the two requests and the free blocks can go to anyone
Notice where the waste goes: on top, 2,038 + 507 slots that will never hold a token plus a gap no request can use; below, three empty slots in A's last block and two in B's. The paper's profiling of the real systems: 20.4% to 38.2% of KV memory holds tokens before, 96.3% after (Figure 2, below). Figures 3 and 7 of the paper (arXiv 2309.06180), by Kwon, Li, Zhuang, Sheng, Zheng, Yu, Gonzalez, Zhang and Stoica, CC BY 4.0; swipe sideways on a phone.

Even the oracle wastes most of its memory. Orca (Oracle) is the paper's idealised baseline: told every request's true output length in advance, it reserves exactly prompt + output and never over-provisions. Yet on the ShareGPT experiment only 38.2% of its KV cache memory holds actual tokens (Figure 2). Knowing the length removes internal fragmentation (zero for Oracle), but two wastes remain. The chunk for a request's future tokens is reserved from the start (25.2%), and the buddy allocator rounds every chunk up to a power of two and leaves gaps between chunks of different sizes (36.6% "external fragmentation and others"). vLLM, allocating 16-token blocks on demand, keeps 96.3% of the memory holding tokens.

Even the oracle wastes most of its memory; vLLM keeps 96.3% holding tokens, and the simulator lands close

The second problem is sharing. Parallel sampling (several outputs for one prompt, as in code assistants) and beam search keep several sequences per request that could share their prompt's KV cache, and beam candidates share much more, but with each sequence in its own contiguous chunk "memory sharing is not possible" (§1). In the paper's §6.3 experiment the prompt is 12% of the total KV cache under parallel sampling, and beam search can share enough to save up to 55% (§3). Compaction, the textbook fix for fragmentation, is "impractical" with a cache this large and would still not allow sharing (§3.1).

The third challenge is scheduling for unknown lengths: as outputs grow the cache can exhaust memory, and the system has to decide whose cache to delete or swap out (§3).

Background: prompt phase, generation phase, iteration-level batching

§2 Background

Generation has a compute-heavy prompt phase (the whole prompt at once) and a memory-bound generation phase (one token per iteration, reading every cached key and value), which dominates a request's latency (§2.2). Orca's iteration-level scheduling already lets requests join and leave the batch after every iteration; PagedAttention keeps it and attacks what still limits it: "the number of requests that can be batched together is still constrained by GPU memory capacity" (§3). Both mechanisms in general, with their visuals: Batching, KV cache and scheduling in depth.

§2 in full: the two phases and iteration-level scheduling as the paper states them

A request's prompt (x1, ..., xn) and its generated tokens together form a sequence. Generation has two phases (§2.2). The prompt phase takes the whole prompt at once, computes the first new token and the keys and values k1..kn, v1..vn; it is a matrix-matrix computation that uses the GPU well. The autoregressive generation phase then adds one token per iteration, computing only the new token's key and value and reading all the cached ones; it is matrix-vector work, memory-bound, and "responsible for most portion of the latency of a single request". A token's KV cache depends on every token before it, so the same token at a different position has a different cache (§2.2).

Batching requests that arrive at different times with different lengths is the job of iteration-level scheduling (Orca; cellular batching before it): after every iteration finished requests leave the batch and new ones join, so a new request waits one iteration instead of a whole batch, and special kernels remove the need to pad inputs and outputs (§2.3). PagedAttention keeps this and attacks what still limits it: "the number of requests that can be batched together is still constrained by GPU memory capacity" (§3). The paper calls the two techniques complementary: Orca interleaves requests so more can run, vLLM raises memory utilisation so more fit (§9).

The idea: page the KV cache like virtual memory

§4.1 PagedAttention

The move is the operating system's answer to fragmentation and sharing, virtual memory with paging (Kilburn et al., 1962): "one can think of blocks as pages, tokens as bytes, and requests as processes" (§1). PagedAttention splits each sequence's KV cache into KV blocks of a fixed number of tokens B, the block size, which need not sit next to each other in memory (§4.1). With key block Kj = (k(j−1)B+1, ..., kjB) and value block Vj likewise, attention for query qi becomes a sum over blocks (Eq. 4):

Aij = exp(qi⊤Kj / √d) / Σt=1⌈i/B⌉ exp(qi⊤Kt1 / √d),   oi = Σj=1⌈i/B⌉ VjAij⊤
Aij
the row of attention scores of query i on block j, (ai,(j−1)B+1, ..., ai,jB)
⌈i/B⌉
the number of blocks holding tokens up to i; the kernel fetches each block wherever it lives, through the block table

The output is exactly ordinary attention (Eq. 3): only where the operands live changes. In Figure 5 the query "forth" attends over three non-contiguous blocks, "Four score and seven", "years ago our fathers", "brought forth" (Figure 5).

One block per token across layers, or per layer and head (footnote 1)

A footnote adds that a block can hold one token's keys and values across all layers and heads, or each layer and head can have its own block and block table; "the two designs have no performance difference" and vLLM uses the second (§4.1, footnote 1).

What paging buys: small blocks allocated on demand remove reservation and bound internal fragmentation; one fixed block size eliminates external fragmentation; and blocks can be shared between sequences, within a request or even across requests (§1).

Block numbers, words and reference counts are the paper's own (Figures 6 to 9). Beam search shows block tables only, as Figure 9 does: each box is a block of four tokens. It plays by itself once in view; any control stops it.

The KV cache manager and the block table

§4.2 to §4.3, Figures 6 and 7

A request's cache is a list of logical KV blocks, filled left to right, the last block's empty slots kept for future tokens. On each GPU worker a block engine takes one contiguous chunk of GPU memory and cuts it into physical KV blocks (the same on CPU memory, for swapping). The block manager keeps a block table per request: for each logical block, its physical block and the number of filled positions, exactly like a page table (§4.2). Beside this, the paper's Figure 6 walk-through (block size 4, the prompt "Four score and seven years ago our"), then its Figures 7, 8 and 9 on the same physical memory; pick a scenario above the drawing. The same mechanism on a larger pool, as engines run it today, is drawn in 3D on Batching, KV cache and scheduling in depth (its Fig. 3).

Each scenario, step by step

  1. Request A arrives. The prompt is "Four score and seven years ago our", 7 tokens. Nothing is reserved for the 2,048-token maximum: vLLM will allocate blocks only as tokens arrive.
  2. Prefill: two blocks, anywhere. The prompt needs two blocks of 4. Logical block 0 maps to physical block 7, logical block 1 to physical block 1 (Figure 6, step 1); the prompt's KV cache, computed with ordinary attention (§4.3), is written into them and the first output token, "fathers", is generated. One slot of block 1 stays free for it.
  3. Decode: fill the last slot. The first decoding step runs PagedAttention over blocks 7 and 1 and stores the KV cache of "fathers" in the free slot; the block table's fill count for logical block 1 goes from 3 to 4 (step 2). "brought" is generated.
  4. Decode: a new block on demand. The last block is full, so the next token needs a new logical block 2; vLLM allocates physical block 3 for it and records the mapping (step 3). At most one block per request is ever partly empty: here 3 slots.
What one iteration does (§4.3)

Every iteration, vLLM picks the sequences to batch, allocates the blocks they newly need, concatenates all the iteration's input tokens (whole prompts for prompt-phase requests, the latest token for the others) into one sequence for the model, and the kernel reads and writes the blocks through the tables (§4.3).

Since blocks are filled left to right and a new one is taken only when the last is full, a request's waste is at most one partly filled block, and its blocks are freed the moment it finishes (§4.3). Larger blocks let the kernel process more positions in parallel but fragment more; that trade-off is the block-size ablation (§7.2, below).

Sharing: reference counts and copy-on-write

§4.4 Other decoding scenarios

Parallel sampling (Figure 8): both samples' logical blocks 0 and 1 map to the same physical blocks 7 and 1, so the prompt's cache is stored once. Each physical block carries a reference count (here 2). When sample A1 writes to its last logical block, vLLM sees physical block 1's count is above 1, allocates block 3, has the block engine copy block 1 into it and decrements the count to 1; when A2 then writes, block 1's count is already 1 and it writes in place. This is copy-on-write at block granularity, as when an OS forks a process; only the prompt's last, partly filled block is ever copied (§4.4).

Beam search shares much more, and the pattern changes as decoding goes, like the process tree of repeated forks (Figure 9): blocks that lose all their references are freed at once, and where earlier systems would copy "a large portion of candidate 2's KV cache" to continue a beam, vLLM copies at most one block (§4.4).

Figure 9 block by block (§4.4)

Beam search shares much more and the pattern changes as decoding goes, like the process tree of repeated forks (Figure 9): with beam width k = 4, all candidates share block 0 (the prompt), candidate 3 diverged at the second block, candidates 0 to 2 share three blocks. When the next top-4 all descend from candidates 1 and 2, the blocks of candidates 0 and 3 lose their references and blocks 2, 4, 5 and 8 are freed; new blocks 9 to 12 hold the new tokens. Where earlier systems would copy "a large portion of candidate 2's KV cache" to continue candidate 3, vLLM copies at most one block (§4.4).

Shared prefix (Figure 10): a long system prompt (instructions and examples, Figure 10's English-to-French few-shot prompt) can be cached once by the provider in reserved physical blocks, "as how OS handles shared library across processes"; a request maps its first logical blocks to them, the last one marked copy-on-write, and the prompt phase then runs only on the user's own input (§4.4). Mixed decoding methods: because the kernel only ever sees a list of physical block IDs per sequence, requests with different decoding methods batch together freely, "which existing systems cannot efficiently do" (§4.4). All of it is built from three primitives: fork (a new sequence from an existing one), append (a token) and free (a finished sequence) (§5.2).

Parallel sampling with 6 outputs per prompt, OPT-13B on the Alpaca trace. The six samples share the prompt's KV cache. How much KV memory does sharing save?
Parallel sampling saves under 10% on Alpaca, beam search up to 55%

Scheduling and preemption

§4.5 Scheduling and Preemption

vLLM serves requests first come, first served, which ensures fairness and prevents starvation; when it must preempt, the latest arrivals go first (§4.5). When the physical blocks run out it faces the two classic paging questions. Which blocks to evict? Since all of a sequence's blocks are read every step, eviction is all-or-nothing per sequence, and the sequences of one request (the beams of a beam search) form a sequence group that is gang-scheduled, preempted and rescheduled together, because they share memory. How to bring them back? Two ways:

  • Swapping: copy the evicted blocks to CPU memory, managed by a CPU block allocator (Figure 4). While any sequence is swapped out, vLLM accepts no new requests; the swap space never exceeds the GPU's KV memory, so it is bounded.
  • Recomputation: drop the blocks and recompute them on rescheduling. This is cheaper than it sounds: the generated tokens are appended to the prompt and the whole cache is rebuilt in one prompt-phase iteration, not token by token. An OS cannot do this; an LLM server can (§4.5, §8).

Which is faster depends on the CPU to GPU bandwidth and the GPU's compute (§7.3, below).

Distributed execution

§4.6 Distributed Execution

Models too large for one GPU run with Megatron-LM-style tensor parallelism: linear layers split for block-wise matrix multiplies, attention split by heads, the GPUs synchronising with all-reduce in an SPMD schedule. Every shard processes the same tokens and so needs the KV cache for the same positions; vLLM therefore keeps one KV cache manager in the centralised scheduler, and every worker uses the same logical-to-physical mapping while storing only its own heads' part of each block (§4.6). Each step the scheduler broadcasts the input token IDs and the block tables; the workers run the model, all-reduce among themselves without the scheduler, and send back the sampled tokens. Workers never coordinate on memory management (§4.6). Tensor parallelism at serve time in general, and the multi-node designs that came later: Distributed and disaggregated serving.

Implementation

§5 Implementation

vLLM is 8.5K lines of Python and 2K lines of C++/CUDA, with a FastAPI frontend that extends the OpenAI API (each request can set its own sampling parameters, maximum length and beam width). The scheduler and block manager are Python; models (GPT, OPT, LLaMA) use PyTorch and Hugging Face Transformers; NCCL carries tensors between GPUs (§5). Three kinds of custom kernel make paging cheap (§5.1): a fused reshape-and-block-write, a fused block-read-and-attention (FasterTransformer's kernel reading through the block table), and a fused block copy for copy-on-write.

The three kernels in detail (§5.1)
  • Fused reshape and block write: each layer's new KV is split into blocks, reshaped to the layout the reads want and written where the block table says, in one kernel launch.
  • Fused block read and attention: FasterTransformer's attention kernel adapted to read the cache through the block table on the fly, with one GPU warp per block for coalesced reads and support for different sequence lengths in one batch.
  • Fused block copy: copy-on-write copies of scattered blocks batched into one launch instead of many small cudaMemcpyAsync calls.

Results

§6 Evaluation

Setup (§6.1): OPT-13B, 66B and 175B and LLaMA-13B on A100s; synthetic Poisson traces with the lengths of ShareGPT (long) and Alpaca (short); baselines FasterTransformer and three reimplementations of Orca (Max, Pow2, Oracle; Orca was not public). The metric is normalized latency against request rate: a system's capacity is the rate where its curve turns up.

The setup in full: instances, workloads, baselines, metric, trace lengths (§6.1)

Setup (§6.1): OPT-13B, 66B and 175B and LLaMA-13B on Google Cloud A2 instances with A100 GPUs (Table 1: one A100-40GB, four A100s, eight A100-80GB). Workloads are synthesised from the input and output lengths of ShareGPT (user-shared ChatGPT conversations) and Alpaca (GPT-3.5 self-instruct data); ShareGPT's prompts are 8.4× longer and its outputs 5.8× longer on average, with more variance (Figure 11). Arrival times are Poisson at a chosen request rate, since the datasets have no timestamps. Baselines: FasterTransformer with a custom dynamic batching scheduler (batch size as large as memory allows), and Orca, which is not public, so the authors implemented their own, with a buddy allocator, in three versions: Oracle (knows the true output lengths, "infeasible to achieve in practice"), Pow2 (over-reserves outputs up to 2×, 25 becomes 32) and Max (always reserves the 2,048-token maximum). The metric is normalized latency (the mean of each request's end-to-end latency divided by its output length, as in Orca) against request rate, over 1-hour traces (15 minutes for OPT-175B, for cost).

Basic sampling (Figure 12, §6.2): each curve is flat until the rate passes the system's capacity, then latency explodes as the queue grows without bound. On ShareGPT vLLM sustains "1.7× to 2.7×" the request rate of Orca (Oracle) and "2.7× to 8×" that of Orca (Max) at similar latency, and up to 22× FasterTransformer's. The reason is the batch: on OPT-13B vLLM runs 2.2× as many requests at once as Orca (Oracle) and 4.3× as many as Orca (Max) (Figure 13; 30.42 / 13.62 = , 30.42 / 7.00 = ). Alpaca follows the same trend except OPT-175B, where 264 GB of KV memory and short sequences let even the Orca baselines batch a lot, and serving becomes compute-bound rather than memory-bound. The abstract says the gain "is more pronounced with longer sequences, larger models, and more complex decoding algorithms": true for longer sequences (ShareGPT over Alpaca) and for decoding, but not monotone in model size, since read off Figure 12 the lead over Orca (Oracle) on ShareGPT is largest at 66B and smallest at 175B. The curves, rebuilt reads every ratio off the paper's figures.

Parallel sampling and beam search (Figure 14, §6.3): the more sequences per request, the larger vLLM's lead; over Orca (Oracle) on OPT-13B and Alpaca it grows from 1.3× in basic sampling to 2.3× in beam search with width 6. Memory saved by sharing, "the number of blocks we saved by sharing divided by the number of total blocks without sharing": 6.1% to 9.8% (parallel sampling) and 37.6% to 55.2% (beam search) on Alpaca, 16.2% to 30.5% and 44.3% to 66.3% on ShareGPT (Figure 15).

Shared prefix (§6.4): LLaMA-13B translating WMT16 English to German with a shared instruction-and-examples prefix: 1.67× Orca (Oracle)'s throughput with a 1-shot prefix (80 tokens) and 3.58× with 5 shots (341 tokens) (Figure 16).

Chatbot (§6.5): OPT-13B answering ShareGPT conversation histories cut to the last 1,024 tokens, with at most 1,024 generated, and no KV cache kept between rounds: vLLM sustains "2× higher request rates" than all three Orca baselines, which behave alike because the buddy allocator makes each of them reserve 1,024 output slots regardless of its length prediction (Figure 17).

Ablations

§7 Ablation Studies

Kernel overhead (§7.1): reading the block table, extra branches and variable lengths make vLLM's attention kernel "20 to 26%" slower than FasterTransformer's in isolation (Figure 18a). The paper calls it small because only attention pays it, not the linear layers, and end to end vLLM wins anyway. Read off the figure, the overhead is 19% to 26% at batch size 32 but 25% to 44% at batch size 8 (Kernel overhead, rebuilt).

Block size: bigger blocks let the kernel process more positions in parallel; smaller ones waste less memory. On the Alpaca trace (short sequences), which block size gives the lowest end-to-end latency?
Latency is lowest at blocks of 16 to 32; larger blocks leave more of each last block empty

Recomputation against swapping (Figure 19, §7.3): swapping many small blocks means many small CPU to GPU transfers, which throttles the effective PCIe bandwidth, so swapping is slow at small block sizes; recomputation does not touch the blocks and costs the same at every size. Recomputation wins for small blocks, swapping for large ones, and from 16 to 64 the two perform alike end to end. The paper's phrasing, "recomputation overhead is never higher than 20% of swapping's latency", cannot mean what it says: at block size 256 recomputation takes 39.1 ms against swapping's 33.4 ms, 117% of it. It holds read as "never more than 20% slower than swapping" (17% at most in the figure).

Where paging does not help, and what is LLM-specific

§8 Discussion, §9 Related work

The authors are explicit about the limits (§8): paging pays off here because the workload allocates memory dynamically (output length unknown) and its performance is bound by GPU memory capacity. In DNN training tensor shapes are static and allocation can be planned ahead; serving non-LLM DNNs is mostly compute-bound, so better memory efficiency may buy nothing; in such cases the indirection and non-contiguous blocks "may rather degrade the performance". What vLLM adds to the OS idea is application knowledge: all-or-nothing eviction (a request needs all its tokens resident), recomputation as a recovery path (impossible for an OS), and fused kernels that hide the indirection (§8).

Related work as the paper places itself (§9)

Related work (§9): general serving systems (Clipper, TensorFlow Serving, Nexus, InferLine, Clockwork; DVABatch, REEF, Shepherd, AlpaServe) ignore the autoregressive token state; Transformer-specific systems use kernel optimisations, advanced batching, model parallelism and parameter sharing, with Orca the closest. Swapping and recomputation were used before to cut training memory; FlexGen swaps weights and token states for offline inference on small GPUs, not online serving; OLLA optimises tensor lifetimes and placement but not at block level; FlashAttention tiles attention to cut its peak memory and IO. Block-level memory management for online serving is the paper's new idea.

How much of this to believe

What holds up.

  • The memory accounting. It is arithmetic anyone can redo: 800 KiB per token, 15.7K slots in 12 GB and 60.1K for OPT-175B recompute exactly from the OPT configurations (Table 1, rebuilt). This page's simulator, given only Table 1's memory, the paper's own length distributions (Figure 11) and the allocation rules of §6.1, independently lands near Figure 2 and Figure 13 on ShareGPT: Orca (Max) batches exactly 7 requests and leaves 8.9% of memory free, and vLLM keeps about 96% of memory holding tokens (Simulate the KV cache).
  • Sharing savings. The simulator, with the authors' released benchmark rule (every sample runs to the trace's output length), gives 6.2%, 9.2% and 9.9% for 2, 4 and 6 parallel samples on Alpaca against the paper's 6.09%, 8.53% and 9.79%.
  • Later replication. The mechanism has been reimplemented and adopted across the industry (Hugging Face TGI, NVIDIA TensorRT-LLM, DeepSpeed-FastGen, SGLang; see Then and now), which is the strongest evidence that the memory win is real.
  • Fair statements of weakness. The paper reports its own kernel overhead, names the setup where it gains little (OPT-175B on Alpaca, compute-bound) and says where paging would hurt (§8). That counts in its favour.

What to discount.

  • The strongest baseline is the authors' own code. Orca was not public, so all three Orca variants are reimplementations, and "we assume Orca uses the buddy allocation algorithm" (§6.1). The buddy allocator's power-of-two rounding is a large part of the measured waste (36.6% "external fragmentation and others" for Oracle), so the baseline's waste is partly a modelling choice. FasterTransformer, likewise, ran under a scheduler the authors wrote.
  • Single runs, no error bars. Every curve in Figures 12, 14, 16 and 17 is one run of one synthetic trace per rate (15 minutes for OPT-175B); no seeds or spreads are reported.
  • The multiples depend on how they are read. "Sustains N× higher request rates at similar latency" has no stated latency threshold. Reading the curves from the paper's vector graphics at 0.5 s/token, vLLM over Orca (Oracle) on ShareGPT is 1.75×, 2.33× and 1.47× for 13B, 66B and 175B: the 175B panel falls below the stated "1.7× to 2.7×" at every threshold from 0.2 to 0.9 s/token. The chatbot's "2×" reads as about 1.4× to 1.7× (The curves, rebuilt). The shared-prefix 1.67× and 3.58× and the beam-search 2.3× do reproduce.
  • Paper and released code differ in places. §4.3's mixed prompt-and-decode steps match the released scheduler only at v0.1.0; from v0.1.3 to v0.1.7 a step with new prompts ran the prompts only, and the released defaults carried limits the paper does not state (details below).
  • Two sentences do not match their figures: the kernel overhead is "20 to 26%" only at batch size 32 (25% to 44% at batch 8), and the recomputation sentence above.
Alpaca's batch is not purely memory-bound (simulator against Figure 13)

Alpaca's batch is not purely memory-bound. The simulator's memory-limited vLLM batch on Alpaca is about 177 requests against Figure 13's 132.44, while Orca (Oracle) matches (72.6 against 72.75). At 30 requests/s vLLM is close to its capacity knee (Figure 12d), so its batch is likely set by arrivals, not memory; the 1.8× batch ratio there reflects the offered load, not the memory limit.

Paper against the released code, version by version

Paper and released code differ in places. §4.3 says each iteration concatenates prompt-phase and decode-phase tokens; the released scheduler did so in v0.1.0 (June 2023), but from v0.1.3 (2 August 2023) through v0.1.7 (11 September 2023, the day before the arXiv posting) a step with new prompts ran the prompts only. Not stated in the paper: the released defaults capped a step at 2,560 tokens and 256 sequences and kept 1% of blocks free as a watermark (v0.1.7 arguments, block manager).

Verdict: believe the mechanism and the memory numbers; they reproduce from first principles and the whole industry adopted the design. Treat "2 to 4×" as the top of a range measured against a baseline the authors built: the gain over an ideal contiguous allocator is real, about 1.5 to 2.4× on ShareGPT-like traffic, and shrinks toward 1× when memory is not the bottleneck.

What it takes to use this

  • Code and licence: vllm-project/vllm, Apache-2.0, installed with pip install vllm (version and popularity, dated, in the closed block under Why it matters). Everything in the paper is released; the paper-era engine (V0) has since been replaced (see Then and now); the engine as it is today: vLLM: inside the default engine.
  • Hardware: the paper's own results are A100s; a single A100-40GB serves OPT-13B with 12 GB of cache. Today's backends are in the dated block below.
  • Settings that matter: block size (16 is still the default), the fraction of GPU memory given to the cache, and the per-step token and sequence limits; paging needs no model changes.
  • When it pays off: many concurrent requests, long or unpredictable outputs, parallel sampling, beam search or shared prefixes, and memory-bound decoding. When it buys little: short sequences on a server with memory to spare (OPT-175B on Alpaca, where the Orca baselines nearly matched it), a single user who needs latency rather than throughput, or workloads with static shapes such as training (§8).

Why it matters (beyond the paper)

This is the paper that made high-throughput LLM serving an open-source commodity, and it did it by importing operating-system ideas from the 1960s (paging, copy-on-write, swapping) rather than new mathematics. The paged KV cache became the standard layout: Hugging Face TGI's PagedAttention "leverages the custom cuda kernels developed by the vLLM Project", TensorRT-LLM enables a paged KV cache (8 to 128 tokens per block) by default, DeepSpeed-FastGen credits vLLM for "blocked KV caching", and SGLang's RadixAttention stores its prefix-cache tensors "in a non-contiguous, paged layout, where the size of each page is equivalent to one token". Continuous batching with a paged cache became the baseline later serving papers measure against: Sarathi-Serve, for one, reports its gains "as compared to vLLM".

Later work refined rather than replaced it. vAttention (2024) keeps the cache contiguous in virtual memory with CUDA's virtual memory APIs and reports up to 1.23× over paged kernels, measuring that paged prefill kernels run up to 37% (FlashAttention-2) and 42% (FlashInfer) slower than their non-paged versions. Sarathi-Serve's chunked prefill and DistServe's disaggregated prefill and decode attacked the prefill-decode interference that step-level scheduling leaves open. Multi-head latent attention (DeepSeek) shrinks the cache from the model side.

vLLM itself became the reference open engine, later rebuilt (the V1 engine) around a per-request token budget that treats prefill and decode alike, and a standard rollout engine for RL post-training; its block manager, scheduler and paged kernels still descend directly from §4.2 to §4.5, so this paper remains the right mental model of the core (the engine today: vLLM: inside the default engine; dated detail below).

vLLM since the paper: releases, governance, adoption, sources read 3 October 2026 (dated; it will change)

vLLM itself became the reference open engine. It added automatic prefix caching, chunked prefill, speculative decoding, quantisation including a quantised KV cache, structured (guided) outputs, disaggregated serving and backends well beyond NVIDIA GPUs (README). The V1 engine (alpha January 2025, default from v0.8.0 in March 2025, the only engine from v0.11.0 in October 2025) rebuilt the scheduler around a per-request token budget that treats prefill and decode alike, made hash-based prefix caching nearly free, isolated the scheduler and executor in an EngineCore process, and delivered up to 1.7× the throughput of V0. vLLM became a PyTorch Foundation-hosted project on 7 May 2025, and llm-d (Red Hat with founding contributors CoreWeave, Google Cloud, IBM Research and NVIDIA) is "powered by a native Kubernetes architecture, vLLM-based distributed inference". It is also a standard rollout engine for reinforcement-learning post-training: verl integrates vLLM and SGLang, TRL documents a vLLM integration and OpenRLHF is built on "Ray + vLLM", so this memory model now sits inside training pipelines too. For anyone reading vLLM's code today, the block manager, scheduler and paged kernels descend directly from §4.2 to §4.5, and this paper is still the right mental model of the core.

Hardware: NVIDIA, AMD and Intel GPUs and x86, ARM and PowerPC CPUs, plus plugins for TPUs, Gaudi, Ascend and others (README).

The repository had about 93,000 GitHub stars on 3 October 2026; the latest release then was 0.30.0 on PyPI (22 September 2026, Python 3.10 to 3.14).

Connections

  • Attention Is All You Need: the KV cache being paged is the per-token key and value state of its self-attention.
  • FlashAttention: the complementary attention-systems paper. FlashAttention optimises compute and IO inside the kernel, PagedAttention where the KV operands live across requests; engines use both (vLLM V1 integrated FlashAttention 3, and the paper's prefill step uses FlashAttention-style attention, §4.3).
  • Megatron-LM: vLLM's distributed execution is Megatron-style tensor parallelism with the KV manager centralised above it.
  • DeepSeek-V3: multi-head latent attention shrinks the KV cache at the architecture level, the model-side attack on the same bottleneck; serving it needed new paged kernels (vLLM ships FlashMLA, per its README).
  • DeepSeek-R1: reinforcement-learning post-training depends on vLLM-class engines for fast rollout generation.
  • Topics: inference-and-serving (continuous batching, PagedAttention and KV caching are named scope items), cuda-and-gpu-programming (the fused paged-attention kernels), swe-and-system-design (a model systems paper: operating-system abstractions applied to a new resource).