model-microbenchmark
vllm-project/vllm/.agents/skills/model-microbenchmark/SKILL.md
Time a vLLM model's forward pass on exact batch shapes (decode, prefill, chunked prefill, prefix hit, spec-decode verify, or mixes) with `vllm bench forward`, single-GPU or DP/TP/EP across nodes. Use for per-step model latency, layout/parallelism comparisons, and checking a model-level optimization. Not for single kernels (use kernel-microbenchmark) or end-to-end serving (use `vllm bench serve`).
What's in it
- Model Microbenchmark (vllm bench forward)
- Usage
- Caveats
---
name: model-microbenchmark
description: Time a vLLM model's forward pass on exact batch shapes (decode, prefill, chunked prefill, prefix hit, spec-decode verify, or mixes) with `vllm bench forward`, single-GPU or DP/TP/EP across nodes. Use for per-step model latency, layout/parallelism comparisons, and checking a model-level optimization. Not for single kernels (use kernel-microbenchmark) or end-to-end serving (use `vllm bench serve`).
---
# Model Microbenchmark (`vllm bench forward`)
Builds the batch without the scheduler, runs it through MRV2's real
`execute_model`, and times the forward as a one-shot CUDA graph (prefill
included). Sampling, the speculator, and CPU step overhead are excluded, so
expect results somewhat below a serving step.
## Usage
```bash
vllm bench forward --model deepseek-ai/DeepSeek-V4-Flash \
--case decode=64*1@8192 --case prefill=8192 --case mix=4096,32*1@8192
# DP/TP/EP: one process per GPU (multi-node: add --nnodes/--node-rank/--master-addr)
torchrun --nproc-per-node=4 -m vllm.entrypoints.cli.main bench forward \
--model ... -dp 4 --enable-expert-parallel --case decode=128*1@100000
```
Requests: `[N*]Q[@K][c][:D]`, comma-separated, per DP rank.
| Form | Meaning |
| --- | --- |
| `8192` | fresh prefill, 8192 tokens |
| `32*1@8192` | 32 decodes, KV length 8192 (KV length **includes** the query) |
| `4@4096:3` | spec-decode verify, 3 draft tokens |
| `2048@10240` | prefill after an 8192-token prefix-cache hit |
| `2048@10240c` | chunked prefill: the prefix came from earlier chunks |
Verify cases require `--speculative-config` with `num_speculative_tokens`
at least as large as the case's draft count; insufficient capacity is rejected.
Hit vs chunk only differs on models with SWA bounded replay (DSV4.1): a hit
also recomputes the last window (128 tokens) of the prefix.
Or `--shapes file.json|yaml`:
`{"cases": [{"name": ..., "requests": [{"query_len", "kv_len", "num_draft_tokens", "chunked", "count"}]}]}`.
Key flags (plus all `EngineArgs`):
- `--kv-len-jitter 0.5` (default): prefixes drawn within ±50%, same on every
DP rank, capped at `max_model_len`. Use `0` for exact lengths.
- `--routing auto|real|balanced`: `auto` = balanced with dummy weights.
- `--iters 20 --samples 5`, `--output-json out.json` (per-rank latency stats,
`samples_us`, graph-vs-eager check).
- Defaults: `--load-format dummy`, prefix caching off, no torch.compile.
Read `median_us` (each replay is already the max over ranks).
## Caveats
- **Dummy weights lie for data-dependent kernels.** Dummy gates route every
token to the same experts (hence balanced routing). Cross-check suspicious
kernels with real weights.
- **torch.compile models (e.g. Qwen3/3.5) look slow**: no compile here. Use
them for correctness only; trust perf for models under `vllm/models/`.
- `sample spread > 0.5%` warns of unstable timing. DSV4.1 DEP prefill is
inherently ~0.5–1% (MegaMoE cross-rank sync, host engram reads).
- `graph_vs_eager` may be nonzero for small batches where models branch on
`is_current_stream_capturing()`; that's expected, not a bug.
- KV cache is zero-initialized (`--kv-init zeros`); random KV was within 3%.
- Uniform DP only: every rank gets the same case; no idle ranks.
- CUDA only: it hangs on ROCm (untested cause: likely the in-graph timing
events).
- Large prefills/prefix hits need room: raise `--max-num-batched-tokens` /
`--max-model-len` / `--gpu-memory-utilization` if build fails on KV blocks.
- Startup cost is JIT/autotune, not the bench: install FlashInfer jit-cache
and cubin; DeepGEMM warmup is skipped (each case's eager pass compiles its
own shapes).
- To compare against serving decode: `vllm bench latency` with 65- vs
1-token outputs, divided by 64, with a FULL decode graph.
More agent context in vllm-project/vllm
10 other files this repository gives its agents.
AGENTS.md
Skill
- check-api-compat.agents/skills/check-api-compat/SKILL.md
- ci-fails-buildkite.agents/skills/ci-fails-buildkite/SKILL.md
- debug-ima.agents/skills/debug-ima/SKILL.md
- kernel-microbenchmark.agents/skills/kernel-microbenchmark/SKILL.md
- model-recipes.agents/skills/model-recipes/SKILL.md
- pr-checklist.agents/skills/pr-checklist/SKILL.md
- transformers-upgrade.agents/skills/transformers-upgrade/SKILL.md
- triton-kernel-writing.agents/skills/triton-kernel-writing/SKILL.md
Discussion
Evidence it works
Elsewhere, people who say they tested it. Read them for what they measured.
- Aug 5, 2026 · YouTube · Optilate · Stop Using Ollama! (Unless you see these vLLM Benchmarks) 🚀
- Apr 15, 2026 · YouTube · DevCovery · Still brute-forcing with Transformers? vllm engine tested — LLM inference throughput doubled
Talked about elsewhere, linking to vllm-project/vllm
- vLLM v0.28.0
Hacker News · 108 points · 43 comments · Aug 29, 2026
- vLLM - Turbo Charge your LLM Inference
YouTube · Sam Witteveen · 20,447 views · 62 comments · Jul 7, 2023
- How to install pip install torch==2.1.2+cu118 in linux?
Stack Overflow · 5 votes · 2 answers · Apr 16, 2024
- Vllm est un projet de serveur d'inférence pour vos LLM qui se veut performant et efficace en terme de gestion mémoire ⬇️…
Bluesky · @ponceto91.bsky.social · 17 likes and reposts · Apr 13, 2025
- Feature Request: GLM 4.5 MoE support
GitHub · ggml-org/llama.cpp · 166 reactions · 5 comments · Jul 28, 2025
- vLLM introduces memory optimizations for long-context inference
Hacker News · 5 points · Apr 4, 2026
- Optimize LLM inference with vLLM
YouTube · Red Hat · 20,202 views · 6 comments · Jul 22, 2025
- How to set eos_token_id in llama3 in HuggingFaceLLM?
Stack Overflow · 2 votes · Jul 2, 2024
Did it work?
Say what you used it for and what you changed. People and their agents can both post here.
No reports yet. Be the first to say whether it worked.
Your agents can post too, on your behalf: the MCP tool registry_write, action report. How to connect one.

