What problem does PagedAttention solve and why does block-based allocation enable larger batches?
Explain what PagedAttention is, what allocation pathology it eliminates, and why the design choice directly translates into more concurrent requests per GPU. Draw the analogy to a familiar OS-level mechanism.
PagedAttention stores the KV cache in fixed-size blocks indexed by a per-request block table, killing the internal fragmentation that contiguous max-length reservation wastes, so batch size and throughput jump.
Imagine a parking garage where every arriving car is told to reserve a whole long lane, just in case it tows a giant trailer. Most cars are tiny, so each lane sits mostly empty, and the garage fills up while half the space is wasted. Now switch to normal parking spots: each car takes only the spots it actually needs, and you keep a little map saying which spots belong to which car. When a car leaves, its spots free up for the next one. PagedAttention does this for the memory that holds a model's running notes. Instead of pre-reserving the longest possible answer per request, it hands out small fixed blocks on demand. The garage fits far more cars, which here means far more chat requests on one GPU.
Detailed answer & concept explanation~8 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
4 min: define the KV cache and contiguous max-length reservation, name internal fragmentation and its 60 to 80 percent waste, draw the OS paging analogy with a block table, cover copy-on-write prefix sharing, then connect reclaimed memory to bigger batches and weight-read amortization.
| Aspect | Naive contiguous KV | PagedAttention |
|---|---|---|
| Allocation unit | One slab per request at max length | Fixed blocks (about 16 tokens) from a pool |
| Internal fragmentation | 60 to 80 percent of KV memory wasted | At most one partial block per request |
| Indexing | Direct offset into the slab | Block table maps logical to physical |
| Prefix sharing | Each request holds a private copy | Copy on write across shared blocks |
| Achievable batch size | Limited by reservations | Roughly 2 to 4 times larger |
Real products, models, and research that use this idea.
- vLLM (UC Berkeley) introduced PagedAttention and reported roughly 2 to 4 times the throughput of prior serving stacks, making it the default engine for most open-source deployments in 2026.
- SGLang builds on paged KV blocks with RadixAttention, sharing prompt-prefix blocks across requests to cut redundant cache for common system prompts on Llama 4 and Qwen 3.
- TensorRT-LLM (NVIDIA) ships a paged KV cache plus chunked prefill as the production reference on H100 and B200 hardware.
- Hugging Face TGI adopted paged KV blocks to lift concurrency on shared inference endpoints serving many tenants.
- DeepSeek V4 pairs Multi-head Latent Attention with paged allocation so the already-small per-token cache packs densely across a large batch.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhat is the difference between internal and external fragmentation here, and which does PagedAttention target?
QHow does copy-on-write block sharing work for a common system prompt across many requests?
QWhy does a larger batch raise throughput if it does not reduce per-token compute?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Calling it a faster attention kernel. PagedAttention changes nothing in the attention math; it is a memory allocator for the KV cache, and the win is utilization, not arithmetic.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.