Skip to content

Diagnose the high-concurrency streaming limit, stream every 4 tokens, record host load - #46

Merged
SamMausberg merged 11 commits into
mainfrom
bench/baselines
Sep 30, 2026
Merged

SamMausberg merged 11 commits into
mainfrom
bench/baselines

Conversation

@SamMausberg

Copy link
Copy Markdown
Owner

This PR fixes how the harness measures high-concurrency serving: it finds what limited streamed throughput, applies the fix to every arm, and makes host CPU load part of every timed run's record.

Frontend diagnosis (evidence/bench/frontend/)

Earlier probes showed clients at c=256-1,024 receiving 5.6-6.6K tok/s while the server's log reported ~16K tok/s of decode. bench/frontend.py launches one server and runs the same point with several client settings, recording for each the client's y, the server's own decode rate while the full batch runs (from its log) and the busiest processes. Plain decoding, c=256, quiet host (other processes at most 0.54 cores):

Server Client y (tok/s) Server decode (tok/s)
default (one-token chunks) default 15,363 18,022
default records-only export 16,593 18,035
default 64 aiperf workers 15,439 18,025
default non-streaming 16,510 18,020
--incremental-streaming-output default 16,178 18,014
--stream-interval 4 default 16,546 18,031
4 tokenizer + 2 detokenizer workers default 14,914 17,886
SGLANG_RUST_SERVER=1 default launch failed (wants a local tokenizer.json)
  • The 5-6K readings were CPU contention: those probes ran beside 41-47-core foreign jobs. They are labelled as contaminated in evidence/bench/README.md and never used.
  • The saturated process is SGLang's tokenizer manager (the launch_server main process: HTTP plus the OpenAI serving layer), at one full core with one-token chunks. aiperf's timing manager is also near one core.
  • Fix: stream-interval = 4 in bench/arms.toml defaults, so every arm streams every 4 tokens. The tokenizer manager drops to 0.35 cores and the client gets the non-streaming throughput. SGLang still streams the first token at once, so TTFT and the last-chunk time that define x and y are unchanged.
  • Rejected, with the numbers above: more aiperf workers (no change), separate tokenizer/detokenizer workers (worse), incremental streaming output (smaller gain).
  • The remaining gap between y and the full-batch decode rate (~8%) is the prefill of each new wave and the final drain, which y counts by definition.
  • Open items (bench/README.md): c>256 on a quiet host; the Rust server with a local tokenizer path.

Host load is now part of every timed run

bench/hostload.py samples, once per second, the CPU used by processes outside the run's own process tree (server, client, evaluator) and summarises mean, maximum, the busiest foreign processes and the run's own busiest processes.

  • Sweep points and quality runs store the summary (point.json host_load, quality.json host_load).
  • A point whose mean foreign load exceeds 2 cores gets the invalid reason host_contention and stays out of the frontier. Points still wait for a quiet host before starting.
  • The module wraps any command for other workstreams (python -m bench.hostload record --out load.json -- <cmd>) and can block until the host is quiet (python -m bench.hostload wait).
  • It replaces the session-based sampler in server.py, which missed servers that start their own session.

Committed timed points re-examined

The frontend points ran with at most 0.54 foreign cores. The two plain-decoding probe rows predate load recording and ran beside a 41-47-core job; the README labels them contaminated. The MTP and tree probes ran at 0.19-0.39 foreign cores. The natural-length run (24 foreign cores) is a length measurement, not a timing, and is labelled so.

Also here

  • bench/sweep.py gains --no-streaming and --aiperf-workers (diagnostic use) and records the server's full-batch decode rate from its log on every point.
  • bench/campaigns/frontend_diagnostic.sh runs the diagnosis, including a 20-problem quality-pipeline smoke. Result of the smoke: 18/20 correct, mean 5,264 completion tokens, 2 of 20 at the 16,384-token cap even under sampling.
  • A test for the repetition-loop detector.

Validation

  • pytest tests/test_bench_harness.py: 25 passed. Tests cover the process-tree exclusion, the contention summary, the host_contention invalid reason and the loop detector.
  • pre-commit passes on all changed files.
  • The diagnostic ran end to end on the GH200 (runs listed in evidence/bench/frontend/launches.csv).

bench.frontend launches one server and runs the same load point with
several aiperf client settings (per-chunk usage off, records-only export,
more workers, non-streaming). Every point now also records the server's
own decode rate at full batch from its log, and the client settings used,
so the client-observed throughput can be compared with what the GPU
sustained and a saturated process is visible in the CPU peaks.
…aselines

# Conflicts:
#	tests/test_bench_harness.py
With one-token chunks SGLang's tokenizer-manager process saturates one core
and limits plain decoding at high concurrency. At c=256 on a quiet host the
client saw 15.4K tok/s against 18.0K of server-side decode; with
--stream-interval 4 the process drops to 0.35 cores and the client sees
16.5K, as with a non-streaming client. The first token is still streamed at
once, so TTFT and the last-chunk time behind x and y are unchanged.
At c=256 on a quiet host the tokenizer-manager process saturates one core
with one-token chunks; streaming every 4 tokens restores the non-streaming
throughput. The earlier 5-6K tok/s probe readings were CPU contention.
bench/hostload.py samples, once per second, the CPU used by every process
outside the run's own process tree (server, client, evaluator), and
summarises mean, maximum, the busiest foreign processes and the run's own
busiest processes. Sweep points and quality runs store the summary; a
sweep point whose mean foreign load exceeds 2 cores gets the invalid
reason host_contention and stays out of the frontier. Points still wait
for a quiet host before they start. The module also wraps any command
(python -m bench.hostload record --out load.json -- cmd ...) and can block
until the host is quiet, for other workstreams' timed runs. It replaces
the session-based sampler in server.py.
@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-30T21:44:48.333258Z e965077 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: e9650777c4

ℹ️ 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/campaigns/frontend_diagnostic.sh Outdated
Comment on lines +14 to +16
fe --arm plain --label fe-plain --variants default records-only workers-64 non-streaming
fe --arm plain --label fe-plain-incremental --set incremental-streaming-output=true --variants default
fe --arm plain --label fe-plain-interval4 --set stream-interval=4 --variants default

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 Restore the one-token control in the diagnostic

When this campaign is rerun, --arm plain already inherits stream-interval = 4 from the newly changed bench/arms.toml, so the fe-plain control on line 14 and the explicit interval-4 treatment on line 16 use the same server setting. The incremental and worker comparisons likewise no longer match the documented one-token baseline, meaning a fresh run cannot reproduce the experiment that justified changing the default. Explicitly set stream-interval=1 for the control-side runs.

Useful? React with 👍 / 👎.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES

Reviewed head e965077 (0 behind main). The diagnosis is sound, the stream-interval claim holds in SGLang's code at the pin, and the host-load sampler excludes the run's own processes. One Codex comment on this PR is correct and not yet addressed, so it blocks.

Blocking

B1. The diagnostic campaign no longer has a one-token control (bench/campaigns/frontend_diagnostic.sh:14-17, Codex P2).

  • What changed. bench/arms.toml now sets stream-interval = 4 for every arm. A rerun of this campaign therefore gives fe-plain (the control), fe-plain-incremental and fe-plain-workers an interval of 4, the same setting as the fe-plain-interval4 treatment.
  • Consequence. The experiment that justifies the new default cannot be reproduced from the committed script.
  • Fix. Add --set stream-interval=1 to the control-side runs: fe-plain, fe-plain-incremental, fe-plain-workers and fe-plain-rust, plus fe-mtp if it is meant as a one-token comparison. Keep the explicit --set stream-interval=4 on the treatment.

Checked and correct

  • The stream interval leaves TTFT and last-chunk time unchanged by construction.
    • At the pin, scheduler_components/output_streamer.py:428-446 sends a streaming request's output when len(output_ids) % stream_interval == 1 for intervals above 1, so the first token goes out at once. It always sends at finish.
    • For speculative arms, len(output_ids) jumps by the accept length, so chunks get coarser but the first and the final chunk still go out immediately. Measured TTFT p50 is 355 ms with an interval of 4, against 375 and 354 ms for the two default runs.
    • x and y as the paper defines them (TTFT and the last-chunk time) are unaffected. Only chunk-gap statistics such as ITL percentiles change meaning.
  • The sampler excludes the run's own process tree.
    • The tree is built from parent pids, and the server is Popen(..., start_new_session=True), still a child of the sweep. aiperf and sgl-eval are children too.
    • I ran python -m bench.hostload record around a command that starts three start_new_session=True CPU burners. They appear under own_peak_cores and not in the foreign list. The foreign list held only the host's other jobs at the time (a SGLang server, pytest).
    • The committed frontend points (old session sampler) also list the scheduler, launch_server, the detokenizer and aiperf's timing manager as own.
  • Sampler overhead is negligible. A /proc scan of 830 processes takes 16 ms of CPU, so a 1-s sample costs 0.034 cores, spent in the sweep process, which is not on the timed path.
  • Table numbers. Every y and server-decode figure in the README table matches frontend/points.csv and frontend_summary.json. The two diagnostic rows marked "prompts differ from the workload prefix" are explained (the records-only and non-streaming exports cannot be checked) and kept out of the frontier.
  • Contaminated probes are not used in the paper. It cites evidence/bench/probes/ only for what launches (Section 9) and quotes no probe throughput. The moonshot README calls those client numbers contaminated too.
  • Tests, hooks and attribution. tests/test_bench_harness.py passes (25 tests), pre-commit passes on all changed files, and there are no AI co-author lines.

Suggestions (not blocking)

  • Blind spot in the sampler. It counts only processes present in both snapshots, from their own utime + stime. A foreign workload of many short-lived processes (a build, pre-commit runs, xargs -P) is undercounted: processes that start and end within a second are missed, and reaped children's CPU moves to the parent's cutime, which is not read.
    • A robust measure is total busy CPU from /proc/stat minus the own tree's CPU. Keep the per-process ranking for the report.
    • A reused pid can also produce a negative delta. Compare the start time (stat field 22), or clamp at zero.
  • The 2-core threshold is conservative but not derived from a measured sensitivity. The host showed 2.1-4.6 foreign cores from other agents while I tested. A short measurement of y against injected foreign load would justify it, or show that it will invalidate many confirmation points on this shared machine.
  • Contaminated probe rows. They are marked only in the README. An invalid_reason (or status) in evidence/bench/probes/points.csv would keep them out of any later aggregation automatically.
  • Single runs. Label the frontend table as single runs per row. The two default-server runs (15,363 and 15,439 tok/s) give a sense of the spread.
  • Hard-coded path. The campaign sources ~/verified-progress/scripts/sglang_env.sh. Resolving it from the script's own location, as Codex asked of Profile SGLang decode and MTP on GH200: attribution, head baseline, bytes per step #13 and Real-head replay: head-input capture, transport and self-evidence bounds #16, keeps it working from another checkout.
  • For the paper and other workstreams. Once confirmation runs use an interval of 4, the serving protocol in the paper should say so. Earlier single-run lever results (evidence/moonshot/lever_sweeps_quick.csv, FP16 state at c = 128, 16.7K tok/s) ran with one-token chunks near the roughly 16K chunks/s limit found here, so their gains may be understated. Their reruns should use the same interval as the baseline.

- Foreign load is now the host's total busy CPU time from /proc/stat minus
  the run's own process tree, so processes that start and exit within a
  sampling interval (builds, hooks, compiles) are counted. The per-process
  lists remain as diagnostics. Test: a short-lived burner outside the tree
  is counted although it never appears in a per-process snapshot.
- The frontend diagnostic pins --stream-interval 1 on its one-token control
  runs, since the arms now default to 4; the failed MTP comparison is
  dropped from it.
- Campaign scripts source the repository's sglang_env.sh relative to their
  own location; the 2-core contention threshold is documented as heuristic.
@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE

This re-review covers head 29db238. B1 and Codex's P2 are fixed.

  • B1. frontend_diagnostic.sh pins --set stream-interval=1 on every one-token control run (fe-plain, -incremental, -workers, -rust) and keeps --set stream-interval=4 on the treatment, so a rerun reproduces the diagnosis. The MTP comparison that had failed is dropped.
  • Suggestions taken.
    • Foreign load is now host busy CPU from /proc/stat minus the run's own tree, so short-lived foreign processes are counted. The new test runs a burner that never appears in a per-pid snapshot and sees it counted.
    • Negative per-pid deltas from pid reuse are clamped.
    • The 2-core threshold is documented as a heuristic, next to the measured idle background of 0.3-0.6 cores.
    • The frontend rows are labelled as single, unrepeated points.
    • Every campaign sources sglang_env.sh relative to itself.
  • Tests and hooks. tests/test_bench_harness.py passes (26 tests), and pre-commit passes on the changed files.

Two notes, not blocking:

  • Own processes that exit within an interval count as foreign. The own tree is subtracted only for processes alive at both ends of an interval, so an own process that starts and exits within one second, or a reaped child of aiperf or the server, is counted as foreign. This errs toward invalidating a point, which is the safe direction. If it starts to trip on quiet hosts, sum the own tree's cutime + cstime deltas as well.
  • The new dflash_tuning.sh passes --no-strict, so tuning points can come from launches that failed a required check (for example missing graph captures). Unless a failure is expected and read from launches.csv, choosing the block size from such points risks tuning on an invalid launch. Run it strict, or exclude launches with checks_failed when choosing.

@SamMausberg
SamMausberg merged commit e41d52c into main Sep 30, 2026
SamMausberg added a commit that referenced this pull request Sep 30, 2026
…nel contract

The paper now argues in dependency order: setting and what the stock engine
computes, the five contracts and the R-stock gap and interval theorems, the
certified low-precision head with its measured candidate sets and fallback
shares, sampled decisions, transport and its measured failure, exactness under
speculation, the stack, drafting and repair hypotheses, the serving protocol,
related work, and a discussion that merges the hypothesis and failure tables.
Secondary derivations, untested mechanisms, engine notes, CPU evidence,
reproduction and attribution move to appendices. Evidence paths, pull request
numbers and pending work move to an evidence register and a development record
(Appendix A); the text cites [En] for committed evidence and [pending Dn] for
designed work, with the scientific status in the prose.

Integrates merged evidence: H2 on DFlash-4B (#35) and MTP-4B (#47), the
overlapped roofline (#44), the frontend diagnosis (#46), the fifth contract
witness (#41) and the precision counts after #43. Folds in the Codex items on
#21 (quantiles over all rows), #32 (pooled tau, GSM8K series) and #36.

Typography: Charter text, a plain title block with the repository URL,
greyscale-safe figures, a new mechanism figure (Figure 1) replacing three
overlapping flowcharts, a drift figure and transport table, two-panel
candidate and acceptance figures, and tables reorganized instead of shrunk.
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