diff --git a/.github/workflows/inkling-depth-precision-source.yml b/.github/workflows/inkling-depth-precision-source.yml new file mode 100644 index 00000000..3103c4a5 --- /dev/null +++ b/.github/workflows/inkling-depth-precision-source.yml @@ -0,0 +1,30 @@ +name: Inkling gated recurrence source checks +on: + push: + branches: + - research/inkling-depth-precision-20261121 + paths: + - "research/inkling_depth_precision/**" + - ".github/workflows/inkling-depth-precision-source.yml" + pull_request: + paths: + - "research/inkling_depth_precision/**" + - ".github/workflows/inkling-depth-precision-source.yml" + workflow_dispatch: +permissions: + contents: read +jobs: + source-test: + runs-on: ubuntu-latest + timeout-minutes: 8 + strategy: + fail-fast: false + matrix: + python-version: ['3.10', '3.12'] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Run source-only unittest fixtures + run: python -m unittest discover -s research/inkling_depth_precision -p 'test_bounds.py' -v diff --git a/research/inkling_depth_precision/README.md b/research/inkling_depth_precision/README.md new file mode 100644 index 00000000..419f2074 --- /dev/null +++ b/research/inkling_depth_precision/README.md @@ -0,0 +1,108 @@ +# Inkling depth/precision bridge: gated recurrence, numerical error and goal-preserving quotients + +Status: literature-derived source-only mathematics and an executable CPU bounds instrument (2026-11-21). +No neural checkpoint, proprietary data, GPU run, or claim of measured Jacobians. Keep all existing +NOR-37 and NOR-48 original records and verdicts unchanged. + +## References inspected + +- Thinking Machines, [Inkling 2 Mini release](https://thinkingmachines.ai/news/inkling-2-mini/), 2026-11-20. +- Thinking Machines, [End-to-End 4-Bit Training](https://thinkingmachines.ai/blog/end-to-end-4-bit-training/). +- Chen et al., [Attention Residuals](https://arxiv.org/abs/2603.15031), 2026. +- Dehghani et al., [Universal Transformers](https://arxiv.org/abs/1807.03819), 2018. +- Yang et al., [Looped Transformers Are Better at Learning Learning Algorithms](https://arxiv.org/abs/2311.12424), 2024. +- Zhu et al., [Scaling Latent Reasoning via Looped Language Models / Ouro](https://arxiv.org/abs/2510.25741), 2025. +- Bae et al., [Mixture-of-Recursions](https://arxiv.org/abs/2507.10524), 2025. +- Chen et al., [TetraJet-v2](https://arxiv.org/abs/2510.27527), 2025/2026. +- Panferov et al., [Quartet II](https://arxiv.org/abs/2601.22813), 2026. +- Goodfire, [Interpreting Inkling 2 Mini](https://www.goodfire.com/research/interpreting-inkling-2-mini/), 2026-11-20. + +Inkling's 24 physical layers apply 12 fixed layers and 12 recurrent layers for each pass. +The fixed three-pass model therefore performs 48 layer applications per generated token. +The variable-loop research checkpoint trained pass counts 1–5 at ratio 1:2:6:2:1 and +post-trained at pass 3; pass 7/10 are extrapolation experiments. The 20 GB checkpoint +requires >=32 GB GPU/unified memory for native deployment. See its +[model card](https://thinkingmachines.ai/model-card/tml-d24-varloop-research/). + +## Derivation: a fixed-gate precision envelope + +Let a frozen-input recurrent map be + + z[t+1] = kappa[t] ⊙ p(x) + gamma[t] ⊙ M[t](z[t]), + +and let a quantized implementation introduce local numerical deviation bounded by +epsilon[t] in infinity norm. If gamma and kappa are held constant with respect +to state and M[t] has infinity-norm Lipschitz constant m[t], then + + e[t+1] <= L[t] e[t] + epsilon[t], + L[t] := ||gamma[t]||_infinity * m[t]. + +By induction, + + e[T] <= (prod_{j=0}^{T-1} L[j]) e[0] + + sum_{j=0}^{T-1} epsilon[j] prod_{h=j+1}^{T-1} L[h]. + +The base case is the initial error. The induction step follows by inserting +the exact intermediate map between the quantized state transition and the +reference transition, then using the triangle inequality and Lipschitz bound. +This is an upper bound on numerical deviation, conditional on supplied L and epsilon. +It is not a guarantee of correct task output, attractor identity, or fidelity +to a private/unobserved reference state. + +**Important assumption:** In Attention Residuals the depth-wise softmax and +cross-loop gate can depend on state. Their complete Jacobian contributes +terms involving derivatives of the gate, normalization and the reader. +The fixed-gate formula cannot certify Inkling by reading only gamma weights. +A native test must estimate/upper-bound the full local operator Jacobian. + +For L < 1 and bounded epsilon, the numerical error approaches a finite +envelope. A perfectly converged wrong answer remains wrong. A serial pointer +chase can continue making verified progress through pass 10 even if its +successive states are far apart. Use the task verifier and algorithmic hop +state as distinct observable quantities. + +## Four proposed falsifiers + +1. **Recurrent placement**: compare middle-12 loop, final-12 loop and fully + untied iso-application controls with matched weights, data and inference. + Primary outcome is independently verified depth extrapolation, not NLL + measured on the same training tasks. +2. **Quantization placement**: at the same file/activation budget, compare + quantizing every loop with preserving cross-loop gates, block-boundary + outlier coordinates and the coda at higher precision. Include randomly + selected matched-number, matched-RMS protected coordinates. +3. **Residual access / goal quotient**: construct a state quotient q(z) and + evaluate if the future output and next task-relevant operator are + measurable from q(z) at a specified pass. Measure conditional future-output + agreement on fresh root families, including serial and convergent tasks. +4. **Exit prediction**: calibrate a per-task depth-value predictor on ordinary + development roots, then evaluate the fixed maximum, oracle hindsight, + learned exit gate and random depth under *measured* compute budgets. + Keep oracle as a diagnostic upper bound, not a deployable policy. + +A meaningful precision certificate must report the reference precision, +software/hardware mode, source hashes, per-pass local error, measured or +certified full-state Jacobian bound, activation outlier statistics and +independently checked answer deltas. The native NVFP4+MXFP8 recipe and the +TetraJet/Quartet innovations concern training-specific numerics; our +source-only error bound does not validate equivalent benefits on an RTX 5080. + +## Source-only local execution + + python -m unittest discover -s research/inkling_depth_precision -p 'test_bounds.py' -v + +The instrument in bounds.py computes the stipulated envelope and analytical +token-layer applications. It does not substitute for measured CUDA throughput, +cache costs, state storage, energy, or correct-answer rate. + +## Interfaces with neighboring projects + +- LoopedTransformers: middle/final loop placement, coda lens, sustained + input reinjection and per-step verified serial tasks. +- EvalMath: task-root matched depth comparisons, compute measured separately + from layer-application proxies, selection-exposure receipts. +- BPD: component-specific interventions at block boundaries; calibrated, + dose-matched native shams before mechanistic attribution. + +The proposed mathematics is **derived source-only**, not a new verified neural +finding. Do not open or relabel sealed NOR or unrelated confirmation cohorts. diff --git a/research/inkling_depth_precision/bounds.py b/research/inkling_depth_precision/bounds.py new file mode 100644 index 00000000..ea3ab018 --- /dev/null +++ b/research/inkling_depth_precision/bounds.py @@ -0,0 +1,85 @@ +"""Source-only recurrence error bounds for Inkling-style looped computation. + +This is an analytical instrument, not a claim about measured model Jacobians. +All Lipschitz constants and one-step numerical error bounds must be supplied. +""" + +from __future__ import annotations + +import math +from collections.abc import Sequence + + +def error_envelope( + local_lipschitz: Sequence[float], + additive_error: Sequence[float], + *, + initial_error: float = 0.0, +) -> tuple[float, ...]: + """Upper bound e[t+1] <= L[t] e[t] + eps[t] for a shared-state recurrence.""" + if len(local_lipschitz) != len(additive_error): + raise ValueError("Lipschitz and error sequences require the same length") + if any( + isinstance(x, bool) or not isinstance(x, (int, float)) + or not math.isfinite(x) or x < 0 + for x in (initial_error, *local_lipschitz, *additive_error) + ): + raise ValueError("bounds must be nonnegative finite numbers") + errors = [float(initial_error)] + for local_gain, error in zip(local_lipschitz, additive_error, strict=True): + upper = local_gain * errors[-1] + error + if not math.isfinite(upper): + raise ValueError("bound overflow") + errors.append(upper) + return tuple(errors) + + +def fixed_gate_gain( + gain_coordinates: Sequence[float], + message_lipschitz: float, +) -> float: + """Infinity-norm bound for diag(gamma) M when gamma is held fixed. + + Input-dependent softmax readers and gates require a bound on their full + Jacobian, including normalization, gating and attention effects. + """ + if not gain_coordinates: + raise ValueError("at least one gain coordinate is required") + values = (*gain_coordinates, message_lipschitz) + if any( + isinstance(v, bool) or not isinstance(v, (int, float)) + or not math.isfinite(v) + for v in values + ) or message_lipschitz < 0: + raise ValueError("finite gate coefficients and a nonnegative Lipschitz bound required") + return max(abs(v) for v in gain_coordinates) * message_lipschitz + + +def applied_layer_proxy( + *, + fixed_layers: int, + looped_layers: int, + loop_passes: int, + total_generated_tokens: int, +) -> int: + """Analytical token-layer applications, not measured FLOPs, bytes or joules.""" + args = (fixed_layers, looped_layers, loop_passes, total_generated_tokens) + if any(type(v) is not int or v < 0 for v in args): + raise ValueError("integer nonnegative layer/token counts required") + if loop_passes < 1 or looped_layers < 1 or total_generated_tokens < 1: + raise ValueError("positive loop passes, middle layers and token count required") + return (fixed_layers + looped_layers * loop_passes) * total_generated_tokens + + +def first_certified_depth( + error_bounds: Sequence[float], + tolerance: float, +) -> int | None: + """First finite depth satisfying the supplied STATE error threshold only.""" + if isinstance(tolerance, bool) or not isinstance(tolerance, (int, float)): + raise ValueError("tolerance must be a real number") + if not math.isfinite(tolerance) or tolerance < 0: + raise ValueError("tolerance must be nonnegative finite") + if any(not math.isfinite(v) or v < 0 for v in error_bounds): + raise ValueError("invalid error bounds") + return next((i for i, value in enumerate(error_bounds) if value <= tolerance), None) diff --git a/research/inkling_depth_precision/test_bounds.py b/research/inkling_depth_precision/test_bounds.py new file mode 100644 index 00000000..bdb80e1e --- /dev/null +++ b/research/inkling_depth_precision/test_bounds.py @@ -0,0 +1,40 @@ +"""Exact source-only checks for recurrence bounds, not neural evidence.""" + +from __future__ import annotations + +import unittest + +try: + from research.inkling_depth_precision.bounds import ( + applied_layer_proxy, error_envelope, first_certified_depth, fixed_gate_gain, + ) +except ModuleNotFoundError: + from bounds import applied_layer_proxy, error_envelope, first_certified_depth, fixed_gate_gain + + +class TestDepthPrecision(unittest.TestCase): + def test_contractive_rounding_envelope(self) -> None: + self.assertEqual(error_envelope([0.5] * 3, [0.1] * 3), + (0.0, 0.1, 0.15000000000000002, 0.17500000000000002)) + self.assertLess(error_envelope([0.5] * 10, [0.1] * 10)[-1], 0.2) + + def test_expansive_error_and_distinct_gates(self) -> None: + self.assertEqual(error_envelope([2, 2], [0.1, 0.1]), (0.0, 0.1, 0.30000000000000004)) + self.assertEqual(fixed_gate_gain([0.25, -0.5, 0.1], 2), 1) + self.assertRaises(ValueError, error_envelope, [1, 2], [0.1]) + self.assertRaises(ValueError, fixed_gate_gain, [], 1) + + def test_layer_cost_and_state_threshold(self) -> None: + self.assertEqual( + applied_layer_proxy(fixed_layers=12, looped_layers=12, + loop_passes=3, total_generated_tokens=100), 4800 + ) + self.assertEqual(first_certified_depth([0.5, 0.2, 0.1], 0.2), 1) + self.assertIsNone(first_certified_depth([0.5, 0.2], 0.1)) + self.assertRaises(ValueError, applied_layer_proxy, + fixed_layers=12, looped_layers=12, + loop_passes=0, total_generated_tokens=10) + + +if __name__ == "__main__": + unittest.main()