Skip to content

Moonshot: P4 strict replay is bit-exact (1.22x kernel), host-gap flag 1.18x, P7 rejection tests - #60

Merged
SamMausberg merged 14 commits into
mainfrom
moonshot/phase3
Oct 1, 2026
Merged

SamMausberg merged 14 commits into
mainfrom
moonshot/phase3

Conversation

@SamMausberg

@SamMausberg SamMausberg commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

Moonshot Phase 2, first results: the strict write-avoiding GDN decode (P4) is bit-identical
to SGLang's packed decode, the speculative host gap has a configuration-level fix worth
1.18x at c = 1, and block-parallel GDN verification (P7) fails its first rejection tests
with SGLang's existing kernel. Also the review follow-ups from #27/#44.

Results (details and tables in evidence/moonshot/README.md 2b-2e)

  • P4 strict replay (patch 0007): at kernel level, on synthetic activations (random
    q/k/v/a/b and prefilled state, the checkpoint's A_log/dt_bias), one layer at a time
    (layer 0 at L = 4 and 16, layer 20 at L = 4): 0 of 201,326,592 state words and 0 of
    1,572,864 output words differ from the packed decode at every step
    (gdn_exact_replay_check_*.json). The end-to-end bitwise probe has not run yet (its first
    attempt failed before serving) and is queued. ReplaySSM on the same inputs differs in 465k
    output words. Kernel time 1.22x at B = 128 and 256 with L = 4 (gdn_exact_replay_bench.json);
    longer rings lose to replay compute. Derived end-to-end gain ~1.08x at B = 128, below the
    pre-registered 1.10x gate (derived); the server-side paired A/B with 2,048-token prompts is
    pending (run_p4b.sh). The one_batch attempt aborted in both arms (patched engine, exact
    replay off in the base arm; stock not tried): a 262k-token single prefill hits an illegal
    memory access in fused_qk_gemma_rmsnorm_rope_gate.
  • Host gap (MTP): --attention-backend triton for target and draft gives 1.18x at c = 1
    and 1.14x at c = 4 (class pending bench's equality classification, since it changes the
    target's attention arithmetic); Triton for the draft only gives 1.08x / 1.06x and is
    exact; the plan-stream arm
    fails on the GDN hybrid (update_verify_buffers_to_fill_after_draft not implemented)
    (host_levers.csv).
  • P7: SGLang's chunked GDN kernel is not a usable fast path (synthetic inputs, one layer,
    one request): it disagrees with the recurrent path in 52-55% of BF16 output words and is
    slower than the recurrent verify for T = 4-256 (p7_fast_verify_check.json,
    p7_verify_width_bench.json). A purpose-built block-parallel kernel is untested.
  • Speculation at high concurrency (derived, 2b; inputs from bench's merged evidence/bench/tuning/points.csv): from bench's tuning throughput, the MTP
    cycle at c = 128 is 35-44 ms against ~13-22 ms of derived components; snapshot-free verify
    beyond ReplaySSM-spec would be worth ~4% of it, so it is not built.
  • Hot-vocabulary maps: held-out coverage on the confirm outputs is 89.1% / 93.3% / 96.3% /
    97.5% for 4k / 8k / 16k / 22.9k rows (token_map_coverage.csv); new hot23k lever.

Review follow-ups

Tooling

  • lever_sweep.py --stream-interval, --workload, --warmup-pool; summarise.py sweeps
    reports each point's server-logged full-batch decode rate (bench's per-point log segment),
    TTFT and ITL p50/p99 and foreign CPU beside client throughput;
    summarise.py paired-sweeps for A B B A comparisons; make_long_prompts.py.
  • Engine patch 0009: SGLANG_GDN_EXACT_REPLAY_BV (exact-replay value tile, default 32; a
    positive power of two, anything else raises).

Testing

  • pre-commit run on the changed files passes.
  • tests/test_gdn_exact_replay.py (3 bitwise tests passed on the GH200 in the P4 hold; the
    6 BV-validation tests pass) and
    tests/test_moonshot_levers.py (5 passed in the SGLang venv).
  • The 9-patch series applies with git am on bd66ce343e and reproduces the branch tree.

The server's logged gen throughput while ~c requests run sits beside the client
throughput, so a front-end limit shows as a gap between the two.
…n byte arithmetic

With PR #13 merged, bandwidth, kernel attribution and the MTP idle share cite
evidence/profiles. README section 2b derives the MTP cycle at c = 128 from bench's
tuning throughput and shows that snapshot-free verification beyond ReplaySSM-spec
is worth ~4% of the cycle, while the cycle is 2-2.7x the sum of its parts.
On the mixed-v2 confirm outputs of the plain sweep (172k tokens), bench's tune maps
cover 89.1% (4,096 rows), 93.3% (8,192), 96.3% (16,384) and 97.5% (22,936) of the
target's tokens; in-sample coverage was 97-100%. README cites the bandwidth sweep
configuration as reused at the head's size.
…ejection tests

- Exact replay (patch 0007) matches SGLang's packed decode on every state and output word
  at every step (L = 4, 16; layers 0 and 20); ReplaySSM does not. Kernel time 1.22x at
  B = 128 and 256 with L = 4; derived ~1.08x end to end, below the pre-registered 1.10x.
- Triton attention for target and draft removes FlashInfer planning from the MTP cycle:
  1.18x at c = 1, 1.14x at c = 4; the plan-stream arm fails on the GDN hybrid.
- P7: the chunked GDN verify disagrees with the recurrent path in 52-55% of BF16 output
  words and is slower than it at one request up to T = 256.
- make_long_prompts.py builds the 2,048-token workload for the server-side P4 A/B;
  quality_arms drops the arm's 640-slot default when the radix cache is off.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 1, 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-10-01T03:23:12.929660Z f0c13b6 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 f0c13b6 against main (merge base 0f0c025, with main merged in at 05ef9c9). The measurements are sound and the numbers match their files. Four claims need tighter scope, and one section cites a branch that has not merged.

Checked and correct

  • Engine patches. git am of patches 0001-0009 at bd66ce343e gives exactly the tree of ~/sglang-wt/moonshot HEAD d28fc494e2, which is clean.
  • P4 bit-exactness files. gdn_exact_replay_check_L4.json, _L16.json and _L4_layer20.json each record 0 of 201,326,592 state words and 0 of 1,572,864 output words differing. Each covers batch 8, 48 steps and forced-flush rate 0.1. ReplaySSM differs in 465,102 output words at layer 0 and in 543,225 at layer 20.
  • P4 kernel times. gdn_exact_replay_bench.json matches the table: 161.5 against 132.9 us (1.215x) at B = 128, and 312.7 against 254.8 us (1.227x) at B = 256, at L = 4.
  • The 1.08x derivation. 1 / (0.584 + 0.416 / 1.215) = 1.08.
  • Host levers. host_levers.csv gives 1.179x and 1.139x for Triton attention, and 1.077x and 1.063x for Triton draft attention only. These are single runs of 16 requests each, with foreign load of 0.23-0.37 cores.
  • P7. p7_fast_verify_check.json shows 52.1-55% BF16 disagreement. p7_verify_width_bench.json matches the width table.
  • Token-map coverage. token_map_coverage.csv matches: 89.1, 93.3, 96.3 and 97.5%.
  • Section 2b arithmetic.
    • Cycles: 128 x 3.26 / y gives 43.5 and 35.0 ms, and plain decode takes 9.5 ms per step.
    • Verify GEMMs: 4.3 TFLOP at 650 TFLOPS is 6.6 ms.
    • Per-request state traffic: 352 MB (7 x 50.3) costs 11.9 ms, and about 100 MB costs 3.4 ms.
    • The snapshots removed: 252 MB x 128 = 32 GB, which takes 8.5 ms at 3.8 TB/s and equals the measured difference of 8.5 ms.
  • Profile citations. These match evidence/profiles/: 3.54 ms with 68 / 10 / 6.5 / 6.2 / 4.8 / 4.3%, 3.47-3.48 TB/s, B = 110-120, and 41.6% of 8.9 ms. The bandwidth wording (3.83 / 3.79 TB/s) matches Fix the head roofline floor and bandwidth wording in profile evidence #54.
  • Lever 5's class. It now reads "class pending measurement; mechanism suggests lossy".
  • Hygiene. Pre-commit passes and there are no AI co-author lines.

Blocking

B1. "Bit-identical" needs its scope, and the end-to-end probe has dropped out of the table (integrator check 1). This affects the PR body, lever row 4, and section 2c's first sentence.

  • The inputs were synthetic. gdn_exact_replay_check.py uses random activations (torch.randn for qkv, a and b), a random prefilled state, and the checkpoint's A_log and dt_bias.
  • The coverage is one layer at kernel level. Ring lengths 4 and 16 were tested at layer 0, and only L = 4 at layer 20.
  • Where it is stated. Section 2c says "random activations", but the PR body and lever row 4 ("bit-identical to the packed decode (kernel check, 2c)") do not.
  • The end-to-end probe never finished. The old row 4 listed "the end-to-end bitwise probe queued". The new row omits it, and ~/vp-data/moonshot/exact_replay_e2e.log contains only "Terminated".
  • Fix: write "bit-identical at kernel level on synthetic activations with the checkpoint's gates (one layer; L = 4 and 16 at layer 0, L = 4 at layer 20)" in all three places, and restore "end-to-end bitwise probe: not run (terminated), queued".

B2. Say which engine the one_batch crash happened in (integrator check 3; section 2c, last sentence; PR body).

  • The illegal memory access in fused_qk_gemma_rmsnorm_rope_gate appears in every timed run: p4_timed/base.r0-r2.log and exact_replay_l4.r0-r2.log.
  • Both arms ran on the patched moonshot engine (PYTHONPATH=~/sglang-wt/moonshot/python, patches 0001-0009), so the crash is not specific to exact replay: base has it turned off.
  • It was not run on stock SGLang.
  • Fix: state that, and either reproduce it on stock bd66ce343e or say that it has not been tried there.

B3. The Triton-attention host-gap result is labelled exact, but it changes the attention arithmetic (integrator check 4; lever row 2, "exact"; section 2d).

  • --attention-backend triton replaces FlashInfer attention for the target as well as the draft. The outputs are therefore a different kernel's, and the lever cannot be called exact.
  • Bench's one completed classification of a Triton MTP arm gives 3.80/1K (3.28-4.41) against the 3.42 plain floor, a ratio of 1.11 (0.90-1.37), all rounding-level. The other pairs are being rerun.
  • Fix: make row 2's class "pending bench's equality classification (attention kernel changed)", and say the same in 2d. Draft-only Triton (1.08x / 1.06x) does not touch the target's arithmetic and could stay exact. State that separately.

B4. P7: scope the conclusion to SGLang's kernel and the synthetic inputs (integrator check 5; section 2e, "by P7's own rejection rule the design is rejected with this kernel"; the PR body).

  • The 52-55% disagreement comes from one layer with synthetic activations. The speed table is for one request.
  • What the data supports: "SGLang's chunked GDN kernel is not a usable fast path for P7 (synthetic inputs, one layer): its BF16 outputs disagree with the recurrent path in 52-55% of words, and at one request it is slower than the recurrent verify at every width up to 256."
  • P7 with a purpose-built block-parallel kernel is untested, so the text should not read as "P7 refuted".

B5. Section 2b cites evidence from an unmerged branch ("Bench's depth tuning (bench workstream, evidence/bench/tuning/, pending its PR)").

Suggestions (not blocking)

  • Row 4's wording. "likely rejected by the derived estimate" would read better as "below the pre-registered 1.10x gate (derived); server A/B pending (run_p4b.sh)".
  • The 1.2-1.9x in 2b. "the profile workstream's B = 32 MTP cycle, 12.5 ms unprofiled, is about 1.2-1.9x its GPU-busy time" needs its derivation. From evidence/profiles/README.md, B = 32 has head share 12.4% of the cycle against 16.3% of busy time, so busy is about 76% of the 13.9 ms profiled cycle, about 10.6 ms, giving about 1.18x. B = 1 gives about 1.28x. Where does 1.9 come from?

Codex's review of f0c13b6 is still running; I'll check its comments before the re-review.

@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: f0c13b6ca2

ℹ️ 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 experiments/moonshot/summarise.py Outdated
Comment on lines +173 to +174
concs = sorted({p['concurrency'] for p in data.get('points', [])})
rates = server_decode_rates(sweep_json.parent / 'server/server.log', concs)

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 Read server decode rates from each point's log segment

When a sweep contains multiple concurrency points, this reads the entire server log, including server warmup and every other point. A higher-concurrency run emits lower #running-req values while draining, so those samples are incorrectly attributed to lower-concurrency rows and can bias server_decode_tok_s and paired server ratios. bench/sweep.py already records the exact per-point segment in point['server_log']['logged_gen_tps_full_batch_p50']; aggregate that value instead of reparsing the run-wide log.

Useful? React with 👍 / 👎.

Comment on lines +31 to +34
+ BV = min(
+ triton.next_power_of_2(V),
+ int(os.environ.get("SGLANG_GDN_EXACT_REPLAY_BV", "32")),
+ )

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 invalid replay tile sizes before launching Triton

When SGLANG_GDN_EXACT_REPLAY_BV is set to 0 or to a non-power-of-two value such as 24, the value is passed directly to triton.cdiv and tl.arange(0, BV). The former divides by zero and the latter requires a power-of-two extent, so plausible settings of the newly advertised selector crash rather than select a tile. Validate that the parsed value is a supported positive power of two before constructing the grid.

Useful? React with 👍 / 👎.

…ing, pending tuning evidence

- 2c and lever row 4: bit-identical at kernel level on synthetic activations, one layer;
  the end-to-end bitwise probe has not run (first attempt failed before serving) and is
  queued; both one_batch arms aborted on the patched engine, stock not tried.
- Lever row 2: Triton attention for the target is pending bench's equality
  classification; draft-only Triton is exact.
- 2e: SGLang's chunked kernel is not a usable fast path for P7 (synthetic, one layer,
  one request); a purpose-built kernel is untested.
- 2b is marked pending bench's PR #57 and shows the cycle/GPU-busy derivation.
@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES

Re-reviewed head ed4682d (one commit on f0c13b6). B1-B5 and both suggestions are addressed. What remains is Codex's two P2 comments, which landed after my first review and are not yet addressed, and one mislabelled floor in the new text.

Earlier items

  • B1 (fixed). Section 2c, row 4 and the PR body now say the result is kernel-level, on synthetic activations, for one layer: layer 0 at L = 4 and 16, layer 20 at L = 4. The end-to-end bitwise probe is listed as not run and queued in run_p4b.sh.
  • B2 (fixed). The text says the crash happened in both arms on the patched engine, with exact replay off in the base arm, and that it was not tried on stock.
  • B3 (fixed). Row 2 now gives target Triton attention as "class pending" and draft-only Triton as exact, as separate entries. See N1 for the cited pair.
  • B4 (fixed). P7 is scoped to SGLang's chunked kernel, and a purpose-built kernel is described as untested.
  • B5 (marked pending). See the merge note at the end.
  • Suggestions (taken). The traffic-only ceiling of 1.18x is right: 1 / (0.584 + 0.416 / 1.6) = 1.185. The cycle against GPU-busy ratios (1.27x, 1.25x and 1.18x from 6.70/5.27, 8.27/6.62 and 12.49/10.62 ms) are right.

Blocking

C1. Codex P2: per-point server decode rates come from the whole log (experiments/moonshot/summarise.py:144-174, server_decode_rates).

  • The function reads the entire server log, including warm-up and every other concurrency point. Rates logged while a higher-concurrency run drains therefore get attributed to lower-concurrency rows.
  • host_levers.csv's server_decode_tok_s column is produced this way.
  • Fix: use the per-point segment that bench/sweep.py already records (point['server_log']['logged_gen_tps_full_batch_p50']), or restrict parsing to each point's time window. Then regenerate host_levers.csv. The client-side x and y in the 2d table are not affected.

C2. Codex P2: patch 0009 does not validate SGLANG_GDN_EXACT_REPLAY_BV (engine/sglang/patches/moonshot/0009-...patch:33).

  • A value of 0 divides by zero in triton.cdiv.
  • A value that is not a power of two fails in tl.arange(0, BV).
  • Fix: accept only positive powers of two up to V, and fail with a clear message otherwise. Then regenerate the patch and recheck that the series reproduces the engine branch.

N1. The floor in the new text is mislabelled, and the pair it cites does not isolate Triton (section 2d, last paragraph, and row 2).

  • "Against the 3.42 floor of stock MTP": 3.42/1K is the floor of stock plain decoding, client concurrency 1 against 32 on servers capped at 16. It is not stock MTP.
  • The 3.80/1K pair is "mtp_s3 buffered verify radix-off triton vs plain c1", which is Triton attention together with ReplaySSM-spec. It does not isolate Triton attention.
  • Fix: write "against the 3.42/1K plain-decoding floor (client concurrency 1 vs 32)", and say the pair combines Triton with buffered verify. Bench is adding Triton-only pairs.

Merge note

The "Pending bench's PR #57" paragraph in section 2b should come out when this rebases after #57 merges, so that main does not say "not merged yet". Otherwise main ends up with a stale pending note about an evidence directory it already contains.

…Triton pair wording

- summarise.py sweeps takes each point's server_log.logged_gen_tps_full_batch_p50 instead
  of parsing the whole server log, so drain-phase rates no longer leak into lower
  concurrencies; it also reports TTFT and ITL p50/p99. host_levers.csv regenerated.
- Patch 0009: SGLANG_GDN_EXACT_REPLAY_BV must be a positive power of two (ValueError
  otherwise); tests cover the default, an override and rejected values. The 9-patch series
  still reproduces the engine branch tree.
- 2d and lever row 2: the 3.42/1K floor is plain decoding at client concurrency 1 vs 32,
  and bench's 3.80/1K pair combines Triton with ReplaySSM-spec, so it does not isolate
  Triton.
@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES

Re-reviewed head 8585e67 (one commit on ed4682d). C1, C2 and N1 are fixed. #57 has now merged (feba087), so one edit is left before merge: the pending note about it.

Fixed in 8585e67

  • C1. summarise.py sweeps takes each point's server_log.logged_gen_tps_full_batch_p50, so rates are no longer parsed from the whole log. host_levers.csv was regenerated. Only server_decode_tok_s changed: three c=4 rows, and none of them is cited in the README.
  • C2. Patch 0009 accepts only a positive power of two for SGLANG_GDN_EXACT_REPLAY_BV and raises ValueError otherwise, and new tests cover it. git am of patches 0001-0009 at bd66ce343e gives tree 919939de, the tree of the engine branch head c29a91692b.
  • N1. Section 2d and row 2 call 3.42/1K the plain-decoding floor at client concurrency 1 against 32. They also say the 3.80/1K pair combines Triton with ReplaySSM-spec, so it does not isolate Triton.
  • Other checks. Pre-commit passes on the changed files. The GPU tests skip on the CPU host; your run on the GH200 covers them.

Blocking (merge-time edit)

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE

Approving head 2d3a0c0. It sits on 8585e67 (C1, C2 and N1, reviewed above) plus two commits:

All items from the three rounds are closed:

  • B1-B5;
  • C1 and C2 (both Codex P2 comments);
  • N1.

The integrator's six checks hold:

  1. Bit-exactness is scoped to kernel level and synthetic activations, and the end-to-end probe is listed as queued.
  2. The 1.08x end-to-end figure is derived and labelled "below the gate, server A/B pending".
  3. The one_batch crash is reported in both arms of the patched engine, untried on stock.
  4. Target Triton attention is pending classification.
  5. The P7 wording is scoped to SGLang's chunked kernel.
  6. Lever 5's class and the bandwidth citation are fixed.

@SamMausberg
SamMausberg merged commit fb1381c into main Oct 1, 2026
SamMausberg added a commit that referenced this pull request Oct 1, 2026
Address review B1 on #64. Merged evidence does not support the "exact
up to the noise floor" class for replayed verification. Moonshot lever
5 (#60) calls it pending, with a mechanism that suggests lossy, because
its verify outputs come from a chunked transform on TF32 tensor cores.
bench/arms.toml (#57) also marks those arms lossy = "pending". The
levers table's class and footnote and the chosen-arms sentence now say
this.

Triton attention for the target changes the target's arithmetic, as
ruled in #60, so the Triton arms and the attention-backend lever are
pending too, and bench-equality covers them.
SamMausberg added a commit that referenced this pull request Oct 1, 2026
Appendix E: integrate the moonshot phase-3 results (#60)
@SamMausberg
SamMausberg deleted the moonshot/phase3 branch October 1, 2026 14:35
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