Benchmark vLLM-TorchTPU¶
Use this guide when you need a serving number someone else can trust: TTFT, TPOT and throughput for a model, layout and flag set, a comparison against a baseline, or an accuracy check that a change did not alter the model. vLLM-TorchTPU's harness under scripts/vllm/benchmarking/ runs the project's CI regression gates; this guide runs a standalone server and client first, then the harness and its gates. Chapter 18, section "Benchmarking with vllm bench serve", explains each flag of the client; chapter 24 is the general method for evidence.
Prerequisites¶
- A TPU host with vLLM-TorchTPU and a clone of
https://github.com/vllm-project/vllm-torchtpu.git(or thevllm/vllm-torchtpu:nightlyimage, which includes the benchmark tools). - Model weights downloaded, or
--load-format dummythrough a config for a performance-only run. - Your chapter 17 TPOT floor for the model and batch, written down before you measure.
Steps¶
1. Install the benchmarking and evaluation extras¶
uv pip install --prerelease=allow -e ".[benchmarking]" --group vllm
This adds lm-eval, evalscope, datasets and runai-model-streamer.
Check: vllm bench serve --help runs.
2. Start the server¶
The standalone recipe matches the nightly 480B performance config:
vllm serve --model=Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8 \
--tensor-parallel-size=8 --data-parallel-size=1 \
--max-model-len=16384 --max-num-batched-tokens=8192 --max-num-seqs=512 \
--port 8000 --async-scheduling --no-enable-prefix-caching \
--gpu-memory-utilization=0.95 --kv-cache-dtype=fp8 \
--enable-expert-parallel --quantization fp8 \
--attention-backend CUSTOM
Leave VLLM_XLA_CHECK_RECOMPILATION at 0 for a benchmark.
Check: Application startup complete.
3. Run the client¶
In a second terminal, three runs that separate balanced, decode-heavy and prefill-heavy work:
vllm bench serve \
--backend vllm \
--model Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8 \
--host localhost \
--port 8000 \
--dataset-name random \
--random-input-len 1024 \
--random-output-len 1024 \
--random-range-ratio 0.8 \
--num-prompts 320 \
--max-concurrency 64 \
--request-rate inf \
--ignore-eos \
--save-result \
--result-filename isl1024_osl1024_c64.json \
--seed 42
Repeat with --random-input-len 1024 --random-output-len 8192 --result-filename isl1024_osl8192_c64.json, then with --random-input-len 8192 --random-output-len 1024 --result-filename isl8192_osl1024_c64.json, other flags unchanged. For a profile from the book's builder, --bench prints the command:
python code/ch18_vllm/launch_profiles.py --bench v7x-8-qwen3-coder-30b-guard --input-len 8192 --output-len 1024 --concurrency 64
--ignore-eos makes every request produce its full output, --max-concurrency 64 with --request-rate inf keeps 64 requests in flight (a closed loop), and --seed 42 makes the random prompts repeatable.
Check: each run writes its JSON. Compare its median TPOT with your floor: the measurement must be above the floor. A measurement below it means an input to the floor is wrong (per chip mixed with per device, or bf16 assumed where weights or KV are fp8). To time requests yourself, python code/ch18_vllm/client.py bench --model MODEL --requests 256 --concurrency 64 --prompt-words 1024 --max-tokens 1024 --floor-tpot-ms YOUR_FLOOR prints median and p99 TTFT and TPOT against the floor.
4. Run the harness¶
The harness loads a config (model, TP, input and output length sweep, concurrency levels), starts vllm serve with its flags, optionally runs discarded warmup passes, runs the client for each length and concurrency combination, and saves JSON per combination. All its configs target TPU v7x-8, and it forces an fp8 KV cache.
# The PR-time guard config
./scripts/vllm/benchmarking/run_benchmarks.sh --config qwen3-coder-30b-fp8-tp8-ep
# Print the commands without running them
./scripts/vllm/benchmarking/run_benchmarks.sh --config qwen3-coder-480b-fp8-tp8-ep --dry-run
# A fixed results directory
./scripts/vllm/benchmarking/run_benchmarks.sh --config qwen3-coder-30b-tp8-ep --results-dir /tmp/perf
| Config | Model | Weights | CI tier |
|---|---|---|---|
qwen3-coder-30b-fp8-tp8-ep |
Qwen3-Coder-30B-A3B-Instruct-FP8 | fp8 | guard (scheduled) |
qwen3-coder-30b-tp8-ep |
Qwen3-Coder-30B-A3B-Instruct | none | nightly |
qwen3.5-35b-fp8-tp4-ep |
Qwen3.5-35B-A3B-FP8 | fp8 | nightly |
qwen3.5-35b-fp8-tp8-ep |
Qwen3.5-35B-A3B-FP8 | fp8 | nightly |
qwen3.5-35b-fp8-dp4-tp2-ep |
Qwen3.5-35B-A3B-FP8 | fp8 | nightly |
qwen3-coder-480b-fp8-tp8-ep |
Qwen3-Coder-480B-A35B-Instruct-FP8 | fp8 | nightly short sweep |
qwen3-coder-480b-fp8-tp8-ep-full |
Qwen3-Coder-480B-A35B-Instruct-FP8 | fp8 | manual only |
All are MoE models with expert parallelism. Configs are shell files in configs/; copy one to add your own. BENCHMARK_WARMUP_RUNS (default 0) sets full passes to discard before each gated result, and PORT (default 8000) the server port.
Check: benchmark_runs/<model>_tp<N>_<timestamp>/ holds config.json, isl<N>_osl<N>_c<N>.json per combination, server.log and benchmark.log.
5. Gate performance against a baseline¶
python3 scripts/vllm/benchmarking/check_regression.py \
--mode perf \
--results-dir <DIR> \
--baseline scripts/vllm/benchmarking/baselines/perf/<config>.baseline.json
With a 5% tolerance it gates median TPOT, total token throughput, output token throughput, completed requests (as a floor relative to the baseline), and median TTFT only where the baseline entry carries it. Under closed-loop load beyond the prefill admission capacity, \(DP \times\) max-num-batched-tokens / prompt length, median TTFT is queue-position noise, so nightly baselines omit it (--gate-ttft-max-concurrency 0).
Check: the command passes against a baseline taken on the same machine with the same flags.
6. Gate accuracy¶
python3 scripts/vllm/benchmarking/check_regression.py \
--mode eval \
--results-dir <DIR> \
--baseline scripts/vllm/benchmarking/baselines/eval/<config>.<task>.baseline.json
The harness runs lm_eval with --run-lm-eval (mmlu_llama, mmlu_pro, gated on exact_match) and --run-code-eval (humaneval_plus_tpu, mbpp_plus_tpu, pass@1), all through chat completions. The default tolerance is 1.5 points (EVAL_TOLERANCE overrides it). Where the baseline carries a standard error, the allowed drop is max(tolerance, 1.645 * hypot(stderr_baseline, stderr_run)), a one-sided 95% test on the difference of two runs; with a standard error on the baseline only it uses sqrt(2) * stderr_baseline, with one on the run only stderr_run.
The harness sends chat_template_kwargs: {"enable_thinking": false} by default. A template keyed on a different flag ignores it and the model reasons anyway (Kimi-K2.6 wants thinking); check the checkpoint's chat_template.jinja and set LM_EVAL_GEN_KWARGS if needed.
Check: every task with a baseline file passes. Gate any quantization or kernel change on this as well as on performance.
Troubleshooting¶
| Symptom | Cause | Fix |
|---|---|---|
| Numbers differ from a colleague's on the same config | A different experiment: prefix caching, concurrency, warmup or a recompilation check left on | Match every flag; --no-enable-prefix-caching as in the configs; VLLM_XLA_CHECK_RECOMPILATION=0 |
| TTFT fails the gate under heavy load | Queue position, not prefill speed, above the admission capacity | Compare TTFT only below \(DP \times\) max-num-batched-tokens / prompt length concurrency |
| Throughput lower than an earlier run with profiling | --profile costs about 11% TTFT and 4% throughput |
Never compare profile-on numbers with a non-profile baseline |
| Parallelism A/B shows a large difference | Different global token budgets | Compare DP (per-rank budget times \(N\)) against TP at the same total |
| A reasoning model scores low with long outputs | The template ignored enable_thinking |
Check chat_template.jinja; set LM_EVAL_GEN_KWARGS (JSON or key=value, not mixed) |
run_benchmarks.sh cannot find benchmark_serving.py |
vLLM not installed in the environment | Install vLLM-TorchTPU in the same environment |
References¶
- vLLM-TorchTPU: Benchmarking & Evaluation Guide
- vLLM-TorchTPU: Server-side capture (vllm serve)
- vLLM-TorchTPU: Optimization Work Best Practices
- vLLM-TorchTPU: Docker images
- Companion code: code/ch18_vllm/
- Chapter 17: Inference math: prefill, decode, KV cache
- Chapter 18: vLLM-TorchTPU
- Chapter 24: Performance you can defend: benchmarks, MFU, SLOs