From b3a0ede2c2065227b59c78d05c2268bf291d6ee6 Mon Sep 17 00:00:00 2001 From: Patrick Dugan Date: Mon, 23 Nov 2026 21:07:42 +0800 Subject: [PATCH 01/18] RT-BPD-02: register reached-state weighted rank source-only math before implementation --- mechinterp/bpd/theory/rtbpd02/PROTOCOL.md | 45 +++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 mechinterp/bpd/theory/rtbpd02/PROTOCOL.md diff --git a/mechinterp/bpd/theory/rtbpd02/PROTOCOL.md b/mechinterp/bpd/theory/rtbpd02/PROTOCOL.md new file mode 100644 index 00000000..7baa6b31 --- /dev/null +++ b/mechinterp/bpd/theory/rtbpd02/PROTOCOL.md @@ -0,0 +1,45 @@ +# RT-BPD-02: reached-state / reader-weighted low-rank theory (source-only registration) + +**Registered 2026-11-23.** Scope: exact finite-dimensional mathematics, deterministic NumPy CPU fixtures, and a schema for a future, explicitly authorized CAL-only Nanbeige archive replay. The Nanbeige pretrained research goal remains paused; no model loading, new neural forward passes, training, GPU reservation, or protected-root access is authorized by this protocol. The 168-case ARG-03-N confirmation cohort stays sealed. + +## Physical questions and estimands + +A shared operator \`W : R^n -> R^m\` is applied repeatedly to inputs with pass-specific reached-state second moments \`Sigma_t = E[h_t h_t^T]\`. For paired counterfactual worlds at the same occurrence, define \`Delta h_t = h_t^A - h_t^B\` and \`Sigma_t^Delta = E[Delta h_t Delta h_t^T]\`. The root is the independent unit; worlds, tokens, module occurrences and passes are nested. Keep a fixed pass, layer, module, token selector, checkpoint, precision and factor rank in every comparison. + +For positive-semidefinite \`Sigma\`, fixed linear downstream reader \`A\` (or identity), and rank bound \`r\`, minimize + +\`\`\` + E_A(K) = tr(A (W-K) Sigma (W-K)^T A^T) + = || A (W-K) Sigma^(1/2) ||_F^2 + subject to rank(K) <= r. +\`\`\` + +Freeze three candidates: (i) Euclidean rank-r truncated SVD of \`W\`; (ii) input-moment-optimal \`K_r\`; (iii) fixed-reader-and-input-moment-optimal \`K_{r,A}\`. Compare their realized physical operators, empirical squared write-error and downstream reader-error on the same source-only vectors. A data-dependent Jacobian \`A(h)\` has no claimed single-SVD solution; any such optimization requires a separately specified numerical method. + +## Exact mathematical claims to check + +Let \`S=Sigma^(1/2)\`, \`S^+\` its Moore-Penrose pseudoinverse, and \`B=AWS\`. With \`M_r\` denoting an SVD rank-r truncation: + +1. \`K_r=(WS)_r S^+\` attains the minimum, including for singular PSD \`Sigma\`, with objective \`sum_{j>r} sigma_j(WS)^2\`. +2. \`K_{r,A}=A^+ (AWS)_r S^+\` attains the minimum for a fixed \`A\`, with objective \`sum_{j>r} sigma_j(AWS)^2\`. The result follows because \`AWS\` has columns in \`im(A)\` and rows in the row space of \`S\`. +3. Solutions are generally nonunique on \`ker(S)\` and \`ker(A)\`. Pseudoinverses choose a minimal-norm representative, with SVD degeneracy handled by comparing operators' physical responses and objectives rather than arbitrary atom labels. +4. For an orthogonal input coordinate change \`Q\`, \`W' = W Q^T\`, \`Sigma'=Q Sigma Q^T\`, the objective and optimal physical map transform covariantly. In degenerate singular-value spaces, compare objectives and projector subspaces rather than expecting an identical SVD basis. +5. When \`A=I\` and \`Sigma=I\`, the formula reduces to conventional truncated SVD. + +These are weighted Eckart-Young facts; novelty claimed here is the recurrent-state and downstream-reader application, not the linear-algebra theorem. + +## Locked synthetic checks + +- \`W = diag(4,3,2)\`, \`Sigma = diag(0.01,1,10)\`, rank 2. Standard truncated SVD has weighted error \`40\`; input-weighted optimum has error \`0.16\`. Compare both against the tail singular-value oracle, with absolute error <=1e-9. +- Same \`W\`, \`Sigma\`, rank 1 and reader \`A=[0,1,0]\`. Reader-specific optimum must have reader error <=1e-9; input-weighted rank-1 candidate has reader error \`9\`. +- Positive-semidefinite singular \`Sigma\`, with a zero eigenvalue. Match the SVD tail oracle and verify no spurious demand on the unobserved direction. +- Identity-input/identity-reader reduction; orthogonal input-gauge covariance; nonsquare rank-deficient reader; null reader; zero moment; invalid indefinite/asymmetric/nonfinite input rejection; paired-contrast input checks. +- All tests run on CPU using only Python stdlib and NumPy. No Torch, HuggingFace, device allocation, model assets or external services. + +Source-only acceptance means each theorem-derived identity agrees with its independent numerical oracle and the locked fixtures pass. No native Nanbeige correctness or behavioral mediation claim follows from this gate. + +## Future archive replay (separately authorized) + +Accept CAL-only archived, actually reached *physical* pre-down_proj inputs, using an explicit schema containing repository/commit/checkpoint digest, backend and quantization, physical layer, pass, token selector, root ID, world ID, input vector, and paired source-identification policy. First build root-balanced \`Sigma_t\` and \`Sigma_t^Delta\` on **CAL roots only**; freeze bases before comparing on disjoint DEV roots. Log post-rounding physical interventions and independently scored oracle outcomes as separate later stages. The currently public Nanbeige report gives aggregate cosines and fitted-operator comparisons; it does not publish the raw per-root reached-state vectors required to construct these covariances. This source-only stage therefore makes no archive-fit accuracy assertion. + +Primary reference: \`MoralityLabAI/LoopedTransformers\` Nanbeige synthesis at \`c074e35\` (\`reports/nanbeige_bpd_gym/NANBEIGE_RESEARCH_SYNTHESIS_20261123.md\`), and \`BPD\` NC-06 gauge/weighting work. Maintain the research pause and the protected ARG-03-N seal. From e444f717facda10a4e5f27bd7b555d314f8fac88 Mon Sep 17 00:00:00 2001 From: Patrick Dugan Date: Mon, 23 Nov 2026 21:08:11 +0800 Subject: [PATCH 02/18] RT-BPD-02: implement exact PSD reached-state and fixed-reader rank solvers --- .../bpd/theory/rtbpd02/weighted_rank.py | 133 ++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 mechinterp/bpd/theory/rtbpd02/weighted_rank.py diff --git a/mechinterp/bpd/theory/rtbpd02/weighted_rank.py b/mechinterp/bpd/theory/rtbpd02/weighted_rank.py new file mode 100644 index 00000000..4a5d4593 --- /dev/null +++ b/mechinterp/bpd/theory/rtbpd02/weighted_rank.py @@ -0,0 +1,133 @@ +"""RT-BPD-02 source-only weighted rank approximation reference implementation. + +All functions are NumPy CPU operations over supplied arrays. No model execution +or external data access is performed. This module describes physical operators, +not learned individual BPD atom identities. +""" +from __future__ import annotations + +from dataclasses import dataclass + +import numpy as np + + +@dataclass(frozen=True) +class RankSolution: + operator: np.ndarray + error: float + tail_oracle: float + singular_values: np.ndarray + input_support_rank: int + reader_rank: int + + +def _matrix(value: np.ndarray, name: str) -> np.ndarray: + out = np.asarray(value, dtype=np.float64) + if out.ndim != 2 or not np.isfinite(out).all(): + raise ValueError(f"{name} must be a finite two-dimensional matrix") + return out + + +def uncentered_second_moment(rows: np.ndarray, weights: np.ndarray | None = None) -> np.ndarray: + """Return E[x x^T]. Rows must be the intended independent weighted units.""" + x = _matrix(rows, "rows") + if not x.shape[0]: + raise ValueError("at least one row is required") + if weights is None: + return x.T @ x / x.shape[0] + w = np.asarray(weights, dtype=np.float64) + if w.shape != (x.shape[0],) or not np.isfinite(w).all() or (w < 0).any() or w.sum() <= 0: + raise ValueError("weights must be finite, nonnegative, and have positive total") + return x.T @ (w[:, None] * x) / w.sum() + + +def paired_contrast_moment(a: np.ndarray, b: np.ndarray, weights: np.ndarray | None = None) -> np.ndarray: + """Second moment of paired A/B differences. Caller guarantees root balance.""" + aa = _matrix(a, "a") + bb = _matrix(b, "b") + if aa.shape != bb.shape: + raise ValueError("paired worlds need the same shape") + return uncentered_second_moment(aa - bb, weights) + + +def truncated_svd(operator: np.ndarray, rank: int) -> np.ndarray: + w = _matrix(operator, "operator") + if not isinstance(rank, (int, np.integer)) or isinstance(rank, (bool, np.bool_)) or rank < 0: + raise ValueError("rank must be a nonnegative integer") + u, s, vt = np.linalg.svd(w, full_matrices=False) + k = min(rank, len(s)) + return (u[:, :k] * s[:k]) @ vt[:k, :] + + +def _moment_sqrt_and_pinv(covariance: np.ndarray, n: int, rtol: float) -> tuple[np.ndarray, np.ndarray, int]: + cov = _matrix(covariance, "covariance") + if cov.shape != (n, n): + raise ValueError("covariance shape must match operator inputs") + scale = max(1.0, float(np.linalg.norm(cov, ord=2))) + if not np.allclose(cov, cov.T, atol=1e-12 * scale, rtol=1e-12): + raise ValueError("covariance must be symmetric") + sym = (cov + cov.T) / 2 + eigval, eigvec = np.linalg.eigh(sym) + if eigval[0] < -1e-12 * scale: + raise ValueError("covariance must be positive semidefinite") + positive = eigval > rtol * max(float(eigval[-1]), np.finfo(np.float64).tiny) + basis = eigvec[:, positive] + root = np.sqrt(eigval[positive]) + sqrt = (basis * root) @ basis.T + pinv_sqrt = (basis / root) @ basis.T + return sqrt, pinv_sqrt, int(positive.sum()) + + +def optimal_weighted_rank( + operator: np.ndarray, + covariance: np.ndarray, + rank: int, + reader: np.ndarray | None = None, + *, + rtol: float = 1e-12, +) -> RankSolution: + """Minimize ||reader @ (W - K) @ sqrt(covariance)||_F^2, rank(K)<=rank. + + With reader=None, the identity map on physical write space is used. + A truncated SVD of reader@W@sqrt(covariance) gives the exact global + optimum. Pseudoinverses pick a minimum-norm representative, including + when covariance or reader is rank deficient. + + Eigenmodes below rtol * largest covariance eigenvalue are treated as + numerical null directions. Readers use the same relative cutoff. + """ + w = _matrix(operator, "operator") + if not isinstance(rank, (int, np.integer)) or isinstance(rank, (bool, np.bool_)) or rank < 0: + raise ValueError("rank must be a nonnegative integer") + if not np.isfinite(rtol) or rtol <= 0 or rtol >= 1: + raise ValueError("rtol must be in (0,1)") + m, n = w.shape + a = np.eye(m) if reader is None else _matrix(reader, "reader") + if a.shape[1] != m: + raise ValueError("reader input width must match operator output width") + sqrt, pinv_sqrt, n_support = _moment_sqrt_and_pinv(covariance, n, rtol) + target = a @ w @ sqrt + u, s, vt = np.linalg.svd(target, full_matrices=False) + k = min(rank, len(s)) + target_rank_k = (u[:, :k] * s[:k]) @ vt[:k, :] + if reader is None: + estimate = target_rank_k @ pinv_sqrt + else: + estimate = np.linalg.pinv(a, rcond=rtol) @ target_rank_k @ pinv_sqrt + error = float(np.linalg.norm(a @ (w - estimate) @ sqrt, ord="fro") ** 2) + tail = float(np.sum(s[k:] ** 2)) + reader_rank = m if reader is None else int(np.linalg.matrix_rank(a, tol=rtol * (np.linalg.svd(a, compute_uv=False)[0] if a.size else 0))) + return RankSolution(estimate, error, tail, s, n_support, reader_rank) + + +def weighted_error(operator: np.ndarray, estimate: np.ndarray, covariance: np.ndarray, reader: np.ndarray | None = None) -> float: + """Evaluate a rank candidate with the same physical reached-state metric.""" + w = _matrix(operator, "operator") + k = _matrix(estimate, "estimate") + if k.shape != w.shape: + raise ValueError("estimate must have the operator shape") + a = np.eye(w.shape[0]) if reader is None else _matrix(reader, "reader") + if a.shape[1] != w.shape[0]: + raise ValueError("reader input width must match operator output width") + sqrt, _, _ = _moment_sqrt_and_pinv(covariance, w.shape[1], 1e-12) + return float(np.linalg.norm(a @ (w - k) @ sqrt, ord="fro") ** 2) From 6a6a87607417c0ae53e944768a57ce6d9b441757 Mon Sep 17 00:00:00 2001 From: Patrick Dugan Date: Mon, 23 Nov 2026 21:08:35 +0800 Subject: [PATCH 03/18] RT-BPD-02: test exact singular, reader, gauge and contrast properties on CPU --- .../bpd/theory/rtbpd02/test_weighted_rank.py | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 mechinterp/bpd/theory/rtbpd02/test_weighted_rank.py diff --git a/mechinterp/bpd/theory/rtbpd02/test_weighted_rank.py b/mechinterp/bpd/theory/rtbpd02/test_weighted_rank.py new file mode 100644 index 00000000..d795cc1b --- /dev/null +++ b/mechinterp/bpd/theory/rtbpd02/test_weighted_rank.py @@ -0,0 +1,103 @@ +"""Pure CPU independent numerical checks for RT-BPD-02.""" +import unittest + +import numpy as np + +from mechinterp.bpd.theory.rtbpd02.weighted_rank import ( + optimal_weighted_rank, paired_contrast_moment, + truncated_svd, uncentered_second_moment, weighted_error, +) + + +class RTBPD02Tests(unittest.TestCase): + def setUp(self): + self.w = np.diag([4.0, 3.0, 2.0]) + self.c = np.diag([0.01, 1.0, 10.0]) + + def test_locked_reached_state_fixture(self): + ordinary = truncated_svd(self.w, 2) + reached = optimal_weighted_rank(self.w, self.c, 2) + self.assertAlmostEqual(weighted_error(self.w, ordinary, self.c), 40.0, places=9) + self.assertAlmostEqual(reached.error, 0.16, places=9) + self.assertAlmostEqual(reached.error, reached.tail_oracle, places=9) + self.assertLess(reached.error, weighted_error(self.w, ordinary, self.c)) + self.assertLessEqual(np.linalg.matrix_rank(reached.operator, tol=1e-9), 2) + + def test_locked_future_reader_fixture(self): + reader = np.array([[0.0, 1.0, 0.0]]) + reader_fit = optimal_weighted_rank(self.w, self.c, 1, reader) + state_fit = optimal_weighted_rank(self.w, self.c, 1) + self.assertLess(reader_fit.error, 1e-9) + self.assertAlmostEqual(weighted_error(self.w, state_fit.operator, self.c, reader), 9.0, places=9) + self.assertAlmostEqual(reader_fit.error, reader_fit.tail_oracle, places=9) + + def test_singular_psd_and_rank_deficient_reader(self): + w = np.array([[3., 2., 1.], [1., 4., 7.], [2., 8., 6.], [5., 9., 3.]]) + c = np.diag([4., 1., 0.]) + reader = np.array([[1., 2., 0., 1.], [2., 4., 0., 2.], [0., 0., 0., 0.]]) + for r in (0, 1, 2, 3): + fit = optimal_weighted_rank(w, c, r, reader) + self.assertAlmostEqual(fit.error, fit.tail_oracle, places=8) + self.assertLessEqual(np.linalg.matrix_rank(fit.operator, tol=1e-8), r) + self.assertEqual(fit.input_support_rank, 2) + self.assertEqual(fit.reader_rank, 1) + + def test_identity_reduces_to_svd(self): + rng = np.random.default_rng(20261123) + w = rng.normal(size=(5, 4)) + for r in range(5): + fit = optimal_weighted_rank(w, np.eye(4), r) + np.testing.assert_allclose(fit.operator, truncated_svd(w, r), atol=1e-10) + self.assertAlmostEqual(fit.error, fit.tail_oracle, places=9) + + def test_orthogonal_input_gauge(self): + rng = np.random.default_rng(2460) + q, _ = np.linalg.qr(rng.normal(size=(3, 3))) + w2 = self.w @ q.T + c2 = q @ self.c @ q.T + a = np.array([[1., 1., 0.], [0., 0., 1.]]) + for r in (0, 1, 2): + fit = optimal_weighted_rank(self.w, self.c, r, a) + rotated = optimal_weighted_rank(w2, c2, r, a) + np.testing.assert_allclose(rotated.operator, fit.operator @ q.T, atol=1e-9) + self.assertAlmostEqual(rotated.error, fit.error, places=9) + + def test_zero_covariance_and_zero_reader(self): + zero_c = optimal_weighted_rank(self.w, np.zeros((3, 3)), 1) + np.testing.assert_array_equal(zero_c.operator, np.zeros((3, 3))) + self.assertEqual(zero_c.error, 0.0) + self.assertEqual(zero_c.input_support_rank, 0) + zero_a = optimal_weighted_rank(self.w, self.c, 1, np.zeros((2, 3))) + self.assertEqual(zero_a.error, 0.0) + self.assertEqual(zero_a.reader_rank, 0) + + def test_paired_contrast_root_weighting(self): + a = np.array([[1., 3.], [2., 5.]]) + b = np.array([[0., 1.], [2., 2.]]) + expected = np.array([[0.5, 1.0], [1.0, 6.5]]) + np.testing.assert_array_equal(paired_contrast_moment(a, b), expected) + weighted = paired_contrast_moment(a, b, np.array([1., 3.])) + np.testing.assert_allclose(weighted, np.array([[0.25, 0.5], [0.5, 7.75]])) + np.testing.assert_array_equal(uncentered_second_moment(a - b), expected) + + def test_invalid_inputs(self): + with self.assertRaisesRegex(ValueError, 'positive semidefinite'): + optimal_weighted_rank(self.w, np.diag([-1., 1., 2.]), 1) + with self.assertRaisesRegex(ValueError, 'symmetric'): + optimal_weighted_rank(self.w, np.array([[1., 1., 0.], [0., 1., 0.], [0., 0., 1.]]), 1) + with self.assertRaises(ValueError): + optimal_weighted_rank(self.w, np.eye(3), -1) + with self.assertRaises(ValueError): + optimal_weighted_rank(self.w, np.eye(3), True) + with self.assertRaises(ValueError): + optimal_weighted_rank(self.w, np.eye(3), 1, np.ones((1, 2))) + with self.assertRaises(ValueError): + uncentered_second_moment(np.array([[np.nan]])) + with self.assertRaises(ValueError): + paired_contrast_moment(np.ones((2, 2)), np.ones((3, 2))) + with self.assertRaises(ValueError): + uncentered_second_moment(np.eye(2), [0., 0.]) + + +if __name__ == '__main__': + unittest.main() From 8123a102cf679ff9384ce2bffc07db210415ca8b Mon Sep 17 00:00:00 2001 From: Patrick Dugan Date: Mon, 23 Nov 2026 21:08:57 +0800 Subject: [PATCH 04/18] RT-BPD-02: document exact solver, evidence limits and CAL archive contract --- mechinterp/bpd/theory/rtbpd02/README.md | 40 +++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 mechinterp/bpd/theory/rtbpd02/README.md diff --git a/mechinterp/bpd/theory/rtbpd02/README.md b/mechinterp/bpd/theory/rtbpd02/README.md new file mode 100644 index 00000000..98d2f370 --- /dev/null +++ b/mechinterp/bpd/theory/rtbpd02/README.md @@ -0,0 +1,40 @@ +# RT-BPD-02: reached-state and fixed-reader-weighted low rank + +**Status:** exact source-only formulation and CPU fixture; no Nanbeige pretrained evaluation. The original 168-case ARG-03-N cohort remains sealed, and the Nanbeige research goal remains paused. + +[Source-only registration](PROTOCOL.md) · [NumPy implementation](weighted_rank.py) · [CPU tests](test_weighted_rank.py) + +## Why this sits alongside BPD + +The \`c074e35\` Nanbeige synthesis in \`MoralityLabAI/LoopedTransformers\` reports almost equal learned VPD/BPD *physical operators*, together with large NF4/BF16 differences in reached inputs and native donor writes. Its REFIT49 symmetric accounting assigns most observed cross-precision pass-1 write disagreement to the reached input. These are development observations, not a native success for the new method. + +Ordinary SVD minimizes \`||W-K||_F^2\`. The recurrent question instead asks how accurately the reduced operator acts on the input distribution at each **physical occurrence**. Let \`Sigma=E[h h^T]\`, or use \`E[(h^A-h^B)(h^A-h^B)^T]\` for source contrasts. For a fixed reader \`A\` chosen in advance, use: + +\`\`\` +min_{rank K <= r} || A (W-K) Sigma^(1/2) ||_F^2. +\`\`\` + +With \`S=Sigma^(1/2)\`, the closed-form solutions are: + +\`\`\` +K_input = (W S)_r S^+ +K_reader = A^+ (A W S)_r S^+ +\`\`\` + +Pseudoinverses cover singular positive-semidefinite moments and rank-deficient readers. The exact optimal loss is the squared tail of the singular values of \`W S\` or \`A W S\`, respectively. Input directions in \`ker(S)\` and write directions in \`ker(A)\` are unidentifiable under this local criterion, so arbitrary factor labels have no causal interpretation. These results are weighted low-rank algebra, rather than new theorems about neural behavior. + +For a nonlinear continuation, an input-dependent Jacobian \`A(h)\` changes the objective; the closed forms only cover a frozen linear \`A\`. A future native study must use a registered physical reader, rounded dose and oracle-scored continuation before claiming causal benefit. + +## CPU reference and result + +From the BPD repository root, with NumPy installed: + +\`\`\`bash +python -m unittest mechinterp.bpd.theory.rtbpd02.test_weighted_rank -v +\`\`\` + +The pre-registered three-dimensional fixture has \`W=diag(4,3,2)\`, \`Sigma=diag(0.01,1,10)\`. For rank 2, conventional SVD drops the third coordinate and suffers weighted squared error **40**, whereas reached-state SVD drops the first and attains **0.16**. With rank 1 and reader \`[0,1,0]\`, reader-weighted fitting gets zero reader error whereas input-only fitting gets **9**. These are predetermined synthetic identities. The tests also check singular moments, rank-deficient readers, input-coordinate rotations, the \`Sigma=I, A=I\` reduction, paired contrasts and rejection of malformed inputs. + +## Archive bridge requirements + +For a numerical test on Nanbeige, source a CAL-only bundle of *actual reached* input vectors indexed by physical layer, module, pass, token support, precision, independently grouped root and world, with checkpoint and source digests. The published aggregate currently reports only physical operator and vector cosines, not the covariance matrices or raw reached vectors needed for this fit. No native model or sealed confirmation cohort is accessed by this package. The next action after this source gate would require a separate explicit resume decision. From a4345641588b6cb4063ca664a444cadc33a55afa Mon Sep 17 00:00:00 2001 From: Patrick Dugan Date: Mon, 23 Nov 2026 21:10:09 +0800 Subject: [PATCH 05/18] RT-BPD-02: normalize Markdown math and code formatting --- mechinterp/bpd/theory/rtbpd02/PROTOCOL.md | 32 +++++++++++------------ 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/mechinterp/bpd/theory/rtbpd02/PROTOCOL.md b/mechinterp/bpd/theory/rtbpd02/PROTOCOL.md index 7baa6b31..71f7fdfe 100644 --- a/mechinterp/bpd/theory/rtbpd02/PROTOCOL.md +++ b/mechinterp/bpd/theory/rtbpd02/PROTOCOL.md @@ -4,35 +4,35 @@ ## Physical questions and estimands -A shared operator \`W : R^n -> R^m\` is applied repeatedly to inputs with pass-specific reached-state second moments \`Sigma_t = E[h_t h_t^T]\`. For paired counterfactual worlds at the same occurrence, define \`Delta h_t = h_t^A - h_t^B\` and \`Sigma_t^Delta = E[Delta h_t Delta h_t^T]\`. The root is the independent unit; worlds, tokens, module occurrences and passes are nested. Keep a fixed pass, layer, module, token selector, checkpoint, precision and factor rank in every comparison. +A shared operator `W : R^n -> R^m` is applied repeatedly to inputs with pass-specific reached-state second moments `Sigma_t = E[h_t h_t^T]`. For paired counterfactual worlds at the same occurrence, define `Delta h_t = h_t^A - h_t^B` and `Sigma_t^Delta = E[Delta h_t Delta h_t^T]`. The root is the independent unit; worlds, tokens, module occurrences and passes are nested. Keep a fixed pass, layer, module, token selector, checkpoint, precision and factor rank in every comparison. -For positive-semidefinite \`Sigma\`, fixed linear downstream reader \`A\` (or identity), and rank bound \`r\`, minimize +For positive-semidefinite `Sigma`, fixed linear downstream reader `A` (or identity), and rank bound `r`, minimize -\`\`\` +``` E_A(K) = tr(A (W-K) Sigma (W-K)^T A^T) = || A (W-K) Sigma^(1/2) ||_F^2 subject to rank(K) <= r. -\`\`\` +``` -Freeze three candidates: (i) Euclidean rank-r truncated SVD of \`W\`; (ii) input-moment-optimal \`K_r\`; (iii) fixed-reader-and-input-moment-optimal \`K_{r,A}\`. Compare their realized physical operators, empirical squared write-error and downstream reader-error on the same source-only vectors. A data-dependent Jacobian \`A(h)\` has no claimed single-SVD solution; any such optimization requires a separately specified numerical method. +Freeze three candidates: (i) Euclidean rank-r truncated SVD of `W`; (ii) input-moment-optimal `K_r`; (iii) fixed-reader-and-input-moment-optimal `K_{r,A}`. Compare their realized physical operators, empirical squared write-error and downstream reader-error on the same source-only vectors. A data-dependent Jacobian `A(h)` has no claimed single-SVD solution; any such optimization requires a separately specified numerical method. ## Exact mathematical claims to check -Let \`S=Sigma^(1/2)\`, \`S^+\` its Moore-Penrose pseudoinverse, and \`B=AWS\`. With \`M_r\` denoting an SVD rank-r truncation: +Let `S=Sigma^(1/2)`, `S^+` its Moore-Penrose pseudoinverse, and `B=AWS`. With `M_r` denoting an SVD rank-r truncation: -1. \`K_r=(WS)_r S^+\` attains the minimum, including for singular PSD \`Sigma\`, with objective \`sum_{j>r} sigma_j(WS)^2\`. -2. \`K_{r,A}=A^+ (AWS)_r S^+\` attains the minimum for a fixed \`A\`, with objective \`sum_{j>r} sigma_j(AWS)^2\`. The result follows because \`AWS\` has columns in \`im(A)\` and rows in the row space of \`S\`. -3. Solutions are generally nonunique on \`ker(S)\` and \`ker(A)\`. Pseudoinverses choose a minimal-norm representative, with SVD degeneracy handled by comparing operators' physical responses and objectives rather than arbitrary atom labels. -4. For an orthogonal input coordinate change \`Q\`, \`W' = W Q^T\`, \`Sigma'=Q Sigma Q^T\`, the objective and optimal physical map transform covariantly. In degenerate singular-value spaces, compare objectives and projector subspaces rather than expecting an identical SVD basis. -5. When \`A=I\` and \`Sigma=I\`, the formula reduces to conventional truncated SVD. +1. `K_r=(WS)_r S^+` attains the minimum, including for singular PSD `Sigma`, with objective `sum_{j>r} sigma_j(WS)^2`. +2. `K_{r,A}=A^+ (AWS)_r S^+` attains the minimum for a fixed `A`, with objective `sum_{j>r} sigma_j(AWS)^2`. The result follows because `AWS` has columns in `im(A)` and rows in the row space of `S`. +3. Solutions are generally nonunique on `ker(S)` and `ker(A)`. Pseudoinverses choose a minimal-norm representative, with SVD degeneracy handled by comparing operators' physical responses and objectives rather than arbitrary atom labels. +4. For an orthogonal input coordinate change `Q`, `W' = W Q^T`, `Sigma'=Q Sigma Q^T`, the objective and optimal physical map transform covariantly. In degenerate singular-value spaces, compare objectives and projector subspaces rather than expecting an identical SVD basis. +5. When `A=I` and `Sigma=I`, the formula reduces to conventional truncated SVD. These are weighted Eckart-Young facts; novelty claimed here is the recurrent-state and downstream-reader application, not the linear-algebra theorem. ## Locked synthetic checks -- \`W = diag(4,3,2)\`, \`Sigma = diag(0.01,1,10)\`, rank 2. Standard truncated SVD has weighted error \`40\`; input-weighted optimum has error \`0.16\`. Compare both against the tail singular-value oracle, with absolute error <=1e-9. -- Same \`W\`, \`Sigma\`, rank 1 and reader \`A=[0,1,0]\`. Reader-specific optimum must have reader error <=1e-9; input-weighted rank-1 candidate has reader error \`9\`. -- Positive-semidefinite singular \`Sigma\`, with a zero eigenvalue. Match the SVD tail oracle and verify no spurious demand on the unobserved direction. +- `W = diag(4,3,2)`, `Sigma = diag(0.01,1,10)`, rank 2. Standard truncated SVD has weighted error `40`; input-weighted optimum has error `0.16`. Compare both against the tail singular-value oracle, with absolute error <=1e-9. +- Same `W`, `Sigma`, rank 1 and reader `A=[0,1,0]`. Reader-specific optimum must have reader error <=1e-9; input-weighted rank-1 candidate has reader error `9`. +- Positive-semidefinite singular `Sigma`, with a zero eigenvalue. Match the SVD tail oracle and verify no spurious demand on the unobserved direction. - Identity-input/identity-reader reduction; orthogonal input-gauge covariance; nonsquare rank-deficient reader; null reader; zero moment; invalid indefinite/asymmetric/nonfinite input rejection; paired-contrast input checks. - All tests run on CPU using only Python stdlib and NumPy. No Torch, HuggingFace, device allocation, model assets or external services. @@ -40,6 +40,6 @@ Source-only acceptance means each theorem-derived identity agrees with its indep ## Future archive replay (separately authorized) -Accept CAL-only archived, actually reached *physical* pre-down_proj inputs, using an explicit schema containing repository/commit/checkpoint digest, backend and quantization, physical layer, pass, token selector, root ID, world ID, input vector, and paired source-identification policy. First build root-balanced \`Sigma_t\` and \`Sigma_t^Delta\` on **CAL roots only**; freeze bases before comparing on disjoint DEV roots. Log post-rounding physical interventions and independently scored oracle outcomes as separate later stages. The currently public Nanbeige report gives aggregate cosines and fitted-operator comparisons; it does not publish the raw per-root reached-state vectors required to construct these covariances. This source-only stage therefore makes no archive-fit accuracy assertion. +Accept CAL-only archived, actually reached *physical* pre-down_proj inputs, using an explicit schema containing repository/commit/checkpoint digest, backend and quantization, physical layer, pass, token selector, root ID, world ID, input vector, and paired source-identification policy. First build root-balanced `Sigma_t` and `Sigma_t^Delta` on **CAL roots only**; freeze bases before comparing on disjoint DEV roots. Log post-rounding physical interventions and independently scored oracle outcomes as separate later stages. The currently public Nanbeige report gives aggregate cosines and fitted-operator comparisons; it does not publish the raw per-root reached-state vectors required to construct these covariances. This source-only stage therefore makes no archive-fit accuracy assertion. -Primary reference: \`MoralityLabAI/LoopedTransformers\` Nanbeige synthesis at \`c074e35\` (\`reports/nanbeige_bpd_gym/NANBEIGE_RESEARCH_SYNTHESIS_20261123.md\`), and \`BPD\` NC-06 gauge/weighting work. Maintain the research pause and the protected ARG-03-N seal. +Primary reference: `MoralityLabAI/LoopedTransformers` Nanbeige synthesis at `c074e35` (`reports/nanbeige_bpd_gym/NANBEIGE_RESEARCH_SYNTHESIS_20261123.md`), and `BPD` NC-06 gauge/weighting work. Maintain the research pause and the protected ARG-03-N seal. From e7c8cdbaa8d2858e35bcbea08f3f07e8101d73bf Mon Sep 17 00:00:00 2001 From: Patrick Dugan Date: Mon, 23 Nov 2026 21:10:12 +0800 Subject: [PATCH 06/18] RT-BPD-02: normalize Markdown math and code formatting --- mechinterp/bpd/theory/rtbpd02/README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/mechinterp/bpd/theory/rtbpd02/README.md b/mechinterp/bpd/theory/rtbpd02/README.md index 98d2f370..846db1cd 100644 --- a/mechinterp/bpd/theory/rtbpd02/README.md +++ b/mechinterp/bpd/theory/rtbpd02/README.md @@ -6,34 +6,34 @@ ## Why this sits alongside BPD -The \`c074e35\` Nanbeige synthesis in \`MoralityLabAI/LoopedTransformers\` reports almost equal learned VPD/BPD *physical operators*, together with large NF4/BF16 differences in reached inputs and native donor writes. Its REFIT49 symmetric accounting assigns most observed cross-precision pass-1 write disagreement to the reached input. These are development observations, not a native success for the new method. +The `c074e35` Nanbeige synthesis in `MoralityLabAI/LoopedTransformers` reports almost equal learned VPD/BPD *physical operators*, together with large NF4/BF16 differences in reached inputs and native donor writes. Its REFIT49 symmetric accounting assigns most observed cross-precision pass-1 write disagreement to the reached input. These are development observations, not a native success for the new method. -Ordinary SVD minimizes \`||W-K||_F^2\`. The recurrent question instead asks how accurately the reduced operator acts on the input distribution at each **physical occurrence**. Let \`Sigma=E[h h^T]\`, or use \`E[(h^A-h^B)(h^A-h^B)^T]\` for source contrasts. For a fixed reader \`A\` chosen in advance, use: +Ordinary SVD minimizes `||W-K||_F^2`. The recurrent question instead asks how accurately the reduced operator acts on the input distribution at each **physical occurrence**. Let `Sigma=E[h h^T]`, or use `E[(h^A-h^B)(h^A-h^B)^T]` for source contrasts. For a fixed reader `A` chosen in advance, use: -\`\`\` +``` min_{rank K <= r} || A (W-K) Sigma^(1/2) ||_F^2. -\`\`\` +``` -With \`S=Sigma^(1/2)\`, the closed-form solutions are: +With `S=Sigma^(1/2)`, the closed-form solutions are: -\`\`\` +``` K_input = (W S)_r S^+ K_reader = A^+ (A W S)_r S^+ -\`\`\` +``` -Pseudoinverses cover singular positive-semidefinite moments and rank-deficient readers. The exact optimal loss is the squared tail of the singular values of \`W S\` or \`A W S\`, respectively. Input directions in \`ker(S)\` and write directions in \`ker(A)\` are unidentifiable under this local criterion, so arbitrary factor labels have no causal interpretation. These results are weighted low-rank algebra, rather than new theorems about neural behavior. +Pseudoinverses cover singular positive-semidefinite moments and rank-deficient readers. The exact optimal loss is the squared tail of the singular values of `W S` or `A W S`, respectively. Input directions in `ker(S)` and write directions in `ker(A)` are unidentifiable under this local criterion, so arbitrary factor labels have no causal interpretation. These results are weighted low-rank algebra, rather than new theorems about neural behavior. -For a nonlinear continuation, an input-dependent Jacobian \`A(h)\` changes the objective; the closed forms only cover a frozen linear \`A\`. A future native study must use a registered physical reader, rounded dose and oracle-scored continuation before claiming causal benefit. +For a nonlinear continuation, an input-dependent Jacobian `A(h)` changes the objective; the closed forms only cover a frozen linear `A`. A future native study must use a registered physical reader, rounded dose and oracle-scored continuation before claiming causal benefit. ## CPU reference and result From the BPD repository root, with NumPy installed: -\`\`\`bash +```bash python -m unittest mechinterp.bpd.theory.rtbpd02.test_weighted_rank -v -\`\`\` +``` -The pre-registered three-dimensional fixture has \`W=diag(4,3,2)\`, \`Sigma=diag(0.01,1,10)\`. For rank 2, conventional SVD drops the third coordinate and suffers weighted squared error **40**, whereas reached-state SVD drops the first and attains **0.16**. With rank 1 and reader \`[0,1,0]\`, reader-weighted fitting gets zero reader error whereas input-only fitting gets **9**. These are predetermined synthetic identities. The tests also check singular moments, rank-deficient readers, input-coordinate rotations, the \`Sigma=I, A=I\` reduction, paired contrasts and rejection of malformed inputs. +The pre-registered three-dimensional fixture has `W=diag(4,3,2)`, `Sigma=diag(0.01,1,10)`. For rank 2, conventional SVD drops the third coordinate and suffers weighted squared error **40**, whereas reached-state SVD drops the first and attains **0.16**. With rank 1 and reader `[0,1,0]`, reader-weighted fitting gets zero reader error whereas input-only fitting gets **9**. These are predetermined synthetic identities. The tests also check singular moments, rank-deficient readers, input-coordinate rotations, the `Sigma=I, A=I` reduction, paired contrasts and rejection of malformed inputs. ## Archive bridge requirements From 4837e5ee192105c4bdee6552a2c3e0628831f2f0 Mon Sep 17 00:00:00 2001 From: Patrick Dugan Date: Mon, 23 Nov 2026 21:10:33 +0800 Subject: [PATCH 07/18] RT-BPD-02: run locked source-only math on hosted CPU CI --- .github/workflows/rtbpd02-source-only.yml | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/rtbpd02-source-only.yml diff --git a/.github/workflows/rtbpd02-source-only.yml b/.github/workflows/rtbpd02-source-only.yml new file mode 100644 index 00000000..19d4a93f --- /dev/null +++ b/.github/workflows/rtbpd02-source-only.yml @@ -0,0 +1,25 @@ +name: RT-BPD-02 source-only CPU mathematics + +on: + pull_request: + paths: + - "mechinterp/bpd/theory/rtbpd02/**" + - ".github/workflows/rtbpd02-source-only.yml" + workflow_dispatch: + +permissions: + contents: read + +jobs: + weighted-rank-cpu: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.11" + - name: Install source-only numerical dependency + run: python -m pip install --disable-pip-version-check "numpy==1.26.4" + - name: Verify weighted low-rank theorems and locked fixtures + run: python -m unittest mechinterp.bpd.theory.rtbpd02.test_weighted_rank -v From cacbcf4feee7d9603f6c4bc88d7cf7bc5316a56f Mon Sep 17 00:00:00 2001 From: Patrick Dugan Date: Mon, 23 Nov 2026 21:10:59 +0800 Subject: [PATCH 08/18] RT-BPD-02: record eight passed synthetic CPU checks and native evidence boundary --- .../rtbpd02/RESULTS_SOURCE_ONLY_20261123.md | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 mechinterp/bpd/theory/rtbpd02/RESULTS_SOURCE_ONLY_20261123.md diff --git a/mechinterp/bpd/theory/rtbpd02/RESULTS_SOURCE_ONLY_20261123.md b/mechinterp/bpd/theory/rtbpd02/RESULTS_SOURCE_ONLY_20261123.md new file mode 100644 index 00000000..568bb36b --- /dev/null +++ b/mechinterp/bpd/theory/rtbpd02/RESULTS_SOURCE_ONLY_20261123.md @@ -0,0 +1,34 @@ +# RT-BPD-02 source-only CPU result, 2026-11-23 + +**Evidence class:** deterministic finite-dimensional NumPy development fixture. No pretrained model, Nanbeige archived state replay, model checkpoint, GPU, training run, formal behavioral comparison or protected 168-case ARG-03-N evaluation was used. The Nanbeige research goal remains paused. + +## Locked numerical check + +For \`W=diag(4,3,2)\`, \`Sigma=diag(0.01,1,10)\`: + +| Arm | Rank | Measured squared weighted error | Algebraic oracle | +| --- | ---: | ---: | ---: | +| Euclidean rank-truncated SVD | 2 | 40 | 40 from dropped third coordinate | +| Reached-state-weighted SVD | 2 | 0.16 | 0.16 tail squared singular value | +| Reached-state rank-1 with reader \`[0,1,0]\` | 1 | 9 downstream | 9 under that reader | +| Fixed-reader-weighted rank-1 | 1 | 0 downstream | 0 tail squared singular value | + +The source-only reference additionally covers a singular PSD input moment, rank-deficient reader, zero moment/reader, identity reduction, orthogonal input-coordinate covariance, paired counterfactual moments and invalid inputs. + +## Execution receipt + +Local isolated CPU run: + +\`\`\`text +PYTHONPATH=/mnt/data/rtbpd02 python -m unittest mechinterp.bpd.theory.rtbpd02.test_weighted_rank -v +Ran 8 tests in 0.014s +OK +\`\`\` + +NumPy version 2.3.5 in the local verification runtime. The repository's GitHub Actions workflow is pinned to NumPy 1.26.4 for an independent CPU replay; its outcome is recorded by GitHub rather than assumed here. + +## Scientific interpretation + +This verifies the declared weighted-rank algebra on synthetic arrays and its numerical implementation. The 250-fold reduction in the rank-2 fixture's weighted error is a consequence of a chosen diagonal covariance, not an estimated Nanbeige gain. The published Nanbeige REFIT49/IO18 aggregate includes fitted physical operator comparisons and reached-state cosine summaries, while the raw root-balanced covariance inputs required for a new native fit remain local/unpublished. + +Future archive replay requires a separate authorization, root-balanced CAL-only source vectors, fixed full-head reader semantics, and preserved model/precision/occurrence IDs. The original ARG-03-N test remains sealed. From 2925a45b5e0fda8437530649fe58c974f1344008 Mon Sep 17 00:00:00 2001 From: Patrick Dugan Date: Mon, 23 Nov 2026 21:11:14 +0800 Subject: [PATCH 09/18] RT-BPD-02: normalize result-note code formatting --- .../bpd/theory/rtbpd02/RESULTS_SOURCE_ONLY_20261123.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mechinterp/bpd/theory/rtbpd02/RESULTS_SOURCE_ONLY_20261123.md b/mechinterp/bpd/theory/rtbpd02/RESULTS_SOURCE_ONLY_20261123.md index 568bb36b..3a249988 100644 --- a/mechinterp/bpd/theory/rtbpd02/RESULTS_SOURCE_ONLY_20261123.md +++ b/mechinterp/bpd/theory/rtbpd02/RESULTS_SOURCE_ONLY_20261123.md @@ -4,13 +4,13 @@ ## Locked numerical check -For \`W=diag(4,3,2)\`, \`Sigma=diag(0.01,1,10)\`: +For `W=diag(4,3,2)`, `Sigma=diag(0.01,1,10)`: | Arm | Rank | Measured squared weighted error | Algebraic oracle | | --- | ---: | ---: | ---: | | Euclidean rank-truncated SVD | 2 | 40 | 40 from dropped third coordinate | | Reached-state-weighted SVD | 2 | 0.16 | 0.16 tail squared singular value | -| Reached-state rank-1 with reader \`[0,1,0]\` | 1 | 9 downstream | 9 under that reader | +| Reached-state rank-1 with reader `[0,1,0]` | 1 | 9 downstream | 9 under that reader | | Fixed-reader-weighted rank-1 | 1 | 0 downstream | 0 tail squared singular value | The source-only reference additionally covers a singular PSD input moment, rank-deficient reader, zero moment/reader, identity reduction, orthogonal input-coordinate covariance, paired counterfactual moments and invalid inputs. @@ -19,11 +19,11 @@ The source-only reference additionally covers a singular PSD input moment, rank- Local isolated CPU run: -\`\`\`text +```text PYTHONPATH=/mnt/data/rtbpd02 python -m unittest mechinterp.bpd.theory.rtbpd02.test_weighted_rank -v Ran 8 tests in 0.014s OK -\`\`\` +``` NumPy version 2.3.5 in the local verification runtime. The repository's GitHub Actions workflow is pinned to NumPy 1.26.4 for an independent CPU replay; its outcome is recorded by GitHub rather than assumed here. From c9d050686c3e990529c9bd049a9227c80313a38a Mon Sep 17 00:00:00 2001 From: Patrick Dugan Date: Mon, 23 Nov 2026 21:12:51 +0800 Subject: [PATCH 10/18] RT-BPD-02: run CPU tests without importing Torch-dependent BPD package --- mechinterp/bpd/theory/rtbpd02/test_weighted_rank.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mechinterp/bpd/theory/rtbpd02/test_weighted_rank.py b/mechinterp/bpd/theory/rtbpd02/test_weighted_rank.py index d795cc1b..f788f02a 100644 --- a/mechinterp/bpd/theory/rtbpd02/test_weighted_rank.py +++ b/mechinterp/bpd/theory/rtbpd02/test_weighted_rank.py @@ -3,7 +3,7 @@ import numpy as np -from mechinterp.bpd.theory.rtbpd02.weighted_rank import ( +from weighted_rank import ( optimal_weighted_rank, paired_contrast_moment, truncated_svd, uncentered_second_moment, weighted_error, ) From 848d6f9264668f696e2b2fcd2bcba239cbce6f67 Mon Sep 17 00:00:00 2001 From: Patrick Dugan Date: Mon, 23 Nov 2026 21:12:54 +0800 Subject: [PATCH 11/18] RT-BPD-02: run CPU tests without importing Torch-dependent BPD package --- .github/workflows/rtbpd02-source-only.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rtbpd02-source-only.yml b/.github/workflows/rtbpd02-source-only.yml index 19d4a93f..6cd6cbfc 100644 --- a/.github/workflows/rtbpd02-source-only.yml +++ b/.github/workflows/rtbpd02-source-only.yml @@ -22,4 +22,4 @@ jobs: - name: Install source-only numerical dependency run: python -m pip install --disable-pip-version-check "numpy==1.26.4" - name: Verify weighted low-rank theorems and locked fixtures - run: python -m unittest mechinterp.bpd.theory.rtbpd02.test_weighted_rank -v + run: python -m unittest discover -s mechinterp/bpd/theory/rtbpd02 -p 'test_weighted_rank.py' -v From 7842d76ee376cefb191e723341ad9d422ac45dd5 Mon Sep 17 00:00:00 2001 From: Patrick Dugan Date: Mon, 23 Nov 2026 21:12:57 +0800 Subject: [PATCH 12/18] RT-BPD-02: run CPU tests without importing Torch-dependent BPD package --- mechinterp/bpd/theory/rtbpd02/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mechinterp/bpd/theory/rtbpd02/README.md b/mechinterp/bpd/theory/rtbpd02/README.md index 846db1cd..9e80c982 100644 --- a/mechinterp/bpd/theory/rtbpd02/README.md +++ b/mechinterp/bpd/theory/rtbpd02/README.md @@ -30,7 +30,7 @@ For a nonlinear continuation, an input-dependent Jacobian `A(h)` changes the obj From the BPD repository root, with NumPy installed: ```bash -python -m unittest mechinterp.bpd.theory.rtbpd02.test_weighted_rank -v +python -m unittest discover -s mechinterp/bpd/theory/rtbpd02 -p 'test_weighted_rank.py' -v ``` The pre-registered three-dimensional fixture has `W=diag(4,3,2)`, `Sigma=diag(0.01,1,10)`. For rank 2, conventional SVD drops the third coordinate and suffers weighted squared error **40**, whereas reached-state SVD drops the first and attains **0.16**. With rank 1 and reader `[0,1,0]`, reader-weighted fitting gets zero reader error whereas input-only fitting gets **9**. These are predetermined synthetic identities. The tests also check singular moments, rank-deficient readers, input-coordinate rotations, the `Sigma=I, A=I` reduction, paired contrasts and rejection of malformed inputs. From 2a19cafcd02285a0c9946e0819fc6d8ccbcdc31d Mon Sep 17 00:00:00 2001 From: Patrick Dugan Date: Mon, 23 Nov 2026 21:13:00 +0800 Subject: [PATCH 13/18] RT-BPD-02: run CPU tests without importing Torch-dependent BPD package --- mechinterp/bpd/theory/rtbpd02/RESULTS_SOURCE_ONLY_20261123.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mechinterp/bpd/theory/rtbpd02/RESULTS_SOURCE_ONLY_20261123.md b/mechinterp/bpd/theory/rtbpd02/RESULTS_SOURCE_ONLY_20261123.md index 3a249988..1c4679d4 100644 --- a/mechinterp/bpd/theory/rtbpd02/RESULTS_SOURCE_ONLY_20261123.md +++ b/mechinterp/bpd/theory/rtbpd02/RESULTS_SOURCE_ONLY_20261123.md @@ -20,7 +20,7 @@ The source-only reference additionally covers a singular PSD input moment, rank- Local isolated CPU run: ```text -PYTHONPATH=/mnt/data/rtbpd02 python -m unittest mechinterp.bpd.theory.rtbpd02.test_weighted_rank -v +cd /mnt/data/rtbpd02 && python -m unittest discover -s mechinterp/bpd/theory/rtbpd02 -p test_weighted_rank.py -v Ran 8 tests in 0.014s OK ``` From 96ffc0651dc22f5b021f3ad2d231e2dcc36d14d0 Mon Sep 17 00:00:00 2001 From: Patrick Dugan Date: Mon, 23 Nov 2026 22:03:49 +0800 Subject: [PATCH 14/18] Register RT-BPD recurrent gym and CAL archive replay --- .../bpd/theory/rtbpd02/EXTENSION_PROTOCOL.md | 27 +++ .../rtbpd02/EXTENSION_REGISTRATION.json | 156 ++++++++++++++++++ 2 files changed, 183 insertions(+) create mode 100644 mechinterp/bpd/theory/rtbpd02/EXTENSION_PROTOCOL.md create mode 100644 mechinterp/bpd/theory/rtbpd02/EXTENSION_REGISTRATION.json diff --git a/mechinterp/bpd/theory/rtbpd02/EXTENSION_PROTOCOL.md b/mechinterp/bpd/theory/rtbpd02/EXTENSION_PROTOCOL.md new file mode 100644 index 00000000..11fd444a --- /dev/null +++ b/mechinterp/bpd/theory/rtbpd02/EXTENSION_PROTOCOL.md @@ -0,0 +1,27 @@ +# RT-BPD-02 extension registration + +This source-only registration extends the [starting protocol](PROTOCOL.md) on BPD draft PR #146. The machine-readable contract is [EXTENSION_REGISTRATION.json](EXTENSION_REGISTRATION.json). Commit it before running the new gym or the Nanbeige archive replay. The [Nanbeige synthesis](https://github.com/MoralityLabAI/LoopedTransformers/blob/c074e354e8bcd4d26c02104fadd289dfdad8a207/reports/nanbeige_bpd_gym/NANBEIGE_RESEARCH_SYNTHESIS_20261123.md) supplies development context. The Nanbeige GPU goal remains paused. No pretrained decoder is run. The original 168 ARG-03-N test cases stay sealed. + +## Exact questions + +Audit the weighted Eckart–Young lift on singular moments and fixed readers. When numerical support is truncated, apply the cutoff to both the reader target and its inverse, report the loss in the resulting metric and in the original metric, and document the physical information that the lift leaves unidentified. Check orthogonal equivariance, general coordinate covariance of the objective and solution sets, and tied singular-value counterexamples. Extend the reference to thin sample factors so high-width empirical moments can be evaluated without a dense covariance. + +Derive the symmetric operator/state disagreement identity and its cross term, fixed future-reader propagation, delayed-visible rank within the presently dark write space, and signed path interference. Establish a sufficient transfer bound using reached-moment and reader-metric domination. Test failures due to missing support, disagreement in direction at equal physical dose, and nonlinear interaction. + +## Synthetic development + +Use one fixed six-dimensional tied operator with a planted orthogonal basis. Propagate the live state with the fixed background and the shared write on each pass. Store the write in a separate cache slot and move it into delayed memory at the next step. The current readout uses the first two planted axes. The future readout uses the two configured mixtures of axes three and four. Check the fixed-reader predictions against explicit state continuation. + +Fit on 24 independently generated source roots, with both counterfactual worlds in each root. A separate 64-root development stream uses the configured initial reach. A distribution-shift stress panel changes only the development reach scale. Compare ordinary SVD, reached-moment SVD, fixed-future-reader SVD, a fixed-bank BPD mask and a fixed seeded random output subspace at the common rank. Enumerate the fixed-bank masks on CAL and minimize the equal-weight mean squared error of the current and delayed linear readouts. This exercises BPD's physical mask law on supplied exact atoms. The archived T1 and T2 banks provide the separate learned-method comparison. Fit no masks on development. Record subspace stability from the two fixed halves of CAL. + +The primary prediction is lower pass-2 future-reader error for reader weighting than ordinary SVD on the aligned development panel. The stress prediction is that reached-state weighting can lose its write-error advantage under shifted reach. Record relative errors, physical output-subspace angles, and finite future direction under a matched residual-space L2 dose. Set the dose to one-quarter of the root's true donor-write L2, and give zero or unavailable directions their explicit status. Report paired root effects and raw development receipts. EvalMath preflight uses the registered bounded directional statistic and matched random arm. Its resolution estimate is development planning with no sealed confirmation readout. + +## Nanbeige archive + +Read the existing audited COMP14 focused CAL last-token layer-21 MLP inputs, native write outputs and raw residuals in both worlds and passes. Verify the source/token/state hashes and the IO18 target, per-fit identities, and original exact all-one native qualification. Train each empirical basis without the scored root. Compare the shared SVD initializer and the T1 and T2 BPD/VPD factor banks at equal rank alongside ordinary SVD of the T2 sum, reached-moment reapproximation, paired-contrast weighting and matched random. Choose the archive T1/T2 and initializer atom subsets on the seven training roots by squared error to the T2 sum, with lexicographic ties. Use the same fold split for all methods. The archive endpoint measures compression of a frozen fitted physical operator. Verify the pinned BF16 full layer-21 affine map against the archived native module writes as a separate closure check. + +Use a fixed BF16 future K reader only on pass 1. Compose the pinned layer-0 K matrix with the two continuous RMSNorm derivatives at the mean raw carrier of the training roots. Measure that linear readout locally; later attention, rounding of modified activations and answer effects remain outside this replay. A corresponding NF4 reader requires the exact quantized physical layer-0 projection and its arithmetic receipt. Report any missing state, layout, support or custody requirement explicitly. Publish only aggregate results and source provenance in BPD. + +## Acceptance + +CPU CI must verify the algebraic identities and counterexamples, the recorded ranks and matched physical doses, and the full synthetic result from the committed source. Independently reduce the code-generated root receipts. Archive playback runs read-only on the existing local inputs under a bounded single-thread CPU lease. All 8 archive roots are exposed calibration and are never counted as confirmation. Scientific evidence distinguishes theorems, synthetic results, archival affine replay and unresolved native causal hypotheses. diff --git a/mechinterp/bpd/theory/rtbpd02/EXTENSION_REGISTRATION.json b/mechinterp/bpd/theory/rtbpd02/EXTENSION_REGISTRATION.json new file mode 100644 index 00000000..7cef6bfb --- /dev/null +++ b/mechinterp/bpd/theory/rtbpd02/EXTENSION_REGISTRATION.json @@ -0,0 +1,156 @@ +{ + "schema": "rtbpd02-extension/v1", + "starting_commit": "2a19cafcd02285a0c9946e0819fc6d8ccbcdc31d", + "nanbeige_synthesis": "c074e354e8bcd4d26c02104fadd289dfdad8a207", + "boundary": { + "cpu_only": true, + "pretrained_decoder_forwards": 0, + "gpu_jobs": 0, + "protected_ARG03_access": false, + "formal_tests": 0, + "readout": "development and finite synthetic only" + }, + "weighted_solver": { + "support_relative_cutoff": 1e-12, + "default_baseline": "existing exact weighted Eckart–Young problem", + "reported_losses": [ + "effective", + "full" + ] + }, + "synthetic": { + "geometry_seed": 14602, + "root_seed": 20261123146, + "train_roots": 24, + "development_roots": 64, + "rank": 2, + "physical_dose": 0.25, + "occurrence_passes": [ + 1, + 2 + ], + "same_root_worlds": [ + "A", + "B" + ], + "branches": [ + "aligned", + "shifted" + ], + "spectrum": [ + 8, + 6, + 4, + 3, + 2, + 1 + ], + "background_diagonal": [ + 0.25, + 0.35, + 1.45, + 1.8, + 0.7, + 0.8 + ], + "recurrent_write_scale": 0.08, + "initial_reach_scale": [ + 0.25, + 0.35, + 1.15, + 1.5, + 0.6, + 0.3 + ], + "shifted_development_scale": [ + 7, + 5, + 0.07, + 0.055, + 0.25, + 0.2 + ], + "delayed_reader_mix": [ + [ + 1, + 0.2 + ], + [ + -0.125, + 0.75 + ] + ], + "methods": [ + "svd", + "reach", + "reader", + "bpd_static", + "random" + ], + "primary": "aligned pass-2 held-out root mean squared fixed future-reader error", + "stress": "shifted pass-2 held-out root mean squared write error", + "numerical_closure_atol": 1e-11 + }, + "archive": { + "expected_roots": 8, + "fit_split": "calibration", + "arm": "focused", + "token": "initial last semantic token", + "layer_zero_based": 21, + "site": "mlp.down_proj", + "backends": [ + "nf4", + "bf16" + ], + "passes": [ + 1, + 2 + ], + "ranks": [ + 1, + 2, + 4 + ], + "target": "the sum of the frozen IO18 T2 rank-eight component operators in each backend", + "unmasked_native_qualification": "verify original all-one full-head bit-exact receipt on both fits per backend", + "native_affine_check": "BF16 only, independently replay layer-21 down-projection on sealed archive vectors", + "evaluation": "leave one complete CAL root out per fold, with both worlds in the same fold", + "moments": [ + "root-balanced reached-state second moment", + "paired counterfactual contrast second moment" + ], + "fixed_reader": "BF16 pass 1 only, K projection composed with continuous Jacobian of both RMS norms at the mean training-fold raw carrier; range restricted to the target write span", + "snapshot_revision": "451ed48c3273ecef7ea8faaa43c31ce529763bb1", + "max_private_bytes": 536870912, + "max_seconds": 420, + "minimum_start_available_bytes": 5368709120, + "minimum_reserve_bytes": 4294967296, + "local_archives": "never upload raw states, fitted arrays, token IDs, prompts or pretrained weights", + "source_file_sha256": { + "experiments/nan_comp14/SOURCE_MANIFEST.json": "b9a62f0eedaedc3eca4667412873d5c7151b6a4fb1f98b41bf1bc6978649043f", + "experiments/nan_comp14/fixtures/public.jsonl": "f6e714cb36b8cdc433eb75ff2bcbde8c1c1f7ebb4d5e6573ea1fdf97f43e5504", + "experiments/nan_comp14/fixtures/tokenizer_receipt.json": "a5ebf1eea257928c8e5579e05f1c4fe8698cbc6b0767e50c8511a75dea4f32bf", + "experiments/nan_readpath37/registration.json": "45f0f8f145ad28ea9334f27a96825b362238e4bea7aa3650f3f6d33e067cd09a", + "experiments/nan_fit16_io18/SOURCE_MANIFEST.json": "7bb76c5c895848cf12643312609a584ca0797bc87e9a05e320b8cfa2d04f4830", + "reports/nanbeige_bpd_gym/nan_fit16_io18_progress.json": "67129eba2f7d995638e9a43d35fd1cbcd3eab0a00e6b93274147be18affe321c", + "experiments/nan_bpd01/receipts/checkpoint_verification.json": "cd3f3223efe8ecf94155ee5e42ee093ddbf20d91b5d19a1decab30ea39e07fdd", + "runs/nan_comp14/audits/bf16.json": "75718b1d3764883f5960794587c0ecf3c6ca3d39a858246812cf971967d3f207", + "runs/nan_comp14/audits/nf4.json": "5c579d64d88f18c3feccb58f0e910b6a5022c5ae55693e4f1036cd29aa57b981", + "runs/nan_fit16_io18/audits/bf16.json": "539a74689a1942173fbad6ce55f53cac08133149167ba48f8a4af222e63ff93e", + "runs/nan_fit16_io18/audits/nf4.json": "d9885205c28fe5fa1ecf6b727ef8ca8580f963ee0b8a909c7eeb4f0f92d17536" + } + }, + "evalmath": { + "commit": "accf4d9040bee8daeabc6b07003bb484708996c0", + "root_metric": "(reader cosine minus SVD cosine)/2 at matched physical dose", + "scientific_min_effect": "0.10", + "target_effect": "0.25", + "measurement_resolution": "0.000001", + "quantile": "0.95", + "confidence": "0.95", + "alpha": "0.05", + "planned_comparisons": 1, + "nominal_planning_roots": 64, + "heldout_sealed": false + } +} From 06033ca67712f2d90665f7d92564fd2586f4ffde Mon Sep 17 00:00:00 2001 From: Patrick Dugan Date: Mon, 23 Nov 2026 22:10:46 +0800 Subject: [PATCH 15/18] Prove reach-transport identities and audit rank supports --- .../bpd/theory/rtbpd02/EXTENSION_PROTOCOL.md | 2 +- .../rtbpd02/EXTENSION_REGISTRATION.json | 23 +- mechinterp/bpd/theory/rtbpd02/THEORY.md | 94 ++++++++ .../bpd/theory/rtbpd02/test_transport.py | 179 +++++++++++++++ mechinterp/bpd/theory/rtbpd02/transport.py | 171 ++++++++++++++ .../bpd/theory/rtbpd02/weighted_rank.py | 208 ++++++++++++------ 6 files changed, 608 insertions(+), 69 deletions(-) create mode 100644 mechinterp/bpd/theory/rtbpd02/THEORY.md create mode 100644 mechinterp/bpd/theory/rtbpd02/test_transport.py create mode 100644 mechinterp/bpd/theory/rtbpd02/transport.py diff --git a/mechinterp/bpd/theory/rtbpd02/EXTENSION_PROTOCOL.md b/mechinterp/bpd/theory/rtbpd02/EXTENSION_PROTOCOL.md index 11fd444a..346e078e 100644 --- a/mechinterp/bpd/theory/rtbpd02/EXTENSION_PROTOCOL.md +++ b/mechinterp/bpd/theory/rtbpd02/EXTENSION_PROTOCOL.md @@ -14,7 +14,7 @@ Use one fixed six-dimensional tied operator with a planted orthogonal basis. Pro Fit on 24 independently generated source roots, with both counterfactual worlds in each root. A separate 64-root development stream uses the configured initial reach. A distribution-shift stress panel changes only the development reach scale. Compare ordinary SVD, reached-moment SVD, fixed-future-reader SVD, a fixed-bank BPD mask and a fixed seeded random output subspace at the common rank. Enumerate the fixed-bank masks on CAL and minimize the equal-weight mean squared error of the current and delayed linear readouts. This exercises BPD's physical mask law on supplied exact atoms. The archived T1 and T2 banks provide the separate learned-method comparison. Fit no masks on development. Record subspace stability from the two fixed halves of CAL. -The primary prediction is lower pass-2 future-reader error for reader weighting than ordinary SVD on the aligned development panel. The stress prediction is that reached-state weighting can lose its write-error advantage under shifted reach. Record relative errors, physical output-subspace angles, and finite future direction under a matched residual-space L2 dose. Set the dose to one-quarter of the root's true donor-write L2, and give zero or unavailable directions their explicit status. Report paired root effects and raw development receipts. EvalMath preflight uses the registered bounded directional statistic and matched random arm. Its resolution estimate is development planning with no sealed confirmation readout. +The primary prediction is lower pass-2 future-reader error for reader weighting than ordinary SVD on the aligned development panel. The stress prediction is that reached-state weighting can lose its write-error advantage under shifted reach. Record relative errors, physical output-subspace angles, and finite future direction under a matched residual-space L2 dose. Set the dose to one-quarter of the root's true donor-write L2, and give zero or unavailable directions their explicit status. Use independent standard-normal common and half-contrast vectors in the planted coordinates, and scale both by the registered reach. World A subtracts the half-contrast and world B adds it. Fit a separate candidate per occurrence. Reuse the same development draws for the stress panel so the reach scale is the only difference. The evaluation keeps zero observed readout directions explicitly marked and assigns them a directional score of zero for EvalMath. A zero reference makes the directional endpoint unavailable. Report paired root effects and raw development receipts. EvalMath preflight uses the registered bounded directional statistic and matched random arm. Its resolution estimate is development planning with no sealed confirmation readout. ## Nanbeige archive diff --git a/mechinterp/bpd/theory/rtbpd02/EXTENSION_REGISTRATION.json b/mechinterp/bpd/theory/rtbpd02/EXTENSION_REGISTRATION.json index 7cef6bfb..0b82687f 100644 --- a/mechinterp/bpd/theory/rtbpd02/EXTENSION_REGISTRATION.json +++ b/mechinterp/bpd/theory/rtbpd02/EXTENSION_REGISTRATION.json @@ -89,7 +89,25 @@ ], "primary": "aligned pass-2 held-out root mean squared fixed future-reader error", "stress": "shifted pass-2 held-out root mean squared write error", - "numerical_closure_atol": 1e-11 + "numerical_closure_atol": 1e-11, + "directional_score": { + "zero_observed": 0, + "zero_reference": "unavailable", + "zero_atol": 1e-11 + }, + "root_generation": { + "distribution": "independent standard-normal common and half-contrast planted coordinates", + "world_A": "common-minus-half-contrast", + "world_B": "common-plus-half-contrast", + "scale": "multiply each coordinate of common and half-contrast by registered reach scales", + "split_seeds": [ + 0, + 1 + ], + "shift": "reuse development standard-normal roots with shifted scale", + "rank_comparison": "separate per-pass fits", + "random_seed_derivation": "geometry RNG after basis, fixed for both passes and splits" + } }, "archive": { "expected_roots": 8, @@ -138,7 +156,8 @@ "runs/nan_comp14/audits/nf4.json": "5c579d64d88f18c3feccb58f0e910b6a5022c5ae55693e4f1036cd29aa57b981", "runs/nan_fit16_io18/audits/bf16.json": "539a74689a1942173fbad6ce55f53cac08133149167ba48f8a4af222e63ff93e", "runs/nan_fit16_io18/audits/nf4.json": "d9885205c28fe5fa1ecf6b727ef8ca8580f963ee0b8a909c7eeb4f0f92d17536" - } + }, + "bf16_affine_coordinates": "float64 affine product, then float32-to-BF16 round-to-nearest ties-to-even. Report elemental equality and numerical residual, without extending the archived all-one parity label" }, "evalmath": { "commit": "accf4d9040bee8daeabc6b07003bb484708996c0", diff --git a/mechinterp/bpd/theory/rtbpd02/THEORY.md b/mechinterp/bpd/theory/rtbpd02/THEORY.md new file mode 100644 index 00000000..caffcaeb --- /dev/null +++ b/mechinterp/bpd/theory/rtbpd02/THEORY.md @@ -0,0 +1,94 @@ +# Reach-Transport Behavioral Parameter Decomposition + +RT-BPD-02 mathematical extension, 23 November 2026 + +A shared weight matrix acts on a different input distribution each time it is called. A physical component can write the same vector at two occurrences and have different effects when a later computation reads that vector. This paper separates compression at a registered occurrence from the causal effect of a finite edit at that occurrence. The companion [registration](EXTENSION_PROTOCOL.md) fixes the synthetic and archive comparisons. + +The starting point is the [Nanbeige Q4 synthesis](https://github.com/MoralityLabAI/LoopedTransformers/blob/c074e354e8bcd4d26c02104fadd289dfdad8a207/reports/nanbeige_bpd_gym/NANBEIGE_RESEARCH_SYNTHESIS_20261123.md). Its physical-closure, pass, matched-dose, and routing checks motivate which quantities to preserve. In particular, an all-one full-head check qualifies a write decomposition, local reader geometry identifies a possible path, and later causal efficacy requires an intervention on a paired source contrast. + +## 1. Occurrences and the reached second moment + +Fix a parameter occurrence $p$ with a linear physical write $Wh$, input coordinate space $X$, output space $Y$, and a distribution $\mu_p$ over reached $h\in X$. A precision backend, token position, recurrence pass, and module site are part of the occurrence definition. Let $\Sigma_p=\mathbb E_{\mu_p}[hh^\top]$ and let $A_p$ map writes into fixed measured coordinates. With finite second moments, linearity of expectation gives + +$$ + \mathcal E_p(K)=\mathbb E_{\mu_p}\big[\|A_p(W-K)h\|_2^2\big] + =\operatorname{tr}\big[A_p(W-K)\Sigma_p(W-K)^\top A_p^\top\big]. +$$ + +The moment is uncentered. Centered covariance omits the error made on the mean and corresponds to a different fitting problem unless a separate offset is restored. The paired contrast moment $\mathbb E[(h_B-h_A)(h_B-h_A)^\top]$ answers the separate question of how closely the component preserves donor–recipient writes. For equally weighted roots with two worlds, use half the sum of both world terms within a root and then average across roots. Changes in recurrence, input prompts, quantization, or prior edits can change the law of $h$ while the parameter identity stays fixed. + +This is an expectation over a fixed law. If replacing $W$ changes the reaches, the objective describes a frozen activation replay. The edited rollout requires a new law or a bound on how far it moves. + +## 2. Exact weighted low-rank approximation + +**Theorem 1 (weighted Eckart–Young lift).** Let $W:X\to Y$, $\Sigma\succeq0$, $S=\Sigma^{1/2}$, and $A:Y\to Z$. For any nonnegative integer $r$, set $M=AWS$. If $M_r$ is obtained by keeping at most its $r$ largest singular modes, then + +$$ + K_* = A^+M_r S^+,\qquad + \min_{\operatorname{rank}K\le r} \|A(W-K)S\|_F^2 + = \sum_{i>r}\sigma_i(M)^2. +$$ + +The statements include zero supports, zero rank, and a budget exceeding the target rank. Any feasible $AKS$ has rank at most $r$, so ordinary Eckart–Young–Mirsky gives the lower bound. The nonzero left and right singular vectors used in a truncation lie in $\operatorname{im}A$ and $\operatorname{im}S$. Thus $AA^+M_rS^+S=M_r$, and the lift attains the bound with rank at most $r$. The same support argument applies to a choice within a tied positive singular block. + +For a fixed optimal image $M_r$, the minimum-Frobenius-norm lift is the displayed pseudoinverse formula. The map $K\mapsto AKS$ constrains the block with columns in $\operatorname{im}A^\top$ and rows in $\operatorname{im}S$. Every other block is Frobenius-orthogonal to that block, and setting those blocks to zero attains minimum norm. The rank-constrained optimizers consist of all lifts of optimal images that satisfy the rank budget. This proof gives minimum norm for the chosen image individually. A different tied truncation can have a different lift norm. If $\sigma_r>\sigma_{r+1}$ at a positive cutoff, the projected optimizer is unique. Singular metrics can still leave physical actions undetermined. For example, with $W=I$ and $\Sigma=\operatorname{diag}(1,0)$, every rank-one map sending $e_1$ to $e_1$ fits observed inputs exactly. + +One can replace $S$ by any thin factor $C$ with $CC^\top=\Sigma$ and use $C^+$ in the lift. If weighted sample rows are $D_i=\sqrt{w_i}\,h_i^\top$ with normalized positive total, a thin SVD of $D$ supplies the factor and its supported directions. A fixed reader on an empirical train support then requires a target with one column per retained sample mode, rather than a full dense input moment. + +**Numerical policy.** The code retains moment eigenvalues greater than $\tau\lambda_{\max}$ and reader singular values greater than $\tau\sigma_{\max}$. It constructs the target and lift on exactly those retained supports. It reports both the effective objective and the full loss for the supplied reader and symmetrized PSD moment. The latter evaluates the same estimate, including the modes omitted in fitting. Small negative eigenvalues within the PSD validation tolerance are clipped. For an illustrative failure, $A=\operatorname{diag}(1,10^{-9})$, $W=\operatorname{diag}(2,10^{10})$, and $\Sigma=I$ put the second singular value of $AWS$ at 10. Dropping that reader direction only during lifting can spend the entire rank-one budget there. Consistent retained support spends it on the first direction, for effective loss zero and full loss 100. A small full loss, a stable subspace, and a well-conditioned lift require additional spectral information. At a tie the selected basis can change under arbitrarily small perturbations. + +**Coordinate covariance.** If $h'=Gh$ and $y'=Hy$ for invertible $G,H$, use $W'=HWG^{-1}$, $K'=HKG^{-1}$, $\Sigma'=G\Sigma G^\top$ and $A'=AH^{-1}$ to keep the measured output fixed. The measured residual for every sample and its squared expectation are invariant, and rank is preserved. This bijects exact feasible and minimizing solution sets. A coordinate Euclidean minimum-norm lift is equivariant under orthogonal changes in the corresponding frames, when the projected optimum is unique or an equivariant tie choice is supplied. General invertible maps change Euclidean lengths, the off-support minimum-norm extension and potentially numerical ranks. With $W=I$, $\Sigma=e_1e_1^\top$, $A=I$, $H=I$ and $G=\left(\begin{smallmatrix}1&1\\0&1\end{smallmatrix}\right)$, the new minimum-norm map is $e_1e_1^\top$. Transporting the old lift instead gives $e_1(1,-1)$, with identical actions on the measured support. Physical-dose claims fix a metric on $Y$ and transport that metric when coordinates change. + +## 3. Disagreement between two occurrences + +**Theorem 2 (exact paired identity).** Embed both occurrences in the same physical frames. For $b$ minus $a$, bars denote arithmetic means and $\Delta$ denotes a difference. Expanding the bilinear map yields + +$$ + K_bh_b-K_ah_a=\Delta K\,\bar h + \bar K\,\Delta h. +$$ + +When the readout changes, $\Delta(AKh)=\Delta A\,\overline{Kh}+\bar A(\Delta K\,\bar h+\bar K\,\Delta h)$. These operations can be evaluated from low-rank map actions on the two reached inputs. The corresponding energy includes the signed cross term $2\langle\Delta K\bar h,\bar K\Delta h\rangle$ and, with varying readers, two more cross terms. A large operator term can cancel a large state term. For scalar $K_a=1$, $K_b=2$, $h_a=2$, $h_b=1$, both writes equal 2 and the terms are $1.5$ and $-1.5$. + +With exact tied weights in a shared native frame, $\Delta K=0$ for a truly fixed component. A separate fit at each pass can have nonzero $\Delta K$ even when the parent weight is tied. Across precisions both the recorded reached states and effective operators may change. An equality for this decomposition gives a paired descriptive accounting. A manipulation of each term under a common baseline is an additional causal design. + +## 4. Future readers, delayed visibility, and direction + +**Theorem 3 (fixed linear future reader).** Inject a write $\delta y$ through $B$ into a dynamical state with tangent transitions $J_1,\ldots,J_L$. Fix local readout maps $C_\ell$ and nonnegative weights $w_\ell$, including any output metric factors. The stack with blocks + +$$ + A_\ell=\sqrt{w_\ell}\,C_\ell J_\ell\cdots J_1 B +$$ + +maps the physical write to the weighted measured trajectory. At horizon zero the transition product is the identity. The squared norm of the stack equals the sum of squared readout errors over those horizons. Thus Theorem 1 solves the rank problem for this stack and a fixed reach law. The identity holds for finite edits of a linear dynamical system and for first derivatives along a frozen differentiable trajectory. If the true readout $f$ has an $L$-Lipschitz Jacobian along the edit segment, the linearization remainder is at most $L\|\delta y\|^2/2$ by integrating the derivative. A fixed stack shared across roots is an explicit approximation when the native Jacobian depends on the root. A general root-dependent $A(h)$ induces a quadratic form involving the expectation of $(hh^\top)\otimes(A(h)^\top A(h))$, which need not factor into two separate metrics. + +**Theorem 4 (delayed-visible rank within the local kernel).** On a write domain $D$, let $C$ be the present reader and $O$ the transported future stack. The number of independent future-visible directions among currently dark writes is + +$$ + \operatorname{rank}\big(O|_{D\cap\ker C}\big) + = \operatorname{rank}\big([C;O]|_D\big)-\operatorname{rank}(C|_D). +$$ + +Project the image of the stacked map onto its current-reader block. Its range is $\operatorname{im}(C|_D)$ and its kernel consists of images $(0,Od)$ of currently dark writes. Rank–nullity proves the identity. A cache slot read only after a transition is an example. A nonzero delayed rank certifies existence of a linear direction. It does not bound its gain or guarantee that a reached donor contrast excites it. A small singular value may be unusable at a stated dose and noise floor. Numerical ranks depend on these scales and the chosen metrics. + +For a reference readout displacement $v$ and observed displacement $u$, use signed gain $u^\top v/\|v\|^2$, readout length $\|u\|$, and cosine $u^\top v/(\|u\|\|v\|)$ where defined. Equal physical $\|\delta y\|$ constrains intervention size. It allows both positive and negative projections of equal magnitude, as from writes $e_1$ and $-e_1$ under reader $e_1^\top$. Distinct source worlds supply the reference displacement. Valid comparisons track zero writes and zero reference readouts explicitly. + +## 5. Cross-pass and cross-precision transport + +**Theorem 5 (sufficient common-target bound).** For one common target and candidate in aligned frames, let $P_j=A_j^\top A_j$. If $\Sigma_q\preceq M\Sigma_p$ and $P_q\preceq cP_p$, then $\mathcal E_q(K)\le Mc\,\mathcal E_p(K)$. Write $D=W-K$. First use $\Sigma_q\preceq M\Sigma_p$ in $\operatorname{tr}(P_q D\Sigma_qD^\top)$. Then use $P_q\preceq cP_p$ on the positive semidefinite matrix $D\Sigma_pD^\top$. The two trace inequalities give the bound. + +There is a finite constant dominating one PSD matrix by another exactly when the target support is contained in the source support. On the source support the least constant is the top eigenvalue after whitening the target by the source. Any target direction visible in the source kernel gives a witness against finite domination. This also shows why a thin empirical CAL moment may give a useful within-fold fit yet provide no finite guarantee on a new root. As a simple witness, $\Sigma_p=e_1e_1^\top$, $\Sigma_q=e_2e_2^\top$, $W=I$, and $K=e_1e_1^\top$ yield errors 0 and 1. An analogous witness takes equal state moments and orthogonal reader supports. + +For a changed target, the Hilbert-space triangle inequality gives +$\sqrt{\mathcal E_q(W_q,K_p)}\le\sqrt{Mc\,\mathcal E_p(W_p,K_p)}+\|A_q(W_q-W_p)\Sigma_q^{1/2}\|_F$ under the same metric conditions. For $K_q$ in place of $K_p$, add the corresponding norm of $K_q-K_p$. Approximate domination with a residual term is possible when its action is bounded separately. To transfer a directional behavioral effect, additionally require a common outcome direction, signed gain on reached edits, and a bound on the linearization remainder at the actual matched dose. None follows from a small Frobenius reconstruction error alone. + +## 6. Signed paths and interactions + +**Theorem 6 (signed interference on a linear unrolled DAG).** Order scalar nodes in causal time and place edge derivatives in strictly lower triangular $T$ with entries $T_{ji}$ for $i\to j$. A perturbation at source $s$ reaches target $t$ with coefficient $[(I-T)^{-1}]_{ts}=\sum_{k=0}^{n-1}(T^k)_{ts}$. Each power enumerates products on paths of its length. Replacing $T$ by $|T|$ gives the sum of the absolute path products, an upper bound on the absolute signed sum. Vector paths use ordered products of linear blocks before scalar projection. Parallel paths of products $+1$ and $-1$ give a zero result despite two individually nonzero paths. + +For nonlinear finite edits, the mixed intervention contrast $f(1,1)-f(1,0)-f(0,1)+f(0,0)$ can be nonzero. For $f(u,v)=uv$ at the zero baseline it equals 1 while both single effects and the first-order derivatives vanish. Corresponding single and joint interventions at physical matched dose are needed to distinguish cancellation, redundancy, and a genuine joint effect. Path accounting with a fixed graph gives a derivative prediction and may miss a routing change when a finite edit alters the graph's effective coefficients. + +## 7. What can be tested + +The synthetic gym gives exact planted channels, independent paired roots, and a delayed reader whose fixed map can be verified by explicit continuation. Its stress panel changes the reached distribution and tests where a fixed compression loses its advantage. The learned T1/T2 atom banks are evaluated separately on exposed Nanbeige CAL archives. For those archives the target is a frozen fitted rank-eight sum and closure against the original BF16 affine module is audited separately. A fixed K-reader response is a linear functional of an archived physical write in one occurrence. For native causal confirmation, future work needs exact all-one full-head parity, aligned per-root donor and recipient states and output directions, native single and joint interventions at matched physical doses, and fresh roots with independently calibrated shams. The processed archive has no authority to release confirmation data. + +A hypothesis left open is that fewer calibrated physical factors can produce equal or better causal rescue on unseen roots than Euclidean SVD or the existing learned banks at equal rank and measured dose. In particular, cache delay, uncertainty in the reference direction, and signed downstream cancellation can reverse an apparent advantage measured by a local reader. The fixed-metric theorems specify what can transfer and expose failure cases. The developmental measurements test specific instances under the registered support and readers. diff --git a/mechinterp/bpd/theory/rtbpd02/test_transport.py b/mechinterp/bpd/theory/rtbpd02/test_transport.py new file mode 100644 index 00000000..19331a67 --- /dev/null +++ b/mechinterp/bpd/theory/rtbpd02/test_transport.py @@ -0,0 +1,179 @@ +"""Independent CPU cases for support, coordinate and causal-transport contracts.""" +import unittest + +import numpy as np + +from transport import ( + delayed_dark_rank, direction, disagreement, dominance_constant, + fixed_future_reader, signed_paths, subspace_angles, +) +from weighted_rank import optimal_sample_rank, optimal_weighted_rank, uncentered_second_moment, weighted_error + + +class SolverAudit(unittest.TestCase): + def test_reader_cutoff_is_applied_to_the_target_and_the_lift(self): + w = np.diag([2., 1e10]) + a = np.diag([1., 1e-9]) + fit = optimal_weighted_rank(w, np.eye(2), 1, a, rtol=1e-6) + np.testing.assert_allclose(fit.operator, np.diag([2., 0.])) + self.assertEqual(fit.reader_rank, 1) + self.assertEqual(fit.error, fit.tail_oracle) + self.assertEqual(fit.error, 0.) + self.assertAlmostEqual(fit.full_error, 100.) + self.assertAlmostEqual(weighted_error(w, fit.operator, np.eye(2), a, full=True), 100.) + exact = optimal_weighted_rank(w, np.eye(2), 1, a, rtol=1e-12) + self.assertAlmostEqual(exact.error, 4.) + self.assertEqual(exact.reader_rank, 2) + + def test_covariance_cutoff_uses_eigenvalues_and_preserves_full_loss(self): + w = np.diag([2., 1e8]) + c = np.diag([1., 1e-10]) + fit = optimal_weighted_rank(w, c, 1, rtol=1e-8) + self.assertEqual(fit.input_support_rank, 1) + self.assertAlmostEqual(fit.error, 0.) + self.assertAlmostEqual(fit.full_error, 1e6) + sample = optimal_sample_rank(w, np.sqrt(2) * np.diag([1., 1e-5]), 1, rtol=1e-8) + np.testing.assert_allclose(sample.operator, fit.operator) + self.assertAlmostEqual(sample.full_error, fit.full_error) + + def test_thin_sample_matches_covariance_with_contrast_and_weights(self): + rng = np.random.default_rng(219) + a = rng.normal(size=(7, 9)) + b = rng.normal(size=a.shape) + w = rng.normal(size=(5, a.shape[1])) + reader = rng.normal(size=(2, w.shape[0])) + weights = np.array([0., 2., 8., 9., 1., 4., 1.]) + rows = a - b + moment = uncentered_second_moment(rows, weights) + sample = optimal_sample_rank(w, rows, 1, reader, weights=weights) + full = optimal_weighted_rank(w, moment, 1, reader) + np.testing.assert_allclose(sample.operator, full.operator, atol=1e-11) + self.assertAlmostEqual(sample.error, full.tail_oracle) + self.assertEqual(sample.input_support_rank, 6) + huge = uncentered_second_moment(np.eye(3), np.full(3, 1e308)) + np.testing.assert_allclose(huge, np.eye(3) / 3) + + def test_numerical_validation_relative_to_small_scales_and_empty_support(self): + with self.assertRaisesRegex(ValueError, "positive semidefinite"): + optimal_weighted_rank(np.eye(2), np.diag([-1e-30, 2e-30]), 1) + with self.assertRaisesRegex(ValueError, "symmetric"): + optimal_weighted_rank(np.eye(2), np.array([[1e-30, 1e-30], [0, 1e-30]]), 1) + for w, c, a in ( + (np.zeros((3, 0)), np.zeros((0, 0)), None), + (np.zeros((0, 2)), np.eye(2), None), + (np.eye(2), np.eye(2), np.zeros((0, 2))), + ): + fit = optimal_weighted_rank(w, c, 7, a) + self.assertEqual(fit.operator.shape, w.shape) + self.assertEqual((fit.error, fit.full_error, fit.tail_oracle), (0., 0., 0.)) + + def test_nonsingular_nonorthogonal_gauges_preserve_the_exact_objective(self): + w = np.array([[1., -3.], [2., 1.]]) + a = np.array([[1., 0.7], [-0.3, 1.]]) + sigma = np.diag([1., .6]) + g = np.array([[3., 1.], [0., .4]]) + h = np.array([[.8, .1], [.5, 1.3]]) + base = optimal_weighted_rank(w, sigma, 1, a) + changed = optimal_weighted_rank( + h @ w @ np.linalg.inv(g), g @ sigma @ g.T, 1, a @ np.linalg.inv(h), + ) + np.testing.assert_allclose(changed.operator, h @ base.operator @ np.linalg.inv(g), atol=1e-12) + self.assertAlmostEqual(base.error, changed.error) + + def test_singular_gauge_covariance_applies_to_solution_sets(self): + w = np.eye(2) + c = np.diag([1., 0.]) + g = np.array([[1., 1.], [0., 1.]]) + base = optimal_weighted_rank(w, c, 1) + changed_w = w @ np.linalg.inv(g) + changed_c = g @ c @ g.T + changed = optimal_weighted_rank(changed_w, changed_c, 1) + transported = base.operator @ np.linalg.inv(g) + self.assertAlmostEqual(weighted_error(changed_w, transported, changed_c), changed.error) + np.testing.assert_allclose(transported[:, 0], changed.operator[:, 0]) + self.assertGreater(np.linalg.norm(transported - changed.operator), .99) + self.assertLess(np.linalg.norm(changed.operator), np.linalg.norm(transported)) + + def test_tied_singular_optima_and_instability_at_a_cutoff(self): + c = np.eye(2) + plus = optimal_weighted_rank(np.diag([1 + 1e-9, 1.]), c, 1).operator + minus = optimal_weighted_rank(np.diag([1., 1 + 1e-9]), c, 1).operator + self.assertAlmostEqual(weighted_error(c, np.diag([1., 0.]), c), 1.) + self.assertAlmostEqual(weighted_error(c, np.diag([0., 1.]), c), 1.) + self.assertAlmostEqual(subspace_angles(plus, minus)[0], np.pi / 2) + + +class TransportAudit(unittest.TestCase): + def test_fixed_and_changed_reader_state_accounting(self): + a = np.array([[1., 2.], [3., 1.]]) + b = np.array([[3., 1.], [2., 3.]]) + xa = np.array([1., -1.]) + xb = np.array([-2., 3.]) + ca, cb = np.array([[2., 3.]]), np.array([[3., 1.]]) + plain = disagreement(a, b, xa, xb) + measured = disagreement(a, b, xa, xb, ca, cb) + np.testing.assert_allclose(plain.total, b @ xb - a @ xa) + np.testing.assert_allclose(measured.total, cb @ b @ xb - ca @ a @ xa) + energies = measured.energies() + self.assertAlmostEqual(energies.pop("total"), sum(energies.values())) + cancel = disagreement([[1.]], [[2.]], [2.], [1.]).energies() + self.assertEqual((cancel["operator"], cancel["state"], cancel["total"]), (2.25, 2.25, 0.)) + self.assertEqual(cancel["operator_state_cross"], -4.5) + + def test_delayed_reader_rank_identity_and_no_transport_counterexample(self): + b = np.eye(2) + j = np.array([[0., 1.], [0., 0.]]) + now = np.array([[1., 0.]]) + future = fixed_future_reader(b, (j,), (np.zeros((0, 2)), now), (0., 4.)) + np.testing.assert_array_equal(future, [[0., 2.]]) + d = np.array([[1., 0., 1.], [0., 1., 1.]]) + rank_gap = np.linalg.matrix_rank(np.vstack((now, future)) @ d) - np.linalg.matrix_rank(now @ d) + self.assertEqual(delayed_dark_rank(now, future, d), rank_gap) + self.assertEqual(delayed_dark_rank(now, np.zeros((1, 2)), d), 0) + self.assertEqual(delayed_dark_rank(np.zeros((0, 2)), future, d), 1) + self.assertEqual(delayed_dark_rank(now, future, np.zeros((2, 0))), 0) + + def test_gain_sign_and_equal_dose_witness(self): + reference = np.array([2., 0.]) + self.assertEqual(direction([1., 0.], reference)["gain"], .5) + self.assertEqual(direction([-1., 0.], reference)["gain"], -.5) + self.assertEqual(direction([0., 0.], reference)["status"], "zero_observed") + self.assertIsNone(direction([1., 0.], [0., 0.])["cosine"]) + + def test_transport_bound_and_two_missing_support_witnesses(self): + source = np.diag([2., 1.]) + target = np.diag([1., 3.]) + ap, aq = np.diag([1., 1.]), np.diag([2., .5]) + m = dominance_constant(source, target) + c = dominance_constant(ap.T @ ap, aq.T @ aq) + self.assertAlmostEqual(m, 3.) + self.assertAlmostEqual(c, 4.) + w, k = np.eye(2), np.diag([1., 0.]) + self.assertLessEqual(weighted_error(w, k, target, aq), m * c * weighted_error(w, k, source, ap)) + first, second = np.diag([1., 0.]), np.diag([0., 1.]) + self.assertTrue(np.isinf(dominance_constant(first, second))) + for cov_p, cov_q, reader_p, reader_q in ( + (first, second, None, None), + (source, source, first, second), + ): + self.assertAlmostEqual(weighted_error(w, k, cov_p, reader_p), 0.) + self.assertAlmostEqual(weighted_error(w, k, cov_q, reader_q), 1.) + self.assertAlmostEqual(dominance_constant(first, 5 * first), 5.) + + def test_signed_cancellation_and_finite_interaction(self): + graph = np.zeros((4, 4)) + graph[1, 0] = graph[2, 0] = graph[3, 1] = 1. + graph[3, 2] = -1. + self.assertEqual(signed_paths(graph, 0, 3), (0., 2.)) + self.assertEqual(signed_paths(graph, 0, 0), (1., 1.)) + graph[0, 3] = 1. + with self.assertRaisesRegex(ValueError, "triangular"): + signed_paths(graph, 0, 3) + f = lambda u, v: u * v + self.assertEqual(f(1, 0) - f(0, 0), 0.) + self.assertEqual(f(0, 1) - f(0, 0), 0.) + self.assertEqual(f(1, 1) - f(1, 0) - f(0, 1) + f(0, 0), 1.) + + +if __name__ == "__main__": + unittest.main() diff --git a/mechinterp/bpd/theory/rtbpd02/transport.py b/mechinterp/bpd/theory/rtbpd02/transport.py new file mode 100644 index 00000000..82f3af58 --- /dev/null +++ b/mechinterp/bpd/theory/rtbpd02/transport.py @@ -0,0 +1,171 @@ +"""Finite-dimensional identities used by RT-BPD-02.""" +from __future__ import annotations + +from dataclasses import dataclass + +import numpy as np + +from weighted_rank import _matrix, _moment_modes, _retained, _tolerance + + +@dataclass(frozen=True) +class Disagreement: + operator: np.ndarray + state: np.ndarray + reader: np.ndarray + + @property + def total(self) -> np.ndarray: + return self.operator + self.state + self.reader + + def energies(self) -> dict[str, float]: + return { + "operator": float(self.operator @ self.operator), + "state": float(self.state @ self.state), + "reader": float(self.reader @ self.reader), + "operator_state_cross": float(2 * (self.operator @ self.state)), + "operator_reader_cross": float(2 * (self.operator @ self.reader)), + "state_reader_cross": float(2 * (self.state @ self.reader)), + "total": float(self.total @ self.total), + } + + +def disagreement(k_a, k_b, x_a, x_b, reader_a=None, reader_b=None) -> Disagreement: + """Split b minus a in common input, write and measured frames.""" + a = _matrix(k_a, "k_a") + b = _matrix(k_b, "k_b") + xa, xb = np.asarray(x_a, dtype=np.float64), np.asarray(x_b, dtype=np.float64) + if a.shape != b.shape or xa.shape != (a.shape[1],) or xa.shape != xb.shape: + raise ValueError("operators and reached states need common dimensions") + if not np.isfinite(xa).all() or not np.isfinite(xb).all(): + raise ValueError("reached states must be finite") + op = (b - a) @ ((xa + xb) / 2) + state = ((a + b) / 2) @ (xb - xa) + if reader_a is None and reader_b is None: + return Disagreement(op, state, np.zeros_like(op)) + ar, br = _matrix(reader_a, "reader_a"), _matrix(reader_b, "reader_b") + if ar.shape != br.shape or ar.shape[1] != a.shape[0]: + raise ValueError("both readers must map writes into the same measured frame") + mean_reader = (ar + br) / 2 + reader = (br - ar) @ ((a @ xa + b @ xb) / 2) + return Disagreement(mean_reader @ op, mean_reader @ state, reader) + + +def fixed_future_reader(write, transitions, readers, weights) -> np.ndarray: + """Stack weighted readouts at horizons zero through len(transitions).""" + propagated = _matrix(write, "write") + w = np.asarray(weights, dtype=np.float64) + if len(readers) != 1 + len(transitions) or w.shape != (len(readers),): + raise ValueError("supply one reader and weight per horizon, including zero") + if not np.isfinite(w).all() or np.any(w < 0): + raise ValueError("reader weights must be nonnegative and finite") + blocks = [] + for horizon, (reader, weight) in enumerate(zip(readers, w)): + if horizon: + propagated = _matrix(transitions[horizon - 1], "transition") @ propagated + block = np.sqrt(weight) * (_matrix(reader, "reader") @ propagated) + blocks.append(block) + return np.vstack(blocks) + + +def _singular_rank(singular_values, rtol: float) -> int: + return int(np.count_nonzero(_retained(singular_values, rtol))) + + +def delayed_dark_rank(present, future, domain, *, rtol: float = 1e-12) -> int: + """Numerical rank of the future reader restricted to currently dark writes. + + First orthonormalize the supplied write domain. Identify the kernel in + current-reader units, then threshold its future image in future-reader + units on the whole supplied domain. + """ + rtol = _tolerance(rtol) + d = _matrix(domain, "domain") + current = _matrix(present, "present") + later = _matrix(future, "future") + q, s, _ = np.linalg.svd(d, full_matrices=False) + q = q[:, :_singular_rank(s, rtol)] + _, now_s, now_vt = np.linalg.svd(current @ q, full_matrices=True) + null = now_vt[_singular_rank(now_s, rtol):, :].T + forward = later @ q + scale = np.linalg.norm(forward, ord=2) if forward.size else 0.0 + delayed_s = np.linalg.svd(forward @ null, compute_uv=False) + return int(np.count_nonzero(delayed_s / scale > rtol)) if scale else 0 + + +def direction(observed, reference, *, zero_atol: float = 0.0) -> dict[str, float | str | None]: + """Measured length, signed parallel gain, and cosine against a fixed direction.""" + x = np.asarray(observed, dtype=np.float64) + y = np.asarray(reference, dtype=np.float64) + if x.shape != y.shape or x.ndim != 1 or not np.isfinite(x).all() or not np.isfinite(y).all(): + raise ValueError("observed and reference must be finite vectors of equal shape") + if not np.isfinite(zero_atol) or zero_atol < 0: + raise ValueError("zero_atol must be finite and nonnegative") + nx, ny = np.linalg.norm(x), np.linalg.norm(y) + if ny <= zero_atol: + return {"status": "zero_reference", "gain": None, "cosine": None, "length": float(nx)} + if nx <= zero_atol: + return {"status": "zero_observed", "gain": 0.0, "cosine": None, "length": float(nx)} + dot = float((x / nx) @ (y / ny)) + cosine = float(np.clip(dot, -1, 1)) + return {"status": "ok", "gain": float(cosine * (nx / ny)), "cosine": cosine, "length": float(nx)} + + +def dominance_constant(source, target, *, rtol: float = 1e-12) -> float: + """Smallest PSD domination constant on numerical support, or infinity. + + Intended for diagnostics at modest dimension. A finite numerical result + is not a certificate for omitted or poorly resolved support directions. + """ + rtol = _tolerance(rtol) + p = _matrix(source, "source") + n = p.shape[0] + q, sp = _moment_modes(p, n) + r, sq = _moment_modes(target, n) + kept = _retained(sp, np.sqrt(rtol)) + target_kept = _retained(sq, np.sqrt(rtol)) + factor = r[:, target_kept] * sq[target_kept] + if not factor.size: + return 0.0 + if np.any(~kept): + null_action = q[:, ~kept].T @ factor + if np.linalg.norm(null_action, ord=2) / sq.max() > np.sqrt(rtol): + return float("inf") + if not np.any(kept): + return float("inf") + whitened = (q[:, kept].T @ factor) / sp[kept, None] + return float(np.linalg.norm(whitened, ord=2) ** 2) + + +def signed_paths(edges, source: int, target: int) -> tuple[float, float]: + """Return signed sum and sum of absolute products in a time-ordered DAG.""" + graph = _matrix(edges, "edges") + n = len(graph) + if graph.shape != (n, n) or np.any(np.triu(graph)): + raise ValueError("edges[dst, src] must be strictly lower triangular") + if not 0 <= source <= target < n: + raise ValueError("node indices must lie in causal order") + signed = np.zeros(n) + absolute = np.zeros(n) + signed[source] = absolute[source] = 1.0 + for dst in range(source + 1, target + 1): + signed[dst] = graph[dst, source:dst] @ signed[source:dst] + absolute[dst] = np.abs(graph[dst, source:dst]) @ absolute[source:dst] + return float(signed[target]), float(absolute[target]) + + +def subspace_angles(a, b, *, rtol: float = 1e-12) -> np.ndarray: + """Angles between actual column supports, in decreasing order. + + Pad missing dimensions with right angles to expose rank loss. + """ + rtol = _tolerance(rtol) + aa, bb = _matrix(a, "a"), _matrix(b, "b") + if aa.shape[0] != bb.shape[0]: + raise ValueError("subspaces need a common output frame") + ua, sa, _ = np.linalg.svd(aa, full_matrices=False) + ub, sb, _ = np.linalg.svd(bb, full_matrices=False) + ka, kb = _singular_rank(sa, rtol), _singular_rank(sb, rtol) + overlap = np.linalg.svd(ua[:, :ka].T @ ub[:, :kb], compute_uv=False) + angles = np.arccos(np.clip(overlap, 0, 1)) + return np.r_[np.repeat(np.pi / 2, abs(ka - kb)), angles[::-1]] diff --git a/mechinterp/bpd/theory/rtbpd02/weighted_rank.py b/mechinterp/bpd/theory/rtbpd02/weighted_rank.py index 4a5d4593..c624bb0b 100644 --- a/mechinterp/bpd/theory/rtbpd02/weighted_rank.py +++ b/mechinterp/bpd/theory/rtbpd02/weighted_rank.py @@ -1,9 +1,4 @@ -"""RT-BPD-02 source-only weighted rank approximation reference implementation. - -All functions are NumPy CPU operations over supplied arrays. No model execution -or external data access is performed. This module describes physical operators, -not learned individual BPD atom identities. -""" +"""CPU reference for rank-constrained physical operators in fixed metrics.""" from __future__ import annotations from dataclasses import dataclass @@ -19,6 +14,7 @@ class RankSolution: singular_values: np.ndarray input_support_rank: int reader_rank: int + full_error: float = float("nan") def _matrix(value: np.ndarray, name: str) -> np.ndarray: @@ -28,21 +24,44 @@ def _matrix(value: np.ndarray, name: str) -> np.ndarray: return out -def uncentered_second_moment(rows: np.ndarray, weights: np.ndarray | None = None) -> np.ndarray: - """Return E[x x^T]. Rows must be the intended independent weighted units.""" +def _rank(rank: int) -> int: + if not isinstance(rank, (int, np.integer)) or isinstance(rank, (bool, np.bool_)) or rank < 0: + raise ValueError("rank must be a nonnegative integer") + return int(rank) + + +def _tolerance(rtol: float) -> float: + if not np.isfinite(rtol) or not 0 < rtol < 1: + raise ValueError("rtol must be in (0,1)") + return float(rtol) + + +def _scaled_rows(rows: np.ndarray, weights: np.ndarray | None) -> np.ndarray: x = _matrix(rows, "rows") - if not x.shape[0]: + if not len(x): raise ValueError("at least one row is required") if weights is None: - return x.T @ x / x.shape[0] + return x / np.sqrt(len(x)) w = np.asarray(weights, dtype=np.float64) - if w.shape != (x.shape[0],) or not np.isfinite(w).all() or (w < 0).any() or w.sum() <= 0: + if w.shape != (len(x),) or not np.isfinite(w).all() or np.any(w < 0) or w.max() == 0: raise ValueError("weights must be finite, nonnegative, and have positive total") - return x.T @ (w[:, None] * x) / w.sum() + scaled = w / w.max() + return np.sqrt(scaled / scaled.sum())[:, None] * x + + +def uncentered_second_moment(rows: np.ndarray, weights: np.ndarray | None = None) -> np.ndarray: + """Return E[x x^T] in the caller's specified sampling measure.""" + if weights is None: + x = _matrix(rows, "rows") + if not len(x): + raise ValueError("at least one row is required") + return (x.T @ x) / len(x) + x = _scaled_rows(rows, weights) + return x.T @ x def paired_contrast_moment(a: np.ndarray, b: np.ndarray, weights: np.ndarray | None = None) -> np.ndarray: - """Second moment of paired A/B differences. Caller guarantees root balance.""" + """Return the second moment of paired A/B differences.""" aa = _matrix(a, "a") bb = _matrix(b, "b") if aa.shape != bb.shape: @@ -52,30 +71,74 @@ def paired_contrast_moment(a: np.ndarray, b: np.ndarray, weights: np.ndarray | N def truncated_svd(operator: np.ndarray, rank: int) -> np.ndarray: w = _matrix(operator, "operator") - if not isinstance(rank, (int, np.integer)) or isinstance(rank, (bool, np.bool_)) or rank < 0: - raise ValueError("rank must be a nonnegative integer") + rank = _rank(rank) u, s, vt = np.linalg.svd(w, full_matrices=False) - k = min(rank, len(s)) - return (u[:, :k] * s[:k]) @ vt[:k, :] + return (u[:, :rank] * s[:rank]) @ vt[:rank, :] -def _moment_sqrt_and_pinv(covariance: np.ndarray, n: int, rtol: float) -> tuple[np.ndarray, np.ndarray, int]: +def _moment_modes(covariance: np.ndarray, width: int) -> tuple[np.ndarray, np.ndarray]: cov = _matrix(covariance, "covariance") - if cov.shape != (n, n): + if cov.shape != (width, width): raise ValueError("covariance shape must match operator inputs") - scale = max(1.0, float(np.linalg.norm(cov, ord=2))) - if not np.allclose(cov, cov.T, atol=1e-12 * scale, rtol=1e-12): + if not width: + return cov, np.empty(0) + scale = np.max(np.abs(cov)) + if not scale: + return np.eye(width), np.zeros(width) + scaled = cov / scale + # Validate PSD relative to the declared matrix scale before selecting support. + if np.max(np.abs(scaled - scaled.T)) > 1e-12: raise ValueError("covariance must be symmetric") - sym = (cov + cov.T) / 2 - eigval, eigvec = np.linalg.eigh(sym) - if eigval[0] < -1e-12 * scale: + eigenvalues, vectors = np.linalg.eigh((scaled + scaled.T) / 2) + if eigenvalues[0] < -1e-12 * np.max(np.abs(eigenvalues)): raise ValueError("covariance must be positive semidefinite") - positive = eigval > rtol * max(float(eigval[-1]), np.finfo(np.float64).tiny) - basis = eigvec[:, positive] - root = np.sqrt(eigval[positive]) - sqrt = (basis * root) @ basis.T - pinv_sqrt = (basis / root) @ basis.T - return sqrt, pinv_sqrt, int(positive.sum()) + roots = np.sqrt(np.maximum(eigenvalues, 0)) * np.sqrt(scale) + return vectors, roots + + +def _retained(values: np.ndarray, cutoff: float) -> np.ndarray: + if not len(values) or values.max() == 0: + return np.zeros(len(values), dtype=bool) + return values / values.max() > cutoff + + +def _reader_modes(reader: np.ndarray | None, width: int, rtol: float): + if reader is None: + return None, None, None + a = _matrix(reader, "reader") + if a.shape[1] != width: + raise ValueError("reader input width must match operator output width") + _, values, vt = np.linalg.svd(a, full_matrices=False) + kept = _retained(values, rtol) + return a, vt[kept, :].T, values[kept] + + +def _squared(values: np.ndarray) -> float: + return float(np.sum(np.square(values))) + + +def _solve(w, basis, roots, rank, reader, rtol) -> RankSolution: + kept = _retained(roots, np.sqrt(rtol)) + input_basis = basis[:, kept] + input_roots = roots[kept] + a, output_basis, output_values = _reader_modes(reader, w.shape[0], rtol) + weighted_w = (w @ input_basis) * input_roots + target = weighted_w if a is None else output_values[:, None] * (output_basis.T @ weighted_w) + u, s, vt = np.linalg.svd(target, full_matrices=False) + projected = (u[:, :rank] * s[:rank]) @ vt[:rank, :] + lift = projected if a is None else output_basis @ (projected / output_values[:, None]) + estimate = (lift / input_roots) @ input_basis.T + defect = w - estimate + effective = (defect @ input_basis) * input_roots + full = (defect @ basis) * roots + if a is not None: + effective = output_values[:, None] * (output_basis.T @ effective) + full = a @ full + reader_rank = w.shape[0] if a is None else len(output_values) + return RankSolution( + estimate, _squared(effective), _squared(s[rank:]), s, + len(input_roots), reader_rank, _squared(full), + ) def optimal_weighted_rank( @@ -86,48 +149,61 @@ def optimal_weighted_rank( *, rtol: float = 1e-12, ) -> RankSolution: - """Minimize ||reader @ (W - K) @ sqrt(covariance)||_F^2, rank(K)<=rank. - - With reader=None, the identity map on physical write space is used. - A truncated SVD of reader@W@sqrt(covariance) gives the exact global - optimum. Pseudoinverses pick a minimum-norm representative, including - when covariance or reader is rank deficient. + """Solve the rank-constrained loss on the retained input and reader supports. - Eigenmodes below rtol * largest covariance eigenvalue are treated as - numerical null directions. Readers use the same relative cutoff. + Covariance eigenvalues and reader singular values must exceed rtol times + their respective maxima. The effective loss, its spectral tail and the + lift share those supports. full_error evaluates the same estimate using + all modes of the symmetrized PSD moment and the supplied reader. """ w = _matrix(operator, "operator") - if not isinstance(rank, (int, np.integer)) or isinstance(rank, (bool, np.bool_)) or rank < 0: - raise ValueError("rank must be a nonnegative integer") - if not np.isfinite(rtol) or rtol <= 0 or rtol >= 1: - raise ValueError("rtol must be in (0,1)") - m, n = w.shape - a = np.eye(m) if reader is None else _matrix(reader, "reader") - if a.shape[1] != m: - raise ValueError("reader input width must match operator output width") - sqrt, pinv_sqrt, n_support = _moment_sqrt_and_pinv(covariance, n, rtol) - target = a @ w @ sqrt - u, s, vt = np.linalg.svd(target, full_matrices=False) - k = min(rank, len(s)) - target_rank_k = (u[:, :k] * s[:k]) @ vt[:k, :] - if reader is None: - estimate = target_rank_k @ pinv_sqrt - else: - estimate = np.linalg.pinv(a, rcond=rtol) @ target_rank_k @ pinv_sqrt - error = float(np.linalg.norm(a @ (w - estimate) @ sqrt, ord="fro") ** 2) - tail = float(np.sum(s[k:] ** 2)) - reader_rank = m if reader is None else int(np.linalg.matrix_rank(a, tol=rtol * (np.linalg.svd(a, compute_uv=False)[0] if a.size else 0))) - return RankSolution(estimate, error, tail, s, n_support, reader_rank) + rank = _rank(rank) + rtol = _tolerance(rtol) + basis, roots = _moment_modes(covariance, w.shape[1]) + return _solve(w, basis, roots, rank, reader, rtol) + + +def optimal_sample_rank( + operator: np.ndarray, + rows: np.ndarray, + rank: int, + reader: np.ndarray | None = None, + *, + weights: np.ndarray | None = None, + rtol: float = 1e-12, +) -> RankSolution: + """Solve the same problem using a thin SVD of weighted sample rows.""" + w = _matrix(operator, "operator") + rank = _rank(rank) + rtol = _tolerance(rtol) + x = _scaled_rows(rows, weights) + if x.shape[1] != w.shape[1]: + raise ValueError("row width must match operator inputs") + _, roots, vt = np.linalg.svd(x, full_matrices=False) + return _solve(w, vt.T, roots, rank, reader, rtol) -def weighted_error(operator: np.ndarray, estimate: np.ndarray, covariance: np.ndarray, reader: np.ndarray | None = None) -> float: - """Evaluate a rank candidate with the same physical reached-state metric.""" +def weighted_error( + operator: np.ndarray, + estimate: np.ndarray, + covariance: np.ndarray, + reader: np.ndarray | None = None, + *, + rtol: float = 1e-12, + full: bool = False, +) -> float: + """Evaluate a candidate in the effective metric or the original PSD metric.""" w = _matrix(operator, "operator") k = _matrix(estimate, "estimate") if k.shape != w.shape: raise ValueError("estimate must have the operator shape") - a = np.eye(w.shape[0]) if reader is None else _matrix(reader, "reader") - if a.shape[1] != w.shape[0]: - raise ValueError("reader input width must match operator output width") - sqrt, _, _ = _moment_sqrt_and_pinv(covariance, w.shape[1], 1e-12) - return float(np.linalg.norm(a @ (w - k) @ sqrt, ord="fro") ** 2) + rtol = _tolerance(rtol) + basis, roots = _moment_modes(covariance, w.shape[1]) + a, output_basis, output_values = _reader_modes(reader, w.shape[0], rtol) + if not full: + kept = _retained(roots, np.sqrt(rtol)) + basis, roots = basis[:, kept], roots[kept] + residual = ((w - k) @ basis) * roots + if a is not None: + residual = a @ residual if full else output_values[:, None] * (output_basis.T @ residual) + return _squared(residual) From 17f043b3d324ee1bf27e90298f3ccf1f15d78ff3 Mon Sep 17 00:00:00 2001 From: Patrick Dugan Date: Mon, 23 Nov 2026 22:15:34 +0800 Subject: [PATCH 16/18] Verify paired recurrent gym and matched-dose controls on CPU --- .github/workflows/rtbpd02-source-only.yml | 22 +- mechinterp/bpd/theory/rtbpd02/controls.py | 19 ++ .../bpd/theory/rtbpd02/synthetic_gym.py | 304 ++++++++++++++++++ .../bpd/theory/rtbpd02/test_synthetic_gym.py | 82 +++++ 4 files changed, 424 insertions(+), 3 deletions(-) create mode 100644 mechinterp/bpd/theory/rtbpd02/controls.py create mode 100644 mechinterp/bpd/theory/rtbpd02/synthetic_gym.py create mode 100644 mechinterp/bpd/theory/rtbpd02/test_synthetic_gym.py diff --git a/.github/workflows/rtbpd02-source-only.yml b/.github/workflows/rtbpd02-source-only.yml index 6cd6cbfc..512b4406 100644 --- a/.github/workflows/rtbpd02-source-only.yml +++ b/.github/workflows/rtbpd02-source-only.yml @@ -1,4 +1,4 @@ -name: RT-BPD-02 source-only CPU mathematics +name: RT-BPD-02 CPU theory and synthetic replay on: pull_request: @@ -14,12 +14,28 @@ jobs: weighted-rank-cpu: runs-on: ubuntu-latest timeout-minutes: 10 + env: + OPENBLAS_NUM_THREADS: "1" + OMP_NUM_THREADS: "1" + MKL_NUM_THREADS: "1" steps: - uses: actions/checkout@v4 + with: + sparse-checkout: | + mechinterp/bpd/theory/rtbpd02 + sparse-checkout-cone-mode: false - uses: actions/setup-python@v5 with: python-version: "3.11" - name: Install source-only numerical dependency run: python -m pip install --disable-pip-version-check "numpy==1.26.4" - - name: Verify weighted low-rank theorems and locked fixtures - run: python -m unittest discover -s mechinterp/bpd/theory/rtbpd02 -p 'test_weighted_rank.py' -v + - name: Check mathematical fixtures, custody logic and independent root reduction + run: python -m unittest discover -s mechinterp/bpd/theory/rtbpd02 -p 'test_*.py' -v + - name: Reproduce registered synthetic development receipts + run: python mechinterp/bpd/theory/rtbpd02/synthetic_gym.py --out "$RUNNER_TEMP/rtbpd02" + - uses: actions/upload-artifact@v4 + with: + name: rtbpd02-synthetic-development + path: ${{ runner.temp }}/rtbpd02/*.json + if-no-files-found: error + retention-days: 14 diff --git a/mechinterp/bpd/theory/rtbpd02/controls.py b/mechinterp/bpd/theory/rtbpd02/controls.py new file mode 100644 index 00000000..1f88da3b --- /dev/null +++ b/mechinterp/bpd/theory/rtbpd02/controls.py @@ -0,0 +1,19 @@ +"""Shared fixed-atom control for matched-rank comparisons.""" +from itertools import combinations + +import numpy as np + + +def best_atom_subset(actions: np.ndarray, target: np.ndarray, rank: int) -> tuple[int, ...]: + """Pick the least squared residual on training actions, then lexical ties. + + actions[i, j] is the projected physical action of atom j on training + sample i. A bank of rank-one atoms gives a summed operator of rank at most + the chosen count. The caller separately checks the achieved rank. + """ + if actions.ndim != 3 or target.shape != (actions.shape[0], actions.shape[2]): + raise ValueError("atom actions and target must share samples and write width") + if not 0 <= rank <= actions.shape[1]: + raise ValueError("invalid atom count") + candidates = combinations(range(actions.shape[1]), rank) + return min(candidates, key=lambda keep: (float(np.sum((target - actions[:, keep].sum(axis=1)) ** 2)), keep)) diff --git a/mechinterp/bpd/theory/rtbpd02/synthetic_gym.py b/mechinterp/bpd/theory/rtbpd02/synthetic_gym.py new file mode 100644 index 00000000..34bbfc3f --- /dev/null +++ b/mechinterp/bpd/theory/rtbpd02/synthetic_gym.py @@ -0,0 +1,304 @@ +"""Registered six-dimensional tied recurrence with paired-root development.""" +from __future__ import annotations + +import argparse +from dataclasses import dataclass +from hashlib import sha256 +import json +from pathlib import Path +from statistics import fmean + +import numpy as np + +from controls import best_atom_subset +from transport import delayed_dark_rank, direction, disagreement, dominance_constant, fixed_future_reader, subspace_angles +from weighted_rank import optimal_sample_rank, truncated_svd, uncentered_second_moment + + +HERE = Path(__file__).resolve().parent + + +@dataclass(frozen=True) +class Gym: + basis: np.ndarray + operator: np.ndarray + background: np.ndarray + scale: float + current: np.ndarray + delayed: np.ndarray + random_output: np.ndarray + + def step(self, states, edit=None): + live, stage = states[..., 0, :], states[..., 1, :] + writes = live @ self.operator.T + if edit is not None: + writes = writes + edit + return np.stack((live @ self.background.T + self.scale * writes, writes, stage), axis=-2) + + def reaches(self, roots, passes): + states = np.stack((roots, np.zeros_like(roots), np.zeros_like(roots)), axis=-2) + result = {} + for occurrence in range(1, max(passes) + 1): + if occurrence in passes: + result[occurrence] = states + states = self.step(states) + return result + + def future_effect(self, before, edit): + base = self.step(self.step(before)) + patched = self.step(self.step(before, edit)) + return (patched[..., 2, :] - base[..., 2, :]) @ self.delayed.T + + +def build(spec: dict) -> Gym: + rng = np.random.default_rng(spec["geometry_seed"]) + n = len(spec["spectrum"]) + q, r = np.linalg.qr(rng.normal(size=(n, n))) + q *= np.sign(np.diag(r)) + w = (q * spec["spectrum"]) @ q.T + f = (q * spec["background_diagonal"]) @ q.T + random, _ = np.linalg.qr(rng.normal(size=(n, spec["rank"])), mode="reduced") + return Gym(q, w, f, spec["recurrent_write_scale"], q[:, :2].T, + np.asarray(spec["delayed_reader_mix"]) @ q[:, 2:4].T, random) + + +def make_roots(spec: dict, gym: Gym, split: int, count: int, scales: list[float]) -> np.ndarray: + rng = np.random.default_rng(np.random.SeedSequence([spec["root_seed"], split])) + common, diff = rng.normal(size=(2, count, len(scales))) * scales + planted = np.stack((common - diff, common + diff), axis=1) + return planted @ gym.basis.T + + +def reader_maps(gym: Gym) -> tuple[np.ndarray, np.ndarray]: + n = len(gym.operator) + zero, eye = np.zeros((n, n)), np.eye(n) + j = np.block([ + [gym.background + gym.scale * gym.operator, zero, zero], + [gym.operator, zero, zero], + [zero, eye, zero], + ]) + b = np.vstack((gym.scale * eye, eye, zero)) + current = np.hstack((np.zeros_like(gym.current), gym.current, np.zeros_like(gym.current))) + delayed = np.hstack((np.zeros_like(gym.delayed), np.zeros_like(gym.delayed), gym.delayed)) + now = fixed_future_reader(b, (), (current,), (1.,)) + later = fixed_future_reader(b, (j,), (np.zeros((0, 3 * n)), delayed), (0., 1.)) + return now, later + + +def fit(gym: Gym, training: np.ndarray, now, later, spec: dict): + w, q, rank = gym.operator, gym.basis, spec["rank"] + rows = training[..., 0, :].reshape(-1, w.shape[1]) + readouts = np.vstack((now, later)) / np.sqrt(2) + atom_writes = (rows @ q * spec["spectrum"])[..., None] * q.T + best = best_atom_subset(atom_writes @ readouts.T, rows @ w.T @ readouts.T, rank) + bpd_mask = (q[:, best] * np.asarray(spec["spectrum"])[list(best)]) @ q[:, best].T + reach_fit = optimal_sample_rank(w, rows, rank) + reader_fit = optimal_sample_rank(w, rows, rank, later) + random = gym.random_output + operators = { + "svd": truncated_svd(w, rank), + "reach": reach_fit.operator, + "reader": reader_fit.operator, + "bpd_static": bpd_mask, + "random": random @ (random.T @ w), + } + return operators, { + "bpd_selected_atoms_zero_based": list(best), + "reach_fit_loss": reach_fit.error, + "reach_spectral_tail": reach_fit.tail_oracle, + "reader_fit_loss": reader_fit.error, + "reader_spectral_tail": reader_fit.tail_oracle, + } + + +def score_root(gym, candidate, before, now, later, dose_fraction, atol): + x = before[:, 0, :] + writes = x @ gym.operator.T + estimates = x @ candidate.T + errors = writes - estimates + truth = writes[1] - writes[0] + contrast = estimates[1] - estimates[0] + dose = dose_fraction * np.linalg.norm(truth) + if dose <= atol: + raise ValueError("registered synthetic donor has zero physical contrast") + norm = np.linalg.norm(contrast) + proposed = contrast * (dose / norm) if norm > atol else np.zeros_like(contrast) + reference_write = dose_fraction * truth + ref = gym.future_effect(before[0], reference_write) + actual = gym.future_effect(before[0], proposed) + closure = float(max(np.max(np.abs(ref - later @ reference_write)), np.max(np.abs(actual - later @ proposed)))) + measured_write = gym.step(before[0], proposed)[1] - gym.step(before[0])[1] + dose_realized = float(np.linalg.norm(measured_write)) + physical_status = "matched" if norm > atol else "zero_write" + if closure > atol or (physical_status == "matched" and abs(dose_realized - dose) > atol): + raise ValueError("finite continuation or physical dose did not close") + outcome = direction(actual, ref, zero_atol=atol) + return { + "write_mse": float(np.mean(np.sum(errors ** 2, axis=-1))), + "current_mse": float(np.mean(np.sum((errors @ now.T) ** 2, axis=-1))), + "future_mse": float(np.mean(np.sum((errors @ later.T) ** 2, axis=-1))), + "contrast_write_sq_error": float(np.sum((truth - contrast) ** 2)), + "truth_write_mse": float(np.mean(np.sum(writes ** 2, axis=-1))), + "truth_future_mse": float(np.mean(np.sum((writes @ later.T) ** 2, axis=-1))), + "requested_dose": float(dose), + "physical_dose": dose_realized, + "physical_status": physical_status, + "reader_closure_max_abs": closure, + "future_direction": outcome, + } + + +def summarize(records: list[dict], methods: list[str]) -> dict: + panes = {} + for panel in sorted({r["panel"] for r in records}): + passes = {} + for occurrence in sorted({r["pass"] for r in records}): + group = [r["methods"] for r in records if r["panel"] == panel and r["pass"] == occurrence] + comparison = {} + for method in methods: + subset = [r[method] for r in group] + means = {key: fmean(r[key] for r in subset) for key in ( + "write_mse", "current_mse", "future_mse", "contrast_write_sq_error", + "truth_write_mse", "truth_future_mse", + )} + means["write_relative_mse"] = means["write_mse"] / means["truth_write_mse"] + means["future_relative_mse"] = means["future_mse"] / means["truth_future_mse"] + means["max_reader_closure_abs"] = max(r["reader_closure_max_abs"] for r in subset) + means["max_matched_dose_error"] = max( + (abs(r["requested_dose"] - r["physical_dose"]) for r in subset if r["physical_status"] == "matched"), + default=None, + ) + means["unmatched_writes"] = sum(r["physical_status"] != "matched" for r in subset) + for field in ("gain", "cosine"): + values = [r["future_direction"][field] for r in subset if r["future_direction"][field] is not None] + means[f"mean_{field}_when_defined"] = fmean(values) if values else None + means[f"n_{field}_defined"] = len(values) + means["negative_gain_roots"] = sum((r["future_direction"]["gain"] or 0) < 0 for r in subset) + comparison[method] = means + passes[str(occurrence)] = {"root_count": len(group), "methods": comparison} + panes[panel] = passes + primary = [r["methods"] for r in records if r["panel"] == "aligned" and r["pass"] == 2] + paired = [r["svd"]["future_mse"] - r["reader"]["future_mse"] for r in primary] + return {"panels": panes, "primary_paired_svd_minus_reader": { + "mean": fmean(paired), "min": min(paired), "max": max(paired), + "positive_roots": sum(x > 0 for x in paired), "roots": len(paired), + }} + + +def evalmath_input(records: list[dict], spec: dict) -> dict: + def as_score(record): + measured = record["future_direction"] + if measured["status"] == "zero_reference": + raise ValueError("reference contrast has no direction for the registered endpoint") + return 0.0 if measured["status"] == "zero_observed" else measured["cosine"] + + rows = [] + for r in records: + if r["panel"] == "aligned" and r["pass"] == 2: + outcomes = r["methods"] + baseline = as_score(outcomes["svd"]) + rows.append({ + "unit_id": r["root_id"], + "paired_effect": f"{(as_score(outcomes['reader']) - baseline) / 2:.12f}", + "sham_effects": [f"{(as_score(outcomes['random']) - baseline) / 2:.12f}"], + }) + return { + "schema_version": 1, + "experiment_id": "RT-BPD-02 synthetic matched-dose direction", + "independent_unit": "paired development source root", + "alpha": spec["alpha"], + "scientific_min_effect": spec["scientific_min_effect"], + "target_effect": spec["target_effect"], + "measurement_resolution": spec["measurement_resolution"], + "sham_quantile": spec["quantile"], + "sham_confidence": spec["confidence"], + "planned_comparisons": spec["planned_comparisons"], + "confirm_units_planned": spec["nominal_planning_roots"], + "pilot_from_development_only": True, + "heldout_sealed": spec["heldout_sealed"], + "units_independent": True, + "pilot": rows, + } + + +def run(registration: dict) -> tuple[dict, list[dict], dict]: + spec = registration["synthetic"] + gym = build(spec) + passes = spec["occurrence_passes"] + now, later = reader_maps(gym) + training = make_roots(spec, gym, 0, spec["train_roots"], spec["initial_reach_scale"]) + train = gym.reaches(training, passes) + policies, training_diagnostics = {}, {} + for p in passes: + policies[p], audit = fit(gym, train[p], now, later, spec) + halves = [fit(gym, x, now, later, spec)[0] for x in np.split(train[p], 2)] + audit["column_rank"] = {k: int(np.linalg.matrix_rank(v)) for k, v in policies[p].items()} + if list(policies[p]) != spec["methods"] or any(r != spec["rank"] for r in audit["column_rank"].values()): + raise ValueError("a registered comparator failed the matched rank") + audit["half_cal_max_output_angle_deg"] = { + k: float(np.degrees(subspace_angles(halves[0][k], halves[1][k]).max())) + for k in policies[p] + } + training_diagnostics[str(p)] = audit + + records, decomposition = [], {} + for panel, scale in zip(spec["branches"], (spec["initial_reach_scale"], spec["shifted_development_scale"]), strict=True): + roots = make_roots(spec, gym, 1, spec["development_roots"], scale) + reached = gym.reaches(roots, passes) + paired = {p: reached[p][:, 1, 0, :] - reached[p][:, 0, 0, :] for p in passes} + a, b = passes + moments = {p: uncentered_second_moment(reached[p][..., 0, :].reshape(-1, len(gym.basis))) for p in passes} + decomposition[panel] = { + "empirical_pass2_over_pass1_psd_bound": dominance_constant(moments[a], moments[b]), + "mean_contrast_energies": {}, + } + for method, ka, kb in [ + ("tied_target", gym.operator, gym.operator), + *((m, policies[a][m], policies[b][m]) for m in spec["methods"]), + ]: + pieces = [disagreement(ka, kb, x, y).energies() for x, y in zip(paired[a], paired[b], strict=True)] + decomposition[panel]["mean_contrast_energies"][method] = { + field: fmean(r[field] for r in pieces) for field in pieces[0] + } + for p in passes: + for i, before in enumerate(reached[p]): + outcomes = { + m: score_root(gym, candidate, before, now, later, spec["physical_dose"], + spec["numerical_closure_atol"]) + for m, candidate in policies[p].items() + } + records.append({"panel": panel, "pass": p, "root_id": f"dev-{i:03d}", "methods": outcomes}) + summary = summarize(records, spec["methods"]) + summary.update({ + "schema": "rtbpd02-synthetic/v1", + "split_counts": {"train": spec["train_roots"], "development": spec["development_roots"]}, + "delayed_dark_rank": delayed_dark_rank(now, later, np.eye(len(gym.basis))), + "fit_diagnostics": training_diagnostics, + "pass_transport": decomposition, + }) + return summary, records, evalmath_input(records, registration["evalmath"]) + + +def write_json(path: Path, data) -> None: + path.write_text(json.dumps(data, indent=2, sort_keys=True, allow_nan=False) + "\n", encoding="utf-8", newline="\n") + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--out", type=Path, required=True) + args = parser.parse_args() + registration = (HERE / "EXTENSION_REGISTRATION.json").read_bytes() + summary, roots, planner = run(json.loads(registration)) + output = args.out + output.mkdir(parents=True, exist_ok=True) + root_path = output / "synthetic_roots.json" + write_json(root_path, roots) + summary["registration_sha256"] = sha256(registration).hexdigest() + summary["synthetic_roots_sha256"] = sha256(root_path.read_bytes()).hexdigest() + write_json(output / "synthetic_summary.json", summary) + write_json(output / "evalmath_input.json", planner) + print(json.dumps(summary["primary_paired_svd_minus_reader"], sort_keys=True)) + + +if __name__ == "__main__": + main() diff --git a/mechinterp/bpd/theory/rtbpd02/test_synthetic_gym.py b/mechinterp/bpd/theory/rtbpd02/test_synthetic_gym.py new file mode 100644 index 00000000..dffdeaca --- /dev/null +++ b/mechinterp/bpd/theory/rtbpd02/test_synthetic_gym.py @@ -0,0 +1,82 @@ +"""Independent root reduction and physical closure for the registered gym.""" +import json +from pathlib import Path +from statistics import fmean +import unittest + +import numpy as np + +from synthetic_gym import build, make_roots, reader_maps, run + + +class SyntheticGymTests(unittest.TestCase): + @classmethod + def setUpClass(cls): + path = Path(__file__).with_name("EXTENSION_REGISTRATION.json") + cls.registration = json.loads(path.read_bytes()) + cls.summary, cls.roots, cls.evalmath = run(cls.registration) + + def test_primary_independent_reduction_and_analytic_reader(self): + g = self.registration["synthetic"] + gym = build(g) + roots = make_roots(g, gym, 1, g["development_roots"], g["initial_reach_scale"]) + initial = roots @ gym.basis + tied_multiplier = np.array(g["background_diagonal"]) + g["recurrent_write_scale"] * np.array(g["spectrum"]) + pass_two = initial * tied_multiplier + analytic = (pass_two[..., 2:4] * np.array(g["spectrum"][2:4])) @ np.asarray(g["delayed_reader_mix"]).T + expected = np.mean(np.sum(np.square(analytic), axis=-1), axis=-1) + rows = [r for r in self.roots if (r["pass"], r["panel"]) == (2, "aligned")] + self.assertEqual(len(rows), 64) + self.assertEqual(len({r["root_id"] for r in rows}), 64) + svd, reader = [[r["methods"][k]["future_mse"] for r in rows] for k in ("svd", "reader")] + np.testing.assert_allclose(svd, expected, atol=1e-11) + np.testing.assert_allclose(reader, np.zeros_like(expected), atol=1e-20) + reduced = fmean(a - b for a, b in zip(svd, reader, strict=True)) + self.assertGreater(reduced, 1.) + self.assertAlmostEqual(reduced, self.summary["primary_paired_svd_minus_reader"]["mean"]) + self.assertEqual(self.summary["primary_paired_svd_minus_reader"]["positive_roots"], 64) + self.assertEqual(self.summary["delayed_dark_rank"], 2) + + def test_shift_reverses_write_advantage_and_roots_are_paired(self): + data = self.summary["panels"] + aligned, shifted = (data[panel]["2"]["methods"] for panel in ("aligned", "shifted")) + self.assertLess(aligned["reach"]["write_mse"], aligned["svd"]["write_mse"]) + self.assertGreater(shifted["reach"]["write_mse"], shifted["svd"]["write_mse"]) + groups = { + (p, b): {r["root_id"] for r in self.roots if (r["pass"], r["panel"]) == (p, b)} + for p in (1, 2) for b in ("aligned", "shifted") + } + self.assertEqual(len(groups[1, "aligned"]), 64) + self.assertTrue(all(g == groups[1, "aligned"] for g in groups.values())) + + def test_physical_dose_closure_and_evalmath_inputs(self): + for phase in self.summary["fit_diagnostics"].values(): + self.assertEqual(set(phase["column_rank"].values()), {2}) + self.assertAlmostEqual(phase["reach_fit_loss"], phase["reach_spectral_tail"]) + self.assertAlmostEqual(phase["reader_fit_loss"], phase["reader_spectral_tail"]) + for row in self.roots: + methods = row["methods"] + self.assertTrue(all(rec["physical_status"] == "matched" for rec in methods.values())) + self.assertTrue(all(abs(rec["physical_dose"] - rec["requested_dose"]) < 1e-11 for rec in methods.values())) + self.assertTrue(all(rec["reader_closure_max_abs"] < 1e-11 for rec in methods.values())) + self.assertEqual(methods["svd"]["future_direction"]["status"], "zero_observed") + self.assertAlmostEqual(methods["reader"]["future_direction"]["cosine"], 1.) + self.assertFalse(self.evalmath["heldout_sealed"]) + self.assertEqual(len(self.evalmath["pilot"]), 64) + for row in self.evalmath["pilot"]: + self.assertAlmostEqual(float(row["paired_effect"]), .5) + self.assertEqual(len(row["sham_effects"]), 1) + + def test_stage_to_memory_is_the_delayed_transport(self): + spec = self.registration["synthetic"] + gym = build(spec) + now, later = reader_maps(gym) + write = gym.basis[:, 2] + np.testing.assert_allclose(now @ write, [0., 0.], atol=1e-14) + before = gym.reaches(make_roots(spec, gym, 1, 3, spec["initial_reach_scale"]), [2])[2][0, 0] + np.testing.assert_allclose(gym.future_effect(before, write), [1., -.125], atol=1e-14) + np.testing.assert_allclose(later @ write, [1., -.125], atol=1e-14) + + +if __name__ == "__main__": + unittest.main() From caa58778bee72e367a3f8387b986206bb5d0a12f Mon Sep 17 00:00:00 2001 From: Patrick Dugan Date: Mon, 23 Nov 2026 22:24:30 +0800 Subject: [PATCH 17/18] Freeze and implement read-only Nanbeige CAL archive replay --- mechinterp/bpd/theory/rtbpd02/ARCHIVE.md | 21 ++ .../bpd/theory/rtbpd02/EXTENSION_PROTOCOL.md | 2 +- .../rtbpd02/EXTENSION_REGISTRATION.json | 12 +- .../bpd/theory/rtbpd02/archive_analysis.py | 254 +++++++++++++++++ .../bpd/theory/rtbpd02/archive_checkpoint.py | 178 ++++++++++++ .../bpd/theory/rtbpd02/archive_inputs.py | 260 ++++++++++++++++++ .../bpd/theory/rtbpd02/archive_lease.py | 100 +++++++ .../bpd/theory/rtbpd02/replay_archive.py | 117 ++++++++ .../bpd/theory/rtbpd02/test_archive_replay.py | 115 ++++++++ 9 files changed, 1057 insertions(+), 2 deletions(-) create mode 100644 mechinterp/bpd/theory/rtbpd02/ARCHIVE.md create mode 100644 mechinterp/bpd/theory/rtbpd02/archive_analysis.py create mode 100644 mechinterp/bpd/theory/rtbpd02/archive_checkpoint.py create mode 100644 mechinterp/bpd/theory/rtbpd02/archive_inputs.py create mode 100644 mechinterp/bpd/theory/rtbpd02/archive_lease.py create mode 100644 mechinterp/bpd/theory/rtbpd02/replay_archive.py create mode 100644 mechinterp/bpd/theory/rtbpd02/test_archive_replay.py diff --git a/mechinterp/bpd/theory/rtbpd02/ARCHIVE.md b/mechinterp/bpd/theory/rtbpd02/ARCHIVE.md new file mode 100644 index 00000000..4fb7bb53 --- /dev/null +++ b/mechinterp/bpd/theory/rtbpd02/ARCHIVE.md @@ -0,0 +1,21 @@ +# Nanbeige CAL archive and future extraction contract + +The replay reads the eight existing focused CAL roots in both worlds at the initial last-prompt token, passes 1 and 2, physical layer 21. Each of the two backends supplies a 10,752-coordinate down-projection input, a 3,072-coordinate native write, and a 3,072-coordinate raw post-layer carrier for each case and pass. COMP14 captured these values at the first generation step with batch size one. The public roster supplies selection and slot identity. Only selected case and state payloads are opened. The corresponding terminal audit anchors the hashes and completed coverage for the original source. The replay verifies the initial token-list digest from the original tokenizer receipt, the case, and the capture length. + +Use the SHA-locked local LoopedTransformers archive tree and the original snapshot directory. The runner checks pinned source and audit hashes, world pairing, backend, target parameter identity, pass, layer, vector shape, checkpoint revision, and separate BF16 and NF4 IO18 fit qualifications. It checks both IO18 trajectories against the common initializer and original all-one full-head and boundary-state bitwise receipts. The eight T2 atoms define the target sum for compression. The source model's physical down-projection is larger and has a separate closure check. + +The BF16 replay streams both pinned shards through read-only handles and reads the requested affine and RMSNorm tensors with NumPy. It publishes bitwise match counts and numerical deviations of a specified CPU emulation against the original captured BF16 native writes. The archived all-one native qualification and the CPU emulation are separately identified. The fixed pass-1 K reader is the derivative of the continuous two-RMSNorm map at the train-fold mean carrier followed by the pinned K projection. Heldout worlds in a root stay together, and CAL exposures predate these folds. The K tangent measures a local reader coordinate and is upstream of attention, recurrence, and answer scoring. + +Run the optional replay with archive and snapshot paths and a fresh output directory outside both input trees. + + python mechinterp/bpd/theory/rtbpd02/replay_archive.py --archive PATH_TO_LOOPEDTRANSFORMERS --snapshot PATH_TO_PINNED_SNAPSHOT --out NEW_OUTPUT_DIRECTORY + +Admission requires at least 5 GiB of available physical memory. The single-thread process uses below-normal priority, a 4 GiB system reserve, a 512 MiB process-private limit, and a 420 second wall limit. The runner does not load a decoder runtime. Its output consists of aggregate measurements and public source provenance plus a local EvalMath input with pseudonymous scalar root effects. The BPD report can publish the aggregate and EvalMath decision. Raw vectors, model weights, fitted factors, prompt text, and token IDs stay on the local host. + +## Data needed for future native validation + +A separately authorized CAL export sufficient to extend this analysis should be immutable, hash-addressed, and documented before any model run. Each record would bind checkpoint and backend build, physical parameter and quantization state, tokenizer revision and input token-list digest, root/world/split, semantic token position, pass, module path, tensor side, dtype, dimensions, physical coordinate-frame identifiers, and capture or patch hook version. Both worlds of one root must appear in the same split. A source whitelist must select CAL independently of any protected test file. A run receipt should account for every selected root and the wire-level tensor digest of every export. + +For native NF4 affine and future-reader closure, provision the effective per-occurrence layer-21 down-projection and layer-0 K operator with its quantization specification, stored packed weights, dequantization scales and metadata, operand, accumulation and output dtypes, and the actual kernel or a numerically qualified implementation. Include matching archived module inputs and outputs and original all-one full-head and boundary-state parity. This makes the handling of axes in the NF4 backend checkable and enables a measured error bound. The BF16 checkpoint projection can serve as a separate baseline for a question about precision differences. + +For native causal transport, capture recipients' pre-edit states and donors' aligned write contrasts. Lock the outcome direction and independent exposure plan before model execution. Verify exact unmasked full-head parity and the projection-specific all-one and zero-gate controls, measure the physical displacement and state radius at the actual site, and register equal-dose random, source-swap, and sign controls. Capture downstream Q/K/V and residuals as needed for the registered reader and record signed source-specific answer effects and correctness, including recovery and corruption. A delayed or joint rescue claim requires matched single- and joint-path interventions. Use a fresh authorized root population for causal inference and a separately calibrated matched-sham tolerance bound. The eight exposed roots supply compatibility and sizing information for that design. diff --git a/mechinterp/bpd/theory/rtbpd02/EXTENSION_PROTOCOL.md b/mechinterp/bpd/theory/rtbpd02/EXTENSION_PROTOCOL.md index 346e078e..d89679ff 100644 --- a/mechinterp/bpd/theory/rtbpd02/EXTENSION_PROTOCOL.md +++ b/mechinterp/bpd/theory/rtbpd02/EXTENSION_PROTOCOL.md @@ -20,7 +20,7 @@ The primary prediction is lower pass-2 future-reader error for reader weighting Read the existing audited COMP14 focused CAL last-token layer-21 MLP inputs, native write outputs and raw residuals in both worlds and passes. Verify the source/token/state hashes and the IO18 target, per-fit identities, and original exact all-one native qualification. Train each empirical basis without the scored root. Compare the shared SVD initializer and the T1 and T2 BPD/VPD factor banks at equal rank alongside ordinary SVD of the T2 sum, reached-moment reapproximation, paired-contrast weighting and matched random. Choose the archive T1/T2 and initializer atom subsets on the seven training roots by squared error to the T2 sum, with lexicographic ties. Use the same fold split for all methods. The archive endpoint measures compression of a frozen fitted physical operator. Verify the pinned BF16 full layer-21 affine map against the archived native module writes as a separate closure check. -Use a fixed BF16 future K reader only on pass 1. Compose the pinned layer-0 K matrix with the two continuous RMSNorm derivatives at the mean raw carrier of the training roots. Measure that linear readout locally; later attention, rounding of modified activations and answer effects remain outside this replay. A corresponding NF4 reader requires the exact quantized physical layer-0 projection and its arithmetic receipt. Report any missing state, layout, support or custody requirement explicitly. Publish only aggregate results and source provenance in BPD. +Use a fixed BF16 future K reader only on pass 1. Compose the pinned layer-0 K matrix with the two continuous RMSNorm derivatives at the mean raw carrier of the training roots. Measure that linear readout locally; later attention, rounding of modified activations and answer effects remain outside this replay. A corresponding NF4 reader requires the exact quantized physical layer-0 projection and its arithmetic receipt. The rank-2 BF16 pass-1 directional descriptor uses one-quarter of the reference donor-write norm and the fixed output map on that matched physical vector. Apply the same directional-score convention as in the synthetic gym. Use the seeded random output subspace as the matched sham in a separate eight-root descriptive EvalMath run with unsealed and independence gates disabled for confirmation. Report any missing state, layout, support or custody requirement explicitly. Publish only aggregate results and source provenance in BPD. ## Acceptance diff --git a/mechinterp/bpd/theory/rtbpd02/EXTENSION_REGISTRATION.json b/mechinterp/bpd/theory/rtbpd02/EXTENSION_REGISTRATION.json index 0b82687f..21904e26 100644 --- a/mechinterp/bpd/theory/rtbpd02/EXTENSION_REGISTRATION.json +++ b/mechinterp/bpd/theory/rtbpd02/EXTENSION_REGISTRATION.json @@ -157,7 +157,17 @@ "runs/nan_fit16_io18/audits/bf16.json": "539a74689a1942173fbad6ce55f53cac08133149167ba48f8a4af222e63ff93e", "runs/nan_fit16_io18/audits/nf4.json": "d9885205c28fe5fa1ecf6b727ef8ca8580f963ee0b8a909c7eeb4f0f92d17536" }, - "bf16_affine_coordinates": "float64 affine product, then float32-to-BF16 round-to-nearest ties-to-even. Report elemental equality and numerical residual, without extending the archived all-one parity label" + "bf16_affine_coordinates": "float64 affine product, then float32-to-BF16 round-to-nearest ties-to-even. Report elemental equality and numerical residual, without extending the archived all-one parity label", + "support_relative_cutoff": 1e-12, + "archive_random_seed": 37035, + "archive_direction_dose_fraction": 0.25, + "direction_zero_atol": 1e-11, + "archive_direction_planner": { + "scope": "BF16 pass 1, rank 2, exposed CAL only", + "paired": "half of fixed-reader cosine minus ordinary-SVD cosine", + "sham": "half of seeded random cosine minus ordinary-SVD cosine", + "independent_confirmation_units": false + } }, "evalmath": { "commit": "accf4d9040bee8daeabc6b07003bb484708996c0", diff --git a/mechinterp/bpd/theory/rtbpd02/archive_analysis.py b/mechinterp/bpd/theory/rtbpd02/archive_analysis.py new file mode 100644 index 00000000..00deb655 --- /dev/null +++ b/mechinterp/bpd/theory/rtbpd02/archive_analysis.py @@ -0,0 +1,254 @@ +"""Whole-root archive compression and transport analysis in small physical write bases.""" +from __future__ import annotations + +from itertools import combinations +from statistics import fmean + +import numpy as np + +from archive_inputs import Bank, require +from controls import best_atom_subset +from transport import Disagreement, direction, subspace_angles +from weighted_rank import optimal_sample_rank, truncated_svd + + +class CompactWrite: + """Orthogonal output coordinates for the fixed T2 target and reapproximations.""" + def __init__(self, bank): + self.output, u = np.linalg.qr(bank.u.T, mode="reduced") + self.operator = u @ bank.v.T + + def lift(self, operator): + u, s, vt = np.linalg.svd(operator, full_matrices=False) + rank = int(np.linalg.matrix_rank(operator)) + return Bank(vt[:rank].T * s[:rank], (self.output @ u[:, :rank]).T) + + +def contrast(rows): + return rows[:, 1] - rows[:, 0] + + +def train_candidates(target, banks, rows, rank, rng_basis, floor, fixed_reader=None): + width = rows.shape[-1] + x = rows.reshape(-1, width) + compact = target.operator + values = x @ compact.T @ target.output.T + reach = optimal_sample_rank(compact, x, rank, rtol=floor) + paired = optimal_sample_rank(compact, contrast(rows), rank, rtol=floor) + z = rng_basis[:, :rank] + policies = { + "svd": target.lift(truncated_svd(compact, rank)), + "reach": target.lift(reach.operator), + "contrast": target.lift(paired.operator), + "random": target.lift(z @ (z.T @ compact)), + } + for name, bank in banks.items(): + keep = best_atom_subset(bank.atoms(x), values, rank) + policies[name] = Bank(bank.v[:, keep], bank.u[list(keep)]) + if fixed_reader is not None: + fixed = optimal_sample_rank(compact, x, rank, fixed_reader, rtol=floor) + policies["reader"] = target.lift(fixed.operator) + for method, bank in policies.items(): + require( + bank.v.shape[1] == bank.u.shape[0] == rank + and np.linalg.matrix_rank(bank.v) == np.linalg.matrix_rank(bank.u) == rank, + f"CAL comparator {method} failed the common rank", + ) + return policies, { + "reached_rank": reach.input_support_rank, + "contrast_rank": paired.input_support_rank, + "reached_spectral_tail_error_abs": abs(reach.error - reach.tail_oracle), + "contrast_spectral_tail_error_abs": abs(paired.error - paired.tail_oracle), + } + + +def heldout_score(x, bank, target, reader, dose_fraction, zero_atol): + truth = target.apply(x) + prediction = bank.apply(x) + delta = truth[1] - truth[0] + estimate = prediction[1] - prediction[0] + dose = dose_fraction * np.linalg.norm(delta) + length = np.linalg.norm(estimate) + total = float(np.sum(truth ** 2) / len(x)) + errors = truth - prediction + result = { + "write_mse": float(np.sum(errors ** 2) / len(x)), + "truth_write_mse": total, + "contrast_write_sq_error": float(np.sum((delta - estimate) ** 2)), + } + if reader is None: + return result + measured = reader(np.column_stack((errors.T, truth.T, delta, estimate))) + err, ref = measured[:, :2], measured[:, 2:4] + normalized = measured[:, 5] * (dose / length) if length > zero_atol else np.zeros_like(measured[:, 5]) + result.update({ + "future_mse": float(np.sum(err ** 2) / len(x)), + "truth_future_mse": float(np.sum(ref ** 2) / len(x)), + "physical_status": "matched" if length > zero_atol and dose > zero_atol else "zero_write_or_reference", + "requested_dose": float(dose), + "constructed_physical_dose": float(np.linalg.norm(estimate * (dose / length))) if length > zero_atol else 0.0, + "future_direction": direction(normalized, dose_fraction * measured[:, 4], zero_atol=zero_atol), + }) + return result + + +def score_mean(rows): + result = {} + for field in ("write_mse", "truth_write_mse", "contrast_write_sq_error", "future_mse", "truth_future_mse"): + if field in rows[0]: + result[field] = fmean(r[field] for r in rows) + for field in ("write", "future"): + ref = result.get(f"truth_{field}_mse") + if ref: + result[f"{field}_relative_mse"] = result[f"{field}_mse"] / ref + if "future_direction" in rows[0]: + result["max_constructed_dose_error"] = max( + (abs(r["constructed_physical_dose"] - r["requested_dose"]) for r in rows if r["physical_status"] == "matched"), + default=None, + ) + result["unmatched_doses"] = sum(r["physical_status"] != "matched" for r in rows) + for name in ("cosine", "gain"): + values = [r["future_direction"][name] for r in rows if r["future_direction"][name] is not None] + result[f"mean_{name}_when_defined"] = fmean(values) if values else None + result[f"n_{name}_defined"] = len(values) + result["negative_gain_roots"] = sum((r["future_direction"]["gain"] or 0) < 0 for r in rows) + return result + + +def split_root(occurrence, heldout): + train = np.arange(len(occurrence.x)) != heldout + return occurrence.x[train], occurrence.carrier[train].mean(axis=(0, 1), dtype=np.float64) + + +def calibrate(occurrence, banks, target, k_reader, ranks, spec, check): + rank_k = len(target.operator) + rng = np.random.default_rng(spec["archive_random_seed"]) + random = np.linalg.qr(rng.normal(size=(rank_k, max(ranks))), mode="reduced")[0] + root_results = {rank: [] for rank in ranks} + fit_diagnostics = {rank: [] for rank in ranks} + output_bases = {rank: [] for rank in ranks} + for heldout in range(len(occurrence.x)): + train, mean_carrier = split_root(occurrence, heldout) + + def measure(writes): + return k_reader(mean_carrier, writes) + + compressed_reader = None if k_reader is None else measure(target.output) + for rank in ranks: + check() + policies, info = train_candidates( + target, banks, train, rank, random, spec["support_relative_cutoff"], compressed_reader, + ) + scored = {name: heldout_score( + occurrence.x[heldout], bank, banks["t2"], measure if k_reader is not None else None, + spec["archive_direction_dose_fraction"], spec["direction_zero_atol"], + ) for name, bank in policies.items()} + root_results[rank].append(scored) + fit_diagnostics[rank].append(info) + output_bases[rank].append({name: bank.u.T for name, bank in policies.items()}) + summaries = {} + for rank in ranks: + rows = root_results[rank] + result = {} + for method in rows[0]: + result[method] = score_mean([r[method] for r in rows]) + result[method]["max_pairwise_output_subspace_angle_deg"] = float(max( + np.degrees(subspace_angles(a[method], b[method]).max()) + for a, b in combinations(output_bases[rank], 2) + )) + result[method]["roots_beating_svd_write_error"] = sum( + r[method]["write_mse"] < r["svd"]["write_mse"] for r in rows + ) + if k_reader is not None: + result[method]["roots_beating_svd_future_error"] = sum( + r[method]["future_mse"] < r["svd"]["future_mse"] for r in rows + ) + info = fit_diagnostics[rank] + summaries[str(rank)] = { + "roots": len(rows), + "methods": result, + "training_reached_support_ranks": sorted({r["reached_rank"] for r in info}), + "training_contrast_support_ranks": sorted({r["contrast_rank"] for r in info}), + "max_reached_spectral_tail_error_abs": max(r["reached_spectral_tail_error_abs"] for r in info), + "max_contrast_spectral_tail_error_abs": max(r["contrast_spectral_tail_error_abs"] for r in info), + } + return summaries, root_results + + +def compact_closure(states, reference, compact): + report = {} + for p, occurrence in states.items(): + direct = reference.apply(occurrence.x) + reduced = (occurrence.x @ compact.operator.T) @ compact.output.T + atoms = reference.atoms(occurrence.x).sum(axis=-2) + delta = np.linalg.norm(reduced - direct) / np.linalg.norm(direct) + atom_delta = np.linalg.norm(atoms - direct) / np.linalg.norm(direct) + require(max(delta, atom_delta) < 1e-11, "T2 physical factor sum did not close") + report[str(p)] = { + "reference_factor_sum_relative_l2": float(atom_delta), + "compact_recomposition_relative_l2": float(delta), + "target_over_archived_native_write_energy": float( + np.sum(direct ** 2) / np.sum(occurrence.native.astype(np.float64) ** 2) + ), + } + return report + + +def outside_support(source, target, cutoff): + x, y = source.reshape(-1, source.shape[-1]), target.reshape(-1, target.shape[-1]) + _, singular, vt = np.linalg.svd(x, full_matrices=False) + support = vt[singular > np.sqrt(cutoff) * singular[0]] + missed = y - (y @ support.T) @ support + return float(np.sum(missed ** 2) / np.sum(y ** 2)) + + +def transfer(a, b, xa, xb, cutoff): + aa, ab = a.apply(xa), a.apply(xb) + ba, bb = b.apply(xa), b.apply(xb) + op = ((ba + bb) - (aa + ab)) / 2 + state = ((bb + ab) - (ba + aa)) / 2 + residual = op + state - (bb - aa) + close = np.linalg.norm(residual) / max(np.linalg.norm(bb - aa), np.linalg.norm(bb), 1.) + require(close < 1e-11, "symmetric operator/state decomposition failed closure") + energies = [Disagreement(o, d, np.zeros_like(o)).energies() for o, d in zip(op, state, strict=True)] + return { + "mean_root_energy": {k: fmean(r[k] for r in energies) for k in energies[0] if "reader" not in k}, + "total_below_sum_due_to_cancellation": sum(r["operator_state_cross"] < 0 for r in energies), + "input_energy_b_outside_a_empirical_contrast_support": outside_support(xa, xb, cutoff), + "input_energy_a_outside_b_empirical_contrast_support": outside_support(xb, xa, cutoff), + "identity_relative_l2": float(close), + } + + +def archive_evalmath(archive_roots, planner): + def score(record): + outcome = record["future_direction"] + if outcome["status"] == "zero_reference": + raise ValueError("matched-dose archive directional reference is unavailable") + return 0.0 if outcome["status"] == "zero_observed" else outcome["cosine"] + + rows = [] + for i, row in enumerate(archive_roots): + svd = score(row["svd"]) + rows.append({ + "unit_id": f"cal-{i:03d}", + "paired_effect": f"{(score(row['reader']) - svd) / 2:.12f}", + "sham_effects": [f"{(score(row['random']) - svd) / 2:.12f}"], + }) + return { + "schema_version": 1, + "experiment_id": "RT-BPD-02 archive BF16 pass-1 rank-2 matched-direction descriptor", + "independent_unit": "selection-exposed CAL root, complete A/B pair", + "alpha": planner["alpha"], + "scientific_min_effect": planner["scientific_min_effect"], + "target_effect": planner["target_effect"], + "measurement_resolution": planner["measurement_resolution"], + "sham_quantile": planner["quantile"], + "sham_confidence": planner["confidence"], + "planned_comparisons": planner["planned_comparisons"], + "confirm_units_planned": planner["nominal_planning_roots"], + "pilot_from_development_only": True, + "heldout_sealed": False, + "units_independent": False, # Reused CAL and heavily overlapping training folds. + "pilot": rows, + } diff --git a/mechinterp/bpd/theory/rtbpd02/archive_checkpoint.py b/mechinterp/bpd/theory/rtbpd02/archive_checkpoint.py new file mode 100644 index 00000000..fa576154 --- /dev/null +++ b/mechinterp/bpd/theory/rtbpd02/archive_checkpoint.py @@ -0,0 +1,178 @@ +"""Pinned BF16 safetensors affine replay and fixed next-pass K tangent.""" +from __future__ import annotations + +from hashlib import sha256 +import json +import os +from pathlib import Path + +import numpy as np + +from archive_inputs import bound, bound_json, require + + +INDEX = "model.safetensors.index.json" +CONFIG = "config.json" +GAMMA = "model.norm.weight" +ETA = "model.layers.0.input_layernorm.weight" +QUERY_K = "model.layers.0.self_attn.k_proj.weight" +DOWN = "model.layers.21.mlp.down_proj.weight" +SHARDS = ("model-00001-of-00002.safetensors", "model-00002-of-00002.safetensors") + + +def decode_bf16(data): + return (np.frombuffer(data, dtype="> 16) & 1)) & 0xFFFF0000).view(np.float32) + + +class Shard: + """Access only declared BF16 tensors through a verified read-only handle.""" + + def __init__(self, stream, expected, check): + stat = os.fstat(stream.fileno()) + digest = sha256() + for block in iter(lambda: stream.read(4 * 1024 * 1024), b""): + digest.update(block) + check() + require(digest.hexdigest() == expected, "checkpoint shard hash mismatch") + self.stream = stream + self.stat = stat + stream.seek(0) + header_len = int.from_bytes(stream.read(8), "little") + require(0 < header_len < 10 * 1024 * 1024, "safetensors header exceeds the replay bound") + self.header = json.loads(stream.read(header_len)) + self.offset = 8 + header_len + self.verify_unchanged() + + def verify_unchanged(self): + stat = os.fstat(self.stream.fileno()) + require((stat.st_size, stat.st_mtime_ns) == (self.stat.st_size, self.stat.st_mtime_ns), + "checkpoint shard changed during replay") + + def row_shape(self, name, shape): + entry = self.header[name] + start, end = entry["data_offsets"] + require( + entry["dtype"] == "BF16" and tuple(entry["shape"]) == shape + and type(start) is int and type(end) is int + and 0 <= start < end <= self.stat.st_size - self.offset + and end - start == 2 * int(np.prod(shape)), + "tensor dtype, shape or byte range disagrees with the pinned layout", + ) + return start, end + + def tensor(self, name, shape, row_range=None): + start, end = self.row_shape(name, shape) + if row_range is None: + out_shape = shape + else: + lo, hi = row_range + require(len(shape) == 2 and 0 <= lo < hi <= shape[0], "invalid safetensors row range") + stride = 2 * shape[1] + end = start + hi * stride + start += lo * stride + out_shape = (hi - lo, shape[1]) + self.stream.seek(self.offset + start) + payload = self.stream.read(end - start) + require(len(payload) == end - start, "incomplete safetensors tensor payload") + values = decode_bf16(payload).reshape(out_shape) + require(np.isfinite(values).all(), "nonfinite values in pinned tensor") + return values + + +def double_rms_jvp(carrier, writes, gamma, eta, eps): + """Continuous derivative of RMSNorm_eta(RMSNorm_gamma(carrier)).""" + x = np.asarray(carrier, dtype=np.float64) + g = np.asarray(gamma, dtype=np.float64) + h = np.asarray(eta, dtype=np.float64) + metric = np.square(g) + eps + scale = 1 / np.sqrt(np.mean(np.square(x) * metric) + eps ** 2) + coupling = (x * metric) @ writes / x.size + return (g * h)[:, None] * (scale * writes - scale ** 3 * x[:, None] * coupling) + + +def replay_affine(shard, occurrences, inp, out, check): + rows = np.concatenate([occurrence.x.reshape(-1, inp) for occurrence in occurrences.values()]).astype(np.float64) + archived = np.concatenate([occurrence.native.reshape(-1, out) for occurrence in occurrences.values()]) + replay = np.empty(archived.shape, dtype=np.float32) + for lo in range(0, out, 192): + check() + hi = min(lo + 192, out) + w = shard.tensor(DOWN, (out, inp), (lo, hi)).astype(np.float64) + replay[:, lo:hi] = round_bf16(rows @ w.T) + residual = replay.astype(np.float64) - archived + equal = replay.view(np.uint32) == archived.view(np.uint32) + denom = float(np.linalg.norm(archived.astype(np.float64))) + per_pass = {} + start = 0 + for phase, occurrence in occurrences.items(): + count = occurrence.x.shape[0] * occurrence.x.shape[1] + stop = start + count + mask = equal[start:stop] + delta = residual[start:stop] + per_pass[str(phase)] = { + "case_writes": count, + "bit_exact_case_writes": int(mask.all(axis=1).sum()), + "bit_exact_elements": int(mask.sum()), + "elements": mask.size, + "max_absolute_error": float(np.max(np.abs(delta))), + "relative_l2": float(np.linalg.norm(delta) / np.linalg.norm(archived[start:stop].astype(np.float64))), + } + start = stop + input_bits = rows.astype(np.float32).view(np.uint32) + output_bits = archived.view(np.uint32) + return { + "method": "float64 affine contraction followed by float32 and BF16 round-to-nearest-even", + "case_writes": len(archived), + "bit_exact_case_writes": int(equal.all(axis=1).sum()), + "bit_exact_elements": int(equal.sum()), + "elements": equal.size, + "max_absolute_error": float(np.max(np.abs(residual))), + "relative_l2": float(np.linalg.norm(residual) / denom) if denom else None, + "all_archived_input_values_bf16_representable": bool(np.all((input_bits & 0xFFFF) == 0)), + "all_archived_output_values_bf16_representable": bool(np.all((output_bits & 0xFFFF) == 0)), + "passes": per_pass, + } + + +class FixedK: + def __init__(self, gamma, eta, eps, k): + self.gamma, self.eta, self.eps, self.k = gamma, eta, eps, k + + def __call__(self, carrier, writes): + return self.k @ double_rms_jvp(carrier, writes, self.gamma, self.eta, self.eps) + + +def checkpoint_replay(snapshot: Path, revision, pinned, tokenizer_config_sha256, occurrences, check): + require(snapshot.name == revision == pinned["revision"], "checkpoint revision mismatch") + locks = pinned["locked_files_sha256"] + bound(snapshot / "tokenizer_config.json", tokenizer_config_sha256) + config = bound_json(snapshot / CONFIG, locks[CONFIG]) + index = bound_json(snapshot / INDEX, locks[INDEX])["weight_map"] + inp, out = config["intermediate_size"], config["hidden_size"] + head_size = config.get("head_dim", out // config["num_attention_heads"]) + k_rows = head_size * config["num_key_value_heads"] + require( + config["num_hidden_layers"] == 22 and inp == 10752 and out == 3072 and k_rows == 1024 + and set(index[name] for name in (GAMMA, ETA, QUERY_K, DOWN)) == set(SHARDS) + and DOWN.removesuffix(".weight") + ".bias" not in index, + "checkpoint layout does not match the registered affine sites", + ) + with (snapshot / SHARDS[0]).open("rb") as f0, (snapshot / SHARDS[1]).open("rb") as f1: + shards = {name: Shard(stream, locks[name], check) for name, stream in zip(SHARDS, (f0, f1), strict=True)} + gamma = shards[index[GAMMA]].tensor(GAMMA, (out,)).astype(np.float64) + eta = shards[index[ETA]].tensor(ETA, (out,)).astype(np.float64) + k = shards[index[QUERY_K]].tensor(QUERY_K, (k_rows, out)).astype(np.float64) + affine = replay_affine(shards[index[DOWN]], occurrences, inp, out, check) + for shard in shards.values(): + shard.verify_unchanged() + return affine, FixedK(gamma, eta, config["rms_norm_eps"], k), { + "checkpoint_revision": revision, + "checkpoint_file_sha256": {name: locks[name] for name in (CONFIG, INDEX, *SHARDS)}, + "tokenizer_config_sha256": tokenizer_config_sha256, + } diff --git a/mechinterp/bpd/theory/rtbpd02/archive_inputs.py b/mechinterp/bpd/theory/rtbpd02/archive_inputs.py new file mode 100644 index 00000000..ef9c446b --- /dev/null +++ b/mechinterp/bpd/theory/rtbpd02/archive_inputs.py @@ -0,0 +1,260 @@ +"""Hash-gated access to the registered COMP14 CAL vectors and IO18 factor banks.""" +from __future__ import annotations + +from dataclasses import dataclass +from hashlib import sha256 +from io import BytesIO +import json +from pathlib import Path + +import numpy as np + + +COMP = "experiments/nan_comp14" +FITS = "experiments/nan_fit16_io18" +RUN_COMP = "runs/nan_comp14" +RUN_FITS = "runs/nan_fit16_io18" +IDENTITY = ("id", "root", "split", "arm", "world") +WORLDS = ("A", "B") +SITES = ("down_proj_input", "down_proj_output", "residual_after_layer") + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def bound(path: Path, expected: str) -> bytes: + data = path.read_bytes() + require(sha256(data).hexdigest() == expected, f"archive hash mismatch for {path.name}") + return data + + +def bound_json(path: Path, expected: str): + return json.loads(bound(path, expected)) + + +def select_cal(payload: bytes, spec: dict): + entries = [ + (i, row) for i, line in enumerate(payload.splitlines()) + if ((row := json.loads(line))["split"], row["arm"]) == (spec["fit_split"], spec["arm"]) + ] + pairs = {(row["root"], row["world"]) for _, row in entries} + roots = tuple(sorted({root for root, _ in pairs})) + require( + len(roots) == spec["expected_roots"] and len(entries) == 2 * len(roots) + and pairs == {(root, w) for root in roots for w in WORLDS} + and len({row["id"] for _, row in entries}) == len(entries), + "registered CAL roots must have exactly one member per world", + ) + return entries, roots + + +def verify_case(case, audit, public, tokens, case_stem, passes): + require(all(case[k] == public[k] == audit[k] for k in IDENTITY), "case identity mismatch") + ids = case["initial_prompt_ids"] + digest = sha256(json.dumps(ids).encode()).hexdigest() + require( + case["status"] == "completed" and case["state_file"] == case_stem + "_states.npz" + and case["state_file_sha256"] == audit["state_sha256"] + and all(type(x) is int and x >= 0 for x in ids) and len(ids) == tokens["tokens"] > 0 + and digest == case["initial_prompt_ids_sha256"] == tokens["ids_sha256"] + and case["steps"][0]["step"] == 0 and case["steps"][0]["history_tokens"] == len(ids) + and [p["loop"] for p in case["initial_phases"]] == passes, + "case token, pass or state custody mismatch", + ) + + +def state_arrays(case, content, layer, passes, input_width, output_width): + rows = case["state_index"] + keys = [r["array_key"] for r in rows] + matches = [ + ((r["loop"], r["site"]), r["array_key"]) for r in rows + if r["layer_zero_based"] == layer and r["site"] in SITES and r["loop"] in passes + ] + index = dict(matches) + require(len(matches) == len(index) == len(passes) * len(SITES), "missing or duplicate physical site") + require(set(index) == {(p, site) for p in passes for site in SITES}, "wrong archived sites") + vectors = {} + with np.load(BytesIO(content), allow_pickle=False) as arrays: + require(len(keys) == len(set(keys)) == len(arrays.files) and set(keys) == set(arrays.files), + "state payload layout disagrees with its case index") + for p in passes: + parts = [] + for site, width in zip(SITES, (input_width, output_width, output_width), strict=True): + vector = arrays[index[p, site]] + require(vector.shape == (width,) and vector.dtype == np.float32 and np.isfinite(vector).all(), + "physical vector has an unexpected shape, dtype or nonfinite value") + parts.append(vector) + vectors[p] = tuple(parts) + return vectors + + +@dataclass(frozen=True) +class Occurrence: + x: np.ndarray + native: np.ndarray + carrier: np.ndarray + + +@dataclass(frozen=True) +class Bank: + v: np.ndarray + u: np.ndarray + + def apply(self, rows): + return (rows @ self.v) @ self.u + + def atoms(self, rows): + return (rows @ self.v)[..., None] * self.u + + +def read_factors(path, digest, keys, dimensions): + with np.load(BytesIO(bound(path, digest)), allow_pickle=False) as archive: + v, u = (np.asarray(archive[name], dtype=np.float64) for name in keys) + require( + (v.shape, u.shape) == dimensions and np.isfinite(v).all() and np.isfinite(u).all() + and np.linalg.matrix_rank(v) == np.linalg.matrix_rank(u) == dimensions[0][1], + "physical factor bank shape, rank or finite numerics changed", + ) + return Bank(v, u) + + +def read_captures(repo, backend, data, base, roster, roots, spec, check): + pins = spec["source_file_sha256"] + source_sha = pins[f"{COMP}/SOURCE_MANIFEST.json"] + cfg = base["backends"][backend] + archive = repo / RUN_COMP / backend + audit = data[f"{RUN_COMP}/audits/{backend}.json"] + require(pins[f"{RUN_COMP}/audits/{backend}.json"] == cfg["audit"], "inconsistent independent COMP14 audit pin") + manifest = bound_json(archive / "manifest.json", cfg["manifest"]) + require( + audit["status"] == "passed" and audit["worker_status"] == "completed" + and audit["source_manifest_sha256"] == manifest["source_manifest_sha256"] == source_sha + and audit["backend"] == manifest["backend"] == backend + and not audit["sealed_test_accessed"] and not manifest["sealed_test_accessed"] + and audit["missing_contexts"] == 0 + and audit["contexts_checked"] == audit["registered_contexts"] == len(audit["records"]) == 240 + and audit["physical_vectors_checked"] == 40 * 240 + and manifest["checkpoint_revision"] == base["revision"] + and manifest["target_parameter_sha256"] == cfg["target"], + "original COMP14 closure or native identity does not match the registration", + ) + token_receipt = data[f"{COMP}/fixtures/tokenizer_receipt.json"] + require(not token_receipt["sealed_test_accessed"], "token receipt scope changed") + cases = {} + custody = [] + for slot, public in roster: + check() + receipt = audit["records"][slot] + stem = f"case_{slot:04d}" + case = bound_json(archive / (stem + ".json"), receipt["case_sha256"]) + verify_case(case, receipt, public, token_receipt["contexts"][public["id"]], stem, spec["passes"]) + payload = bound(archive / (stem + "_states.npz"), receipt["state_sha256"]) + cases[public["root"], public["world"]] = state_arrays( + case, payload, spec["layer_zero_based"], spec["passes"], base["input_width"], base["width"], + ) + custody.append((receipt["case_sha256"], receipt["state_sha256"], case["initial_prompt_ids_sha256"])) + result = {} + for p in spec["passes"]: + result[p] = Occurrence(*[ + np.stack([np.stack([cases[root, world][p][i] for world in WORLDS]) for root in roots]) + for i in range(len(SITES)) + ]) + return result, sha256(json.dumps(custody, separators=(",", ":")).encode()).hexdigest() + + +def read_banks(repo, backend, data, base, spec): + pins = spec["source_file_sha256"] + source_sha = pins[f"{FITS}/SOURCE_MANIFEST.json"] + source = data[f"{FITS}/SOURCE_MANIFEST.json"] + old = data["reports/nanbeige_bpd_gym/nan_fit16_io18_progress.json"] + init_pin = source["initialization"][backend] + cfg = base["backends"][backend] + old_backend = old["backends"][backend] + audit_path = f"{RUN_FITS}/audits/{backend}.json" + audit = data[audit_path] + dimensions = ((base["input_width"], base["rank"]), (base["rank"], base["width"])) + require( + old["source_manifest_sha256"] == audit["source_manifest_sha256"] == source_sha + and old_backend["status"] == "completed_audited" and audit["status"] == "passed" + and audit["backend"] == backend and audit["worker_status"] == "completed" and not audit["sealed_test_accessed"] + and old_backend["receipt_sha256"] == audit["receipt_sha256"] + and old_backend["audit_sha256"] == pins[audit_path] + and sorted(c["passes"] for c in audit["cells"]) == spec["passes"], + "IO18 fit group has no matching independent audit", + ) + initial = read_factors( + repo / f"runs/nan_gym05/{backend}/linear_baselines/layer21_down_proj.npz", + init_pin["file_sha256"], ("V8", "U8"), dimensions, + ) + banks, receipts = {"initializer": initial}, {"initializer_sha256": init_pin["file_sha256"]} + for cell in audit["cells"]: + phase = cell["passes"] + folder = repo / RUN_FITS / backend / f"t{phase}_layer21_down_proj_rank8" + receipt = bound_json(folder / "receipt.json", cell["receipt_sha256"]) + require( + cell["status"] == "passed" and receipt["status"] == "completed" + and receipt["backend"] == backend and receipt["passes"] == phase + and receipt["layer_zero_based"] == spec["layer_zero_based"] and receipt["module"] == "down_proj" + and receipt["rank"] == base["rank"] and not receipt["sealed_test_accessed"] + and receipt["source_manifest_sha256"] == source_sha + and receipt["target_parameter_sha256_unchanged"] == cfg["target"] + and receipt["initial_svd_file_sha256"] == init_pin["file_sha256"] + and receipt["effective_operator_sha256"] == init_pin["effective_operator_sha256"] + and receipt["native_all_one_full_head_bit_exact"] is True + and receipt["native_all_one_boundary_states_bit_exact"] is True + and receipt["optimizer_steps_completed"] == 16, + "IO18 receipt changed native target, same-initialization, or exact parity qualification", + ) + bank_pair = [] + for stage, steps, filename in (("initial_checkpoint", 0, "initial.npz"), ("final_checkpoint", 16, "final.npz")): + checkpoint = receipt[stage] + require(checkpoint["optimizer_steps_completed"] == steps and checkpoint["file"] == filename, + "IO18 checkpoint path or optimizer step changed") + if steps: + require(checkpoint["sha256"] == cell["checkpoint_sha256"], "independent fit payload audit mismatch") + bank_pair.append(read_factors(folder / filename, checkpoint["sha256"], ("V", "U"), dimensions)) + require(np.array_equal(initial.v, bank_pair[0].v) and np.array_equal(initial.u, bank_pair[0].u), + "IO18 did not start from the frozen SVD initializer") + name = f"t{phase}" + if phase == 2: + require(cell["receipt_sha256"] == cfg["factor_receipt"] and cell["checkpoint_sha256"] == cfg["factor_bank"], + "T2 target differs from the previously pinned physical bank") + banks[name] = bank_pair[1] + receipts[name] = { + "receipt_sha256": cell["receipt_sha256"], + "factor_sha256": cell["checkpoint_sha256"], + "original_native_all_one_full_head_bit_exact": True, + "original_native_all_one_boundary_states_bit_exact": True, + "original_backend_effective_recomposition_relative_l2": receipt["final_effective_operator_closure"]["relative_l2"], + } + return banks, receipts + + +def load_inputs(repo, spec, check): + files = spec["source_file_sha256"] + roster_path = f"{COMP}/fixtures/public.jsonl" + roster, roots = select_cal(bound(repo / roster_path, files[roster_path]), spec) + data = {path: bound_json(repo / path, digest) for path, digest in files.items() if path != roster_path} + base = data["experiments/nan_readpath37/registration.json"] + require( + base["revision"] == spec["snapshot_revision"] == data[f"{COMP}/SOURCE_MANIFEST.json"]["checkpoint_revision"] + and base["width"] == 3072 and base["input_width"] == 10752 and base["rank"] == 8, + "parent dimensions or checkpoint revision changed", + ) + states, banks, custody = {}, {}, {} + for backend in spec["backends"]: + states[backend], root_hash = read_captures(repo, backend, data, base, roster, roots, spec, check) + banks[backend], qualified = read_banks(repo, backend, data, base, spec) + custody[backend] = { + "ordered_case_state_token_custody_sha256": root_hash, + "native_manifest_sha256": base["backends"][backend]["manifest"], + "native_target_parameter_sha256": base["backends"][backend]["target"], + "fit_qualification": qualified, + "cases_verified": 2 * len(roots), + "vectors_verified": 2 * len(roots) * len(spec["passes"]) * len(SITES), + } + return states, banks, custody, data["experiments/nan_bpd01/receipts/checkpoint_verification.json"], ( + data[f"{COMP}/fixtures/tokenizer_receipt.json"]["tokenizer_config_sha256"] + ) diff --git a/mechinterp/bpd/theory/rtbpd02/archive_lease.py b/mechinterp/bpd/theory/rtbpd02/archive_lease.py new file mode 100644 index 00000000..55e05580 --- /dev/null +++ b/mechinterp/bpd/theory/rtbpd02/archive_lease.py @@ -0,0 +1,100 @@ +"""Bounded local CPU lease for the optional archive replay.""" +from contextlib import contextmanager +import ctypes as ct +import os +from pathlib import Path +import sys +import threading +import time + + +class MemoryStatus(ct.Structure): + _fields_ = [(name, ct.c_uint32) for name in ("length", "load")] + [ + (name, ct.c_uint64) for name in ( + "total_phys", "available_phys", "total_page", "available_page", + "total_virtual", "available_virtual", "available_extended_virtual", + ) + ] + + +class ProcessMemory(ct.Structure): + _fields_ = [(name, ct.c_uint32) for name in ("length", "page_faults")] + [ + (name, ct.c_size_t) for name in ( + "peak_working_set", "working_set", "peak_paged_pool", "paged_pool", + "peak_nonpaged_pool", "nonpaged_pool", "pagefile", "peak_pagefile", "private", + ) + ] + + +def memory(): + if os.name == "nt": + kernel = ct.WinDLL("kernel32", use_last_error=True) + kernel.GetCurrentProcess.restype = ct.c_void_p + kernel.GlobalMemoryStatusEx.argtypes = (ct.POINTER(MemoryStatus),) + kernel.K32GetProcessMemoryInfo.argtypes = (ct.c_void_p, ct.POINTER(ProcessMemory), ct.c_uint32) + system, process = MemoryStatus(), ProcessMemory() + system.length, process.length = ct.sizeof(system), ct.sizeof(process) + if not kernel.GlobalMemoryStatusEx(ct.byref(system)): + raise ct.WinError(ct.get_last_error()) + if not kernel.K32GetProcessMemoryInfo(kernel.GetCurrentProcess(), ct.byref(process), process.length): + raise ct.WinError(ct.get_last_error()) + return int(system.available_phys), int(process.private) + if sys.platform == "linux": + def kib(path, names): + rows = (line.split() for line in Path(path).read_text().splitlines()) + return 1024 * sum(int(fields[1]) for fields in rows if fields and fields[0] in names) + return ( + kib("/proc/meminfo", {"MemAvailable:"}), + kib("/proc/self/smaps_rollup", {"Private_Clean:", "Private_Dirty:", "Private_Hugetlb:"}), + ) + raise RuntimeError("archive resource admission requires Windows or Linux process memory counters") + + +def lower_priority(): + if os.name == "nt": + kernel = ct.WinDLL("kernel32", use_last_error=True) + kernel.GetCurrentProcess.restype = ct.c_void_p + kernel.SetPriorityClass.argtypes = (ct.c_void_p, ct.c_uint32) + if not kernel.SetPriorityClass(kernel.GetCurrentProcess(), 0x4000): + raise ct.WinError(ct.get_last_error()) + else: + os.nice(5) + + +@contextmanager +def lease(spec): + for name in ("OPENBLAS_NUM_THREADS", "OMP_NUM_THREADS", "MKL_NUM_THREADS", "BLIS_NUM_THREADS"): + os.environ[name] = "1" + available, _ = memory() + if available < spec["minimum_start_available_bytes"]: + raise RuntimeError(f"archive start requires 5 GiB available, observed {available / 2**30:.2f} GiB") + lower_priority() + started = time.monotonic() + stop = threading.Event() + samples = [] + + def check(): + available, private = memory() + elapsed = time.monotonic() - started + samples.append((available, private, elapsed)) + if (available < spec["minimum_reserve_bytes"] + or private > spec["max_private_bytes"] + or elapsed > spec["max_seconds"]): + raise RuntimeError("archive lease limit exceeded") + + def monitor(): + while not stop.wait(2.0): + try: + check() + except Exception as error: + print(error, file=sys.stderr, flush=True) + os._exit(3) # Bound even an in-flight BLAS or archive read. + watcher = threading.Thread(target=monitor, daemon=True) + watcher.start() + try: + check() + yield check, samples + check() + finally: + stop.set() + watcher.join() diff --git a/mechinterp/bpd/theory/rtbpd02/replay_archive.py b/mechinterp/bpd/theory/rtbpd02/replay_archive.py new file mode 100644 index 00000000..36a02c6e --- /dev/null +++ b/mechinterp/bpd/theory/rtbpd02/replay_archive.py @@ -0,0 +1,117 @@ +"""Read-only NumPy replay of the registration's local Nanbeige CAL archive.""" +from __future__ import annotations + +import argparse +from hashlib import sha256 +import json +from pathlib import Path + +from archive_lease import lease + + +HERE = Path(__file__).resolve().parent + + +def replay(repo, snapshot, registration, check): + import numpy as np + + from archive_analysis import CompactWrite, archive_evalmath, calibrate, compact_closure, contrast, transfer + from archive_checkpoint import checkpoint_replay + from archive_inputs import load_inputs + + spec = registration["archive"] + states, banks, custody, checkpoint, tokenizer_sha = load_inputs(repo, spec, check) + affine, fixed_k, weights = checkpoint_replay( + snapshot, spec["snapshot_revision"], checkpoint, tokenizer_sha, states["bf16"], check, + ) + comparison, closures = {}, {} + recipes = spec["passes"] + for backend in spec["backends"]: + comparison[backend] = {} + target = CompactWrite(banks[backend]["t2"]) + closures[backend] = compact_closure(states[backend], banks[backend]["t2"], target) + for p in recipes: + is_fixed = (backend, p) == ("bf16", 1) + result, roots = calibrate( + states[backend][p], banks[backend], target, fixed_k if is_fixed else None, spec["ranks"], spec, check, + ) + comparison[backend][str(p)] = result + if is_fixed: + planning = archive_evalmath(roots[2], registration["evalmath"]) + transfers = {} + rtol = spec["support_relative_cutoff"] + for p in recipes: + transfers[f"pass_{p}_bf16_to_nf4_t2"] = transfer( + banks["bf16"]["t2"], banks["nf4"]["t2"], + contrast(states["bf16"][p].x), contrast(states["nf4"][p].x), rtol, + ) + for backend in spec["backends"]: + t1, t2 = banks[backend]["t1"], banks[backend]["t2"] + a, b = [contrast(states[backend][p].x) for p in recipes] + transfers[f"{backend}_pass_1_to_2_tied_t2"] = transfer(t2, t2, a, b, rtol) + transfers[f"{backend}_pass_1_to_2_t1_then_t2"] = transfer(t1, t2, a, b, rtol) + return { + "schema": "rtbpd02-nanbeige-cal-archive/v1", + "status": "completed_exposed_CAL_affine_and_fixed_reader_replay", + "numpy_version": np.__version__, + "root_count": spec["expected_roots"], + "split": spec["fit_split"], + "arm": spec["arm"], + "denominators": "one complete A/B root per fold; no additional native trials", + "pretrained_decoder_forwards": 0, + "gpu_jobs": 0, + "protected_ARG03_access": False, + "archive_custody": custody, + "checkpoint_custody": weights, + "bf16_native_affine": affine, + "fixed_readers": {"bf16/pass1": spec["fixed_reader"], "nf4": "exact native K projection and arithmetic receipt unavailable"}, + "t2_target_closure": closures, + "leave_one_root_out": comparison, + "paired_operator_state_transport": transfers, + }, planning + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--archive", type=Path, required=True, help="LoopedTransformers local archive root") + parser.add_argument("--snapshot", type=Path, required=True, help="Pinned existing checkpoint snapshot") + parser.add_argument("--out", type=Path, required=True, help="New output directory outside the two input trees") + args = parser.parse_args() + repo, snapshot, output = args.archive.resolve(), args.snapshot.resolve(), args.out.resolve() + if output.exists() or output.is_relative_to(repo) or output.is_relative_to(snapshot): + parser.error("use a new output directory outside the immutable archive and checkpoint") + registration = (HERE / "EXTENSION_REGISTRATION.json").read_bytes() + cfg = json.loads(registration) + with lease(cfg["archive"]) as (check, samples): + receipt, planner = replay(repo, snapshot, cfg, check) + check() + receipt["registration_sha256"] = sha256(registration).hexdigest() + receipt["replay_source_sha256"] = { + name: sha256((HERE / name).read_bytes()).hexdigest() for name in ( + "replay_archive.py", "archive_lease.py", "archive_inputs.py", "archive_checkpoint.py", "archive_analysis.py", + "controls.py", "transport.py", "weighted_rank.py", + ) + } + receipt["resource_receipt"] = { + "single_thread": True, + "min_sampled_available_physical_bytes": min(a for a, _, _ in samples), + "max_sampled_process_private_bytes": max(p for _, p, _ in samples), + "elapsed_seconds": round(max(s for _, _, s in samples), 3), + "sample_count": len(samples), + } + output.mkdir(parents=True, exist_ok=False) + for name, content in (("archive_aggregate.json", receipt), ("archive_evalmath_input.json", planner)): + with (output / name).open("x", encoding="utf-8", newline="\n") as f: + json.dump(content, f, indent=2, sort_keys=True, allow_nan=False) + f.write("\n") + print(json.dumps({ + "status": receipt["status"], "roots": receipt["root_count"], + "affine_case_writes": receipt["bf16_native_affine"]["case_writes"], + "affine_bit_exact_case_writes": receipt["bf16_native_affine"]["bit_exact_case_writes"], + "peak_sampled_private_bytes": receipt["resource_receipt"]["max_sampled_process_private_bytes"], + "elapsed_seconds": receipt["resource_receipt"]["elapsed_seconds"], + }, sort_keys=True)) + + +if __name__ == "__main__": + main() diff --git a/mechinterp/bpd/theory/rtbpd02/test_archive_replay.py b/mechinterp/bpd/theory/rtbpd02/test_archive_replay.py new file mode 100644 index 00000000..0ab7ec04 --- /dev/null +++ b/mechinterp/bpd/theory/rtbpd02/test_archive_replay.py @@ -0,0 +1,115 @@ +"""Public microfixtures for the private archive replay contract.""" +from hashlib import sha256 +from io import BytesIO +import json +from pathlib import Path +import tempfile +import unittest + +import numpy as np + +from archive_analysis import CompactWrite, outside_support, split_root, train_candidates, transfer +from archive_checkpoint import Shard, double_rms_jvp, round_bf16 +from archive_inputs import Bank, Occurrence, select_cal, state_arrays, verify_case + + +class ArchiveReplayTests(unittest.TestCase): + def test_whole_root_selection_and_token_custody_fail_closed(self): + pairs = [ + {"id": f"root-{w}", "root": "root", "world": w, "split": "calibration", "arm": "focused"} + for w in ("A", "B") + ] + rows = [*pairs, dict(pairs[0], split="development", id="development-A")] + spec = {"expected_roots": 1, "fit_split": "calibration", "arm": "focused"} + payload = "\n".join(map(json.dumps, rows)).encode() + selected, roots = select_cal(payload, spec) + self.assertEqual(roots, ("root",)) + self.assertEqual(selected, list(enumerate(pairs))) + with self.assertRaisesRegex(ValueError, "exactly one"): + select_cal(payload + b"\n" + json.dumps(pairs[0]).encode(), spec) + + ids = [1, 72, 13] + digest = sha256(json.dumps(ids).encode()).hexdigest() + case = dict(pairs[0], status="completed", initial_prompt_ids=ids, initial_prompt_ids_sha256=digest, + state_file="case_0000_states.npz", state_file_sha256="state", initial_phases=[{"loop": 1}, {"loop": 2}], + steps=[{"step": 0, "history_tokens": 3}]) + audit = dict(pairs[0], state_sha256="state") + token = {"tokens": 3, "ids_sha256": digest} + verify_case(case, audit, pairs[0], token, "case_0000", [1, 2]) + with self.assertRaisesRegex(ValueError, "token"): + verify_case(case, audit, pairs[0], dict(token, ids_sha256="alien"), "case_0000", [1, 2]) + + def test_vector_index_joins_physical_site_and_phase(self): + indices, arrays = [], {} + for p in (1, 2): + for site, width in (("down_proj_output", 2), ("residual_after_layer", 2), ("down_proj_input", 3)): + key = f"v{len(indices)}" + indices.append(dict(loop=p, site=site, layer_zero_based=21, array_key=key)) + arrays[key] = np.full(width, len(indices), dtype=np.float32) + buf = BytesIO() + np.savez(buf, **arrays) + values = state_arrays({"state_index": indices}, buf.getvalue(), 21, [1, 2], 3, 2) + np.testing.assert_array_equal(values[1][0], [3., 3., 3.]) + np.testing.assert_array_equal(values[2][1], [4., 4.]) + broken_index = [*indices, dict(indices[-1], array_key="duplicate")] + with self.assertRaisesRegex(ValueError, "missing or duplicate"): + state_arrays({"state_index": broken_index}, buf.getvalue(), 21, [1, 2], 3, 2) + + def test_safetensors_row_stream_and_round_to_nearest_even(self): + header = json.dumps({"weight": {"dtype": "BF16", "shape": [2, 2], "data_offsets": [0, 8]}}).encode() + data = np.array([0x3F80, 0x4000, 0x4040, 0xC080], dtype=" Date: Mon, 23 Nov 2026 22:31:05 +0800 Subject: [PATCH 18/18] Report Nanbeige CAL replay and RT-BPD-02 development results --- .../NANBEIGE_CAL_ARCHIVE_AGGREGATE.json | 1353 +++++++++++++++++ .../NANBEIGE_CAL_EVALMATH_PREFLIGHT.json | 24 + .../NANBEIGE_RT_BPD_02_REPORT_20261123.md | 73 + mechinterp/bpd/theory/rtbpd02/README.md | 42 +- .../rtbpd02/SYNTHETIC_EVALMATH_INPUT.json | 466 ++++++ .../rtbpd02/SYNTHETIC_EVALMATH_PREFLIGHT.json | 24 + .../bpd/theory/rtbpd02/SYNTHETIC_SUMMARY.json | 573 +++++++ 7 files changed, 2522 insertions(+), 33 deletions(-) create mode 100644 mechinterp/bpd/theory/rtbpd02/NANBEIGE_CAL_ARCHIVE_AGGREGATE.json create mode 100644 mechinterp/bpd/theory/rtbpd02/NANBEIGE_CAL_EVALMATH_PREFLIGHT.json create mode 100644 mechinterp/bpd/theory/rtbpd02/NANBEIGE_RT_BPD_02_REPORT_20261123.md create mode 100644 mechinterp/bpd/theory/rtbpd02/SYNTHETIC_EVALMATH_INPUT.json create mode 100644 mechinterp/bpd/theory/rtbpd02/SYNTHETIC_EVALMATH_PREFLIGHT.json create mode 100644 mechinterp/bpd/theory/rtbpd02/SYNTHETIC_SUMMARY.json diff --git a/mechinterp/bpd/theory/rtbpd02/NANBEIGE_CAL_ARCHIVE_AGGREGATE.json b/mechinterp/bpd/theory/rtbpd02/NANBEIGE_CAL_ARCHIVE_AGGREGATE.json new file mode 100644 index 00000000..2f1ddac5 --- /dev/null +++ b/mechinterp/bpd/theory/rtbpd02/NANBEIGE_CAL_ARCHIVE_AGGREGATE.json @@ -0,0 +1,1353 @@ +{ + "archive_custody": { + "bf16": { + "cases_verified": 16, + "fit_qualification": { + "initializer_sha256": "0e372bf19ddbbd29aa57cea5ffa0de649139398993222a04cad8f0ba4ac4624c", + "t1": { + "factor_sha256": "3e6b097940dcd94f2e2eb650ee8354b3e1f9cf20c7719dc42e439284f2a4a976", + "original_backend_effective_recomposition_relative_l2": 2.3259481451987085e-07, + "original_native_all_one_boundary_states_bit_exact": true, + "original_native_all_one_full_head_bit_exact": true, + "receipt_sha256": "65ca847fc5b7d4a742bde0772fc442f409b9b708b7e0df3e36c3d0b8346ec58a" + }, + "t2": { + "factor_sha256": "daa8e628b79ddebb75b79325c562e60aa51274a9bfcf2b02856add9278c53f55", + "original_backend_effective_recomposition_relative_l2": 2.3502370538608375e-07, + "original_native_all_one_boundary_states_bit_exact": true, + "original_native_all_one_full_head_bit_exact": true, + "receipt_sha256": "8976e3142bf54b0b4258c3c5447843fe944e389a9c41859e901f6a852fa253b0" + } + }, + "native_manifest_sha256": "9f75078798d12449777733a4d7fbb93ba232f04e858253e7b8f5180334b3006b", + "native_target_parameter_sha256": "cf3db880c052137e7ff7a0dac1e498174f78e32fd3ae9a384aca341fb1d09186", + "ordered_case_state_token_custody_sha256": "8b5332f5dbd5f99b0bd8415a9ceb2031f1887ac669738daf46d6dddcc4b1a313", + "vectors_verified": 96 + }, + "nf4": { + "cases_verified": 16, + "fit_qualification": { + "initializer_sha256": "df4d9d4fe54493e676ef3a68941cc3f5954fdcb7473e419987e674783f4f7617", + "t1": { + "factor_sha256": "4560a14b18ead9296887f691dc91436ab76cc2214c840ec50aca1da7191d71d5", + "original_backend_effective_recomposition_relative_l2": 2.2900864848907077e-07, + "original_native_all_one_boundary_states_bit_exact": true, + "original_native_all_one_full_head_bit_exact": true, + "receipt_sha256": "457bffbf0ff0328bab2ad61a6c8f47be333c156fc4cbff82a816e69208aab945" + }, + "t2": { + "factor_sha256": "31746c9c77a219ef1c03ccdfe6faa1d224f70b3a0cbc2708e7984dc1f82fe897", + "original_backend_effective_recomposition_relative_l2": 2.308633213488065e-07, + "original_native_all_one_boundary_states_bit_exact": true, + "original_native_all_one_full_head_bit_exact": true, + "receipt_sha256": "46a4deb27434c06efa2e7b50daf48c27e5afff83475764b015918cbd4699a19f" + } + }, + "native_manifest_sha256": "b7548c9a600feed607cfa59cdd3d611f473e6bb056f3f26734232f9957ca6c85", + "native_target_parameter_sha256": "8e80e7d748d5daf858a0b37dd7843d38952554ce3aabea1104e52cf1ef7663b3", + "ordered_case_state_token_custody_sha256": "6543bc866a69918d0efe208fc07932622802c8738ec4e264a27f1c4c6d3df85c", + "vectors_verified": 96 + } + }, + "arm": "focused", + "bf16_native_affine": { + "all_archived_input_values_bf16_representable": true, + "all_archived_output_values_bf16_representable": true, + "bit_exact_case_writes": 0, + "bit_exact_elements": 71091, + "case_writes": 32, + "elements": 98304, + "max_absolute_error": 8.0, + "method": "float64 affine contraction followed by float32 and BF16 round-to-nearest-even", + "passes": { + "1": { + "bit_exact_case_writes": 0, + "bit_exact_elements": 34346, + "case_writes": 16, + "elements": 49152, + "max_absolute_error": 8.0, + "relative_l2": 0.00228710712403669 + }, + "2": { + "bit_exact_case_writes": 0, + "bit_exact_elements": 36745, + "case_writes": 16, + "elements": 49152, + "max_absolute_error": 2.0, + "relative_l2": 0.0015636413308056886 + } + }, + "relative_l2": 0.002129931599569799 + }, + "checkpoint_custody": { + "checkpoint_file_sha256": { + "config.json": "f6cb15b22847664f3a6049dc4b58fdd10f1650d112ac99a1da3d051f17c2ca19", + "model-00001-of-00002.safetensors": "09d265d5ec837bc64462796b7f8c110be9a135a55ed7a6eb5d07e0e90c976a94", + "model-00002-of-00002.safetensors": "31019e7870a044f44bc3f7e981f8c5ecd42d341e5ca6cfdbfd07fb95d95be389", + "model.safetensors.index.json": "30d8da0fa8b97abc6d9eddfd017a0cb7a649bcbd58caa57804c56c767db5c0f1" + }, + "checkpoint_revision": "451ed48c3273ecef7ea8faaa43c31ce529763bb1", + "tokenizer_config_sha256": "82316b70213c65e5f820c03d5a11561ccda4055bda984cb770ed0d51fe497c56" + }, + "denominators": "one complete A/B root per fold; no additional native trials", + "fixed_readers": { + "bf16/pass1": "BF16 pass 1 only, K projection composed with continuous Jacobian of both RMS norms at the mean training-fold raw carrier; range restricted to the target write span", + "nf4": "exact native K projection and arithmetic receipt unavailable" + }, + "gpu_jobs": 0, + "leave_one_root_out": { + "bf16": { + "1": { + "1": { + "max_contrast_spectral_tail_error_abs": 1.249000902703301e-16, + "max_reached_spectral_tail_error_abs": 1.5543122344752192e-15, + "methods": { + "contrast": { + "contrast_write_sq_error": 13.982640485663499, + "future_mse": 23.44879162939544, + "future_relative_mse": 0.025437557420504277, + "max_constructed_dose_error": 4.440892098500626e-16, + "max_pairwise_output_subspace_angle_deg": 0.9763698167723973, + "mean_cosine_when_defined": 0.8029213870809802, + "mean_gain_when_defined": 0.7896716938311703, + "n_cosine_defined": 8, + "n_gain_defined": 8, + "negative_gain_roots": 1, + "roots_beating_svd_future_error": 8, + "roots_beating_svd_write_error": 7, + "truth_future_mse": 921.8177375196502, + "truth_write_mse": 2306022.5636934657, + "unmatched_doses": 0, + "write_mse": 30570.956081594242, + "write_relative_mse": 0.013257006485066626 + }, + "initializer": { + "contrast_write_sq_error": 1.4326202056932185, + "future_mse": 204.81167110902504, + "future_relative_mse": 0.2221823933005619, + "max_constructed_dose_error": 3.3306690738754696e-16, + "max_pairwise_output_subspace_angle_deg": 2.4148365394514667e-06, + "mean_cosine_when_defined": 0.8268605597209406, + "mean_gain_when_defined": 0.8899060725193956, + "n_cosine_defined": 8, + "n_gain_defined": 8, + "negative_gain_roots": 0, + "roots_beating_svd_future_error": 8, + "roots_beating_svd_write_error": 8, + "truth_future_mse": 921.8177375196502, + "truth_write_mse": 2306022.5636934657, + "unmatched_doses": 0, + "write_mse": 23238.92408359735, + "write_relative_mse": 0.010077492063380543 + }, + "random": { + "contrast_write_sq_error": 116.5403380468722, + "future_mse": 963.6641142207844, + "future_relative_mse": 1.0453954995634287, + "max_constructed_dose_error": 8.881784197001252e-16, + "max_pairwise_output_subspace_angle_deg": 1.2074182697257333e-06, + "mean_cosine_when_defined": -0.05157655765217216, + "mean_gain_when_defined": -0.17641799468684413, + "n_cosine_defined": 8, + "n_gain_defined": 8, + "negative_gain_roots": 6, + "roots_beating_svd_future_error": 0, + "roots_beating_svd_write_error": 0, + "truth_future_mse": 921.8177375196502, + "truth_write_mse": 2306022.5636934657, + "unmatched_doses": 0, + "write_mse": 2304072.931241639, + "write_relative_mse": 0.9991545475389 + }, + "reach": { + "contrast_write_sq_error": 1.238319336207797, + "future_mse": 0.01841551722421076, + "future_relative_mse": 1.9977395177664608e-05, + "max_constructed_dose_error": 2.220446049250313e-16, + "max_pairwise_output_subspace_angle_deg": 0.01654358151809987, + "mean_cosine_when_defined": 0.7898948092971726, + "mean_gain_when_defined": 0.7667928201457904, + "n_cosine_defined": 8, + "n_gain_defined": 8, + "negative_gain_roots": 1, + "roots_beating_svd_future_error": 8, + "roots_beating_svd_write_error": 8, + "truth_future_mse": 921.8177375196502, + "truth_write_mse": 2306022.5636934657, + "unmatched_doses": 0, + "write_mse": 11.510854312024913, + "write_relative_mse": 4.9916486045082015e-06 + }, + "reader": { + "contrast_write_sq_error": 1.3411369846800367, + "future_mse": 0.01836305773767402, + "future_relative_mse": 1.992048643703016e-05, + "max_constructed_dose_error": 8.881784197001252e-16, + "max_pairwise_output_subspace_angle_deg": 0.016541368926940546, + "mean_cosine_when_defined": 0.789894927783751, + "mean_gain_when_defined": 0.7667933486470382, + "n_cosine_defined": 8, + "n_gain_defined": 8, + "negative_gain_roots": 1, + "roots_beating_svd_future_error": 8, + "roots_beating_svd_write_error": 8, + "truth_future_mse": 921.8177375196502, + "truth_write_mse": 2306022.5636934657, + "unmatched_doses": 0, + "write_mse": 12.775939487530577, + "write_relative_mse": 5.540249123611287e-06 + }, + "svd": { + "contrast_write_sq_error": 1.4641835202806428, + "future_mse": 208.8759509963248, + "future_relative_mse": 0.22659137755186906, + "max_constructed_dose_error": 2.220446049250313e-16, + "max_pairwise_output_subspace_angle_deg": 0.0, + "mean_cosine_when_defined": 0.8266110639690648, + "mean_gain_when_defined": 0.8917594155799209, + "n_cosine_defined": 8, + "n_gain_defined": 8, + "negative_gain_roots": 0, + "roots_beating_svd_future_error": 0, + "roots_beating_svd_write_error": 0, + "truth_future_mse": 921.8177375196502, + "truth_write_mse": 2306022.5636934657, + "unmatched_doses": 0, + "write_mse": 23323.727949047312, + "write_relative_mse": 0.010114267013801727 + }, + "t1": { + "contrast_write_sq_error": 1.4068451354063598, + "future_mse": 201.42154003765805, + "future_relative_mse": 0.21850473454722863, + "max_constructed_dose_error": 8.881784197001252e-16, + "max_pairwise_output_subspace_angle_deg": 0.0, + "mean_cosine_when_defined": 0.8271648670958074, + "mean_gain_when_defined": 0.8893245184641297, + "n_cosine_defined": 8, + "n_gain_defined": 8, + "negative_gain_roots": 0, + "roots_beating_svd_future_error": 8, + "roots_beating_svd_write_error": 8, + "truth_future_mse": 921.8177375196502, + "truth_write_mse": 2306022.5636934657, + "unmatched_doses": 0, + "write_mse": 22834.87407845546, + "write_relative_mse": 0.009902276949919233 + }, + "t2": { + "contrast_write_sq_error": 1.4272184921069089, + "future_mse": 205.48674523771206, + "future_relative_mse": 0.2229147225899759, + "max_constructed_dose_error": 8.881784197001252e-16, + "max_pairwise_output_subspace_angle_deg": 0.0, + "mean_cosine_when_defined": 0.8270999340962986, + "mean_gain_when_defined": 0.8921412481069428, + "n_cosine_defined": 8, + "n_gain_defined": 8, + "negative_gain_roots": 0, + "roots_beating_svd_future_error": 8, + "roots_beating_svd_write_error": 8, + "truth_future_mse": 921.8177375196502, + "truth_write_mse": 2306022.5636934657, + "unmatched_doses": 0, + "write_mse": 23136.061149078523, + "write_relative_mse": 0.010032885850007644 + } + }, + "roots": 8, + "training_contrast_support_ranks": [ + 7 + ], + "training_reached_support_ranks": [ + 14 + ] + }, + "2": { + "max_contrast_spectral_tail_error_abs": 1.0755285551056204e-16, + "max_reached_spectral_tail_error_abs": 1.1102230246251565e-15, + "methods": { + "contrast": { + "contrast_write_sq_error": 14.02208541388823, + "future_mse": 23.701363803001186, + "future_relative_mse": 0.025711551034779203, + "max_constructed_dose_error": 8.881784197001252e-16, + "max_pairwise_output_subspace_angle_deg": 33.83741198857424, + "mean_cosine_when_defined": 0.8229743732009711, + "mean_gain_when_defined": 0.7957660923622465, + "n_cosine_defined": 8, + "n_gain_defined": 8, + "negative_gain_roots": 0, + "roots_beating_svd_future_error": 8, + "roots_beating_svd_write_error": 7, + "truth_future_mse": 921.8177375196502, + "truth_write_mse": 2306022.5636934657, + "unmatched_doses": 0, + "write_mse": 30774.150043046746, + "write_relative_mse": 0.013345120957427667 + }, + "initializer": { + "contrast_write_sq_error": 0.7398615335853188, + "future_mse": 106.62047911190733, + "future_relative_mse": 0.11566329738760806, + "max_constructed_dose_error": 3.3306690738754696e-16, + "max_pairwise_output_subspace_angle_deg": 0.0, + "mean_cosine_when_defined": 0.8720435853440021, + "mean_gain_when_defined": 0.9095214885400099, + "n_cosine_defined": 8, + "n_gain_defined": 8, + "negative_gain_roots": 0, + "roots_beating_svd_future_error": 8, + "roots_beating_svd_write_error": 8, + "truth_future_mse": 921.8177375196502, + "truth_write_mse": 2306022.5636934657, + "unmatched_doses": 0, + "write_mse": 12361.899259704169, + "write_relative_mse": 0.0053607017790427 + }, + "random": { + "contrast_write_sq_error": 110.82497357987312, + "future_mse": 1702.3232440898985, + "future_relative_mse": 1.8467026341566901, + "max_constructed_dose_error": 8.881784197001252e-16, + "max_pairwise_output_subspace_angle_deg": 0.0, + "mean_cosine_when_defined": 0.10786819020247843, + "mean_gain_when_defined": 0.35871945737161537, + "n_cosine_defined": 8, + "n_gain_defined": 8, + "negative_gain_roots": 2, + "roots_beating_svd_future_error": 0, + "roots_beating_svd_write_error": 0, + "truth_future_mse": 921.8177375196502, + "truth_write_mse": 2306022.5636934657, + "unmatched_doses": 0, + "write_mse": 2213476.0954250065, + "write_relative_mse": 0.9598674923109898 + }, + "reach": { + "contrast_write_sq_error": 1.2256865743605982, + "future_mse": 0.016654258363060375, + "future_relative_mse": 1.8066758411345237e-05, + "max_constructed_dose_error": 1.7763568394002505e-15, + "max_pairwise_output_subspace_angle_deg": 56.840854525574635, + "mean_cosine_when_defined": 0.8235109030938814, + "mean_gain_when_defined": 0.7759696735472605, + "n_cosine_defined": 8, + "n_gain_defined": 8, + "negative_gain_roots": 1, + "roots_beating_svd_future_error": 8, + "roots_beating_svd_write_error": 8, + "truth_future_mse": 921.8177375196502, + "truth_write_mse": 2306022.5636934657, + "unmatched_doses": 0, + "write_mse": 11.131806852155536, + "write_relative_mse": 4.827275772326425e-06 + }, + "reader": { + "contrast_write_sq_error": 1.236775317653335, + "future_mse": 0.016224550963840453, + "future_relative_mse": 1.7600606175680795e-05, + "max_constructed_dose_error": 8.881784197001252e-16, + "max_pairwise_output_subspace_angle_deg": 54.509381696022245, + "mean_cosine_when_defined": 0.8049327041882276, + "mean_gain_when_defined": 0.7825099973978987, + "n_cosine_defined": 8, + "n_gain_defined": 8, + "negative_gain_roots": 1, + "roots_beating_svd_future_error": 8, + "roots_beating_svd_write_error": 8, + "truth_future_mse": 921.8177375196502, + "truth_write_mse": 2306022.5636934657, + "unmatched_doses": 0, + "write_mse": 11.523751913205986, + "write_relative_mse": 4.997241611872542e-06 + }, + "svd": { + "contrast_write_sq_error": 1.4122502114583206, + "future_mse": 208.16373984746582, + "future_relative_mse": 0.22581876153476427, + "max_constructed_dose_error": 1.7763568394002505e-15, + "max_pairwise_output_subspace_angle_deg": 0.0, + "mean_cosine_when_defined": 0.8995877494727925, + "mean_gain_when_defined": 0.990291459597703, + "n_cosine_defined": 8, + "n_gain_defined": 8, + "negative_gain_roots": 0, + "roots_beating_svd_future_error": 0, + "roots_beating_svd_write_error": 0, + "truth_future_mse": 921.8177375196502, + "truth_write_mse": 2306022.5636934657, + "unmatched_doses": 0, + "write_mse": 22822.73105384542, + "write_relative_mse": 0.009897011162497537 + }, + "t1": { + "contrast_write_sq_error": 0.7617327890363378, + "future_mse": 107.41595180079963, + "future_relative_mse": 0.11652623661790829, + "max_constructed_dose_error": 4.440892098500626e-16, + "max_pairwise_output_subspace_angle_deg": 2.091309789151873e-06, + "mean_cosine_when_defined": 0.8709052741518596, + "mean_gain_when_defined": 0.9092672289656161, + "n_cosine_defined": 8, + "n_gain_defined": 8, + "negative_gain_roots": 0, + "roots_beating_svd_future_error": 8, + "roots_beating_svd_write_error": 8, + "truth_future_mse": 921.8177375196502, + "truth_write_mse": 2306022.5636934657, + "unmatched_doses": 0, + "write_mse": 12840.664400426429, + "write_relative_mse": 0.005568316894462664 + }, + "t2": { + "contrast_write_sq_error": 0.733451202766287, + "future_mse": 107.4378929536191, + "future_relative_mse": 0.11655003866892816, + "max_constructed_dose_error": 1.7763568394002505e-15, + "max_pairwise_output_subspace_angle_deg": 1.4787793334710982e-06, + "mean_cosine_when_defined": 0.8718899581732318, + "mean_gain_when_defined": 0.9117655937328712, + "n_cosine_defined": 8, + "n_gain_defined": 8, + "negative_gain_roots": 0, + "roots_beating_svd_future_error": 8, + "roots_beating_svd_write_error": 8, + "truth_future_mse": 921.8177375196502, + "truth_write_mse": 2306022.5636934657, + "unmatched_doses": 0, + "write_mse": 12243.301640558333, + "write_relative_mse": 0.0053092722652933275 + } + }, + "roots": 8, + "training_contrast_support_ranks": [ + 7 + ], + "training_reached_support_ranks": [ + 14 + ] + }, + "4": { + "max_contrast_spectral_tail_error_abs": 1.3877787807814457e-17, + "max_reached_spectral_tail_error_abs": 2.220446049250313e-16, + "methods": { + "contrast": { + "contrast_write_sq_error": 14.028770278508695, + "future_mse": 24.000516470455707, + "future_relative_mse": 0.026036075781134656, + "max_constructed_dose_error": 1.7763568394002505e-15, + "max_pairwise_output_subspace_angle_deg": 89.23719576111976, + "mean_cosine_when_defined": 0.8340687141399227, + "mean_gain_when_defined": 0.814677677447089, + "n_cosine_defined": 8, + "n_gain_defined": 8, + "negative_gain_roots": 0, + "roots_beating_svd_future_error": 7, + "roots_beating_svd_write_error": 7, + "truth_future_mse": 921.8177375196502, + "truth_write_mse": 2306022.5636934657, + "unmatched_doses": 0, + "write_mse": 30790.571393896014, + "write_relative_mse": 0.013352242028620903 + }, + "initializer": { + "contrast_write_sq_error": 0.1412464268198341, + "future_mse": 13.421847740454325, + "future_relative_mse": 0.01456019687424187, + "max_constructed_dose_error": 1.1102230246251565e-16, + "max_pairwise_output_subspace_angle_deg": 2.2588727439225506e-06, + "mean_cosine_when_defined": 0.9329408522570481, + "mean_gain_when_defined": 0.8929633828895949, + "n_cosine_defined": 8, + "n_gain_defined": 8, + "negative_gain_roots": 0, + "roots_beating_svd_future_error": 8, + "roots_beating_svd_write_error": 8, + "truth_future_mse": 921.8177375196502, + "truth_write_mse": 2306022.5636934657, + "unmatched_doses": 0, + "write_mse": 2833.3845116090542, + "write_relative_mse": 0.0012286889799859259 + }, + "random": { + "contrast_write_sq_error": 105.45657704108181, + "future_mse": 1763.7890145073627, + "future_relative_mse": 1.9133815099427551, + "max_constructed_dose_error": 8.881784197001252e-16, + "max_pairwise_output_subspace_angle_deg": 0.0, + "mean_cosine_when_defined": 0.2882459247651426, + "mean_gain_when_defined": 1.065097434849242, + "n_cosine_defined": 8, + "n_gain_defined": 8, + "negative_gain_roots": 1, + "roots_beating_svd_future_error": 0, + "roots_beating_svd_write_error": 0, + "truth_future_mse": 921.8177375196502, + "truth_write_mse": 2306022.5636934657, + "unmatched_doses": 0, + "write_mse": 2114843.7593195206, + "write_relative_mse": 0.9170958656762918 + }, + "reach": { + "contrast_write_sq_error": 1.2080907600955333, + "future_mse": 0.014190235680235561, + "future_relative_mse": 1.5393754212646695e-05, + "max_constructed_dose_error": 1.7763568394002505e-15, + "max_pairwise_output_subspace_angle_deg": 53.89766106235896, + "mean_cosine_when_defined": 0.8698331450459792, + "mean_gain_when_defined": 0.8481324725778401, + "n_cosine_defined": 8, + "n_gain_defined": 8, + "negative_gain_roots": 0, + "roots_beating_svd_future_error": 8, + "roots_beating_svd_write_error": 8, + "truth_future_mse": 921.8177375196502, + "truth_write_mse": 2306022.5636934657, + "unmatched_doses": 0, + "write_mse": 10.692624146958886, + "write_relative_mse": 4.636825465329762e-06 + }, + "reader": { + "contrast_write_sq_error": 1.1970623916068448, + "future_mse": 0.014618888690285256, + "future_relative_mse": 1.5858762633078135e-05, + "max_constructed_dose_error": 8.881784197001252e-16, + "max_pairwise_output_subspace_angle_deg": 59.57841110203382, + "mean_cosine_when_defined": 0.8730673516429821, + "mean_gain_when_defined": 0.8609354862013752, + "n_cosine_defined": 8, + "n_gain_defined": 8, + "negative_gain_roots": 0, + "roots_beating_svd_future_error": 8, + "roots_beating_svd_write_error": 8, + "truth_future_mse": 921.8177375196502, + "truth_write_mse": 2306022.5636934657, + "unmatched_doses": 0, + "write_mse": 10.907958372889585, + "write_relative_mse": 4.730204528189324e-06 + }, + "svd": { + "contrast_write_sq_error": 0.29714889478589535, + "future_mse": 57.99042920917265, + "future_relative_mse": 0.06290877995601216, + "max_constructed_dose_error": 8.881784197001252e-16, + "max_pairwise_output_subspace_angle_deg": 1.2074182697257333e-06, + "mean_cosine_when_defined": 0.9664445315722571, + "mean_gain_when_defined": 1.025730054266504, + "n_cosine_defined": 8, + "n_gain_defined": 8, + "negative_gain_roots": 0, + "roots_beating_svd_future_error": 0, + "roots_beating_svd_write_error": 0, + "truth_future_mse": 921.8177375196502, + "truth_write_mse": 2306022.5636934657, + "unmatched_doses": 0, + "write_mse": 6676.987377518438, + "write_relative_mse": 0.0028954562208724313 + }, + "t1": { + "contrast_write_sq_error": 0.17069410285382802, + "future_mse": 16.491027019129284, + "future_relative_mse": 0.017889682903587813, + "max_constructed_dose_error": 8.881784197001252e-16, + "max_pairwise_output_subspace_angle_deg": 3.4150945850063763e-06, + "mean_cosine_when_defined": 0.9317816950820978, + "mean_gain_when_defined": 0.8890223720632513, + "n_cosine_defined": 8, + "n_gain_defined": 8, + "negative_gain_roots": 0, + "roots_beating_svd_future_error": 8, + "roots_beating_svd_write_error": 8, + "truth_future_mse": 921.8177375196502, + "truth_write_mse": 2306022.5636934657, + "unmatched_doses": 0, + "write_mse": 3421.633976022294, + "write_relative_mse": 0.0014837816549990723 + }, + "t2": { + "contrast_write_sq_error": 0.13270826758739504, + "future_mse": 12.713526660352732, + "future_relative_mse": 0.013791800854864459, + "max_constructed_dose_error": 8.881784197001252e-16, + "max_pairwise_output_subspace_angle_deg": 2.4148365394514667e-06, + "mean_cosine_when_defined": 0.9329644332277464, + "mean_gain_when_defined": 0.897718634505299, + "n_cosine_defined": 8, + "n_gain_defined": 8, + "negative_gain_roots": 0, + "roots_beating_svd_future_error": 8, + "roots_beating_svd_write_error": 8, + "truth_future_mse": 921.8177375196502, + "truth_write_mse": 2306022.5636934657, + "unmatched_doses": 0, + "write_mse": 2664.914838673646, + "write_relative_mse": 0.0011556325946808416 + } + }, + "roots": 8, + "training_contrast_support_ranks": [ + 7 + ], + "training_reached_support_ranks": [ + 14 + ] + } + }, + "2": { + "1": { + "max_contrast_spectral_tail_error_abs": 1.3642420526593924e-12, + "max_reached_spectral_tail_error_abs": 2.2737367544323206e-12, + "methods": { + "contrast": { + "contrast_write_sq_error": 1912.1135186134838, + "max_pairwise_output_subspace_angle_deg": 20.770527800498094, + "roots_beating_svd_write_error": 1, + "truth_write_mse": 623540.2206326958, + "write_mse": 517375.65184339654, + "write_relative_mse": 0.8297390203929814 + }, + "initializer": { + "contrast_write_sq_error": 1740.3695000092976, + "max_pairwise_output_subspace_angle_deg": 2.699869328381916e-06, + "roots_beating_svd_write_error": 8, + "truth_write_mse": 623540.2206326958, + "write_mse": 209604.3449812114, + "write_relative_mse": 0.33615208457367735 + }, + "random": { + "contrast_write_sq_error": 3240.663169394011, + "max_pairwise_output_subspace_angle_deg": 1.2074182697257333e-06, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 623540.2206326958, + "write_mse": 622500.5649031554, + "write_relative_mse": 0.9983326565069284 + }, + "reach": { + "contrast_write_sq_error": 2541.4491885402535, + "max_pairwise_output_subspace_angle_deg": 0.954520821694336, + "roots_beating_svd_write_error": 8, + "truth_write_mse": 623540.2206326958, + "write_mse": 2065.122017766733, + "write_relative_mse": 0.003311930729458459 + }, + "svd": { + "contrast_write_sq_error": 2337.380813686189, + "max_pairwise_output_subspace_angle_deg": 0.0, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 623540.2206326958, + "write_mse": 453094.58070989774, + "write_relative_mse": 0.726648523571022 + }, + "t1": { + "contrast_write_sq_error": 1743.795810605359, + "max_pairwise_output_subspace_angle_deg": 0.0, + "roots_beating_svd_write_error": 8, + "truth_write_mse": 623540.2206326958, + "write_mse": 209834.22428999835, + "write_relative_mse": 0.3365207525459754 + }, + "t2": { + "contrast_write_sq_error": 1739.29005264073, + "max_pairwise_output_subspace_angle_deg": 2.091309789151873e-06, + "roots_beating_svd_write_error": 8, + "truth_write_mse": 623540.2206326958, + "write_mse": 209534.32167145386, + "write_relative_mse": 0.3360397849858713 + } + }, + "roots": 8, + "training_contrast_support_ranks": [ + 7 + ], + "training_reached_support_ranks": [ + 14 + ] + }, + "2": { + "max_contrast_spectral_tail_error_abs": 3.126388037344441e-13, + "max_reached_spectral_tail_error_abs": 1.9895196601282805e-13, + "methods": { + "contrast": { + "contrast_write_sq_error": 1639.6274014758412, + "max_pairwise_output_subspace_angle_deg": 31.026466013413984, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 623540.2206326958, + "write_mse": 454199.8509720017, + "write_relative_mse": 0.7284210960940622 + }, + "initializer": { + "contrast_write_sq_error": 726.9688381103063, + "max_pairwise_output_subspace_angle_deg": 3.4150945850063763e-06, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 623540.2206326958, + "write_mse": 36851.133446391825, + "write_relative_mse": 0.05909984990062004 + }, + "random": { + "contrast_write_sq_error": 2829.6202370976193, + "max_pairwise_output_subspace_angle_deg": 0.0, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 623540.2206326958, + "write_mse": 462756.91182134213, + "write_relative_mse": 0.7421444463547042 + }, + "reach": { + "contrast_write_sq_error": 1124.7851532382704, + "max_pairwise_output_subspace_angle_deg": 6.337748763784281, + "roots_beating_svd_write_error": 8, + "truth_write_mse": 623540.2206326958, + "write_mse": 1024.5755964632967, + "write_relative_mse": 0.0016431587932269661 + }, + "svd": { + "contrast_write_sq_error": 716.759180681665, + "max_pairwise_output_subspace_angle_deg": 0.0, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 623540.2206326958, + "write_mse": 35018.968759796786, + "write_relative_mse": 0.056161523508882275 + }, + "t1": { + "contrast_write_sq_error": 731.4974590797445, + "max_pairwise_output_subspace_angle_deg": 2.831646840510158e-06, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 623540.2206326958, + "write_mse": 36963.80964520525, + "write_relative_mse": 0.059280553879425275 + }, + "t2": { + "contrast_write_sq_error": 725.789938240123, + "max_pairwise_output_subspace_angle_deg": 0.0, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 623540.2206326958, + "write_mse": 36510.74889320503, + "write_relative_mse": 0.058553959608504784 + } + }, + "roots": 8, + "training_contrast_support_ranks": [ + 7 + ], + "training_reached_support_ranks": [ + 14 + ] + }, + "4": { + "max_contrast_spectral_tail_error_abs": 4.618527782440651e-14, + "max_reached_spectral_tail_error_abs": 8.526512829121202e-14, + "methods": { + "contrast": { + "contrast_write_sq_error": 1440.9494631949174, + "max_pairwise_output_subspace_angle_deg": 45.732989538836364, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 623540.2206326958, + "write_mse": 433012.7741180375, + "write_relative_mse": 0.6944424109140332 + }, + "initializer": { + "contrast_write_sq_error": 314.2561924065111, + "max_pairwise_output_subspace_angle_deg": 3.1945284701301985e-06, + "roots_beating_svd_write_error": 7, + "truth_write_mse": 623540.2206326958, + "write_mse": 7651.147559125121, + "write_relative_mse": 0.012270495640781006 + }, + "random": { + "contrast_write_sq_error": 1569.0157520583791, + "max_pairwise_output_subspace_angle_deg": 0.0, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 623540.2206326958, + "write_mse": 74241.66907544142, + "write_relative_mse": 0.11906476377756296 + }, + "reach": { + "contrast_write_sq_error": 981.808376359938, + "max_pairwise_output_subspace_angle_deg": 40.61262223904971, + "roots_beating_svd_write_error": 8, + "truth_write_mse": 623540.2206326958, + "write_mse": 943.0545822049737, + "write_relative_mse": 0.0015124198103020074 + }, + "svd": { + "contrast_write_sq_error": 303.47836102736613, + "max_pairwise_output_subspace_angle_deg": 1.2074182697257333e-06, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 623540.2206326958, + "write_mse": 9083.108397164558, + "write_relative_mse": 0.014566996797653374 + }, + "t1": { + "contrast_write_sq_error": 313.6960077508157, + "max_pairwise_output_subspace_angle_deg": 0.0, + "roots_beating_svd_write_error": 7, + "truth_write_mse": 623540.2206326958, + "write_mse": 7493.675685362528, + "write_relative_mse": 0.012017950787134182 + }, + "t2": { + "contrast_write_sq_error": 313.233517143413, + "max_pairwise_output_subspace_angle_deg": 2.831646840510158e-06, + "roots_beating_svd_write_error": 7, + "truth_write_mse": 623540.2206326958, + "write_mse": 7312.173869359759, + "write_relative_mse": 0.011726868014929684 + } + }, + "roots": 8, + "training_contrast_support_ranks": [ + 7 + ], + "training_reached_support_ranks": [ + 14 + ] + } + } + }, + "nf4": { + "1": { + "1": { + "max_contrast_spectral_tail_error_abs": 1.6653345369377348e-16, + "max_reached_spectral_tail_error_abs": 4.884981308350689e-15, + "methods": { + "contrast": { + "contrast_write_sq_error": 3.329839706935414, + "max_pairwise_output_subspace_angle_deg": 0.9032258122184389, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 2820728.074609799, + "write_mse": 118253.23702524143, + "write_relative_mse": 0.04192294822378432 + }, + "initializer": { + "contrast_write_sq_error": 0.907188051938507, + "max_pairwise_output_subspace_angle_deg": 2.2588727439225506e-06, + "roots_beating_svd_write_error": 1, + "truth_write_mse": 2820728.074609799, + "write_mse": 28016.65894976435, + "write_relative_mse": 0.009932421066018564 + }, + "random": { + "contrast_write_sq_error": 83.25844199140096, + "max_pairwise_output_subspace_angle_deg": 0.0, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 2820728.074609799, + "write_mse": 2818267.8549933517, + "write_relative_mse": 0.9991278068812828 + }, + "reach": { + "contrast_write_sq_error": 2.050629402148858, + "max_pairwise_output_subspace_angle_deg": 0.01893420751638575, + "roots_beating_svd_write_error": 8, + "truth_write_mse": 2820728.074609799, + "write_mse": 35.12575621395339, + "write_relative_mse": 1.2452726843870782e-05 + }, + "svd": { + "contrast_write_sq_error": 0.9074177377532855, + "max_pairwise_output_subspace_angle_deg": 0.0, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 2820728.074609799, + "write_mse": 27999.207832261654, + "write_relative_mse": 0.00992623432378709 + }, + "t1": { + "contrast_write_sq_error": 0.8848095840109464, + "max_pairwise_output_subspace_angle_deg": 0.0, + "roots_beating_svd_write_error": 8, + "truth_write_mse": 2820728.074609799, + "write_mse": 27171.558546417305, + "write_relative_mse": 0.009632817424336814 + }, + "t2": { + "contrast_write_sq_error": 0.9040909723663156, + "max_pairwise_output_subspace_angle_deg": 1.2074182697257333e-06, + "roots_beating_svd_write_error": 8, + "truth_write_mse": 2820728.074609799, + "write_mse": 27914.441405612008, + "write_relative_mse": 0.009896183065953109 + } + }, + "roots": 8, + "training_contrast_support_ranks": [ + 7 + ], + "training_reached_support_ranks": [ + 14 + ] + }, + "2": { + "max_contrast_spectral_tail_error_abs": 3.122502256758253e-17, + "max_reached_spectral_tail_error_abs": 1.7763568394002505e-15, + "methods": { + "contrast": { + "contrast_write_sq_error": 3.294878111000259, + "max_pairwise_output_subspace_angle_deg": 30.462418473577692, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 2820728.074609799, + "write_mse": 118244.99356601019, + "write_relative_mse": 0.041920025765818436 + }, + "initializer": { + "contrast_write_sq_error": 0.5865429688587201, + "max_pairwise_output_subspace_angle_deg": 2.699869328381916e-06, + "roots_beating_svd_write_error": 8, + "truth_write_mse": 2820728.074609799, + "write_mse": 15181.674062869159, + "write_relative_mse": 0.005382182777391363 + }, + "random": { + "contrast_write_sq_error": 79.96348324398977, + "max_pairwise_output_subspace_angle_deg": 2.091309789151873e-06, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 2820728.074609799, + "write_mse": 2707250.77774921, + "write_relative_mse": 0.9597702104353726 + }, + "reach": { + "contrast_write_sq_error": 2.053289706111891, + "max_pairwise_output_subspace_angle_deg": 64.79101753099636, + "roots_beating_svd_write_error": 8, + "truth_write_mse": 2820728.074609799, + "write_mse": 34.72157445321912, + "write_relative_mse": 1.2309436973297143e-05 + }, + "svd": { + "contrast_write_sq_error": 0.8653502504225153, + "max_pairwise_output_subspace_angle_deg": 2.4148365394514667e-06, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 2820728.074609799, + "write_mse": 27576.461904843633, + "write_relative_mse": 0.009776363114568703 + }, + "t1": { + "contrast_write_sq_error": 0.5971930762860383, + "max_pairwise_output_subspace_angle_deg": 3.306651113363206e-06, + "roots_beating_svd_write_error": 8, + "truth_write_mse": 2820728.074609799, + "write_mse": 15551.025490832137, + "write_relative_mse": 0.005513124654166944 + }, + "t2": { + "contrast_write_sq_error": 0.5821718916297308, + "max_pairwise_output_subspace_angle_deg": 3.6222548091772e-06, + "roots_beating_svd_write_error": 8, + "truth_write_mse": 2820728.074609799, + "write_mse": 15033.21374859214, + "write_relative_mse": 0.005329550864512786 + } + }, + "roots": 8, + "training_contrast_support_ranks": [ + 7 + ], + "training_reached_support_ranks": [ + 14 + ] + }, + "4": { + "max_contrast_spectral_tail_error_abs": 2.3418766925686896e-17, + "max_reached_spectral_tail_error_abs": 2.7755575615628914e-16, + "methods": { + "contrast": { + "contrast_write_sq_error": 3.2969703998638145, + "max_pairwise_output_subspace_angle_deg": 84.109080329943, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 2820728.074609799, + "write_mse": 118486.41820987959, + "write_relative_mse": 0.04200561524395443 + }, + "initializer": { + "contrast_write_sq_error": 0.12844556253375003, + "max_pairwise_output_subspace_angle_deg": 8.537736462515939e-07, + "roots_beating_svd_write_error": 8, + "truth_write_mse": 2820728.074609799, + "write_mse": 2985.551273202527, + "write_relative_mse": 0.0010584328564232583 + }, + "random": { + "contrast_write_sq_error": 76.3720329851108, + "max_pairwise_output_subspace_angle_deg": 3.4150945850063763e-06, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 2820728.074609799, + "write_mse": 2588536.941065605, + "write_relative_mse": 0.9176839711582926 + }, + "reach": { + "contrast_write_sq_error": 2.0438691543130605, + "max_pairwise_output_subspace_angle_deg": 33.5576121223748, + "roots_beating_svd_write_error": 8, + "truth_write_mse": 2820728.074609799, + "write_mse": 34.61543211764815, + "write_relative_mse": 1.2271807562462971e-05 + }, + "svd": { + "contrast_write_sq_error": 0.2956210298828772, + "max_pairwise_output_subspace_angle_deg": 1.9090959104164224e-06, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 2820728.074609799, + "write_mse": 7549.0549663088495, + "write_relative_mse": 0.002676278877875577 + }, + "t1": { + "contrast_write_sq_error": 0.14753661767124032, + "max_pairwise_output_subspace_angle_deg": 2.9575586669421963e-06, + "roots_beating_svd_write_error": 8, + "truth_write_mse": 2820728.074609799, + "write_mse": 3631.8403933833238, + "write_relative_mse": 0.0012875542403660194 + }, + "t2": { + "contrast_write_sq_error": 0.12227837240114926, + "max_pairwise_output_subspace_angle_deg": 1.7075472925031877e-06, + "roots_beating_svd_write_error": 8, + "truth_write_mse": 2820728.074609799, + "write_mse": 2782.89358384721, + "write_relative_mse": 0.0009865869769216152 + } + }, + "roots": 8, + "training_contrast_support_ranks": [ + 7 + ], + "training_reached_support_ranks": [ + 14 + ] + } + }, + "2": { + "1": { + "max_contrast_spectral_tail_error_abs": 3.126388037344441e-13, + "max_reached_spectral_tail_error_abs": 9.094947017729282e-13, + "methods": { + "contrast": { + "contrast_write_sq_error": 840.206267023303, + "max_pairwise_output_subspace_angle_deg": 16.98008337997192, + "roots_beating_svd_write_error": 7, + "truth_write_mse": 679481.742525445, + "write_mse": 466999.2816648642, + "write_relative_mse": 0.6872874610716655 + }, + "initializer": { + "contrast_write_sq_error": 770.941119470885, + "max_pairwise_output_subspace_angle_deg": 2.091309789151873e-06, + "roots_beating_svd_write_error": 8, + "truth_write_mse": 679481.742525445, + "write_mse": 209040.25306990268, + "write_relative_mse": 0.30764660768214036 + }, + "random": { + "contrast_write_sq_error": 2398.7945582081, + "max_pairwise_output_subspace_angle_deg": 0.0, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 679481.742525445, + "write_mse": 678318.799670997, + "write_relative_mse": 0.9982884855005439 + }, + "reach": { + "contrast_write_sq_error": 1736.5321872562106, + "max_pairwise_output_subspace_angle_deg": 0.7513809065364343, + "roots_beating_svd_write_error": 8, + "truth_write_mse": 679481.742525445, + "write_mse": 1328.1426889599607, + "write_relative_mse": 0.001954640729600214 + }, + "svd": { + "contrast_write_sq_error": 2034.041018283134, + "max_pairwise_output_subspace_angle_deg": 0.0, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 679481.742525445, + "write_mse": 516524.0016625522, + "write_relative_mse": 0.7601734812517197 + }, + "t1": { + "contrast_write_sq_error": 771.2031036256768, + "max_pairwise_output_subspace_angle_deg": 3.306651113363206e-06, + "roots_beating_svd_write_error": 8, + "truth_write_mse": 679481.742525445, + "write_mse": 209126.5371433486, + "write_relative_mse": 0.3077735928063105 + }, + "t2": { + "contrast_write_sq_error": 769.7408000875114, + "max_pairwise_output_subspace_angle_deg": 1.4787793334710982e-06, + "roots_beating_svd_write_error": 8, + "truth_write_mse": 679481.742525445, + "write_mse": 208973.6023112067, + "write_relative_mse": 0.3075485171014454 + } + }, + "roots": 8, + "training_contrast_support_ranks": [ + 7 + ], + "training_reached_support_ranks": [ + 14 + ] + }, + "2": { + "max_contrast_spectral_tail_error_abs": 3.694822225952521e-13, + "max_reached_spectral_tail_error_abs": 2.5579538487363607e-13, + "methods": { + "contrast": { + "contrast_write_sq_error": 848.2078808211612, + "max_pairwise_output_subspace_angle_deg": 86.16299226124376, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 679481.742525445, + "write_mse": 448882.00876590284, + "write_relative_mse": 0.6606240913810768 + }, + "initializer": { + "contrast_write_sq_error": 367.68523350054096, + "max_pairwise_output_subspace_angle_deg": 0.0, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 679481.742525445, + "write_mse": 42157.71472106489, + "write_relative_mse": 0.062043925660719555 + }, + "random": { + "contrast_write_sq_error": 2067.2561291717143, + "max_pairwise_output_subspace_angle_deg": 2.091309789151873e-06, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 679481.742525445, + "write_mse": 499618.0992328993, + "write_relative_mse": 0.7352928974602873 + }, + "reach": { + "contrast_write_sq_error": 817.5185779314551, + "max_pairwise_output_subspace_angle_deg": 16.748952406003326, + "roots_beating_svd_write_error": 8, + "truth_write_mse": 679481.742525445, + "write_mse": 675.2783414833494, + "write_relative_mse": 0.0009938138131181087 + }, + "svd": { + "contrast_write_sq_error": 358.43260714075257, + "max_pairwise_output_subspace_angle_deg": 2.4148365394514667e-06, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 679481.742525445, + "write_mse": 40292.99590490263, + "write_relative_mse": 0.059299600538411455 + }, + "t1": { + "contrast_write_sq_error": 369.0309966568859, + "max_pairwise_output_subspace_angle_deg": 3.1945284701301985e-06, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 679481.742525445, + "write_mse": 41836.804493511096, + "write_relative_mse": 0.06157163890528583 + }, + "t2": { + "contrast_write_sq_error": 366.4223023057679, + "max_pairwise_output_subspace_angle_deg": 2.2588727439225506e-06, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 679481.742525445, + "write_mse": 41836.37270161904, + "write_relative_mse": 0.06157100343288822 + } + }, + "roots": 8, + "training_contrast_support_ranks": [ + 7 + ], + "training_reached_support_ranks": [ + 14 + ] + }, + "4": { + "max_contrast_spectral_tail_error_abs": 4.085620730620576e-14, + "max_reached_spectral_tail_error_abs": 4.263256414560601e-14, + "methods": { + "contrast": { + "contrast_write_sq_error": 807.5293007483112, + "max_pairwise_output_subspace_angle_deg": 55.97144711607083, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 679481.742525445, + "write_mse": 412205.2222133251, + "write_relative_mse": 0.6066465019078698 + }, + "initializer": { + "contrast_write_sq_error": 242.12626172680214, + "max_pairwise_output_subspace_angle_deg": 1.2074182697257333e-06, + "roots_beating_svd_write_error": 8, + "truth_write_mse": 679481.742525445, + "write_mse": 9266.911918615591, + "write_relative_mse": 0.01363820591289628 + }, + "random": { + "contrast_write_sq_error": 916.1745173303586, + "max_pairwise_output_subspace_angle_deg": 3.4150945850063763e-06, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 679481.742525445, + "write_mse": 66873.92810407128, + "write_relative_mse": 0.09841902131986573 + }, + "reach": { + "contrast_write_sq_error": 689.2625119726337, + "max_pairwise_output_subspace_angle_deg": 83.18296361974622, + "roots_beating_svd_write_error": 8, + "truth_write_mse": 679481.742525445, + "write_mse": 598.7550774069057, + "write_relative_mse": 0.000881193768623568 + }, + "svd": { + "contrast_write_sq_error": 248.7518072095507, + "max_pairwise_output_subspace_angle_deg": 1.9090959104164224e-06, + "roots_beating_svd_write_error": 0, + "truth_write_mse": 679481.742525445, + "write_mse": 10908.50139680643, + "write_relative_mse": 0.01605414938194301 + }, + "t1": { + "contrast_write_sq_error": 241.9665119930635, + "max_pairwise_output_subspace_angle_deg": 2.831646840510158e-06, + "roots_beating_svd_write_error": 8, + "truth_write_mse": 679481.742525445, + "write_mse": 9251.677197079369, + "write_relative_mse": 0.013615784822552338 + }, + "t2": { + "contrast_write_sq_error": 240.8225308051229, + "max_pairwise_output_subspace_angle_deg": 1.2074182697257333e-06, + "roots_beating_svd_write_error": 8, + "truth_write_mse": 679481.742525445, + "write_mse": 8934.864412593812, + "write_relative_mse": 0.01314952831460254 + } + }, + "roots": 8, + "training_contrast_support_ranks": [ + 7 + ], + "training_reached_support_ranks": [ + 14 + ] + } + } + } + }, + "numpy_version": "2.5.5", + "paired_operator_state_transport": { + "bf16_pass_1_to_2_t1_then_t2": { + "identity_relative_l2": 8.708301589107453e-17, + "input_energy_a_outside_b_empirical_contrast_support": 0.9424614310264587, + "input_energy_b_outside_a_empirical_contrast_support": 0.9474481344223022, + "mean_root_energy": { + "operator": 0.31730626518497224, + "operator_state_cross": 18.671806160983554, + "state": 3534.779108417848, + "total": 3553.768220844017 + }, + "total_below_sum_due_to_cancellation": 3 + }, + "bf16_pass_1_to_2_tied_t2": { + "identity_relative_l2": 0.0, + "input_energy_a_outside_b_empirical_contrast_support": 0.9424614310264587, + "input_energy_b_outside_a_empirical_contrast_support": 0.9474481344223022, + "mean_root_energy": { + "operator": 0.0, + "operator_state_cross": 0.0, + "state": 3556.7028598562397, + "total": 3556.7028598562397 + }, + "total_below_sum_due_to_cancellation": 0 + }, + "nf4_pass_1_to_2_t1_then_t2": { + "identity_relative_l2": 7.218135864250759e-17, + "input_energy_a_outside_b_empirical_contrast_support": 0.9871731996536255, + "input_energy_b_outside_a_empirical_contrast_support": 0.9780325889587402, + "mean_root_energy": { + "operator": 0.24778400756429514, + "operator_state_cross": 25.762259948905943, + "state": 2702.3060987706244, + "total": 2728.3161427270943 + }, + "total_below_sum_due_to_cancellation": 2 + }, + "nf4_pass_1_to_2_tied_t2": { + "identity_relative_l2": 0.0, + "input_energy_a_outside_b_empirical_contrast_support": 0.9871731996536255, + "input_energy_b_outside_a_empirical_contrast_support": 0.9780325889587402, + "mean_root_energy": { + "operator": 0.0, + "operator_state_cross": 0.0, + "state": 2730.689275876967, + "total": 2730.689275876967 + }, + "total_below_sum_due_to_cancellation": 0 + }, + "pass_1_bf16_to_nf4_t2": { + "identity_relative_l2": 6.011463080654529e-17, + "input_energy_a_outside_b_empirical_contrast_support": 0.35828670859336853, + "input_energy_b_outside_a_empirical_contrast_support": 0.3298099637031555, + "mean_root_energy": { + "operator": 0.015145989654184946, + "operator_state_cross": -0.057053870070400886, + "state": 264.7445667945631, + "total": 264.70265891414687 + }, + "total_below_sum_due_to_cancellation": 2 + }, + "pass_2_bf16_to_nf4_t2": { + "identity_relative_l2": 1.3837945207273e-16, + "input_energy_a_outside_b_empirical_contrast_support": 0.3064521551132202, + "input_energy_b_outside_a_empirical_contrast_support": 0.3030567169189453, + "mean_root_energy": { + "operator": 7.839958989186025, + "operator_state_cross": -10.314503767569915, + "state": 2833.737032643624, + "total": 2831.26248786524 + }, + "total_below_sum_due_to_cancellation": 4 + } + }, + "pretrained_decoder_forwards": 0, + "protected_ARG03_access": false, + "registration_sha256": "8d2214076db59384fd51b29e67c762b90568a510fa5b549734dc9ab6939014d0", + "replay_source_sha256": { + "archive_analysis.py": "9ae9798bfb33333020bd6c19fa5f11fe016517924bc2d59aa8a20cccb6f54d32", + "archive_checkpoint.py": "42c3033b287f3d93a3ce3de5e7edfb71d0614e84534d42bd1e82e3ae1c1ee2fb", + "archive_inputs.py": "218f43942ff91f98d54c8e3c5c85bd8fd9a35944499f924073e38bdfbccf8a86", + "archive_lease.py": "4da30a3463235a82dab4bae38ec9664e91c70ef7f9e816f621fb56e52a33e33a", + "controls.py": "1702fd2ed5764031de3a7759337ebcf88f3072c347ab8ca12be32300325caa88", + "replay_archive.py": "db86b8ad4512344d82d6f5d2e6ed5c34786be6be74940fcb1522337d14c0872f", + "transport.py": "886cd0ce2ce2ec7d2a59e12607ed1c51098be46da65aaa8e416cfc8deaf8a9af", + "weighted_rank.py": "f8bfb7fdc94dbcf49de4b8d6a863f84e99eca713fcf6fe95226b399c9848453b" + }, + "resource_receipt": { + "elapsed_seconds": 65.422, + "max_sampled_process_private_bytes": 111755264, + "min_sampled_available_physical_bytes": 10392551424, + "sample_count": 2168, + "single_thread": true + }, + "root_count": 8, + "schema": "rtbpd02-nanbeige-cal-archive/v1", + "split": "calibration", + "status": "completed_exposed_CAL_affine_and_fixed_reader_replay", + "t2_target_closure": { + "bf16": { + "1": { + "compact_recomposition_relative_l2": 1.0407610220997053e-15, + "reference_factor_sum_relative_l2": 1.7595519248141094e-17, + "target_over_archived_native_write_energy": 0.9807110957647631 + }, + "2": { + "compact_recomposition_relative_l2": 7.17980849636074e-16, + "reference_factor_sum_relative_l2": 8.940998714834839e-17, + "target_over_archived_native_write_energy": 0.7989353937655941 + } + }, + "nf4": { + "1": { + "compact_recomposition_relative_l2": 1.1801724481748423e-15, + "reference_factor_sum_relative_l2": 1.627176543260463e-17, + "target_over_archived_native_write_energy": 0.9829259158631111 + }, + "2": { + "compact_recomposition_relative_l2": 7.3113908228921e-16, + "reference_factor_sum_relative_l2": 9.075400912846954e-17, + "target_over_archived_native_write_energy": 0.8023776713739527 + } + } + } +} diff --git a/mechinterp/bpd/theory/rtbpd02/NANBEIGE_CAL_EVALMATH_PREFLIGHT.json b/mechinterp/bpd/theory/rtbpd02/NANBEIGE_CAL_EVALMATH_PREFLIGHT.json new file mode 100644 index 00000000..24e25c34 --- /dev/null +++ b/mechinterp/bpd/theory/rtbpd02/NANBEIGE_CAL_EVALMATH_PREFLIGHT.json @@ -0,0 +1,24 @@ +{ + "approx_resolvable_effect": 0.17483391579292118, + "approx_worlds_for_80pct_power": 16, + "decision": "REDESIGN_OR_PILOT_ONLY", + "experiment_id": "RT-BPD-02 archive BF16 pass-1 rank-2 matched-direction descriptor", + "independent_unit": "selection-exposed CAL root, complete A/B pair", + "limits": "Normal-based power is planning only. Root and sham independence, symmetry, readout sealing, and the scientific effect floor require independent audits. Repeated outcomes within a root are never additional worlds.", + "mean_pilot_effect": -0.047327522642125, + "mechanistic_variation_floor": 0.1, + "observed_worst_sham": 0.593329503234, + "order_statistic_rank": null, + "pilot_world_sigma": 0.21369020741286243, + "pilot_worlds": 8, + "planned_comparisons": 1, + "planned_confirmation_worlds": 64, + "reasons": [ + "heldout_unsealed", + "independence_unverified", + "sham_quantile_uncalibrated" + ], + "schema": "EvalMath/mechinterp-power-preflight/v1", + "target_effect": 0.25, + "upper_sham_quantile": null +} diff --git a/mechinterp/bpd/theory/rtbpd02/NANBEIGE_RT_BPD_02_REPORT_20261123.md b/mechinterp/bpd/theory/rtbpd02/NANBEIGE_RT_BPD_02_REPORT_20261123.md new file mode 100644 index 00000000..6c573ab9 --- /dev/null +++ b/mechinterp/bpd/theory/rtbpd02/NANBEIGE_RT_BPD_02_REPORT_20261123.md @@ -0,0 +1,73 @@ +# Nanbeige RT-BPD-02 research report + +November 23, 2026 · BPD draft PR #146 + +Reached-state weighting substantially improved compression of a fixed Nanbeige T2 write on eight exposed CAL roots. That improvement did not carry over to the signed donor direction. In the BF16 rank-2 pass-1 comparison, future-reader weighting reduced relative K-readout squared error from 0.2258 to 0.0000176, while mean matched-dose cosine fell from 0.900 to 0.805. The archive therefore supports evaluating compression and source-specific behavior separately. The independently replayed synthetic gym shows where the two objectives can agree and gives an explicit distribution-shift failure. + +[Theory](THEORY.md) · [Locked registration](EXTENSION_PROTOCOL.md) · [Archive contract](ARCHIVE.md) · [Nanbeige synthesis](https://github.com/MoralityLabAI/LoopedTransformers/blob/c074e354e8bcd4d26c02104fadd289dfdad8a207/reports/nanbeige_bpd_gym/NANBEIGE_RESEARCH_SYNTHESIS_20261123.md) + +## Mathematical findings + +The weighted Eckart–Young lift gives a global minimizer for a fixed reached second moment and a fixed measured reader, including singular supports. A numerical reader cutoff must affect both the target and the lift. The original implementation could spend rank on a singular direction discarded by its pseudoinverse. The corrected solver reports the optimized effective loss, its spectral tail, and the full loss of that same physical lift. Exact objective values and solution sets are covariant under invertible coordinate changes. A minimum-coordinate-Frobenius-norm lift can change off support under a shear, and a tied spectral cutoff can rotate the selected subspace by 90° under an arbitrarily small perturbation. + +The paired difference is the operator change acting on the midpoint plus the midpoint operator acting on the state change. Squared energies include their signed cross term. An additional reader term applies when the measured map changes. Delayed-visible rank follows by restricting the future reader to the kernel of the current reader. A fixed linear stack, or a frozen tangent stack with a controlled remainder, can serve as a rank objective. Reached moments and readers with sufficient support domination admit a transfer bound. Orthogonal source and destination supports, opposite signed gains at equal dose, cancelling paths, and nonlinear joint edits provide explicit failure cases. [Proofs and counterexamples](THEORY.md) + +## Synthetic development + +The six-dimensional tied recurrence stores its write in a stage slot and delivers it to delayed memory after another step. Its two delayed-visible axes are locally dark. The five candidates use rank 2, with 24 paired roots for methods that fit on training data. The physical-dose comparisons evaluated both registered pass occurrences on the same 64 independently drawn development roots, with a separate rescaling of those draws for the shift panel. Explicit state continuation verified the fixed reader to numerical precision. Each candidate intervention was sized at one-quarter of the reference write contrast. + +| Method | Aligned pass-2 write MSE | Aligned pass-2 delayed MSE | Aligned matched-dose cosine | Shifted pass-2 write MSE | +| --- | ---: | ---: | ---: | ---: | +| Ordinary SVD | 334.019 | 269.263 | Undefined, zero readout | 1.317 | +| Reached-state SVD | 18.153 | 0.05381 | 0.9972 | 7,442.533 | +| Fixed-future-reader SVD | 16.971 | < 1e−26 | 1.0000 | 7,452.655 | +| BPD mask over planted atoms | 16.971 | < 1e−26 | 1.0000 | 7,452.655 | +| Seeded random write subspace | 268.306 | 191.582 | 0.7263 | 6,194.316 | + +The registered fixed-reader result improved over SVD on 64 of 64 roots. The paired reduction averaged 269.263, with a range of 13.347 to 1,236.862. An independent test computes the ordinary-SVD error directly from the planted recurrence and reduces the root receipts. The BPD mask also recovers the two planted reader axes. This fixture tests a fixed bank of exact atoms, and the archived IO18 banks supply the learned-bank comparison. + +The reader and BPD retained exact direction in the shifted panel, where mean signed gain after dose matching was about 250× the reference at pass 2. That gain reflects the large physical dose relative to a small delayed component. The reached fit gave negative gain on 26 of 64 shifted pass-2 roots. Its maximum pass-2 output angle between independent CAL halves was 8.29°, compared with numerical zero for the fixed reader. A fixed bank can fit a chosen finite-dimensional reader and still write poorly under a changed reach law. + +EvalMath returned **REDESIGN_OR_PILOT_ONLY**. With undefined SVD directions assigned the preregistered score of zero, the direction effect was 0.500. The worst-root sham bound was 0.49958 on the bounded scale, above the registered 0.25 planning effect, and the development stream has no sealed confirmation. [Synthetic summary](SYNTHETIC_SUMMARY.json) · [Synthetic EvalMath input](SYNTHETIC_EVALMATH_INPUT.json) · [Synthetic preflight](SYNTHETIC_EVALMATH_PREFLIGHT.json) · [Hosted CPU replay and raw synthetic artifact](https://github.com/MoralityLabAI/BPD/actions/runs/45193970011) + +## Nanbeige CAL archive + +The replay validated 16 focused CAL cases and 96 selected vectors per backend across passes 1 and 2. It joined both worlds of each root by identity, verified the original token-list digest, and checked the archived tensor and fit hashes. All four IO18 fit cells carried the original bit-exact native all-one full-head and boundary-state qualifications. The reference T2 rank-eight sum recomposed within 1.19e−15 relative L2 in the compact physical basis. Each new fit left out both worlds of the scored root. The original exposure of the eight CAL roots, shared factor banks, and overlapping folds limit the interpretation to development. + +**Native affine audit.** The CPU emulation of the separate, full BF16 down-projection used the pinned checkpoint weights, float64 contraction and BF16 round-to-nearest-even via float32. It matched 71,091 of 98,304 elements by bits and 0 of 32 complete writes. Relative L2 was 0.002130, and maximum absolute deviation was 8.0. Both recorded operands and outputs were BF16-representable. These numbers expose a host-to-native replay discrepancy. The exact all-one receipts qualify the original native runs, and the CPU emulation has no exact native closure claim. + +**Write reconstruction.** The reached fit beat ordinary SVD on all eight exposed roots at each of ranks 1, 2 and 4, in both precisions and both passes. Each cell in the next table reports the rank-2 ratio of mean squared write error to mean squared T2 target write, with worlds averaged within roots. Pair-contrast weighting fit a different loss and often incurred a higher write error. The atom-mask baselines sometimes improved on ordinary SVD and sometimes did worse. Ranks 1 and 4 and all scoring fields are included in the aggregate. [Archive aggregate](NANBEIGE_CAL_ARCHIVE_AGGREGATE.json) + +| Backend and pass | Ordinary SVD | Reached fit | Pair-contrast fit | SVD initializer mask | T1 mask | T2 mask | Random | +| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | +| BF16 1 | 0.009897 | 0.00000483 | 0.013345 | 0.005361 | 0.005568 | 0.005309 | 0.959867 | +| BF16 2 | 0.056162 | 0.001643 | 0.728421 | 0.059100 | 0.059281 | 0.058554 | 0.742144 | +| NF4 1 | 0.009776 | 0.0000120 | 0.041920 | 0.005382 | 0.005513 | 0.005330 | 0.959770 | +| NF4 2 | 0.059300 | 0.000994 | 0.660624 | 0.062044 | 0.061572 | 0.061571 | 0.735293 | + +**Fixed BF16 K reader.** The BF16 pass-1 fit uses the continuous derivative of both RMS norms and the pinned layer-0 K matrix at the mean training-fold carrier. The CPU calculation stops at K before RoPE and attention. Normalizing writes to equal physical L2 before this frozen reader exposed a difference between average squared reconstruction error and the paired donor contrast. At rank 2, the fixed-reader fit also had a 54.5° maximum output-subspace angle between leave-one-root-out fits. The reached fit's angle was 56.8°. Reached-state and fixed-reader fits used rank-14 input supports. Pair-contrast fits used rank-7 supports. A small residual on this reached cloud therefore leaves the physical directions underdetermined away from it. + +| BF16 pass-1 rank-2 method | Relative K-readout MSE | Mean donor cosine at matched dose | Mean signed gain | +| --- | ---: | ---: | ---: | +| Ordinary SVD | 0.225819 | 0.900 | 0.990 | +| Reached fit | 0.00001807 | 0.824 | 0.776 | +| Fixed-reader fit | 0.00001760 | 0.805 | 0.783 | +| Pair-contrast fit | 0.025712 | 0.823 | 0.796 | +| SVD initializer mask | 0.115663 | 0.872 | 0.910 | +| T1 mask | 0.116526 | 0.871 | 0.909 | +| T2 mask | 0.116550 | 0.872 | 0.912 | +| Random | 1.846703 | 0.108 | 0.359 | + +The reader fit reduced K-readout error on all eight roots. Its mean paired cosine effect after dividing by two was −0.04733. EvalMath returned **REDESIGN_OR_PILOT_ONLY** for the reused, unsealed CAL folds, with independence and the 95/95 sham bound unverified. An archive matched-dose computation constructs equal-length physical inputs to a frozen CPU reader. Native intervention dose after rounding and answer mediation remain unmeasured. [Archive preflight](NANBEIGE_CAL_EVALMATH_PREFLIGHT.json) + +**Transport.** For the tied T2 target within each backend, the entire cross-pass contrast change is the state term. Pass 2 put 94.7% of BF16 and 97.8% of NF4 contrast-input energy outside the corresponding pass-1 empirical contrast support. Across backends, the mean squared state term was 264.74 at pass 1 and 2,833.74 at pass 2, compared with operator terms of 0.0151 and 7.84. The signed cross terms were −0.0571 and −10.31, respectively. These are fixed-bank physical decompositions on paired archived states. They give no finite empirical moment-domination guarantee and do not identify the causal effect of changing precision. [Transport receipts](NANBEIGE_CAL_ARCHIVE_AGGREGATE.json) + +## Implications for the gym + +The earlier Nanbeige synthesis used the Inkling 2 Mini work to motivate matched-depth evaluation and measuring specific later readers. The tied synthetic gym now tests that design with known physical source factors and an explicit delayed cache. Nanbeige carries residuals serially between passes, so its development replay uses an architecture-specific next-pass K tangent. The new benchmarks record present and delayed outputs, signed donor direction and gain at common dose, root-level holdouts, and output-subspace stability alongside reconstruction. The results justify keeping those endpoints distinct when comparing equal-rank SVD and BPD candidates. [Nanbeige synthesis, matched interventions](https://github.com/MoralityLabAI/LoopedTransformers/blob/c074e354e8bcd4d26c02104fadd289dfdad8a207/reports/nanbeige_bpd_gym/NANBEIGE_RESEARCH_SYNTHESIS_20261123.md#what-a-matched-intervention-changes) + +Native causal validation still requires the native NF4 operator and reader arithmetic, exact parity of the considered physical patch, a verified first-pass head, rounded matched doses, and signed active/sham and clean-reader-rescue outcomes on new authorized roots. The archive provides the verified layout and precise extraction contract for that stage. This work ran zero pretrained forwards and zero GPU jobs. The 168-case ARG-03-N cohort remains sealed. [Archive and extraction contract](ARCHIVE.md) + +## Reproduction and custody + +The original source-only CI passed at its pinned head. The extension first committed the registration, then the proof and support audit, then the synthetic and archive runners. The hosted Ubuntu job ran 30 tests with NumPy 1.26.4 and reproduced the primary synthetic result. The local archive used NumPy 2.5.5 with one CPU thread, 65.4 seconds, and 106.6 MiB peak sampled process-private memory. It verified both pinned checkpoint shards. The receipts publish aggregate measurements and content hashes. The synthetic artifact contains the generated root rows and can be regenerated by the source command in the README. Its byte hash is host-specific because floating-point serialization can vary at the last digits. [Original CI](https://github.com/MoralityLabAI/BPD/actions/runs/45181729576) · [Extension CPU CI](https://github.com/MoralityLabAI/BPD/actions/runs/45193970011) · [Locked EvalMath planner](https://github.com/MoralityLabAI/EvalMath/tree/accf4d9040bee8daeabc6b07003bb484708996c0/skills/evalmath-mechinterp-power) diff --git a/mechinterp/bpd/theory/rtbpd02/README.md b/mechinterp/bpd/theory/rtbpd02/README.md index 9e80c982..eacd3683 100644 --- a/mechinterp/bpd/theory/rtbpd02/README.md +++ b/mechinterp/bpd/theory/rtbpd02/README.md @@ -1,40 +1,16 @@ -# RT-BPD-02: reached-state and fixed-reader-weighted low rank +# RT-BPD-02 reached-state and fixed-reader-weighted low rank -**Status:** exact source-only formulation and CPU fixture; no Nanbeige pretrained evaluation. The original 168-case ARG-03-N cohort remains sealed, and the Nanbeige research goal remains paused. +The original CPU formulation is now extended by the [mathematical paper](THEORY.md), the matched-rank [synthetic recurrence](synthetic_gym.py), and a read-only [Nanbeige CAL archive replay](ARCHIVE.md). The [research report](NANBEIGE_RT_BPD_02_REPORT_20261123.md) records the results and limits. The [initial source-only protocol](PROTOCOL.md) and its [eight-test result](RESULTS_SOURCE_ONLY_20261123.md) remain the starting reference. -[Source-only registration](PROTOCOL.md) · [NumPy implementation](weighted_rank.py) · [CPU tests](test_weighted_rank.py) +For a fixed physical reader and a reached second moment, the [NumPy solver](weighted_rank.py) implements the weighted Eckart–Young lift with explicit numerical input and reader supports. The [transport reference](transport.py) covers paired operator and state differences, fixed future readers, delayed-dark rank, directional gain, and signed paths. The [extension registration](EXTENSION_PROTOCOL.md) defines the synthetic and archive families. -## Why this sits alongside BPD +## CPU reproduction -The `c074e35` Nanbeige synthesis in `MoralityLabAI/LoopedTransformers` reports almost equal learned VPD/BPD *physical operators*, together with large NF4/BF16 differences in reached inputs and native donor writes. Its REFIT49 symmetric accounting assigns most observed cross-precision pass-1 write disagreement to the reached input. These are development observations, not a native success for the new method. +From the BPD repository root with Python 3.11 and NumPy 1.26.4: -Ordinary SVD minimizes `||W-K||_F^2`. The recurrent question instead asks how accurately the reduced operator acts on the input distribution at each **physical occurrence**. Let `Sigma=E[h h^T]`, or use `E[(h^A-h^B)(h^A-h^B)^T]` for source contrasts. For a fixed reader `A` chosen in advance, use: + python -m unittest discover -s mechinterp/bpd/theory/rtbpd02 -p 'test_*.py' -v + python mechinterp/bpd/theory/rtbpd02/synthetic_gym.py --out PATH_FOR_SYNTHETIC_RECEIPTS -``` -min_{rank K <= r} || A (W-K) Sigma^(1/2) ||_F^2. -``` +The output contains an aggregate, one measurement per synthetic root, method, panel and pass, and the synthetic EvalMath input. Both worlds are repeated measurements within a root. The [CPU workflow](../../../../.github/workflows/rtbpd02-source-only.yml) runs the public checks and publishes the generated synthetic receipts. The optional archive replay needs the existing audited COMP14 and IO18 assets and both pinned checkpoint shards. See the [archive contract](ARCHIVE.md) for the command and the exact inputs. -With `S=Sigma^(1/2)`, the closed-form solutions are: - -``` -K_input = (W S)_r S^+ -K_reader = A^+ (A W S)_r S^+ -``` - -Pseudoinverses cover singular positive-semidefinite moments and rank-deficient readers. The exact optimal loss is the squared tail of the singular values of `W S` or `A W S`, respectively. Input directions in `ker(S)` and write directions in `ker(A)` are unidentifiable under this local criterion, so arbitrary factor labels have no causal interpretation. These results are weighted low-rank algebra, rather than new theorems about neural behavior. - -For a nonlinear continuation, an input-dependent Jacobian `A(h)` changes the objective; the closed forms only cover a frozen linear `A`. A future native study must use a registered physical reader, rounded dose and oracle-scored continuation before claiming causal benefit. - -## CPU reference and result - -From the BPD repository root, with NumPy installed: - -```bash -python -m unittest discover -s mechinterp/bpd/theory/rtbpd02 -p 'test_weighted_rank.py' -v -``` - -The pre-registered three-dimensional fixture has `W=diag(4,3,2)`, `Sigma=diag(0.01,1,10)`. For rank 2, conventional SVD drops the third coordinate and suffers weighted squared error **40**, whereas reached-state SVD drops the first and attains **0.16**. With rank 1 and reader `[0,1,0]`, reader-weighted fitting gets zero reader error whereas input-only fitting gets **9**. These are predetermined synthetic identities. The tests also check singular moments, rank-deficient readers, input-coordinate rotations, the `Sigma=I, A=I` reduction, paired contrasts and rejection of malformed inputs. - -## Archive bridge requirements - -For a numerical test on Nanbeige, source a CAL-only bundle of *actual reached* input vectors indexed by physical layer, module, pass, token support, precision, independently grouped root and world, with checkpoint and source digests. The published aggregate currently reports only physical operator and vector cosines, not the covariance matrices or raw reached vectors needed for this fit. No native model or sealed confirmation cohort is accessed by this package. The next action after this source gate would require a separate explicit resume decision. +The Nanbeige archive is selection-exposed development evidence. Native causal, GPU, and protected-cohort work require a separately authorized protocol. diff --git a/mechinterp/bpd/theory/rtbpd02/SYNTHETIC_EVALMATH_INPUT.json b/mechinterp/bpd/theory/rtbpd02/SYNTHETIC_EVALMATH_INPUT.json new file mode 100644 index 00000000..730a1a50 --- /dev/null +++ b/mechinterp/bpd/theory/rtbpd02/SYNTHETIC_EVALMATH_INPUT.json @@ -0,0 +1,466 @@ +{ + "alpha": "0.05", + "confirm_units_planned": 64, + "experiment_id": "RT-BPD-02 synthetic matched-dose direction", + "heldout_sealed": false, + "independent_unit": "paired development source root", + "measurement_resolution": "0.000001", + "pilot": [ + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.492076113112" + ], + "unit_id": "dev-000" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.401148181528" + ], + "unit_id": "dev-001" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.282741287623" + ], + "unit_id": "dev-002" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.498020722587" + ], + "unit_id": "dev-003" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.438797836991" + ], + "unit_id": "dev-004" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.418362629135" + ], + "unit_id": "dev-005" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.259046936022" + ], + "unit_id": "dev-006" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.360945536843" + ], + "unit_id": "dev-007" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.416719611715" + ], + "unit_id": "dev-008" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.493876973869" + ], + "unit_id": "dev-009" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.413400643953" + ], + "unit_id": "dev-010" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.491518589957" + ], + "unit_id": "dev-011" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.491792274070" + ], + "unit_id": "dev-012" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.483229207029" + ], + "unit_id": "dev-013" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.463932047520" + ], + "unit_id": "dev-014" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.303117141272" + ], + "unit_id": "dev-015" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.305138007957" + ], + "unit_id": "dev-016" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.457301302391" + ], + "unit_id": "dev-017" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.387919253457" + ], + "unit_id": "dev-018" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.465483988308" + ], + "unit_id": "dev-019" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.497755259155" + ], + "unit_id": "dev-020" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.285963633995" + ], + "unit_id": "dev-021" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.426377503619" + ], + "unit_id": "dev-022" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.256630436158" + ], + "unit_id": "dev-023" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "-0.421676847732" + ], + "unit_id": "dev-024" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.348589239129" + ], + "unit_id": "dev-025" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.380036576861" + ], + "unit_id": "dev-026" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.467206072209" + ], + "unit_id": "dev-027" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.257721858273" + ], + "unit_id": "dev-028" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "-0.408071091099" + ], + "unit_id": "dev-029" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.362559286029" + ], + "unit_id": "dev-030" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.245110956310" + ], + "unit_id": "dev-031" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.098464971216" + ], + "unit_id": "dev-032" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.455930444904" + ], + "unit_id": "dev-033" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.421971489987" + ], + "unit_id": "dev-034" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.374739333095" + ], + "unit_id": "dev-035" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.499583493961" + ], + "unit_id": "dev-036" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.485269554713" + ], + "unit_id": "dev-037" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.381744106512" + ], + "unit_id": "dev-038" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.491017400397" + ], + "unit_id": "dev-039" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.455628280650" + ], + "unit_id": "dev-040" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.326606929608" + ], + "unit_id": "dev-041" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.441937386458" + ], + "unit_id": "dev-042" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.493588841200" + ], + "unit_id": "dev-043" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.283059277339" + ], + "unit_id": "dev-044" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.495388721044" + ], + "unit_id": "dev-045" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.052709142040" + ], + "unit_id": "dev-046" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.372342090801" + ], + "unit_id": "dev-047" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.420057695480" + ], + "unit_id": "dev-048" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.259817372081" + ], + "unit_id": "dev-049" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.480542961971" + ], + "unit_id": "dev-050" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.445874136200" + ], + "unit_id": "dev-051" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.318417129452" + ], + "unit_id": "dev-052" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.426815171546" + ], + "unit_id": "dev-053" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.332904979021" + ], + "unit_id": "dev-054" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.365730194313" + ], + "unit_id": "dev-055" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.404567764579" + ], + "unit_id": "dev-056" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.389147931535" + ], + "unit_id": "dev-057" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.462286502209" + ], + "unit_id": "dev-058" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.415929832040" + ], + "unit_id": "dev-059" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.283107979599" + ], + "unit_id": "dev-060" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.389073662229" + ], + "unit_id": "dev-061" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.324340527122" + ], + "unit_id": "dev-062" + }, + { + "paired_effect": "0.500000000000", + "sham_effects": [ + "0.371235460418" + ], + "unit_id": "dev-063" + } + ], + "pilot_from_development_only": true, + "planned_comparisons": 1, + "schema_version": 1, + "scientific_min_effect": "0.10", + "sham_confidence": "0.95", + "sham_quantile": "0.95", + "target_effect": "0.25", + "units_independent": true +} diff --git a/mechinterp/bpd/theory/rtbpd02/SYNTHETIC_EVALMATH_PREFLIGHT.json b/mechinterp/bpd/theory/rtbpd02/SYNTHETIC_EVALMATH_PREFLIGHT.json new file mode 100644 index 00000000..715c9899 --- /dev/null +++ b/mechinterp/bpd/theory/rtbpd02/SYNTHETIC_EVALMATH_PREFLIGHT.json @@ -0,0 +1,24 @@ +{ + "approx_resolvable_effect": 0.499583493961, + "approx_worlds_for_80pct_power": null, + "decision": "REDESIGN_OR_PILOT_ONLY", + "experiment_id": "RT-BPD-02 synthetic matched-dose direction", + "independent_unit": "paired development source root", + "limits": "Normal-based power is planning only. Root and sham independence, symmetry, readout sealing, and the scientific effect floor require independent audits. Repeated outcomes within a root are never additional worlds.", + "mean_pilot_effect": 0.5, + "mechanistic_variation_floor": 0.499583493961, + "observed_worst_sham": 0.499583493961, + "order_statistic_rank": 64, + "pilot_world_sigma": 0.0, + "pilot_worlds": 64, + "planned_comparisons": 1, + "planned_confirmation_worlds": 64, + "reasons": [ + "heldout_unsealed", + "target_below_mechanistic_variation_floor", + "confirmation_underpowered" + ], + "schema": "EvalMath/mechinterp-power-preflight/v1", + "target_effect": 0.25, + "upper_sham_quantile": 0.499583493961 +} diff --git a/mechinterp/bpd/theory/rtbpd02/SYNTHETIC_SUMMARY.json b/mechinterp/bpd/theory/rtbpd02/SYNTHETIC_SUMMARY.json new file mode 100644 index 00000000..0f359d79 --- /dev/null +++ b/mechinterp/bpd/theory/rtbpd02/SYNTHETIC_SUMMARY.json @@ -0,0 +1,573 @@ +{ + "delayed_dark_rank": 2, + "fit_diagnostics": { + "1": { + "bpd_selected_atoms_zero_based": [ + 2, + 3 + ], + "column_rank": { + "bpd_static": 2, + "random": 2, + "reach": 2, + "reader": 2, + "svd": 2 + }, + "half_cal_max_output_angle_deg": { + "bpd_static": 0.0, + "random": 1.2074182697257333e-06, + "reach": 20.657998673957465, + "reader": 1.2074182697257333e-06, + "svd": 0.0 + }, + "reach_fit_loss": 22.945608455784992, + "reach_spectral_tail": 22.94560845578499, + "reader_fit_loss": 6.49904452476344e-30, + "reader_spectral_tail": 0.0 + }, + "2": { + "bpd_selected_atoms_zero_based": [ + 2, + 3 + ], + "column_rank": { + "bpd_static": 2, + "random": 2, + "reach": 2, + "reader": 2, + "svd": 2 + }, + "half_cal_max_output_angle_deg": { + "bpd_static": 0.0, + "random": 1.2074182697257333e-06, + "reach": 8.294091422140472, + "reader": 8.537736462515939e-07, + "svd": 0.0 + }, + "reach_fit_loss": 17.178864353258238, + "reach_spectral_tail": 17.17886435325824, + "reader_fit_loss": 3.0861734516545076e-28, + "reader_spectral_tail": 0.0 + } + }, + "panels": { + "aligned": { + "1": { + "methods": { + "bpd_static": { + "contrast_write_sq_error": 44.05927183047781, + "current_mse": 19.325869088885046, + "future_mse": 8.298741148031532e-31, + "future_relative_mse": 1.0696557868237653e-32, + "max_matched_dose_error": 1.7763568394002505e-15, + "max_reader_closure_abs": 1.7763568394002505e-15, + "mean_cosine_when_defined": 1.0, + "mean_gain_when_defined": 1.8622690940453646, + "n_cosine_defined": 64, + "n_gain_defined": 64, + "negative_gain_roots": 0, + "truth_future_mse": 77.58328660730949, + "truth_write_mse": 115.05607325954318, + "unmatched_writes": 0, + "write_mse": 22.887619793652373, + "write_relative_mse": 0.19892578588200677 + }, + "random": { + "contrast_write_sq_error": 174.54420876229298, + "current_mse": 20.042538889949903, + "future_mse": 58.02025530422664, + "future_relative_mse": 0.7478447722625903, + "max_matched_dose_error": 8.881784197001252e-16, + "max_reader_closure_abs": 8.881784197001252e-16, + "mean_cosine_when_defined": 0.6034768317304564, + "mean_gain_when_defined": 0.2971603630102038, + "n_cosine_defined": 64, + "n_gain_defined": 64, + "negative_gain_roots": 7, + "truth_future_mse": 77.58328660730949, + "truth_write_mse": 115.05607325954318, + "unmatched_writes": 0, + "write_mse": 88.63039282048828, + "write_relative_mse": 0.7703234632434924 + }, + "reach": { + "contrast_write_sq_error": 49.37060465479675, + "current_mse": 21.392136863680793, + "future_mse": 0.7766157483762569, + "future_relative_mse": 0.01001009086283138, + "max_matched_dose_error": 1.7763568394002505e-15, + "max_reader_closure_abs": 1.7763568394002505e-15, + "mean_cosine_when_defined": 0.9695939784964555, + "mean_gain_when_defined": 1.4774369476269544, + "n_cosine_defined": 64, + "n_gain_defined": 64, + "negative_gain_roots": 1, + "truth_future_mse": 77.58328660730949, + "truth_write_mse": 115.05607325954318, + "unmatched_writes": 0, + "write_mse": 25.69334991100233, + "write_relative_mse": 0.22331154873540085 + }, + "reader": { + "contrast_write_sq_error": 44.05927183047782, + "current_mse": 19.325869088885046, + "future_mse": 7.729164317703304e-30, + "future_relative_mse": 9.962408987421143e-32, + "max_matched_dose_error": 8.881784197001252e-16, + "max_reader_closure_abs": 8.881784197001252e-16, + "mean_cosine_when_defined": 1.0, + "mean_gain_when_defined": 1.8622690940453648, + "n_cosine_defined": 64, + "n_gain_defined": 64, + "negative_gain_roots": 0, + "truth_future_mse": 77.58328660730949, + "truth_write_mse": 115.05607325954318, + "unmatched_writes": 0, + "write_mse": 22.887619793652377, + "write_relative_mse": 0.19892578588200682 + }, + "svd": { + "contrast_write_sq_error": 192.0888581798455, + "current_mse": 3.8678792413975295e-29, + "future_mse": 77.58328660730949, + "future_relative_mse": 1.0, + "max_matched_dose_error": 1.7763568394002505e-15, + "max_reader_closure_abs": 1.1657341758564144e-15, + "mean_cosine_when_defined": null, + "mean_gain_when_defined": 0.0, + "n_cosine_defined": 0, + "n_gain_defined": 64, + "negative_gain_roots": 0, + "truth_future_mse": 77.58328660730949, + "truth_write_mse": 115.05607325954318, + "unmatched_writes": 0, + "write_mse": 95.73020417065814, + "write_relative_mse": 0.8320308651131366 + } + }, + "root_count": 64 + }, + "2": { + "methods": { + "bpd_static": { + "contrast_write_sq_error": 32.57684604242719, + "current_mse": 14.330759181017356, + "future_mse": 2.4013603552981646e-30, + "future_relative_mse": 8.918256086089795e-33, + "max_matched_dose_error": 2.6645352591003757e-15, + "max_reader_closure_abs": 2.6645352591003757e-15, + "mean_cosine_when_defined": 1.0, + "mean_gain_when_defined": 1.3275355334639751, + "n_cosine_defined": 64, + "n_gain_defined": 64, + "negative_gain_roots": 0, + "truth_future_mse": 269.2634447942882, + "truth_write_mse": 348.3494822464865, + "unmatched_writes": 0, + "write_mse": 16.971288212060475, + "write_relative_mse": 0.04871914292110779 + }, + "random": { + "contrast_write_sq_error": 537.4101668765372, + "current_mse": 44.56059612502527, + "future_mse": 191.582135454803, + "future_relative_mse": 0.7115044361152248, + "max_matched_dose_error": 1.7763568394002505e-15, + "max_reader_closure_abs": 2.6645352591003757e-15, + "mean_cosine_when_defined": 0.7263313103738592, + "mean_gain_when_defined": 0.3795761727649699, + "n_cosine_defined": 64, + "n_gain_defined": 64, + "negative_gain_roots": 2, + "truth_future_mse": 269.2634447942882, + "truth_write_mse": 348.3494822464865, + "unmatched_writes": 0, + "write_mse": 268.3055800487589, + "write_relative_mse": 0.7702195459527342 + }, + "reach": { + "contrast_write_sq_error": 35.03619620356378, + "current_mse": 15.471813024809615, + "future_mse": 0.05380646657331039, + "future_relative_mse": 0.00019982833768771485, + "max_matched_dose_error": 3.552713678800501e-15, + "max_reader_closure_abs": 2.6645352591003757e-15, + "mean_cosine_when_defined": 0.99715037375943, + "mean_gain_when_defined": 1.3047683322799482, + "n_cosine_defined": 64, + "n_gain_defined": 64, + "negative_gain_roots": 0, + "truth_future_mse": 269.2634447942882, + "truth_write_mse": 348.3494822464865, + "unmatched_writes": 0, + "write_mse": 18.153192782714086, + "write_relative_mse": 0.05211201310145533 + }, + "reader": { + "contrast_write_sq_error": 32.57684604242719, + "current_mse": 14.330759181017356, + "future_mse": 4.049802261768573e-28, + "future_relative_mse": 1.504029730014982e-30, + "max_matched_dose_error": 1.7763568394002505e-15, + "max_reader_closure_abs": 2.6645352591003757e-15, + "mean_cosine_when_defined": 1.0, + "mean_gain_when_defined": 1.3275355334639751, + "n_cosine_defined": 64, + "n_gain_defined": 64, + "negative_gain_roots": 0, + "truth_future_mse": 269.2634447942882, + "truth_write_mse": 348.3494822464865, + "unmatched_writes": 0, + "write_mse": 16.971288212060472, + "write_relative_mse": 0.04871914292110777 + }, + "svd": { + "contrast_write_sq_error": 682.4783232964531, + "current_mse": 1.247525841195661e-28, + "future_mse": 269.2634447942882, + "future_relative_mse": 1.0, + "max_matched_dose_error": 1.7763568394002505e-15, + "max_reader_closure_abs": 2.6645352591003757e-15, + "mean_cosine_when_defined": null, + "mean_gain_when_defined": 0.0, + "n_cosine_defined": 0, + "n_gain_defined": 64, + "negative_gain_roots": 0, + "truth_future_mse": 269.2634447942882, + "truth_write_mse": 348.3494822464865, + "unmatched_writes": 0, + "write_mse": 334.01872306546915, + "write_relative_mse": 0.9588609717786888 + } + }, + "root_count": 64 + } + }, + "shifted": { + "1": { + "methods": { + "bpd_static": { + "contrast_write_sq_error": 18137.794505493548, + "current_mse": 9659.891989522745, + "future_mse": 3.9218128248348174e-29, + "future_relative_mse": 1.7283350024091722e-28, + "max_matched_dose_error": 1.4210854715202004e-14, + "max_reader_closure_abs": 1.0658141036401503e-14, + "mean_cosine_when_defined": 1.0, + "mean_gain_when_defined": 531.2772180724096, + "n_cosine_defined": 64, + "n_gain_defined": 64, + "negative_gain_roots": 0, + "truth_future_mse": 0.22691276976790367, + "truth_write_mse": 9660.802734968207, + "unmatched_writes": 0, + "write_mse": 9660.559053957459, + "write_relative_mse": 0.9999747763185489 + }, + "random": { + "contrast_write_sq_error": 14725.72010787167, + "current_mse": 7085.42993682081, + "future_mse": 331.2987229563263, + "future_relative_mse": 1460.0267904498858, + "max_matched_dose_error": 1.0658141036401503e-14, + "max_reader_closure_abs": 6.217248937900877e-15, + "mean_cosine_when_defined": -0.008897957659085734, + "mean_gain_when_defined": -35.618345592569085, + "n_cosine_defined": 64, + "n_gain_defined": 64, + "negative_gain_roots": 31, + "truth_future_mse": 0.22691276976790367, + "truth_write_mse": 9660.802734968207, + "unmatched_writes": 0, + "write_mse": 7956.17075610563, + "write_relative_mse": 0.8235517248797042 + }, + "reach": { + "contrast_write_sq_error": 17857.062385681485, + "current_mse": 9379.711218657312, + "future_mse": 131.5641128127154, + "future_relative_mse": 579.8003917861694, + "max_matched_dose_error": 1.4210854715202004e-14, + "max_reader_closure_abs": 7.105427357601002e-15, + "mean_cosine_when_defined": -0.007982289141068081, + "mean_gain_when_defined": -7.809772033593622, + "n_cosine_defined": 64, + "n_gain_defined": 64, + "negative_gain_roots": 31, + "truth_future_mse": 0.22691276976790367, + "truth_write_mse": 9660.802734968207, + "unmatched_writes": 0, + "write_mse": 9516.76566178076, + "write_relative_mse": 0.9850905688544814 + }, + "reader": { + "contrast_write_sq_error": 18137.794505493548, + "current_mse": 9659.891989522745, + "future_mse": 3.3189519773234354e-28, + "future_relative_mse": 1.4626554427581157e-27, + "max_matched_dose_error": 1.4210854715202004e-14, + "max_reader_closure_abs": 7.105427357601002e-15, + "mean_cosine_when_defined": 1.0, + "mean_gain_when_defined": 531.2772180723973, + "n_cosine_defined": 64, + "n_gain_defined": 64, + "negative_gain_roots": 0, + "truth_future_mse": 0.22691276976790367, + "truth_write_mse": 9660.802734968207, + "unmatched_writes": 0, + "write_mse": 9660.559053957459, + "write_relative_mse": 0.9999747763185489 + }, + "svd": { + "contrast_write_sq_error": 1.708187842280996, + "current_mse": 1.584225748511349e-27, + "future_mse": 0.22691276976790378, + "future_relative_mse": 1.0000000000000004, + "max_matched_dose_error": 1.4210854715202004e-14, + "max_reader_closure_abs": 4.884981308350689e-15, + "mean_cosine_when_defined": null, + "mean_gain_when_defined": 0.0, + "n_cosine_defined": 0, + "n_gain_defined": 64, + "negative_gain_roots": 0, + "truth_future_mse": 0.22691276976790367, + "truth_write_mse": 9660.802734968207, + "unmatched_writes": 0, + "write_mse": 0.9107454454617395, + "write_relative_mse": 9.427223290309081e-05 + } + }, + "root_count": 64 + }, + "2": { + "methods": { + "bpd_static": { + "contrast_write_sq_error": 13963.44257260785, + "current_mse": 7452.159276678826, + "future_mse": 3.2455859139239706e-29, + "future_relative_mse": 4.3472339409052393e-29, + "max_matched_dose_error": 1.4210854715202004e-14, + "max_reader_closure_abs": 7.105427357601002e-15, + "mean_cosine_when_defined": 1.0, + "mean_gain_when_defined": 249.5243516419097, + "n_cosine_defined": 64, + "n_gain_defined": 64, + "negative_gain_roots": 0, + "truth_future_mse": 0.7465864404914292, + "truth_write_mse": 7453.476152324186, + "unmatched_writes": 0, + "write_mse": 7452.655418961317, + "write_relative_mse": 0.9998898858269489 + }, + "random": { + "contrast_write_sq_error": 11453.208578556249, + "current_mse": 5544.690012827362, + "future_mse": 240.50399146095154, + "future_relative_mse": 322.1381723764544, + "max_matched_dose_error": 1.4210854715202004e-14, + "max_reader_closure_abs": 7.105427357601002e-15, + "mean_cosine_when_defined": 0.0005983158285162202, + "mean_gain_when_defined": -17.928818616395297, + "n_cosine_defined": 64, + "n_gain_defined": 64, + "negative_gain_roots": 31, + "truth_future_mse": 0.7465864404914292, + "truth_write_mse": 7453.476152324186, + "unmatched_writes": 0, + "write_mse": 6194.315518634444, + "write_relative_mse": 0.831063974988757 + }, + "reach": { + "contrast_write_sq_error": 13943.573745436568, + "current_mse": 7431.890206443505, + "future_mse": 9.902211426589611, + "future_relative_mse": 13.263315390608529, + "max_matched_dose_error": 7.105427357601002e-15, + "max_reader_closure_abs": 1.4210854715202004e-14, + "mean_cosine_when_defined": 0.1639059428657561, + "mean_gain_when_defined": 27.73962862073169, + "n_cosine_defined": 64, + "n_gain_defined": 64, + "negative_gain_roots": 26, + "truth_future_mse": 0.7465864404914292, + "truth_write_mse": 7453.476152324186, + "unmatched_writes": 0, + "write_mse": 7442.532866172568, + "write_relative_mse": 0.9985317875944092 + }, + "reader": { + "contrast_write_sq_error": 13963.44257260785, + "current_mse": 7452.159276678826, + "future_mse": 1.0764132201911733e-28, + "future_relative_mse": 1.4417797616075652e-28, + "max_matched_dose_error": 1.4210854715202004e-14, + "max_reader_closure_abs": 1.4210854715202004e-14, + "mean_cosine_when_defined": 1.0, + "mean_gain_when_defined": 249.52435164190274, + "n_cosine_defined": 64, + "n_gain_defined": 64, + "negative_gain_roots": 0, + "truth_future_mse": 0.7465864404914292, + "truth_write_mse": 7453.476152324186, + "unmatched_writes": 0, + "write_mse": 7452.655418961317, + "write_relative_mse": 0.9998898858269489 + }, + "svd": { + "contrast_write_sq_error": 2.5091533881042025, + "current_mse": 1.1198333722375856e-27, + "future_mse": 0.7465864404914294, + "future_relative_mse": 1.0000000000000002, + "max_matched_dose_error": 1.4210854715202004e-14, + "max_reader_closure_abs": 3.552713678800501e-15, + "mean_cosine_when_defined": null, + "mean_gain_when_defined": 0.0, + "n_cosine_defined": 0, + "n_gain_defined": 64, + "negative_gain_roots": 0, + "truth_future_mse": 0.7465864404914292, + "truth_write_mse": 7453.476152324186, + "unmatched_writes": 0, + "write_mse": 1.3168756453594963, + "write_relative_mse": 0.00017667939340610363 + } + }, + "root_count": 64 + } + } + }, + "pass_transport": { + "aligned": { + "empirical_pass2_over_pass1_psd_bound": 4.174171437294987, + "mean_contrast_energies": { + "bpd_static": { + "operator": 0.0, + "operator_reader_cross": 0.0, + "operator_state_cross": 0.0, + "reader": 0.0, + "state": 155.8910335082008, + "state_reader_cross": 0.0, + "total": 155.8910335082008 + }, + "random": { + "operator": 0.0, + "operator_reader_cross": 0.0, + "operator_state_cross": 0.0, + "reader": 0.0, + "state": 41.064235904462535, + "state_reader_cross": 0.0, + "total": 41.064235904462535 + }, + "reach": { + "operator": 6.099824127998813, + "operator_reader_cross": 0.0, + "operator_state_cross": 6.366309792915152, + "reader": 0.0, + "state": 153.22368727772636, + "state_reader_cross": 0.0, + "total": 165.68982119864032 + }, + "reader": { + "operator": 7.980907788704345e-28, + "operator_reader_cross": 0.0, + "operator_state_cross": 6.880007641097563e-13, + "reader": 0.0, + "state": 155.891033508201, + "state_reader_cross": 0.0, + "total": 155.89103350820167 + }, + "svd": { + "operator": 0.0, + "operator_reader_cross": 0.0, + "operator_state_cross": 0.0, + "reader": 0.0, + "state": 0.7731789186052889, + "state_reader_cross": 0.0, + "total": 0.7731789186052889 + }, + "tied_target": { + "operator": 0.0, + "operator_reader_cross": 0.0, + "operator_state_cross": 0.0, + "reader": 0.0, + "state": 156.79528324824662, + "state_reader_cross": 0.0, + "total": 156.79528324824662 + } + } + }, + "shifted": { + "empirical_pass2_over_pass1_psd_bound": 4.174171437291467, + "mean_contrast_energies": { + "bpd_static": { + "operator": 0.0, + "operator_reader_cross": 0.0, + "operator_state_cross": 0.0, + "reader": 0.0, + "state": 0.3372190032074158, + "state_reader_cross": 0.0, + "total": 0.3372190032074158 + }, + "random": { + "operator": 0.0, + "operator_reader_cross": 0.0, + "operator_state_cross": 0.0, + "reader": 0.0, + "state": 72.86817687754589, + "state_reader_cross": 0.0, + "total": 72.86817687754589 + }, + "reach": { + "operator": 115.00877622785333, + "operator_reader_cross": 0.0, + "operator_state_cross": 36.555490514400596, + "reader": 0.0, + "state": 3.540167081117276, + "state_reader_cross": 0.0, + "total": 155.1044338233712 + }, + "reader": { + "operator": 6.074889624020039e-28, + "operator_reader_cross": 0.0, + "operator_state_cross": -7.474912479112256e-16, + "reader": 0.0, + "state": 0.3372190032074166, + "state_reader_cross": 0.0, + "total": 0.3372190032074158 + }, + "svd": { + "operator": 0.0, + "operator_reader_cross": 0.0, + "operator_state_cross": 0.0, + "reader": 0.0, + "state": 285.1290637559325, + "state_reader_cross": 0.0, + "total": 285.1290637559325 + }, + "tied_target": { + "operator": 0.0, + "operator_reader_cross": 0.0, + "operator_state_cross": 0.0, + "reader": 0.0, + "state": 285.4900566844446, + "state_reader_cross": 0.0, + "total": 285.4900566844446 + } + } + } + }, + "primary_paired_svd_minus_reader": { + "max": 1236.8619902280814, + "mean": 269.2634447942882, + "min": 13.347270711230934, + "positive_roots": 64, + "roots": 64 + }, + "registration_sha256": "8d2214076db59384fd51b29e67c762b90568a510fa5b549734dc9ab6939014d0", + "schema": "rtbpd02-synthetic/v1", + "split_counts": { + "development": 64, + "train": 24 + }, + "synthetic_roots_sha256": "3273441352c560404a9a2e60d7a2a716ff1bd23142fab5a67faed9178694bcbb" +}