Skip to content

Moonshot: Codex follow-ups (exact-replay dispatch guard, TTFT aggregation, overlapped ceiling) - #44

Merged
SamMausberg merged 2 commits into
mainfrom
moonshot/phase2
Sep 30, 2026
Merged

SamMausberg merged 2 commits into
mainfrom
moonshot/phase2

Conversation

@SamMausberg

Copy link
Copy Markdown
Owner

Follow-up to #27 addressing the Codex review comments and the reviewer's ceilings note.

How each comment was handled

  • Codex P1, patch 0007 (replayssm_beta allocated as a local, never reaching the layer
    cache; AttributeError in ordinary GDN serving).
    Checked on bd66ce343e with the series
    applied; not reproduced. MambaPool.State already declares replayssm_beta with a
    None default (it existed for KDA speculative replay), the pool passes the local into
    both State and SpeculativeState constructors, and at_layer_idx slices every field.
    Ordinary serving with 0007 applied already ran (the plain arm in
    evidence/moonshot/lever_sweeps_quick.csv, SGLang head 233fe67ede). The comment does
    point at a real weakness: with the flag on but no ring, the old code fell through to
    another kernel silently. New patch 0008 raises in that case and logs the first
    exact-replay dispatch, and tests/test_moonshot_levers.py pins the field and its slicing.
    No P4 result exists yet (the job is queued), so none ran without the exact kernel.
  • Codex, summarise.py: TTFT from the last repeat only. It now averages the per-run
    medians across repeats.
  • Reviewer, ceilings model. The additive floor max(W/BW, BF/P) + Bs/BW is now labelled
    as the layer-serial model of the current engine (not a hardware bound), and the overlapped
    hard roofline max((W + Bs)/BW, BF/P) is added to ceilings.json, ceilings.csv, the
    docstring and README 1.4 (plain FP32 32.1k tok/s and the full lossy stack 141.2k at
    B = 2,048, against 23.7k and 78.9k layer-serial).

Testing

  • pre-commit run on the changed files passes.
  • pytest tests/test_moonshot_levers.py: 2 passed, 3 skipped in the repo venv; 5 passed in
    the SGLang venv with the engine/moonshot worktree on PYTHONPATH.
  • The 8-patch series applies with git am on bd66ce343e and reproduces the branch tree.
  • python experiments/moonshot/ceilings.py regenerates the committed JSON and CSV.

…on, overlapped ceiling

- Codex P1 on patch 0007 (replayssm_beta never reaching the layer cache): checked
  on bd66ce343e, not reproduced. MambaPool.State declares replayssm_beta with a
  None default, the pool passes the local into both State constructors, and
  at_layer_idx slices every field; a test now pins this. Patch 0008 makes
  SGLANG_GDN_EXACT_REPLAY fail loudly when the ring is missing and logs the
  dispatch, so no run can use another kernel silently.
- summarise.py reported TTFT from the last repeat only; it now averages the
  per-run medians.
- ceilings.py labels its additive floor as the layer-serial model of the
  current engine and adds the overlapped hard roofline
  max((W + B s)/BW, B F/P) to ceilings.json and ceilings.csv.
@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:22:42.185347Z 30b4588 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.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES

Reviewed head 30b4588 (4 behind main, no conflicts in the files it touches). The non-reproduction of Codex's P1 holds, the ceilings regenerate byte for byte, and Codex finished with no findings. One wording item blocks, because it reintroduces the claim that #36 removed from the paper.

Blocking

B1. The overlapped model is called a "hard roofline", but its compute-bound rows depend on the assumed tensor-core rate.

  • Location. experiments/moonshot/ceilings.py docstring ("This is the hard roofline"), ceilings.json execution_models.overlapped_floor_ms ("overlapped (hard roofline)"), and evidence/moonshot/README.md 1.4 ("the hard roofline for an engine that overlaps ...").
  • Why it is wrong.
    • max((W + B s)/BW, B F/P) removes the serial-execution assumption. It still uses P = 60%/70% of the datasheet peak, which is an assumption, not a peak.
    • The compute-bound rows are therefore not hard bounds. The full lossy stack's 141.2k is P/F at 60% of FP8 peak; at the datasheet peak the same formula gives 178.8k. The two ReplaySSM rows at 82.3k are compute-bound the same way.
    • Even the bandwidth-bound rows rest on the 3.79 TB/s input, whose evidence is still pending in Profile SGLang decode and MTP on GH200: attribution, head baseline, bytes per step #13.
  • Consequence. The paper as merged in Paper milestone 4: moonshot ceilings and first lever runs; P6 citation fixes #36 deliberately avoids "hard" for this reason. Evidence that calls the same numbers hard would be cited against it.
  • Fix. In all three places, call it "the overlapped roofline at the assumed P and BW". Optionally, note that the compute-bound rows rise to P_datasheet/F if the GEMMs reached peak.

Checked and correct

  • Codex P1 on 0007 does not reproduce. I applied 0001-0007 with git am to bd66ce343e in a scratch worktree.
    • MambaPool.State declares replayssm_beta: Optional[torch.Tensor] = None (memory_pool.py:432, present at the pin).
    • The pool sets the local to None (655) and allocates it only in the exact-replay branch (725). The KDA branch (758) cannot overwrite it for GDN.
    • It passes the local into both SpeculativeState(...) (890) and State(...) (916).
    • at_layer_idx slices every field, and None stays None.
    • So layer_cache.replayssm_beta in gdn_backend.py:671 always exists. Ordinary serving cannot raise AttributeError.
  • Patch 0008.
    • Applied on top, the series gives tree da9fd1fa39a4, identical to the tree of local engine/moonshot (1101be8c5f).
    • The guard sits in packed_decode. With --enable-linear-replayssm the write cursor is non-None in eager decode, in graph capture (the static per-bs buffers) and in replay, so it fires only for the flag without a ring.
  • Tests.
    • tests/test_moonshot_levers.py: 2 passed and 3 skipped in the repo venv.
    • 5 passed in the SGLang venv with the patched tree on PYTHONPATH. I ran that with CUDA_VISIBLE_DEVICES="", so no GPU was touched.
    • Pre-commit passes on all changed files.
  • Ceilings. python experiments/moonshot/ceilings.py --out ... --csv ... regenerates ceilings.json and ceilings.csv byte for byte.
    • At B = 2,048 the overlapped column gives plain FP32 32,098 and the full lossy stack 141,166 tokens/s.
    • The "(compute-bound)" labels are correct: for ReplaySSM + 16-bit at B = 2,048, B F/P is 24.9 ms against 23.9 ms of bytes.
  • Agreement with the paper's Eq. 19 (Paper milestone 4: moonshot ceilings and first lever runs; P6 citation fixes #36). The merged paper quotes no overlapped numbers; it gives the bound in symbols only. The 33.3k and 141k were in my review of Paper milestone 4: moonshot ceilings and first lever runs; P6 citation fixes #36.
    • They are the B -> infinity limit, min(BW/s, P/F). At B = 2,048 the plain stack still carries W/BW (8.41 GB of 241.8 GB), hence 32.1k against 33.3k.
    • Compute-bound stacks are already at the limit, so the lossy stack is 141.2k either way.
    • The layer-serial column is the same at B = 2,048 and in the limit, because the step time is linear in B from B = 256 on.
    • So the two sets of numbers agree; they are evaluated at different B.
  • TTFT aggregation. summarise.py now takes the mean of the per-run medians over every repeat that has one, and the docstring says so.
  • Attribution. There are no AI co-author lines.

Suggestions (not blocking)

  • Large-batch limit. Add min(BW/s, P/F) per stack to ceilings.json, or label the table "at B = 2,048" wherever the paper quotes it. Eq. 19 defines the large-batch ceiling as that limit, and for the bandwidth-bound stacks it differs from the B = 2,048 value by 3-7%.
  • 0008's remaining fall-through. The new guard covers the missing ring. It does not cover a decode backend without packed decode: only the Triton dispatcher sets supports_packed_decode, and with any other backend SGLANG_GDN_EXACT_REPLAY=1 is ignored without error.
    • Option 1: raise at backend init when the flag is set and supports_packed_decode is false.
    • Option 2: have the P4 protocol require the new "GDN decode: exact replay kernel" log line before its bit-exactness result counts.

…d BW

Its compute-bound rows inherit the assumed tensor-core rate and BW is still an
assumption, so it is not a hard bound. ceilings.json also records its
B -> infinity limit min(BW/s, P/F) per stack (33.3k tok/s for plain FP32).
@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE

This re-review covers head 18f60f7. B1 is fixed.

  • Wording. All three places (the ceilings.py docstring, ceilings.json execution_models, README 1.4) now call it "the overlapped roofline at the assumed P and BW". They also note that its compute-bound rows inherit the assumed P and would be higher at the datasheet peaks. Nothing in the moonshot evidence or code calls it a hard bound any more.
  • The large-batch limit. ceilings.json now records overlapped_limit_tokens_per_s = min(BW/s, P/F) per stack, matching the paper's Eq. 19. Plain FP32 is 33,255 tokens/s; the full lossy stack is 141,166 tokens/s, compute-bound, so the same as at B = 2,048. README 1.4 cites it.
  • Regeneration and hooks. python experiments/moonshot/ceilings.py --out ... --csv ... regenerates both files byte for byte, and pre-commit passes.
  • 0008. For the optional point, the plan is noted: --enable-linear-replayssm requires the Triton GDN decode backend, and the P4 job will require the "GDN decode: exact replay kernel" log line before any result counts.

Everything verified in my first review still holds: the non-reproduction of Codex's P1 at the pin, the 8-patch tree, the tests and the TTFT aggregation.

@SamMausberg
SamMausberg merged commit 565d253 into main Sep 30, 2026
@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE

Still approved at 5561bcb. The only change since my approval at 18f60f7 adds an opt-in --stream-interval option to experiments/moonshot/lever_sweep.py (default 0, which leaves every arm unchanged). Pre-commit passes on the file.

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