Skip to content

Performance you can defend: benchmarks, MFU, SLOs

40 min read

Prerequisites: Correctness: parity gates and numerical checks

A performance number is a claim about a workload, a machine, a software stack and a measurement method, compressed into one figure. When any of the four is missing, the number cannot be checked, and two numbers that differ in any of them cannot be compared. The earlier chapters each measured something: chapter 2 estimated a matmul before timing it, chapter 7 watched per-step latency settle after compilation, chapter 10 read where a step's time went, chapters 14 and 16 turned throughput into MFU, chapters 17 and 18 measured TTFT and TPOT against a floor, and chapter 21 read latency percentiles against an SLO. This chapter pulls those checks into one method of evidence: what a defensible number has to state, how to exclude compilation and find the steady state, how to report training and serving metrics with their conventions, how to compare a number with its roofline and two configurations with each other, and how to read a published claim. It assumes chapter 23's parity gate has passed: a faster run that computes something else is not a speedup.

What this chapter covers

  • The seven elements that make a performance number defensible: workload, hardware and topology, software versions, warm-up and compile exclusion, steady-state window, repetitions and units.
  • Training metrics (step time, tokens per second per chip or per device, MFU) and the FLOP conventions behind MFU.
  • Serving metrics as the llm-d and vLLM-TorchTPU harnesses define them: TTFT and TPOT percentiles, throughput at an SLO, goodput and cost per token.
  • Measurements against their roofline floor, and repeated runs that separate a real speedup from noise.
  • A checklist for published performance claims, and a benchmark report in which every field records where its value came from.

What makes a number defensible

A number is defensible when a reader who doubts it can find out exactly what was run and repeat it. Seven things have to be stated. The table gives each one, what goes wrong without it, and a published example that does it well.

Element What to state What goes wrong without it Published example
Workload Model and size, the step's scope (forward only, or forward, loss, backward and optimizer), batch and sequence, dtype policy; for serving, input and output lengths (ISL and OSL), the length spread, concurrency or request rate, prefix caching on or off Two "throughputs" of different work are compared The FLUX case study's shape (batch_size=2, sequence 32,768, bf16) and its kernel block sizes; the vLLM-TorchTPU client's --random-input-len, --random-output-len, --random-range-ratio, --max-concurrency, --ignore-eos, --seed
Hardware and topology Generation, chip count, devices per chip, slice topology Per-chip and per-device rates differ by 2x on v7x The Qwen3 235B table: chips, TensorCores and slices per row
Software PyTorch, TorchTPU, framework and kernel versions; the flags; the build type The next release changes the number and nobody can tell why FLUX: "Python 3.14, PyTorch 2.15 (pre-release), JAX 0.12, einops 0.8.2, and TorchTPU built from source"
Warm-up and compile exclusion Which steps were dropped and by what rule Compilation is averaged into the steady rate perflab: warm up until the compile count stops changing
Steady-state window How many steps were timed, how each was timed (synchronization), what else ran (profiler, GC) A short or disturbed window reports noise as signal FLUX: 10 timed steps with the profiler disabled; perflab: 10 post-warm-up steps with GC disabled
Repetitions and variance Independent runs, and the spread across them A 3% "improvement" inside run-to-run noise vLLM-TorchTPU's Spec-Bench mode: SPEC_WARMUP_PROMPTS (20) and SPEC_REPS (2) measured passes per cell
Units and conventions Per chip or per device, tokens or samples, mean or median, which percentile, which FLOP count Ratios off by constant factors Chapter 16's reproduction of every MFU figure on two conventions

The TorchTitan TPU optimization guide adds one more line to the software row, for anyone who builds TorchTPU: build wheels with optimizations on (-c opt for a Bazel build), because "a fastbuild wheel can have dramatically slower eager dispatch and will silently ruin every measurement".

A reference harness: TorchTPU's perflab

TorchTPU's own benchmark harness, perflab (torch_tpu/perflab/measure.py), is the clearest published statement of how to time a step, and every rule in it answers one of the rows above.

  • Warm-up ends when compilation does. perflab runs warm-up steps, reading the device's cumulative compile count after each, and stops at the first step whose count equals the previous step's, no earlier than min_warmup_steps (default 10) and no later than max_warmup_steps (default 20). If the counts never settle it raises "Benchmark function compilations have not stabilized", rather than timing a compiling program.
  • The first step's time and the warm-up overhead are reported, not discarded. first_step_time_seconds and warmup_overhead_seconds ("(wall time of n steps) - (wall time of 1 warm step) * n", with the last warm-up step as the warm step) are outputs of their own. Compile time is a real cost; it belongs in its own field, not in the steady rate.
  • The steady window must not compile. It times post_warmup_steps (default 10) steps and raises PostWarmupRecompileError if the compile count moves.
  • Nothing else runs in the window. Cyclic garbage collection is disabled around each loop ("Cyclic collection landing mid-loop adds a latency spike to measurements"), and the wall time spent only on profiling is subtracted "so that runs with and without xprof report comparable wall times".
  • Wall time and device time are separate. Each timed step waits for its result (await_result) before the clock stops; when profiled steps are available, perflab also reports the average device time per step and computes MFU from both.

Read left to right. An orange dashed container labelled Excluded holds three blocks in a row: an amber block Build and load, an orange block Compile steps and a grey block Settling steps. A green dashed container labelled Timed holds a green block Steady window and a blue block Repeat runs. To the right of both containers stands a teal block Report percentiles. Arrows run left to right between consecutive blocks, labelled first call, count flat, timer starts, n steps and per-run stats. Beneath the blocks a thin navy step-time trace starts high under Compile steps, falls steeply and then gently under Settling steps, and runs flat and low under Steady window and Repeat runs.

Follow the trace under the blocks: the number you report is read only where it is flat. The boundary between the two containers is a rule (the compile count stops changing), not a guess, and repeats are separate runs, because steps within one run share whatever made that run fast or slow.

Two ways to time a step

Published benchmarks time steps in two ways, and the choice changes what the number means.

Synchronize every step. The Muse Glimmer training example wraps each step in time.perf_counter() and calls torch.accelerator.synchronize() before stopping the clock; so does the inference case study for each decode step, and so does perflab. You get a distribution of step times, which is what you need for percentiles and for spotting a compile. The cost: TPU execution is asynchronous, and a sync per step stops the host from dispatching the next step while the device runs this one, so the per-step time includes a host round trip the production loop may hide.

Dispatch back to back and synchronize once. The FLUX case study runs 3 warm-up steps and then 10 timed steps "dispatched back to back", with one torch.accelerator.synchronize() after the last, and reports total time over steps; chapter 2's matmul timing and run_single_trace_training_step in the TorchTitan sample code do the same. You get a throughput that includes overlap of host and device, but only a mean: no percentiles, and a compile inside the window is invisible.

Use the first for latency and for finding the steady state, the second for a throughput figure once you know the window is clean. Never time without a sync at all: the host then measures only how long it took to queue the work.

The companion's steady_state(times, warmup) turns per-step times into the numbers a report needs. It drops the warm-up, returns n, mean, sample standard deviation, nearest-rank p50, p90 and p99 (chapter 21's percentile, reused), and refuses a window with no steps:

from bench import steady_state, time_steps

times = time_steps(lambda: step(batch), steps=60, sync=torch.accelerator.synchronize)
st = steady_state(times, warmup=10)   # ValueError if warmup >= len(times)
st["p50"], st["p90"], st["p99"], st["mean"], st["std"], st["n"]

Compilation: the largest distortion

On a TPU, the first call of a compiled program compiles it, and the difference between that call and the next is three to four orders of magnitude. A stopwatch around the whole run measures a different workload from the one in the title. The two Muse Glimmer 30B case studies show how large the error gets.

Two panels under the title A stopwatch that includes compiling steps reports a different workload. Left, Training: Muse Glimmer 30B, 4 v7x chips, 5-step log. Blue dots show each step's own rate from the README log: 797 tokens per second per rank at step 0, then 2,404, 2,381, 2,395 and 2,399. A green dashed line marks the steady state over steps 1 to 4 at 2,395 tokens per second. An orange line shows the stopwatch over steps 0 to k: 797, 1,197, 1,435, 1,595 and 1,709, with an arrow at the last point labelled 5 steps: minus 29%. Right, Decode: Muse Glimmer 30B, one v7x chip, batch 1, on a log scale from 0.02 to 200 tokens per second. A green dashed line marks the steady state over steps 2 to 20 at 42.4 tokens per second (23.58 ms). An amber line, stopwatch from decode step 1, rises to 0.99 at 20 tokens; an orange line, stopwatch from the prompt (prefill), rises to 0.49 at 20 tokens.

The orange lines are what a stopwatch reports, the green lines what the hardware sustains. In training the gap closes slowly as steps accumulate; in decode, 20 tokens are not nearly enough to dilute two compiles, and the stopwatch is wrong by a factor of 87.

Training. The Muse Glimmer example's README prints five steps: "Run 0: 51.387 seconds, 797.09 TPS (per rank)", then 17.040, 17.202, 17.101 and 17.073 s. Run 0 "is when torch.compile does the compilation work". Each rank processes \(8 \times 5{,}120 = 40{,}960\) tokens per step, so the steady rate over runs 1 to 4 is \(40{,}960 / 17.104 = 2{,}395\) tokens per second per rank. A stopwatch over all five steps gives \(5 \times 40{,}960 / 119.803 = 1{,}709\), 29% low, and an MFU of 23.6% instead of 33.0%. perflab would not have stopped there: its rule ends warm-up at the first step whose compile count equals the previous step's, but no earlier than min_warmup_steps, default 10, so with its defaults all five logged steps would still be warm-up and nothing would yet be timed. Only with min_warmup_steps set to 1 would warm-up end at run 1 (if, as the README says, only run 0 compiles), with perflab's overhead formula giving \(51.387 + 17.040 - 2 \times 17.040 = 34.3\) s.

Decode. The inference case study's StaticCache run compiles twice: prefill (21,024.81 ms, for the 7-token prompt) and decode step 1 (19,756.86 ms, for seq_len = 1). From step 2 every token takes about 23.6 ms. The steady rate is \(1{,}000 / 23.58 = 42.4\) tokens per second for the one user; 20 tokens timed from the prompt give \(20 / 41.2 \text{ s} = 0.49\). The case study's own table reports this correctly: it averages steps 2 to 20 and labels the average "(no warmup)".

Settling steps are not compile steps

After the compiling calls, the decode steps still drift down: steps 2 and 3 take 24.66 and 24.29 ms, and from step 4 they sit between 23.34 and 23.69 ms (chapter 22 noticed the same). Whether those two steps are in the window changes some statistics and not others:

$ python code/ch24_evidence/bench.py --cpu-smoke   (excerpt)
2. Muse Glimmer 30B decode, StaticCache, 20 steps (ms per token, batch 1)
   warmup=1: n=19  p50 23.43  p90 24.29  p99 24.66  mean 23.58  std 0.333 ms  (cv 1.41%)
   warmup=3: n=17  p50 23.43  p90 23.59  p99 23.69  mean 23.47  std 0.092 ms  (cv 0.39%)

The median does not move. The mean moves by 0.5%, the standard deviation by a factor of 3.6, and the p99 is simply the slowest step in the window. Two lessons follow. Report the median for a step time, because it is the statistic least sensitive to where you drew the boundary. And never read a p99 from a short window: with nearest-rank percentiles, the p99 of 19 values is the maximum, and the p90 is the 18th of 19.

Cold caches

Compilation is not the only first-run cost. The inference case study loads its checkpoint in "between ~100 s and ~420 s in our runs, depending on storage read throughput", and a rerun with unchanged code loads prefill and step 1 from PyTorch's on-disk AOTAutogradCache "instead of recompiling; decode times per token are unchanged". To measure cold start on purpose, it resets with torch._dynamo.reset() and clears the AOTAutogradCache first. Chapter 7 added the exception: bounded-dynamic executables are not serialized to that cache and compile again in every new process. So "first request after deploy" and "first request after restart with a warm cache" are two different measurements, and both differ from steady state. Report the one your users meet, and name it.

Serving harnesses handle warm-up explicitly. vLLM-TorchTPU's run_benchmarks.sh can run "discarded full-traffic warmup passes" (BENCHMARK_WARMUP_RUNS, default 0: set it); its Spec-Bench mode runs 20 warm-up prompts per cell before its measured passes. A serving engine also compiles its token buckets at startup (chapter 18), which is why a server's first requests after a restart can be slow even with warm-up passes in the benchmark.

Training metrics: step time, tokens per second, MFU

Step time is the primary measurement; everything else is derived from it. State what the step contains. The Muse Glimmer example's step is forward, the chunked fused LM head and loss, backward, an all-reduce of the replicated parameters' gradients, the AdamW step and zero_grad, on random tokens already on the device: no data loading.

Tokens per second is tokens per step over the mean steady step time, because a rate over a window is total work over total time. Say whose tokens: the example's worker prints "Local TPS" from rank 0, which is per device; the announcement post quotes "TPS per TPU", per chip; the Qwen3 235B table quotes "TPS per TensorCore". On v7x, per chip is twice per device.

MFU is model FLOPs per second over peak FLOPs per second. Both halves carry a convention.

Convention What it counts Where it is used Effect
\(6N\) 6 FLOPs per matmul parameter per token; embedding table excluded; no attention, no recompute The TorchTPU announcement post (it reproduces every Muse Glimmer figure, chapter 16); mfu() in code/ch16_case_study/mfu.py Lowest of the three for long sequences
\(6N\) + attention Adds \(6\, n_\text{heads} (d_{qk} + d_v)\) per attended token per layer, windowed layers counting only their window; no causal discount TorchTitan's logged MFU; compute_mfu in the TorchTitan sample code About 2 to 4 points higher for Muse Glimmer (chapter 16)
Counted ops torch.utils.flop_counter.FlopCounterMode on one eager step of a CPU fake copy: matmuls, convolutions and SDPA, forward and backward; elementwise ops, norms and the optimizer count zero; "the attention formula ignores causal masking"; ops with no formula, "e.g. _grouped_mm", count zero TorchTPU perflab (perflab/flops.py) Counts every matmul it sees, attention included; an MoE's grouped matmuls disappear and its MFU reads far too low

Hardware FLOPs utilization is a fourth number, not a convention of MFU: it counts the recomputed forward of activation checkpointing as work, so it is higher than MFU whenever checkpointing is on. MFU deliberately does not credit recompute; chapter 16 showed the Muse Glimmer example executing 50.8% of peak in matmul work at a published 38% MFU.

The peak needs the same care. A v7x chip's bf16 peak is 2,307 TFLOP/s and a device's 1,153.5. perflab computes MFU twice, from wall-clock step time and from device time (device_mfu), and warns when either exceeds 1: "the FLOPs or the step time are wrong". An MFU above 100% is the cheapest bug detector you have; one around 200% is almost always a per-chip rate against a per-device peak in the wrong direction.

For the Muse Glimmer README log, with chapter 16's \(N = 26{,}509{,}949{,}440\):

\[ \text{MFU} = \frac{2{,}394.8 \times 6 \times 26.51 \times 10^9}{1{,}153.5 \times 10^{12}} = 33.0\% \text{ per device} \]

and per chip, \(4{,}789.6\) tokens per second against 2,307 TFLOP/s, the same 33.0%. The case study's text gives "2400 to 2800 TPS per rank", and the announcement post's 38% comes from the top of that range (chapter 16). The log in the same repository sits at the bottom.

Serving metrics: latency percentiles, throughput at an SLO, goodput, cost

Latency

Every llm-d benchmark harness except lm-eval (which measures accuracy) records the same five: TTFT, the time to the first output token, which contains queueing and prefill; ITL, the gap between consecutive output tokens; TPOT, the time per output token after the first, an average of the ITLs of one request; end-to-end latency; and throughput. Chapter 17 derived what bounds each: prefill is usually compute-bound, decode memory-bound, and the batch trades one user's TPOT against everyone's throughput.

Latency is a distribution, and an SLO is a percentile of it. The figure shows why the mean is the wrong summary.

Two panels under the title Illustrative: latency percentiles against an SLO. Left, One run: mean and median inside the SLO, p90 outside: a histogram of time to first token for 200 synthetic requests, most between 250 and 2,000 ms and a second group between 4,000 and 9,000 ms. Vertical lines mark p50 993 ms in blue, mean 1,766 ms in purple, a dashed SLO line at 3,000 ms labelled SLO: P90 under 3,000 ms, p90 5,363 ms in orange and p99 8,527 ms in dotted orange. Right, Read the percentile where the CDF crosses 0.9: cumulative distributions of a healthy run and a run with a queueing tail, a grey line at 0.9 and the dashed SLO line at 3,000 ms; the healthy run crosses 0.9 at p90 1,710 ms, left of the SLO, the run with a tail at p90 5,363 ms, right of it. A footnote says the data are synthetic fixtures from chapter 21, not a measurement.

Synthetic data, chosen to show the shape. The 15% of requests that queued for seconds barely move the median and move the mean less than the SLO's headroom; the p90 lands among them. A report that gives only the mean says this run meets a 3 s SLO, and it does not.

Three rules follow. Report the percentile your SLO is written at, with n beside it. Measure at the client or the router, which sees queueing, not only at the engine. And do not over-read the median TTFT under heavy closed-loop load: vLLM-TorchTPU's performance gate omits it beyond the prefill-admission capacity, \(DP \times\) max-num-batched-tokens / prompt length, because there "median TTFT is queue-position noise"; nightly baselines are calibrated with --gate-ttft-max-concurrency 0.

Throughput at an SLO, and goodput

A serving throughput figure means nothing without the latency it was bought at: any engine can raise tokens per second by batching more and letting TPOT grow. Report throughput at a stated load point (concurrency, or request rate) together with the percentiles there, and find the capacity as the load at which a percentile crosses the SLO. llm-d's llmdbenchmark workload profiles run a load ladder for exactly this; read the report per stage, and the stage where P90 TTFT crosses the SLO is the pool's capacity at that replica count (chapter 21). Its guide_<guide-name>_<n>.yaml profiles "reproduce the load ladder used to showcase" a guide's performance, so a published llm-d result can be rerun with the same workload, and its harness-agnostic benchmark report exists to exchange results "in a reproducible and standardized way".

Goodput folds the SLO into the throughput: completed requests per second whose TTFT and TPOT both met their SLOs. goodput() in the companion code implements this definition. On chapter 21's synthetic breach fixture, 169 of 200 requests meet both SLOs: a goodput of 84.5% of the throughput (against the example SLO pair in llm-d's Scale to Latency SLOs guide, a P90 TTFT under 3 s and a P90 TPOT under 100 ms), which no average shows. Do not confuse it with Google's ML Goodput Measurement library, which the TorchTitan integration post plans to adopt: that measures how much of a training job's chip time "turns into preserved training progress".

Cost per token

llm-d's inference cost recipe joins OpenCost allocation costs with vLLM token counts and exports three gauges under the llm_ prefix. llm_cost_per_million_tokens is the unit-economics metric, and its labels are the conventions you must state:

  • cost_basis: "allocation" (max of request and usage, times price, plus a share of idle and shared cost) for chargeback, "usage" (actual consumption) for efficiency. The two give different numbers for the same pod.
  • phase: empty for blended, prompt or generation for one side.
  • allocation_method: compute_time splits prefill and decode cost by vLLM's measured times ("most accurate"); multiplier uses "a fixed 2.5x ratio" when timing metrics are unavailable, which makes the per-phase split an assumption, not a measurement; empty means no tokens or a failed join.
  • llm_cache_savings_fraction, the share of prompt tokens served from the KV cache, says how much of a low cost came from prefix reuse that a different workload would not get.

A cost per token is a throughput divided into a price, so it inherits every condition of the throughput (workload, concurrency, SLO) and adds the price basis.

A smoke test is not a benchmark

llm-d's healthcheck.sh checks /health, /v1/models and one completion, and -l fails it if that completion's latency exceeds a bound (the example output shows 1842 ms). It is the right gate after every deploy. One request's latency is not a performance result: it has no load, no distribution and no warm-up rule.

Against the roofline

A measurement means more next to an estimate of what it should be. Chapter 2's roofline gives a floor: the larger of compute time at peak FLOP/s and memory time at peak bandwidth. The scaling book's profiling chapter does this for one matmul of a mock Transformer, estimating 95.6 ms and reading 96 ms in the trace (How to Scale Your Model, profiling). The ratio of measured to floor tells you which question to ask next.

Run Floor Measured Ratio Reading
Muse Glimmer training step, per device \(6N \times 40{,}960 / 1{,}153.5 \text{ TFLOP/s} = 5.65\) s 17.10 s 3.03x (MFU 33.0%) Chapter 16's fuller estimate, with recompute, attention and AdamW, is 7.80 s; the rest needs a trace
Muse Glimmer decode step, one device 53.02 GB / 3,690 GB/s = 14.37 ms (chapter 22) 23.58 ms 1.64x (61% of peak bandwidth) 9.21 ms per token is not weight reads
FLUX block, one v6e chip not estimated in the case study 122.51 ms The case study gives no floor; the speedups are relative only

Three readings are mechanical. A measurement below the floor means an input to the floor is wrong, almost always per chip against per device or a dtype assumption (fp8 weights read as bf16). A measurement near the floor means the remaining levers change the work, not the efficiency. A measurement far above it needs a trace before any change: vLLM-TorchTPU's optimization guidance makes "xprof traces the unit of evidence" (P-1): "E2e numbers alone prove nothing; a perf claim needs the trace plus a mechanism explanation of where the gain comes from." The TorchTitan optimization guide's first diagnostic is the same: capture a profile over a few steady-state steps and read the idle fraction, because "the single most useful number is the idle percentage".

Comparing two configurations fairly

A comparison is fair when exactly one thing differs and the difference is larger than the noise. The vLLM-TorchTPU and TorchTitan guides give the rules, mostly as warnings.

Hold the workload fixed. Same model, batch, sequence, dtypes, ISL and OSL, concurrency, prefix caching setting and warm-up rule. The FLUX case study shows how much the workload matters: at its sequence length of 32,768, compilation alone gives 1.12x; "at shorter sequence lengths, compilation matters more (about 3x at a sequence length of 640)". Neither figure is "the" speedup of compilation.

Match the global budget when parallelism changes. vLLM-TorchTPU's P-4: "Parallelism A/Bs compare at matched global token budget (DP with per-rank budget × N ranks vs TP at the same total). Interrogate any win the mechanism doesn't predict", because such a win is "usually a batch-size artifact". The TorchTitan guide's batch-size advice explains why the artifact is large: a bigger per-device batch is "often the single largest MFU lever at small scale".

Compare like windows. Chapter 22 found that the case study's DynamicCache was "2.5% slower" on the published averages, which used steps 2 to 20 for one cache and 4 to 20 for the other; on the same window the gap is 3.0%.

Report both sides of a trade-off. P-3: "scheduler changes report throughput and latency". PR-1: performance PRs "carry per-mode speedups (decode/prefill/mixed)" and update CI thresholds in the same PR.

Clear the noise. vLLM-TorchTPU's performance gate (check_regression.py --mode perf) compares median TPOT, total and output token throughput, completed requests (as a floor) and median TTFT (where the baseline has it) with a baseline at a flat 5% tolerance. Its accuracy gate is statistical: the allowed drop is \(\max(\text{tolerance}, 1.645\, \text{hypot}(se_\text{baseline}, se_\text{run}))\), because "the noisy quantity is their difference". The companion's compare() applies that second form to repeated performance runs, combining the performance gate's 5% with the accuracy gate's 1.645 formula: give it one summary per independent run (each run's median step time, say), and a change counts only if it beats both 5% and \(1.645\) times the combined relative standard error.

$ python code/ch24_evidence/bench.py --cpu-smoke   (excerpt)
4. Comparing configurations (FLUX DoubleStreamBlock means, one run each)
   zero-copy views only (eager)   ratio 0.998  gain +0.2%  threshold 5.0%  -> within noise (variance unknown)
   all four optimizations         ratio 0.686  gain +31.4%  threshold 5.0%  -> better (variance unknown)

The FLUX case study itself reads the first row correctly: zero-copy views leave the step time essentially unchanged (178.61 to 178.30 ms) and are kept for their memory, not their speed. Its 1.46x for all four changes clears any plausible noise. A 3% claim from one run each does not, whatever the sign.

Correctness first. Run chapter 23's gates on the candidate before comparing speed. vLLM-TorchTPU's CI runs its performance check and its accuracy checks against the same live server for this reason.

Reading published claims critically

The same seven elements, folded into four questions, plus a check that the number reproduces from its own inputs and a check that correctness was shown, make a checklist for any number you did not measure yourself. Work down it before you repeat a claim or plan around one.

A decision tree of six white rounded questions down the centre; an arrow down from each question is its Yes answer. First question: Workload, hardware and unit stated? No leads right to an orange card, Direction only: do not plan on it. Second: Reproduces from its own numbers? No leads right to an orange card, Ask which number is wrong. Third: FLOP count, percentile, cost basis stated? No leads left to a grey card, Recompute on your convention, from which an arrow runs down and right into the fourth question. Fourth: Warm-up excluded, window and repeats stated? No leads right to a grey card, One best run: expect lower, from which an arrow runs down and left into the fifth question. Fifth: Software pinned? No leads left to a grey card, Valid for that build only, from which an arrow runs down and right into the sixth question. Sixth: Correctness shown? No leads right to an orange card, Not a result until parity is shown. Down from the sixth question, a green card: Defensible: compare it with your own run.

Read down for yes. An orange card ends the reading until the gap is filled; a grey card changes how you read the number; where an arrow leaves it, the reading continues at the next question.

Apply it to three published claims.

Claim 1: Qwen3 235B on up to 8,192 v7x chips (announcement post, Case Study 3). The workload is unusually well specified: the exact config (qwen3_moe_235b_scan at a pinned commit), 16 sequences of 4,096 tokens per TensorCore, the precision policy, the kernels, scan, activation offloading, full checkpointing, Graph Trainer, the auxiliary loss and the dataset. The table reproduces from its own columns: one slice, \(32{,}768 \times 4{,}096\) tokens in 29.3 s over 2,048 TensorCores is 2,237 tokens per second per TensorCore against the published 2,236, and the other rows agree within the rounding of their step times. The unit is per TensorCore, so per chip is double. What is missing: the FLOP convention behind "28.8%" (for the same 1,024-chip slice the integration post gives 32.42%, and at 8,192 chips, where both posts give 4,208 tokens per second per chip, it gives 30.51% against the table's 27.1%: a ratio of 1.126 in both rows, the two-convention gap of chapter 16), the warm-up rule, the number of steps averaged, any variance, and software versions; and the text's "28% MFU" at 8,192 chips does not match the table's 27.1%. Verdict: the throughput and the weak-scaling shape are defensible; the MFU is defensible only after you pick a convention and recompute it.

Claim 2: Muse Glimmer 30B training, "~5.6k TPS per TPU with 38% MFU" (announcement post, Case Study 2). It reproduces on \(6N\) per chip, and chapter 16 showed which \(N\). But the case study gives a range, "2400 to 2800 TPS per rank", and the 38% sits at its top; the repository's own README log, five steps from one job, gives 2,381 to 2,404 per rank, 33%. The job pulls the image tag torch-tpu:latest, so the software is whatever was latest that day; the example seeds ranks differently and reports no loss check, so it is a throughput demonstration. Verdict: the claim is honest about the best case of a range. Plan on about 33% for this code until you measure your own, and report your version.

Claim 3: "lowest cost per million tokens overall at 2.01 cents" on InferenceX 8K/1K (announcement post, Case Study 4, citing SemiAnalysis). The post gives the workload class (8K in, 1K out), the hardware (TPU v7) and the stack (vLLM-TorchTPU), and says the result comes from a third-party benchmark. It does not give, in the post, the price basis behind the cost, the concurrency or interactivity point on the Pareto frontier at which 2.01 cents was reached, the latency at that point, or the software versions. A cost per token is a throughput divided into a price; without the load point and the latency, it cannot be compared with your SLO-bound deployment, and llm-d's own cost metric would need its cost_basis and allocation_method stated to mean anything. Verdict: a direction, and a pointer to the original benchmark, which is where the missing fields would have to come from.

The FLUX case study is the contrast case: hardware, software versions, model shape, precision, kernel block sizes and timing method all in one block under the table. Its one gap is variance: the means come with no spread.

Failure modes

What you see Likely cause Check or fix
Throughput far below the published figure for the same model Compilation inside the timed window; or an eager run (the TorchTitan guide: "Eager mode is for development and debugging only") Exclude steps until the compile count is flat; compile with backend="tpu", dynamic=False
One run's step time much worse than the last run's Cold caches: weights from storage, programs not in AOTAutogradCache, bounded-dynamic programs recompiled per process Say which start you measured; warm up explicitly
Periodic spikes in the steady window A recompile (a shape that keeps changing), garbage collection, a host sync in the loop (.item(), logging the loss every step) fail_on_recompile or perflab's recompile check; disable GC around the window; read device values every N steps
A speedup that does not survive a rerun The difference is inside run-to-run noise Repeat runs; compare() with the combined standard error
A parallelism change wins by more than its mechanism predicts Different global token budget, so a different batch Match the global budget (P-4)
MFU above 100%, or exactly half or double a reference Per-chip rate against per-device peak, or the reverse Put both in one unit; recompute
MoE MFU absurdly low A counter that gives _grouped_mm zero FLOPs (perflab's FlopCounterMode) Count expert FLOPs from the active parameters
Serving throughput better, users complain Batching raised throughput and the tail latency with it; or the report gave the mean Report percentiles at the SLO's quantile, and goodput
Median TTFT moves randomly between runs at high concurrency Queue-position noise beyond prefill-admission capacity Gate on TPOT and throughput there, as vLLM-TorchTPU's nightly baselines do
Results differ from a recipe's with "the same" flags Prefix caching, concurrency, --ignore-eos, a different dataset or length spread, a fastbuild wheel, shape checks or recompilation checks left on Copy the recipe's command and environment exactly; strip per-op checks for benchmarks
A p99 that changes a lot when one step is added n too small: nearest-rank p99 of fewer than 100 values is the maximum Time more steps or requests, and print n
Timings disagree with and without a profiler The profiler's overhead is in the window Disable it in timed steps (FLUX) or subtract it (perflab)

Verifying the result

You have defensible evidence when a report states the seven elements with a source for each, its result reproduces from its own inputs, it sits above its roofline floor by a ratio you can explain, and a comparison clears the noise. Run the companion first:

python code/ch24_evidence/bench.py --cpu-smoke     # steady state, warm-up rules, comparisons
python code/ch24_evidence/report.py --cpu-smoke    # renders the template, refuses an unsourced spec
pytest tests/ch24 -q

Both end with cpu-smoke: OK. The tests check the published arithmetic (2,395 tokens per second and 33.0% MFU from the README log, 23.58 ms from the decode table, perflab's own overhead example), that a window with no steps raises, and that a spec with a missing or unsourced field is refused.

A benchmark report template, filled

report.py renders a report from a JSON spec in which every field is {"value": ..., "source": ...}. A value can be null with a source that says why it is unknown; it is then listed as a gap. A field with no source, or a required field missing, stops the report. It computes the results itself, with the earlier chapters' code: chapter 21's percentiles, chapter 16's mfu, chapter 2's estimate. Here is the filled example, code/ch24_evidence/examples/glimmer_training.json, rendered (provenance rows shortened):

# Benchmark report: Muse Glimmer 30B, pure-PyTorch FSDP training step, one v7x host

## Results
| steady steps (n)                     | 4 (dropped 1 warm-up)                         |
| step time p50 / p90 / p99            | 17.073 / 17.202 / 17.202 s                    |
| step time mean ± std                 | 17.104 ± 0.070 s (cv 0.41%)                   |
| throughput per rank                  | 2,395 tokens/s                                |
| throughput, stopwatch over all steps | 1,709 tokens/s (-28.6%)   do not report       |
| MFU per rank                         | 33.0%     chapter 16 mfu(): 6N / peak         |
| compute floor                        | 5.65 s per step; measured mean is 3.03x       |

## Provenance (field | value | source)
| tokens per step | 40,960 per rank | worker.py and model_fsdp.py Config: batch_size 8 x seq_len 5120 |
| topology        | 2x2x1           | batchv1_job.yaml (cloud.google.com/gke-tpu-topology: 2x2x1)     |
| image           | .../torch-tpu:latest | batchv1_job.yaml (image)                                   |
| versions        | not stated      | the job pulls the floating tag latest and prints no version     |
| timer           | perf_counter around one step, then synchronize, rank 0 | worker.py (the Run loop) |
| excluded        | build, init, inputs; step 0, which compiles | worker.py; README.md                |
| timings         | 51.387, 17.04, 17.202, 17.101, 17.073 s | README.md job log, Run 0 to Run 4        |
| convention      | 6N, N = 26,509,949,440, embedding excluded | chapter 16                           |
| peak flops      | 1.154e+15 per device | chapter 1; code/ch16_case_study/mfu.py                     |
  ... (workload, hardware, published claim and correctness rows)

## Gaps and flags
- Gap: software.versions: not stated: the job pulls the floating tag latest ...
- Gap: correctness.parity: not stated: the example seeds each rank differently ...
- Flag: only 4 steady steps; perflab times 10 by default
- Flag: one run: run-to-run variance unknown, so a difference under 5% cannot be called

Every number in the Results block can be traced to a row below it, and the Gaps block says what a reviewer cannot check. That is the standard: a report with gaps listed is defensible; a report with gaps hidden is not. A second example, serving_synthetic.json, fills the serving half of the template (TTFT and TPOT percentiles, the SLO verdict, throughput and goodput) from chapter 21's synthetic fixture and says so in its first line.

For your own run:

  1. Copy an example spec and fill it before you measure. Workload, hardware, software versions (print torch.__version__ and your TorchTPU version in the job log), the warm-up rule, the window, the number of runs. Unknowns go in as null with a reason.
  2. Measure with a sync per step for at least as many steady steps as perflab's default (10), more for percentiles, and log the compile count. Use steady_state with the warm-up from warmup_steps (perflab's rule) or, failing compile counts, slow_prefix. Report compile time and first-step time separately.
  3. Repeat the run at least three times in separate processes and keep one summary per run; compare configurations with compare().
  4. Put the floor next to the measurement (chapter 2, 16, 17 or 22's estimates), and capture an XProf trace of the steady window (chapter 10) for any claim you want someone else to act on.
  5. For serving, run the vLLM-TorchTPU harness or llmdbenchmark with a stated workload profile and warm-up passes, feed per-request records to chapter 21's slo_check.py, and report the percentile your SLO uses with goodput beside throughput.
  6. On a TPU, python code/ch24_evidence/bench.py times a compiled bf16 matmul per step, finds the warm-up from the slow steps and prints the ratio of its median to chapter 2's roofline bound. Record that ratio with your TPU generation and TorchTPU version.

Worked problems

Problem 1. From the README log (runs 0 to 4: 51.387, 17.040, 17.202, 17.101, 17.073 s; 40,960 tokens per rank per step), compute the steady throughput per rank and per chip, the MFU on \(6N\) with \(N = 26.51 \times 10^9\), and the MFU a stopwatch over all five steps would report.

Answer

Steady mean over runs 1 to 4: \(68.416 / 4 = 17.104\) s, so \(40{,}960 / 17.104 = 2{,}395\) tokens per second per rank and 4,790 per chip. MFU: \(2{,}394.8 \times 6 \times 26.51 \times 10^9 / 1.1535 \times 10^{15} = 33.0\%\) per device; per chip \(4{,}789.6 \times 159.06 \times 10^9 / 2.307 \times 10^{15}\), also 33.0%. Over all five steps: \(204{,}800 / 119.803 = 1{,}709\) tokens per second, MFU 23.6%, 29% low. report.py prints both and marks the second "do not report".

Problem 2. In the decode case study, prefill and step 1 compile (21,024.81 and 19,756.86 ms) and every later token takes about 23.58 ms. How many tokens must a stopwatch started at the prompt cover before it reads within 10% of the steady 42.4 tokens per second? What does that say about benchmarking short generations?

Answer

With \(W = 40{,}781.67\) ms for prefill plus step 1 and \(t = 23.58\) ms per later token, \(N\) tokens take \(W + (N - 1)t\). Require \(N / (W + (N-1)t) \ge 0.9 / t\), so \(0.1 N t \ge 0.9 (W - t)\) and \(N \ge 9 (W - t) / t = 15{,}557\) tokens. A benchmark of short generations against a cold process measures compilation; even 1,000 tokens would read 1,000 / 64.3 s, 15.5 tokens per second. Warm up first (or use a warm cache), then time.

Problem 3. A colleague reports "decode p99 = 24.66 ms" from the case study's steps 2 to 20, and another "p99 = 23.69 ms" from steps 4 to 20. Which is right, and what would you report instead?

Answer

Both are the maximum of their window, because nearest-rank p99 of 19 or 17 values is the largest one; neither estimates a tail. The difference is whether two settling steps are inside the window, which a warm-up rule should decide in advance. Report the median (23.43 ms in both windows), the mean with n (23.58 ms, n = 19, or 23.47 ms, n = 17) and the rule used; for a p99, time at least 100 steps, and preferably several runs.

Problem 4. A pull request claims an 8% speedup. Five independent runs of each configuration give median step times of 100, 110, 90, 105, 95 ms (baseline) and 92, 102, 82, 97, 87 ms (candidate). Is the claim defensible? What would make it so?

Answer

The means are 100 and 92 ms, a gain of 8%. Each side's sample standard deviation is 7.9 ms, so the standard errors of the means are 3.5 ms, or 3.5% and 3.8% relative; combined in quadrature, 5.2%. The threshold, compare()'s rule, is \(\max(5\%, 1.645 \times 5.2\%) = 8.6\%\), and 8% is under it: compare() returns "within noise". The runs are too noisy to call an 8% change. Find and remove the source of the 20% run-to-run spread first (a shared host, a cold cache, GC, data loading); with the spread of a quiet machine, say 0.5%, the same 8% would clear 5% easily. Attach a trace of both configurations and the mechanism, as P-1 asks.

Problem 5. A team reports that TP=8 serves 1.4x the output tokens per second of DP=8 for the same model on one v7x host. Both ran vllm bench serve at --max-concurrency 64 with --max-num-batched-tokens 8192 on every engine. Judge the comparison.

Answer

The budgets are not matched. With DP=8, eight engines each admit up to 8,192 batched tokens, 65,536 in total; with TP=8, one engine admits 8,192. The concurrency is the same, but how many prompt tokens each step may prefill differs eightfold, so prefill and decode interleave differently and the comparison measures a scheduling budget as much as a layout. P-4 requires matched global token budgets, and a win larger than the mechanism predicts "is usually a batch-size artifact". Rerun with the DP per-rank budget times 8 equal to the TP budget, report TTFT and TPOT percentiles beside throughput (P-3), state ISL and OSL, --ignore-eos and the prefix caching setting, and attach traces.

Problem 6. A perflab-style run of an MoE model reports 9% MFU, and a hand calculation on \(6N_\text{active}\) gives 31% for the same step time. Which do you trust, and how do you write it up?

Answer

perflab's FLOP counter uses FlopCounterMode, under which ops without a formula count zero, and its own docstring names _grouped_mm: the expert matmuls of an MoE layer, most of its FLOPs, disappear from the numerator. The 9% is a counting artifact. Trust the calculation from active parameters, but write down its convention (\(6N_\text{active}\), with or without attention, no recompute), the unit (per chip or per device) and the peak used, and report the counted figure only alongside an explanation. The general rule: when two MFUs disagree by more than a few points for the same step time, the conventions differ, not the run.

Problem 7. A dashboard shows llm_cost_per_million_tokens{phase="generation", allocation_method="multiplier", cost_basis="allocation"} falling 30% after a change that enabled prefix caching. A manager wants to report "generation 30% cheaper". What do you say?

Answer

Three things qualify it. allocation_method="multiplier" means the split between prompt and generation cost is the fixed 2.5x ratio used when vLLM's timing metrics are unavailable, so the generation figure is an assumed share of the total, not a measured one; prefix caching saves prompt work, so a change in the generation share under a fixed ratio is not evidence about generation at all. cost_basis="allocation" charges requested capacity and a share of idle cost, so it moves with utilization as well as efficiency; use "usage" for an efficiency claim. And check llm_cache_savings_fraction: the saving depends on how much of this workload's prompts are shared. Report the blended cost per million tokens on the usage basis before and after, at a stated load and with latency percentiles, and enable the timing metrics so the split becomes compute_time.

Quick questions

  1. Name the seven elements a performance number must state, and the failure each one prevents.
  2. How does perflab decide that warm-up has ended, and what does it do if a compile happens in the timed window?
  3. When would you synchronize every step, and when dispatch back to back with one synchronization? What does each hide?
  4. Why is the p99 of 19 steps the maximum, and what statistic do you report for a step time instead?
  5. Give three FLOP conventions for MFU and say which one undercounts an MoE model, and why.
  6. Why does vLLM-TorchTPU's gate omit median TTFT under heavy closed-loop load?
  7. What is goodput, and why can a run with higher throughput have lower goodput?
  8. Which labels of llm_cost_per_million_tokens must accompany a cost figure, and what does allocation_method="multiplier" mean?
  9. What does a measurement below its roofline floor tell you?
  10. What must be true before a 5% difference between two configurations can be called a speedup?

Key takeaways

  • A number is defensible when it states its workload, hardware and topology, software versions, warm-up rule, steady window, repetitions and units, each with a source; list what is unknown instead of leaving it out.
  • Exclude compilation by rule (the compile count stops changing), report compile and first-step time separately, and say whether you measured a cold or a warm start. Including two compiles made a 20-token decode benchmark wrong by 87x.
  • Report step time as a median with n, throughput as work over the mean of the steady window, and MFU with its FLOP convention (\(6N\), \(6N\) plus attention, or counted ops) and its unit (per chip or per device). An MFU above 100% is a units bug.
  • Serving results are distributions: report the percentile your SLO uses, throughput at a stated load point, goodput beside throughput, and cost per token with its cost basis and allocation method.
  • Put every measurement next to its roofline floor. Below the floor, an input is wrong; far above it, take a trace before you change anything.
  • Compare configurations with one thing changed, budgets matched, the same window, repeated runs and a threshold of \(\max(5\%, 1.645 \times\) combined standard error\()\), after the correctness gates of chapter 23 have passed.
  • Read published claims with the checklist: reproduce them from their own numbers, recompute them on your convention, and treat a best case of one run as a ceiling.

Part VII moves from judging the stack to extending it, with new ATen lowerings, vLLM-TorchTPU patches and plugins (chapter 25) and agent-driven onboarding and tuning (chapter 26). Everything you build there ships behind the two gates of this Part: a parity report that can fail, and a benchmark report that states where every number came from.

References