The decoding phase is the iterative, memory-bandwidth-bound stage of autoregressive inference where a language model generates its output sequence token-by-token. Each forward pass consumes the previously generated token and the cached key-value (KV) states to produce the next token's logits, a process repeated until a stop condition is met. This phase is characterized by small, sequential computations dominated by memory reads, making it fundamentally different from the parallel prefilling phase.
Glossary
Decoding Phase

What is the Decoding Phase?
A technical definition of the decoding phase in autoregressive language model inference.
Optimizing the decoding phase is critical for reducing inference latency and cost. Techniques like continuous batching and KV cache management directly target its bottlenecks by maximizing GPU utilization and minimizing redundant memory transfers. Its performance is a primary determinant of user-perceived speed in applications like chatbots and code completion, making it a central focus of inference serving architectures.
Key Characteristics of the Decoding Phase
The decoding phase is the primary latency and cost driver in autoregressive text generation. Its defining characteristics stem from its iterative, sequential nature and heavy reliance on memory bandwidth.
Autoregressive and Sequential
The decoding phase operates autoregressively, meaning each generated output token becomes part of the input for generating the next token. This creates a fundamental sequential dependency where token N cannot be generated until token N-1 is produced. This serial nature prevents the full parallelization possible in the prefill phase, making it inherently slower per token. The process is defined as: P(output_token | prompt, all_previous_tokens).
Memory-Bound (Bandwidth Limited)
Unlike the compute-heavy prefill phase, decoding is predominantly memory-bound. Each forward pass to generate a single token involves:
- Loading the model's weights from GPU memory (HBM).
- Loading the growing KV Cache for all previous tokens.
- Performing relatively small matrix operations. The time is dominated by the memory transfer of these large tensors, not the arithmetic itself. This is characterized by low arithmetic intensity (FLOPs per byte of memory access).
KV Cache Intensive
The Key-Value (KV) Cache is the critical state maintained during decoding. It stores the intermediate key and value vectors from the attention mechanism for all previously generated tokens, preventing their recomputation. Its size grows linearly with the batch size and sequence length, consuming significant GPU memory. Efficient management of this cache—its allocation, eviction, and memory layout—is paramount for performance. Techniques like paged attention are designed specifically to optimize KV cache usage.
Small, Frequent Kernel Launches
Each token generation requires launching a full set of GPU kernels for a forward pass, but for a very small amount of new computation (one token per sequence). This results in high kernel launch overhead relative to useful work. The small, per-token matrix multiplications often fail to fully utilize the GPU's massive parallel compute units (SMs), leading to low hardware utilization if not carefully batched. This contrasts with the large, efficient matmuls of the prefill phase.
Governed by Continuous Batching
Continuous batching (or iteration-level scheduling) is the essential optimization for this phase. It dynamically groups multiple user requests (sequences) into a single batch for each decoding step. New requests can join the active batch, and finished sequences can exit, without waiting for the entire original batch to complete. This maximizes GPU utilization and throughput by ensuring the GPU is always working on a sufficiently large batch of token generations, amortizing kernel launch and memory access overheads.
Primary Source of Inference Latency
For long generations, the time spent in the decoding phase dwarfs the initial prefill time. Latency is determined by: Total Latency = Prefill Time + (Number of Tokens * Per-Token Iteration Time). The per-token iteration time is the key metric for decoding efficiency. Furthermore, tail latency (p95, p99) is heavily influenced by variability in this phase, caused by factors like different sequence lengths in a batch leading to head-of-line blocking in naive batching schemes.
Decoding Phase vs. Prefill Phase
A technical comparison of the two primary computational stages in autoregressive transformer inference, highlighting their distinct resource constraints and optimization targets.
| Feature / Characteristic | Prefill Phase | Decoding Phase |
|---|---|---|
Primary Computational Constraint | Compute-Bound (FLOPs) | Memory-Bound (Bandwidth) |
Parallelism Granularity | Token-Level (Full prompt processed in parallel) | Batch-Level (Multiple sequences processed in parallel) |
Dominant Operation | Dense Matrix Multiplication (MatMul) | Gather & MatMul (Attention with KV Cache) |
Key-Value (KV) Cache Activity | Populated (Initial cache is created) | Read & Extended (Cache is read and appended to) |
Typical Latency Profile | High, one-time cost proportional to prompt length | Low, repeated cost per generated token |
Optimization Priority | Maximizing FLOP/s utilization | Minimizing memory bandwidth consumption |
Impact of Batch Size | Throughput increases significantly with larger batches | Throughput increases but latency per token also rises |
Common Optimization Techniques | Operator FusionTensor Parallelism | Continuous BatchingKV Cache QuantizationSpeculative Decoding |
Frequently Asked Questions
The decoding phase is the iterative, memory-bandwidth-bound stage of autoregressive inference where a model generates output tokens one at a time. This section answers common technical questions about its mechanics, bottlenecks, and optimization strategies.
The decoding phase is the sequential, token-by-token generation stage of an autoregressive language model, where each new output token is produced conditioned on the model's previous outputs and the cached key-value (KV) states from the initial prompt.
During this phase, the model performs a small, memory-bound forward pass for each token. The primary computational pattern shifts from the large, parallel matrix multiplications of the prefilling phase to repeated, smaller operations that are heavily constrained by the speed of reading the model's parameters and the growing KV cache from GPU memory. This iterative nature makes the decoding phase the dominant contributor to latency in text generation tasks.
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
The decoding phase is a core component of autoregressive generation. These related terms define the surrounding systems, bottlenecks, and optimization techniques that interact with it.
Prefilling Phase
The initial, compute-intensive stage of autoregressive inference where the model processes the entire input prompt in parallel. This single, large forward pass generates the first output token and populates the initial key-value (KV) cache. It is distinct from the memory-bandwidth-bound decoding phase that follows.
KV Cache
A memory structure that stores the computed key and value matrices from the transformer's attention layers for previously generated tokens. During the decoding phase, this cache is read and updated incrementally, avoiding redundant computation but creating a memory-bandwidth bottleneck. Efficient cache management is critical for long-context inference.
- Purpose: Enables incremental generation without re-processing past tokens.
- Challenge: Memory footprint grows linearly with batch size and sequence length.
Memory-Bound Operation
An operation whose execution time is limited by the speed of reading from or writing to memory (e.g., GPU HBM), rather than by the processor's raw computational throughput. The decoding phase is predominantly memory-bound because each step performs a small amount of computation on a large, cached state (the KV cache). Optimizations focus on improving memory access patterns and reducing data movement.
Iteration Time
The latency of a single forward pass of the model during generation. In the decoding phase, this is the time taken to generate one new token for each active sequence in the batch. It is the fundamental unit of latency for streaming outputs and is a key metric optimized by techniques like continuous batching and speculative decoding.
Speculative Decoding
An inference optimization technique that uses a smaller, faster draft model to propose a short sequence of candidate tokens. These tokens are then verified in parallel by the larger target model in a single forward pass. This reduces the number of expensive decoding steps required from the target model, directly accelerating the decoding phase.
Attention Mechanism
The core transformer component that computes a weighted sum of value vectors based on the compatibility between a query and a set of keys. During decoding, the causal attention mask ensures each token only attends to itself and previous tokens. The need to store keys and values for all prior tokens is what creates the KV cache and defines the decoding phase's memory access pattern.

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