PagedAttention is an attention algorithm, introduced with the vLLM inference engine, that manages the Key-Value (KV) cache in non-contiguous, paged memory blocks analogous to virtual memory in operating systems. This design decouples the logical sequence of tokens from their physical memory layout, allowing for dynamic memory allocation and eliminating the need for pre-allocating large, contiguous buffers for the maximum possible sequence length.
Glossary
PagedAttention

What is PagedAttention?
PagedAttention is an algorithm for managing the Key-Value (KV) cache in large language model inference, enabling efficient memory sharing for variable-length sequences.
The paged approach enables critical optimizations like memory sharing for identical prompts across multiple requests and highly efficient continuous batching with variable sequence lengths. By reducing internal memory fragmentation and waste, PagedAttention dramatically increases the number of concurrent requests a server can handle, directly improving throughput and reducing the cost per token for LLM serving.
Key Features of PagedAttention
PagedAttention is the core memory management algorithm in the vLLM inference serving engine. It treats the Key-Value (KV) cache of a Transformer model like an operating system manages virtual memory, enabling high throughput for variable-length sequences.
Non-Contiguous Memory Paging
PagedAttention divides the KV cache for each sequence into fixed-size blocks, analogous to memory pages. These blocks can be allocated in non-contiguous physical memory (GPU DRAM). This eliminates the need for large, contiguous memory reservations and prevents fragmentation when sequences are of different lengths or are processed in continuous batching.
- Key Benefit: Enables efficient sharing of GPU memory across multiple requests.
- Analogy: Similar to how an OS allows a program's memory to be scattered across physical RAM.
Efficient Memory Sharing
The algorithm enables two powerful forms of memory sharing, drastically reducing total memory consumption:
- Shared Prompts: In multi-user or multi-tenant scenarios, identical system prompts or shared context across requests (e.g., a document preamble) are stored in read-only KV cache blocks. All sequences referencing this context point to the same physical memory.
- Parallel Sampling: When generating multiple outputs (candidates) from a single prompt (e.g., for beam search or sampling), the shared prompt's KV cache is not duplicated. Each candidate sequence reuses these blocks, diverging only in newly generated tokens.
This sharing is managed via a block table that maps logical blocks in a sequence to physical blocks in memory.
Block Table & Virtual Addressing
Each sequence maintains a block table, a central data structure that acts as a page table. It maps the sequence's logical KV cache blocks to physical blocks in GPU memory.
- Logical Blocks: Represent the sequence's KV cache in order.
- Physical Blocks: The actual allocated memory locations, which may be non-contiguous or shared.
- Function: During attention computation, the kernel uses this table to gather the required keys and values from potentially scattered physical blocks, performing the equivalent of a virtual-to-physical address translation.
This indirection is what enables flexible allocation, sharing, and on-the-fly memory optimization.
Optimized Attention Kernels
PagedAttention requires custom GPU kernels to execute efficiently. These kernels are designed to:
- Interpret Block Tables: Read the mapping and gather KV data from the dispersed physical blocks.
- Handle Variable-Length Sequences: Seamlessly compute attention for sequences where the last block may be partially filled.
- Minimize Overhead: The gather operation is fused into the attention computation, avoiding significant performance penalties compared to naive implementations.
These kernels are a key enabler, making the paging abstraction practical for high-performance inference.
Dynamic Allocation & Eviction
Blocks are allocated dynamically as a sequence generates more tokens. When GPU memory is exhausted, vLLM can employ eviction policies to reclaim space.
- Allocation: New blocks are assigned from a free pool as needed.
- Eviction: Least-recently-used (LRU) or other policies can swap out blocks of completed or low-priority sequences. In a future extension, blocks could be paged to CPU RAM.
- Benefit: This allows the system to serve more concurrent requests than would fit if all KV caches were pre-allocated contiguously, maximizing GPU utilization and throughput.
Enabler for Continuous Batching
PagedAttention is foundational for continuous batching (iteration-level scheduling). In this paradigm, new requests are added to a running batch as others finish, creating a ragged batch of sequences at different generation stages.
- Challenge: Traditional contiguous KV cache management cannot handle this efficiently.
- Solution: PagedAttention's block-based approach allows each sequence to manage its cache independently. The scheduler can add a new sequence by simply allocating a new block table and a few initial blocks, without reorganizing the memory of existing sequences.
This combination is what allows vLLM to achieve near-100% GPU utilization during inference.
PagedAttention vs. Traditional KV Cache Management
A technical comparison of memory management strategies for the Key-Value (KV) cache during autoregressive generation in large language models.
| Feature / Metric | Traditional KV Cache (Contiguous) | PagedAttention (vLLM) |
|---|---|---|
Memory Allocation | Contiguous per sequence | Non-contiguous, paged blocks |
Memory Sharing | ||
Handles Variable-Length Sequences | Inefficient, causes fragmentation | Efficient, eliminates internal fragmentation |
Memory Utilization | Low (typically 20-40%) | High (near 100%) |
Maximum Batch Size | Limited by worst-case sequence length | Dramatically increased, limited by total physical memory |
Implementation Complexity | Lower | Higher (requires virtual memory management) |
Sequential Decoding Speed | Baseline | Comparable or faster (reduced memory pressure) |
Support for Advanced Sampling | Limited (beam search is complex) | Native support for parallel sampling/beam search |
Frequently Asked Questions
PagedAttention is a foundational algorithm for efficient large language model serving, enabling high-throughput inference by optimizing memory management for the Key-Value (KV) cache. These questions address its core mechanics, benefits, and practical applications.
PagedAttention is an attention algorithm that manages the Key-Value (KV) cache in non-contiguous, paged memory blocks, analogous to virtual memory paging in operating systems. It works by decoupling the logical sequence of tokens from their physical memory layout. Instead of allocating a single contiguous block of memory for each request's KV cache—which leads to fragmentation and wasted capacity due to variable sequence lengths—PagedAttention divides the cache into fixed-size blocks. A block table for each request maps its logical tokens to these physical blocks, allowing blocks to be shared across sequences (e.g., in prompt sharing) and allocated on-demand. This enables the vLLM serving engine to achieve near-zero internal fragmentation and high GPU utilization.
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 core component of high-throughput LLM serving. These related concepts are essential for understanding the broader ecosystem of memory, scheduling, and computational optimizations required for efficient inference.
Continuous Batching
An inference scheduling strategy that dynamically groups incoming requests into a running batch. Unlike static batching, new sequences are added to the batch as others finish generation, maximizing GPU utilization. This is the scheduling layer that PagedAttention optimizes for, as it efficiently manages the KV cache for sequences of variable and unpredictable lengths within the continuous batch.
KV Cache
The Key-Value (KV) Cache is a memory buffer that stores the computed key and value vectors for previous tokens in a sequence during autoregressive generation. This avoids recomputing these vectors for every new token, dramatically reducing computational cost. PagedAttention is an algorithm specifically designed to manage this cache efficiently in non-contiguous, paged memory blocks.
FlashAttention
An I/O-aware, exact attention algorithm that reduces memory reads/writes between GPU SRAM and HBM. While PagedAttention optimizes memory management between attention computations (the KV cache), FlashAttention optimizes the computation of attention itself. They are complementary techniques: FlashAttention speeds up the attention operation, and PagedAttention efficiently manages the memory for its inputs/outputs across many concurrent requests.
Memory Fragmentation
A state where free memory is broken into small, non-contiguous blocks, preventing the allocation of larger contiguous buffers despite sufficient total free space. In LLM serving, variable-length sequences cause severe external fragmentation of the KV cache. PagedAttention solves this by allocating memory in fixed-size blocks (pages), eliminating fragmentation and allowing memory to be shared (e.g., for prompt sharing between requests).
Inference Latency & Throughput
The two primary performance metrics for model serving. Latency is the time to process a single request. Throughput is the number of requests processed per unit of time. PagedAttention primarily optimizes for throughput by enabling higher GPU utilization through efficient continuous batching and reduced memory waste. It can also reduce latency in high-load scenarios by preventing queueing delays.

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