Skip to content

State safety: pinned MTP switch pairs, checkpoint reuse and the MTP radix-off history control - #147

Merged
SamMausberg merged 5 commits into
mainfrom
state/pinned-mtp-line1
Oct 1, 2026
Merged

SamMausberg merged 5 commits into
mainfrom
state/pinned-mtp-line1

Conversation

@SamMausberg

@SamMausberg SamMausberg commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

Results that landed since #118: the MTP half of the pinned switch matrix, the GDN checkpoint-reuse tests, and the MTP radix-off history control. Nothing here is a state error; every divergence is rounding-level.

What ran

  • Pinned matrix, MTP steps 3 with --disable-radix-cache, --disable-overlap-schedule, --enable-deterministic-inference and --enable-fp32-lm-head, each at c1 and c32 on one server, pools pinned (cap 8, 49,152 KV tokens, 40 GDN slots). Runs from ~/vp-wt/state at a493cbf (runner files identical to main), engine bd66ce34 clean: scripts/gpu_lock.sh -x python run_matrix.py --configs mtp_s3_noradix,mtp_s3_nooverlap,mtp_s3_det,mtp_s3_fp32head --passes c1,c32 --port 30055.
  • targeted.py prefix for MTP steps 3 (12 prompts), the tree and plain decoding (8 each), shared hold, same checkout.
  • targeted.py history --config mtp_s3_noradix with the 12 history prompts, shared hold, same checkout.

Code (commit before the evidence)

  • pairs_pinned.json: adds the radix-off floor (plain c1 vs c32 without the radix cache), radix-off MTP against radix-off plain at c1 and c32, overlap off against radix off, and deterministic plain vs MTP at c32. The plain runs are still queued, so these pairs are listed in missing_pairs for now.
  • pairs_cross_bench.json and a block in analyze_all.sh: compares the pinned radix-off runs with bench's unpinned radix-off equality runs at batch 1.
  • compare.py: each pair's summary now records bitwise_identical, first_difference_index (prompts by the first output index where tokens or top-k logprobs differ) and output0_differs (prompts whose first output token, a product of the prefill alone, differs, split at the 64-token GDN prefill chunk). Logprobs are compared only where both runs recorded them (logprobs_compared counts those prompts), so the queued logprobs-off controls are judged on their tokens. Additive keys; the CSV columns are unchanged. Unit tests added.

Findings (evidence/state_safety/README.md)

  • MTP radix-off history control: 12/12 prompts identical in tokens and logprobs (0 cached prefills), like plain decoding. The history dependence needs the radix cache for MTP too. This closes the pending control.
  • Pools at batch 1, radix off: the pinned mtp_s3_noradix/c1 run is bitwise identical (320/320, tokens and top-5 logprobs) to bench's unpinned radix-off MTP s3 run (cap 16, 426,043 KV tokens; cross_bench.json). Bench's README states as reasoning that pools do not matter at c=1 without the radix cache; for MTP it is now measured. The plain counterpart is queued.
  • Switches, MTP s3 (pinned): radix off vs on c1 98/320 (1.73/1k); overlap off vs on c1 161/320 (3.40); deterministic c1 vs c32 168/320 (3.48), so deterministic mode does not make MTP batch-invariant; FP32 head c1 vs c32 130/320 (2.44, against 3.25 with the BF16 head, larger margin at most 0.19 nats), so the FP32 head removes ties, not divergences. No large, no not_argmax.
  • Speculation against plain decoding, full set: at c1 no prompt is bitwise identical to plain decoding; for every MTP configuration, the logprobs of 313 or 314 prompts first differ at output index 1 (the first verify forward), the rest at index 2 or 3. That is consistent with the tap's decode-versus-verify recurrent kernels, though only the tapped prompts locate the kernel.
  • Prefill depends on the GDN cache strategy: at this pin --disable-overlap-schedule also switches extra_buffer to no_buffer. Radix off or overlap off changes the first output token's logprobs (prefill only) in 192 of 193 prompts longer than 64 tokens and 0 of 127 shorter ones, which extends tap v4's 6/6 to the full set. The cause (checkpoint tracking in the extend kernel) is still code reading.
  • GDN checkpoint reuse: a finished request keeps only its latest checkpoint, so decode checkpoints were restored in only 9/100 (MTP s3), 6/68 (tree) and 6/68 (plain) cases. Those match a cold prefill in tokens 9/9, 6/6 and 4/6 (2 ties). Checkpoints taken in the finishing cycle: 45/53 and 19/21, the rest exact ties. Plain decoding differs at similar rates.

Validation

  • pytest tests/test_state_safety_compare.py (pinned to one core): passes.
  • STATE_ALLOW_MISSING=1 experiments/state_safety/analyze_all.sh at 530ca00 regenerated the evidence. A script compared every value of the committed JSON files on main with the regenerated ones: all reproduce, apart from missing_pairs and, in pools.json (a list), 8 added entries with all 38 old ones unchanged. missing_pairs goes from 26 to 30: the four line-1 MTP pairs left it, and the eight new pairs whose plain runs are still queued joined it. The CSV diffs are additions only.
  • Host-identity check passes on all evidence files (analyze_all.sh and the pre-commit guard).

Not done here: the plain-decoding half of the switch matrix (queued), the logprobs-off and retraction controls, the second MTP session, the ReplaySSM and FlashInfer decode paths, aborts, chunked prefill and repeats (queued), and the declared first-cycle test (queued, unchanged).

Review

  • Codex P2 (absent logprobs counted as differences): fixed in fdf2197. A run without logprobs is compared on its tokens alone, with a unit test. Evidence regenerated at fdf2197 in d00d0af: the only change is the new logprobs_compared count, 320 for every pair, since all current runs recorded logprobs. A script checked that no other value changed.
  • The reviewer's note: missing_pairs is 30, not shorter. The 26 on main lose the four line-1 MTP pairs and gain eight new pairs whose plain runs are queued. The body above is corrected. The message of 4566540 says "shorter"; this note supersedes it.

…t bench's radix-off runs

pairs_pinned.json gains the radix-off floor (plain c1 vs c32 without the radix
cache), radix-off speculation against radix-off plain decoding at c1 and c32,
overlap off against radix off (overlap off also switches the GDN radix strategy
to no_buffer at this pin), and deterministic plain vs MTP at c32.
pairs_cross_bench.json compares the pinned radix-off runs with the bench
workstream's unpinned radix-off equality runs at batch 1.
…summaries

Each pair's summary now counts prompts whose tokens and top-k logprobs are
bitwise identical, prompts by the first output index where they differ, and,
by prompt length against the 64-token GDN prefill chunk, prompts whose first
output token (a product of the prefill alone) differs.
Evidence regenerated with STATE_ALLOW_MISSING=1 experiments/state_safety/analyze_all.sh
at 530ca00 from the B6 line-1 runs (mtp_s3 with the radix cache off, the overlap
scheduler off, deterministic inference and the FP32 head, c1 and c32, pinned
pools), the prefix tests and the MTP radix-off history test. Every earlier value
reproduces; the changes are new pairs, new runs, three new summary keys and a
shorter missing_pairs.
@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-01T19:46:06.356463Z d00d0af Manual request
ℹ️ 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.

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

ℹ️ 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/state_safety/compare.py Outdated
row['bitwise_identical'] = ta == tb and top_a == top_b
# The first output token comes from the prefill alone: a difference there is a
# difference in the prefill computation, before any decode or verify step.
row['output0_differs'] = ta[:1] != tb[:1] or top_a[:1] != top_b[: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 Treat absent logprobs as unavailable

When the queued plain__nolp and mtp_s3__nolp controls land, one side intentionally has an empty top_logprobs list. This comparison consequently marks every prompt as output0_differs, sets bitwise_identical false, and records first_difference_index as 0 even when all generated tokens match, falsely reporting a prefill/output difference caused only by disabled instrumentation. Distinguish unavailable logprobs from unequal logprobs and compare them only when both runs collected them.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in fdf2197: logprobs are compared only when both runs recorded them (any(top_a) and any(top_b)). Otherwise bitwise_identical, output0_differs and first_difference rest on the tokens alone, and each summary counts the prompts whose logprobs were compared (logprobs_compared). Unit test test_run_without_logprobs_is_compared_on_tokens_only. Evidence regenerated in d00d0af; the only change is the new count (320 everywhere, since no current run lacks logprobs).

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES (4566540, 1 blocking: Codex r4159245466; every evidence number checks out)

Reproduction of main's values. Compared value by value with main:

  • noise_floor.json, run_meta_pinned.json and targeted.json reproduce exactly.
  • pools.json contains all 38 old entries unchanged, plus 8 new ones (inserted, not appended).
  • In noise_floor_pinned.json every shared pair reproduces. Note that missing_pairs is longer now, 30 against 26: 4 old pairs are measured and 8 new pairs are queued. The PR body says "shorter".

Findings: every number matches the files.

  • Switches (noise_floor_pinned.json):
    • radix off against on at c1: 98/320, 1.73 per 1,000;
    • overlap off: 161/320, 3.40;
    • deterministic, c1 against c32: 168/320, 3.48;
    • FP32 head: 130/320, 2.44, all near, largest margin 0.186.
    • No pair has large or not_argmax.
  • First differences. Speculation against plain at c1: every MTP configuration has 313 or 314 prompts first differing at output index 1 and none bitwise identical.
  • Prefill. Radix off and overlap off each change output 0 in 192 of 193 prompts longer than 64 tokens and in 0 of 127 shorter ones.
  • cross_bench.json: 320/320 bitwise.
  • targeted.json:
    • The MTP radix-off history control is 12/12 identical, with 0 of 38 prefills cached.
    • Decode checkpoints were restored in 9/100, 6/68 and 6/68 cases. Among those, every non-identical case is plain decoding's two ties, so 9/9, 6/6 and 4/6 hold.
    • Finishing-cycle checkpoints: 45/53 and 19/21, the rest ties.

Code. The compare.py additions are additive keys, and the CSV columns are unchanged. The code commit precedes the evidence commit. The branch merges cleanly into main. Host identity: 0 hits.

Blocking: Codex r4159245466 is valid.

  • The new bitwise_identical, output0_differs and first_difference compare top_logprobs lists. A run without logprobs (the queued __nolp controls) would make every prompt look different at output 0.
  • When either side lacks logprobs:
    • compare tokens only;
    • record the logprob-based fields as unavailable (None) rather than as a difference;
    • and have the summary say how many prompts were token-only.
  • Extend tests/test_state_safety_compare.py with such a pair. Better to fix it now, before those controls run, than to discover it in their evidence.

My tests and pre-commit run on the fix head.

A run made without logprobs (the queued logprobs-off controls) has an empty
top_logprobs list. bitwise_identical, output0_differs and first_difference now
rest on the tokens alone for such a prompt, instead of reporting a difference at
output index 0, and each summary counts the prompts whose logprobs were compared
(logprobs_compared). Raised by Codex on #147.
STATE_ALLOW_MISSING=1 experiments/state_safety/analyze_all.sh at the previous
commit. The only change is the new logprobs_compared count in each pair's summary
(320 for every pair: all current runs recorded logprobs).
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: d00d0af766

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

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (d00d0af)

fdf2197 resolves my item, Codex's comment on absent logprobs.

  • Logprobs are compared only when both runs recorded them. compare.py checks any(top_a) and any(top_b) first. Otherwise bitwise_identical, output0_differs and first_difference rest on the tokens alone, and each row and summary reports logprobs_compared. A unit test covers a run without logprobs.
  • The regenerated evidence (d00d0af) changes nothing else. For cross_bench, cross_regime, noise_floor and noise_floor_pinned, every JSON value equals 4566540's apart from the new logprobs_compared key. Its value equals each pair's prompt count (320, or 96 and 8 in noise_floor), so every committed pair had logprobs on both sides and no committed number moves.
  • Checks. tests/test_state_safety_compare.py passes (13 tests), pre-commit from main is clean, and Codex found no issues on this head.

Optional: once the logprobs-off control pairs are compared, the state README should say that bitwise_identical then means tokens only and that logprobs_compared gives the count.

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