Unit 3 of 12 · about 5 hours · derive, measure

Compute, bandwidth, launch, capacity and queue-bound regimes

Regime classification is the prediction half of this section's checkpoint. Every later claim about a stall or a speedup is checked against the regime you declared first.

You'll be able to

  • Derive arithmetic intensity for a matmul and place prefill and decode work on a roofline for your GPU.
  • Explain the compute, bandwidth, launch, capacity and queue-bound regimes and how batching moves each boundary.
  • Predict the bottleneck for short and long prompts with small and large batches before profiling.

Covers

Compute-bound, bandwidth-bound and launch-bound regimesCapacity-bound and queue-bound regimesArithmetic intensity and roofline position
1

Read

In this order, only the parts listed

0 of 4 done

  1. Roofline and arithmetic intensity, recomputedHands-On LLM Serving and Optimization - Chapter 5 and the Chapter 4 metrics section

    Boundaries of GPU Compute and Memory Bandwidth (pp. 178 to 180), Arithmetic Intensity in Matrix Multiplications (pp. 181 to 183) and Applying Arithmetic Intensity Analysis to the LLM Prefill and Decode Phases (pp. 183 to 185)

    Recompute Table 5-9 and Table 5-10 with the parenthesized formula . The printed formula omits the parentheses and its last denominator term is wrong: at the correct prefill values are about 62 and 410 for and , and the correct decode value is about 1.0, not 0.5. The verdicts are unchanged.

  2. Cost, MFU and the latency trade-offEfficiently Scaling Transformer Inference

    Section 2.1 (p. 3) and Section 4.4 with Tables 2 and 3 (pp. 9 to 10): small batches give low latency at worse MFU and higher cost, and the low-latency versus high-throughput configurations

  3. Small batches and the launch floorAI Systems Performance Engineering - Chapter 16, profiling and debugging inference

    Inference Troubleshooting Recipes with Table 16-1 (pp. 973 to 978): the below-50-percent-SM-utilization small-batch row, which prescribes larger batches and fused kernels before reaching for the profiler

  4. The saturation kneeTime to First Token - Measurement and Load-Testing Sessions

    Week 5: the concurrency sweep at 1, 2 and 4 up to 128, and the knee where throughput saturates while latency degrades

2

Focus on

  • Arithmetic intensity is FLOPs per byte moved. The ridge is peak FLOPs per second divided by peak bytes per second, and work below it is bandwidth-bound.
  • Prefill intensity grows with sequence length while decode intensity stays near 1 FLOP per byte at any length. At very small shapes time stops falling with bytes: that flat floor is the launch-bound regime.
  • Batching raises intensity by reusing each weight load across requests, which moves the bandwidth boundary but never removes the sequential decode chain.
  • Capacity-bound means the KV cache does not fit, so the batch or the lengths must shrink. Queue-bound means waiting requests grow while the device stays busy. Diagnose both from KV-cache usage and waiting counts, not from kernel timings or memory used.
Common mistakes · 3
  • Quoting the book's Table 5-10 decode value of 0.5. The printed denominator is wrong and the correct value is about 1.0. Both sit far below any GPU ridge, so the verdict stands but the number does not.
  • Comparing intensities across precisions or tokenizers without restating units. Bytes per element and tokens per request change the numbers, so a ratio without its setup is not comparable.
  • Naming a regime from memory used. vLLM preallocates its KV pool, so read vllm:kv_cache_usage_perc: near full with preemptions is capacity-bound, a busy device with a growing queue is queue-bound, and an idle device with a growing queue points at admission limits or host overhead.
3

Try it yourself

Closed-book, before checking anything

Closed-book, derive for a matmul, evaluate it for and at and , and place both points against your GPU's ridge and against 419 FLOPs per byte, the book's L40S example.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.What are the units of arithmetic intensity and of the roofline ridge?Answer

    FLOPs per byte for intensity. The ridge is peak FLOPs per second divided by peak bytes per second, also FLOPs per byte.

  2. 2.At on the book's L40S ridge of 419, which corrected Table 5-10 prefill values are compute-bound?Answer

    Only at about 1365. The corrected 62 at and 410 at are still bandwidth-bound, as is decode at about 1.0.

  3. 3.Why does batching move the bandwidth boundary?Answer

    One weight load serves tokens instead of one, so FLOPs per byte rise with while the sequential steps per request stay fixed.

  4. 4.How do you tell capacity-bound from queue-bound without a profiler?Answer

    Capacity-bound shows KV-cache usage near full with preemptions or a capped running batch. Queue-bound shows waiting requests growing while the device stays busy. Check vllm:kv_cache_usage_perc and vllm:num_requests_waiting.

5

Practice

  • 100 Days of Inference Day 06: Ops-Byte Ratio and Roofline

    Run the roofline plot and the attention arithmetic-intensity cells for your GPU; reproduce the , example at about 31 ops per byte and sweep batch size to the compute-bound crossover

    The notebook's attention accounting follows its book's model. Check it against your matmul derivation rather than treating it as a measured result.

You're done when

Your hand-derived intensities match the corrected table values, and your roofline plot puts prefill and decode on opposite sides of the ridge for a long prompt.

Only when you can do this without notes.

Leads to

Notes

Resources · 4 for this unit, 8 more in the section

Also in this section

  • AI Systems Performance Engineering companion code - Chapter 16Chris Fregly · required

    Begin with inference_profiling.py, inference_server_load_test.py, monitoring_bundle.py and runtime scheduler instrumentation. Run only hardware-compatible targets, retain raw artifacts and re-measure all bundled expectations on your own device.

  • vLLM Metrics Design and Production MetricsvLLM Project · required

    Map scheduler and cache events to exported request, queue, TTFT, inter-token and generation metrics. The link is pinned to v0.31.0; check the definitions against the version you install.

  • vLLM Benchmark CLI (v0.31.0)vLLM Project · required

    Use vllm bench latency, vllm bench throughput and vllm bench serve for phase and endpoint baselines. Fix the dataset, lengths, request rate, warmup and sampling, and keep the raw per-request results.

  • TensorRT-LLM Benchmarking GuideNVIDIA · support

    Use Before Benchmarking and Online Serving Benchmarking as a reproducibility checklist. Borrow environment capture and startup metrics even if TensorRT-LLM is not the selected engine.

  • LLM Inference Systems Laboratory - InstrumentationRoadmap-Final · support

    Complete Milestone B: correlate request, iteration, KV, scheduler, kernel and resource events, quantify observer overhead, and retain raw arrival and completion records.

  • Taming Throughput-Latency Tradeoff in LLM Inference with Sarathi-ServeAgrawal et al. · support

    Read arXiv v3, Chunked-prefills and Stall-free batching for the chunked-prefill vocabulary and the prefill-decode interference argument, and Overhead of chunked-prefills for the cost of splitting. Treat the reported capacity gains as the paper's result on its hardware.

  • py-spy - sampling profiler for PythonBen Frederick · support

    Use py-spy record to take CPU flame graphs of tokenizer and detokenizer work, and py-spy top to watch the hot functions live. Launch the profiled process under py-spy.

  • vLLM SamplingParams API (v0.31.0)vLLM Project · reference

    Look up temperature, seed, max_tokens, ignore_eos, stop and stop_token_ids defaults when you fix the output contract. The link is pinned to v0.31.0; check the fields against the version you install.