Apex › Storage & databases

KV cache & PagedAttention

Why an LLM server’s memory, not its compute, caps how many chats it runs at once. Every token’s key and value stay in the KV cache so attention can look back; reserving a contiguous slab for each request’s max context wastes almost all of it — the same internal fragmentation that killed fixed-partition OS memory. vLLM’s PagedAttention applies the virtual-memory fix: fixed-size blocks + a per-sequence block table, allocated on demand. Slide the sequence length and flip naive↔paged to watch the block pool go from mostly-empty to packed and the sequences-that-fit jump ~10×.

More in Storage & databases