Repository navigation
chore: add a serving comparison harness against vLLM and SGLang - #3677
Merged
Merged
Conversation
Add scripts/bench/serving_compare.py, a standard-library driver that starts mlxcel-server, vLLM or SGLang from per-engine command templates (or uses an already-running server with --external), waits for the health endpoint, measures every shape and concurrency cell with the same `vllm bench serve` client (one discarded warmup, 16 prompts at c=1 and 4*c otherwise, random dataset, --ignore-eos, one seed), and stops the server with SIGTERM then SIGKILL. It keeps the raw client JSON per cell, prints the epic #3671 table layout, and appends one CSV row per comparable cell. A cell with a failed request, fewer output tokens than num_prompts * output_len, or, for mlxcel, no decode steps in /metrics prints NOT COMPARABLE and writes no row. A missing client is a clear error with exit status 2. scripts/bench/serving_compare.md documents the isolated venv setup, the server commands and the guard; docs/benchmarks.md names the script as the method for serving claims in CUDA performance PRs; bench_results/ is gitignored. The guard and command builders are covered by scripts/bench/serving_compare_test.py, re-exported from tests/ so CI discovery runs it. Closes #3663
The guard reads mlxcel's /metrics, which mlxcel-server serves only with --metrics, so the default command now passes it. An explicit --parallel 32 splits --ctx-size 65536 into 2048-token slots, so a shape that does not fit one slot (8192x128) raises --ctx-size to 32 times the next power of two, as vLLM's --max-model-len already was.
Review fixes for the serving comparison harness. stop_server now signals and waits on the whole process group, so vLLM and SGLang children that outlive the leader are SIGKILLed, and it ignores further interrupts so a second Ctrl-C cannot skip the SIGKILL. The warmup uses seed + 1 so it does not pre-cache the measured prompts. Every server gets --host, CSV rows are appended per cell with machine paths stripped from server_args, an aborted engine makes the exit status 1, HTTP protocol errors no longer crash a health or metrics probe, and the command tests build expected paths with venv_bin so they pass on Windows.
mlxcel-server rejects a value flag given twice, so --mlxcel-args could not change --ctx-size or --parallel. A flag set in the *-args options now replaces the template's flag and value; --host and --port stay with the driver, which probes them.
On GB10 the host OOM killer took mlxcel-server during the first 31B cell, and the driver went on to run every remaining cell against a closed port. It now checks the launched server after each cell and aborts that engine with the exit code and the server log tail.
datetime.UTC exists only from Python 3.11; use datetime.timezone.utc so the tests run on older interpreters in CI.
The random dataset in `vllm bench serve` draws prompts in order from the seed alone, and the harness keeps one server up across cells. With one measured seed per shape, c=1's prompts were the first 16 of c=8's and c=8's the first 32 of c=32's, and each 8192-token prompt began with the 512-token prompt at its index, so prefix caches could serve half of the c=8 and a quarter of the c=32 requests. `cell_seed` now derives one seed per (shape, concurrency) cell from `--seed`, and the warmup takes the next value. Seeds stay identical across engines. A unit test pins distinct seeds across the ladder; the docs and the technical report describe the change.
inureyes
marked this pull request as ready for review
December 2, 2026 02:52
This was referenced Dec 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
scripts/bench/serving_compare.py, one command that reproduces the cross-engine serving table of epic #3671. For each--engine mlxcel|vllm|sglangit starts the server from a per-engine command template (or benchmarks a running server with--external URL), waits for the health endpoint, measures every shape and concurrency cell with the samevllm bench serveclient, and stops the server. It keeps the raw client JSON per cell, prints the table in the epic's column layout, and appends one CSV row per comparable cell.What is in it
scripts/bench/serving_compare.py: standard-library driver. Default ladder--concurrency 1,8,32,--shapes 512x128,8192x128; per cell one discarded warmup (--num-prompts c), then 16 prompts at c=1 and4 * cotherwise,--backend openai-chat --endpoint /v1/chat/completions --dataset-name random --ignore-eos, a per-cell client seed derived from--seed(identical for every engine). Server commands are the issue's templates, extendable with--mlxcel-args,--vllm-args,--sglang-argsand pointed with--mlxcel-bin,--vllm-venv,--sglang-venv,--client.--dry-runprints every server, health, version, warmup and measured client command without launching anything.comparability_reason): a cell with any failed request, fewer thannum_prompts * output_lenoutput tokens (EOS leaked), or for mlxcel no movement ofmlxcel_batch_decode_steps_totalin/metrics(or/metricsunavailable) printsNOT COMPARABLE: <reason>and writes no CSV row. A non-zero client exit marks the cellFAILED.OUT_DIR/<engine>_server.log,--startup-timeout900 s, port-in-use refusal before launch, SIGTERM to the group then SIGKILL after 30 s, also on Ctrl-C and SIGTERM. The whole group is waited on (vLLM and SGLang children can outlive the leader) and further interrupts are ignored while stopping. A server that exits during a cell aborts that engine with its log tail instead of running the remaining cells against a closed port. An aborted engine or any unreported cell makes the exit status 1.--out-dir(defaultbench_results/serving/<UTC timestamp>/, now gitignored), Markdown table on stdout, rows appended per cell to--csv(defaultdocs/benchmark_results/serving_compare.csv) with the issue's 19 columns.server_argsis stored with repo-relative and~paths.scripts/bench/serving_compare.md: venv install for vLLM, SGLang and mlx-lm, the single-client rationale, server templates, cells, outputs, guard rules, gpu-lock wrapping.docs/benchmarks.md: new section "Serving claims in CUDA performance PRs" naming the script as the method.scripts/bench/serving_compare_test.py(guard on synthetic result JSON, command builders, flag override, process-group stop, CSV columns, table layout, dry-run, missing-client error), re-exported bytests/test_bench_serving_compare.pyso CI'sunittest discover -s testsruns them.Deviations from the issue text
--metrics: mlxcel-server serves/metricsonly with that flag, and the guard reads it.--host(default 127.0.0.1), sovllm servedoes not bind all interfaces.cell_seed, from--seed, shape and concurrency), identical for every engine. The random dataset draws prompts in order from the seed and the server stays up across cells, so a single seed would nest prompt sets (c=1's 16 prompts are the first 16 of c=8's, c=8's the first 32 of c=32's, each 8192-token prompt starts with the 512-token prompt at its index) and a warmup on the measured seed would pre-send measured prompts; prefix caches would serve those repeats. Found in the technical-report pass and fixed before merge.--max-model-len 8192and mlxcel keeps--ctx-size 65536when every shape fits, which covers the acceptance command (--shapes 512x128). The default8192x128shape does not fit 8192 nor the 2048-token per-slot windows of--parallel 32 --ctx-size 65536, so it raises them to the next power of two (16384 and 524288).--*-argsreplaces the template's flag, because mlxcel-server's clap parser rejects a repeated value flag (--ctx-sizetwice is an error).--hostand--portare refused there.vllmexecutable exits 2 with the install pointer.Verification (GB10, spark-101)
python3 -m py_compile scripts/bench/serving_compare.py: OK.python3 -m unittest scripts/bench/serving_compare_test.py: 19 tests OK;python3 -m unittest discover -s tests -p 'test_bench_serving_compare.py': OK.--dry-run --engine mlxcel --engine vllm --engine sglang --model nvidia/Gemma-4-31B-IT-NVFP4: prints all commands, launches nothing.uv pip install vllmworked on this aarch64 host in an isolated scratchpad venv (vLLM 0.34.0, torch 2.14.0, the same vLLM version as the B200 reference run), andvllm bench serveran as the client against mlxcel-server. No vLLM or SGLang server was run here.cargo build --release --features cuda --bin mlxcel-server, thengpu-lock run --tag serving-compare -- python3 scripts/bench/serving_compare.py --engine mlxcel --model models/gemma-4-e2b-it-4bit --concurrency 1,8 --shapes 512x128,8192x128(exit 0, 4 CSV rows, every cell passed the guard; for example the c=1 512x128 JSON has completed 16, failed 0, total_output_tokens 2048 = 16 x 128):These are single runs on a shared host and are a functional proof of the driver, not a performance baseline.
2b3c5f4ad) completed a short run on the same host,--concurrency 1 --shapes 512x128on gemma-4-e2b-it-4bit: exit 0, one CSV row, TPOT 15.11 ms, TTFT 667.4 ms (the host was loaded by unrelated compile jobs).oom_score_adj 1000, so it is the victim whoever consumes memory) partway through the c=1 cell, afterNVRM ... NV_ERR_NO_MEMORYkernel lines started about a minute earlier; c=1 was running at about 170 ms per token. In the retry it was killed during warmup, with 168 NVRM lines in that window and about 45 GB of anonymous memory held host-wide. Host memory pressure from unrelated jobs and--parallel 32 --ctx-size 65536not fitting the 31B on GB10 are both open readings. The guard did its job on the first attempt (c=1:NOT COMPARABLE: 3 of 16 requests failed, no CSV rows), and that run is why the driver now aborts an engine whose server dies mid-run; the retry exercised that path (exited with code -9 before it became healthy, exit 1). A third attempt was not made, because repeated NVRM out-of-memory events precede host freezes on GB10. The 31B baseline needs an idle, freshly booted host.Deferred
Closes #3663