protologue

FlashAttention vs PagedAttention

FlashAttention and PagedAttention both make transformer attention cheaper on GPUs but solve different problems. FlashAttention speeds up the attention computation itself by working in tiles in fast on-chip memory, mainly for training and long prompts, while PagedAttention manages the memory that holds each request's key-value cache during serving, storing it in non-contiguous blocks so that more requests fit in a batch.

Definitions

FlashAttention PTL-0252
FlashAttention is an exact attention algorithm for transformers that computes attention in tiles held in fast on-chip GPU memory, reducing reads and writes to slower high-bandwidth memory so that attention runs faster and uses memory linear rather than quadratic in sequence length.
PagedAttention PTL-0253
PagedAttention is a technique for serving language models that stores each request's key-value cache in fixed-size blocks that need not be contiguous in memory, like pages in operating-system virtual memory, which reduces wasted memory and lets requests share cached blocks.

Differences

FlashAttentionPagedAttention
Problem addressedMemory traffic during the attention computationFragmented, duplicated key-value cache memory during serving
Main ideaCompute exact attention in tiles held in on-chip SRAMStore the KV cache in fixed-size blocks, like virtual-memory pages
Where it is usedTraining and inference kernelsServing systems that batch many requests, such as vLLM
Changes the model's outputNo, the result is exact attentionNo, it changes memory layout only
Reported benefitFaster training and longer feasible contextsTwo to four times higher serving throughput at similar latency

Which to use

  • Look to FlashAttention when the attention computation itself is the bottleneck, as in training or processing long inputs.
  • Look to PagedAttention when serving many concurrent requests and KV cache memory limits the batch size.

Sources

  1. Dao et al. (2022). FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness.
  2. Kwon et al. (2023). Efficient Memory Management for Large Language Model Serving with PagedAttention.

Cite this page

Protologue. (2026). FlashAttention vs PagedAttention. In Protologue: A Taxonomy of Prompting and LLM Techniques (v1.7.0). https://protologue.com/compare/flashattention-vs-pagedattention/

Markdown