What problem does PagedAttention solve and why does block-based allocation enable larger batches?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
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.
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.
What an interviewer would ask next. Try answering before peeking at the approach.
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.