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
19 changes: 19 additions & 0 deletions research/mixed-point-scalar-digest/NOTICE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Notice

This package accelerates the historical mixed-point scalar digest in
`scripts/audit_mixed_point.py:scalar_check` while preserving the mixed-point
and early-sharing mathematical screens.

Predecessor credit:

- Douglas R. Colkitt — mixed-point circuits, source/target-span frame cuts,
early-sharing screens and the historical certificates.
- Closest tooling priors on *different* objects: CrocSwap/integer-mult-bounds
PRs #756 (balanced-Fano packed replay), #1793 (inplace-side prefix), #1861
(parity-side basis/contains), #1922 (joint-frame cleared product), #1217
(ternary frame-pair memoization), and `research/rational-containment-performance/`
(mixed-point `contained` adapter).

Prepared by Wentao Li with substantial AI assistance under Apache-2.0.
This is not independent human peer review and is not a formal proof of the
multiplication theorem.
105 changes: 105 additions & 0 deletions research/mixed-point-scalar-digest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Faster exact mixed-point scalar digests with identical receipts

**Tooling improvement; no new kappa.** At base
`0b1cccf86e2f5132ed286a26ef0a681a495740ea`, the historical mixed-point audit
(`scripts/audit_mixed_point.py`) and the early-sharing screen both call
`scalar_check` on large cancellation-free circuits. Profiling shows a large
share of that helper’s time in per-node `json.dumps((node, args), …)` and
per-output `json.dumps((i, node), …)` while building `circuit_sha256`.

This change writes the same UTF-8 digest lines with an equivalent hand-rolled
formatter (`[node,null]`, `[node,[a,b]]`, `[i,node]`), keeps every support and
topology `require`, and leaves `circuit_sha256` unchanged. No certificate
`source_sha256` pin lists `audit_mixed_point.py`; the mixed-point and
early-sharing mathematical payloads stay fieldwise identical to the committed
files.

## Reproduce

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

```sh
python3.12 -I -B research/mixed-point-scalar-digest/verify.py
python3.12 -I -O -B research/mixed-point-scalar-digest/verify.py
python3.12 -B scripts/research_package.py --package research/mixed-point-scalar-digest
python3.12 -I -B research/mixed-point-scalar-digest/benchmark.py --rounds 5
```

Expected:

```text
PASS_MIXED_POINT_SCALAR_DIGEST scalar_cases=7 encoding_cases=5 certs=0 no_new_kappa
PASS_REGISTERED_RESEARCH_PACKAGE research/mixed-point-scalar-digest outcome=completed
PASS_IDENTICAL_MIXED_POINT_SCALAR_RECEIPTS
```

Default verify is read-only. Full `make verify`, selected cold replay, Lean, and
multiplication-theorem obligations were not rerun for this isolated
historical-checker change.

## Result

On Linux / CPython 3.12.3 (Linux-6.12.94+-x86_64-with-glibc2.39), five
alternating fresh-process pairs timing only `scalar_check` on the fixed
mixed-point circuit set (block-only and hybrid `h=50`, then four factored
rounds; construction excluded from the timed window) gave median wall time
**10.004 → 4.444 seconds (2.25×)**. Timing is host-descriptive and is not a
correctness gate; all samples and environment pins are in
[RESULT.json](RESULT.json). Every scalar receipt matches the baseline checker
fieldwise (`roles`, `circuit_sha256`, flags).

## Equivalence

For each active node the historical encoder emitted

- `json.dumps((node, None), separators=(',',':'))+'\n'` → `[node,null]\n`
- `json.dumps((node, (a,b)), separators=(',',':'))+'\n'` → `[node,[a,b]]\n`

and for each output index

- `json.dumps((i, node), separators=(',',':'))+'\n'` → `[i,node]\n`

with default JSON integer formatting (no whitespace). The hand-rolled writer
emits those exact byte strings. A `None` vs `null` spelling mutant differs and
is rejected by the package controls. Support and topology `require` calls are
unchanged, including under `-O` (they use `require`, not `assert`).

## Open next questions

1. **Question:** Can the same byte-identical hand-rolled digest pattern
accelerate `SharedPointCircuit.verify` / `ExclusionCircuit.verify` without
changing `circuit_sha256`?
**Why it matters:** Those verifiers still call `json.dumps` once per active
node on large common-point circuits.
**First step:** Profile `SharedPointCircuit.verify` for the h=50
bit-compression local circuit and compare a hand-rolled line writer against
the committed digest.
**Blocked by:** Out of this session’s stop rule; `scalar_check` was the
profiled mixed-point bottleneck.

2. **Question:** Should `certificates/mixed-point-audit.json` refresh its stale
`rational_span_frames.py` `source_sha256` pin (live digest already differs on
main)?
**Why it matters:** The pin is historical provenance for an unchanged
mathematical payload; leaving it avoids mixing a tooling PR with an
unrelated pin repair.
**First step:** Open a dedicated provenance follow-up that only rewrites the
three `source_sha256` entries after a clean certificate regenerate.
**Blocked by:** Pin repair is outside this tooling change.

## Overlap and credit

Closest priors (different objects):
[CrocSwap/integer-mult-bounds#756](https://github.com/CrocSwap/integer-mult-bounds/pull/756),
[CrocSwap/integer-mult-bounds#1793](https://github.com/CrocSwap/integer-mult-bounds/pull/1793),
[CrocSwap/integer-mult-bounds#1861](https://github.com/CrocSwap/integer-mult-bounds/pull/1861),
[CrocSwap/integer-mult-bounds#1922](https://github.com/CrocSwap/integer-mult-bounds/pull/1922),
[CrocSwap/integer-mult-bounds#1217](https://github.com/CrocSwap/integer-mult-bounds/pull/1217),
and `research/rational-containment-performance/` (mixed-point `contained`
adapter). No competing open PR on the `scalar_check` digest object at refresh.

Douglas R. Colkitt authored the mixed-point and early-sharing screens and
original checkers. Prepared by Wentao Li
([VictorLiwentao](https://github.com/VictorLiwentao),
[@Is__Victor](https://x.com/Is__Victor)) with substantial AI assistance, under
Apache-2.0.
50 changes: 50 additions & 0 deletions research/mixed-point-scalar-digest/RESULT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"environment": {
"executable": "/usr/bin/python3.12",
"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": "mixed-point scalar_check only (construction excluded): block_only+hybrid h=50 and four factored rounds",
"median_baseline_seconds": 10.004118329999983,
"median_optimized_seconds": 4.444395452000208,
"median_ratio": 2.2509514371628683,
"no_new_kappa": true,
"rounds": 5,
"samples": [
{
"baseline_seconds": 10.759656437000558,
"optimized_seconds": 4.545425416000398,
"ratio": 2.367139585906609,
"round": 0
},
{
"baseline_seconds": 10.004118329999983,
"optimized_seconds": 4.3992744540000785,
"ratio": 2.274038238488088,
"round": 1
},
{
"baseline_seconds": 9.629288107999855,
"optimized_seconds": 4.488741446999484,
"ratio": 2.1452089013584397,
"round": 2
},
{
"baseline_seconds": 9.663091254000392,
"optimized_seconds": 4.444395452000208,
"ratio": 2.1742194992237924,
"round": 3
},
{
"baseline_seconds": 10.133248975999777,
"optimized_seconds": 4.4019990880005935,
"ratio": 2.301965260197803,
"round": 4
}
],
"source_sha256": {
"baseline": "2eead5d410d1c96f1a7ef47c9c35d16ca6bb6d9c2a6a8d24273290add842214d",
"production": "fc7ca3e07d8a3ad54e894c387a89b310ae0b7048763cd48bb27f5daeb0d73dba"
},
"status": "PASS_IDENTICAL_MIXED_POINT_SCALAR_RECEIPTS"
}
78 changes: 78 additions & 0 deletions research/mixed-point-scalar-digest/SOURCES.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"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/mixed-point-audit.json",
"usage": "provenance",
"git_blob": "5b65e2e08aacc2e58ce4d199fe9f157218fa237f",
"sha256": "4053408adcd8de22edd9ac2b9dde491338f210540ac3a00e8dae9276b3cc2d3b"
},
{
"path": "certificates/early-sharing-audit.json",
"usage": "provenance",
"git_blob": "344a4582845190583a35f222cb0296e4fa1fc378",
"sha256": "f822ea9e6b69c116f160688caa2b899cb2e209424706f36634e5a9af95480d67"
},
{
"path": "docs/research/mixed-point-audit.md",
"usage": "provenance",
"git_blob": "31f712b8f78cee8a05b8cb490c8c979c79265ee2",
"sha256": "c80527f9e98c27bd7f5858a06c7273f84c40e0c41505eb4d16029b61f80fb968"
},
{
"path": "docs/research/early-sharing-and-centers.md",
"usage": "provenance",
"git_blob": "945661f9954155acf87dd9d6dbca47d18509bbdd",
"sha256": "f8706dbda32f7a07081f4010400ba15124b8ae8edacf73867392f1ce2d7d2d50"
},
{
"path": "scripts/audit_mixed_point.py",
"usage": "provenance",
"git_blob": "0c9e11b9f5d7fae9b5e5a312eca3f246b7aa7d3c",
"sha256": "2eead5d410d1c96f1a7ef47c9c35d16ca6bb6d9c2a6a8d24273290add842214d"
},
{
"path": "scripts/audit_early_sharing.py",
"usage": "provenance",
"git_blob": "33ce7c0dcffe97acab529700c348e2cd430ad874",
"sha256": "2cf08ee65f8f8610578614d0ff0308eb432732e779f1e8c03e67f1979e75fdc6"
},
{
"path": "scripts/experiments/mixed_point_circuit.py",
"usage": "provenance",
"git_blob": "b7f561f416f815d0fd135f0a0464c291a9a68468",
"sha256": "f509362b5031976a22af351fd158ae0b4520fa4f286a5176ec37023d672a7ddc"
},
{
"path": "scripts/experiments/early_sharing.py",
"usage": "provenance",
"git_blob": "671df3d5fb4e13d1758edf4efeb7276c65122468",
"sha256": "1dd42768536bac13727528e51a999152cf9516a53c4001f2c390323e7f453378"
},
{
"path": "scripts/rational_span_frames.py",
"usage": "provenance",
"git_blob": "755f59a5fc87bffae51b57543b0ad5150fa93da8",
"sha256": "7386947406d5dc4322a39fb7ccd886876a2fa1d163e823f0f231e11cf9ca0cec"
},
{
"path": "tests/test_mixed_point.py",
"usage": "provenance",
"git_blob": "1d97e9f9bbcd4d61f618fc562a0e22b58af59ad5",
"sha256": "bb279af4bf072e9709d70cefe0cdf0230688d865f9c5e902350c4aade9218452"
}
]
}
70 changes: 70 additions & 0 deletions research/mixed-point-scalar-digest/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": "1e60c388106de197fb515e8dc9b5a10f",
"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 scripts/audit_mixed_point.py:scalar_check emit the same circuit_sha256 digest lines (and the same support/topology rejection checks) without per-node json.dumps, so the historical mixed-point and early-sharing scalar streams keep fieldwise-identical receipts?",
"scope_change_reason": "The catalogue card asks for one measured replay bottleneck with before/after wall time and retained checks. Expertise override selected verifier-engineering (seed 1e60c388106de197fb515e8dc9b5a10f) after the complex-mechanisms draw landed on saturated packing/rank-shape work listed as deferred. Profiling named scalar_check's per-node json.dumps stream inside audit_mixed_point / audit_early_sharing as the bottleneck on this fixed historical screen.",
"bottleneck_link": "Side result on review throughput: mixed-point and early-sharing certificates are part of verify-certificates. A faster identical scalar digest does not change kappa or the binding complex supplier.",
"budget_minutes": 60,
"stop_rule": "Ship an equivalence-preserving scalar_check digest change with frozen baseline, identical mixed-point and early-sharing mathematical payloads, registered replay and a measured before/after median. Do not reopen the mathematical screens or run the selected cold frontier replay.",
"outcome": "completed",
"evidence": "PASS_MIXED_POINT_SCALAR_DIGEST via research/mixed-point-scalar-digest/verify.py (also under -O); PASS_IDENTICAL_MIXED_POINT_SCALAR_RECEIPTS via benchmark.py; mixed-point and early-sharing certificate mathematical payloads match the committed files (audit_mixed_point.py is not a source_sha256 pin in either certificate).",
"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 byte-identical hand-rolled digest pattern accelerate SharedPointCircuit.verify / ExclusionCircuit.verify without changing circuit_sha256?",
"why_it_matters": "Those verifiers still call json.dumps once per active node on large common-point circuits.",
"first_step": "Profile SharedPointCircuit.verify for the h=50 bit-compression local circuit and compare a hand-rolled line writer against the committed digest.",
"blocked_by": "Out of this session's stop rule; scalar_check was the profiled mixed-point bottleneck."
},
{
"question": "Should certificates/mixed-point-audit.json refresh its stale rational_span_frames.py source_sha256 pin (live digest already differs on main)?",
"why_it_matters": "The pin is historical provenance for an unchanged mathematical payload; leaving it avoids mixing a tooling PR with an unrelated pin repair.",
"first_step": "Open a dedicated provenance follow-up that only rewrites the three source_sha256 entries after a clean certificate regenerate.",
"blocked_by": "Pin repair is outside this tooling change."
}
]
}
58 changes: 58 additions & 0 deletions research/mixed-point-scalar-digest/VERIFY.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"schema_version": 1,
"status": "ready",
"python": "3.12",
"requirements": [],
"inputs": [
"scripts/audit_mixed_point.py",
"scripts/audit_early_sharing.py",
"scripts/experiments/mixed_point_circuit.py",
"scripts/experiments/early_sharing.py",
"scripts/rational_span_frames.py",
"certificates/mixed-point-audit.json",
"certificates/early-sharing-audit.json",
"docs/research/mixed-point-audit.md",
"docs/research/early-sharing-and-centers.md",
"tests/test_mixed_point.py"
],
"commands": [
{
"argv": [
"{python}",
"-I",
"-B",
"{package}/verify.py"
],
"timeout_seconds": 480,
"checks": "Exact baseline copy of the base-commit audit_mixed_point.py; identical scalar_check receipts on mixed-point full-size and factored circuits plus early-sharing full-size; encoding foil rejects a wrong null spelling while preserving Boolean support checks; mixed-point and early-sharing mathematical payloads match committed certificates."
},
{
"argv": [
"{python}",
"-I",
"-O",
"-B",
"{package}/verify.py"
],
"timeout_seconds": 480,
"checks": "Same equivalence and certificate payload discipline under -O (require() gates, not assert)."
},
{
"argv": [
"{python}",
"-I",
"-B",
"-m",
"unittest",
"discover",
"-s",
"tests",
"-p",
"test_mixed_point*.py",
"-v"
],
"timeout_seconds": 120,
"checks": "Existing mixed-point unit tests plus focused scalar-digest package controls."
}
]
}
Loading
Loading