nemo_automodel.components.speculative.bench_common
nemo_automodel.components.speculative.bench_common
Engine-agnostic workload machinery shared by the drafter benchmarks.
bench_sglang and bench_vllm drive the same OpenAI-style
chat-completions workload and report the same throughput/speedup numbers; they
differ only in how each engine exposes its acceptance statistics (SGLang’s
/server_info vs vLLM’s Prometheus /metrics). This module holds the
shared layer: the prompt loader, the timed HTTP workload runner, and the
throughput / speedup / CLI-bounds helpers.
Module Contents
Classes
Functions
Data
API
Aggregate timing for one workload pass against a server.
POST one chat completion and return its completion_tokens (0 on no usage).
Normalize a raw (non-chat) dataset field into a single prompt string.
Accepts a plain string, or a non-empty list of strings (the first entry is
used — e.g. MT-Bench’s two-turn prompt column, reduced to its first
turn). Returns None for anything else, or a blank/whitespace-only string.
Load up to --num-prompts chat prompts.
Reads from --prompt-column when set (a raw single-turn text field,
wrapped into a fresh user message — for datasets like GSM8K/HumanEval that
are not chat-messages-shaped), else from --messages-column (an existing
OpenAI-messages list, trailing assistant turn dropped). prompt_column is
an optional attribute — callers that only ever use messages_column
(the two single-dataset benchmarks’ own argparse.Namespace) need not set it.
Return the server root URL without a trailing slash or /v1 suffix.
Chat completions live at <root>/v1/chat/completions and the engine’s
stats endpoint at its own root-relative path; accept either
http://host:port or the OpenAI-style http://host:port/v1 so the
flag is forgiving.
Output tokens per wall-clock second, or None if nothing was timed.
Print a benchmark summary as JSON, optionally also write it to output_json.
Shared tail of bench_sglang/bench_vllm’s _run: returns exit code
1 with nothing printed when summary is None (no usable prompts
were loaded), else 0.
Send every prompt through <server>/v1/chat/completions and time the pass.
Return spec / baseline output throughput, or None if not computable.
Reject invalid values of the CLI flags every benchmark shares.