Menu

PagedAttention: Why Splitting the KV Cache into Blocks Lets Long Contexts Fit in Memory
πŸ“°

PagedAttention: Why Splitting the KV Cache into Blocks Lets Long Contexts Fit in Memory

DEV Community: deeplearningΒ·Umesh Tharuka MalaviarachchiΒ·9 days ago
#yjYUOJ93
#devtodeeplearning#education#devto#dev#block
Long article (2114 words) β€” no AI summary yet.
Reading 0:00
15s threshold

PagedAttention: Why Splitting the KV Cache into Blocks Lets Long Contexts Fit in Memory

Serving a large language model is, to a surprising extent, a memory management problem. The weights are large, but they are fixed. The part that grows while a request runs is the key-value cache, the stored keys and values for every token generated so far. When that cache is managed badly, most of the GPU memory set aside for it sits empty, and requests that could have run together wait in a queue instead. PagedAttention fixes the management, not the model, and the fix is borrowed from an old idea in operating systems: paging.

The idea was introduced in the vLLM system by Kwon and colleagues in 2023. It does not change what attention computes. It changes where the keys and values live, and how they are found, so that memory is allocated only when it is actually needed and can be shared when several requests need the same tokens.

The KV cache problem

A transformer generates one token at a time.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.