Before you start: words you need#
| Word | Plain meaning |
|---|---|
| Bound | Limited by. “Memory-bound” means memory bandwidth is the resource running out. |
| Compute-bound | The arithmetic units (tensor cores, CUDA cores) are the limit. |
| Memory-bound | Moving bytes between HBM and the chip is the limit. |
| Latency-bound | Neither is saturated: the GPU is waiting on dependencies, small kernels or launches. |
| Host-bound | The GPU is idle because the CPU has not given it work yet (Python, scheduling, syncs). |
| Ridge point | Peak FLOP/s ÷ peak bandwidth; work above this intensity is compute-bound (22.b). |
| W8A8, W4A16 | Shorthand for number formats: weights in 8 bits and activations in 8; weights in 4 bits and activations in 16 (13.b). |
| Clock locking | Fixing the GPU’s clock speed with nvidia-smi -lgc so it does not change during a test. |
1. What is it?#
Sorting each piece of work, and each whole step, into one of four regimes:
COMPUTE-BOUND arithmetic units are the constraint
MEMORY-BOUND HBM bandwidth is the constraint
LATENCY-BOUND neither is saturated; the GPU waits on dependencies or tiny kernels
HOST-BOUND the GPU is idle; the CPU is the constraintLesson 6.d shows how to classify one kernel with Nsight Compute’s compute and memory throughput numbers. This lesson is about classifying a running inference system: per phase, per operating point, and sometimes without a profiler at all.
2. Why does it matter?#
Because every optimisation helps one regime and does almost nothing for the others. Applying the wrong one is the largest single source of wasted performance work.
MEMORY-BOUND helps: fewer bytes (quantize weights, 13.b; quantize KV, 13.h),
bigger batches, fusion (fewer round trips), faster HBM
does NOT help: more FLOPs, more SMs, FP8 maths without FP8 storage
COMPUTE-BOUND helps: lower-precision maths (FP8 or FP4 tensor cores), fewer FLOPs,
better tiling, a faster GPU
does NOT help: weight-only quantization (the maths stays BF16), more bandwidth
LATENCY-BOUND helps: fusion (13.j), CUDA graphs (13.k), more independent work per kernel,
more occupancy (6.c)
does NOT help: quantization, bandwidth, FLOPs
HOST-BOUND helps: CUDA graphs, removing syncs, less Python per step, async scheduling (17.d),
a dedicated CPU core (22.i)
does NOT help: anything on the GPURead the “does NOT help” lines before every optimisation project. They are the things that sound useful and are not.
3. Simple analogy#
A restaurant kitchen at dinner.
- Compute-bound: the cooks are all busy cooking. Hire cooks or simplify the menu.
- Memory-bound: the cooks wait for ingredients from the store room. A faster runner or pre-portioned ingredients help; more cooks do not.
- Latency-bound: every dish needs ten tiny steps, each waiting for the last. Cooks and runners are both half idle. Combine steps.
- Host-bound: the kitchen is fine but the waiter takes orders slowly. Nothing in the kitchen helps.
4. Tiny example: one rule of thumb, checked#
For a decode step’s weight matrices in BF16:
FLOPs = 2 × parameters × batch bytes ≈ 2 × parameters
intensity = FLOPs / bytes ≈ batch
H100 ridge point = 989 TFLOP/s ÷ 3.35 TB/s ≈ 295 FLOP/byte
→ decode weight GEMMs are memory-bound until the batch reaches roughly 300.So “decode is memory-bound” is true at batch 32 (intensity 32) and false at batch 512. Prefill of a 2,000-token prompt has intensity around 2,000 and is compute-bound. The regime depends on the operating point, not on the model.
5. Technical explanation#
Four ways to classify#
1. Arithmetic (fast, no tools). Compute FLOPs and bytes and compare intensity with the ridge point, as in section 4 and 22.b. Works for anything you can count.
2. The whole-step floor (22.b). If measured step time is within about 25% of the bandwidth floor, the step is memory-bound and done. If it is several times the floor, it is latency- or host-bound, whatever the arithmetic says.
3. The profiler. Nsight Systems first: what fraction of the step has a kernel running (22.h)? Well below 90% means host-bound or waiting. Then Nsight Compute on the top kernels: compute throughput and memory throughput as a percentage of peak (the “speed of light” section, 6.d). High memory and low compute is memory-bound; both low is latency-bound.
4. The perturbation test (no profiler). Change one resource and watch the time:
sudo nvidia-smi -lgc 1000,1000 # lock graphics (SM) clocks low, in MHz
# re-run the same benchmark
sudo nvidia-smi -rgc # resetTime grows in proportion to the clock cut → compute-bound (or latency-bound in SM work)
Time barely changes → memory-bound (HBM clock unchanged)
Time barely changes AND GPU busy is low → host-boundSome GPUs also allow locking memory clocks (nvidia-smi -lmc), which gives the opposite test.
This works on a production-like system where attaching ncu is not allowed. Locking clocks
needs administrator rights.
The LLM inference map#
OPERATION TYPICAL REGIME WHY
Prefill GEMMs (prompt > ~300) compute intensity ≈ tokens in the chunk
Prefill attention (long prompt) compute reuses each K, V for many queries
Decode GEMMs (batch < ~300, BF16) memory intensity ≈ batch
Decode GEMMs (batch > ~300, BF16) compute past the ridge
Decode attention memory each sequence reads its own KV;
intensity ≈ query heads per KV head
RMSNorm, residual, activation memory or latency ~1 FLOP per byte, tiny tensors
Sampling at small batch latency small tensors, several kernels
Batch 1 anything, small model latency or host launch overhead dominates
MoE expert GEMMs memory, usually each expert sees a small batch (14.g)The summary: LLM inference is memory-bound almost everywhere except prefill, and latency- or host-bound wherever the work per kernel is small. That one fact explains why quantization dominates decode optimisation, why batching matters so much, why HBM bandwidth sells GPUs, and why speculative decoding (12.n) works.
The format moves the crossover#
Weight-only quantization changes bytes but not maths; W8A8 changes both. The crossover batch moves accordingly (section 6 has the program):
ridge crossover batch
H100 BF16 295 295
H100 FP8 (W8A8) 591 295 ← both axes halve: crossover unchanged
H100 INT4 (W4A16) 295 74 ← bytes ÷ 4, maths still BF16With W4A16, decode GEMMs turn compute-bound at batch ~75. That is why INT4 weight-only quantization gives large speedups at small batch and much smaller ones at high batch (13.f).
The latency-bound case (the one people miss)#
Both compute and memory throughput low. Causes:
1. Too little parallelism a small batch gives a few thread blocks for 132 SMs
2. Dependency chains each step waits for the previous one
3. Launch overhead a 3 µs kernel with 4 µs of launch work around it
4. Synchronisation barriers, or waiting on another stream or GPUSmall decode kernels at batch 1 are often latency-bound rather than memory-bound. That is why CUDA graphs and fusion help there more than quantization does.
6. Under the hood: crossovers and step time#
// regime.go: at which batch size does a decode weight GEMM stop being
// memory-bound? Depends on the GPU and on the number format.
package main
import "fmt"
type gpu struct {
name string
bf16, fp8, bw float64 // dense TFLOP/s, dense TFLOP/s, TB/s
}
type format struct {
name string
bytesPerParam float64
fp8Math bool // true: tensor cores run in FP8; false: BF16 math
}
func main() {
gpus := []gpu{{"H100 SXM", 989, 1979, 3.35}, {"B200", 2250, 4500, 8.0}}
formats := []format{
{"BF16 weights, BF16 math", 2, false},
{"FP8 weights, FP8 math (W8A8)", 1, true},
{"INT4 weights, BF16 math (W4A16)", 0.5, false},
}
fmt.Printf("%-9s %-33s %6s %8s\n", "GPU", "format", "ridge", "B_cross")
for _, g := range gpus {
for _, f := range formats {
peak := g.bf16
if f.fp8Math {
peak = g.fp8
}
ridge := peak / g.bw // FLOP per byte
// intensity of a decode GEMM = 2*B FLOPs per param / bytesPerParam
cross := ridge * f.bytesPerParam / 2
fmt.Printf("%-9s %-33s %6.0f %8.0f\n", g.name, f.name, ridge, cross)
}
}
// Step time for the weight GEMMs of an 8B model on an H100, BF16.
const params, bytesPer = 7.5e9, 2.0
fmt.Printf("\n8B model, BF16, H100: weight-GEMM time per decode step\n")
fmt.Printf("%6s %9s %9s %8s %11s\n", "batch", "mem ms", "math ms", "bound", "tok/s")
for _, b := range []float64{1, 8, 32, 128, 256, 512, 1024} {
mem := params * bytesPer / 3.35e12 * 1e3
math := 2 * params * b / 989e12 * 1e3
t, bound := mem, "memory"
if math > mem {
t, bound = math, "compute"
}
fmt.Printf("%6.0f %9.2f %9.2f %8s %11.0f\n", b, mem, math, bound, b/t*1e3)
}
}Output:
GPU format ridge B_cross
H100 SXM BF16 weights, BF16 math 295 295
H100 SXM FP8 weights, FP8 math (W8A8) 591 295
H100 SXM INT4 weights, BF16 math (W4A16) 295 74
B200 BF16 weights, BF16 math 281 281
B200 FP8 weights, FP8 math (W8A8) 562 281
B200 INT4 weights, BF16 math (W4A16) 281 70
8B model, BF16, H100: weight-GEMM time per decode step
batch mem ms math ms bound tok/s
1 4.48 0.02 memory 223
8 4.48 0.12 memory 1787
32 4.48 0.49 memory 7147
128 4.48 1.94 memory 28587
256 4.48 3.88 memory 57173
512 4.48 7.77 compute 65933
1024 4.48 15.53 compute 65933Two things to notice:
- While memory-bound, step time is flat: batch 1 and batch 256 cost the same 4.48 ms, so throughput grows almost linearly with batch. Past the crossover, throughput stops growing.
- This counts only the weight GEMMs. The KV cache read grows with batch × context and is always memory-bound, so real systems hit a memory limit (KV capacity, 12.f) or a bandwidth limit long before the 66k tok/s this program suggests.
7. Performance implications#
- Classify at your actual operating point. The same deployment can be memory-bound at night (batch 8) and close to compute-bound at peak (batch 300). The right optimisation differs.
- Prefill and decode want different hardware. Prefill is compute-bound, decode bandwidth-bound. This is the physical reason for disaggregated prefill and decode (14.j).
- Weight-only quantization wins at low batch. W4A16 helps a lot at batch 8 and little at batch 256, where the maths takes over.
- Long context shifts decode toward KV bandwidth. At 32k tokens per sequence, KV reads dominate and weight quantization alone helps little; KV quantization (13.h) and attention variants (12.g) matter more.
8. Production implications#
- Classify before optimising. Two numbers or one clock test, ten minutes.
- Track memory-interface activity for decode-heavy fleets. DCGM’s DRAM activity metric (22.d) near 0.6–0.9 is healthy for decode. A drop with unchanged traffic means a regression.
- “Both low” means look at the CPU and the timeline, not the kernels.
- Reject proposals that do not match the regime. “We cut FLOPs 40%” for memory-bound decode is worth nothing; say so.
9. Common mistakes#
- Assuming memory-bound because “decode is memory-bound”. Usually true at the kernel level, but a whole step can be latency- or host-bound, and the fixes are completely different.
- Optimising FLOPs for memory-bound work.
- Expecting more bandwidth to help compute-bound prefill.
- Not recognising the latency-bound and host-bound cases.
- Classifying once and never rechecking as batch size and context length change.
- Using a whole-model average. Classify per phase and per kernel group.
10. Hands-on exercise#
- Run
regime.go. Add an “FP4 weights, FP4 maths” row for B200 (dense FP4 roughly 9,000 TFLOP/s, 0.5 bytes per weight). Where is the crossover? - Add a KV term to the step-time loop: 128 KiB per token (12.f), 2,048 tokens per sequence. At what batch does KV reading cost more than the weights?
- The clock test. Lock SM clocks low and re-run a decode benchmark at batch 8 and a prefill benchmark with 4,000-token prompts. Which slows down in proportion to the clock?
- Watch the regime change. For your engine’s main decode GEMM, measure step time at batch 1, 8, 32, 128, 512. Where does the time start to grow? Compare with the computed crossover.
- Build a latency-bound case. Add a per-step
.item()to a decode loop. Confirm with Nsight Systems that the GPU sits idle and with the clock test that SM clocks do not matter.
11. Interview questions#
- How do you tell whether an inference workload is memory-, compute-, latency- or host-bound?
- Name three optimisations that help memory-bound decode and two that do not.
- At what batch does BF16 decode on an H100 become compute-bound? Show the arithmetic.
- Why does W4A16 quantization help a lot at batch 8 and much less at batch 256?
- How would you classify a workload without a profiler?
- Both compute and memory throughput are low. What does that mean, and where do you look next?
12. Further reading#
Checked on 12 November 2026.
- Nsight Compute Profiling Guide: the speed-of-light section and warp stall reasons.
- nvidia-smi documentation:
-lgc,-lmcand-rgc. - V. Volkov, “Better Performance at Lower Occupancy” (GTC 2010): the latency-bound case.
- Lessons 6.a and 6.d (one kernel), 22.b (the whole step), 13.b (quantization by regime).