05.01 · Concept · Free
Two Ways to Go Faster
State the framing the rest of the module hangs on: decode is bandwidth-bound, so every real optimisation either shrinks the bytes read per step or reduces the number of steps. Classify a proposed optimisation as one or the other.
Curated for this lesson
Fewer Bytes, Fewer Steps
Two Ways to Go Faster
The speaker discusses attention optimisations, saying local/sliding-window attention avoids the full 'n by n attention' and that sharing key/value projections is used because 'when you decode... the keys and the values, they're going to come up a lot' and a smaller KV cache 'allows you to save a little bit of space, a little bit of memory.'
Autoregressive decode is usually limited by memory bandwidth, not arithmetic, so speedups fall into two buckets: read fewer bytes on each accepted token, or need fewer target-model steps per accepted token. That framing separates quantisation, KV-cache and attention-kernel work from speculative or multi-token decoding schemes.
What this lesson answers
- why is LLM decode bandwidth bound
- fewer bytes versus fewer steps inference optimisation
- how to classify speculative decoding optimisation
Notes
In autoregressive decode, the mechanism to optimize is the per-token recurrence : every emitted token normally requires one forward pass that rereads model weights and attends over the accumulated KV cache. The useful framing is therefore , with ; for large-batch prefill the max often selects compute, but for single-token decode of large models it usually selects bandwidth. The rest of the module hangs on the dichotomy: an optimization either lowers per accepted token, or lowers per accepted token. Quantization, tensor parallel layout, KV-cache compression, MQA/GQA, FlashAttention-style IO-aware kernels, and PagedAttention-style cache management are “fewer bytes.” Speculative decoding, Medusa-style heads, and EAGLE are “fewer steps,” because they try to accept multiple future tokens after one expensive target-model verification.
A concrete bandwidth calculation makes the framing less slogan-like. A 70B parameter model in FP16 has about GB of weights, ignoring small metadata and non-parameter reads. On an 80GB H100 with peak HBM bandwidth around TB/s, a single decode step that must stream all weights has a lower bound s, or about tokens/s before KV traffic, synchronization, kernel overhead, and imperfect bandwidth utilization. KV reads are smaller but not free: with layers, KV heads, head dimension , FP16 elements, and context , reading K and V for one new token costs bytes, about GB, or another ms at peak HBM. That is why shrinking weights from FP16 to INT4 is a first-order decode optimization, while shaving a few TFLOPs from an MLP is not first-order unless batch size or arithmetic intensity moves the step out of the bandwidth regime.
“Fewer bytes” techniques attack different terms in . Weight-only quantization reduces the weight stream roughly from bytes to bytes plus scales; for the same 70B model, ideal 4-bit weights are GB, giving a bandwidth lower bound ms, or tokens/s before overhead. Grouped-query attention, introduced as a practical compromise after multi-query attention, reduces KV cache bytes by replacing many query heads with fewer KV heads; the example above uses 8 KV heads rather than, say, 64, an reduction in the attention-cache stream. FlashAttention, from Dao et al.’s IO-aware exact attention paper and later FlashAttention-2/3, is a fewer-bytes optimization for prefill and attention kernels because it avoids materializing the attention matrix and improves SRAM/HBM traffic. PagedAttention, introduced by vLLM in the SOSP 2023 paper “Efficient Memory Management for Large Language Model Serving with PagedAttention,” is also fewer bytes in practice: it prevents cache fragmentation and copying by mapping logical token blocks to physical pages, increasing effective batching without moving KV tensors around.
“Fewer steps” techniques change rather than the per-step byte count. In speculative decoding, from Leviathan et al. and Chen et al. in 2023, a cheap draft model proposes tokens, the expensive target model verifies them in one parallel pass, and the sampler accepts a prefix with the exact target distribution; if the expected accepted tokens per target call is , the target-model step count falls from to about . If a 70B target at the FP16 lower bound above costs ms per call and a 7B draft costs roughly GB TB/s ms per generated draft token, then drafting tokens costs about ms and one target verification costs ms. With expected accepted length , the cost per output token is ms, or tokens/s, versus tokens/s for target-only. EAGLE, from the 2024 “Extrapolation Algorithm for Greater Language-model Efficiency” line of work, improves the draft side by predicting in feature space rather than just token space, so its classification is still fewer steps: it is valuable only insofar as it raises or lowers draft cost.
The two classes fail in different, concrete regimes. Fewer-bytes methods stop helping when the bottleneck stops being HBM reads: large batch decode can raise arithmetic intensity enough that GEMMs become compute- or scheduler-limited, and then INT4 weights may be constrained by dequantization, tensor-core shape support, or collective communication rather than raw bytes. Overcompressing also makes quality or acceptance worse: aggressive KV quantization can perturb attention logits on long contexts, and a 4-bit target may reject more speculative tokens if it changes the distribution used by the serving contract. Fewer-steps methods become negative when , equivalently . In the numeric example, , so speculative decoding must accept more than tokens per target verification merely to break even; on high-temperature sampling, code with brittle next-token dependencies, tool-call JSON, or a draft model poorly matched to the target, can fall below that and throughput drops.
The named inference systems are mostly combinations of this taxonomy rather than exceptions to it. vLLM’s PagedAttention is the canonical cache-management fewer-bytes system, while SGLang builds serving-level speedups around RadixAttention prefix reuse, constrained decoding, and speculative paths, so a proposed SGLang optimization should be classified by whether it avoids rereading KV/prefix bytes or avoids target decode steps. TensorRT-LLM packages fewer-bytes kernels and formats such as weight-only quantization, FP8, paged KV cache and fused attention, and also implements speculative decoding and in-flight batching. NVIDIA Dynamo, announced as a disaggregated generative-AI inference serving stack, and llm-d, the Kubernetes-native distributed LLM inference project, move the same primitives into cluster scheduling: prefix/KV routing and cache-aware placement are fewer bytes over the network and HBM, while speculative workers or disaggregated draft/verify pipelines are fewer steps. When evaluating any new paper, kernel, or release note, the operational question is not whether it “accelerates LLMs,” but which side of it reduces, and under what workload that product is still the limiter.
Common questions
- Why is single-token LLM decode often bandwidth-bound?
- Each new token normally requires a forward pass that streams the model weights and attends over the growing KV cache. For large models at small batch sizes, the hardware spends more time moving those bytes from memory than doing the arithmetic. That makes memory traffic the first thing to inspect when judging decode latency.
- What counts as a fewer-bytes optimisation?
- A fewer-bytes optimisation reduces the data read or moved for a decode step. Weight quantisation, KV-cache compression, grouped-query or multi-query attention, IO-aware attention kernels, and paged cache management all fit here. They help most when HBM reads, cache traffic, or avoidable tensor movement dominate the step.
- What counts as a fewer-steps optimisation?
- A fewer-steps optimisation reduces expensive target-model calls per accepted output token. Speculative decoding, auxiliary decoding heads, and feature-space draft methods all try to propose or verify multiple future tokens around one target pass. They only help when enough proposed tokens are accepted to repay the draft and verification overhead.
Short definition: what is Two Ways to Go Faster?
