Repository navigation
Exact witnesses that separate the exactness contracts (P7) - #26
Conversation
Six tests, in exact arithmetic or explicit-order float32, show that the contracts P7 distinguishes are different: FP32 reassociation flips a greedy winner; distinct FP32 values share a BF16 rounding cell; logits (1, 0) and (2, 0) share an argmax but not a law; two inverse-CDF samplers share a law but not seeded tokens; a regrouped gated-delta recurrence changes most FP32 outputs but few after BF16 rounding; and the transition norm is at most 1 exactly when 0 <= beta ||k||^2 <= 2, which gives the state-error recursion.
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. |
|
Verdict: APPROVE Reviewed at What I checked
Suggestions (non-blocking)
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 69d2d1bff7
ℹ️ 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".
| seq_out, split_out = [], [] | ||
| for _ in range(steps): | ||
| k = rng.standard_normal(d).astype(F32) | ||
| k = (k / F32(np.sqrt(np.sum(k.astype(np.float64) ** 2)))).astype(F32) |
There was a problem hiding this comment.
Make the GDN normalization reduction sequential
When this witness is rerun on another NumPy build or CPU architecture, np.sum may use a pairwise or otherwise implementation-dependent reduction, so the rounded normalized key—and consequently the reported recurrence-difference counts—is not governed by the fixed order promised in the module and evidence README. Accumulate the squared norm with an explicit loop before taking the square root, as is already done for the matrix reductions.
Useful? React with 👍 / 👎.
| Each test checks one small counterexample showing that two of the paper's contracts differ: | ||
| identical internal state, identical greedy outputs, identical seeded samples, and the exact | ||
| sampling distribution. Exact cases use Fractions; floating-point cases use NumPy scalar and |
There was a problem hiding this comment.
Cover empirical-quality equivalence in the witness suite
When this suite is used as the P7 counterexample evidence advertised by its header and README, it covers only four of the five stated contracts: this enumeration stops at sampling-distribution equality, and none of the six tests separates empirical-quality equivalence from a stronger contract. The resulting artifacts therefore cannot support the advertised five-contract separation; add a fixed metric/dataset witness or explicitly narrow the suite's claimed scope.
Useful? React with 👍 / 👎.
P7 (
TASKS.md) asks the paper to separate five contracts:Its counterexamples were run outside this repository. This PR reproduces them as tests before the paper cites them, in the same way PR #20 did for P4 and P5.
What changed
tests/test_contracts.pyhas six test methods. Exact cases useFraction. Floating-point cases use NumPy float32 scalar and elementwise arithmetic: IEEE binary32, round to nearest, ties to even, no FMA contraction. Every reduction is an explicit sequential loop, so the evaluation order is the one stated.1 + 2^-24 + 2^-24. Summed sequentially in FP32 it returns1, which ties row 0, and the first-index argmax picks token 0. Regrouped, it returns1 + 2^-23and picks token 1, as real arithmetic does.1and1 + 2^-10both round to1in BF16.(1, 0)and(2, 0)give base-2 laws(2/3, 1/3)and(4/5, 1/5).1/4to different tokens.S_t = S_0 P_t + W_t, which is equal in exact arithmetic. Over 50 steps at width 32 (seed 7), 1,481 of 1,600 FP32 outputs differ, and 2 still differ after BF16 rounding. The sandbox figures in P7 (1,173 of 1,600, and 1) came from a different setup; this test reproduces the phenomenon, not those numbers.(I - beta k k^T)has spectral norm at most 1 exactly when0 <= beta ||k||^2 <= 2, which gives the state-error recursion||E_t|| <= |alpha_t| ||E_{t-1}|| + ||eta_t||. Atbeta ||k||^2 = 5/2the norm is3/2.The query-invisible witness (equal readout now, different later) already exists in
tests/test_state_structure.py(PR #20).evidence/contracts/holds the JSON report and the log, both generated at29c85d7, which the JSON records. The README gives the command and what each witness shows.Scope
These witnesses show that the contracts are distinct in general. They are not engine measurements. How often each difference occurs in SGLang is the state workstream's divergence analysis.
Validation
python tests/test_contracts.py: 6 of 6 pass.python -m pytest tests/test_contracts.py: 6 passed.pre-commit run --filespasses on the changed files: ruff, mypy and codespell.evidence/is excluded from the hooks.