Skip to content

Add serving benchmark harness, frozen workload and GSM8K quality check - #17

Merged
SamMausberg merged 7 commits into
mainfrom
bench/harness
Sep 30, 2026
Merged

SamMausberg merged 7 commits into
mainfrom
bench/harness

Conversation

@SamMausberg

@SamMausberg SamMausberg commented Sep 30, 2026 •

Copy link
Copy Markdown
Owner

This adds the serving benchmark harness that the baselines, the before/after comparisons and the moonshot and drafter arms run through, together with a frozen prompt set, the GSM8K quality check and the first feasibility evidence. Tuned baselines and the confirmation sweep will come in a follow-up PR.

What is here

  • bench/arms.toml, bench/arms.py: server arms as declarative launch flags (plain, MTP, DFlash), with --set/--unset/--env/--sglang-worktree overrides and lossy / require_full_graph_coverage declarations for arms that change numerics or exceed the CUDA-graph range.
  • bench/server.py: launches an arm in its own process group, waits for /health_generate, and records the command, the SGLang tree actually imported (and its git state), this repository's commit, /server_info and GPU state. It refuses to benchmark unless decode/verify CUDA graphs were captured up to capacity, prefill graphs were captured, the scheduler reports the overlap scheduler on (optionally confirmed by a py-spy stack showing event_loop_overlap), capacity was not capped by the GDN state cache, and the speculative settings and backend are the requested ones.
  • bench/sweep.py: one server launch, then closed-loop aiperf 0.13.0 over client concurrency. Per point: prefix-cache flush, one warmup wave from a disjoint pool, max(64, 8c) measured requests, /metrics deltas, log-segment stats, and foreign CPU load (it waits for other processes to use under two cores; see below).
  • bench/results.py: the paper's frontier metrics. x = mean over requests of n_i / e_i (includes TTFT); y = total output tokens / (last completion - first send). Also the decode-only rate, a steady-state throughput that excludes the drain, latency percentiles, and per-request speculative statistics from SGLang's sglext.spec_tokens_details.
  • bench/pareto.py: points.csv, frontier.csv (mean/std/min/max over repeats, Pareto flag, ratios to a baseline), launches.csv, PGFPlots .dat and a PNG.
  • bench/workloads/mixed-v2/: 1,857 prompts from pinned MT-Bench, OASST1, HumanEval, MBPP and GSM8K train revisions, split per domain into disjoint warmup, tune and confirm sets; GSM8K test is reserved for the quality check, so no workload prompt is a quality problem. bench/build_workload.py rebuilds the files byte for byte (checked).
  • bench/quality.py + bench/quality/gsm8k_test.jsonl: full GSM8K test (1,319) via sgl-eval's pipeline, thinking on, T 0.6 / top-p 0.95 / top-k 20 with a fixed seed (top-k is added to the request body because sgl-eval has no option for it and the checkpoint has no generation_config.json), and a paired comparison (accuracy delta, exact McNemar, identical answers).
  • bench/lengths.py, bench/token_map.py: natural-length and repetition-loop analysis; FR-Spec-style hot-token maps from tune-split outputs.
  • bench/campaigns/: the command sequences behind each evidence directory.
  • evidence/bench/: natural-length distribution on the (v1) tune split and the capacity/tree probes, marked feasibility-probe with per-point foreign CPU load (README has commands, flags and which rows are contaminated).

Findings so far (details in evidence/bench/README.md)

  • Decoding differs by purpose, deliberately. The throughput panel is greedy with 512 fixed output tokens: greedy is the setting speculative acceptance is usually reported at and the one the certified-head contract targets first, and the panel is about 95% natural text (3.8% of greedy thinking outputs stop and 0.7% are looping within 512 tokens). The quality check samples (thinking on, T 0.6, top-p 0.95, top-k 20, fixed seed, natural stopping): with greedy decoding a quarter of thinking outputs loop until the 16,384-token cap (maths 36%), so a greedy GSM8K score would be dominated by loop behaviour and cost several times more tokens. Sampled accuracy tests a lossless change for equality in distribution and prices a lossy one; greedy output equality is the state workstream's check.
  • Capacity is bounded by the GDN state cache (5 x 48 MB slots per request with the radix cache, plus one intermediate state per draft token), not the KV cache; plain decoding serves 1,024 concurrent requests with the radix cache off. BF16 state at 512 with MTP fails at verify-graph capture (FlashInfer workspace).
  • Draft trees (top-k 2 and 4) run on the Qwen3.5 GDN hybrid at this commit.

Validation

  • pytest tests/test_bench_harness.py: 18 passed (arm merging, log parsing and launch verification, hand-computed x/y/steady-state/acceptance on a synthetic aiperf export, Prometheus deltas, frontier dominance).
  • End-to-end on the GH200: a debug sweep, the capacity and tree probes, and a natural-stopping run completed through the harness; the launch checks pass for plain and MTP, and py-spy shows the overlap event loop.
  • pre-commit on all changed files passes, mypy included, after merging current main.

Review round 1

Fixed: README quality description; GSM8K test no longer appears in any workload split (mixed-v2 uses GSM8K train); probe evidence has status and foreign-load columns and no Pareto flags; top-k 20 is now sent; the DFlash arm holds only algorithm flags, with backend/runtime flags to be chosen once for all arms on the tuning split (the card's GDN-kernel and plan-stream settings are an explicit ablation); the quality campaign runs the plain arm twice for the identical-answer noise floor. The frontend limit is diagnosed in the next exclusive slot, before any confirmation sweep.

Limitations and open issues

  • The probes are feasibility checks, not tuned performance. The plain c=256 probe ran while another workstream's 45-core CPU job was active; its client throughput (5.6K tok/s against ~16K tok/s of server-side decode) is contaminated, and a frontend diagnostic on a quiet host is queued.
  • CPU contention from other jobs is not prevented by the GPU lock; sweeps now wait for a quiet host and record foreign load per point, but a point can still run contended after the wait limit (it is then marked in point.json).
  • pyproject.toml gains bench in the mypy file list and the repository root on pytest's path.

bench/ holds declarative SGLang server arms (arms.toml), a launcher that
records the exact command, source trees and /server_info and verifies from
the log and the scheduler's resolved state that CUDA graphs cover decode
and prefill up to capacity and that the overlap scheduler is on, an aiperf
concurrency sweep runner, the per-point result parser (paper frontier
metrics x and y, TTFT, ITL, per-request speculative acceptance from the
sglext stream extension), and a Pareto aggregator.

bench/workloads/mixed-v1 is a frozen, disjoint warmup/tune/confirm split
of 1,857 chat, code and maths prompts from pinned public datasets
(MT-Bench, OASST1, HumanEval, MBPP, GSM8K), rebuilt byte-identically by
bench/build_workload.py.

pyproject.toml adds bench to the mypy file list and the repository root to
pytest's path so tests can import the package.
bench/quality.py freezes the GSM8K test split (1,319 problems, pinned
revision, sgl-eval's answer parsing) and scores an arm with sgl-eval:
greedy, thinking on, natural stopping up to 16,384 tokens. It also compares
two runs pairwise (accuracy delta, exact McNemar test, identical answers
and generations).

bench/lengths.py summarises natural output lengths per domain, including
the share of requests that would stop before a fixed output length.
bench/token_map.py builds an FR-Spec-style hot-token draft vocabulary from
the model's outputs on the tune split and reports coverage on other runs.

The sweep now samples CPU time used by processes outside its own and the
server's sessions, waits for it to fall below 2 cores before each point and
records it: the GPU lock does not keep CPU-heavy jobs away, and the
scheduler, tokenizer manager and client are CPU-bound. The default server
memory fraction rises to 0.85 so a 5-step MTP chain fits at capacity 128.
bench/README.md documents the workflow and metric definitions.
- arms.toml gains a DFlash arm (z-lab/Qwen3.5-4B-DFlash at a pinned
  revision, block 8) with the model card's GDN kernel, piecewise-prefill
  and plan-stream settings, adapted to sm_90 (flashinfer target attention).
- The launch check knows that DFLASH has no EAGLE draft-extend graph;
  sweeps accept --no-strict for probing new algorithms.
- Sweeps can drop per-chunk usage and raw export (to separate client from
  server streaming costs) and record per-process CPU peaks of the server
  and client alongside foreign load.
- lengths.py locates greedy repetition loops. In a natural-stopping run on
  the tune split a quarter of thinking-mode greedy outputs loop until the
  16,384-token limit, so the quality check now uses Qwen's recommended
  thinking-mode sampling (T 0.6, top-p 0.95, fixed seed) instead of greedy.
- pareto.py also writes launches.csv: capacity, graph range, memory split,
  failed checks and source commits for every server launch.
torch.compile fails on Qwen3.5's residual-stream Contribution object
during piecewise prefill graph capture at bd66ce34, so the DFlash arm keeps
SGLang's default breakable prefill graph.
bench/campaigns/ holds the exact command sequences behind each evidence
directory. evidence/bench/ starts with the natural-length measurement on
the tune split (fixed 512-token panel is ~95% natural text; a quarter of
greedy thinking outputs loop to the 16,384-token limit) and the capacity
and draft-tree probes (1,024 concurrent plain requests with the radix
cache off; trees run on the GDN hybrid; BF16 state at 512 fails at verify
graph capture).
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-30T19:46:59.667979Z 63c25cf PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 63c25cfdd8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bench/sweep.py
measured = cycled(self.workload, requests)
prompts = [*cycled(self.warmup_pool, warmup), *measured]
point_dir = self.run_dir / f'r{repeat}' / f'c{concurrency:03d}'
flushed = self.flush_cache()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Abort a point when the prefix-cache flush fails

If /flush_cache remains unavailable after the retries, this stores False but proceeds with the measurement. Because each point reuses the same workload prefix, cached prompts from the preceding warmup or concurrency point can then materially inflate throughput and acceptance results; the later Pareto pipeline does not exclude points whose cache_flushed flag is false. Abort or retry the point instead of benchmarking known-contaminated cache state.

Useful? React with 👍 / 👎.

Comment thread bench/pareto.py
Comment on lines +156 to +157
for row in rows:
groups[(row['label'], int(row['concurrency']))].append(row)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Exclude unsuccessful points from frontier aggregation

When aiperf exits nonzero after producing partial artifacts, or when some requests fail, the point still reaches this grouping and its x_e2e/y values are computed from only the successful subset. Such a partial point can therefore look artificially fast and even be marked Pareto-optimal; a point with no finite metrics is also marked optimal because comparisons with NaN are false. Filter or explicitly invalidate points with request failures, OSL mismatches, nonzero aiperf status, failed cache flushes, or prompt mismatches before computing the frontier.

Useful? React with 👍 / 👎.

Comment thread bench/quality.py
Comment on lines +196 to +198
a, b = load(run_a), load(run_b)
shared = sorted(set(a) & set(b))
only_a = sum(1 for key in shared if a[key]['correct'] == 'True' and b[key]['correct'] != 'True')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject quality comparisons with different problem sets

If either quality run is partial or contains different IDs, intersecting the keys silently changes the evaluation population and can hide exactly the failed or omitted problems, producing a misleading accuracy delta and McNemar result. Since this function is presented as a paired comparison on the same GSM8K problems, require identical ID sets (and ideally the expected 1,319 IDs) rather than scoring only shared.

Useful? React with 👍 / 👎.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES

Reviewed at 396c740, whole diff. The harness is careful: the paper's metrics are implemented correctly, launches are checked from the logs, the workload is frozen and rebuildable, and the tests are hand-computed. The blocking items are three documentation and labelling fixes, one of them about the quality set's overlap with the tune split.

What I ran and checked

  • Tests and hooks. Merged into current main in a scratch worktree: pytest tests/test_bench_harness.py gives 18 passed, and the full suite 72 passed. pre-commit on the changed files passes every hook, including mypy.
  • Workload. python -m bench.build_workload --out <scratch> rebuilds warmup.jsonl, tune.jsonl, confirm.jsonl and manifest.json byte for byte.
    • The splits are disjoint by id and by text: 0 overlaps across all three pairs.
    • manifest.json pins every source revision and states the licences: MT-Bench Apache-2.0, OASST1 Apache-2.0, HumanEval MIT, MBPP CC-BY-4.0, GSM8K MIT.
  • Metrics against the paper. They match Eq. (frontier):
    • x_e2e is the mean of n_i / e_i;
    • y is the sum of n_i over (last completion - first send);
    • x_decode is a mean of per-request rates, not the reciprocal of mean TPOT, as the paper requires.
  • Metrics against aiperf 0.13.0's source (aiperf/metrics/types/*.py):
    • request_latency ends at the last content response, which is the paper's e_i;
    • inter_token_latency divides by osl - first_content_chunk_tokens when --per-chunk-usage is passed, and sweep.py passes it;
    • --use-server-token-count makes output_sequence_length the server's completion_tokens;
    • the field names request_latency, time_to_first_token, inter_token_latency, output_sequence_length and input_sequence_length are aiperf's.
  • Launch checks. These work from server.log and /server_info:
    • graph-capture begin and end lines per role, and coverage of the capacity;
    • disable_overlap_schedule: false plus the known non-overlap fallback strings, with optional py-spy;
    • the GDN-cache cap marker;
    • the speculative and backend settings.
  • Natural-length evidence. It supports the sampled quality check: 142 of 576 greedy thinking outputs (24.7 %) hit 16,384 tokens (maths 36.5 %, chat 31.8 %, code 5.7 %), and 3.8 % stop before 512.

Blocking

1. bench/README.md gives the wrong quality settings. The "Commands" block says # Quality (GSM8K test, greedy, thinking on, natural stopping). bench/quality.py and the PR body use T 0.6, top-p 0.95, a fixed seed and thinking on. Fix the comment, and give the reason there in one line: greedy thinking loops to the cap on about a quarter of prompts.

2. The GSM8K quality set overlaps the tune split, and this is not stated.

  • The overlap. The workload's maths prompts are GSM8K test problems: 43 in warmup, 192 in tune and 384 in confirm. All of them are also in the 1,319-problem quality set.
  • Consequence. Any arm whose settings are chosen on the tune split is then quality-checked partly on problems it was tuned on. That includes token_map.py maps built from tune outputs and any threshold of a lossy arm. For lossless drafter-side choices this affects only acceptance; for lossy arms it is leakage.
  • Fix, either:
    • draw the workload's maths prompts from GSM8K train; or
    • state the overlap in bench/README.md and evidence/bench/README.md, and have quality.py compare report accuracy on the problems outside the tune and warmup splits as well as on all 1,319.

3. The probe numbers are labelled as pilots only in the README, not in the committed CSVs.

  • What is there. evidence/bench/probes/points.csv and frontier.csv carry no pilot or contamination marker. frontier.csv even sets a Pareto flag on feasibility probes. The cap-plain-radix-256 point, which you describe as contaminated by a 45-core foreign job, looks like any other row. The PR body says contaminated points are marked in point.json, which is not committed.
  • Fix. Add a status column (pilot, and the foreign CPU load or contention flag per point) to both CSVs, or do not emit frontier.csv for the probes.

Suggestions (non-blocking)

  1. Top-k is not applied in the quality run. The Qwen3.5-4B snapshot at 851bf6e has no generation_config.json, so SGLang's sampling_defaults=model falls back to OpenAI defaults, and no top-k is applied. Qwen recommends top-k 20 with T 0.6 and top-p 0.95. Either set it server-side (--preferred-sampling-params '{"top_k": 20}'), or record the deviation in quality.json and the README.
  2. Noise floor for the paired comparison. Run one arm twice to get the identical-answer rate. Also check whether the fixed seed is honoured on SGLang's top-p path and in speculative verification. Without that, "identical answers" between arms has no reference point.
  3. DFlash arm confound. The DFlash arm also changes linear-attn-prefill/decode-backend to flashinfer and sets SGLANG_ENABLE_OVERLAP_PLAN_STREAM=1. Comparing it with plain and mtp therefore mixes the drafter with the GDN kernel backend. Add plain and MTP variants with the same backends (the baseline, A, B, A+B pattern), or measure the backend effect separately.
  4. Client ceiling at high concurrency. The probes show a client-side y of 4.8-6.6K tok/s at c = 512 and 1,024, against about 16K tok/s of server-side decode. Resolve the frontend diagnostic before the confirmation sweep, and flag high-concurrency points where the client, not the server, sets y.
  5. Accept length. accept_length = osl / verify_ct counts the prefill-produced first token as if it came from a verify step (about 0.2 % at 512 tokens). Say which of this and the server's spec_accept_length the plots use.

- Workload mixed-v2 draws its maths prompts from GSM8K train, so no
  warmup, tune or confirm prompt is a GSM8K test problem (the quality
  set). mixed-v1 stays in history for the feasibility probes that used it.
- The quality check now sends Qwen's full recommended thinking-mode
  sampling, including top-k 20: sgl-eval has no top-k option and the
  checkpoint ships no generation_config.json, so bench.quality runs
  sgl-eval's own pipeline with top_k added to each request body.
- Probe evidence carries a status and the foreign CPU load per point and
  no longer has a frontier or Pareto flags; the README states that the
  plain-decode probes ran during a 41-47-core foreign job.
- The DFlash arm holds only algorithm flags; GDN kernel backends and the
  plan-stream variable are tuned as shared flags for every arm, and the
  model card's settings become an explicit ablation in the probe script.
- README quality command no longer says greedy.
@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE

Re-reviewed at 64878c6. All three blocking items are resolved.

  1. Quality settings. The README's quality command now states thinking on, T 0.6 / top-p 0.95 / top-k 20, a fixed seed and natural stopping, matching bench/quality.py.
  2. GSM8K overlap. The workload is now mixed-v2, with maths prompts from GSM8K train.
    • I checked every GSM8K prompt in warmup, tune and confirm against the 1,319 quality problems: 0 overlaps.
    • python -m bench.build_workload rebuilds all four mixed-v2 files byte for byte.
    • The mixed-v1 provenance of the earlier probes and natural lengths is stated, with the commit.
  3. Probe labels. points.csv carries status = feasibility-probe and foreign_cpu_max, and frontier.csv with its Pareto flags is gone. The README names the two contaminated plain rows and says their client throughput is not used.

Also done:

  • top-k 20 is sent (EXTRA_BODY);
  • the DFlash arm now holds only algorithm flags, with backend and runtime flags shared by every arm;
  • a plain-twice run gives the noise floor.

The branch merges into main without conflicts. test_bench_harness.py gives 18 passed, and hooks pass on the changed files, including mypy.

Before the confirmation sweep:

  • resolve the frontend limit, since the client-side y sits below the server's decode rate at c ≥ 512;
  • rerun the natural lengths on mixed-v2 as the evidence README says.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant