Repository navigation
Moonshot: commit the sweep levers and the P13 state-rank study - #128
Conversation
These lived only as uncommitted changes in the moonshot worktree, which the queued P13 job and the planned X3/X4 sweeps run from, so their outputs could not have been cited. - levers.py: tuned_noradix, gdn_triton, gdn_verify_triton, prefill_delay4/8 and fold (the last needs the drafter's engine patch, not on main; its comment says so). - summarise.py: the sweeps table adds server_full_batch_tps, the token-weighted full-batch decode rate, beside the median-window rate. - gdn_state_rank_study.py: P13's offline, training-free test of a rank-r GDN state in the key dimension; not run yet.
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: d4ce798806
ℹ️ 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".
| parser.add_argument('--ranks', type=int, nargs='+', default=[32, 64, 96, 128]) | ||
| parser.add_argument('--kinds', nargs='+', default=['energy', 'query', 'product']) |
There was a problem hiding this comment.
Reject invalid rank and basis sweep values
When a custom sweep contains a typo such as --kinds qurey, bases() silently executes the product branch but records the result as qurey; likewise, ranks outside 1..128 produce mislabeled data (r=0 selects all 128 vectors while reporting a zero state fraction, and r>128 still selects only 128 vectors). Constrain --kinds with argparse choices and reject ranks outside the valid interval before running so malformed experiment commands cannot silently corrupt the study output.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 3f630a3. --kinds now uses argparse choices (energy, query, product), --ranks accepts only integers in 1..128, and bases() raises on an unknown kind or an out-of-range rank instead of falling through to the product basis. Checked: --kinds qurey, --ranks 0 and --ranks 129 each exit 2 with an argparse error before the model loads. The defaults, which the queued P13 run uses, are unchanged.
A typo such as --kinds qurey silently ran the product basis under the typo's label, and ranks outside 1..128 produced mislabelled rows (r = 0 selected all 128 vectors). --kinds now has argparse choices, --ranks accepts only 1..128, and bases() raises on an unknown kind or rank (Codex review of #128). The defaults the queued P13 run uses are unchanged.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3f630a3ca2
ℹ️ 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".
| parser.add_argument('--calib-count', type=int, default=24) | ||
| parser.add_argument('--eval-count', type=int, default=8) | ||
| parser.add_argument('--probes', type=int, default=24) |
There was a problem hiding this comment.
Require positive sample counts
When any of --calib-count, --eval-count, or --probes is zero, the expensive GPU run eventually fails through division by zero or empty statistics; negative calibration/evaluation counts are worse because Python slicing accepts them, so the study processes nearly the entire dataset while recording a negative requested count in the result metadata. Use a positive-integer argparse type for all three options so malformed experiment commands fail before loading the model.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in a1c49a9. --calib-count, --eval-count and --probes (the script's only count arguments) accept only integers of at least 1, checked at argument parsing; --calib-count 0, --eval-count -1 and --probes 0 each exit 2 before the model loads. A count larger than its file now stops the run instead of recording fewer texts than requested. The defaults (24, 8, 24) fit the default files (48 and 512 texts).
--calib-count, --eval-count or --probes of zero failed late with a division by zero, and negative counts sliced nearly the whole file while recording the negative number. All three now accept only integers of at least 1, and a count larger than its file stops the run instead of recording fewer texts than requested (Codex review of #128). The defaults (24, 8, 24) fit the default files.
|
Verdict: REQUEST CHANGES (one item: the new Codex P2) Review of the exact head 3f630a3: d4ce798 plus the argument checks for Codex r4156847576. Verified
Blocking
Merge-order note (non-blocking for this PR)
Suggestion. The |
|
@codex review |
The ~35 ms served cycle at c = 128 was an estimate, and that arrivals' prefill passes cause the gap is untested (reviewer's note).
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 781ec0dab0
ℹ️ 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".
|
|
||
| @torch.no_grad() | ||
| def kl_and_agreement(model: Any, ids: torch.Tensor, ref_logp: torch.Tensor) -> tuple[float, float]: | ||
| logits = model(ids.unsqueeze(0)).logits[0].float() |
There was a problem hiding this comment.
Disable the model cache for projected-state forwards
With the pinned Qwen model's default use_cache=True, these teacher-forced calls still create the model's fixed-width GDN recurrent cache. Once state['basis'] selects any rank below 128, the replacement rule returns an r-wide final state that cannot be stored in that 128-wide cache, so the study fails on its first reduced-rank evaluation instead of producing results. Pass use_cache=False on every calibration, reference, evaluation, and retrieval model call.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 154e94f: every calibration, reference, evaluation and retrieval call now passes use_cache=False. One correction on the failure mode: at the pinned transformers (the SGLang venv's), a fresh DynamicCache stores the r-wide final state without error (a tiny random Qwen3.5 model at r = 32 returns a cache state of shape [1, 2, 32, 16]), so the study would not have failed; it would only have computed and stored a state it never reuses. The new tests/test_moonshot_gdn_state_rank.py runs the patched rule on that tiny model on CPU: a full-rank rotation reproduces the unprojected outputs within 1e-4, and rank 32 runs without the cache (it skips without torch and transformers).
|
Verdict: APPROVE (provisional, on 781ec0d: Codex is still running on this head. I will confirm or withdraw once it finishes.) Re-review of a1c49a9 and 781ec0d on top of 3f630a3.
Everything else stands from my review of 3f630a3. |
|
Verdict: REQUEST CHANGES (withdraws my provisional approval of 781ec0d) Codex's P1 on 781ec0d is valid and blocking. The projected-state forwards run with |
…ed rule The study's teacher-forced calls left use_cache at its default, so HF built a cache and had the projected rule return each layer's final state. At the pinned transformers a fresh DynamicCache stores the r-wide state without error (checked on a tiny model), but the cache is never reused, so every call now passes use_cache=False (Codex review of #128). tests/test_moonshot_gdn_state_rank.py runs the patched rule on a tiny random Qwen3.5 model on CPU: a full-rank rotation reproduces the stock outputs within 1e-4, and rank 32 runs without the cache. It skips without torch and transformers.
|
@codex review |
|
Verdict: APPROVE (provisional, on 154e94f: Codex is still running on this head. I will confirm or withdraw once it finishes.) 154e94f addresses Codex P1 r4157009510, and the thread has a reply:
I ran the test in the SGLang venv on one core with CUDA hidden (2 passed). Pre-commit passes on both files. Everything else stands from my reviews of 3f630a3 and 781ec0d. |
|
Codex Review: Didn't find any major issues. Nice work! 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". |
Moves the moonshot work that existed only as uncommitted changes in the moonshot worktree onto main. The queued and planned jobs that use it then run committed code. Two of those jobs were already queued against that worktree: the P13 state-rank study (shared) and the quality probe for the INT4/DFlash arms (shared). Their outputs could not have been cited otherwise.
What is added
experiments/moonshot/levers.py, the levers used by the planned X3, X4c and X4d sweeps:tuned_noradix: radix off with 128 state slots, matching bench's tuned arms.gdn_triton: Triton GDN decode and verify, pinned so arms on different engines match.gdn_verify_triton: Triton GDN verify only. Its exactness class is pending bench's equality classification.prefill_delay4andprefill_delay8: SGLang's prefill delayer, batching arrivals (scheduling only).fold: GDN fold-every-commit buffered verify. It needs the drafter workstream's engine patch, which is not on main. The lever's comment says so and that, on an engine without the patch, the flag alone gives stock ReplaySSM-spec.No existing lever changes.
experiments/moonshot/summarise.py: the sweeps table gainsserver_full_batch_tps, the token-weighted server decode rate over full-batch windows (bench'slogged_gen_tps_full_batch). It sits beside the median-window rate already reported, which drops prefill-heavy windows and so flatters speculation.experiments/moonshot/gdn_state_rank_study.py: proposal P13's offline, training-free test. Each GDN head's state is reduced to rank r in the key dimension, with energy, query and product bases. It runs on the HF model with teacher forcing, measuring KL, top-1 agreement and a delayed-retrieval probe. It has not run yet. The coordinator's rule for P13 is one run, closed if it misses the quality budget.experiments/moonshot/README.md: a row forgdn_state_rank_study.pyin the script index.Left out on purpose: the README's exactness-class updates. They cite bench's
evidence/bench/equality/classes.json, which is not on main yet, and will follow once bench's equality PR merges. The worktree's oldergdn_fast_verify_check.pyis also left out, since main's version is newer.Validation
tests/test_moonshot_levers.py: 2 passed, 3 skipped (engine tests without SGLang).