Skip to content

Moonshot Phase 1: serving ceilings, composable levers and first measurements - #27

Merged
SamMausberg merged 11 commits into
mainfrom
moonshot/portfolio
Sep 30, 2026
Merged

SamMausberg merged 11 commits into
mainfrom
moonshot/portfolio

Conversation

@SamMausberg

@SamMausberg SamMausberg commented Sep 30, 2026 •

Copy link
Copy Markdown
Owner

Phase 1 of the moonshot workstream: what bounds Qwen3.5-4B serving on the GH200 at both
ends of the Pareto curve, a composable set of engine levers, the first measurements, and a
ranked portfolio. Results that are still queued on the GPU are marked pending in
evidence/moonshot/README.md; this PR will be updated as they land.

What is here

  • experiments/moonshot/levers.py: every lever as a separate flag/environment override on
    the bench arms, with its lossy label and conflicts, so stacks compose as lists
    (baseline, A, B, A+B).
  • Drivers built on the bench harness (bench/ on main): lever_sweep.py (timed, bench.sweep), gsm8k_arms.py
    (bench.quality), quality_arms.py + logit_probe.py (greedy divergence, top-20 KL,
    teacher-forced agreement against a reference server), decode_ceiling_sweep.py
    (static-batch sglang.benchmark.one_batch up to B = 1,024), summarise.py (tables,
    paired speedups with t intervals, four-way interaction factors).
  • ceilings.py -> evidence/moonshot/ceilings.{json,csv}: derived roofline floors per
    lever stack from the checkpoint sizes and the measured HBM peak.
  • gdn_exact_replay_check.py: bit-exactness (every output and state word at every step)
    and kernel time of write-avoiding GDN decode against SGLang's packed decode (proposal P4).
  • Engine patches engine/sglang/patches/moonshot/0001-0007 (branch engine/moonshot), all
    off by default:
    1. untie a reduced MTP draft head for --speculative-token-map (the tied Qwen3.5 head made
      the flag silently wrong at the pin);
    2. and 4. lossy relaxed greedy verification for MTP and DFlash chains
      (SGLANG_SPEC_RELAXED_GREEDY_LOGIT_GAP);
    3. and 6. experimental FP8 GDN state with 16-bit ReplaySSM ring records;
    4. --speculative-token-map for the DFlash captured draft head;
    5. rounding-preserving live replay for GDN decode (SGLANG_GDN_EXACT_REPLAY): the packed
      decode's own FP32 operands replayed from a dense anchor written every L steps;
      designed to be bit-identical, validation pending.

Findings so far

  • The charter's estimate holds in the derived byte count: per-request bytes (FP32 GDN
    state read and written every step) pass the 8.41 GB of weights at B = 74-84; the
    kernel-time measurement of the crossover is the profile workstream's (pending).
  • The 133-request cap is a slot reservation (5 FP32 slots per request), not traffic.
  • FP16 GDN state: +24% tokens/s at c = 128, +11% at c = 32, none at c = 1 (single runs;
    quality pending).
  • Online FP8 W8A8 does not work here through CUTLASS (the aarch64 sgl-kernel build aborts
    on sm_90) and shows no consistent gain through the Triton route (0.96-1.06x, single
    runs); FP8 KV gives nothing at these context lengths. Both are recorded as negative
    results.
  • Public DFlash drafters for Qwen3.5-4B exist (z-lab, nota-ai INT4) and the nota-ai INT4
    QAD target is a ready lossy arm.

Testing

  • pre-commit run on the changed files passes (ruff, mypy, codespell).
  • pytest tests/test_moonshot_levers.py: lever composition in the repo venv; the engine
    tests (relaxed verification, reduced draft head) pass in the SGLang venv with the
    worktree on PYTHONPATH and skip elsewhere.
  • The exported patches apply with git am on bd66ce343e and reproduce the branch tree
    exactly.
  • Not yet run on GPU: patches 0005 and 0007 (their checks are queued).

@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-30T20:33:00.431304Z 49f3313 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.

Levers are composable flag/env overrides on the bench arms (levers.py), run
through bench.sweep (lever_sweep.py), bench.quality (gsm8k_arms.py), a
logit-level quality probe (logit_probe.py, quality_arms.py) and a static-batch
decode ceiling sweep (decode_ceiling_sweep.py). ceilings.py derives per-stack
roofline floors from the config and the measured HBM peak.

Engine patches (engine/moonshot): untie a reduced MTP draft head for
--speculative-token-map on tied Qwen3.5, relaxed greedy chain verification
for MTP and DFlash (off by default), and an experimental FP8 GDN state.
… and hot-vocab levers

transformers 5 returns a BatchEncoding from apply_chat_template(tokenize=True),
which the probe sent as two string ids; template to text and encode instead.
Levers gain DFlash (z-lab and nota-ai drafters), the INT4 QAD target, bench's
hot-vocabulary maps, relaxed acceptance, plan-stream/glue-graph host levers
and the Triton FP8 GEMM route (the aarch64 CUTLASS FP8 kernel aborts here).
The ceiling sweep parses one_batch logs and stops runaway runs.
gdn_exact_replay_check.py compares SGLang's packed decode, ReplaySSM and the
rounding-preserving replay (engine/moonshot patch 0007) on every output and
state word at every step, and times one layer per step at batch 32-256.
quality_arms gains a probe-concurrency option for bitwise end-to-end checks;
summarise.py gains the four-way interaction table.
lever_sweeps_quick.csv: plain, FP16 GDN state (+24% at c=128), FP8 W8A8 via the
Triton route (no gain; the aarch64 CUTLASS FP8 GEMM aborts), FP8 KV (no gain at
~334-token contexts). ReplaySSM levers now set the no_buffer radix strategy, and
NGRAM arms run bench's launch checks non-strictly (no draft graph exists).
mixed-v1 left the tree with the bench harness merge; v2 keeps GSM8K test out of
the workload. Monkeypatches of bench entry points go through vars() so mypy,
which now sees bench's types, accepts them.

@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: 49f3313987

ℹ️ 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".

replayssm_d = layer_cache.replayssm_d
replayssm_k = layer_cache.replayssm_k
replayssm_g = layer_cache.replayssm_g
+ replayssm_beta = layer_cache.replayssm_beta

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 Attach the beta ring to each layer cache

Patch 0007 allocates replayssm_beta only as a local in MambaPool, but never adds it to the per-layer cache structure or initializes a None field when exact replay is disabled. Consequently this unconditional dereference can make ordinary GDN serving fail with AttributeError after the patch is applied; even if the cache tolerates a missing value, SGLANG_GDN_EXACT_REPLAY=1 cannot receive the allocated tensor and silently misses the new kernel path. Wire the per-layer beta slice into the cache alongside replayssm_d/k/g.

Useful? React with 👍 / 👎.

'y_tok_s_gpu': round(statistics.fmean(ys), 1) if ys else '',
'y_std': round(statistics.stdev(ys), 1) if len(ys) > 1 else '',
'accept_len': round(statistics.fmean(spec), 3) if spec else '',
'ttft_p50_ms': round(plist[-1].get('ttft_ms', {}).get('p50', float('nan')), 1),

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 Aggregate TTFT across repeated sweeps

When multiple sweep.json files contribute to the same label and concurrency, throughput and acceptance are aggregated across plist, but TTFT is taken only from plist[-1]. Thus any run with --repeats > 1 reports an arbitrary final run's p50 while labeling the row with the combined run count and combined throughput statistics, so run ordering can change the committed TTFT result. Aggregate the per-run TTFT values or emit them separately.

Useful? React with 👍 / 👎.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES

Reviewed at 8f17441, whole diff (a work-in-progress PR; I reviewed what is committed).

What I checked

  • Patches. All seven moonshot-000*.patch files apply in order with git am to SGLang bd66ce343e in a scratch clone. The resulting tree (032c2ccf...) is identical to engine/moonshot at 233fe67ede, the head the README names.
  • Ceilings. experiments/moonshot/ceilings.py regenerates ceilings.json and ceilings.csv byte for byte.
  • Tests. tests/test_moonshot_levers.py passes (2 tests); the GPU exact-replay tests skip cleanly without CUDA.
  • Lossy labels. Every lossy lever in levers.py is labelled: BF16, FP16 and FP8 state, FP8 W8A8, FP8 KV, INT4 QAD target, relaxed greedy g = 1 and 2. FP16 state quality is marked pending. Relaxed acceptance and the INT4 target list their quality as pending or quote nota-ai's own figures.
  • Single runs. lever_sweeps_quick.csv has runs = 1 and an empty y_std, and Section 2 of the README states single runs.

Blocking

1. The branch conflicts with main. engine/sglang/README.md is add/add with the geometry PR (#16), which is now on main. Merge main and combine the two patch sections.

2. Numbers rest on evidence that is not on main (standing rule: no committed file may cite unmerged or uncommitted evidence).

Fix. Mark each as pending its PR (profile #13, drafter #22), or wait until they merge and cite the committed files. Label the ceilings "derived with a bandwidth from PR #13, pending" until then.

3. The strict replay (P4, patch 0007) is called exact without a committed check.

  • Where. Section 3, row 4 says "exact by construction" and "none if bit-identical". The PR body says 0007 has not run on a GPU, and neither evidence/moonshot/gdn_exact_replay_check.json nor a test result is committed.
  • Fix. Write "designed to be bit-identical; bit-exactness check pending (evidence/moonshot/gdn_exact_replay_check.json)". The lever note in levers.py ("meant to be bit-identical") already says this.
  • Also say that gdn_exact_replay_check.py is a one-layer kernel check with random activations at batch 4. It is not the paper's pre-registered P4 test: batch 128, 512 greedy tokens, every state word and GDN output of the model.

4. One claim contradicts its CSV.

  • The claim. "The Triton W8A8 route runs but gives no speedup at any concurrency."
  • The CSV. lever_sweeps_quick.csv has y_vs_baseline 1.012 at c = 1, 1.059 at c = 32 and 0.965 at c = 128.
  • Fix. Write "no consistent gain (0.96-1.06x in single runs)".

5. Reproduction uses personal worktrees.

  • Where. The README's commands use ~/vp-wt/bench, ~/vp-wt/moonshot and ~/sglang-wt/moonshot, and logit_probe.py l. 48 hard-codes ~/vp-wt/bench/bench/workloads/mixed-v2/tune.jsonl.
  • Fix. Bench is on main now. Merge main, import bench from the repository, and give repo-relative commands, with the engine worktree created by scripts/sglang_worktree.sh and the patches applied.

Suggestions (non-blocking)

  1. ReplaySSM-spec labels. Section 3, row 5 calls MTP + ReplaySSM-spec "exact up to reassociation", while Section 1.2 describes the spec fold as a bitwise clone of the recurrent update. Under the stock-kernel contract, "up to reassociation" means not exact. State which applies, and label it pending its bit-exactness check.
  2. Single-run labels in the portfolio. Add "single run" to the portfolio's "measured 1.24x at c=128", as Section 2 does. Mark "likely near-lossless" as an expectation from DAMP on another model.

…s review

Per the per-workstream patch convention, the series moves to
engine/sglang/patches/moonshot/0001-0007 and engine/sglang/README.md keeps the
geometry section with a moonshot section below it. Figures from unmerged PRs
are marked as under review (profile PR #13), the drafter's tau cites
evidence/drafter on main, strict replay is described as designed to be
bit-identical with validation pending, the FP8 W8A8 sentence matches the CSV,
and reproduction uses repository paths (bench is on main).
@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE

Re-reviewed at b31003f. All five blocking items are resolved.

  1. Merge. main is merged, and the branch is current and conflict-free. The patches moved to engine/sglang/patches/moonshot/0001-0007. They still apply with git am to bd66ce343e in a scratch clone and reproduce the same tree (032c2ccf...). The engine README keeps geometry's section.
  2. Evidence sources.
  3. Strict replay. It now reads "designed to be bit-identical; validation pending", and the one-layer kernel check is distinguished from the pre-registered P4 test.
  4. FP8 W8A8. It now reads "no consistent gain (0.96-1.06x ...)", which matches the CSV.
  5. Paths. Reproduction uses repository paths, and no ~/vp-wt paths remain.

Rechecked at this commit: ceilings.py still regenerates ceilings.csv byte for byte; test_moonshot_levers.py passes (2 tests, GPU tests skipped); hooks pass, including mypy.

Note for merging. The "PR #13, under review" labels are acceptable while #13 is open. At merge time they cite an unmerged branch, so either merge #13 first or replace them with the committed file paths.

Suggestions (non-blocking):

  • "single runs, within run-to-run noise": run-to-run noise was not measured for these arms, so drop "within run-to-run noise", or cite a repeat-variance measurement.
  • "bench notes; evidence pending" for the 1,024-request run and the front-end limit: both are in the committed evidence/bench/probes/points.csv (status = feasibility-probe) and evidence/bench/README.md on main. Cite those instead of notes.

Profile workstream figures (bandwidth, kernel attribution, idle share) become
stated assumptions or pending markers until its evidence merges; bench's
capacity statement cites evidence/bench/README.md; single-run FP8 wording no
longer claims a noise band. ceilings.json and ceilings.csv regenerate
identically.
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