nemo_automodel.components.speculative.bench_vllm
nemo_automodel.components.speculative.bench_vllm
Offline acceptance / speedup benchmark for a trained drafter served by vLLM.
This is the vLLM companion to bench_sglang: the same chat-completions
workload machinery (which it imports), with the acceptance statistics read from
vLLM’s Prometheus /metrics endpoint instead of SGLang’s /server_info.
It covers every drafter serve_vllm can launch — EAGLE-3, P-EAGLE, and the
DFlash family — and reports:
accept_length— mean tokens emitted per target verification step, including the one guaranteed bonus token:1 + num_accepted_tokens / num_drafts.acceptance_rate— fraction of proposed draft tokens accepted:num_accepted_tokens / num_draft_tokens.output_throughput_tok_s— measured decode throughput (output tokens per wall-clock second).speedup— optional: throughput divided by the same workload’s throughput against a--baseline-serverrunning without speculation.
The spec-decode counters (vllm:spec_decode_num_drafts_total,
vllm:spec_decode_num_draft_tokens_total,
vllm:spec_decode_num_accepted_tokens_total) are snapshotted before and after
the workload and differenced, so — unlike SGLang’s server-cumulative
avg_spec_accept_length — the numbers cover exactly this benchmark’s
requests even on a server that has already handled other traffic.
Typical usage (after serve_vllm launches the drafter on port 8000):
python -m nemo_automodel.components.speculative.bench_vllm
—server http://localhost:8000
—model Qwen/Qwen3-8B
—input-data Aeala/ShareGPT_Vicuna_unfiltered
—num-prompts 64 —concurrency 16 —max-new-tokens 256
Add --baseline-server http://localhost:8001 (a second server started
without --speculative-config) to also report the end-to-end speedup.
vLLM is intentionally NOT a dependency of this script — it talks to the server
over HTTP, so only aiohttp is required (already pulled in by the project).
The server itself must be running separately; see serve_vllm.
Module Contents
Classes
Functions
Data
API
One snapshot of vLLM’s cumulative spec-decode counters.
Return the counter increase since before (clamped at zero per counter).
Mean tokens per verify step incl. the bonus token: 1 + accepted / drafts.
Fraction of proposed draft tokens accepted: accepted / draft_tokens.
GET <server>/metrics and parse the spec-decode counters; None on failure.
Parse the spec-decode counters out of a Prometheus exposition payload.
Values are summed across label sets (multiple engines / model labels), and
None is returned when the drafts counter is absent — i.e. the server is
not running with speculative decoding.
Async driver: compute the benchmark summary and report it. Returns an exit code.
Validate args, run the workload(s), and return the metrics dict.
Returns None when no usable prompts were loaded (the caller’s cue to
report a failure without raising — a bad --num-prompts/etc. value is a
real programming error and still raises via _validate_workload_args).
Split out of _run so bench_sweep can drive one dataset at a time
without the printing / --output-json side effects below.
Assemble the metrics dict reported to stdout / --output-json.
CLI entry point. Parses argv and returns the process exit code.