Paged Attention is a virtual memory-inspired technique that divides the KV cache into fixed-size blocks, allowing them to be stored non-contiguously in GPU memory. This eliminates the internal and external fragmentation caused by pre-allocating large contiguous memory chunks for each sequence's maximum possible context length.
Glossary
Paged Attention

What is Paged Attention?
Paged Attention is a memory management algorithm that partitions the KV cache into non-contiguous blocks, eliminating fragmentation and enabling high-throughput serving of large language models.
By mapping logical KV cache blocks to physical memory blocks via a block table, Paged Attention enables memory sharing across sequences with identical prompt prefixes. This prefix caching optimization, implemented in serving engines like vLLM, dramatically increases throughput and reduces memory waste during batched inference.
Key Features of Paged Attention
Paged Attention is a novel memory management algorithm that treats the KV cache like virtual memory, partitioning it into fixed-size blocks that can be mapped non-contiguously in physical memory. This eliminates fragmentation and enables near-optimal memory utilization during LLM serving.
Block-Based Memory Management
Paged Attention partitions the KV cache into fixed-size blocks, analogous to pages in an operating system's virtual memory. Each block stores the key and value tensors for a contiguous subsequence of tokens. The block table maps logical sequences to physical blocks, allowing non-contiguous storage without requiring large contiguous memory allocations. This eliminates internal and external fragmentation, ensuring that memory is wasted only in the last block of a sequence—typically less than 4% overhead.
Memory Sharing via Copy-on-Write
Blocks can be shared across multiple sequences through a copy-on-write mechanism. When parallel sampling generates multiple outputs from a single prompt, all output sequences share the prompt's KV cache blocks. A block is only copied when a sequence writes to it, drastically reducing memory duplication. This is critical for techniques like beam search and parallel decoding, where dozens of sequences share a common prefix.
Dynamic Memory Allocation
Unlike traditional serving systems that pre-allocate a fixed maximum-length KV cache slot per sequence, Paged Attention allocates blocks on demand as generation proceeds. This enables the scheduler to oversubscribe GPU memory, packing more concurrent sequences than physically possible under static allocation. When memory is exhausted, blocks from preempted sequences can be swapped to CPU RAM and later restored, enabling graceful handling of memory pressure without request failure.
Near-Optimal Throughput
By eliminating fragmentation and enabling memory sharing, Paged Attention achieves near-optimal memory utilization. The vLLM serving engine, which implements this algorithm, demonstrates up to 24x higher throughput compared to Hugging Face Transformers and 2-4x improvement over previous state-of-the-art systems like FasterTransformer. This throughput gain comes entirely from better memory management, not from modifying the attention computation itself.
Seamless Batching and Preemption
Paged Attention enables continuous batching by allowing new sequences to join a running batch without waiting for existing sequences to complete. When GPU memory is exhausted, the scheduler can preempt low-priority sequences by evicting their blocks to CPU memory. When memory becomes available, blocks are swapped back in, and generation resumes exactly where it left off. This cooperative preemption avoids the all-or-nothing eviction of traditional systems.
Frequently Asked Questions
Clear, technical answers to the most common questions about the PagedAttention algorithm, its implementation in vLLM, and its impact on large language model serving throughput.
PagedAttention is a novel attention algorithm that manages the KV cache by partitioning it into fixed-size, non-contiguous blocks of memory, analogous to how an operating system manages virtual memory with pages. In a standard transformer, the KV cache grows as a contiguous tensor for each sequence, leading to internal and external memory fragmentation and limiting batch size. PagedAttention eliminates this by allowing each sequence's KV cache to be stored across multiple discrete blocks that do not need to be physically adjacent. During the attention computation, a block table maps logical block indices to physical block addresses, and a custom GPU kernel efficiently gathers the relevant blocks. This enables memory sharing between sequences—for example, when multiple requests share an identical system prompt prefix, the KV cache blocks for that prefix are mapped into each sequence's logical block table rather than being physically duplicated. The result is near-zero memory waste and the ability to pack significantly more concurrent sequences into GPU VRAM, directly translating to higher serving throughput.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
PagedAttention is a foundational innovation for high-throughput LLM serving. These related concepts form the complete stack for efficient, memory-optimized inference.
KV Cache
The key-value cache stores the computed attention keys and values from all previous tokens during autoregressive generation. Without it, the model would recompute attention for the entire sequence at each step, resulting in quadratic complexity. PagedAttention directly manages this cache by partitioning it into non-contiguous blocks, eliminating the memory fragmentation that plagues traditional contiguous allocation schemes.
Continuous Batching
A serving technique that maximizes GPU utilization by appending new sequences to a running batch immediately upon arrival, rather than waiting for the entire batch to complete. When combined with PagedAttention, continuous batching can seamlessly evict and reallocate KV cache blocks as sequences finish, allowing the freed memory to serve new requests without fragmentation penalties.
Prefix Caching
An optimization that stores and reuses the computed KV cache for a shared prompt prefix across multiple generation requests. When multiple users share a common system prompt, PagedAttention's block-based structure allows the prefix's KV blocks to be shared by reference rather than copied, dramatically reducing memory consumption and eliminating redundant computation for identical prompt segments.
Flash Attention
An IO-aware exact attention algorithm that minimizes high-bandwidth memory (HBM) reads and writes by tiling the computation in GPU SRAM. While Flash Attention optimizes the computation of attention, PagedAttention optimizes the storage of its outputs. The two techniques are complementary and often deployed together in production serving stacks to maximize both speed and memory efficiency.
Grouped-Query Attention (GQA)
An attention mechanism that uses a single set of key-value heads shared across multiple query heads, reducing the size of the KV cache proportionally. For example, Llama 2 70B uses 8 key-value heads for 64 query heads, cutting KV cache memory by 8x. GQA directly reduces the memory pressure that PagedAttention must manage, enabling larger batch sizes and longer context windows.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us