Skip to content

Exact witnesses for the P4 and P5 state-structure analyses - #20

Merged
SamMausberg merged 3 commits into
mainfrom
paper/state-structure
Sep 30, 2026
Merged

SamMausberg merged 3 commits into
mainfrom
paper/state-structure

Conversation

@SamMausberg

Copy link
Copy Markdown
Owner

The P4 (minimal recurrent state) and P5 (sharing computation across requests) analyses in ~/vp-coord/PROPOSALS.md rest on small counterexamples that were run in a sandbox outside this repository. Before the paper cites them, this PR reproduces them as exact tests.

What changed

tests/test_state_structure.py has nine test methods. Each checks one witness in exact rational arithmetic (Fraction), or with NumPy float32 where the point is rounding. The Gated DeltaNet step is S' = S alpha (I - beta k k^T) + beta v k^T.

  • Query-invisible is not unobservable. With alpha = beta = 1/2, k = (3/5, 4/5), q = e1 and a state difference along e2: q . ds = 0, but q^T A ds = -3/25.
  • Coordinate-key writes reach any matrix. Three writes with unit coordinate keys and gates in (0, 1) reach an arbitrary 3 x 3 target.
  • Contraction, not erasure. det A = alpha^d (1 - beta ||k||^2), which is 243/1000 for the chosen values.
  • Non-commuting transitions. Transitions for non-orthogonal keys do not commute.
  • SiLU raises rank. SiLU(log 2 [[1, 2], [2, 4]]) has determinant -64/1275 log^2 2, so rank one becomes rank two.
  • One step separates identical states. Four requests with the same state go from batch rank 1 to 4 after one step.
  • RMSNorm defeats the output projection's null space. Two vectors that W_o = [1, 0] cannot distinguish project to 1 and 1/5 after RMSNorm.
  • Lazy decay is not bit-identical. In float32, fl(fl(a1 x) a2) and fl(fl(a1 a2) x) differ by one ulp for a1 = a2 = 0.9, x = 1.3.
  • BF16 rounding breaks rank one. A BF16 x BF16 outer product is exact in float32 and has rank 1. Rounded to BF16, it has exact rank 28 of 32 (seed 0).

evidence/state_structure/ holds the JSON report, the log and a README with the command and what each witness shows.

Scope

These witnesses show that particular shortcuts are not valid in general. They are not measurements of Qwen3.5-4B states. The GPU experiment for P4 (bit-exact live replay at batch 128) belongs to the moonshot workstream, and the P5 ceiling belongs to profile.

Validation

  • python tests/test_state_structure.py: 9 of 9 pass in under 0.1 s.
  • python -m pytest tests/test_state_structure.py: 9 passed.
  • pre-commit run --files on the changed files passes. The hooks cover ruff, mypy and codespell; evidence/ is excluded from the hooks.
  • No new dependencies were installed.

The P4 (minimal recurrent state) and P5 (sharing across requests)
analyses rest on small counterexamples that were run outside this
repository. tests/test_state_structure.py reproduces nine of them in
exact rational arithmetic, or with NumPy float32 where the point is
rounding: a query-invisible state difference that becomes visible after
one gated-delta step (-3/25), coordinate-key writes reaching any matrix,
the transition determinant (contraction, not erasure), non-commuting
transitions, SiLU raising a rank-one matrix to rank two, one step taking
identical states to batch rank four, RMSNorm defeating the output
projection's null space, a one-ulp FP32 lazy-decay discrepancy, and a
BF16-rounded rank-one product with exact rank 28.

Results and the command are in evidence/state_structure/.
@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-30T19:50:08.387337Z 07bf911 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 at 07bf911 (the branch is current with main), whole diff. All nine witnesses are correct. One small item blocks: the float32 witness does not name its rounding.

What I ran and checked

  • pytest tests/test_state_structure.py: 9 passed. The evidence JSON reports status pass and 9 methods.
  • I checked each exact witness by hand:
    • q^T A ds = -alpha beta k_1 k_2 = -3/25. A is symmetric, so this equals ds^T A q, which is the next-step output difference for the same query.
    • The coordinate-key construction sets column j at step j and then scales it by alpha at the d - 1 - j later steps, so it reaches any target.
    • det = (9/10)^3 (1 - 2/3) = 243/1000.
    • The two transitions do not commute.
    • SiLU(c log 2) = c log 2 / (1 + 2^-c) gives [[2/3, 8/5], [8/5, 64/17]] with det = 128/51 - 64/25 = -64/1275. The log 2 substitution keeps this exact.
    • The batch rank goes from 1 to 4 over the rationals.
    • RMSNorm without eps or weight gives projections 1 and 1/5, with a rational root.
  • I recomputed the two floating-point witnesses independently:
    • float32 (0.9 * 1.3) * 0.9 = 0x3f86c8b4 and (0.9 * 0.9) * 1.3 = 0x3f86c8b3: one ulp apart.
    • With a separate struct-based round-to-nearest-even BF16 rounding, the rounded 32 x 32 outer product (default_rng(0)) has exact rational rank 28. The FP32 product equals the exact product and has rank one.
  • The README states the BF16 result the right way round: rank one in FP32, and rank 28 only after rounding to BF16.
  • No committed file cites ~/vp-coord. P4 and P5 are defined in TASKS.md.

Blocking

  1. Name the rounding of the float32 witness. The README row for test_fp32_lazy_decay_is_one_ulp_off and the test comment say "In float32, fl(...)" without the rounding. The BF16 helper does say ties-to-even. Write "IEEE binary32, round to nearest, ties to even (NumPy scalar arithmetic)". This is the rounding the one-ulp result depends on: another rounding, or an FMA-contracted GPU kernel, could give a different pair.

Suggestions (non-blocking)

  1. test_bf16_rounding_breaks_rank_one asserts >= 28, while the README and PR body claim exact rank 28. Use assertEqual(r_rounded, 28) so the test pins the stated number.
  2. The evidence README says the files were produced on main at 66e166e plus this change. Recording git rev-parse HEAD in the JSON, as the precision tests do, makes that auditable.
  3. The README could point at TASKS.md (P4, P5) for where these analyses are defined. The PR body cites ~/vp-coord/PROPOSALS.md.
  4. test_rmsnorm_hides_no_null_space uses RMSNorm without eps or the learned weight. Say so in the README, and note that a zero weight entry could restore the null space, so the witness covers the unweighted norm.

The one-ulp lazy-decay discrepancy depends on IEEE binary32 round to
nearest, ties to even without FMA contraction; the test comment and the
README now say so. The BF16 witness asserts the exact rank 28, the
RMSNorm witness notes it has no epsilon or weight, and the JSON records
the repository commit.
@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE

Re-reviewed at 227790b. The blocking item is resolved: the test comment and the README row now name the lazy-decay witness's arithmetic as IEEE binary32, round to nearest, ties to even (NumPy scalar multiplies, no FMA contraction), and note that a contracting or reordering kernel may differ.

The optional items are done too:

  • assertEqual(r_rounded, 28) now pins the stated rank;
  • the JSON records repo_commit e0edd06;
  • P4 and P5 are cited from TASKS.md;
  • the RMSNorm witness states that it uses no epsilon and no weight.

At this commit, 9 tests pass and the hooks, including mypy, pass on the changed files.

@SamMausberg
SamMausberg merged commit 08032e4 into main Sep 30, 2026
@SamMausberg
SamMausberg deleted the paper/state-structure branch September 30, 2026 19:52
SamMausberg added a commit that referenced this pull request Sep 30, 2026
…witnesses

PR #20 is merged, so the state-structure witnesses are cited as committed
evidence. The Amdahl example for state write avoidance no longer quotes
the unmerged 42% time share; it gives the formula, a byte-derived share
labelled as such, and leaves the measured share pending.

The sampling section states the adopted contract: fixed-noise
verification with the stock seeded sampler's keyed noise, which keeps
point-mass acceptance equal to stock and seeded outputs token-identical
to non-speculative decoding. Top-p falls back, and the partition-bracket
guards are marked as analysis rather than built.
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