Skip to content

State safety: divergence given perturbation, by onset (perturbation.py) - #162

Merged
SamMausberg merged 4 commits into
mainfrom
state/perturbation-onset
Oct 1, 2026
Merged

SamMausberg merged 4 commits into
mainfrom
state/perturbation-onset

Conversation

@SamMausberg

@SamMausberg SamMausberg commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

How much of a divergence rate is "how many prompts were perturbed" and how much is "how often a perturbed trajectory flips a near tie"? The ratios to the floor in Appendix E (1.15 times at cap 16, about six times at cap 8) depend on the first. This PR measures the two separately, conditioned on when the perturbation starts.

Code

experiments/state_safety/perturbation.py (187995e), run by analyze_all.sh on both run roots:

  • A prompt is perturbed when its outputs are not bitwise identical (tokens and top-5 logprobs; tokens alone where a run has no logprobs, as in compare.py).
  • Its onset is the first output index where they differ (compare.py's first_difference).
  • Per pair, overall and by onset bucket (0-31, 32-127, 128+): the share of perturbed prompts whose tokens diverge, with a Wilson 95% interval, the median onset, and token divergences per 1,000 post-onset positions (onset to divergence or end).
  • Unit tests in tests/test_state_safety_perturbation.py.

Evidence (6793e90, from existing runs, no GPU; README scoped in 53020c7)

perturbation.json (first matrix) and perturbation_pinned.json. Summary in evidence/state_safety/README.md, "Divergence given perturbation":

Pair Perturbed Median onset Diverged (share, 95%) Per 1,000 post-onset
Plain c1 vs c32, cap 16 320/320 3 167 (0.52, 0.47-0.58) 3.55
Plain c1 vs c32, cap 8 75/320 0 41 (0.55, 0.43-0.65) 4.11
MTP s3 vs plain, c1 320/320 1 171 (0.53, 0.48-0.59) 3.71
MTP s1/s5/tree vs plain, c1 320/320 1 0.51-0.53 3.53-3.71
MTP vs plain, c32 320/320 1 0.52-0.57 3.55-3.99
MTP s1 vs s3, c1 241/320 41 92 (0.38) 3.47
  • Scope: the comparison this supports is speculation (MTP against plain decoding) beside the two floors, in the 0-31 onset bucket, which holds nearly every perturbed prompt. There the share is 35/62 (0.56, 0.44-0.68) for plain at cap 8, 165/318 (0.52, 0.46-0.57) at cap 16, and 0.51-0.57 for every MTP configuration against plain decoding. Post-onset rates are 3.5-4.1 per 1,000. On this measure no excess of speculation over either floor is detected; the cap-8 interval is wide, so a modest difference is not excluded.
  • The conditional rate varies by source, and the README lists the pairs that differ. Over pairs with at least 30 perturbed prompts, shares run from 0.29 to 0.60 and post-onset rates from 1.56 to 6.74. The most distant is the first matrix's deterministic + verify KV-split MTP pair, 28/96 (0.29, 0.21-0.39) at 1.56 per 1,000, unexplained; the pinned deterministic pair without the patch is 0.53. Also listed: the FP32 head (0.41), MTP s1 vs s3 (0.38 overall, 0.50 in the 0-31 bucket), overlap off vs radix off (0.60, 4.65), and the plain repeats at c32 (6.74 and 6.70 per 1,000, small and late-onset).

Checks

  • pytest tests/test_state_safety_perturbation.py and tests/test_state_safety_compare.py: pass. pre-commit (ruff, mypy, shellcheck, codespell, host-identity guard): pass.
  • Self-review items covered: exit status (a diverged prompt without a first difference raises), partial inputs (missing runs are listed in missing_pairs, empty groups give null), output written via temp file and rename.
  • Limits: intervals assume prompts are independent; the post-onset rate treats positions as independent although they cluster by prompt.

Appendix holds its "derived" floor sentence until this merges, then folds it citing the README.

Review

  • Reviewer (REQUEST CHANGES on 6793e90): "whatever perturbed it" and "none does" claimed more than the pairs show. Fixed in 53020c7. The conclusion is scoped to speculation against the floors, all ranges are given, and the deterministic + KV-split pair is named as unexplained. Also taken: "within the generated output (up to 256 tokens)" and "at c32 also from the prefill (36-63 prompts at output index 0)".

For each pair of runs, a prompt is perturbed when its outputs are not bitwise
identical, and its onset is the first output index where they differ. The
script reports, overall and by onset bucket (0-31, 32-127, 128+), the share of
perturbed prompts whose tokens diverge (Wilson 95% interval), the median onset,
and token divergences per 1,000 post-onset positions. analyze_all.sh runs it on
both run roots.
perturbation.py at 187995e on the existing runs (no new GPU run):
python perturbation.py --runs ~/vp-data/state/runs --pairs pairs.json and
--runs ~/vp-data/state/runs_pinned --pairs pairs_pinned.json. About half of the
perturbed prompts diverge in tokens whatever perturbed them, in the 0-31 onset
bucket that holds nearly all of them; post-onset rates 3.5 to 4.1 per 1,000.
@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-01T20:37:19.961974Z 53020c7 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.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES (6793e90; 1 blocking. The method and numbers are right, but two sentences generalize past the pairs.)

What checks out

  • Reproduction. I reran perturbation.py on ~/vp-data/state/runs and runs_pinned with the committed pairs files. Both outputs equal the committed perturbation.json (8 pairs) and perturbation_pinned.json (28 pairs) exactly, including missing_pairs.
  • The definitions support the README's wording.
    • Onset is compare.py's first_difference: the first index where the top-5 arrays differ before the first token divergence, or else the divergence index.
    • Exposure is onset to divergence inclusive (pos - onset + 1), or onset to the end of the shorter output.
    • No pair here has a tokens-only row (every row has logprobs on both sides), and no pair has a length mismatch, so neither edge case touches these numbers.
  • The table matches the JSON, as do the 0-31 bucket figures: 35/62, 165/318, and 51/103 for MTP s1 vs s3, plus 245 bitwise at cap 8, FP32 head 0.41 / 2.45, and the "other pinned pairs" shares of 0.44-0.60.

Blocking

  1. "So a perturbed trajectory flips a near tie at about the same rate whatever perturbed it" and "A source that flipped near ties more often per perturbed trajectory would raise the share or the post-onset rate; none does" claim more than the pairs show. The JSONs include pairs outside the stated range:

    • The first matrix's deterministic + verify KV split patch, mtp_s3 c1 vs c32 (96 prompts): 28/96 diverge, 0.29 (0.21-0.39), at 1.56 per 1,000 post-onset. Its interval excludes the 0.5 the bullet calls general, and the README neither mentions nor explains it.
    • Post-onset rates above 4.1: repeat session, plain c32 at 6.74 (42 perturbed, first matrix) and 6.70 (8, pinned); same server repeat c32, plain at 4.69 (9); overlap off vs radix off c1, mtp_s3 at 4.65 (share 0.60). The small ones are noisy, but "none does" is literally false.

    Scope the conclusion to what it rests on: speculation against plain decoding versus the cap-8 batch-shape floor, in the pinned matrix. Give the full range of shares and post-onset rates over all pairs, and name the deterministic + KV-split pair as unexplained.

Optional

  • "the share whose tokens diverge within the 256 generated tokens": outputs end at EOS or at 256 (the 96-prompt pair averages 238 tokens), so "within their outputs (at most 256 tokens)" is exact.
  • "speculation perturbs all 320 against plain decoding from the first verify forward" holds at c = 1, where onsets are at outputs 1-3. At c = 32, 36-63 prompts per configuration already differ at output 0, the prefill.

…list the exceptions

Review of #162: the conditional rate is not the same for every source of
perturbation. The README now limits the conclusion to MTP against plain decoding
beside the cap-8 and cap-16 floors, in the 0-31 onset bucket, and lists the pairs
that differ with their numbers, among them the unexplained deterministic + verify
KV-split pair (28/96, 0.29). The output may end before 256 tokens, and at c32
speculation also perturbs some prompts from the prefill.
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (provisional, on 53020c7: Codex has not reviewed this head yet. I will confirm once it does.)

53020c7 changes only the README section, and it resolves my item.

  • The conclusion is scoped. It now covers speculation against plain decoding beside the cap-8 and cap-16 floors, in the 0-31 onset bucket, with intervals: cap 8 35/62 (0.44-0.68), cap 16 165/318 (0.4641-0.5732), MTP 0.51-0.57. It says "mainly the number of prompts perturbed" and that no excess is detected on this measure, and it keeps the caveat about the wide cap-8 interval.
  • The variation is stated with every pair's numbers. Over pairs with at least 30 perturbed prompts, shares run 0.29-0.60 and post-onset rates 1.56-6.74 (both bounds checked against the JSONs). The deterministic + KV-split pair is called unexplained, beside the unpatched pinned 0.53. The FP32 head, s1 vs s3 (0.50 in the bucket), overlap vs radix (0.60, 4.65) and the small late-onset repeats (6.74, 6.70, 4.69) are listed, and the remaining pinned pairs fall at 0.47-0.55 and 2.97-3.98.
  • Both optional fixes are in. At c1 the onset is output 1 for 313-314 prompts, and at c32 it is output 0 for 36-63, both as I counted.
  • Checks. The JSONs are unchanged from what I reproduced. tests/test_state_safety_perturbation.py and test_state_safety_compare.py pass (15 tests), and pre-commit from main is clean.

Nit, optional: the lowest share among "the other pinned pairs" is 152/320 = 0.475 (MTP s5 c1 vs c32), which conventional rounding makes 0.48. "0.47 to 0.55" is fine as a range that contains it.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 53020c7b74

ℹ️ 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 (confirmed on 53020c7)

This confirms my provisional approval. Codex found no issues on this head (20:37 UTC).

@SamMausberg
SamMausberg merged commit 94193d2 into main Oct 1, 2026
SamMausberg added a commit that referenced this pull request Oct 1, 2026
The editor shortens Table 1, Table 2, Section 3's accumulation lemma, the kernel
checks, Section 2.5 and Figure 5 in the main text; their full versions land here
in the same milestone as those cuts:

- A.1: the full numerical-assumptions table, verbatim, as tab:assumptions-full;
- A.3: the statement of Lemma lem:tree before its proof, the sentence on what the
  tree's shape distinguishes, and that the conservative model covers the Hopper
  model's gamma about sixfold;
- A.8: the outlier-column, PCA and centring results (selfevidence-csv, stats) and
  the gather-size sentence that #160 dropped, traced to selfevidence_plain4b.json's
  batch unions (9.45 and 12.51 entries on steps with 5-8 and 9-16 positions);
- A.9 (new, app:kernel-checks): the per-variant self-test, runtime probes and
  tests, the measured int8 TMA violation and the seven-build version pattern that
  matches triton-lang/triton#9433 (kernel-impl, kernel-tma, triton-tma);
- C.5: the capture prompts' datasets and domains from prompt_manifest.csv;
- C.7: the full transport table, verbatim, as tab:transport-full;
- E.8: Figure fig:frontier with its detail (four of nine arms, 3.45x per-request
  rate, 0.98x and 0.86x, run-to-run variation), and the divergence-given-
  perturbation result of #162 with its intervals and exceptions, cited through
  a new register entry state-perturb.

The app-scope glossary terms "Capture and replay", "Certified row" and
"Enclosure" go: the main-text block now defines them.

Built alone, the branch shows lem:tree and fig:frontier defined twice; the
editor's cuts remove the main-text copies in the same push. Checker clean.
SamMausberg added a commit that referenced this pull request Oct 1, 2026
The main text now explains the method in plain operations before its
machinery, and separates method from measurement:

- Introduction: what a verifier uses from the head, the method as four
  operations (approximate, bound, refine, fall back), why the reference must
  be the engine's own kernel (with a marked hypothetical BF16 tie), transport
  in one paragraph, and shorter contributions.
- Section 2 defines vocabulary entry, position and batch shape, keeps the
  references, the gap condition and the interval form, and is the one place
  that explains the error models and the fallback. Table 1 is a short
  one-column table; the full table is Appendix A (tab:assumptions-full).
  Section 2.5 keeps the headline divergences and the scoped perturbation
  result (#162); the rest is in Appendix D.
- Section 3 is the method: the error bound (Lemma tree now stated in
  Appendix A), the refinement as five steps, sampled decisions, the kernel
  and its checks (TMA detail in Appendix A.9).
- Section 4 is the measurement: setup, candidates, fallback and agreement,
  and the head-only runtime with its committed cause (kernel-micro).
- Section 5 keeps the transport argument; Table 2 is a two-drafter summary
  (full table in Appendix C) and Figure 4 is placed at the section start.
- Section 7 consolidates the limitations; the stock serving frontier keeps
  two sentences and its figure moves to Appendix E.

"Row" now means a row of W only in mathematics; prose says vocabulary entry
for rows of W and position for head inputs.
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