System Design
19. AI System Design and LLM InfrastructureAnimated
Paged Attention
Manage the KV cache in fixed-size blocks.
The idea
Like virtual memory pages, blocks are allocated on demand, removing fragmentation.
Watch it work
Press play, pause, or step through. Some animations have settings you can change.
Memory is split into small blocks, like pages in an operating system.
- used:
- 0
- free:
- 16
1/12
PagedAttention (vLLM) removes the fragmentation that wastes most KV-cache memory.
Step by step
- 1Split the KV cache into blocks
- 2Allocate as the sequence grows
- 3Free blocks when done
- 4Share blocks for shared prefixes
Where it is used
vLLM-style serving.
Watch out for
Block table lookup adds a little overhead.