The block table: PagedAttention as OS-style paging
Module 6 derived how much memory paging recovers. This concept is about the data structure that recovers it.
The KV cache is never reserved for a sequence's maximum possible length. Instead it is carved into fixed-size blocks — 16 tokens each, in vLLM's original design — drawn from a single pool shared by every sequence resident on the GPU. Each sequence owns a block table: a small array mapping its logical block indices (0, 1, 2, …, in the order the sequence filled them) to physical block indices anywhere in that shared pool. That is exactly the indirection an operating system uses for virtual-memory pages, mapped onto a much smaller address space — a sequence at 8k context needs 512 logical blocks, not the millions of pages a real OS manages, so the whole table for one sequence is a couple of kilobytes (the math lab makes this precise).
A sequence claims a new physical block only when its current one fills — after its 17th token, not before. Allocation tracks actual usage instead of a worst-case reservation, which is the entire mechanism behind Module 6's fragmentation numbers: nothing is wasted because nothing is reserved ahead of need.
The attention kernel has to cooperate with this or the indirection is pointless. Given a block table and a slot mapping — which physical slot each token in the current step's batch belongs to — a paged-attention kernel gathers the right K and V vectors from scattered physical memory instead of assuming one contiguous run per sequence. This is the detail Module 7's kernel material calls out: paging changes the memory access pattern attention has to support, not just the allocator sitting above it. A kernel written for a contiguous cache cannot serve a paged one; the two were co-designed.
One consequence worth stating plainly, because it explains why the mechanism is boring rather than clever: nothing here is lossy. Every byte in the cache is still exactly the K and V vectors the model would have produced with a contiguous buffer. Paging is pure bookkeeping — it changes where bytes live, never what they are — which is why Module 6 could call it free.
LOGICAL (per sequence) PHYSICAL POOL (shared)
seq A block table ┌───┬───┬───┬───┬───┬───┬───┬───┐
L0 ──────────────────┐ │ P0│ P1│ P2│ P3│ P4│ P5│ P6│ P7│
L1 ──────────┐ └────────────► │ │ │███│ │ │███│ │███│
L2 ──┐ │ └───┴───┴───┴───┴───┴───┴───┴───┘
│ └───────────────────► ▲ ▲ ▲
└────────────────────────────────────────────► L2 L1 L0
(16 tokens each, non-contiguous)
REMEMBERA block table is a small array of physical block ids; the attention kernel reads through it instead of assuming one contiguous buffer per sequence.