Skip to content

Tooling: 1.13x faster exact stage-pair audit with identical receipts - #824

Merged
Mister-Meeseeks merged 2 commits into
CrocSwap:mainfrom
navinor:research/seed92-verification-engineering
Oct 14, 2026
Merged

Mister-Meeseeks merged 2 commits into
CrocSwap:mainfrom
navinor:research/seed92-verification-engineering

Conversation

@navinor

@navinor navinor commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

The historical stage-pair audit spends most of its runtime in exact rational arithmetic. This replaces two wasteful patterns with identical operations, preserving every receipt and rejection check. Tooling improvement; no new kappa.

Changes

  1. scripts/audit_fused_block.py — rational_rank skips redundant Q(x) construction when an entry is already a Fraction. Q(Q) returns the same value after needless normalization.
  2. scripts/audit_stage_pair.py — modular_rank converts denominators through a cached _mod_inv(d, prime) helper (same pow(d, -1, prime) call) instead of one fresh pow() per matrix entry. lru_cache does not cache exceptions, so a non-invertible denominator raises the same ValueError.

No matrix, pivot order, stopping rule, candidate list, or rejection predicate was touched.

Measurements

Fresh-process timings of certificate() (compute only), CPython 3.12.14 / Windows, stdlib only. OS caches not flushed; host not isolated. Timing is descriptive, not a pass threshold.

run original (s) optimized (s)
1 16.63 14.31
2 15.79 13.96
3 15.57 13.64
median 15.79 13.96

Median 15.79 s to 13.96 s: 1.13x faster, 11.6% less wall time. Microbenchmarks: rational_rank 3.05x on 50 sampled frames; modular conversion 1.42x on 20 sampled matrices.

python3 -B research/stage-pair-performance/benchmark.py --rounds 3

Expected: PASS_IDENTICAL_STAGE_PAIR_RECEIPTS.

Validation

  • Full certificate() output identical to certificates/stage-pair-audit.json in every field except the single expected source_sha256 entry for the edited audit_stage_pair.py (rank sum 8684, 64 candidates, 6 local improvements).
  • audit_fused_block and audit_joint_frames certificates regenerate byte-identical.
  • New tests/test_stage_pair_performance.py: 6 tests compare optimized helpers against verbatim base-commit references on edge cases (empty, zero, singular, non-square, ints vs Fractions, 30-digit numerators, primes 101/103), including the ValueError path. Existing suites pass: test_stage_pair (8), test_fused_block (7), test_joint_frames (8), test_quadratic_affine (4).
  • Full make verify and the selected-supplier cold replay were not rerun for this isolated historical-checker change. upstream/ untouched; selected frontier unchanged.

Provenance

  • Contributor: Aaron Wang (navinor).
  • Prepared with substantial AI assistance (Muse Spark via OpenCode). No independent human peer review claimed.
  • Base: 7ee02b7c96d85f22b38d28bd7ed49bb8c1aeb261. OS-random assignment seed 92, verification-engineering track. Claim, candidates, and overlap review in research/stage-pair-performance/SELECTION.json. No open PR covers the stage-pair audit (checked through PR 823).

@Mister-Meeseeks

Copy link
Copy Markdown
Contributor

100-PR batch review at 2b342526350a3c36936feb7f3f50669fad2770b1.

Merged to main, preserving the original contributor commits and package attribution.

Reviewed scope: Fraction reuse and modular-inverse caching in two rank checkers; focused reference-equivalence and failure regressions.

The pinned scoped command passed; the batch ledger contains its command, input hashes, environment and log. This incorporates the research/tooling contribution and does not change the selected κ or discharge the inherited multiplication-theorem assumptions.

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

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