Repository navigation
Moonshot P4b: explain the 127-request plateau; amend to a running limit of 129 - #123
Conversation
At the pinned engine a prefill pass that carries a chunked request's tail stops admitting one request early: that request is in can_run_list and already holds its req_to_token row, while running_bs leaves it out, so it is counted twice. batch_is_full then stays set until a request finishes, so every synchronised P4b wave stopped at 127 running with one queued. admission_plateaus.py checks this against each wave's plateau in the scheduler log. The p4_pools lever now pins --max-running-requests 129 at concurrency 128 (KV and mamba pins unchanged), and the validator's pinned constant follows.
The third P4b attempt (admission preflight 20261001T115146Z) plateaued at 127 running with 132 mamba slots and KV usage 0.40, so neither pool was the limit. The cause is a double count of a chunked request's tail in SGLang's admission check; all 56 wave plateaus of the three attempts match it (p4_admission_plateaus.csv, from admission_plateaus.py at f84ef6c). The amendment, declared before any rerun, sets --max-running-requests 129 at concurrency 128 and keeps the other pins; the preflight runs alone first and must show 128 running in both arms.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fc76655f8b
ℹ️ 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".
| inferable = [row for row in rows if row['continuation'] != ''] | ||
| mismatched = [row for row in inferable if row['plateau_observed'] != row['plateau_predicted']] |
There was a problem hiding this comment.
Fail when expected plateaus are absent
When a supplied server log contains no matching queued decode plateau, or every plateau has a non-inferable continuation, it contributes no inferable row; the script can consequently print 0 of 0 as predicted, write an empty or incomplete CSV, and exit successfully. This also lets one unparseable server log disappear while other logs provide rows, so the evidence command does not actually guarantee its claim that every wave was checked. Require at least the expected plateau count per log, and reject non-inferable rows for these synchronized P4b runs, before reporting success.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 591d060. The script now prints one count line per server log and exits 1 if any log has fewer than --min-plateaus plateaus (default 1), if any plateau's continuation is not inferable (outside the synchronised-wave scope), or if any plateau differs from the prediction. The evidence command passes --min-plateaus 4; every one of the 12 logs has 4 or 5 plateaus, and the regenerated CSV is byte-identical. Command-line tests in tests/test_moonshot_admission_plateaus.py cover a log without plateaus, a count below the minimum, and an out-of-scope plateau.
|
Verdict: REQUEST CHANGES Review of the exact head fc76655 ("Record the 127-plateau cause and amend P4b to a running limit of 129"). The diagnosis is careful and, as far as I can check it, right. The amendment is dated before any further run. What blocks is an unanswered Codex comment and two small consistency fixes. What I verified
Blocking
Suggestions (non-blocking)
|
…eded-rank items Bounded-range sampling is the paper's Proposition "Bounded logit error" (app_sampling.tex), so the theory item is done (PR #21, #49, #53; Codex and the integrator's review). New active items from the integrator: round the Hopper accumulation constant up to cover its derived value and rerun what used it, and state that seeded top-k/top-p at the pin keys noise by sorted rank. M1 and P4 record #123's explanation of the 127-request plateau as the status of an open PR.
admission_plateaus.py exited 0 when a log yielded no plateau or only non-inferable ones, so an unparsed log could vanish from the evidence. It now prints one count line per server log and exits 1 if a log has fewer than --min-plateaus plateaus (default 1), any plateau's continuation is not inferable, or any plateau differs from the prediction (Codex review of #123). Also: the test is renamed to the tests/test_moonshot_* convention and covers the command line; validate_p4_ab.py's docstring names the 655,360-token KV pin; the script index lists admission_plateaus.py.
Section 4 now records, for the eight files that had no command, the two exclusive-lock jobs that produced them: their commands, repository and engine commits, run times, and how each committed file relates to its raw output (six byte-identical JSON copies, two CSVs that regenerate byte for byte with summarise.py on main). The run_p4_timed.sh citation, a script outside git, is replaced by a description of that job. Corrections: the setup line named patches 0001-0007 for everything, and 2c said the aborted one-batch P4 A/B ran on 0001-0009; it ran on 0001-0008 (engine 1101be8c5f). 2c also notes that all 56 plateaus had a chunk tail, so the amended preflight is the discriminating test, and the plateau command now requires four plateaus per log.
|
@codex review |
|
Verdict: APPROVE (provisional, on 9c1c3aa: Codex is still running on this head. I will confirm or withdraw once it finishes.) Re-review of the PR's own commits on top of the main merge 076ebb1: 591d060 and 9c1c3aa. My three blocking items are fixed.
Tests. The three P4 test files pass on one core (37 passed). The new section 4 provenance holds.
Suggestions taken. 2c now says all 56 plateaus had C = 1, so the amended preflight is the discriminating test. The capture entry is 129, because the alignment is 1. Checks. Pre-commit passes on the changed files. The commits are by Samuel Mausberg, with no AI lines. The hostname check is clean over the diff and the PR text. The PR body is #123's own, not hostgap's. The citation of |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9c1c3aaf25
ℹ️ 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".
| rows: list[dict[str, int | str]] = [] | ||
| failed: list[str] = [] | ||
| for run in args.runs: | ||
| logs = sorted(run.glob('*/*/server/server.log')) |
There was a problem hiding this comment.
Require every expected server log
If one arm's server.log is absent, this glob simply omits it, while the remaining logs can each satisfy --min-plateaus 4; the command can therefore exit successfully and overwrite the CSV without all 12 logs that the README says were checked. The fresh evidence after the earlier fix is that only discovered logs are validated—there is still no comparison against each run's lever_sweep_log.jsonl or an expected arm count—so require exactly the configurations recorded for every supplied run before reporting success.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in b07bdb0. Each run directory must now hold lever_sweep_log.jsonl, and the script requires exactly one server log for every configuration it lists (label with # as _), and none outside it; a missing or extra arm fails the run before any plateau counts. New tests cover a recorded configuration without a log and a log outside the record. The evidence CSV regenerates byte-identical.
A missing arm's server.log was silently left out by the glob, so the check could pass with fewer logs than the run had. Each run directory must now hold lever_sweep_log.jsonl and exactly one server log per configuration it lists, with no logs outside it (Codex review of #123). The evidence CSV regenerates byte-identical.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b07bdb0d88
ℹ️ 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".
| arms = [ | ||
| json.loads(line)['config'].replace('#', '_') | ||
| for line in record.read_text().splitlines() | ||
| if line.strip() | ||
| ] |
There was a problem hiding this comment.
Require the complete expected configuration set
When lever_sweep.py is interrupted before later configurations run, its JSONL contains only the completed prefix because records are appended after each arm (experiments/moonshot/lever_sweep.py:113-133). These lines then treat that prefix as the entire expected set, so an incomplete P4 A/B directory containing one recorded log with four matching plateaus exits successfully even though the reproduction expects eight A/B logs or two preflight logs. The fresh evidence after the prior fix is this incremental construction of lever_sweep_log.jsonl; require an independently supplied expected configuration list/count rather than deriving completeness solely from that file.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in fd8f028. The expected set now comes from the declared plan, not from the record: each run must be given as --expect RUN=LABEL,... (the configurations it was launched with, in order; a run without one, or a plan without a run, fails). The record must list exactly the plan, in order, each with exit 0, so an interrupted run whose JSONL holds only the completed prefix fails; the run must also hold one server log per planned configuration and none outside it. The README command gives the three plans (the A/B in run_p4b.sh's declared A B B A order, the two preflights). New tests cover an interrupted run and a run without a plan; the CSV regenerates byte-identical.
lever_sweep appends a record only after each configuration finishes, so an interrupted run's lever_sweep_log.jsonl holds just the completed prefix, and taking the expected set from it let an incomplete run pass. Each run is now checked against its declared configurations, given as --expect RUN=LABEL,... (the launch plan): the record must list exactly those, in order, each with exit 0, and the run must hold one server log per configuration and none outside the plan (Codex review of #123). The README command gives the plans; the CSV regenerates byte-identical.
|
@codex review |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 54535045b4
ℹ️ 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".
| after the run, before the summary step. | ||
|
|
||
| `p4_admission_plateaus.csv` (2c, the 127 plateau) is read from the server logs of the three | ||
| void P4b attempts on CPU, by `admission_plateaus.py` at commit 591d060: |
There was a problem hiding this comment.
Attribute the reproduction command to a compatible revision
Checking out the stated 591d060 revision and running the command below fails because that version of admission_plateaus.py has no --expect option; the option was introduced in fd8f028. Update the cited revision (or separately identify the original-generation and current reproduction revisions) so the documented command can actually regenerate this evidence.
AGENTS.md reference: AGENTS.md:L15-L18
Useful? React with 👍 / 👎.
| - Running-limit amendment (2026-10-01 at 14:29 UTC, before any further run): both arms | ||
| set `--max-running-requests 129` with the client at concurrency 128, so at most 128 | ||
| requests are ever in the server. The limit at the last pass becomes 129 - R - 1, and the | ||
| wave reaches 129 - C = 128 with a chunk tail and min(129, 128) = 128 without one. The |
There was a problem hiding this comment.
Update the declared pool limit to 129
This amendment makes 129 the active running-request limit, but the same served-A/B declaration still says at lines 220–223 that p4_pools pins --max-running-requests 128. Because that pool bullet already incorporates the later KV and mamba amendments, it reads as the current configuration rather than merely historical state and now contradicts both this amendment and levers.py; update it to 129 while noting that the void attempts used 128.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 03bac1b: the declaration's pool bullet now reads --max-running-requests 129 (128 in the three void attempts; running-limit amendment of 14:29 UTC, below), annotated in place like the KV and mamba pins.
|
Verdict: REQUEST CHANGES (withdraws my provisional approval of 9c1c3aa; two new Codex P2s) Re-review of b07bdb0, fd8f028 and 5453504. Verified
Blocking: both Codex P2s on 5453504 are valid and unanswered.
|
…d8f028 The declaration's pool bullet still named --max-running-requests 128 although the amendment made 129 the active limit; it now reads 129, with 128 noted for the void attempts, like the KV and mamba pins. The reproduction command needs --expect, which exists from fd8f028 on; the CSV was first written at 591d060 and is identical at both (Codex and reviewer on #123).
|
@codex review |
|
Verdict: APPROVE (provisional, on 03bac1b: Codex is still running on this head. I will confirm or withdraw once it finishes.) 03bac1b fixes both Codex P2s from 5453504, and both threads have replies:
Everything else stands from my review of 5453504: the audit, the CSV identity, the tests and the negative check. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 03bac1b0d5
ℹ️ 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".
| if args.csv: | ||
| with args.csv.open('w', newline='') as handle: | ||
| writer = csv.DictWriter(handle, fieldnames=FIELDS, lineterminator='\n') | ||
| writer.writeheader() | ||
| writer.writerows(rows) |
There was a problem hiding this comment.
Preserve the CSV when the audit fails
When a declared server log is missing, has too few plateaus, or otherwise fails validation, this block still truncates and rewrites --csv before the subsequent nonzero exit; for example, a missing expected log replaces an existing CSV with a header-only file while returning 1. The fresh evidence after the earlier exit-status fix is that CSV writing still precedes if failed: sys.exit(1). Write to a temporary file and replace the destination only after all checks pass, so a failed regeneration cannot destroy the last valid evidence.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 9331c15: the script now exits 1 before touching --csv when any check fails, so an existing CSV is left as it was; the file is written only when every check passes. Tests cover a failed audit with an existing CSV (unchanged) and a passing one (written). The evidence CSV regenerates byte-identical.
A failed audit still truncated and rewrote --csv before exiting 1, so a missing log could replace the evidence with a header-only file. The script now exits before writing when any check fails, leaving an existing CSV untouched (Codex review of #123). Tests cover both cases; the CSV regenerates byte-identical.
|
@codex review |
|
Verdict: APPROVE (provisional, on 9331c15: Codex is still running on this head. I will confirm or withdraw once it finishes.) 9331c15 fixes the Codex P2 "Preserve the CSV when the audit fails". Everything else stands from my reviews of 5453504 and 03bac1b. |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…and the running-limit amendment (#123) From evidence/moonshot/README.md and p4_admission_plateaus.csv (#123). The third preflight was void like the first two, with the attention cache at 40% use and 127 of 132 state slots taken. The cause, read from the engine source: a request whose last prefill chunk runs in the pass holds its request-table row (lowering the admission limit) and also counts as one of the pass's requests, so a wave stops at M - 1 = 127 when its last pass carries a chunk tail; all 56 waves in the 12 server logs did and stopped at 127. That tests the prediction at one limit and one chunk only; the amended preflight (running limit 129, client at 128, predicting 128 running) is the discriminating test and is queued. The register entry p4-declared gains the plateau CSV and its script.
…and the running-limit amendment (#123) From evidence/moonshot/README.md and p4_admission_plateaus.csv (#123). The third preflight was void like the first two, with the attention cache at 40% use and 127 of 132 state slots taken. The cause, read from the engine source: a request whose last prefill chunk runs in the pass holds its request-table row (lowering the admission limit) and also counts as one of the pass's requests, so a wave stops at M - 1 = 127 when its last pass carries a chunk tail; all 56 waves in the 12 server logs did and stopped at 127. That tests the prediction at one limit and one chunk only; the amended preflight (running limit 129, client at 128, predicting 128 running) is the discriminating test and is queued. The register entry p4-declared gains the plateau CSV and its script.
…and the running-limit amendment (#123) From evidence/moonshot/README.md and p4_admission_plateaus.csv (#123). The third preflight was void like the first two, with the attention cache at 40% use and 127 of 132 state slots taken. The cause, read from the engine source: a request whose last prefill chunk runs in the pass holds its request-table row (lowering the admission limit) and also counts as one of the pass's requests, so a wave stops at M - 1 = 127 when its last pass carries a chunk tail; all 56 waves in the 12 server logs did and stopped at 127. That tests the prediction at one limit and one chunk only; the amended preflight (running limit 129, client at 128, predicting 128 running) is the discriminating test and is queued. The register entry p4-declared gains the plateau CSV and its script.
Appendix E.5: P4's 127-request plateau explained; running limit amended to 129 (#123)
P4b's served A/B has failed admission three times: every wave in both arms stopped at 127 running requests with one queued, first with 360,448 KV tokens, then with 655,360, then with 132 mamba slots. The third attempt (admission preflight 20261001T115146Z) had KV usage 0.40 and 5 free mamba slots, so neither pool was the limit. This PR records the actual cause, checks it against every wave of the three attempts, and amends the pre-registration before any rerun.
Cause (engine code at
bd66ce343e, checked against the logs)A prefill pass stops taking requests once
len(adder.can_run_list) >= get_num_allocatable_reqs(running_bs)(managers/scheduler.py:3971), and that limit ismin(max_running_requests - running_bs, req_to_token_pool.available_size())(scheduler.py:3784-3802). A chunked request whose tail runs in the pass is incan_run_list(schedule_policy.py:1166) and still holds thereq_to_tokenrow it took with its first chunk (chunk_cache.py:82-87,memory_pool.py:317-327), butrunning_bsexcludes it (scheduler.py:3660-3663). It is counted twice, so a pass that carries a chunk tail stops atmax_running_requests - 1and setsbatch_is_full, which stays set until a running request finishes (scheduler.py:4193-4197,4268-4269).P4b's waves are synchronised (one wave of 128 per AIPerf phase,
ignore_eos, 512 output tokens), and its 2,046-2,048-token prompts in 8,192-token passes leave a chunk tail in the last pass of every wave. All 56 wave plateaus in the 12 server logs of the three attempts show the tail (C = 1) and stop at 127 with one request queued, as the derivation predicts (evidence/moonshot/p4_admission_plateaus.csv). Because every wave had C = 1, these logs test the prediction only at C = 1; the amended preflight is the discriminating test. The 128th request then decodes alone after the wave: 1.8 s and 2.1 s of 11.1 s and 11.4 s profiling phases in the third attempt.Changes
experiments/moonshot/admission_plateaus.py(new, withtests/test_moonshot_admission_plateaus.py): finds each wave's plateau in a scheduler log, infers whether the last pass carried a chunk tail, and compares the plateau withmax_running_requests - C. The inference assumes nothing finished between the two passes, which holds for P4b's single-wave phases. The script prints one count line per log and exits 1 if a log has fewer than--min-plateausplateaus, if any continuation is not inferable (outside that scope), or if any plateau differs from the prediction. The evidence command requires 4 per log; every log has 4 or 5.evidence/moonshot/README.md2c: the third void attempt, the cause with line references, and a dated running-limit amendment:--max-running-requests 129at concurrency 128, KV (655,360) and mamba (132) pins unchanged. Predicted outcome: 128 running in both arms and no single-request tail. The README also says which earlier explanations this replaces (KV budget, mamba slots), and why disabling chunked prefill or running at concurrency 127 was rejected.levers.py(p4_pools),validate_p4_ab.py(pinned constant 129; its docstring names the 655,360-token KV pin) and its test, and therun_p4b.shheader.check_admission.pyis unchanged: it already requires 128 running in the measured phase of both arms.experiments/moonshot/README.md: the script index gains the row foradmission_plateaus.py. Main, with Script indexes for experiments/profiling, moonshot and repair; fix two stale README statements #126, is merged in.evidence/moonshot/README.mdsection 4 (coordinator's request): commands, commits and run times for the eight evidence files that had none. They come from two exclusive-lock jobs; the committed JSONs are byte-identical copies of their raw outputs, and both CSVs regenerate byte for byte withsummarise.pyon main. The citation ofrun_p4_timed.sh, which is not in git, is replaced by a description of that job. Two engine statements are corrected: the setup line named patches 0001-0007 for every result, and 2c said the aborted one-batch A/B ran on 0001-0009, when it ran on 0001-0008 (1101be8c5f).Review
get_cuda_graph_max_batch_sizealigns toget_cuda_graph_batch_size_alignment(), which is 1 here (no two-batch overlap, no gathered buffer, tensor parallelism 1;utils/common.py:4059-4071), so the entry is 129.Validation
admission_plateaus.py --min-plateaus 4over the three attempts: 12 logs, 56 plateaus, all as predicted. The README gives the command; the regenerated CSV is byte-identical to the first one.pytest tests/test_moonshot_admission_plateaus.py tests/test_moonshot_validate_p4_ab.py tests/test_moonshot_levers.py: 36 passed, 3 skipped (GPU tests).run_p4_admission.shat fc76655, queued in the normal lane) is the test. The full P4b job is queued only if it shows 128 running in both arms.