Memory-bound decoding
How it works
Compute-kernel performance is described by the roofline model: an operation is compute-bound when its arithmetic intensity (FLOPs/byte) exceeds the hardware's ratio of peak compute to memory bandwidth, and memory-bound otherwise. In the LLM decode phase, at small batch size, each byte of weights read is paired with very few operations (matrix-vector multiply), so intensity is low and memory reads dominate. To generate one token, all model parameters plus the entire KV cache must be read from HBM; the theoretical speed ceiling is (memory bandwidth) / (bytes read per token). Hence techniques that reduce bytes read per token — weight and KV cache quantization, GQA/MQA, batching (amortizing weight reads across requests), and speculative decoding (multiple tokens per pass) — directly raise generation throughput.
Problem solved
The natural assumption that LLM inference is GPU-compute bound leads to wrong optimizations. The memory-bound decoding concept explains why, when generating one token at a time, the GPU is underutilized: matrix-vector operations have low arithmetic intensity (few FLOPs per byte read from memory), so time is dominated by moving weights and the KV cache from HBM. Understanding this steers optimization toward reducing memory traffic (quantization, batching, GQA/MQA, speculative decoding) rather than adding FLOPs.
Key mechanisms
Strengths & limitations
Components
The ratio of floating-point operations to bytes read from memory; low in the decode phase at small batch.
An analytical framework relating attainable performance to arithmetic intensity, peak compute, and hardware memory bandwidth.
The total size of weights and KV cache read from HBM to generate one token, setting the theoretical speed limit.
Implementation
Focusing on reducing floating-point operations does not speed up decode, because the bottleneck is memory bandwidth.
For long contexts, per-token KV cache reads match or exceed weight reads, further loading memory.
Evolution
Roofline provides a framework to classify kernels as compute- or memory-bound by arithmetic intensity.
LLM serving performance analyses (e.g. works on efficient transformer inference) identify memory-bound decoding as the main limit and the motivation for batching and quantization.
Hyperparameters (configurable axes)
The main lever for arithmetic intensity; a larger batch amortizes weight reads and eases the memory limit.
Weight precision (FP16/INT8/INT4) setting the bytes read per token.
Computational complexity
Time complexity: t_token >= (bajty wag + bajty KV cache) / przepustowość pamięci. Space complexity: Ruch pamieci na token = O(rozmiar wag + rozmiar KV cache).
Modern GPUs have a FLOPs-to-memory-bandwidth ratio on the order of hundreds of operations per byte, whereas decode at batch 1 reaches an intensity near ~1-2 operations per byte - hence deep compute underutilization. Moving from FP16 to INT4 weights (~4x fewer bytes per token) yields a roughly proportional several-fold generation speedup, confirming memory-traffic dominance.
Compute bottleneck
The phenomenon is by definition a memory bottleneck: low arithmetic intensity makes speed depend on memory bandwidth, not FLOPs.
Execution paradigm
Concerns the dense decode pass in which all weights are read per token.
This is a performance property of dense autoregressive generation, not a routing mechanism.
Parallelism
Batching many requests amortizes weight reads and eases the memory limit; within a single sequence generation stays sequential.
Hardware requirements
Generation speed depends on GPU memory bandwidth (HBM2e/HBM3); cards with higher bandwidth generate tokens faster regardless of spare FLOPs.
On CPUs, low RAM bandwidth makes memory-bound decoding even more severe, sharply limiting tokens per second.