Skip to content

Tooling: faster partial-swap SharedPoint verify digests and __init__ construction with identical receipts - #2039

Merged
Mister-Meeseeks merged 3 commits into
CrocSwap:mainfrom
VictorLiwentao:cursor/partial-swap-digest-60b9
Oct 15, 2026
Merged

Mister-Meeseeks merged 3 commits into
CrocSwap:mainfrom
VictorLiwentao:cursor/partial-swap-digest-60b9

Conversation

@VictorLiwentao

@VictorLiwentao VictorLiwentao commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Change and scope

At base 0b1cccf86e2f5132ed286a26ef0a681a495740ea, the partial-swap fork (scripts/partial_swap/shared.py) spends substantial wall time in two places on the historical h=46 circuit:

  1. SharedPointCircuit.verify — per-node / per-output json.dumps while building circuit_sha256
  2. SharedPointCircuit.__init__ — per-common sort/unpack/lookup in the merge/lookup loop

This PR applies the same byte-identical hand-rolled digest formatter used on the canonical producer in CrocSwap/integer-mult-bounds#1994, then ports the merge/lookup construction rewrite from CrocSwap/integer-mult-bounds#2054 onto this distinct producer fork (including point_order / sorted pair_ids). Support checks stay; circuit_sha256 and the constructed DAG stay fieldwise identical. certificates/partial-swap-network.json updates only the scripts/partial_swap/shared.py source_sha256 pin once for the combined file.

Tooling improvement; no new kappa. Selected frontier untouched.

Result

On Linux / CPython 3.12.3 (Linux-6.12.94+-x86_64-with-glibc2.39), five alternating fresh-process pairs:

Path Median before → after
partial_swap.shared.SharedPointCircuit(46).verify 2.176 → 1.050 s (2.07×)
partial_swap.shared.SharedPointCircuit(46) construction 0.771 → 0.523 s (1.47×)

Timing is host-descriptive and is not a correctness gate.

Packages: research/partial-swap-digest/, research/partial-swap-init/.

Validation

python3.12 -I -B research/partial-swap-digest/verify.py
python3.12 -I -O -B research/partial-swap-digest/verify.py
python3.12 -B scripts/research_package.py --package research/partial-swap-digest
python3.12 -I -B research/partial-swap-init/verify.py
python3.12 -I -O -B research/partial-swap-init/verify.py
python3.12 -B scripts/research_package.py --package research/partial-swap-init

Expected:

PASS_PARTIAL_SWAP_DIGEST verify_cases=5 encoding_cases=8 certs=1 no_new_kappa
PASS_REGISTERED_RESEARCH_PACKAGE research/partial-swap-digest outcome=completed
PASS_PARTIAL_SWAP_INIT verify_cases=5 mutant=rejected certs=1 no_new_kappa
PASS_REGISTERED_RESEARCH_PACKAGE research/partial-swap-init outcome=completed

Default verify is read-only aside from the already-committed pin-only certificate refresh. Historical support checks use assert and are stripped under -O; structure/circuit_sha256 identity remain the gates. Full make verify, selected cold replay, Lean, and multiplication-theorem obligations were not rerun for these isolated historical-checker changes.

Overlap and credit

Closest priors (different objects): CrocSwap/integer-mult-bounds#756, CrocSwap/integer-mult-bounds#1793, CrocSwap/integer-mult-bounds#1861, CrocSwap/integer-mult-bounds#1922, CrocSwap/integer-mult-bounds#1984, CrocSwap/integer-mult-bounds#1994, CrocSwap/integer-mult-bounds#2054 (canonical __init__; this ports the same construction rewrite to the producer fork). #2001's ExclusionCircuit / DisjointTensor support-mask files are not touched.

Douglas R. Colkitt authored the shared-point / exclusion circuits. icekylinx adapted the partial-swap producer copy. Prepared by Wentao Li (VictorLiwentao, @Is__Victor) with substantial AI assistance, under Apache-2.0.

…l receipts

Hand-roll byte-identical circuit_sha256 lines in scripts/partial_swap/shared.py,
preserving support checks. Pin-only refresh of certificates/partial-swap-network.json.
No new kappa.

Prepared by Wentao Li with substantial AI assistance.
Five alternating fresh-process pairs on CPython 3.12.3; median verify
2.176 → 1.050 s. Prepared by Wentao Li with substantial AI assistance.
…rocSwap#2039

Port the CrocSwap#2054 merge/lookup construction rewrite onto the producer fork after
CrocSwap#2039's verify digests. Identical DAG and circuit_sha256; one re-pin of
certificates/partial-swap-network.json; package research/partial-swap-init/.
Median construction 0.771 → 0.523 s (1.47×).

Prepared by Wentao Li with substantial AI assistance.
@VictorLiwentao VictorLiwentao changed the title Tooling: 2.07× faster partial-swap SharedPoint verify digests with identical receipts Tooling: faster partial-swap SharedPoint verify digests and __init__ construction with identical receipts Oct 14, 2026
@Mister-Meeseeks
Mister-Meeseeks merged commit 06164c0 into CrocSwap:main Oct 15, 2026
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