Inspired by operating system virtual memory, PagedAttention partitions the KV cache into small, fixed-size blocks (e.g., 16 tokens) that are allocated on-demand and can be non-contiguous in physical memory. This eliminates fragmentation, reducing memory waste to under 4%, and enables efficient memory sharing via a block table.