Skip to content
Merged
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
2 changes: 1 addition & 1 deletion certificates/inplace-side.json
Original file line number Diff line number Diff line change
Expand Up @@ -5609,7 +5609,7 @@
"docs/research/inplace-side.md": "c228f131d95f3ea348455c13378c19ed6e3c75af7e14cf68ea0ada445ab3ac72",
"scripts/audit_inplace_side.py": "16d295f9f9250d35f6f1de2843d5e13c7adbf88d595ebcd0b65b00d1a938acd9",
"scripts/experiments/core_limits.py": "a31a27cc24cf0349a507d1141a2b965ea25f1c60f355d7e13c581305a12d3a43",
"scripts/experiments/inplace_side.py": "4e7cb3df2e263f6c7f5907c55e3ee04c08926e6dbc984bbda1722a27b0a48ff6",
"scripts/experiments/inplace_side.py": "4397b84f3ac52554bf14303171410a2799af0bf8dae11ec64594bb5c011e93a2",
"scripts/experiments/inplace_side_witnesses.json": "90fe710f5daa35cc9e4892b29d712d66110b7b2b4c404da95a960ea7041618b9"
},
"status": "SPECIFIED IN-PLACE FAMILY EXCLUDED; NO STRONGER KAPPA",
Expand Down
121 changes: 121 additions & 0 deletions research/inplace-side-performance/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Faster historical inplace-side prefix replay

**Tooling improvement; no new kappa.** The historical
`scripts/experiments/inplace_side.py:verify_prefix` check rejects a specified
n-role Gauss–Jordan side family using three pinned witnesses (`h = 42, 46, 50`).
Each elimination column previously rebuilt `sorted(unused)` to locate the least
unused row with the pivot bit set. The production checker now scans an unused
flag array from index 0 and tests bits with a column mask. The lexicographic
rule, XOR updates, switch witnesses, deficit arithmetic and every receipt field
are unchanged.

The selected frontier, `upstream/` and the mathematical rejection in
[docs/research/inplace-side.md](../../docs/research/inplace-side.md) are not
reopened. Only the source pin for `scripts/experiments/inplace_side.py` changes
inside `certificates/inplace-side.json`.

## Reproduce

Python **3.12**, standard library only, from the repository root:

```sh
python3.12 -I -B research/inplace-side-performance/verify.py
python3.12 -I -O -B research/inplace-side-performance/verify.py
python3.12 -I -B -m unittest tests.test_inplace_side tests.test_inplace_side_performance -v
python3.12 -B scripts/research_package.py --package research/inplace-side-performance --check-only
python3.12 -B scripts/research_package.py --package research/inplace-side-performance
```

Expected verifier line:

```text
PASS_INPLACE_SIDE_PREFIX_FAST witnesses=3 h=[42, 46, 50] paths=[151, 415, 767] ... no_new_kappa
```

Expected registered replay:

```text
PASS_REGISTERED_RESEARCH_PACKAGE research/inplace-side-performance outcome=completed
```

Normal verification is read-only. To regenerate the certificate after editing the
production source:

```sh
python3.12 -I -B research/inplace-side-performance/verify.py --write-certificate
```

Before/after wall times (descriptive; not a pass gate):

```sh
python3.12 -I -B research/inplace-side-performance/benchmark.py --rounds 5
```

Expected: `PASS_IDENTICAL_INPLACE_PREFIX_RECEIPTS`. Samples are retained in
[RESULT.json](RESULT.json). On this Linux host / CPython 3.12.3, five alternating
fresh-process pairs gave median **17.061 s → 5.466 s (3.12×)** for the three
pinned witnesses. Timing is descriptive, not a correctness gate.

## Why the receipts stay identical

For each column `col`, the original code selected

```text
min{ i in unused : rows[i] has bit col }
```

by materializing `sorted(unused)` and taking the first hit. Scanning
`i = 0, 1, …` over a boolean unused table and stopping at the first hit yields
the same index, because the integers are totally ordered. Column tests
`rows[i] & (1 << col)` equal `rows[i] >> col & 1` on these nonnegative row
masks. The subsequent row-XOR updates therefore run on the same pivot sequence
and produce the same residual matrix, the same certified nonorthogonal path
list and the same deficit upper bound.

[baseline.py](baseline.py) is a byte-identical copy of
`scripts/experiments/inplace_side.py` at base
`0b1cccf86e2f5132ed286a26ef0a681a495740ea` (blob
`db3de6f1d962ccc3a4eae31f83c72bba995ba44e`). The verifier compares every field
of every witness receipt against that baseline, checks shared rejection
behavior, rejects a greatest-unused mutant on all three witnesses, and requires
the working certificate to differ from the base certificate only in the single
`inplace_side.py` source pin.

## Task card, overlap and limits

Chooser seed `1cd1f71746c2d200dd617bc3dd17d8a6` drew `bit-mechanisms`; live
helper-contract and register-model surfaces were saturated. Expertise override
to `replay-runtime` (verifier-engineering). Scope **refined** to this fixed
historical screen inside `make verify-certificates`.

Closest priors (different objects; no code reused here):

- [CrocSwap #756](https://github.com/CrocSwap/integer-mult-bounds/pull/756) —
packed-column balanced-Fano replay (2.91×) on a different checker.
- [CrocSwap #1584](https://github.com/CrocSwap/integer-mult-bounds/pull/1584) —
finite-bit block-core frame interning.
- [CrocSwap #1076](https://github.com/CrocSwap/integer-mult-bounds/pull/1076) /
[#1075](https://github.com/CrocSwap/integer-mult-bounds/pull/1075) —
quadratic-affine / quadratic-code tooling.
- Local `find_overlap.py` for `inplace side` / `inplace_side` / `verify_prefix`
reported no competing open PR on this object at refresh time.

Limits: timing is host-descriptive; OS caches were not flushed. Full
`make verify`, selected-supplier cold replay, Lean and multiplication-theorem
obligations were not rerun for this isolated historical-checker change.

## Open next questions

- Can the same least-unused scan replace `sorted(unused)` inside `compile_side`
without changing gate lists on `h = 6, 10` and, if identical, on `h = 50`?
- Should CI grow a soft regression timer for this screen, or keep RESULT.json
descriptive only?

## Credit

Douglas R. Colkitt authored the inplace-side rejection, witnesses and original
checker. Prepared by Wentao Li
([VictorLiwentao](https://github.com/VictorLiwentao),
[@Is__Victor](https://x.com/Is__Victor), wentaol4@illinois.edu)
with substantial AI assistance, under Apache-2.0. No independent human
peer-review or formal proof-assistant claim.
62 changes: 62 additions & 0 deletions research/inplace-side-performance/RESULT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"ai_assistance": "Substantial AI assistance for profiling, implementation, packaging, benchmarking and writing. Not independent human peer review.",
"base_commit": "0b1cccf86e2f5132ed286a26ef0a681a495740ea",
"baseline_seconds": [
16.747456939999665,
17.098737376999907,
17.06069083300008,
16.890133087999857,
17.154922305999662
],
"engines": {
"baseline": "research/inplace-side-performance/baseline.py",
"optimized": "scripts/experiments/inplace_side.py"
},
"environment": {
"implementation": "CPython",
"isolated_host": false,
"os_caches_flushed": false,
"platform": "Linux-6.12.94+-x86_64-with-glibc2.39",
"python": "3.12.3 (main, Aug 31 2026, 10:18:26) [GCC 13.3.0]"
},
"fixture": "scripts/experiments/inplace_side_witnesses.json",
"medians": {
"baseline": 17.06069083300008,
"optimized": 5.465907218000211,
"speedup": 3.121291700088902
},
"no_new_kappa": true,
"optimized_seconds": [
5.465907218000211,
5.394471960999908,
5.672483955000189,
5.443477510999855,
5.647890871000072
],
"receipt_fields_compared": [
"all_internal_rational_frames_allowed",
"bad_endpoints",
"certified_nonorthogonal_paths",
"deficit_upper",
"disjoint_switches",
"excess_per_invocation_lower",
"h",
"n",
"no_positive_deficit",
"prefix_columns",
"scope"
],
"rounds": 5,
"scope": "Fixed historical inplace-side prefix check on the three pinned witnesses (h=42,46,50). Not a selected-supplier cold replay or multiplication runtime.",
"source_sha256": {
"baseline.py": "4e7cb3df2e263f6c7f5907c55e3ee04c08926e6dbc984bbda1722a27b0a48ff6",
"scripts/experiments/inplace_side.py": "4397b84f3ac52554bf14303171410a2799af0bf8dae11ec64594bb5c011e93a2",
"scripts/experiments/inplace_side_witnesses.json": "90fe710f5daa35cc9e4892b29d712d66110b7b2b4c404da95a960ea7041618b9"
},
"status": "PASS_IDENTICAL_INPLACE_PREFIX_RECEIPTS",
"witness_h": [
42,
46,
50
]
}
48 changes: 48 additions & 0 deletions research/inplace-side-performance/SOURCES.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"schema_version": 1,
"base_commit": "0b1cccf86e2f5132ed286a26ef0a681a495740ea",
"files": [
{
"path": "docs/research/agent-task-catalog.json",
"usage": "provenance",
"git_blob": "06c96f5579bb67ed1b86d334e78fbed7da6945f1",
"sha256": "6686ad58f1fbdbc87134a78901b60fd53a20d3984355e91defbbebc9e9fa8075"
},
{
"path": "certificates/selected-result.json",
"usage": "provenance",
"git_blob": "ae6a99f28aa468649eb66a361e764d769363bf11",
"sha256": "10b9e340fd8e354a37a0c4813c90e5de1dd42044b5f6aca4a3fc5a42b685fa32"
},
{
"path": "certificates/inplace-side.json",
"usage": "provenance",
"git_blob": "8d3240c59c26c1839c2cf7a9b063fd30cbbe5a84",
"sha256": "1a2020c346e7d039e924a8c782dc6b3f0e94039eb1bec2b2644fc3de9d41ccdb"
},
{
"path": "docs/research/inplace-side.md",
"usage": "provenance",
"git_blob": "a0bb57cacd27d7c2921f6060f59b42aeb1355311",
"sha256": "c228f131d95f3ea348455c13378c19ed6e3c75af7e14cf68ea0ada445ab3ac72"
},
{
"path": "scripts/audit_inplace_side.py",
"usage": "provenance",
"git_blob": "2e9108178ee2e07d17f52d7cf79e079e91ba5feb",
"sha256": "16d295f9f9250d35f6f1de2843d5e13c7adbf88d595ebcd0b65b00d1a938acd9"
},
{
"path": "scripts/experiments/inplace_side.py",
"usage": "provenance",
"git_blob": "db3de6f1d962ccc3a4eae31f83c72bba995ba44e",
"sha256": "4e7cb3df2e263f6c7f5907c55e3ee04c08926e6dbc984bbda1722a27b0a48ff6"
},
{
"path": "scripts/experiments/inplace_side_witnesses.json",
"usage": "input",
"git_blob": "9d9970245a71705da7b84122a8be5b44755b5005",
"sha256": "90fe710f5daa35cc9e4892b29d712d66110b7b2b4c404da95a960ea7041618b9"
}
]
}
70 changes: 70 additions & 0 deletions research/inplace-side-performance/TASK.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"schema_version": 1,
"task_id": "replay-runtime",
"priority_revision": 3,
"base_commit": "0b1cccf86e2f5132ed286a26ef0a681a495740ea",
"chooser_seed": "1cd1f71746c2d200dd617bc3dd17d8a6",
"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_baseline.py"
],
"expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY",
"inspect": "Read the selected reproduction command and choose a single replay stage for profiling.",
"scope": "Positive control / source-bound orientation only; this is not a new construction or full cold replay."
},
"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": "Can the historical inplace-side prefix checker (scripts/experiments/inplace_side.py:verify_prefix on the three pinned h=42/46/50 witnesses) be sped up without changing any receipt field, rejection condition or the regenerated certificates/inplace-side.json except its single source pin?",
"scope_change_reason": "The catalogue card asks for one measured replay bottleneck with before/after wall time and retained checks. The OS-random bit-mechanisms draw (seed 1cd1f71746c2d200dd617bc3dd17d8a6) was saturated on helper-contract/register-model work; expertise override selected verifier-engineering. Profiling make verify-certificates pointed at this fixed historical screen rather than isolated-test harness caching.",
"bottleneck_link": "Side result on review throughput: the inplace-side certificate is part of verify-certificates. A faster identical replay does not change kappa or the binding complex supplier.",
"budget_minutes": 60,
"stop_rule": "Ship an equivalence-preserving verify_prefix change with frozen baseline, identical witness receipts, rejection/mutant controls, certificate pin discipline, registered replay and a measured before/after median. Do not reopen the mathematical rejection or run the selected cold frontier replay.",
"outcome": "completed",
"evidence": "PASS_INPLACE_SIDE_PREFIX_FAST via research/inplace-side-performance/verify.py (also under -O); PASS_IDENTICAL_INPLACE_PREFIX_RECEIPTS via benchmark.py; certificates/inplace-side.json differs from base only in the inplace_side.py source pin.",
"author": "Wentao Li",
"github": "VictorLiwentao",
"email": "wentaol4@illinois.edu",
"ai_assistance": "Substantial AI assistance for orientation, overlap search, profiling, implementation, packaging, benchmarking and writing. Not independent human peer review.",
"open_questions": [
{
"question": "Can the same least-unused scan replace sorted(unused) pivots inside compile_side without changing gate lists?",
"why_it_matters": "compile_side is not on the certificate hot path here, but shares the same lexicographic rule; unifying it would remove a second O(n log n) sort per column on small controls.",
"first_step": "Diff gate lists for h=6 and h=10 between set/sort and flag-scan compile_side, then time h=50 if identical.",
"blocked_by": "Out of this session's stop rule; not needed for the verify_prefix receipt claim."
},
{
"question": "Should verify-certificates adopt a microbenchmark regression gate for this screen?",
"why_it_matters": "A future edit could restore sorted(unused) without failing equivalence tests.",
"first_step": "Decide whether RESULT.json medians belong in CI or remain descriptive.",
"blocked_by": "Maintainer CI-budget preference."
}
]
}
54 changes: 54 additions & 0 deletions research/inplace-side-performance/VERIFY.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"schema_version": 1,
"status": "ready",
"python": "3.12",
"requirements": [],
"inputs": [
"scripts/experiments/inplace_side.py",
"scripts/experiments/inplace_side_witnesses.json",
"scripts/audit_inplace_side.py",
"certificates/inplace-side.json",
"docs/research/inplace-side.md",
"tests/test_inplace_side.py"
],
"commands": [
{
"argv": [
"{python}",
"-I",
"-B",
"{package}/verify.py"
],
"timeout_seconds": 180,
"checks": "Exact baseline copy of the base-commit source; identical verify_prefix receipts on all three pinned witnesses and small h=6/10 controls; shared rejection of reused switches, wrong prefixes and out-of-range switches; greatest-unused mutant rejected on every witness; certificates/inplace-side.json matches certificate() and differs from the base certificate only in the inplace_side.py source pin."
},
{
"argv": [
"{python}",
"-I",
"-O",
"-B",
"{package}/verify.py"
],
"timeout_seconds": 180,
"checks": "Same equivalence and certificate discipline under -O (require() gates, not assert)."
},
{
"argv": [
"{python}",
"-I",
"-B",
"-m",
"unittest",
"discover",
"-s",
"tests",
"-p",
"test_inplace_side*.py",
"-v"
],
"timeout_seconds": 180,
"checks": "Existing inplace-side unit tests plus focused performance-package controls."
}
]
}
Loading
Loading