Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
177 changes: 177 additions & 0 deletions research/paired26-integer-dot-replay/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
# Faster complete paired26 replay with integer dot products

This contribution was produced by Nick Petalas. Apache-2.0.

Claim type: scoped implementation-equivalence proof, exact finite conformance
and local performance evidence. The complete primary command from
[Andrey Mas / an664's PR1624](https://github.com/CrocSwap/integer-mult-bounds/pull/1624)
takes **33.77% less median wall time locally**, from 0.628150 s to 0.415995 s.
Nine fresh-process pairs alternate their execution order. All eighteen commands
succeed with identical complete stdout and zero failures. Discovery stopped at
the first verified improvement. This is new implementation work. The predecessor's
decoder minimum and classification are cited results, not audit deliverables.

## Exact change and proof

The frozen source and certificate remain unchanged. `replay.py` authenticates
both SHA256 pins before executing the exact source bytes, then replaces only
its eight-coordinate rational `dot`. It runs the original default entry point,
including every mathematical check and rejection control. The accelerated
command accepts no arguments and cannot select the certificate-writing option.
It imports no predecessor bytecode.

For an integer/Fraction row v, let q(v) be the positive least common multiple
of its reduced denominators, and put
n(v)[i] = numerator(v[i]) q(v) / denominator(v[i]). Then

```text
sum_i v[i] w[i] = sum_i n(v)[i] n(w)[i] / (q(v) q(w)).
```

Python integer arithmetic is exact. One final Fraction reduction replaces the
repeated rational products and additions. Integer-only inputs return an integer,
matching the original type. Other widths/types use the original function,
including its shape-error behavior.

Row conversion is reused only for the identical container with all eight scalar
objects identical to its saved snapshot. Built-in integers and Fractions are
immutable. Mutating a row therefore causes conversion again, including a change
from an integer to an equal Fraction. Cached entries retain their owners, so
object IDs cannot be recycled while cached. At most 1,024 rows are cached;
capacity clearing changes only conversion work. No dot-product result is cached.
Every call still computes all eight products and their sum.

## Conformance evidence

The new verifier compares all **189,904 reached dot values and exact types**
with the original throughout the complete primary computation. Both complete
computed certificates agree and pass the original strict comparison against the
saved certificate. Its canonical computed-certificate SHA256 is
`f975a374d2d0ce6346ae4eaf053dfd049185fdf2dfe731f1b175de77e99e5fc1`.
The new route performs 12,369 conversions, 367,439 row-cache hits and twelve
capacity clears, with zero reached fallbacks. Both routes retain the fourteen
original rejection controls and two additional complex controls.

Additional conformance covers 65,536 rational vector pairs, ten fallback widths,
three fallback types, five in-place mutations and 2,049 capacity inputs. Eight
rejecting controls cover two bad shapes, both source pins, a wrong denominator,
wrong integer numerators, an oversized source and the writer option. Explicit
exceptions remain active under `-O`.
The unchanged default workload still includes all 511 functional records,
1,716 subsets, four decoder examples, full all-pairs identities, actual support
ranks and complete saved-certificate comparison. The separate predecessor
`audit.py` is unchanged and outside this optimization.

## Local timing evidence

CPython 3.12.15, macOS 27.0.1 arm64, eighteen logical CPUs. The load average
near the run was 1.76, 2.16, 2.11. Other applications remained active. Runs were
serial and alternating. Both commands use `-I -W error -B`, identical source and
certificate bytes and the same interpreter. Every timed region includes fresh
process startup and the complete default replay/certificate comparison. The new
route also includes authentication and cache initialization.

| Pair | Original seconds | Integer seconds |
|---:|---:|---:|
| 1 | 0.620465667 | 0.415328333 |
| 2 | 0.634360125 | 0.568668250 |
| 3 | 0.621159000 | 0.418008917 |
| 4 | 0.627842541 | 0.415584500 |
| 5 | 0.630763416 | 0.418947291 |
| 6 | 0.624511541 | 0.412711708 |
| 7 | 0.634765208 | 0.415995042 |
| 8 | 0.631476833 | 0.416269375 |
| 9 | 0.628149917 | 0.415403291 |

The ranges are 0.620465667 to 0.634765208 s and 0.412711708 to 0.568668250 s.
Every pair improves, including the slower second candidate run. Complete stdout
SHA256 is
`81d9b07342fe4de43ffa4acc83a5a33afedefd11939410d2d3d7be07edd8f10b`.
These are local observations, not a portable speed guarantee or CI timing claim.

An untimed discovery profile places 2.015 of 2.474 profiled seconds in `dot`,
with Fraction multiplication/addition dominating. The saving is below that
81.45% share. An untimed candidate profile leaves 0.817 of 1.357 profiled seconds
in the replacement dot, including 0.487 s in row conversion/snapshot checking.
Profiles are excluded from wall-time reporting. Final Fraction construction and
all unchanged certificate work remain. There is no cached certificate or early
acceptance.

## Reproduction

From the repository root, standard library only:

```sh
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -I -W error -B research/paired26-integer-dot-replay/replay.py
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -I -W error -B research/paired26-integer-dot-replay/verify.py
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -I -O -W error -B research/paired26-integer-dot-replay/verify.py
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/research_package.py --package research/paired26-integer-dot-replay
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/check_research_commit.py --package research/paired26-integer-dot-replay --check-source-history
```

Any CPython 3.12 executable can replace the displayed path. Expected markers
are the unchanged `PASS_FIXED_PAIRED26_MINIMUM_62`, `PASS_PAIRED26_INTEGER_DOT`,
`PASS_REGISTERED_RESEARCH_PACKAGE` and `PASS_RESEARCH_COMMIT_BYTES`.
For timings, run `benchmark.py --pairs 9 --output /absolute/fresh/outside.json`
with that interpreter and flags. `verify.py --receipt /absolute/fresh/outside.json`
generates a hash-bound receipt. Default replay writes no artifacts.

## Sources, scope and limitations

Base main is `7c49fe32c55de02c2c873655c804b16e4c3fef0a`, priority revision 8.
[TASK.json](TASK.json) refines replay-runtime to one complete default command.
[SOURCES.json](SOURCES.json) pins exact inputs and provenance. Both input files
are declared in [VERIFY.json](VERIFY.json) for CI invalidation; any byte change
fails the adapter's hash boundary before source execution.

Credit Andrey Mas / an664 / PR1624 for the original proof, program and
certificate; woklerx / PR1020 and PR1077 for the puncture, first pair and prior
decoder; Hanson Sun / bbMisk / PR1521 for the completion question;
themilkman216 / PR968 and DreamingOfClouds / PR717 for the geometry/billing model;
and the retained E8 lineage. Josie Elliston's PR1663 is a separate mathematical
audit, cited as prior work rather than replayed here. Common-denominator
arithmetic and caching are standard. The new result is the source-bound adapter,
equivalence contract and measured complete-command saving.

Earlier exact-arithmetic implementations include Ali Romman's
[PR5002](https://github.com/CrocSwap/integer-mult-bounds/pull/5002) and Nick
Petalas's [PR6272](https://github.com/CrocSwap/integer-mult-bounds/pull/6272)
and [PR6281](https://github.com/CrocSwap/integer-mult-bounds/pull/6281).
They already use denominator clearing on other complete commands. This adapter's
specific contract reuses scalar-row normalization across calls while detecting
in-place mutations, and preserves the complete scalar value and return type.
Those earlier product implementations are not imported or extended here.

No new decoder optimum, physical supplier, kappa, selected-frontier change,
complete multiplication theorem, independent human review or formal proof-kernel
acceptance is claimed. All five inherited framework assumptions remain.
No Lean, Docker, selected cold replay or separate predecessor audit was run.

Local registered normal and optimized conformance commands passed in 1.870 s
and 1.953 s respectively, below their sixty-second timeouts. The package
metadata/registered replay passed. Publication-byte/source-history and exported
standalone checks are recorded in the PR body after the publication commit.
Hosted CI is pending at initial publication.

Power of Ten inspection bounds numerical loops by eight coordinates, 1,024
cached rows, the fixed test corpus, at most fifteen timing pairs and a 30-second
subprocess timeout. Functions stay below sixty lines. Source reads are capped
at 1 MiB. Source pins, arithmetic equality, capacity and full fixture coverage
are checked with exceptions. Python integer/Fraction allocation is a managed
runtime deviation from fixed allocation. Live cached collections are bounded;
allocator internals and arbitrary external scalar bit lengths are not measured.
Executing authenticated source and replacing its `dot` callable are explicit
deviations from static dispatch/metaprogramming restrictions, constrained to
one SHA256-pinned module and one function. The inherited verifier stays frozen.
A native fixed-allocation implementation and separate static analyzer are not
supplied. Warning-strict normal/optimized execution and AST inspection are used.

## Open next questions

Can the same representation improve another named complete rational replay?
Profile that command first, then authenticate its sources and check all reached
widths, scalar types, mutation behavior and output. Different denominators and
mutation patterns require new evidence. Neither the percentage nor this
conformance certificate transfers automatically. This follow-on is unclaimed.

[Advance claim](https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-19371170).
60 changes: 60 additions & 0 deletions research/paired26-integer-dot-replay/SOURCES.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"schema_version": 1,
"base_commit": "7c49fe32c55de02c2c873655c804b16e4c3fef0a",
"files": [
{
"path": "certificates/selected-result.json",
"usage": "provenance",
"git_blob": "d59b5035e7b4cbaa9d688a1d32dd0d6eb79c466a",
"sha256": "9b8d0eea95b3bf0dfcb7938a732a6439b87a2685dec2a5ab9e525b3b34debbfa"
},
{
"path": "docs/research/agent-task-catalog.json",
"usage": "provenance",
"git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec",
"sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81"
},
{
"path": "research/complex-paired26-completion/certificate.json",
"usage": "input",
"git_blob": "5d6d2095b6536595ffd2999124636a9f45c90192",
"sha256": "18103be5548d9558dfc49cc90bc9308aab13e48e7f99d30a45fd90cec7c2776d"
},
{
"path": "research/complex-paired26-completion/verify.py",
"usage": "input",
"git_blob": "f59630a3261c914b65af6ed9e2d19a43ac9ba522",
"sha256": "34f20844f5184a66f2217b481c0cc82ed6a9eb85e97d3ec53eec36b641d2b07d"
},
{
"path": "research/complex-paired26-completion/README.md",
"usage": "provenance",
"git_blob": "6712df1150d88a8b5ecc51871e8919fac93766e3",
"sha256": "ba2ebeb515190b7279ee490cd2ed450c9a48e91a22602ac7e384b9840367c0bc"
},
{
"path": "research/complex-paired26-completion/ATTRIBUTION.md",
"usage": "provenance",
"git_blob": "bcac7c7d87574e88a3b2b1884964d8235606a415",
"sha256": "30c8dfdf13e5b3026e26ecb36288546eebe21f89a3075dc39c236baa09d7307d"
},
{
"path": "research/complex-paired26-completion/proof.md",
"usage": "provenance",
"git_blob": "4a89efa74126836857c73fddc48147b0446ec4d7",
"sha256": "0305c955d39a0b11b9e3a3b58606882ceb85daac765050583645765c7a35fad3"
},
{
"path": "research/complex-paired26-completion/audit.py",
"usage": "provenance",
"git_blob": "80c5269ed29c9f73d1e0b8819e612d907e3b211b",
"sha256": "5e39772867f69faaf95c4a9b429129485c462f1daedc1ce5b311dd542a5cb535"
},
{
"path": "research/complex-paired26-completion/LICENSE",
"usage": "provenance",
"git_blob": "d645695673349e3947e8e5ae42332d0ac3164cd7",
"sha256": "cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30"
}
]
}
61 changes: 61 additions & 0 deletions research/paired26-integer-dot-replay/TASK.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"schema_version": 1,
"task_id": "replay-runtime",
"priority_revision": 8,
"base_commit": "7c49fe32c55de02c2c873655c804b16e4c3fef0a",
"original_card": {
"id": "replay-runtime",
"question": "Can one measured replay bottleneck be sped up without dropping coverage?",
"starting_points": [
"scripts/run_isolated_tests.py",
"scripts/verify_replay_coverage.py",
"certificates/selected-result.json"
],
"methods": [
"Profile one isolated replay and optimize the measured bottleneck.",
"Design source-bound reuse with explicit dependency invalidation and negative controls."
],
"acceptance_gate": "Report before/after wall time on the same fixture, retained checks and invalidation behavior.",
"first_step": {
"command": [
"python3",
"-B",
"scripts/research_selected_baseline.py"
],
"expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY",
"inspect": "Resolve the current selected review, separate complex/ordinary BIT/admitted BIT/outer budgets, and compare the card against live handoffs before starting. Historical ceilings require exact source/model equivalence.",
"scope": "Source-binding orientation only; not a scientific replay or all-size proof. Materialize selected inputs if this checkout is sparse."
},
"first_experiment": "Measure one unchanged fixture, preserve check coverage, and test one optimization with invalidation controls.",
"bottleneck_link": "Faster trustworthy replays increase review throughput and let mechanism candidates be checked sooner.",
"allowed_variations": [
"Profile one stage or design one source-bound cache boundary."
],
"scope_change_triggers": [
"Skipping coverage or comparing different fixtures to claim speedup."
],
"overlap_terms": [
"replay runtime",
"cache invalidation",
"isolated tests"
]
},
"scope_status": "refined",
"actual_scope": "Accelerate the complete default primary command of PR1624 by exact common-denominator integer dot products, preserving every reached dot value/type, complete certificate and original rejection control.",
"scope_change_reason": "One source-bound fixture and one measured arithmetic bottleneck refine the replay-runtime card. This is implementation work, not a mathematical audit of PR1624.",
"bottleneck_link": "Faster complete exact replays reduce the cost of checking construction candidates; no kappa or supplier improvement is inferred.",
"budget_minutes": 60,
"stop_rule": "Stop after the first verified end-to-end improvement. At most two implementation candidates; no expansion of the predecessor theorem.",
"outcome": "completed",
"evidence": "Nine alternating fresh-process pairs: medians 0.628149917 s and 0.415995042 s, 33.774561% less wall time. Complete stdout equal with zero failures. Full conformance compares 189904 reached dot values/types and both complete certificates; 65536 rational cases, mutation/capacity/fallback controls and eight rejecting controls pass.",
"author": "Nick Petalas",
"ai_assistance": "Independent human and formal proof-kernel review are unclaimed.",
"open_questions": [
{
"question": "Can the same integer-row representation improve another named complete rational replay?",
"why_it_matters": "Exact arithmetic replay can dominate the cost of screening new constructions.",
"first_step": "Profile that complete command and enumerate its reached widths/types before choosing a bounded adapter.",
"blocked_by": "Different mutation patterns, denominator growth and output contracts need new source-bound conformance and timing evidence."
}
]
}
37 changes: 37 additions & 0 deletions research/paired26-integer-dot-replay/VERIFY.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"schema_version": 1,
"status": "ready",
"python": "3.12",
"requirements": [],
"inputs": [
"research/complex-paired26-completion/certificate.json",
"research/complex-paired26-completion/verify.py"
],
"commands": [
{
"argv": [
"{python}",
"-I",
"-W",
"error",
"-B",
"{package}/verify.py"
],
"timeout_seconds": 60,
"checks": "Compare all 189904 reached dot values and types, both complete certificates and the stored certificate; retain 14 original plus 2 complex controls; 65536 rational pairs, mutation/capacity/fallback and eight rejecting controls."
},
{
"argv": [
"{python}",
"-I",
"-O",
"-W",
"error",
"-B",
"{package}/verify.py"
],
"timeout_seconds": 60,
"checks": "Compare all 189904 reached dot values and types, both complete certificates and the stored certificate; retain 14 original plus 2 complex controls; 65536 rational pairs, mutation/capacity/fallback and eight rejecting controls."
}
]
}
Loading