Loading the interactive visualization…

08 · Reference notes

← All visual guides

PagedAttention Explained

PagedAttention manages the KV cache in fixed-size blocks, letting LLM serving systems allocate and share GPU memory efficiently without contiguous reservations.

01 · Definition

What is PagedAttention?

It is a serving-system technique rather than a new attention equation. The model's logical KV cache remains one sequence, while the physical GPU blocks that hold it can be allocated wherever space is available.

02 · Mechanism

Why contiguous KV caches waste memory

Serving many requests creates caches of different lengths that grow at different speeds. Reserving one large contiguous region for each sequence leads to fragmentation and over-allocation, especially when generations finish at unpredictable times.

03 · Mechanism

How pages map the cache

PagedAttention divides each KV cache into fixed-size blocks. A small block table maps a sequence's logical token positions to physical GPU blocks, much like virtual memory maps an address space to pages. Attention reads through the table as if the cache were continuous.

04 · Mechanism

Why block sharing helps

When requests share a prompt, their initial KV-cache blocks can be shared instead of copied. New blocks are allocated only as each request generates, which improves memory utilization and supports higher serving throughput.

05 · Mechanism

What PagedAttention changes

The attention math is unchanged. PagedAttention changes the memory manager around the cache so an inference server can pack, grow, release, and sometimes share cache storage more efficiently.

Source · Original paper