Skip to content

Tooling: batch exact rows for the quadratic-affine rank witness (8.4x faster check, no new kappa) - #1076

Merged
Mister-Meeseeks merged 1 commit into
CrocSwap:mainfrom
navinor:research/agent-11-verifeng-seed89
Oct 16, 2026
Merged

Mister-Meeseeks merged 1 commit into
CrocSwap:mainfrom
navinor:research/agent-11-verifeng-seed89

Conversation

@navinor

@navinor navinor commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Tooling improvement; no new kappa. Verification engineering (track 85-94, seed 89). Base commit 2921874911956718fcaaaf9396fe8267b3cfa9f0. Prepared with help from opencode.

What changes

scripts/audit_quadratic_affine.py (part of make verify-certificates) builds twelve exact quadratic-affine rank witnesses; its hot path rank_witness in scripts/experiments/quadratic_affine.py constructed each row with one inner call per (row, column) pair (160,135,378 calls in the heavy fixture). This replaces that loop with an exact bit-sliced batched engine (lane-packed character masks, even-lane SWAR zero test, collision-free staged stride-8 gather). inner, the fixtures and all mathematical outputs are unchanged.

Measured on the same host and input (CPython 3.13.15, Windows):

Run Wall time
scripts/audit_quadratic_affine.py at base 89.1 s
scripts/audit_quadratic_affine.py with this change 10.6 s (8.4x)
Row construction, all fixtures, reference vs batched 67.0 s -> 3.56 s

The regenerated certificates/quadratic-affine-vectors.json differs from the base commit in exactly one line: the recorded hash of the edited source file. Every case record, row digest, binary rank and span control is byte-identical.

Verification

sh python3 -B research/quadratic-affine-performance/benchmark.py --out /tmp/qa-benchmark.json

Expected final line: PASS identical rows (14662 rows, 0 mismatches); certificate equals committed; controls: odd-lane false positive demonstrated, dropped gather stage detected.

All 14,662 witness rows (including all 12,623 rows of the heavy fixture) are compared against the verbatim base-commit reference engine; the full certificate is recomputed and required to equal the committed file, and the committed base-commit snapshot evidence/base-certificate.json must differ only in the edited source's hash. research/quadratic-affine-performance/test_engine.py (11 tests) adds brute-force primitive comparisons with borrow-chain adversaries, randomized family samples, unchanged rejection paths, and negative controls (odd-lane SWAR false positive; dropped gather stage; one-bit row corruption changing the digest). The suite was red-green verified: a deliberately dropped gather stage fails 5 tests. tests/test_quadratic_affine.py passes unchanged and python3 -B scripts/verify_selected_result.py still reports the selected kappa.

Overlap

PR 752 (Curtis Dransfield, seed 92) reached this hotspot first with a non-invasive packed-lane adapter (73.4 s -> 10.96 s on macOS arm64). Credit to them. This PR is an independent second implementation that additionally (1) wires the speedup into the shipped check so the default make verify-certificates run gets faster, (2) machine-checks the one-line certificate diff against a committed base-commit snapshot, and (3) corroborates the packed-lane conclusion from a different lane design with red-green verified negative controls.

Scope

No certificate content, bound, kappa value, patch, generator, proof supplement, pinned source or upstream/ file changes; only scripts/experiments/quadratic_affine.py, its regenerated certificate (one line), and the evidence package research/quadratic-affine-performance/. This is a finite-check speedup, not a formal proof of any theorem. The unchanged GF(2) elimination is now the runtime floor. Full make verify, the selected cold replay, Lean and remote Linux CI were not run; only the affected checks above were. Apache-2.0.

…ank witness (no new kappa)

Replace the per-pair inner loop in scripts/experiments/quadratic_affine.py
rank_witness with an exact bit-sliced batched orthogonality engine:
lane-packed character masks, even-lane SWAR zero test, collision-free
stride-8 gather. scripts/audit_quadratic_affine.py (make verify-certificates)
drops from 89.1s to 10.6s on the same host; all 14,662 witness rows are
byte-identical to the base-commit reference engine and the regenerated
certificate differs only in this source file's recorded hash.

Evidence and negative controls in research/quadratic-affine-performance
(differential benchmark, 11 tests, red-green verified). No mathematical
claim, bound, or kappa value changes. Prepared with help from opencode.
@Mister-Meeseeks

Copy link
Copy Markdown
Contributor

100-PR batch review at cced22b95fb5b485da05b8187c8a9754b6a8c85a.

This remains open after scoped triage. Next review step: Engine regressions pass and fixtures 0–10 compare exactly, but the full benchmark reached 180 seconds during the heavy fixture. Complete all 14,662 row comparisons and the fresh certificate/hash-only comparison before changing the default checker.

This is a specific continuation point, not a rejection or a request to redo already recorded checks. Completed local evidence is retained separately from outstanding whole-head obligations.

Batch review, attribution and evidence. Thank you for the contribution.

@navinor

navinor commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Continuation run for the outstanding whole-head obligations, at head cced22b95fb5b485da05b8187c8a9754b6a8c85a, per the continuation point in #1076 (comment) and the batch review doc https://github.com/CrocSwap/integer-mult-bounds/blob/main/docs/research/community-efficient200-review.md. Both outstanding checks are complete. No code was changed.

Environment: Windows 11, CPython 3.13.15. The python3 alias on this host is the broken Microsoft Store stub, so commands were run as python -B ... with the same interpreter the README's python3 -B refers to. All runs were blocking foreground runs under a 60-minute budget; the 180-second figure in the batch review is a triage budget, not a proof criterion.

1. Full differential benchmark — all 14,662 row comparisons

python -B research/quadratic-affine-performance/benchmark.py --out %TEMP%\qa-1076-scratch\benchmark.json

Total wall time 103.3 s. Per-fixture row comparisons of the shipped batched engine against the verbatim base-commit reference (inner per pair), with per-fixture wall times:

fixture rows equal reference batched
0 3/3 0.000 s 0.000 s
1 3/3 0.000 s 0.000 s
2 5/5 0.000 s 0.000 s
3 23/23 0.001 s 0.000 s
4 23/23 0.001 s 0.000 s
5 45/45 0.002 s 0.000 s
6 383/383 0.054 s 0.006 s
7 383/383 0.055 s 0.007 s
8 765/765 0.200 s 0.018 s
9 23/23 0.000 s 0.000 s
10 383/383 0.049 s 0.005 s
11 (heavy) 12623/12623 68.358 s 3.454 s

Totals: 14,662 rows compared, 0 mismatches, including every one of the 12,623 rows of the heavy fixture that the earlier run reached its 180-second cap on. Row-construction totals across all fixtures: reference 68.719 s vs batched 3.491 s. The heavy fixture's full rank_witness (batched rows plus the unchanged GF(2) elimination) took 17.77 s on this host, rank 12623. Final lines of the run:

heavy rank_witness (batched engine): 17.77s, rank 12623
certificate equals committed; base-commit certificate differs only in: scripts/experiments/quadratic_affine.py
PASS identical rows (14662 rows, 0 mismatches); certificate equals committed; controls: odd-lane false positive demonstrated, dropped gather stage detected

Both negative controls behaved as required: the odd-lane SWAR false positive was demonstrated on a borrow chain, and a dropped gather stage was caught by the same row comparison. Timings above are measurements on this host, not acceptance thresholds; they differ from the host recorded in research/quadratic-affine-performance/README.md.

2. Fresh certificate recomputation and hash-only comparison

The certificate was recomputed through the package's own flow (audit_quadratic_affine.certificate() serialized with prepare_layers.serializable) and compared with the committed certificates/quadratic-affine-vectors.json:

  • The recomputed certificate equals the committed certificate byte for byte.
  • The committed base-commit snapshot research/quadratic-affine-performance/evidence/base-certificate.json differs from the recomputed certificate in exactly one line — the recorded hash of the edited source file scripts/experiments/quadratic_affine.py:
-    "scripts/experiments/quadratic_affine.py": "8f9252bd092eb14779997c6767e090377e91f4d57e6526e9840ae0dd7dcc8f9c",
+    "scripts/experiments/quadratic_affine.py": "124e33558b232aa7c684c332f2902dc437c0959fd13ce4b711f5ef923ed75a6f",

No other certificate field differs. The same one-line diff is what git diff 2921874911956718fcaaaf9396fe8267b3cfa9f0 HEAD -- certificates/quadratic-affine-vectors.json shows at the head under review.

3. Regression re-runs

python -B research/quadratic-affine-performance/test_engine.py

11 tests pass in 1.28 s (wall 1.7 s): Ran 11 tests ... OK.

python -B scripts/audit_quadratic_affine.py

Wall 13.2 s, output: PASS: twelve exact quadratic-affine core rejections, including Gaussian rank-two labels.

Obligations from the batch review doc

Now satisfied for #1076:

  • All 14,662 row comparisons completed with 0 mismatches, including the full heavy fixture; the earlier 180-second triage run left this outstanding and implied no conclusion.
  • The fresh certificate equals the committed certificate, and the committed base-commit snapshot differs from it only in the recorded hash line of scripts/experiments/quadratic_affine.py — the "one-line hash-only diff" claim is now machine-checked end to end.
  • The direct reference comparison and failure controls that the batch review doc requires before considering a default-checker change are recorded above.

Still open, and not claimed here:

  • Changing the default checker remains gated on maintainer acceptance; this run produces evidence for that decision and does not make it.
  • No formal proof or theorem claim: this is finite evidence for a finite check. Per the batch review doc, no formalization is accepted from a Python source check alone. No kappa value, bound, certificate content, or mathematical claim changes.
  • Timing ratios are measurements on one host, not independently claimed speedup thresholds.

Attribution: Aaron Wang / navinor, with help from opencode.

cursor Bot pushed a commit to VictorLiwentao/integer-mult-bounds that referenced this pull request Oct 15, 2026
… hotspot

Identity/speedup evidence stands (~9× CrocSwap#752 packed lanes). Do not open a
competing CrocSwap PR while navinor CrocSwap#1076 rewrites the same production path.
@Mister-Meeseeks
Mister-Meeseeks merged commit c9d9a74 into CrocSwap:main Oct 16, 2026
60 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants