Pidoku

Benchmarking Inference Correctly

Module 22 Lesson 22.g 1h 30m Difficulty 4/5

Prerequisites 2.c, 19.d, 22.a

★ A wrong benchmark is worse than no benchmark, because it produces confident wrong decisions.


Before you start: words you need#

WordPlain meaning
WorkloadWhat the benchmark sends: prompt lengths, output lengths, shared prefixes, and how requests arrive.
Open loopRequests arrive at a set rate whatever the server is doing, like real users.
Closed loopA fixed number of clients, each sending the next request only when the last one finished.
Steady stateThe period after start-up effects (compilation, cache warm-up, queue build-up) have passed.
GoodputRequests per second (or share of requests) that met every latency target. Throughput that counts only satisfied users.
Pareto curveA curve of best trade-offs, here throughput per GPU against speed per user: no point on it can improve one without losing the other.
ScenarioIn MLPerf, a fixed way of sending load: Offline (all at once), Server (random arrivals with latency limits), Interactive (tighter limits).
Error barThe spread of a result across repeated runs. Without it you cannot tell a real change from noise.

1. What is it?#

Running a controlled load against an inference system and reporting numbers that someone else could reproduce and make a decision from. Lesson 19.d covers the vLLM tools and flags. This lesson covers what makes any benchmark valid, which tools exist in 2026, how to read public results, and how to report your own.

The eight requirements:

1. REALISTIC WORKLOAD     real length distributions and prefix sharing, not fixed lengths
2. REALISTIC ARRIVALS     open-loop rates or replayed traces, not "N clients in a loop"
3. STEADY STATE           warm up, discard the start, run long enough
4. CLIENT-SIDE TIMING     measured where the user is, through the real path
5. THE RIGHT METRICS      TTFT and ITL percentiles, bucketed; goodput; cost
6. CONTROLLED SETUP       known clocks, no other tenants, every version recorded
7. REPEATABLE             several runs, seeds fixed where possible, error bars
8. HONEST REPORT          every number, including the unflattering ones

Most published inference benchmarks break 1, 2 and 5. Most internal ones break 3 and 7.

Facts checked on 12 November 2026.


2. Why does it matter?#

Because benchmark numbers drive the expensive decisions: which engine, which GPU, how many replicas, whether an optimisation ships. A benchmark with fixed 1,024-token prompts, a closed loop and a 30-second run produces a number that is real but describes a system you do not run. Teams then size a fleet for it and find out in production.


3. Simple analogy#

Measuring a restaurant’s speed. Timing one diner who orders the same dish at 3 pm tells you almost nothing about Saturday at 8 pm. A useful test sends a realistic mix of orders (workload), at Saturday’s arrival rate, without waiting for one table to finish before seating the next (open loop), after the kitchen is warmed up (steady state), timing from the diner’s chair rather than the kitchen pass (client side), and repeats it on several Saturdays (error bars).


4. Tiny example: why one number is not enough#

The program in section 6 analyses 2,000 requests from a toy server with chat-like lengths:

run 1: 2000 requests
  TTFT all prompts      p50     86 ms   p99    470 ms
  TTFT prompt <=512     p50     63 ms   p99    290 ms   (n=1295)
  TTFT prompt 512-2k    p50    118 ms   p99    393 ms   (n=597)
  TTFT prompt 2k-8k     p50    313 ms   p99    698 ms   (n=103)
  TTFT prompt >8k       p50    986 ms   p99   1177 ms   (n=5)
goodput (TTFT<=1s and ITL p95<=50ms), 3 runs: 95.2% 94.5% 94.6% -> 94.8 ± 0.4%
  • The unbucketed p99 (470 ms) describes nobody: short prompts are much faster, long ones much slower. Bucket by prompt length.
  • The “>8k” bucket has five requests. Its “p99” is just the largest of five numbers. Report the count with every percentile.
  • Goodput varies by about half a percentage point between runs of the same setup. A change smaller than that is noise.

5. Technical explanation#

Requirement 1: the workload#

WRONG   every prompt 1,024 tokens, every output 128 tokens
        → one point in a two-dimensional space, and not one your traffic occupies

RIGHT   lengths sampled from your logs (22.j): prompt lengths heavy-tailed,
        output lengths depending on the task; realistic prefix sharing
        (system prompts, multi-turn history, agent loops)

BEST    replay real traces: anonymised lengths and timestamps, no content

Prefix sharing matters as much as lengths now. A random dataset gives a 0% prefix-cache hit rate; repeating one prompt gives 100%; real chat and agent traffic sits in between and changes throughput a lot (12.m). Agentic workloads (long multi-turn sessions, shared prefixes, pauses between turns, tool calls) behave differently again, which is why newer suites add dedicated agentic scenarios.

Also: do not set ignore_eos with fixed output lengths unless you are measuring something specific. It removes the output-length variance that makes scheduling hard.

Requirement 2: arrivals#

Closed-loop load (N clients in a loop) adapts to the server: when the server slows, the clients slow, so queues never form and latency looks fine at any “load”. This is coordinated omission; 19.d demonstrates it with a program. The rules:

CLOSED LOOP  → finds a throughput ceiling at a fixed concurrency. Never use it for SLO claims.
OPEN LOOP    → requests at rate λ (Poisson or burstier). Sweep λ and plot latency against it.
               The rate just before the curve bends is your capacity at that SLO.
TRACE REPLAY → recorded timestamps: diurnal peaks and bursts. Final validation.

Always say which one a number came from.

Requirement 3: steady state#

Start-up effects inflate or deflate early numbers:

kernel JIT and autotuning on first use      CUDA graph capture, torch.compile
allocator pool growth                        prefix cache warming
GPU boost clocks before heat soak            queue build-up at a new rate

Warm up with at least a minute (or several hundred requests) of representative load and discard it. Measure for several minutes, or a few thousand requests. Check that the waiting-queue gauge is not still rising when you stop: if it is, the system is overloaded at that rate and the numbers are not steady. Restart, or reset the prefix cache, between runs that should not share cache contents.

Requirement 4: client-side timing#

Server-side TTFT is what the engine saw. Client-side TTFT is what the user saw, and adds network round trips, TLS, load balancer and proxy time. A buffering proxy can make server TTFT perfect while client TTFT is twenty times worse (22.k, case 8). Measure both; if they differ by more than a round trip, investigate.

Take timestamps as each streamed chunk arrives:

Go
// Fragment: client-side timing of one streamed request.
func measure(ctx context.Context, url string, payload []byte) (Result, error) {
	req, _ := http.NewRequestWithContext(ctx, "POST", url, bytes.NewReader(payload))
	req.Header.Set("Content-Type", "application/json")
	t0 := time.Now()
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		return Result{}, err
	}
	defer resp.Body.Close()

	var res Result
	var prev time.Time
	sc := bufio.NewScanner(resp.Body)
	for sc.Scan() {
		data, ok := strings.CutPrefix(sc.Text(), "data: ")
		if !ok {
			continue
		}
		if data == "[DONE]" {
			break
		}
		now := time.Now()
		if prev.IsZero() {
			res.TTFT = now.Sub(t0)
		} else {
			res.ITLs = append(res.ITLs, now.Sub(prev))
		}
		prev = now
	}
	return res, sc.Err()
}

A chunk can carry more than one token (speculative decoding, --stream-interval), so count tokens from the response, not chunks. And watch the load generator’s own CPU: a single-core Python client saturates before a fast server does.

Requirement 5: the metrics#

TTFT        p50, p90, p99, bucketed by prompt length, with counts
ITL         p50, p90, p99 (and against token position if it drifts)
E2E         bucketed by output length
Throughput  output tok/s, input tok/s, requests/s
Goodput     requests/s meeting BOTH the TTFT and ITL targets
Cost        $ per million input and output tokens at a stated GPU price
Efficiency  % of the step floor (22.b), average running batch

Goodput is the metric that resists gaming: you can raise throughput by making everyone slow, but not goodput. vllm bench serve --goodput ttft:1000 tpot:50 and GuideLLM’s goodput profile both compute it.

Requirement 6: the setup#

Shell
nvidia-smi -pm 1                                   # persistence mode
nvidia-smi --query-compute-apps=pid,used_memory --format=csv   # nobody else on the GPU
sudo nvidia-smi -lgc <mhz>,<mhz>                   # optional: lock SM clocks
# ... run ...
sudo nvidia-smi -rgc                               # reset clocks

Lock clocks for A/B comparisons of software changes: it removes a source of run-to-run variance so a 5% change is visible. Do not lock them for capacity claims: production runs at whatever clock power and heat allow, often lower than boost after minutes of load. Report which you did. Also record driver, CUDA, engine and model versions, and set the CPU frequency governor to performance if you control the host.

Requirements 7 and 8: repeat, then report everything#

Run at least three times and report mean and spread. Report the unfavourable numbers too: the long-prompt bucket, the p99, the rate at which the SLO broke.

The tools in 2026#

ToolWhat it isUse it for
vllm bench serve (19.d)vLLM’s built-in client. Rate, burstiness, ramp-up, --goodput, many datasets, trace replay. vllm bench sweep grids server and client settings.Quick, engine-adjacent tests; works against any OpenAI-compatible server.
GuideLLMSLO-oriented benchmarking platform under the vLLM organisation. v0.8.0 (30 Sep 2026) added a goodput profile that searches for the highest load meeting latency targets; v0.8.1 (8 Oct 2026) added knee detection.Capacity and SLO studies, HTML and CSV reports.
NVIDIA AIPerfNVIDIA’s load generator for OpenAI-compatible endpoints; used under InferenceX’s agentic scenario.Engine comparisons, multi-turn and agentic traces.
Your own harnessA few hundred lines (section 6 and the fragment above).Testing the full production path, custom auth and routing.

GuideLLM’s command line changed in 0.8: options take kind= registry values, and --profile has no default any more:

Shell
guidellm run \
  --backend kind=openai_http,target=http://localhost:8000 \
  --profile kind=sweep \
  --constraint kind=max_duration,seconds=60 \
  --data kind=synthetic_text,prompt_tokens=1024,output_tokens=256

Profiles include synchronous, concurrent, throughput, constant, poisson and sweep. Pin the container tag; latest may be a pre-release.

Reading public benchmarks#

MLPerf Inference (MLCommons) is the audited, rule-bound benchmark. Each submission runs fixed models at a fixed accuracy target in fixed scenarios: Offline (all queries available at once: a throughput ceiling), Server (Poisson arrivals with TTFT and per-token latency limits) and, for LLMs, Interactive (tighter latency limits). v6.0 (1 April 2026) added DeepSeek-R1 interactive, Qwen3-VL-235B, GPT-OSS-120B and a text-to-video test. v6.1 (16 September 2026) set a participation record (30 organisations by StorageReview’s count) and added a datacenter RAG pipeline and an edge agentic test; it also carried NVIDIA’s first Vera Rubin NVL72 preview results. The rules make results comparable; the price is that the workloads are fixed, and vendors tune heavily for them. Read the Server and Interactive numbers, not just Offline, and check whether a result is “Available” or “Preview” hardware.

InferenceX (SemiAnalysis, formerly InferenceMAX) is an open-source benchmark that re-runs whenever a software release, driver or model changes, across NVIDIA, AMD and other hardware and across vLLM, SGLang, TensorRT-LLM, Dynamo and others. It reports curves, not single numbers: throughput per GPU against interactivity (tokens per second per user), plus cost per million tokens and energy per token. Its AgentX scenario replays multi-turn agentic coding traces. It is the best public source for “which stack on which GPU at which interactivity”, but it is one organisation’s configurations; your model, lengths and SLO can move the ranking.

Vendor claims (“up to 3.7x”) are usually the best point on a favourable curve. Ask for the interactivity, sequence lengths and precision behind them.


6. Under the hood: from raw results to a report#

Go
// report.go: turn raw per-request results into the numbers a benchmark
// report needs: TTFT bucketed by prompt length, goodput, and run-to-run spread.
// The "server" is a toy latency model so the program runs anywhere.
package main

import (
	"fmt"
	"math"
	"math/rand/v2"
	"sort"
)

type result struct {
	prompt, output int
	ttftMS, itlP95 float64
}

// One benchmark run: chat-like lengths (lognormal), a toy server.
func run(seed uint64, n int) []result {
	rng := rand.New(rand.NewPCG(seed, 7))
	out := make([]result, n)
	for i := range out {
		prompt := int(math.Min(32768, math.Exp(5.8+1.1*rng.NormFloat64())) + 10)
		output := int(math.Min(4096, math.Exp(4.6+0.9*rng.NormFloat64())) + 1)
		queue := rng.ExpFloat64() * 60                // ms waiting for a slot
		prefill := float64(prompt) / 12.0             // ~12k prompt tok/s
		itl := 22 + 6*rng.NormFloat64()*rng.Float64() // ms, small jitter
		if rng.IntN(20) == 0 {
			itl += 40 // 1 in 20 requests shares steps with long prefills
		}
		out[i] = result{prompt, output, queue + prefill, itl}
	}
	return out
}

func pct(xs []float64, p float64) float64 {
	s := append([]float64(nil), xs...)
	sort.Float64s(s)
	return s[int(math.Ceil(p/100*float64(len(s))))-1]
}

func main() {
	const ttftSLO, itlSLO = 1000.0, 50.0 // ms
	buckets := []struct {
		name   string
		lo, hi int
	}{{"<=512", 0, 512}, {"512-2k", 513, 2048}, {"2k-8k", 2049, 8192}, {">8k", 8193, 1 << 30}}

	var goodputs []float64
	for seed := uint64(1); seed <= 3; seed++ {
		rs := run(seed, 2000)
		var all []float64
		good := 0
		for _, r := range rs {
			all = append(all, r.ttftMS)
			if r.ttftMS <= ttftSLO && r.itlP95 <= itlSLO {
				good++
			}
		}
		goodputs = append(goodputs, 100*float64(good)/float64(len(rs)))
		if seed > 1 {
			continue
		}
		fmt.Printf("run 1: %d requests\n", len(rs))
		fmt.Printf("  TTFT all prompts      p50 %6.0f ms   p99 %6.0f ms\n", pct(all, 50), pct(all, 99))
		for _, b := range buckets {
			var xs []float64
			for _, r := range rs {
				if r.prompt >= b.lo && r.prompt <= b.hi {
					xs = append(xs, r.ttftMS)
				}
			}
			fmt.Printf("  TTFT prompt %-8s  p50 %6.0f ms   p99 %6.0f ms   (n=%d)\n",
				b.name, pct(xs, 50), pct(xs, 99), len(xs))
		}
	}
	mean, sd := 0.0, 0.0
	for _, g := range goodputs {
		mean += g / 3
	}
	for _, g := range goodputs {
		sd += (g - mean) * (g - mean) / 2
	}
	fmt.Printf("goodput (TTFT<=1s and ITL p95<=50ms), 3 runs: %.1f%% %.1f%% %.1f%% -> %.1f ± %.1f%%\n",
		goodputs[0], goodputs[1], goodputs[2], mean, math.Sqrt(sd))
}

The output is in section 4. Swap run for your real results (from the client fragment, or from vllm bench serve --save-result --save-detailed) and the rest of the analysis stays the same.

What a good report looks like#

Model and serving: Llama-3.3-70B-Instruct, FP8 weights and KV, vLLM v0.32.0, 8×H100 SXM,
  TP=8, max_num_seqs=256, max_num_batched_tokens=4096, prefix caching on, CUDA graphs on.
Workload: 2,000 requests; prompt lengths sampled from production logs of 3 Nov 2026
  (p50 330, p95 2,100, p99 8,400 tokens); outputs p50 180, p95 890; 38% prefix-cache hit rate.
Load: open loop, Poisson, 4 to 20 req/s in steps of 2; 60 s warm-up, 600 s measured per rate;
  clocks unlocked (capacity claim); 3 runs per rate.
Results at 12 req/s (mean ± sd of 3 runs):
  TTFT p50 210 ± 8 ms, p95 780 ± 34 ms (prompts ≤ 2k, n≈1,700 per run)
  TTFT p95 3,400 ± 210 ms (prompts > 8k, n≈20 per run)
  ITL p50 22 ± 0.4 ms, p99 61 ± 4 ms
  Output throughput 4,180 ± 90 tok/s; goodput 10.8 of 12 req/s (TTFT ≤ 1 s, ITL p95 ≤ 50 ms)
  Average running batch 71; whole-step at 74% of the bandwidth floor
  Cost $0.53 per million output tokens at $2.50 per GPU-hour, fully used
Knee: p95 TTFT crosses 1 s at 14 req/s.

(The numbers are illustrative.) The bad report is “we got 4,180 tokens/sec”. It is not wrong; it is impossible to reproduce, compare or act on.


7. Performance implications#

  • Fixed lengths flatter throughput. No long prompts to disturb decode, no variance to cause preemption, often a perfect or zero cache hit rate.
  • Short runs flatter latency. Queues have not built and clocks have not settled.
  • Closed loops flatter tail latency. The queue is capped at the number of clients.
  • Offline numbers flatter everything. No HTTP, no streaming, no tokenising under load; use them as a ceiling only.
  • Interactivity and throughput trade. Every public curve shows it: the same GPU gives several times more tokens per GPU at 20 tok/s per user than at 200. A single number without its point on that curve is meaningless.

8. Production implications#

  • Benchmark the path users take, including gateway, auth and load balancer, at least once per release.
  • Keep one benchmark definition (workload file, rates, durations, SLOs) in version control, and run it for every engine upgrade and configuration change. Compare against the stored baseline.
  • Refresh the workload from production logs every few months; traffic shapes drift.
  • Set admission limits from the knee, not from the peak throughput (19.d, 20.e).
  • Use public benchmarks to shortlist, then measure your own workload before buying.

9. Common mistakes#

  1. Fixed-length prompts and outputs. The most common and most misleading.
  2. Closed loop only. Hides queueing.
  3. No warm-up, or too short a run.
  4. Server-side timing only. Misses everything between the server and the user.
  5. Unbucketed TTFT percentiles, and percentiles of tiny buckets without counts.
  6. One run. No error bars, so no way to see a real change.
  7. Throughput without the latency it was achieved at.
  8. Comparing a tuned system with an untuned one. Tune both, or say you did not.
  9. Not publishing the workload. The result cannot be interpreted.
  10. Reusing a warm prefix cache between runs and calling the improvement real.

10. Hands-on exercise#

  1. Run report.go. Change the prompt-length distribution to fixed 1,024 tokens. What happens to the bucketed table and to goodput?
  2. In run, make 1 in 5 requests suffer the extra 40 ms instead of 1 in 20. How much does goodput drop? Which target fails?
  3. Open versus closed. Benchmark one server closed-loop at 64 clients and open-loop at the rate that gives about 64 requests in flight. Compare p99 TTFT (19.d explains the difference).
  4. The warm-up effect. Measure throughput over the first 10 seconds, 10–60 seconds, and after 5 minutes. How much does a short run overstate?
  5. GuideLLM sweep. Run the sweep in section 5 against a local server, then a poisson profile at the rate just below the knee it reports. Do the two agree?
  6. Read a public result. Pick one InferenceX curve and one MLPerf Server result for the same GPU. What interactivity, sequence lengths and precision does each assume? Which is closer to your workload?

11. Interview questions#

  1. What makes an inference benchmark valid? Name five requirements.
  2. Closed loop or open loop: when do you use each, and what does each hide?
  3. Why must TTFT percentiles be bucketed by prompt length, and reported with counts?
  4. What is goodput, and why is it harder to game than throughput?
  5. When should you lock GPU clocks, and when should you not?
  6. How do MLPerf’s Offline, Server and Interactive scenarios differ, and which matters for a chat product?
  7. A vendor says their GPU is “3x faster for inference”. What do you ask?

12. Further reading#

Checked on 12 November 2026.

↑↓ navigate↵ openesc close

100% drag to pan · scroll or pinch to zoom · double-click to zoom in