Inference terms

PagedAttention: how vLLM manages KV memory

PagedAttention is an attention algorithm, introduced with vLLM in 2023, that stores each request's KV cache in small fixed-size blocks instead of one contiguous region. A block table maps logical blocks to physical ones, the way an operating system maps memory pages. The vLLM authors report this cut KV cache waste from 60-80% to under 4%, letting a GPU batch far more requests at once.

What PagedAttention solves

Every running request keeps keys and values for its tokens in the KV cache. Before vLLM, many serving systems reserved one contiguous chunk per request, sized for the maximum possible output. Most requests never used that much, and the leftover gaps between chunks could not be handed to anyone else.

The vLLM team measured the cost. Their launch post says existing systems wasted 60-80% of this memory to fragmentation and over-reservation. Wasted cache memory means fewer requests in the batch, and fewer requests in the batch means lower throughput per GPU.

The paper by Kwon et al. described the cache as large and dynamic, and showed that managing it poorly wastes memory through fragmentation and redundant duplication. Its answer borrowed a fifty-year-old idea from operating systems.

References: vLLM blog: Easy, fast, and cheap LLM serving with PagedAttention · Kwon et al., Efficient Memory Management for LLM Serving with PagedAttention

How PagedAttention works

The cache is divided into blocks, each holding keys and values for a fixed number of tokens. A request's blocks do not need to sit next to each other in memory. Each request has a block table that maps its logical blocks, in order, to physical blocks anywhere on the GPU. The attention kernel follows the table to fetch keys and values block by block.

The vLLM authors put the analogy directly: blocks are pages, tokens are bytes and sequences are processes. New blocks are allocated only as a sequence grows. The only waste is the unfilled part of each sequence's last block, which the authors report keeps total waste under 4%.

Blocks can also be shared. When several outputs come from one prompt, as in parallel sampling or beam search, they point at the same physical blocks for the shared prefix. A reference count tracks sharing, and copy-on-write duplicates a block only when one sequence changes it. The launch post reports this cut memory use for such sampling by up to 55%, worth up to 2.2× throughput.

How PagedAttention works
Operating system ideaPagedAttention equivalent
PageCache block holding a fixed number of tokens
ByteToken
ProcessSequence (request)
Page tableBlock table: logical to physical blocks
Shared pages with copy-on-writeShared prompt blocks across samples or beams

References: vLLM blog: Easy, fast, and cheap LLM serving with PagedAttention · Kwon et al., Efficient Memory Management for LLM Serving with PagedAttention

Worked example: reserved vs paged memory

Assume a block size of 16 tokens and Llama 3.1 8B, which needs 128 KiB of cache per token in BF16. A request has a 600-token prompt and writes 400 tokens, 1,000 in all, against a 4,096-token maximum.

With up-front reservation, the system holds 4,096 token slots: 512 MiB. Only 1,000 are used, so 3,096 slots, about 387 MiB, sit idle until the request ends. With paged blocks, the request uses 63 blocks: 62 full and one holding 8 tokens. Waste is 8 slots, or 1 MiB. Across 40 concurrent requests, the difference is roughly 15 GiB of memory that can hold more conversations.

Worked example: reserved vs paged memory
Item (1,000 tokens used, illustrative)Reserve 4,096 tokensPaged, 16-token blocks
Token slots held4,0961,008 (63 blocks)
Memory held at 128 KiB/token512 MiB126 MiB
Idle slots3,0968
Idle memoryAbout 387 MiB1 MiB
Idle memory over 40 requestsAbout 15 GiB40 MiB

References: Llama 3.1 8B Instruct config.json (Hugging Face mirror)

Published results

The paper reports that vLLM improves throughput of popular models by 2-4× at the same latency compared with FasterTransformer and Orca. The launch post reports up to 24× higher throughput than Hugging Face Transformers and up to 3.5× higher than Text Generation Inference, measured by the authors on LLaMA-7B on an NVIDIA A10G and LLaMA-13B on an A100 40GB, with request lengths sampled from ShareGPT.

These are 2023 results against 2023 baselines. Other engines have since adopted paged or block-based cache management, so the gap between modern engines is much smaller. Treat the figures as evidence that the technique works, not as a forecast for your setup.

References: Kwon et al., Efficient Memory Management for LLM Serving with PagedAttention · vLLM blog: Easy, fast, and cheap LLM serving with PagedAttention

Configure it in vLLM, SGLang and llama.cpp

In vLLM, paging is always on. --block-size sets the number of tokens per block. --gpu-memory-utilization sets how much GPU memory the engine may use, and the block pool gets what remains after weights and activations, and vllm:kv_cache_usage_perc shows how full it is. --enable-prefix-caching builds on blocks: vLLM hashes each full block by its tokens and the prefix before it, so a later request with the same prefix reuses the block. Freed blocks go to a queue and the least recently used are evicted first.

SGLang uses its own paged pool. --page-size sets tokens per page, with a default of 1, and RadixAttention reuses shared prefixes across requests unless you pass --disable-radix-cache. --mem-fraction-static sets the memory for weights plus the pool.

llama.cpp's server works differently: -c sets a total context that its -np slots share, and -kvu uses one unified buffer across sequences. It does not describe this as PagedAttention, so compare engines by measuring concurrency at your context length rather than by feature name.

Configure it in vLLM, SGLang and llama.cpp
EngineBlock or page sizeMemory budgetPrefix reuse
vLLM--block-size--gpu-memory-utilization--enable-prefix-caching (hashed blocks, LRU eviction)
SGLang--page-size (default 1)--mem-fraction-staticRadixAttention; off with --disable-radix-cache
llama.cppNot paged in the same way-c shared by -np slots; -kvu unified buffer--cache-reuse via KV shifting

References: vLLM documentation: vllm serve arguments · vLLM documentation: Automatic prefix caching design · SGLang documentation: Server arguments · llama.cpp server README · vLLM documentation: Metrics design

How PagedAttention changes cost per token

Memory that is not wasted becomes batch slots, and batch slots become tokens per GPU-hour. In the example above, 15 GiB saved across 40 requests is room for about 15 more 8K conversations on an 8B model, if compute keeps up.

An illustrative calculation with assumed figures: a GPU at an assumed $2 per hour serves 40 concurrent requests and an assumed 1,200 output tokens per second with reserved memory. With block allocation it serves 55 requests and, by assumption, 1,500 tokens per second. Cost per million output tokens falls from about $0.46 to about $0.37. Measure your own engine at your context lengths before you plan on it. To choose the right GPU and engine, start with deploy vLLM on a cloud GPU.

How PagedAttention changes cost per token
Allocation (illustrative)Concurrent requestsAssumed output tokens/sCost per million at $2/h
Reserve maximum length401,200$0.46
Paged blocks551,500$0.37

Common misconceptions

It does not reduce the memory each token needs; the per-token cost is set by the model and the cache data type. It removes waste around that memory. It is also not a faster attention formula like FlashAttention; it changes where keys and values live and how the kernel finds them. And it does not remove out-of-memory errors: a cache that is truly full still queues or preempts requests, as vLLM out of memory explains.

References: Kwon et al., Efficient Memory Management for LLM Serving with PagedAttention

Related terms

Continuous batching uses the freed memory to keep more requests in flight. Prefix caching reuses blocks across requests. Time to first token drops when prefix blocks are reused. FlashAttention speeds up the attention math itself and is often used alongside block-based caching.

Checklist and next step

Watch cache usage under real load. Set the memory fraction and maximum context for your traffic. Turn on prefix caching if requests share system prompts. Track preemptions and waiting requests. Compare engines by concurrent requests served at your target latency.

Then size the GPU. NeuraMesh rents GPUs by the hour: choose a GPU, a plan, GPU count, hours and region on rent GPUs, and you receive a confirmed quotation, typically within one business day, with nothing charged until you approve. The compute advisor can suggest a card for your model.

NeuraMesh prices for these GPUs

NeuraMesh prices per GPU-hour in USD, excluding taxes, as of 2026-11-27. Live prices are on the rental pages.
GPUMemoryData centerValue
RTX 409024 GB$0.46$0.40
L40S48 GB$1.26$0.54
A10080 GB$1.56$0.98
H10080 GB$2.88$2.00

Every order is confirmed in a quotation before you pay. See all GPU prices.

Questions readers ask

What is PagedAttention in simple terms?

It stores each request's attention keys and values in small fixed-size blocks that can sit anywhere in GPU memory, tracked by a block table. Memory is handed out as a sequence grows instead of reserved for the worst case, so little is wasted.

Who created it?

Researchers at UC Berkeley, led by Woosuk Kwon, introduced it with the vLLM project in 2023. The paper is Efficient Memory Management for Large Language Model Serving with PagedAttention.

Do I need to enable it in vLLM?

No. Block-based cache management is how vLLM stores keys and values. You can change block size with --block-size and turn on prefix caching, but there is no switch to turn paging off.

Is PagedAttention the same as prefix caching?

No, but prefix caching depends on it. Paging stores each request in blocks. Prefix caching keeps full blocks after a request ends, indexed by a hash of their tokens and prefix, so a later request with the same start can reuse them and skip that part of prefill.

Does it help a single user?

Very little. Its benefit is fitting more requests into the same memory, and parallel sampling sharing. A lone request on a large GPU rarely runs short of cache memory.

Sources and editorial notes

Primary documentation reviewed November 24, 2026. Provider descriptions reflect published documentation. Recommendations are our analysis; worked figures are illustrative unless explicitly stated otherwise. No independent provider benchmark or uptime ranking is claimed.

Read the editorial policy.

Need this GPU? Rent it from NeuraMesh: choose a GPU and plan, get a confirmed quotation, and pay only when you approve. See pricing.