How does PagedAttention enable prefix sharing across requests and what data structure makes it cheap?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Explain how PagedAttention's block-table design lets multiple in-flight requests share KV cache for a common prompt prefix without copying it. What data structure makes detection cheap, and what happens when one request needs to diverge from the shared prefix?
Block tables map each request's KV positions to fixed-size physical blocks, so requests with a shared prefix point at the same blocks; a hash index detects the match and copy-on-write handles divergence.
Imagine a library where every reader needs the same opening chapters of a textbook before branching into their own topic. Instead of photocopying those chapters for each reader, the librarian hands everyone a card that points to the one shared copy on the shelf. The library keeps a tally of how many readers point at each shelf slot. When a reader finally wants to scribble their own notes onto a page, the librarian photocopies just that one page, gives it to them, and updates their card to point at the copy. Everyone else keeps sharing the original. A quick lookup table tells the librarian instantly whether an arriving reader's opening chapters already sit on a shelf, so nobody waits while shared pages are found and reused.
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: block table indirection + pointer sharing of prefix blocks + reference counting + copy-on-write divergence + parent-chained block hashing + RadixAttention contrast + eviction and cache-key correctness.
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.
Saying the shared prefix is copied into each request's cache. It is referenced by pointer, never duplicated; only a divergent block is ever copied, and only that block.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.