firehose> #llmops

Paged Attention

Paged attention applies operating-system virtual memory paging to the KV Cache, and the whole idea is in that sentence. Instead of one contiguous VRAM block per request sized to the maximum output length, the cache is broken into small fixed-size pages (16 tokens each by default in vLLM). Pages live anywhere in GPU memory — non-contiguous, allocated on demand as the sequence actually grows — and a lightweight block table maps the logical page addresses the model sees to the physical page addresses where the data really sits. That indirection is the entire mechanism, and it dissolves all three modes of KV Cache Fragmentation at once: internal waste is bounded by one page, external gaps stop mattering because contiguity is no longer required, and duplication disappears because two requests' block tables can point at the same physical page.

That last property is the one that compounds. Because blocks are hashed by their token sequence, requests sharing a system prompt resolve to the same physical pages automatically — cross-request prefix sharing is not a separate feature bolted on, it is what content-addressed pages are. This is the mechanism underneath Prompt Caching, and it explains that concept's otherwise arbitrary rule that the stable content must come first: a cache hit is a chain of matching block hashes, and the first differing token ends the chain.

The transferable lesson is larger than LLM serving: a decades-old solution from an adjacent systems discipline often beats a novel domain-specific one. Nothing about paging is new; what was new was noticing that KV cache allocation had become a memory-management problem and that memory management was already solved.

Claims


Linked from