What is PagedAttention?

PagedAttention is an attention and memory management method in language model serving that manages the KV cache in fixed-size blocks, like virtual memory in operating systems, reducing memory fragmentation.

It differs from FlashAttention in its goal: FlashAttention speeds up the attention computation itself and cuts memory access, while PagedAttention organises how KV cache memory is allocated and shared. It computes attention exactly and does not change model outputs or accuracy.

Topic
Inference and performance
Also known as
Paged attention, paged KV cache
Origin
2023, Kwon et al.

How PagedAttention works

  1. Each sequence's KV cache is split into fixed-size blocks that need not be contiguous in memory.
  2. A block table tracks which physical blocks hold each sequence; attention reads the right blocks through this table.
  3. Memory is allocated block by block as a request grows, so no large area has to be reserved for the longest possible answer and waste falls.
  4. Blocks are freed when a request ends; requests sharing a common prefix can share the same blocks.

In more detail

Internal versus external fragmentation and block size

PagedAttention eliminates external fragmentation completely because every physical block has the same fixed size, leaving only minor internal fragmentation in each sequence's final partially filled block. Choosing the block size (typically 16 or 32 tokens) involves a direct trade-off: very small blocks increase block-table lookup and kernel overhead, while overly large blocks increase internal waste.

Copy-on-write and prefix sharing

When shared prefixes (such as a system prompt or parallel beam-search branches) diverge, PagedAttention applies copy-on-write: sequences continue reading the shared physical blocks until a token differs, at which point only the diverging block is copied and modified. This substantially lowers KV-cache memory consumption in multi-branch decoding and shared-instruction workloads.

Swapping versus recomputation when memory fills

If concurrent requests exhaust all physical KV blocks in GPU memory, the serving engine must preempt lower-priority or recent sequences either by swapping their KV blocks to host CPU RAM over PCIe or by discarding and recomputing them later. Understanding this preemption policy is vital for capacity planning because excessive swapping or recomputation causes sudden tail-latency spikes.

Use alongside KV cache quantisation, GQA, MLA and disaggregated serving

Paged KV-cache management has evolved alongside grouped-query attention (GQA), multi-head latent attention (MLA), FP8 KV-cache quantisation and disaggregated prefill-decode architectures. Combining paging with lower-precision KV caches and cross-node KV transfer frameworks further expands effective context capacity on fixed on-premise hardware.

Commonly confused terms

TermHow it differs
Continuous batchingContinuous (iteration-level) batching schedules new requests into running batches at every decode step; PagedAttention supplies the non-contiguous KV-cache memory layout that prevents memory fragmentation from blocking those dynamic batches.
Prefix cachingAutomatic Prefix Caching (APC) or RadixAttention reuses identical KV blocks across prompts sharing a system prompt or few-shot prefix; PagedAttention is the underlying block-table and copy-on-write paging primitive that makes block-level sharing possible.

Why PagedAttention matters for on-premises AI

With long contexts and uneven request lengths, classic allocation leaves much memory unused; paging cuts that loss. The organisation's existing GPUs can then serve more users at once and extra hardware can wait. Used with continuous batching, the effect grows. The gain depends on workload and hardware; it does not guarantee the same rise in concurrent requests everywhere, so organisations measure with their own load.

ON-PREMISES EXAMPLE

A bank uses an inference server with PagedAttention to raise the number of concurrent customer chats; with the KV cache managed in pages, the same GPU handles more sessions.

Common questions

Does PagedAttention change model output or accuracy?

No. It computes attention exactly and only changes how the KV cache is held in memory.

What is needed to use PagedAttention?

An inference engine that supports it. Most current language model serving software includes paged KV caching; no model retraining is required.

Sources

Related page on this site: Supermicro page · In the glossary: Glossary, M to Q

What does this term mean for your infrastructure?

We can work out together in a technical assessment how it maps onto your data, hardware and security requirements.

Request a technical assessment →

This site sets no cookies. Visitor numbers are counted in aggregate using a cookieless method that does not identify anyone. See the Privacy Policy for details.