diff --git a/docs/ci-verification.md b/docs/ci-verification.md index 63ba3e9aa8..52b62d0481 100644 --- a/docs/ci-verification.md +++ b/docs/ci-verification.md @@ -1,8 +1,25 @@ # CI verification -## Current selected-family replay: #6030 +## Current selected-family replay: #7000 with #7001 The [selected record](../certificates/selected-result.json) binds conditional +κ = 0.00363005817 to the [application review](research/pr-intake-evidence/pr7000-application/PROOF-REVIEW.md), +[validation receipts](research/pr-intake-evidence/pr7000-application/VALIDATION.json), +and [explicit source closure](../certificates/frontier7000-source.json). +`make frontier7000-verify` follows that exact-source selected replay. The review +reuses eleven authenticated preceding executions and records seven fresh serial +application, scalar and complete native-catalogue executions. The earlier +monolithic timeout is retained separately and is not completed coverage. +Consult the receipts for exact commands, source heads and limits. + +The five inherited framework assumptions remain. No complete uniform word, +literal multiplier execution, independent human proof or formal-kernel proof +is asserted. Routine research submissions do not need to rerun this +selected-family replay. The sections below preserve historical checkpoints. + +## Historical selected-family replay: #6030 + +The [historical checkpoint](../certificates/checkpoints/frontier6030.json) binds conditional κ = 0.003125804 to the [proof review](research/pr-intake-evidence/pr6030-audit/PROOF-REVIEW.md), [validation receipts](research/pr-intake-evidence/pr6030-audit/VALIDATION.json), and [explicit source closure](../certificates/frontier6030-source.json). diff --git a/research/historical-selected-replay-gap/README.md b/research/historical-selected-replay-gap/README.md index 55d8cc3b49..36d9a873ca 100644 --- a/research/historical-selected-replay-gap/README.md +++ b/research/historical-selected-replay-gap/README.md @@ -69,7 +69,11 @@ python3 -B scripts/research_package.py --package research/historical-selected-re The direct command prints `PASS_HISTORICAL_SELECTED_REPLAY_GAP`. A registered replay prints `PASS_REGISTERED_RESEARCH_PACKAGE`. Both require Git history -containing the two inspected commits. +containing the two inspected commits and the source and manifest objects at +`2485805a6d47f36ea83ddde6327d453ac82d44dc`. The verifier uses a temporary +sparse checkout of that commit, checks the declared source digests there, and +uses its planner and manifest inventory. The recorded rejections and selection +therefore remain reproducible after later changes to the live Makefile or CI guide. ## Open next questions diff --git a/research/historical-selected-replay-gap/SOURCES.json b/research/historical-selected-replay-gap/SOURCES.json index c1010eec95..62bb8b3950 100644 --- a/research/historical-selected-replay-gap/SOURCES.json +++ b/research/historical-selected-replay-gap/SOURCES.json @@ -4,13 +4,13 @@ "files": [ { "path": "Makefile", - "usage": "input", + "usage": "provenance", "git_blob": "0d683a06b9e7ee162496108ce9a7c5d2ee94fccf", "sha256": "4f2d4f2dcd15139ec82658a975f85ed300897385f85799218539f4c8d60567da" }, { "path": "certificates/partial-swap-network.json", - "usage": "input", + "usage": "provenance", "git_blob": "eccafa830c16170c36faf93045ddf1f638f7bcd4", "sha256": "4c0b9d37e1034b2076e30a70f8e514416298c462d9ee98bc87fe6556b14df786" }, @@ -22,7 +22,7 @@ }, { "path": "docs/ci-verification.md", - "usage": "input", + "usage": "provenance", "git_blob": "63ba3e9aa8bdc5e942b56e34244b92b16f854085", "sha256": "c7d3027e9ad8bcbff68f07aa9576b30fb2f3c76c44d876d40c7fdbf4a3e2228a" }, @@ -34,163 +34,163 @@ }, { "path": "research/clifford-state-performance/SOURCE.json", - "usage": "input", + "usage": "provenance", "git_blob": "6f98a0061a5104dfab82c9e806f819b41811f684", "sha256": "396d0f08df24952248140d5c65c51b8c902ef1c580892ff7ea182890530f67ee" }, { "path": "research/community-batch1047-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "5e0f92af463ec12c5e1dcc3effd44081a88af647", "sha256": "07a9daeaf2bda308a92e9a4684f13d5fc766c7772d74801fceb7f4599fdab226" }, { "path": "research/community-batch1099-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "9e13266bf85e627f1b7dc225e9530ea69fd2c7f0", "sha256": "421e1211fb1897c45621dc6801c276e53f2e6f335583c9c9049e535f87c0a3b1" }, { "path": "research/community-batch932-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "cc4d03eb59b9ab3f952735f7e88ff18c2d15d7af", "sha256": "184629cac91a5cfaca50330a88596008b824221433867dcf8117539c913c284a" }, { "path": "research/community-batch970-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "8b9f4111badf7de5d97684799560b55110e9da79", "sha256": "23188ed920e38a54006cb883e181585620821c63bf7e8b5e05d32719417cc37e" }, { "path": "research/community-frontier741-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "a5300d4e7a5381a3f443fc54c768ca6f0f236d68", "sha256": "3c820fb30e1b4d9bcfc6a7ab524375e5b2abd66b940af2c509146104f0bcd79c" }, { "path": "research/community-frontier890-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "d7ff6d777b01d69b6ce84caf25d3b7e4a4d2f211", "sha256": "6b185a9902652f893f3ebd8ada92d2f11b6de6533a9a4d11718a8a4496101128" }, { "path": "research/community-hyperplane599-audit/SOURCE.json", - "usage": "input", + "usage": "provenance", "git_blob": "546f37d326d10a99910ae8f908e71ef768524d98", "sha256": "65099d764bfcc39bda5e4d9966783611b094c3522dbdd1435cd498d657a8ef8e" }, { "path": "research/community-k492-audit/SOURCE.json", - "usage": "input", + "usage": "provenance", "git_blob": "e538481e4cb16ed936d3195f2dfb5b5a9ca0a76b", "sha256": "2c0f4fa5bc150d05658af2e7c54c4d2c337dd52b7efd3d69530ae73bcbdf452a" }, { "path": "research/community-reconciliation92-audit/MANIFEST.json", - "usage": "input", + "usage": "provenance", "git_blob": "2a2e93685173d5f13cbb5abe740f5d90352e0228", "sha256": "5f501f3c118131e7d069f30ad77186eb2ad6961f9680a0ef105f4514ed41808a" }, { "path": "research/partial-swap-digest/baseline.py", - "usage": "input", + "usage": "provenance", "git_blob": "a2f0190704db83bd8ef48e46e723c49b925804fe", "sha256": "81e9af92cdf38243a540cdcff2062778e449467848d444da37a9553c12ca4c34" }, { "path": "research/r420-two-sided-basis/SOURCES.json", - "usage": "input", + "usage": "provenance", "git_blob": "5d718e11e62f4bcadecf1e02d6b61f87dbe190b0", "sha256": "d9810b0d139c5a1211fd2c1f0d142187cc1fca30026e1e7bc4f9ecfacf1596d1" }, { "path": "research/skip-clones/SOURCE.json", - "usage": "input", + "usage": "provenance", "git_blob": "8d1bb3b9c8189e35e5d8bfdfa632d7473e8be0d5", "sha256": "0b68e63e35a97ce6b0cdb6e291b88ebaa8f2dd4afb70b2498f10ee89428258dc" }, { "path": "research/split-skip/SOURCE.json", - "usage": "input", + "usage": "provenance", "git_blob": "2ab610b6ea2edd2865fda793ef2168b0c76afb4f", "sha256": "7c2b4646a3ecfef6f881da5c43e4bd0fa9a4d1b00548b8ab458d897e16735134" }, { "path": "scripts/historical-ci-inputs/Makefile", - "usage": "input", + "usage": "provenance", "git_blob": "aff68409021c9d401a6f8013b9dfd7dbcc30f2a8", "sha256": "ea8830dd79da493e2d75baf753d733ff7efbcf2b4794afe41fae0ac8f3055646" }, { "path": "scripts/historical-ci-inputs/ledger-batch932-run_isolated_tests.py", - "usage": "input", + "usage": "provenance", "git_blob": "65db599ab0b1dea0312c4ca048e0bd0f44c3736f", "sha256": "96ea543e6c707424afe247e77bd86c82152f90fc76a0773c4232145da5cdf8d1" }, { "path": "scripts/historical-ci-inputs/ledger-batch932-test_isolated_test_runner.py", - "usage": "input", + "usage": "provenance", "git_blob": "34820a8f24678f918f4d0e7a35380d8013fc3495", "sha256": "628391b6abfbc8674ceec1751867a4392f2cc0b5b66886243e139af86cf355ac" }, { "path": "scripts/historical-ci-inputs/ledger-batch970-verify_selected_result.py", - "usage": "input", + "usage": "provenance", "git_blob": "c755b76e0d44ba4917aa94440ebe54daefce5b2a", "sha256": "d7fd929726b326aeeaf0a3996475adec88eee9aac09ae0bebeeaa0bc1fc8f199" }, { "path": "scripts/historical-ci-inputs/ledger-frontier741-ci-verification.md", - "usage": "input", + "usage": "provenance", "git_blob": "7f3c012504187917a728b9fe87043f0fc8cd006a", "sha256": "a854022e0e1d5d4db4d60e586be3ea56005013ef14a1fc06d02bc06e8529c4b0" }, { "path": "scripts/historical-ci-inputs/partial-swap-context.json", - "usage": "input", + "usage": "provenance", "git_blob": "ad65114886bf34a4fd27e79f3be502389e689faa", "sha256": "833a9642f33aeab2ffea17ec9c6b82e0a953f90192b2c82e10bef21538dccba9" }, { "path": "scripts/historical-ci-inputs/partial-swap-network.json", - "usage": "input", + "usage": "provenance", "git_blob": "52075f2463f60af5e16571347f24274fce73a1ea", "sha256": "f3c4be597b2f2136da4ae2cc80c7454f63c90aa01f84e5b8131cee4dd55de815" }, { "path": "scripts/partial_swap/shared.py", - "usage": "input", + "usage": "provenance", "git_blob": "44a0e454c70f9c4b98e258b8443612e6a119904b", "sha256": "5a0646a50b9f3e8ea55168620a78e8853b0ab810517cefc8cfb8696aedee278a" }, { "path": "scripts/replay_historical_check.py", - "usage": "input", + "usage": "provenance", "git_blob": "1e92fff2782970ef71378f594f2350d245a4db26", "sha256": "5467619c78183d3adc82b0cb55af28e5c1a01fca2b0588677816244b53e2bafd" }, { "path": "scripts/research_package.py", - "usage": "input", + "usage": "provenance", "git_blob": "091b4c8f58bac9a9580d76025b887dc5c873d05f", "sha256": "e1256016e7f51827d04fa2179255989f639ae1d97afaa9c16265f85a0c6abd70" }, { "path": "scripts/run_isolated_tests.py", - "usage": "input", + "usage": "provenance", "git_blob": "a96ab35b315ce492e7fbbfd6c5ae211aa066b541", "sha256": "49eb56dd0fc0d8d8ffdb209970a7adf2176223580646f575d5c22e59543b381c" }, { "path": "scripts/verify_selected_result.py", - "usage": "input", + "usage": "provenance", "git_blob": "6882a4700e410dec569b51ae2eaf1a19cc019195", "sha256": "d6b305eac5b9bdb8172c469ad30a1655a60fa0aceac8b1bf610e1b73f51babd8" }, { "path": "tests/test_isolated_test_runner.py", - "usage": "input", + "usage": "provenance", "git_blob": "343b24abf6719b81805eba5a84c74e57634c8288", "sha256": "3a5470d0b139828b90e19bf9583ddeafcd69f8e34f2824664eb3a2958a52e34d" } diff --git a/research/historical-selected-replay-gap/VERIFY.json b/research/historical-selected-replay-gap/VERIFY.json index 98553e72ed..ab7efa3471 100644 --- a/research/historical-selected-replay-gap/VERIFY.json +++ b/research/historical-selected-replay-gap/VERIFY.json @@ -4,36 +4,7 @@ "python": "3.12", "requirements": [], "inputs": [ - "Makefile", - "certificates/partial-swap-network.json", - "docs/ci-verification.md", - "research/clifford-state-performance/SOURCE.json", - "research/community-batch1047-audit/CONTENT-COVERAGE.json", - "research/community-batch1099-audit/CONTENT-COVERAGE.json", - "research/community-batch932-audit/CONTENT-COVERAGE.json", - "research/community-batch970-audit/CONTENT-COVERAGE.json", - "research/community-frontier741-audit/CONTENT-COVERAGE.json", - "research/community-frontier890-audit/CONTENT-COVERAGE.json", - "research/community-hyperplane599-audit/SOURCE.json", - "research/community-k492-audit/SOURCE.json", - "research/community-reconciliation92-audit/MANIFEST.json", - "research/partial-swap-digest/baseline.py", - "research/r420-two-sided-basis/SOURCES.json", - "research/skip-clones/SOURCE.json", - "research/split-skip/SOURCE.json", - "scripts/historical-ci-inputs/Makefile", - "scripts/historical-ci-inputs/ledger-batch932-run_isolated_tests.py", - "scripts/historical-ci-inputs/ledger-batch932-test_isolated_test_runner.py", - "scripts/historical-ci-inputs/ledger-batch970-verify_selected_result.py", - "scripts/historical-ci-inputs/ledger-frontier741-ci-verification.md", - "scripts/historical-ci-inputs/partial-swap-context.json", - "scripts/historical-ci-inputs/partial-swap-network.json", - "scripts/partial_swap/shared.py", - "scripts/replay_historical_check.py", - "scripts/research_package.py", - "scripts/run_isolated_tests.py", - "scripts/verify_selected_result.py", - "tests/test_isolated_test_runner.py" + "scripts/research_package.py" ], "commands": [ { diff --git a/research/historical-selected-replay-gap/verify.py b/research/historical-selected-replay-gap/verify.py index 83b995941a..9d266c5a4e 100644 --- a/research/historical-selected-replay-gap/verify.py +++ b/research/historical-selected-replay-gap/verify.py @@ -6,8 +6,10 @@ """ import hashlib import importlib.util +import json import subprocess import sys +import tempfile from pathlib import Path ROOT = Path(__file__).resolve().parents[2] @@ -61,31 +63,47 @@ def require(ok, message): raise SystemExit(message) -def load_checker(): - path = ROOT / "scripts/replay_historical_check.py" - spec = importlib.util.spec_from_file_location("historical_selected_replay_gap_checker", path) +def load_module(path): + spec = importlib.util.spec_from_file_location(path.stem, path) module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) return module +def checkout_snapshot(snapshot, sources, runner, env): + paths = [runner.canonical_relative_path(row["path"]) for row in sources["files"]] + git = ["git", "-c", "maintenance.auto=false", "-c", "gc.auto=0", + "-c", "core.autocrlf=false"] + subprocess.run([*git, "clone", "--quiet", "--shared", "--no-tags", "--no-checkout", + "--", str(ROOT), str(snapshot)], cwd=ROOT, env=env, check=True) + subprocess.run([*git, "update-ref", "--no-deref", "HEAD", INSPECTED], + cwd=snapshot, env=env, check=True) + # The pinned planner reads omitted manifests from the sparse HEAD/index. + patterns = "".join(f"/{path.as_posix()}\n" for path in paths) + subprocess.run([*git, "sparse-checkout", "set", "--no-cone", "--stdin"], + cwd=snapshot, env=env, input=patterns.encode("utf-8"), check=True) + subprocess.run([*git, "read-tree", "-mu", "HEAD"], cwd=snapshot, env=env, check=True) + for path, row in zip(paths, sources["files"], strict=True): + require(hashlib.sha256((snapshot / path).read_bytes()).hexdigest() == row["sha256"], + "historical checkout source digest changed: " + path.as_posix()) + + def entries(checker): for name, config in checker.CONFIG.items(): for entry in [config, *config.get("additional_inputs", [])]: yield name, entry -def reject(checker, entry): +def reject(root, checker, entry): try: - checker.authenticated_input(ROOT, entry) + checker.authenticated_input(root, entry) except ValueError as exc: return str(exc) raise SystemExit("historical input was admitted: " + entry["path"]) -def main(): - require(not sys.flags.optimize, "assertions must stay enabled") - checker = load_checker() +def check_snapshot(root, env): + checker = load_module(root / "scripts/replay_historical_check.py") selected = [entry for name, entry in entries(checker) if name == "tooling-ledger" and entry["path"] == SELECTED_PATH] require(len(selected) == 1, "selected-result checker overlay is not unique") @@ -94,7 +112,7 @@ def main(): require(entry["accepted_live_sha256"] == [SELECTED_ACCEPTED], "accepted selected-checker successors changed") frozen = (checker.INPUTS / entry["input"]).read_bytes() - live = (ROOT / SELECTED_PATH).read_bytes() + live = (root / SELECTED_PATH).read_bytes() require(hashlib.sha256(frozen).hexdigest() == SELECTED_PIN, "frozen selected checker bytes changed") require(hashlib.sha256(live).hexdigest() == SELECTED_LIVE, "live selected checker digest changed") require(SELECTED_LIVE not in (SELECTED_PIN, SELECTED_ACCEPTED), "live checker was already admitted") @@ -102,7 +120,7 @@ def main(): # live successor, not a broken comparison. require(SELECTED_PIN in (SELECTED_PIN, *entry["accepted_live_sha256"]), "pin membership control failed") - require(reject(checker, entry) == REJECTIONS[SELECTED_PATH][1], + require(reject(root, checker, entry) == REJECTIONS[SELECTED_PATH][1], "selected checker rejection text changed") counts = {path: 0 for path in REJECTIONS} @@ -110,7 +128,7 @@ def main(): for _name, item in entries(checker): if item["path"] not in REJECTIONS: continue - message = reject(checker, item) + message = reject(root, checker, item) counts[item["path"]] += 1 messages.setdefault(item["path"], message) for path, (count, message) in REJECTIONS.items(): @@ -118,20 +136,31 @@ def main(): require(messages[path] == message, "rejection text changed for " + path) require(sum(counts.values()) == 19, "rejection total changed") ci = [item for _name, item in entries(checker) if item["path"] == CI_PATH] - require(len(ci) == 1 and hashlib.sha256((ROOT / CI_PATH).read_bytes()).hexdigest() == CI_LIVE, + require(len(ci) == 1 and hashlib.sha256((root / CI_PATH).read_bytes()).hexdigest() == CI_LIVE, "selected CI note digest changed") diff = subprocess.check_output( - ["git", "diff", "--name-only", PARENT, INSPECTED], cwd=ROOT, text=True) + ["git", "diff", "--name-only", PARENT, INSPECTED], cwd=root, env=env, text=True) changed = sorted(name for name in diff.splitlines() if name) require(changed == CHANGED, "inspected commit diff changed") - sys.path.insert(0, str(ROOT / "scripts")) - from research_package import plan_details - details = plan_details(ROOT, set(changed)) + planner = load_module(root / "scripts/research_package.py") + details = planner.plan_details(root, set(changed)) require([row["package"] for row in details] == PLAN_PACKAGES, "helper plan selection changed") matched = {name for row in details for names in row["causes"].values() for name in names} require(sorted(set(changed) - matched) == UNMATCHED, "unmatched plan paths changed") - require(plan_details(ROOT, set()) == [], "empty change set selected a package") + require(planner.plan_details(root, set()) == [], "empty change set selected a package") + + +def main(): + require(not sys.flags.optimize, "assertions must stay enabled") + sources = json.loads(Path(__file__).with_name("SOURCES.json").read_bytes()) + require(sources["base_commit"] == INSPECTED, "historical checkout base changed") + runner = load_module(ROOT / "scripts/research_package.py") + env = runner.git_source_env() + with tempfile.TemporaryDirectory(prefix="historical-selected-replay-") as temporary: + snapshot = Path(temporary) / "snapshot" + checkout_snapshot(snapshot, sources, runner, env) + check_snapshot(snapshot, env) print("PASS_HISTORICAL_SELECTED_REPLAY_GAP") print("selected_checker_live=" + SELECTED_LIVE) print("rejections=19 distinct_paths=7 plan_packages=9") diff --git a/research/tiered-native-multiplier/CLOCK.md b/research/tiered-native-multiplier/CLOCK.md new file mode 100644 index 0000000000..bbd06a788d --- /dev/null +++ b/research/tiered-native-multiplier/CLOCK.md @@ -0,0 +1,45 @@ +# One complete signed machine and its absolute clock + +Let $n\ge2$ be the larger significant bit length of two canonical signed integers. Count a read, a write or a one-cell move on one fixed-alphabet tape as one transition. The complete recurring upper bound is $2^{339787971}\,n(1+\log_2 n)^{1-0.0038982}$. Fixed installation is billed separately. Short zero and unit inputs fit the same bound with $n=2$. A caller can also supply a longer byte interval with high zeros. In that case the machine scans and restores the entire interval. One may take $n$ to include the declared input lengths in bits, or add the linear charge for these bytes. The placement threshold below refers to significant bits. + +The maintained hypothesis contract has five parts. They cover (1) all-column native operators, spectator and phase conventions, (2) ownership, erasure and suspended fields, (3) uniform chronological compiler closure, (4) the retained physical tape and precision services and (5) the analytic decomposition, fine-prime avoidance and exact recovery. This research proves the changes to the source, its calendar, its clock and its connection to the signed caller under those same premises. The selected application on main and the open K7 application retain their respective status. [Selected hypothesis statements](https://github.com/CrocSwap/integer-mult-bounds/blob/e54523517d0f03e58352e647c403a5af3e525a57/certificates/selected-result.json) · [K7 source application](https://github.com/CrocSwap/integer-mult-bounds/pull/8052) + +## Ordinary funding from the actual K7 circuit + +K7 has 630 independent raw registers, 2,796 transfers and 3,426 dirty clears. The seven retracted returns reduce the grades of seven productive helpers from eight to four in every one of the 36 calls. Both linear totals fall by 1,008. The new totals are 286,098 productive and 284,592 paid over 18,906 and 104,652 labels. The full weighted moment and a chronological coupling of 24 cells, together with the retained physical quotient/weighted receiver, fund the binary trial $c_B=4391986206293/2^{50}$. Each nonempty transport edge has $5r\le4k$. Paid and productive tags are rebuilt from the new graph. The independent binary enclosure and signed register, frame and weighted physical checks operate on these same bytes. [K7 journal](source/K7-STACK-LEDGER.json) · [Whole-machine cost code](receipt.py) + +For ordinary stage $i$, let $N=2^{H_i}$, $J=N^{1024}$, and let $b_0=0$. The raw finite factor times the full physical child factor $47/20$ is below $2^{11/8}$. Its contracting volume ratio is at most $375/376$. Choose $b_i$ strictly below + +$$ +\min\left(0.0039,\ [249(c_B-11/(8H_i))+b_{i-1}]/250\right). +$$ + +The receipt takes the preceding whole $10^{-21}$ tick for the intermediate stage and books exactly $\kappa+5\cdot10^{-18}$ for the last. Both actual receivers have $H_i\ge3000$ and construct an active native recipe. Input, zero, signed returns and boundary calls use the five-exchange/quotient rules from the retimed machine. Each tier passes 54 strict inequalities, four further functional inequalities and its independent positive price check. [Exact margins](RESULT.json) · [Physical ordinary proof](https://github.com/aliromman/integer-mult-bounds/blob/dfd25d553a843a946ca0b94130a5ff8943e98fdd/research/retimed-native-multiplier/ORDINARY-CLOCK.md) + +## Counting tape movement + +Use the inherited per-prefix expression $J^5 X^{20}$, where $X=2^{16} N^4(D+1)(w+1)^{252}$. Here $D$ bounds the number of saved coefficient links, $w$ is the component bound, and $u$ is the width of a balanced digit present on the actual pass. At each admitted root the component geometry is inherited down the same-stage tree. It satisfies $D+1\le256(w+1)$, $w+1\le2^{259}u^{258}$, and $u\ge e^\eta/2$ with $e\ge N$ and $\eta=.0039>1/258$. For $H\ge8192$, $u\ge2^{30}$ and $H\le258(1+\log_2u)$. Substitution gives + +$$ +\log_2(J^5 X^{20}) +\le5200H+480+259\cdot5060+258\cdot5060\log_2u +\le2660000(1+\log_2u)2^u$ distinct cells. Charge one extra transition per cell on that pass. This includes retrieval from the fixed store and all saved coefficient links. Short carry and shift kernels still get their separate $2^{50}$ per-cell allowance. Suspended parent banks remain parked between the lower children of one issuance. Their heads traverse the parent bank at most twice at the two boundaries. [Kernel-checked digit inequality](TierCost.lean) + +The original sweep bound has three counts for a parent field. These are the visits to elementary native sites, the fixed factor or owner scans at one site, and the owner range crossed per opening. Each is at most $N^{96}$ from the actual event and descriptor counts. Owner width is $N^{92}$. Each bounded physical scan includes the complete prefix, packet, spectator gap and suffix it traverses. The remaining $2^{22}(N+1)^6a_1+2$. At the positive root the outer selector supplies at least $2^{s-100}/s^7$ real ordered windows. The actual second ticket on the 10,191-grade group needs a complete slot exchange. When $s-7\lceil\log_2s\rceil\ge H_M+a_2+102$, this creates a genuine ordinary invocation past the second cutoff. The native compiler issues real singleton children. At a populated bin one can take birth at the last tick and paid ordinal one. Delaying it by at least one tick makes this a terminal singleton. The decreasing same-stage coarse width eventually enters the stopped weighted pair. Its two earlier exchanges use the real previous component width at least $2^{a_1}$, so the first binary stage also enters its native recipe. This proof counts the full fields on zero inputs as well. The first satisfying $s$ and the first post-dyadic jump imply all larger $s$, since the successive post-jump minima grow by $2^j-7$. [Physical stock and geometry](https://github.com/aliromman/integer-mult-bounds/blob/dfd25d553a843a946ca0b94130a5ff8943e98fdd/research/retimed-native-multiplier/ACTIVATION.md) · [Stock computations](source/activation.py) + +For the smaller branch $A=7437$. At this threshold the square controller has $2^{7412}$ true axes, with largest axis address width 5,592,406. For the terminal branch $A=1274851$. The first/continuing historical stripe slack is 1,701/1,635 bits in the entry branch and 635,376/615,539 in the terminal branch. The two-stage bound uses 1,964 log units of fixed adapter overhead, plus the depth term. It counts the high-water end of each tape, held pending raw calls, real zero padding, temporary copies, returns and scrubbing. The separate input-dependent control ceiling has logarithm 3,153,922 on entry and 696,320,002 at the terminal ranks. The cofinal live numerical bound is $6.2pT<297.6n$ bits in the predecessor's accounting. True generated positive rows number $2^{94208}$ and $2^{62560000}$ respectively. They contain arbitrary independent data. The construction retains the true high-coordinate and invertible low-matrix terms in its admitted ordinary layout. + +The exterior machine performs both input conversions, normalized forward transforms, pointwise product, opposite transform, the original-coordinate inverse scaling, coefficient rounding, inverse CRT and carry. The native changes return the same H or interchange on the same represented data. The existing radius estimate includes the two operand scales and a strict half-unit rounding margin on the true coefficients. Consequently the rounding and signed output proof transfers under the five stated premises. All independent size factors and double-width root tables in the outer cost remain charged. The early geometry supplied here still exceeds the limits of host-sized lists. The executable evidence therefore includes signed products at finite geometries and separate real raw-source executions. [Signed precision and outer clock](https://github.com/aliromman/integer-mult-bounds/blob/dfd25d553a843a946ca0b94130a5ff8943e98fdd/research/retimed-native-multiplier/OUTER-CLOCK.md) + +For $g=10^{-18}$ use the inherited bound $(17/g)^{16}<2^{1182}$. The cofinal outer coefficient is at most $1602+220H_M+\log_2 B$ in log units. The finite controller, including private geometry and the scalar prefix, has log ceiling 84,500,001. Taking the larger gives 125,660,241 for the entry rate and 339,787,970 for the terminal rate. In the entry branch $1+\log_2 n\le2^{1274851}$. Converting its entire bound from .00345 to .0038982 costs at most $\lceil(.0038982-.00345)1274851\rceil=572$ bits. The resulting 125,660,813 is below the terminal ceiling. One additional bit pays the selector, header restoration and fixed branch control. This proves the stated all-input ceiling on a single machine. [Formal price conversion](TierCost.lean) · [Full receipt](RESULT.json) diff --git a/research/tiered-native-multiplier/LICENSE b/research/tiered-native-multiplier/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/research/tiered-native-multiplier/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/research/tiered-native-multiplier/MEASUREMENTS.json b/research/tiered-native-multiplier/MEASUREMENTS.json new file mode 100644 index 0000000000..b5cf242025 --- /dev/null +++ b/research/tiered-native-multiplier/MEASUREMENTS.json @@ -0,0 +1,267 @@ +{ + "observations": [ + { + "revision": "8053", + "wall": 83.03838674999997, + "cpu": 82.74014700000001, + "rss_bytes": 309346304, + "python": "3.12.16", + "system": "macOS-27.2-arm64-arm-64bit", + "machine": "arm64", + "installed": [ + [ + [ + 60000, + 18906, + 104652, + 24 + ], + [ + 960000, + 18906, + 104652, + 24 + ], + [ + 20000000, + 105216, + 564144, + 54 + ] + ] + ], + "binary_sha256": "9e7392c52bcf29c0cc58c54c619f95c28f476394c33e8e0a5aa30c9557d31362" + }, + { + "revision": "candidate", + "wall": 5.10587195800008, + "cpu": 5.094125999999999, + "rss_bytes": 277184512, + "python": "3.12.16", + "system": "macOS-27.2-arm64-arm-64bit", + "machine": "arm64", + "installed": [ + [ + [ + 3000, + 18906, + 104652, + 24 + ], + [ + 3080, + 18906, + 104652, + 24 + ], + [ + 1024, + 105216, + 564144, + 62 + ] + ], + [ + [ + 35327, + 18906, + 104652, + 24 + ], + [ + 559005, + 18906, + 104652, + 24 + ], + [ + 680000, + 105216, + 564144, + 62 + ] + ] + ], + "binary_sha256": "9e7392c52bcf29c0cc58c54c619f95c28f476394c33e8e0a5aa30c9557d31362" + }, + { + "revision": "candidate", + "wall": 5.076919667000311, + "cpu": 5.065735000000001, + "rss_bytes": 276201472, + "python": "3.12.16", + "system": "macOS-27.2-arm64-arm-64bit", + "machine": "arm64", + "installed": [ + [ + [ + 3000, + 18906, + 104652, + 24 + ], + [ + 3080, + 18906, + 104652, + 24 + ], + [ + 1024, + 105216, + 564144, + 62 + ] + ], + [ + [ + 35327, + 18906, + 104652, + 24 + ], + [ + 559005, + 18906, + 104652, + 24 + ], + [ + 680000, + 105216, + 564144, + 62 + ] + ] + ], + "binary_sha256": "9e7392c52bcf29c0cc58c54c619f95c28f476394c33e8e0a5aa30c9557d31362" + }, + { + "revision": "8053", + "wall": 82.19959216699999, + "cpu": 81.98890300000001, + "rss_bytes": 309772288, + "python": "3.12.16", + "system": "macOS-27.2-arm64-arm-64bit", + "machine": "arm64", + "installed": [ + [ + [ + 60000, + 18906, + 104652, + 24 + ], + [ + 960000, + 18906, + 104652, + 24 + ], + [ + 20000000, + 105216, + 564144, + 54 + ] + ] + ], + "binary_sha256": "9e7392c52bcf29c0cc58c54c619f95c28f476394c33e8e0a5aa30c9557d31362" + } + ], + "serial_setup": { + "integer_pairs": 4071, + "rational_cases": 7396, + "max_datum_bits": 274877906944, + "lookup": 170141183460469231731687303715884105728, + "local_arithmetic": 297105609434291902295870930944, + "all_setup": 217364570380528137475793294892811967875864032914108887556978854854656, + "setup_exponent": 228 + }, + "subsequent_8054_pair": [ + { + "revision": "8054", + "wall": 94.90161866700055, + "cpu": 91.768531, + "rss_bytes": 324567040, + "python": "3.12.16", + "system": "macOS-27.2-arm64-arm-64bit", + "machine": "arm64", + "installed": [ + [ + [ + 60000, + 18906, + 104652, + 24 + ], + [ + 960000, + 18906, + 104652, + 24 + ], + [ + 20000000, + 105216, + 564142, + 54 + ] + ] + ], + "binary_sha256": "9e7392c52bcf29c0cc58c54c619f95c28f476394c33e8e0a5aa30c9557d31362" + }, + { + "revision": "candidate", + "wall": 5.059486707999895, + "cpu": 5.052404, + "rss_bytes": 277331968, + "python": "3.12.16", + "system": "macOS-27.2-arm64-arm-64bit", + "machine": "arm64", + "installed": [ + [ + [ + 3000, + 18906, + 104652, + 24 + ], + [ + 3080, + 18906, + 104652, + 24 + ], + [ + 1024, + 105216, + 564144, + 62 + ] + ], + [ + [ + 35327, + 18906, + 104652, + 24 + ], + [ + 559005, + 18906, + 104652, + 24 + ], + [ + 680000, + 105216, + 564144, + 62 + ] + ] + ], + "binary_sha256": "9e7392c52bcf29c0cc58c54c619f95c28f476394c33e8e0a5aa30c9557d31362" + } + ] +} diff --git a/research/tiered-native-multiplier/NOTICE.md b/research/tiered-native-multiplier/NOTICE.md new file mode 100644 index 0000000000..71759b91e8 --- /dev/null +++ b/research/tiered-native-multiplier/NOTICE.md @@ -0,0 +1,7 @@ +# Attribution and license + +Ali Romman directed the dilation, charged physical transport, rank choices, tier selection, and integration of this signed multiplier. This work received substantial OpenAI Codex assistance. The contribution includes new calendar bounds, placement and transition proofs, and the independent checks of the changed construction. All archived source retains its Apache 2.0 license and notices. [License](LICENSE) · [Source manifest](SOURCES.json) + +- SYLforge supplied the seven exact K7 return retractions, binary word, chart and register checks, and the two-stage extended and compact comparisons. This package consumes the K7 graph and journal at `baaec65bf8e4c7e92be110a00d5b06522177931f`. ToikY repriced the earlier Gaussian coupling at `e25494616bf149217644ce08d949181ea3600e13` and supplied the live two-return change at `40940734cf582ded0896833b3dc93880299cf927`. ToikY also contributed earlier outer and binary work. [K7 notice](source/K7-NOTICE.md) · [PR #8052](https://github.com/CrocSwap/integer-mult-bounds/pull/8052) · [PR #8053](https://github.com/CrocSwap/integer-mult-bounds/pull/8053) · [PR #8054](https://github.com/CrocSwap/integer-mult-bounds/pull/8054) +- Ali Romman supplied the fixed quadratic phase compiler, sparse derivation of the actual helper data and chronological role segments in PR #8051, and the earlier retimed signed multiplier and connected activation proof in PR #8042. Clear1nsight supplied the competing six-stage and retimed price endpoints. This contribution retains their scientific status and builds on the fixed compiler at `cc21f7040cb3376709b30fc42f289827836d8be5` and retimed machine at `dfd25d553a843a946ca0b94130a5ff8943e98fdd`. [Installer notice](source/INSTALLER-NOTICE.md) · [PR #8051](https://github.com/CrocSwap/integer-mult-bounds/pull/8051) · [PR #8042](https://github.com/CrocSwap/integer-mult-bounds/pull/8042) · [PR #8050](https://github.com/CrocSwap/integer-mult-bounds/pull/8050) +- DreamingOfClouds and Jerry Chen (CubeJerry) supplied physical bank, counted compiler, weighted oracle, and verification work in the source lineage. The numerical graph, grade-14 construction, signed 48-call interpretation, analytic caller, and exact CRT retain their original credits. The archive includes its nested notices. The shared package prerequisite at `0618e75a22cec54d1651394ef83d088551b7f026` comes from Jerry Chen's historical CI repair. [Physical source credits](https://github.com/aliromman/integer-mult-bounds/blob/6285dd829114705862e8d91facaedc1f31d3cfcb/research/single-band-native-carriers/NOTICE.md) · [PR #7257](https://github.com/CrocSwap/integer-mult-bounds/pull/7257) · [Selected record on the canonical base](https://github.com/CrocSwap/integer-mult-bounds/blob/e54523517d0f03e58352e647c403a5af3e525a57/certificates/selected-result.json) diff --git a/research/tiered-native-multiplier/NUMERICAL.md b/research/tiered-native-multiplier/NUMERICAL.md new file mode 100644 index 0000000000..e09739d76c --- /dev/null +++ b/research/tiered-native-multiplier/NUMERICAL.md @@ -0,0 +1,33 @@ +# The numerical word that runs + +The small copy executes the retained signed 48-call Gaussian word on $f$ columns. After it returns, the second copy executes the same word on $79f$ columns. Each copy has its own original owners and all spectator data. On the first copy only, the first 1,008 rank-one child requests issue the two disjoint half-column factors in order. Here $f$ is positive and even. Productive ports stay independent. For a loan at a common rank, both halves act on the original physical job. Their product is the original tensor kernel. The signed caller, fixed odd divisors, absolute Clifford phases, chart reversals, port order, roots and all owner returns run through the retained physical interpreter. The source has 5,674 moves, 6,965 rows, 323,573 donor occurrences per graph call and 1,291 independent roles. The strict physical discharge below uses this source and these copies together. [Physical implementation delta](runtime.patch) · [All-column identity and rational grids](https://github.com/aliromman/integer-mult-bounds/blob/6285dd829114705862e8d91facaedc1f31d3cfcb/research/single-band-native-carriers/STRONG-COMPLEX.md) + +## Directed capacities + +Let $t=1-c$ with $c=2143194013/2^{39}$. Multiply each base grade by the copy's actual column dilation. Replace the 1,008 paid unit grades by 2,016 halves. This gives 105,216 productive labels and 564,144 loans. For each productive grade $k$ use a lower enclosure of $T_k=n_k k^t$. For each paid grade $r$ use an upper enclosure of $P_r=m_r r^t$. Write $T,P$ for their respective sums. The receipt has $(T-P)/T>5.97\cdot10^{-11}$. Assign paid mass in descending order to capacities $T_k P/T$. Each nonempty edge obeys $5r\le4k$. The 62 edge shares are exact rationals. The shares of each paid grade sum to one. The aggregate assigned to grade $k$ is its entire specified capacity. The smallest nonempty share per individual productive label exceeds $2^{-64}$. The independent log/exp enclosure checks the sign again. For the previous physical dilations 1 and 8, it gives a negative margin below $-0.17$ at the new complete rate. Differentiating the signed sum after division by $16^t$ and bounding its derivative on sixteen rational subintervals proves uniqueness of each crossing, including the new peer with 1,006 splits, on $0\le t\le1$. Price headroom in the new construction comes from changing the paid jobs that execute. [Numerical receipt](RESULT.json) · [Second interval calculation](independent_price.py) + +## Finite calendar and honest boundary loss + +Put $M=2^H$, $H\ge1024$, $L=32768$, $U=2\lfloor M/(2048\cdot12087)\rfloor$, $K=M^{82}$, $V=M^6$, $R=M^2$. Keep $M^{92}$ productive rows. A bin $[e,e+2)$ runs $e-8$ real base columns. The large job therefore runs $79(e-8)$ columns. Transport density is $V x^{-1-t}$. Under $y=xr/k$, the change of variables gives the factor $(r/k)^t$ used by the capacity invoice. The prefix fits by $8k\ge10r$, and the lost suffix has fewer than $10k$ axes. The same 6/5 clock levels and delay base $2^{20}$ respect all 564,144 cuts. Their lifetime is below $M^{77}$ and a path through one activation has at most $4H+1$ open raw contexts. The path can enter only one of the two disjoint native copies. All supplied axes carry real data. Padding jobs start at zero and retire through the same phases. [Chronological and boundary proof](https://github.com/aliromman/integer-mult-bounds/blob/dfd25d553a843a946ca0b94130a5ff8943e98fdd/research/retimed-native-multiplier/TRANSFER.md) + +For the new largest grade, $k/r\le20382$ and $k\le12087$. At an exterior integration point $x\le Uk/r.99$, $t>.996$, $\max(k)^c<1.06$ and common boundary mass $\Psi>.19P$. The retained fringe account therefore gives $64/L$. We have $U\ge(1-2^{-128})M/(1024\cdot12087)$. The external productive width lies strictly between $KVM/2$ and $M^{91}$. Thus $M^{92}$ holds at least 4,096 whole productive widths. The final partial group contributes a factor at most $4097/4096$. With $\delta=2^{-128}$ the complete finite multiplier on the raw leaf ratio, including the recursive summation reserve, is bounded by + +$$ +\frac{256}{255}\frac{4097}{4096}\frac{1028}{1024} +(1024\cdot12087 L)^c +\frac{1+64/L+\delta}{(1-10/L)(1-\delta)^3}<2^{43/256}. +$$ + +The executable check proves the inequality with outward integer roots. This buys $ba$ gives $Z=M^{220}(1+B_{\rm ord})$. Every active rank, installed stream and root-factor choice here is the one used for the reported signed product. [Control construction](grades.py) · [Per-use control bound](https://github.com/aliromman/integer-mult-bounds/blob/dfd25d553a843a946ca0b94130a5ff8943e98fdd/research/retimed-native-multiplier/INSTALLATION.md) diff --git a/research/tiered-native-multiplier/README.md b/research/tiered-native-multiplier/README.md new file mode 100644 index 0000000000..694dbf5f33 --- /dev/null +++ b/research/tiered-native-multiplier/README.md @@ -0,0 +1,33 @@ +# A tiered signed multiplier with smaller native ranks + +One signed multitape multiplier attains conditional κ = 0.0038982 for arbitrary binary inputs. It uses the K7 ordinary word, a Gaussian word with physical dilations 1 and 79, and two complete sets of native ranks. The public input header selects the set. Both sets run the same CRT, signed Fourier, product and recovery algorithm. The largest rank is $2^{680000}$. The complete recurring coefficient is at most $2^{339787971}$ tape transitions in the normalization below. [Machine quantities](RESULT.json) · [Sources and exact hashes](SOURCES.json) + +| Complete construction | κ | Ordinary log₂ ranks | Gaussian log₂ rank | Sufficient connected A | Ceiling for log₂ C | +|---|---:|---:|---:|---:|---:| +| Two unsplit K7 returns, PR #8054 | .0038981730255 | 60,000 and 960,000 | 20,000,000 | 21,020,646 | 21,111,681,659 | +| Entry branch | .00345 local | 3,000 and 3,080 | 1,024 | 7,437 | 125,660,241 at its local rate | +| Terminal branch | .0038982 | 35,327 and 559,005 | 680,000 | 1,274,851 | 339,787,970 | +| Single machine | **.0038982** | both sets above | at most 680,000 | **7,437** for a complete native path, **1,274,851** for the terminal path | **339,787,971 at all lengths** | + +For each A the sufficient input length is $2^{\lceil 2^A/6\rceil-1}+1$ significant bits. Here $N_i=2^{H_i}$ and $M=2^{H_M}$ are internal ranks. The price pays for arbitrary inputs, numeric recovery, the smaller branch, every parked bank and every cell traversed. Complete fixed installation falls from a published ceiling of $2^{513}$ to $2^{228}$ tape transitions. Two matched fresh-process observations per version of the preceding fixed-carrier compiler and this complete compiler took 82.62 and 5.09 seconds on average. Input-dependent preparations have their own charge. [Fixed setup and measurements](SETUP.md) [Numerical source, precision and movement](NUMERICAL.md) · [Complete product, clocks and activation](CLOCK.md) + +The complete gain over ToikY’s 1,006-split result is exactly 53949/2000000000000. Its 1-to-8 raw ceiling is below .003898180942173. The previous version with 1,008 splits has a raw crossing below .0038981803447950341293615589, which is already below the new complete rate. [Leading comparison](https://github.com/CrocSwap/integer-mult-bounds/pull/8054) · [Independent interval proof](independent_price.py) + +A lower-rate one-stage configuration in the same source family activates at A = 6,913 with H = 5,610 and numerical H = 1,024. The lower-rate two-stage compact configuration uses 9,100 and 144,000, with numerical H = 8,500 and A = 161,992. At κ = .003893947 the K7 configuration has A = 1,056,618 and numerical H = 36,000. These are smaller in one or more dimensions than the terminal branch above. The 7,437 threshold is for both actual ordinary stages and the numerical supplier. The finite price conversion also applies when an earlier machine has a suitable smaller connected profile. The independently significant terminal comparison is the 29.41-fold reduction in the largest rank exponent and the 16.49-fold reduction in the terminal threshold exponent against K7 extended. [K7 configurations](https://github.com/CrocSwap/integer-mult-bounds/pull/8052) + +## Reproduce + +Use Git and CPython 3.12 with assertions enabled. + +```sh +python3.12 -IB scripts/research_package.py --package research/tiered-native-multiplier +python3.12 -IB research/tiered-native-multiplier/bootstrap.py /tmp/tier-install +python3.12 -B /tmp/tier-install/band_product.py -741503 466013 +``` + +The last command prints `-345550037539` at the ordinary small-input base. The registered replay also runs an explicit physical Fourier geometry, the changed Gaussian source and the K7 interpreter. Open both Lean files with Mathlib and Lean 4.34.1, or run `check_lean.py LEAN_ROOT MATHLIB_ROOT`. [Verification scope](VERIFICATION.md) · [Attribution](NOTICE.md) + +## Open next questions + +- Can a different numerical word or weighted ordinary exchange reduce the terminal exponents by another order of magnitude? The old Gaussian source fails the strict raw moment before finite costs at the new complete rate. +- Can the outer controller generate and serve its enormous sides on physical inputs at an attainable scale? The first full execution proved here still requires at least $2^{7412}$ axes at the certified entry geometry. A production-scale timing comparison remains open. diff --git a/research/tiered-native-multiplier/RESULT.json b/research/tiered-native-multiplier/RESULT.json new file mode 100644 index 0000000000..0254672701 --- /dev/null +++ b/research/tiered-native-multiplier/RESULT.json @@ -0,0 +1,136 @@ +{ + "binary": { + "targets": 18906, + "paid": 104652, + "margin": "55321779883482082595639/244544123725211460862213013703178693829", + "transport_cells": 24, + "physical_factor_upper_millionths": 1101878 + }, + "gaussian": { + "targets": 105216, + "paid": 564144, + "margin": "26805012692229413055189664863/448259604423667117305978754355871799892", + "transport_cells": 62, + "physical_factor_upper_millionths": 1121328 + }, + "entry": { + "kappa": "69/20000", + "binary_H": [ + 3000, + 3080 + ], + "gaussian_H": 1024, + "width_exponents": [ + 276000, + 283360, + 94208 + ], + "rates": [ + "3428763898577864693/1000000000000000000000", + "690000000000001/200000000000000000" + ], + "positive_rate": "2053016477/549755813888", + "signed": { + "strict": 54, + "functional": 4, + "smallest_margin": "1/10000000000000000000", + "ordinary_margin": "1/1000000000000000000", + "positive_margin": "119292388218992043473/419430400000000000000000" + }, + "stock": { + "binary_cuts": [ + 3077, + 6221 + ], + "public_exponent_A": 7437, + "first_public_offset": 4, + "initial_s": 7438, + "stage_and_outer_fixed_log_overhead": 1964, + "retimed_first_stripe_margin": 1701, + "retimed_all_size_margin_floor": 1635, + "absolute_log2_private_control_envelope": 3153922, + "storage_upper": "6.2 p T < 297.6 n bits" + }, + "geometry": { + "public_offset_above_2_to_A": 4, + "first_extent_bits_minus_b": -7433, + "last_extent_bits_minus_b": -7432, + "minimum_width": 3809536, + "log2_axis_count": 7412, + "largest_axis_width": 5592406, + "private_clock_log2_upper": 5734316302, + "actual_dense_root_entry_log2": 11184812 + }, + "variable_cost_surcharges": [ + 0, + 25818582 + ], + "log2_B": 125433359, + "log2_C": 125660241 + }, + "terminal": { + "kappa": "19491/5000000", + "binary_H": [ + 35327, + 559005 + ], + "gaussian_H": 680000, + "width_exponents": [ + 3250084, + 51428460, + 62560000 + ], + "rates": [ + "1923248757962185099/500000000000000000000", + "779640000000001/200000000000000000" + ], + "positive_rate": "22769993547549/5841155522560000", + "signed": { + "strict": 54, + "functional": 4, + "smallest_margin": "1/10000000000000000000", + "ordinary_margin": "1/1000000000000000000", + "positive_margin": "1329962864739041/7130316800000000000000000" + }, + "stock": { + "binary_cuts": [ + 35534, + 594603 + ], + "public_exponent_A": 1274851, + "first_public_offset": 4, + "initial_s": 1274852, + "stage_and_outer_fixed_log_overhead": 1964, + "retimed_first_stripe_margin": 635376, + "retimed_all_size_margin_floor": 615539, + "absolute_log2_private_control_envelope": 696320002, + "storage_upper": "6.2 p T < 297.6 n bits" + }, + "geometry": { + "public_offset_above_2_to_A": 4, + "first_extent_bits_minus_b": -1274847, + "last_extent_bits_minus_b": -1274846, + "minimum_width": 652725504, + "log2_axis_count": 1274819, + "largest_axis_width": 715827883, + "private_clock_log2_upper": 734314544100, + "actual_dense_root_entry_log2": 1431655766 + }, + "variable_cost_surcharges": [], + "log2_B": 190186368, + "log2_C": 339787970 + }, + "old_rate": ".0038981730255", + "rate_delta": "53949/2000000000000", + "entry_premium": 572, + "complete_log2_C": 339787971, + "prefix": { + "small_stop_tail_factor_log2": 1591, + "private_prefix_log2": 126082079, + "controls_prefix_log2": 5081414, + "private_prefix_after_input_log2": 84484466, + "early_log2_C_bound": 84500000, + "tail_log2_fixed_factor_including_b_to_n": 1434, + "tail_unit": "(1 + B + Z) * n * (1 + log2(n))^(1-kappa)" + } +} diff --git a/research/tiered-native-multiplier/SERIAL-SETUP.md b/research/tiered-native-multiplier/SERIAL-SETUP.md new file mode 100644 index 0000000000..b9b8b3f1e2 --- /dev/null +++ b/research/tiered-native-multiplier/SERIAL-SETUP.md @@ -0,0 +1,19 @@ +# Serial arithmetic in fixed installation + +With the fixed indexed-action and width bounds of the quadratic installer, the complete two-tier setup takes fewer than $2^{228}$ individual tape reads, writes and moves. This includes the original $2^{32}$ multiplier for parsing, hashing, initialization and cleanup. The improved price comes from the arithmetic implementation and a sharper sum of the existing charges. It does not give an elapsed-time ratio. [Predecessor fixed census](https://github.com/aliromman/integer-mult-bounds/blob/cc21f7040cb3376709b30fc42f289827836d8be5/research/quadratic-native-installation/COST.md) + +Store a magnitude as a delimited binary word, most significant digit first. Zero is the one digit `0`. Store a sign separately. Use separate work tapes for the operands, output, quotient, alignment and temporary sums. In the reference program a forward or backward word iterator is one sequential traversal. Reverse emission uses a separate tape. Removing leading zeros, concatenation, and making a copy with the last digit omitted each use one or two sequential passes. The last operation uses one symbol of lookahead. A temporary tape is rewound and cleared. The comparison of equal-length digit strings reads both tapes from the same end. The reference uses this representation for all unbounded arithmetic. Its only primitive division, `divmod(digit, 2)`, acts on a carry and two one-bit digits. [Serial operations](serial_setup.py) + +**Division.** Let the two positive magnitudes have bit lengths $a\ge b$. Scan their inputs together for the first $b$ digits. For each of the $a-b$ remaining dividend digits, write a zero on a separate tape. Append these zeros to a copy of the divisor. This aligns its high digit with the high digit of the dividend. The dividend is initially less than twice the aligned divisor since both have $a$ digits. Emit one quotient digit per alignment. Compare the entire remainder to this divisor, then subtract it if the result is nonnegative. Shift a copy of the divisor one position to the right for the next iteration. After a comparison the remainder is below the old aligned divisor. Before the next comparison it is below twice the new aligned divisor. The last comparison uses the original divisor. This proves the quotient and remainder identity with remainder strictly smaller than the divisor. A shorter dividend returns quotient zero and restores a copy of the dividend. A zero divisor is rejected. + +Let $h$ bound the two input lengths. The setup, copies and final truncation need fewer than 16 whole-word passes. One quotient digit needs fewer than 16 passes over words of at most $h+4$ tape symbols. This includes comparison, two rewinds, subtraction, the backward and forward output copies, shifting the divisor, resetting both argument heads, advancing the unary loop and clearing or reusing the bounded scratch. Moving to the opposite end before a reverse scan counts as a pass. In one such pass allow 64 transitions per position. The local state reads at most four current symbols, writes at most three and moves at most four heads per symbol. End tests, delimiters, the sign, carry, and a constant number of shifts fit the allowance. Thus $2^{11}(h+4)(a-b+3)$ suffices for division with clear work tapes and the quotient and remainder returned. The short and zero cases use fewer transitions. + +**Euclid and signed operations.** The sign-normalized first division has $a\ge b$. Write $a_i,b_i$ for the successive bit lengths and $k$ for the number of nonzero divisors. At every nonfinal step $a_{i+1}=b_i$, so $\sum_i(a_i-b_i)\le h$. In two steps a positive divisor falls below half its previous value or the procedure finishes, which gives $k\le 2h+2$. The sum of all alignment lengths is therefore at most $h+k$. This counts quotients with one bit, including consecutive such quotients near the Fibonacci worst case. + +The program also computes both Bézout coefficients. Their recurrence takes each of the two columns $(u,v)$ to $(v,u-qv)$. It preserves each remainder as the signed combination of the two inputs. The nonzero signs of each column alternate from the initial pair of unit rows, allowing a zero at the start. After the initial terms, the magnitudes are nondecreasing, since $q\ge1$ and $|u-qv|=|u|+q|v|$ when $u$ and $v$ have opposite signs or one is zero. The final zero row is a primitive integer relation because every Euclid row replacement has determinant $-1$. For positive inputs $A,B$, its two magnitudes are $B/g,A/g$ for $g=\gcd(A,B)$. This bounds every intermediate coefficient by $\max(A,B,1)$. It includes the product $q|v|$ as well. A zero original operand uses the unit row directly. Swapping inputs or restoring their signs changes neither bound. + +To multiply $v$ by $q$, process the quotient from its high end. Double the accumulated magnitude, then add $|v|$ if the next digit is one. Every prefix product is at most $q|v|$. One quotient digit requires fewer than 16 passes of the same $h+4$ symbols, including leading-zero deletion, addition and scratch release. The two signed additions following the two products each take fewer than 16 passes. The quotient has at most $a_i-b_i+1$ digits. The divider, both products, the two updates and the row and input copies fit $2^{16}(h+4)(a_i-b_i+3)$ per Euclid division. The full Bézout result, including the initial swap, sign handling, final copy and cleanup, costs at most $2^{16}(h+4)(7h+9)$. The three extra units include these boundary passes. [Quotient and Bézout implementation](serial_setup.py) + +**Whole installer.** Use $w=2^{38}$ for the length of an individual indexed datum. Both scalar operands can have this full width. Signed rational addition uses two cross-products and a sum in its numerator and one product in its denominator. Multiplication and division use two products. All unreduced magnitudes have at most $h=2w+2$ bits. Reduction uses the preceding Euclid implementation followed by two exact unsigned divisions. In addition to the Euclid term, $8\cdot2^{16}(h+4)^2$ suffices for all products, signed sums, exact divisions, normalization and erasure. Thus one complete rational operation takes fewer than $2^{110}$ local steps. Long serialized strings may occupy the whole $w$-bit field during lookup or parsing. The scalar proof permits the same width for the numerators and denominators. It does not assume that they have the smaller sizes seen in timing runs. + +With $2^{68}$ actions and records of up to $4w$ cells, every old value and every new value fit in $2^{108}$ cells together. The original complete lookup costs $8\cdot2^{108}\cdot512\cdot128=2^{127}$ transitions with the rewrite stream, cursor and key restoration. Let $E=2^{16}(h+4)(7h+9)+8\cdot2^{16}(h+4)^2$. The setup bill is $(2^{68}+1)(2^{127}+E+2^{120})2^{32}<2^{228}$. The $2^{120}$ allowance and the parsing and cleanup multiplier remain charged. The input-dependent calendar construction and every active numerical tape keep their separate recurring price. The code checks the exact integer inequality together with 4,071 quotient or Bézout inputs and 7,396 rational operations. This finite test supplements the proof for all operand lengths. [Independent arithmetic and exact budget checks](check_serial_setup.py) diff --git a/research/tiered-native-multiplier/SETUP.md b/research/tiered-native-multiplier/SETUP.md new file mode 100644 index 0000000000..9512c6724c --- /dev/null +++ b/research/tiered-native-multiplier/SETUP.md @@ -0,0 +1,30 @@ +# Fixed installation and measurements + +The complete two-tier installation takes fewer than $2^{228}$ single-tape reads, writes and moves on the stated multitape machine. The fixed store, including old value versions and scratch for the indexed representation, is bounded as in the source by $2^{108}$ record cells, with separate constant-many local arithmetic tapes of length $O(2^{38})$. The incumbent reports $2^{513}$ transitions. The quadratic installer already had a $2^{241}$ bound on its earlier configuration. The last reduction from 241 to 228 comes from sequential arithmetic and a tighter tape accounting. The incumbent can also use that lowering after its own scalar-action and width census. The distinct changes in actual work are the quadratic phase generation, shared chronological roles, and removal of numbered grade materialization at installation. [Serial arithmetic proof and exact integer bill](SERIAL-SETUP.md) · [Quadratic installer and source](https://github.com/aliromman/integer-mult-bounds/blob/cc21f7040cb3376709b30fc42f289827836d8be5/research/quadratic-native-installation/COST.md) + +## Installed sources and active work + +The binary constructor authenticates and replays the K7 source. Removing seven terminal moves reduces the number of charged operations and operational chart pairs from the earlier binary graph. The Gaussian producer authenticates the 48-call graph, builds the 60,206 shared rational coefficients, and compiles each chart and its absolute phase by a binary quadratic form. The original single-width caller used 334,176 typed roles. The shared source keeps 25,621 distinct records and 145 chronological segments. Those changes were made in PR #8051. The two new grades objects compute one histogram for each distinct segment and concatenate the chronological rank streams at the required dilations. They add both halves at each of the first 1,008 unit loans in the first stream. The dense prior implementation constructed 105,216 productive and 564,144 paid grade entries during fixed preparation. The new implementation instantiates these 669,360 ordinal entries at each active calendar construction and shares the installed grades and coupling across the two tiers. [Installed representation](grades.py) · [Physical calendar and charge](NUMERICAL.md) + +The same scalar-action bound of $2^{68}$ and individual width $w=2^{38}$ bits apply to the changed sources. The original $2^{64}$ allowance for numeric preparation covers the quadratic compiler and the full pair of words. K7 needs fewer binary operations and a subset of the earlier graph's used frame pairs. There are fewer than $2^{20}$ Gaussian roles. The two dilations and the signed split add at most a constant number of fixed operations per role. The two immutable Gaussian grade streams and their histograms serve both tiers. A single Gaussian price constructs 62 cells. It uses at most 39 root and 40 product steps per endpoint for fewer than $2^8$ distinct grades. All resulting cell numerators and denominators have fewer than 512 bits. The extra recipes contain only references to the same words and couplings, finite rank exponents, rational stops and the two price profiles. All these additions, including the 39-step directed enclosure, fit $2^{32}$ further indexed operations. This is within the original $2^{68}$ bill, which bounded the numerical generation by $2^{64}$ and both 36-call and 48-call compilers together with spare capacity. Reading and restoring the new package and both archived sources uses the charged fixed parsing, comparison, hash, decompression, initialization and cleanup allowance. Active geometry, coefficient precision, full-rank control files and the reconstruction of the two grade sequences receive the separate recurring price in the clock. [Pinned complete predecessor census](https://github.com/aliromman/integer-mult-bounds/blob/dfd25d553a843a946ca0b94130a5ff8943e98fdd/research/retimed-native-multiplier/INSTALLATION.md) · [Installed source bindings](SOURCES.json) + +## Observed host installation + +Four serial fresh-process observations used CPython 3.12.16 on macOS 27.2 arm64. Order was incumbent, candidate, candidate, incumbent. Each process restored the authenticated source, installed the complete fixed program, built all recipes delivered by that multiplier, checked the installed dimensions and common K7 digest, then removed its private temporary directory. The comparison uses ToikY's extended multiplier and the complete two-tier candidate. CPU includes the process and its children. Peak resident bytes refer to the compiler process. The runs share the host filesystem cache and ordinary machine load. [Raw observations](MEASUREMENTS.json) · [Measurement entry](measure_setup.py) + +| Fixed installation | Wall seconds | CPU seconds | Peak resident bytes | +|---|---|---|---| +| Fixed-carrier K7 in PR #8053 | 83.0384, 82.1996 | 82.7401, 81.9889 | 309,346,304 and 309,772,288 | +| Both tiers of this multiplier | 5.1059, 5.0769 | 5.0941, 5.0657 | 277,184,512 and 276,201,472 | + +The ratio of the mean elapsed times is 16.23. The same K7 source digest appears in all four records. The incumbent installed three rank recipes with 54 Gaussian coupling cells. The candidate installed six recipes for two profiles, with shared banks and 62 Gaussian cells. These observations apply to fixed compilation. No comparable production-size multiplication timing is available. [Pinned competitor verifier](https://github.com/ToikY/integer-mult-bounds/blob/e25494616bf149217644ce08d949181ea3600e13/research/p104-gaussian-fixed-carrier/verify.py) + +A subsequent matched pair ran the newly published 1,006-split PR #8054 and the candidate in fresh processes. The peer took 94.902 seconds elapsed, 91.769 seconds CPU and 324,567,040 peak resident bytes. The candidate took 5.059 seconds elapsed, 5.052 seconds CPU and 277,331,968 bytes. This is one paired observation. The peer produced 564,142 numerical loans. The candidate produced 564,144. [Two-unsplit-return source](https://github.com/ToikY/integer-mult-bounds/blob/40940734cf582ded0896833b3dc93880299cf927/research/p104-gaussian-unsplit-returns/prepare.py) + +Given an exact checkout of PR #8053, pass its package directory as the argument to the first command. Run each command in a new process. + +```sh +python3.12 -IB research/tiered-native-multiplier/measure_setup.py --peer-8054 /path/to/research/p104-gaussian-unsplit-returns +python3.12 -IB research/tiered-native-multiplier/measure_setup.py --peer-8053 /path/to/research/p104-gaussian-fixed-carrier +python3.12 -IB research/tiered-native-multiplier/measure_setup.py +``` diff --git a/research/tiered-native-multiplier/SOURCES.json b/research/tiered-native-multiplier/SOURCES.json new file mode 100644 index 0000000000..9d532ab36f --- /dev/null +++ b/research/tiered-native-multiplier/SOURCES.json @@ -0,0 +1,130 @@ +{ + "schema_version": 1, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "files": [ + { + "path": "AGENTS.md", + "git_blob": "ff81117fca368042f6092964d1f54eb4e6e08fb9", + "sha256": "fece32cdec9c1572ddce354a0b623459cb2c4ca162125d36d36262a92e3caa83", + "usage": "provenance" + }, + { + "path": "autoresearch.md", + "git_blob": "2fe84a7b30b1e26e60ce0ec4775894eb1831c5d6", + "sha256": "d16f0d3bb4d4b213d06c128db6d6460b0fe9ec1ac5a6c1ea1febf1db40e7b60d", + "usage": "provenance" + }, + { + "path": "CONTRIBUTING.md", + "git_blob": "5185786f2ec00f215019fb5777d70979429690a9", + "sha256": "fcd1a8d0e52342a23b8ffa9e905e85ccc539fb084145ef016dfc93cedfb3d924", + "usage": "provenance" + }, + { + "path": "certificates/selected-result.json", + "git_blob": "75d77b328ea02ded535e7f23aee5b1e55d0bb1a8", + "sha256": "154c3d30455d778fd3343b6b4851f0fa4665f0f7625b0adb3675e2bafbbf6bf1", + "usage": "provenance" + }, + { + "path": "docs/research/agent-task-catalog.json", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81", + "usage": "provenance" + }, + { + "path": "research/unconditional-batched-crt/CRT.md", + "git_blob": "d98dd8e368431cac33d5fc1c8c336696663641d6", + "sha256": "02c3a1e38cbee25aefe2640cc72676da62ba10eb7519fbcb9adb9d48b74eff2b", + "usage": "provenance" + }, + { + "path": "research/delayed-cover-physical-batch-routing/PROOF.md", + "git_blob": "af919b5ba2257c07ea17180f9b8c9fd457556079", + "sha256": "1c3dcd294d327a16fa081b7ea27497941ac6480d352f53e55e8b9e87f45d1454", + "usage": "provenance" + }, + { + "path": "notes/compact-control-movement.tex", + "git_blob": "06b6a9ef24245ac7b724c53a204635415b402357", + "sha256": "b963c3d2f4e1b7059aa289bb4b4ac89b688920bcf42f5b20d7698cdef0132cc6", + "usage": "provenance" + } + ], + "canonical_main": "e54523517d0f03e58352e647c403a5af3e525a57", + "retimed": "dfd25d553a843a946ca0b94130a5ff8943e98fdd", + "quadratic_installer": "cc21f7040cb3376709b30fc42f289827836d8be5", + "k7": "baaec65bf8e4c7e92be110a00d5b06522177931f", + "installer_files": { + "bootstrap.py": "17229a98e1da1c03fcc95accdfa7f804667f9c983f768cd3b53c24b611ae901f", + "retimed-source.tar.gz": "3d30e35c5a77f43372e94ccca7aaa38ce706631fc5b4601293bbd8619dfb2775", + "SOURCES.json": "0c5d1999cf744db7c71b29fbd0601e18fa50c7fa134c172ff713ddad65fadff1", + "production.patch": "54a5be1f9a9961fbbf23df7fb874194bc208ea6b87ca01742f87ec8027f0ca7e", + "gauss_phase.py": "a087d0dd5f448d39e6a2dfdc876be7238b75a55b8f9c350eda3907a1865bcb56", + "phase_atlas.py": "6425300f5d3d984290496df0ff411aca6879869b285298e553cd4d94ba02faa7", + "clock_ports.py": "7d67eb9db9c50fec056440ef17acc6566cdcac740f44d74790213a5179d34b1e", + "sparse_helpers.py": "823144823a54b0e79ee9891ed0bc7ba6fb7ecd846fbc1d0d287f19b3a046ecbd", + "LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "NOTICE.md": "c6b1753ad6ebda2a2143b1a9efc80fadad6c1b27552c3ec8bc7bfdb431fb8eeb" + }, + "runtime": { + "band_product.py": { + "before": "98595de1aa89a158cfddeb462f9a87bad4a8d59c0d1eb01f24790cb46050044d", + "after": "0a2a243378ced624fa94100d7743bab5209edacda1e3b5a5c2fda6fd0a66791b" + }, + "binary_receiver.py": { + "before": "670c500573ef35b5faba27af4e1ec62922db96877dc1af1db337f82ff362d0ca", + "after": "a7cc759e9a88e60dbcd59ca314ae5b9d39a33b5c642b56e680bbab775b0f06c5" + }, + "independent_binary_price.py": { + "before": "1936595a79fbfa14ec74af3b4e521216740d00bd45f379b5e97a1440e5a2aaf9", + "after": "05f77dd77baff30ff241744901769b952de43859e00afb0739c8b4e18dc30dd2" + }, + "installations.py": { + "before": "2244e7e27f7348575944eb652a741861a0a04d77b18c297db221ef74b3116a16", + "after": "1c6978b8c7d136ef87191512d9ab9eb3dda8a818844244b96cb165d46d97b1df" + }, + "ordinary_carrier.py": { + "before": "e2d07d8136bda5b6a74160e3625cb8c1a0deef2c42bdb4e8cfd7a8d7e3922394", + "after": "aa1a64d48daf22f3918922481899a460dfe8e70268388e41f133279bc78f141d" + }, + "retimed_supplier.py": { + "before": "a50112eb4ee9e56532f54b79bc68f6c2b395be3c717b1e9a0e4178a5b76d846e", + "after": "9c89e67dcc480f2a3664f15446159701c98ef9d7518dbd175baf9a76453eb82f" + }, + "strong-bit.json.gz": { + "before": "74e93daf2b7acf794ffb51f92f03f51556f68126d41ee13a8969bddb4cbe6326", + "after": "9e7392c52bcf29c0cc58c54c619f95c28f476394c33e8e0a5aa30c9557d31362" + }, + "strong_binary.py": { + "before": "dddbfa0a3ae6ee1fc847c24b9b1e2115809d126acafbea988e5331cee3bbb0a4", + "after": "64673cce85c94f90c498ca01bfda138bb98e08b56ad3777c6565be86bde09020" + }, + "transport.py": { + "before": "98bdb540233794338b426d1b0d0e72cff7fcbbd08be702af0d81e237dbecaae9", + "after": "9eb8f0d77a4c53fc4fddffdfe198cab930b6d1f49e2b6d43c970397051bb7818" + }, + "unpowered_price.py": { + "before": "c273f2bcd46a114595ee669021aa6cd7223488f87cee0fe10bd762bc92177424", + "after": "a6c80d4605065889bb49144c034965a6bf33d8fad7f73ef97dcf1089e48316b4" + } + }, + "archive_and_overlay_sha256": { + "source/INSTALLER-NOTICE.md": "c6b1753ad6ebda2a2143b1a9efc80fadad6c1b27552c3ec8bc7bfdb431fb8eeb", + "source/K7-NOTICE.md": "9c5ae9750012d305d917e625d14a33cc880e810e801e73364725bcdc24bffdb5", + "source/K7-STACK-LEDGER.json": "a0c0d5b241e6861a5c49a287617e48fba56b09824f5ef4fcb7f03152edf37e8e", + "source/activation.py": "6e7f89d40a4d10ecd40a50e5b96334dfc64db90841ece7e3ef12eeca5ee5093b", + "source/check_binary_k7.py": "5eeb8f818725249cbabf215c323c3f8351b1c4ed3c127119341e6ed09f490dd6", + "source/installer.tar.gz": "6696459e2e3552f802e7caaaf93dc86c9bb6b62ee38631702bff2e3a8a9a481a", + "source/ordinary_clock.py": "91dcf0ef72dddbde998b80f3d8b30c8036de9ce97e06e2bbd9c4159bf292020d", + "source/outer_budget.py": "ca4438db28a447ed5c43d87d43f0ac10a0cb2b4e183342ac93139d517b9d4d02", + "source/outer_clock.py": "63363c3da673365f3ac5e1b7e318c6938005f1e9c9896799504cc598efbf96fa", + "source/strong-bit-k7.json.gz": "9e7392c52bcf29c0cc58c54c619f95c28f476394c33e8e0a5aa30c9557d31362", + "runtime.patch": "6c93961841be2abc3629928074e2c7917d264e94187276fc88a33f922a3c62e4", + "grades.py": "340684fdd5ca0e611836b0e7301f1c339282ba532bf9e3ec8055944d8981f3c8", + "installations.py": "1c6978b8c7d136ef87191512d9ab9eb3dda8a818844244b96cb165d46d97b1df" + }, + "live_comparator": "40940734cf582ded0896833b3dc93880299cf927", + "repriced_fixed_carrier": "e25494616bf149217644ce08d949181ea3600e13", + "live_comparator_replay_head": "f6f4ecd5dd717ce2b155dd564469e9693ac90f6d" +} diff --git a/research/tiered-native-multiplier/ScaledEntrance.lean b/research/tiered-native-multiplier/ScaledEntrance.lean new file mode 100644 index 0000000000..0823ea46fc --- /dev/null +++ b/research/tiered-native-multiplier/ScaledEntrance.lean @@ -0,0 +1,28 @@ +import Mathlib.Tactic + +namespace ScaledEntrance + +def upper (M : ℕ) := 2*(M/(2048*12087)) +def band (M : ℕ) := 2*((3*upper M)/8) +def actualSize (M : ℕ) := 10191*(band M-8) + +/-- All integer rounding in the changed physical entrance, including the period fences. -/ +theorem placement (M : ℕ) (large : 10^13 ≤ M) : + (32768 < band M) ∧ + (4424 * upper M < 10191 * band M) ∧ + ((band M+2)*10191 < 4424*M) ∧ + (1616 * actualSize M < M) ∧ + (M+6000 < 1620*actualSize M) := by + simp only [upper, band, actualSize] + omega + +/-- Both following tickets belong to the five-hit prefix and differ from slot one. -/ +theorem tickets (M : ℕ) (large : 10^13 ≤ M) : + 3240 < 5 * ((1620*actualSize M - M)/4) ∧ + 1620/5 = 324 ∧ 3240/5 = 648 := by + have h := (placement M large).2.2.2.2 + omega + +#print axioms placement +#print axioms tickets +end ScaledEntrance diff --git a/research/tiered-native-multiplier/TASK.json b/research/tiered-native-multiplier/TASK.json new file mode 100644 index 0000000000..0c085c2bab --- /dev/null +++ b/research/tiered-native-multiplier/TASK.json @@ -0,0 +1,93 @@ +{ + "schema_version": 1, + "task_id": "selected-stock-envelope", + "priority_revision": 8, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "original_card": { + "id": "selected-stock-envelope", + "question": "What explicit uniform stock envelope does the actual selected stopped producer supply at one bootstrap stage?", + "starting_points": [ + "research/selected-bootstrap-stock-audit/README.md", + "research/bootstrap-cutoff-time-space-split/README.md", + "certificates/selected-result.json", + "docs/research/community-efficient1000-review.md", + "research/stock-margin-chain/README.md" + ], + "methods": [ + "Derive a source-bound reserve recurrence at the actual selected atom widths, separating parent stock from completed inner borrowing.", + "Find an exact missing implication or counterexample to a proposed selected-stage stock envelope." + ], + "acceptance_gate": "Bind every coefficient and depth factor to the selected producer and state the width domain. Compare a proved envelope with the sufficient cutoff guard; a large numerical headroom or a historical m=120 coefficient is not a selected m=73 proof.", + "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": "Choose one actual selected producer/stage and derive its parent reserve and depth coefficient from source. Check whether newer handoffs already cover that exact obligation. Stop with the missing implementation lemma if it cannot be bounded; do not rerun #2972 cutoff/headroom arithmetic as a new contribution.", + "bottleneck_link": "This reduces a concrete inherited implementation obligation without confusing unchanged kappa arithmetic with a completed theorem.", + "allowed_variations": [ + "One stage or one explicit reserve/depth implication.", + "An independently checked same-domain proof repair, retaining all remaining assumptions." + ], + "scope_change_triggers": [ + "Importing the historical 57604 or 252 allowance without a selected-producer binding.", + "Calling a conditional fit lemma a full outer-proof adoption.", + "Replacing an actual selected stock coefficient with cutoff comparisons or a conditional fit inequality." + ], + "overlap_terms": [ + "selected stock", + "stock envelope", + "bootstrap cutoff", + "1956", + "1965", + "1990", + "2972", + "stock-margin-chain", + "actual_stock_coefficient" + ], + "existing_checks": [ + { + "scope": "Retained stock audit identifies missing actual selected-stage coefficients; later cutoff-chain arithmetic does not supply them.", + "evidence": "docs/research/research-family-status.md#revision-6-handoffs-source-archives-awaiting-independent-validation", + "remaining": "Derive one actual reserve/depth coefficient from the selected producer.", + "status": "reviewed", + "source_commit": "836b19bfa309ceafbc8ee32a15e8c4b10dde7e11", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + } + ] + }, + "claim": "https://github.com/CrocSwap/integer-mult-bounds/discussions/8039#discussioncomment-19819246", + "related": [ + "https://github.com/CrocSwap/integer-mult-bounds/pull/8027", + "https://github.com/CrocSwap/integer-mult-bounds/pull/8030", + "https://github.com/CrocSwap/integer-mult-bounds/pull/8035", + "https://github.com/CrocSwap/integer-mult-bounds/pull/8042", + "https://github.com/CrocSwap/integer-mult-bounds/pull/8050", + "https://github.com/CrocSwap/integer-mult-bounds/pull/8051", + "https://github.com/CrocSwap/integer-mult-bounds/pull/8052", + "https://github.com/CrocSwap/integer-mult-bounds/pull/8053", + "https://github.com/CrocSwap/integer-mult-bounds/pull/8054" + ], + "scope_status": "changed", + "actual_scope": "Construct one signed multiplier with a higher complete rate and smaller fixed ranks, setup and connected activation. Give an absolute recurring tape clock.", + "scope_change_reason": "The donor assigned joint construction scale and complete rate. The live K7 binary word moved the bottleneck to the Gaussian transport.", + "bottleneck_link": "Two identical grade supports at dilations one and eight have insufficient signed capacity at the new rate. The last ordinary stage and the numerical rank set the required outer precision.", + "stop_rule": "Require a strict comparison with the current open leader, one complete all-input clock, two connected execution thresholds, a literal physical source replay and signed numerical recovery.", + "evidence": "RESULT.json, NUMERICAL.md, CLOCK.md, SETUP.md, MEASUREMENTS.json, ScaledEntrance.lean, TierCost.lean, and the registered replay.", + "author": "Ali Romman", + "ai_assistance": "Substantial OpenAI Codex assistance on the construction, proofs and adversarial checks.", + "outcome": "completed", + "open_questions": [ + { + "question": "Can a new Gaussian source and a cheaper weighted ordinary call reduce the terminal size of both suppliers?", + "why_it_matters": "The terminal numerical rank remains at 2^680000, and the first connected outer geometry requires 2^7412 genuine CRT axes.", + "first_step": "Supply a physical source with a larger directed moment or a cheaper physical child exchange. Reprice both stages and the numerical caller.", + "blocked_by": "The two-copy Gaussian source and the K7 binary word both have finite raw price ceilings." + } + ] +} diff --git a/research/tiered-native-multiplier/TierCost.lean b/research/tiered-native-multiplier/TierCost.lean new file mode 100644 index 0000000000..716dec61d1 --- /dev/null +++ b/research/tiered-native-multiplier/TierCost.lean @@ -0,0 +1,38 @@ +import Mathlib.Tactic + +namespace TierCost + +/-- Each admitted high fibre has enough cells to pay its coefficient clock. -/ +theorem highFibre (k : ℕ) (hk : 30 ≤ k) : 2660000 * (k + 2) < 2 ^ k := by + induction k, hk using Nat.le_induction with + | base => decide + | succ k hk ih => + rw [pow_succ] + omega + +/-- Convert a rate on a finite initial interval to the global rate. -/ +theorem finitePrefix (x A lo hi : ℝ) (hx : 0 < x) (hA : x ≤ (2:ℝ)^A) + (hh : lo ≤ hi) : x^(1-lo) ≤ x^(1-hi) * (2:ℝ)^(A*(hi-lo)) := by + have h := Real.rpow_le_rpow hx.le hA (sub_nonneg.mpr hh) + rw [← Real.rpow_mul (by norm_num : (0:ℝ) ≤ 2)] at h + calc + x^(1-lo) = x^(1-hi) * x^(hi-lo) := by + rw [← Real.rpow_add hx] + congr 1 + ring + _ ≤ _ := mul_le_mul_of_nonneg_left h (Real.rpow_nonneg hx.le _) + +theorem entryPrice (x : ℝ) (hx : 0 < x) (hA : x ≤ (2:ℝ)^(1274851:ℝ)) : + x^(1-(345:ℝ)/100000) ≤ x^(1-(38982:ℝ)/10000000) * (2:ℝ)^(572:ℝ) := by + apply (finitePrefix x 1274851 (345/100000) (38982/10000000) hx hA (by norm_num)).trans + apply mul_le_mul_of_nonneg_left _ (Real.rpow_nonneg hx.le _) + exact Real.rpow_le_rpow_of_exponent_le (by norm_num) (by norm_num) + +theorem strictGain : + (19491:ℚ)/5000000 - 7796346051/2000000000000 = 53949/2000000000000 := by norm_num + +#print axioms highFibre +#print axioms finitePrefix +#print axioms entryPrice +#print axioms strictGain +end TierCost diff --git a/research/tiered-native-multiplier/VERIFICATION.md b/research/tiered-native-multiplier/VERIFICATION.md new file mode 100644 index 0000000000..59f0deac99 --- /dev/null +++ b/research/tiered-native-multiplier/VERIFICATION.md @@ -0,0 +1,25 @@ +# Verification and scope + +The registered check restores the actual signed program from its archived source in a new empty directory for each scope. Each restoration verifies the outer archive, exact member set, individual hashes, input images, patch and output images. It uses Git and CPython 3.12 with assertions. It requires no network connection. [Bootstrap](bootstrap.py) · [Manifest](SOURCES.json) · [Registered commands](VERIFY.json) + +```sh +python3.12 -IB scripts/research_package.py --package research/tiered-native-multiplier +``` + +| Check | Evidence | +|---|---| +| Complete invoice | The checker builds all six installed recipes, compares independently enumerated productive and paid grades, and checks both exact prices. It recomputes 54 strict and four functional signed inequalities per profile, the activation, first physical exchange, stock and complete transition bounds. It compares the full receipt with committed bytes. [Receipt](receipt.py) · [Placement](check_placement.py) | +| Independent numerical price | A second rational logarithm and exponential enclosure bounds both the 1,008- and 1,006-split 1-to-8 signed moments, their derivatives over the whole admissible interval, and the new 1-to-79 moment. Its negative control rejects the old source at the new complete rate. [Interval check](independent_price.py) | +| Binary physical calls | The inherited K7 checker replays all independent registers and every chronological dirty clear and move. It checks all 2,353 chart pairs, all 44,734 frame gates, the 36-call outer word and the weighted physical transfers. [K7 checker](source/check_binary_k7.py) | +| Numerical physical calls | The new raw word executes on two independent, nonzero tensor-product witnesses. The widths are 2 and 158. All 564,144 loans issue, all 105,216 owners receive writes and every handle retires. There are 143,616 owner writes, 119,470,080 requested output axes and 115,056 peak live handles. The individual ray evaluator uses closed tensor products. It does not materialize a dense state of dimension $2^{1422}$. The written all-column argument applies to arbitrary inputs under the retained premises. [Physical replay](check_gaussian.py) · [Numerical proof](NUMERICAL.md) | +| Signed product | The public binary entry handles signs, zero, padded input intervals and head restoration. The two-axis Fourier test uses the physical movement back end and the same signed product class on supplied finite CRT sides. It returns −345550037539 for −741503 and 466013, from coefficients 11811, 10996, 4152, 868, 77. It executes 157,248 H calls and 138 shuttles with 633,744 padded bytes. The ordinary public entry for these two small operands uses its specified scalar base. [Product check](verify.py) · [Complete signed account](CLOCK.md) | + +The fixed-setup replay also checks 4,071 division or Bézout inputs and 7,396 rational arithmetic cases against independent integer and fraction arithmetic. It checks the full explicit bound of $2^{228}$ transitions. The phase census exercises both residue classes on the actual graph and recovers each additional charged field traversal. [Arithmetic proof](SERIAL-SETUP.md) · [Phase check](check_phase_passes.py) + +The Lean proofs cover the integer placement and ticket fences, the high-fibre induction, the finite-interval conversion and the exact comparison with the live complete price. The supplied runner builds both modules with Lean 4.34.1 and Mathlib revision `d13f23b723b8a846827a245b89c10fc7d3f11612`, prints theorem axioms and invokes the standalone `leanchecker` on both objects. The high-fibre statement uses `propext` and `Quot.sound`. The other listed declarations use only `propext`, `Classical.choice` and `Quot.sound`. [Placement](ScaledEntrance.lean) · [Clock](TierCost.lean) · [Kernel replay](check_lean.py) + +```sh +python3.12 -IB research/tiered-native-multiplier/check_lean.py LEAN_ROOT MATHLIB_ROOT +``` + +The full circuit interpretation, charged calendar and tape layout, analytic error and product proof remain written mathematics with exact finite checks. The five inherited scientific premises remain external. The production activation lengths exceed physical execution capacity. The setup measurements cover the compiler itself. No multiplication timing or performance crossover at those lengths is available. [Complete assumptions and clock](CLOCK.md) · [Fixed installation measurements](SETUP.md) diff --git a/research/tiered-native-multiplier/VERIFY.json b/research/tiered-native-multiplier/VERIFY.json new file mode 100644 index 0000000000..4c1d8aadbc --- /dev/null +++ b/research/tiered-native-multiplier/VERIFY.json @@ -0,0 +1,75 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py", + "price" + ], + "timeout_seconds": 170, + "checks": "Rebuild and price both complete source profiles, all signed margins, true placement, activation and the all-input transition bound." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py", + "interval" + ], + "timeout_seconds": 150, + "checks": "Bound the old global Gaussian crossing and the changed signed moment with independent log and exp enclosures." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py", + "binary" + ], + "timeout_seconds": 140, + "checks": "Replay K7 on all independent roles, rational charts and weighted physical controls." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py", + "gaussian" + ], + "timeout_seconds": 180, + "checks": "Execute both complete numerical words on independent nonzero witnesses and check all loans, owners and releases." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py", + "product" + ], + "timeout_seconds": 200, + "checks": "Run the signed general entry and compare exact physical Fourier coefficients, product and restored input heads on a finite geometry." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py", + "setup" + ], + "timeout_seconds": 110, + "checks": "Check the serial quotient, signed B\u00e9zout and rational primitives and the absolute fixed-installation tape bill." + } + ] +} diff --git a/research/tiered-native-multiplier/bootstrap.py b/research/tiered-native-multiplier/bootstrap.py new file mode 100644 index 0000000000..89c6726b37 --- /dev/null +++ b/research/tiered-native-multiplier/bootstrap.py @@ -0,0 +1,54 @@ +"""Restore and bind the two signed tiers from the archived research sources.""" + +from argparse import ArgumentParser +from hashlib import sha256 +import json +from pathlib import Path +from shutil import copyfile +from subprocess import run +import sys +import tarfile +from tempfile import TemporaryDirectory + +HERE = Path(__file__).resolve().parent + + +def install(destination): + dest = Path(destination).resolve() + dest.mkdir(parents=True, exist_ok=True) + if any(dest.iterdir()): + raise ValueError("Use an empty installation directory") + pins = json.loads((HERE / "SOURCES.json").read_bytes()) + for name, hex_digest in pins["archive_and_overlay_sha256"].items(): + if sha256((HERE / name).read_bytes()).hexdigest() != hex_digest: + raise ValueError(f"The source differs at {name}") + with TemporaryDirectory(prefix="tier-source-") as temp: + folder = Path(temp) + entries = dict(pins["installer_files"]) + with tarfile.open(HERE / "source/installer.tar.gz") as source: + for member in source: + name = member.name + if name not in entries or Path(name).name != name or not member.isfile(): + raise ValueError("Invalid fixed source entry") + data = source.extractfile(member).read() + if sha256(data).hexdigest() != entries.pop(name): + raise ValueError(f"The fixed source differs at {name}") + (folder / name).write_bytes(data) + if entries: + raise ValueError("The fixed compiler is incomplete") + run([sys.executable, "-IB", str(folder / "bootstrap.py"), str(dest)], check=True) + for phase in ("before", "after"): + for name, hashes in pins["runtime"].items(): + if sha256((dest / name).read_bytes()).hexdigest() != hashes[phase]: + raise ValueError(f"The {phase} image differs at {name}") + if phase == "before": + run(["git", "apply", "--no-index", str(HERE / "runtime.patch")], check=True, cwd=dest) + copyfile(HERE / "source/strong-bit-k7.json.gz", dest / "strong-bit.json.gz") + copyfile(HERE / "installations.py", dest / "installations.py") + copyfile(HERE / "grades.py", dest / "grades.py") + + +if __name__ == "__main__": + cli = ArgumentParser(description=__doc__) + cli.add_argument("destination", type=Path) + install(cli.parse_args().destination) diff --git a/research/tiered-native-multiplier/check_gaussian.py b/research/tiered-native-multiplier/check_gaussian.py new file mode 100644 index 0000000000..e904a06486 --- /dev/null +++ b/research/tiered-native-multiplier/check_gaussian.py @@ -0,0 +1,102 @@ +"""Run both literal scaled copies on independent nonzero Gaussian product states.""" +from argparse import ArgumentParser +from pathlib import Path +from functools import cache +import sys +p=ArgumentParser() +p.add_argument("runtime",type=Path) +args=p.parse_args() +sys.path.insert(0,str(args.runtime.resolve())) +from upstream import HERE,install +_,_,_,source=install() +from raw48 import ComplexRaw +from periodic import Job +from retimed_supplier import Raw +from grades import SCALES, SPLITS +from band_product import production_supplier +from check_nonzero_eight import Field, Axes, WitnessRaw, addresses, basis, diagonal, final_ray, rot + +class RayField(Field): + def blank(self): + return RayField(self.stock) + + def phase(self,fn,suffix): + if self.data is None: + return + z,rays=self.data + n=len(rays) + base=fn(0)%4 + z=rot(z,base) + # The source opcodes I, S and CZ apply the same phase polynomial in + # each of the n physical columns. Evaluate that polynomial on all 512 + # assignments of the first column. Check additional physical addresses + # in every column as well as two mixed whole-register assignments. + single=tuple((fn(x)-base)%4 for x in addresses(0,n)) + after=[] + totals=[base,base] + probes=[0,0] + for i,v in enumerate(rays): + indices=((71*i+93)%512,(11*i+7)%512) + locations=addresses(i,n) + for sample,j in enumerate(indices): + assert (fn(locations[j])-base)%4==single[j] + totals[sample]+=single[j] + probes[sample]|=locations[j] + v2,phase=diagonal(v,single) + after.append(v2) + z=rot(z,phase) + assert all(fn(a)%4==q%4 for a,q in zip(probes,totals)) + self.data=z,tuple(after) + +def check(): + assert SCALES==(1,79) and SPLITS==1008 + producer=production_supplier(1024,10**18) + a,w=producer.physical,producer.word + sizes, paid = producer.recipe.targets, producer.recipe.paid + assert producer.recipe.ambient==153*79 + stock=[0,0] + fields={i:RayField(stock) for i in range(len(sizes))} + jobs=[Job(i,range(2*k)) for i,k in enumerate(sizes)] + clock,call=next((i,row[1]) for i,row in enumerate(a.instructions()) if row[0]=="NATIVE") + key=("helper",clock,call,1544) + pawn=next(i for i,p in enumerate(w.targets) if p.tag==key) + assert w.targets[pawn].rank==8 + exp={} + widths=tuple(2*s for s in SCALES) + for copy,cols in enumerate(widths): + owner=pawn+copy*len(w.targets) + origins=tuple((37*i+11+17*copy)%512 for i in range(cols)) + initial=((3 if not copy else -7)<<2048,(5 if not copy else 2)<<2048) + fields[owner].data=initial,tuple(basis(i) for i in origins) + exact=tuple(final_ray(i) for i in origins) + z=rot(initial,sum(p for _,p in exact)) + assert all(x % (16**cols)==0 for x in z) + exp[owner]=(z[0]//16**cols,z[1]//16**cols),tuple(v for v,_ in exact) + raw=WitnessRaw(a,fields,Axes(),low=0,bundle=1,slots=2*producer.recipe.ambient) + it=Raw(w,raw).native(jobs,2) + completed=0 + nonzero={width:0 for width in widths} + for grade in paid: + job=next(it) + field=fields[job.owner] + completed+=1 + assert len(job.axes)==2*grade + if field.data is not None: + nonzero[len(field.data[1])]+=1 + for axis in job.axes: + field.paid(axis) + assert next(it,None) is None + assert set(fields)==set(range(len(sizes))) and all(f.live and f.writes>0 for f in fields.values()) + assert {i:f.data for i,f in fields.items() if f.data is not None}==exp + assert all(nonzero.values()) + writes=sum(f.writes for f in fields.values()) + for f in fields.values(): + f.retire() + assert stock[0]==0 + print("physical columns",widths,"nonzero cut counts",nonzero,"all paid",completed) + print("owners",len(fields),"owner writes",writes,"sum output axes",2*sum(sizes),"peak handles",stock[1]) + print("exact nonzero output Hilbert log2 dimensions",tuple(9*x for x in widths)) + print("PASS_SCALED_POSITIVE_RAW") + +if __name__=="__main__": + check() diff --git a/research/tiered-native-multiplier/check_lean.py b/research/tiered-native-multiplier/check_lean.py new file mode 100644 index 0000000000..fade224096 --- /dev/null +++ b/research/tiered-native-multiplier/check_lean.py @@ -0,0 +1,20 @@ +"""Kernel-check both proof files against a specified Lean and Mathlib build.""" + +from pathlib import Path +import os +from shutil import copyfile +from subprocess import run +import sys +from tempfile import TemporaryDirectory + +package = Path(__file__).resolve().parent +lean_bin = Path(sys.argv[1]).resolve() / "bin" +mathlib = Path(sys.argv[2]).resolve() +with TemporaryDirectory(prefix="tier-lean-") as temp: + dst = Path(temp) + paths = [dst, mathlib / ".lake/build/lib/lean", *sorted((mathlib / ".lake/packages").glob("*/.lake/build/lib/lean"))] + env = os.environ | {"LEAN_PATH":os.pathsep.join(map(str,paths)), "PATH":str(lean_bin)+os.pathsep+os.environ["PATH"]} + for name in ("ScaledEntrance","TierCost"): + copyfile(package / (name+".lean"),dst / (name+".lean")) + run([lean_bin/"lean","-o",name+".olean",name+".lean"],cwd=dst,env=env,check=True) + run([lean_bin/"leanchecker","-v",name],cwd=dst,env=env,check=True) diff --git a/research/tiered-native-multiplier/check_phase_passes.py b/research/tiered-native-multiplier/check_phase_passes.py new file mode 100644 index 0000000000..616fe10344 --- /dev/null +++ b/research/tiered-native-multiplier/check_phase_passes.py @@ -0,0 +1,119 @@ +"""Count whole-field phase passes added by changing the large-copy dilation.""" + +from argparse import ArgumentParser +from collections import Counter, defaultdict +from pathlib import Path +import json +import sys + +def phase_census(atlas): + """Return signed, occurrence-weighted I instructions for each graph role.""" + counts = defaultdict(Counter) + def visit(label, tape, inverse=False): + for op in tape: + if op[0] == "I": + residue = ((-1 if inverse else 1) * op[1]) % 4 + counts[label][residue] += 1 + calls = [r for r in atlas.instructions() if r[0] == "NATIVE"] + shape = tuple(map(len, atlas.regs)) + assert all(tuple(map(len, r[3])) == shape for r in calls) + for node in atlas.graph["schedule"]: + if node in atlas.moves: + _, right, left = atlas.factors[atlas.moves[node]] + visit("paid, right", right) + visit("paid, left", left) + for i, pair in enumerate(zip(atlas.graph["initial"],atlas.graph["final"],strict=True)): + if i not in atlas.main: + _, right, left = atlas.factors[pair] + visit("helper, inverse right", right, True) + visit("helper, inverse left", left, True) + for p, regs in enumerate(atlas.regs): + move, correct = atlas.contacts[p] + for k in range(len(regs)): + visit("main, contact", move) + visit("main, inverse contact", move, True) + visit("main, correction", correct) + if k % 2 == 0: + visit("main, producer", atlas.port[p][0]) + else: + visit("main, consumer", atlas.port[p][1]) + # The only rank-dependent branch in a chart's phase-dispatch count + # is I. S and CZ always issue once. Multiplicity is independent of + # graph binding; each binding has the same count of each port parity. + per_group = Counter() + by_role = {} + for label, row in sorted(counts.items()): + per_group[label.split(",")[0]] += row[1] + row[3] + by_role[label] = [row[x] for x in range(4)] + return { + "native_graphs_per_copy":len(calls), + "main_slot_counts":dict(sorted(Counter(shape).items())), + "graph_issued_roles":[len(atlas.moves),len(atlas.graph["initial"])-len(atlas.main),len(atlas.main)], + "signed_I_exponents_per_graph":by_role, + "odd_I_by_role_per_graph":dict(per_group), + "all_copy_delta_at_residue_2":len(calls)*sum(per_group.values()), + "all_copy_delta_at_residue_0":0, + } + +def dynamic(atlas, widths): + # Use the unmodified chart and graph generators for one bound call. + # A null payload charges callback invocations. These tests do not price + # the non-phase instructions, field lengths, or the recursive child. + from periodic import Job + from raw48 import ComplexRaw + class Columns: + window = 1 + offset = suffix = 0 + def row(self, *args): pass + class Field: + def __init__(self, counter): self.counter = counter + def copy(self): return Field(self.counter) + blank = copy + def clear(self): pass + def retire(self): pass + def replace(self, other): pass + def scale(self, *args): pass + def scale_add(self, *args): pass + def phase(self, fn, suffix): + self.counter["all_phase_calls"] += 1 + if fn(0) % 4: + self.counter["nonzero_constant_at_zero"] += 1 + class Raw(ComplexRaw): + def align(self, field, job, canonical): return () + def unalign(self, field, route): pass + @staticmethod + def axis_list(cols, axes): return range(cols * len(axes)) + clock,row = next((i,r) for i,r in enumerate(atlas.instructions()) if r[0]=="NATIVE") + _, call, color, bound = row + rows = {} + for cols, bundle in widths: + counts = Counter() + roots={r:Field(counts) for group in bound for r in group} + jobs = {("helper",clock,call,atlas.layout["source_labels"][i]):Job(i,()) + for i in range(len(atlas.graph["initial"])) if i not in atlas.main} + fields = {j.owner:Field(counts) for j in jobs.values()} + machine=Raw(atlas,fields,Columns(),low=0,bundle=bundle,slots=153*cols) + issued=sum(1 for _ in machine.graph(clock,call,color,bound,jobs,roots,cols)) + assert issued == len(atlas.moves) + rows[f"columns={cols},bundle={bundle}"] = dict(counts,returned_paid=issued) + return rows + +def main(): + parser=ArgumentParser() + parser.add_argument("machine", type=Path) + args=parser.parse_args() + sys.path.insert(0,str(args.machine.resolve())) + from upstream import install,HERE + _, _, _, source=install() + from strong_complex import artifacts + atlas=artifacts(source/"research/grade14-native-realization", HERE/"inputs") + report=phase_census(atlas) + assert report["native_graphs_per_copy"]==48 + assert report["odd_I_by_role_per_graph"]=={"paid":3042,"helper":697,"main":200} + probes=dynamic(atlas,[(2*8,1),(2*79,1),(2*79,2)]) + old,large,even_bundle=probes.values() + assert large["all_phase_calls"]-old["all_phase_calls"]==sum(report["odd_I_by_role_per_graph"].values()) + assert large["nonzero_constant_at_zero"]==3939 and even_bundle==old + report["one_real_graph_callbacks"] = probes + print(json.dumps(report,indent=2)) +if __name__ == "__main__": main() diff --git a/research/tiered-native-multiplier/check_placement.py b/research/tiered-native-multiplier/check_placement.py new file mode 100644 index 0000000000..8820fe49b0 --- /dev/null +++ b/research/tiered-native-multiplier/check_placement.py @@ -0,0 +1,50 @@ +"""Reconstruct the first productive row and its true placement exchange at the new ranks.""" +from fractions import Fraction as F +from itertools import islice +from pathlib import Path +from json import dumps +import sys +sys.path.insert(0,str(Path(sys.argv[1]).resolve())) +from upstream import HERE,install +install() +from strong_complex import load_changed,word +from raw48 import ComplexRaw +from periodic import Job +from transport import axes +from unpowered_price import ranks,certify +from installations import GAUSSIAN_C, ENTRY, TERMINAL +from strict_moment import UNIT,power_interval +from retimed_supplier import SCALES +assert SCALES==(1,79) +tar,paid=ranks() +margin,cells=certify(GAUSSIAN_C,(tar,paid)) +assert min(cells.values())/sum(tar.values()) > F(1,2**64) +assert max(max(v.numerator.bit_length(),v.denominator.bit_length()) for v in cells.values())<512 +raw=word(*load_changed(HERE/"inputs")) +roots=[p for p in raw.targets if p.rank==129 and p.tag[:2]==("root","rotated")] +assert len(roots)==384 and tar[10191]==624 and cells[4424,10191]==1 +assert power_interval(10191,GAUSSIAN_C)[1]*100 < UNIT*106 +out={} +class Support: + def __init__(self):self.swaps=[] + def swap(self,a,b,z,s):self.swaps.append((a,b,z)) +class Columns: + window=1 + swap=None +for H in (ENTRY.complex_log,TERMINAL.complex_log): + M=1<624*4 + sz=10191*(band-8) + period=4*(-(-M//(4*sz))) + tickets=tuple(islice(axes(M,sz,period,0),3)) + sup=Support() + unit=ComplexRaw(None,{},Columns(),low=0,bundle=1,slots=M) + route=unit.align(sup,Job(0,tickets),ComplexRaw.axis_list(3,(0,))) + assert sup.swaps[0]==(1,tickets[1],1) + out[H]=dict(period=period,tickets=tickets,first_swap=sup.swaps[0]) +print(dumps(dict(starts=out,root=roots[0].tag,nonempty=len(cells),minimum_probability_lower="2^-64"), + indent=2)) diff --git a/research/tiered-native-multiplier/check_serial_setup.py b/research/tiered-native-multiplier/check_serial_setup.py new file mode 100644 index 0000000000..202f8913be --- /dev/null +++ b/research/tiered-native-multiplier/check_serial_setup.py @@ -0,0 +1,101 @@ +"""Check the serial arithmetic against independent host arithmetic and exact budgets.""" + +from fractions import Fraction +from itertools import product +from math import gcd +from random import Random +import json +from pathlib import Path +import sys + +sys.path.insert(0, str(Path(__file__).resolve().parent)) + +from serial_setup import bezout, quotient_remainder, rational + + +def integer(x): + return (-1 if x < 0 else 1, format(abs(x), "b")) + + +def value(x): + return x[0] * int(x[1], 2) + + +def check_pair(a, b): + if b: + q, r = quotient_remainder(integer(a)[1], integer(b)[1]) + assert (int(q, 2), int(r, 2)) == divmod(abs(a), abs(b)) + else: + try: + quotient_remainder(integer(a)[1], "0") + except ZeroDivisionError: + pass + else: + raise AssertionError("division by zero") + g, x, y = bezout(integer(a), integer(b)) + assert value(x)*a + value(y)*b == int(g, 2) == gcd(a, b) + + +def rat(x): + return integer(x.numerator), format(x.denominator, "b") + + +def check_rational(x, y, op): + if op == "/" and not y: + try: + rational(op, rat(x), rat(y)) + except ZeroDivisionError: + return + raise AssertionError("rational division by zero") + expected = {"+": Fraction.__add__, "-": Fraction.__sub__, + "*": Fraction.__mul__, "/": Fraction.__truediv__}[op](x, y) + assert rational(op, rat(x), rat(y)) == rat(expected) + + +def clock(): + w = 2**38 + h = 2*w + 2 + # The bound for a Euclid step includes both signed coefficient updates. + bezout_cost = 2**16*(h + 4)*(7*h + 9) + elementary = 2**16*(h + 4)**2 + scalar = bezout_cost + 8*elementary + assert scalar < 2**110 + store = 4*w*2**68 + lookup = 8*store*512*128 + assert store == 2**108 and lookup == 2**127 + action = lookup + scalar + 2**120 + assert action < 2**128 + total = (2**68 + 1)*action*2**32 + assert total < 2**228 + return dict(max_datum_bits=w, lookup=lookup, local_arithmetic=scalar, + all_setup=total, setup_exponent=228) + + +def main(): + pairs = list(product(range(-31, 32), repeat=2)) + for width in (1, 2, 11, 31, 63, 127, 256, 512): + a = 2**width - 1 + for b in (1, a, a + 1, 2**(width//2) + 1): + pairs.append((a, b)) + pairs.append((-b, a)) + rng = Random(17813) + for width in (16, 64, 256): + for _ in range(12): + pairs.append((rng.getrandbits(width), -rng.getrandbits(width))) + a, b = 0, 1 + while b.bit_length() < 512: + a, b = b, a + b + pairs.extend(((a, b), (-b, -a))) + for a, b in pairs: + check_pair(a, b) + numbers = sorted({Fraction(a, b) for a in range(-6, 7) for b in range(1, 6)}) + rational_cases = 0 + for x, y in product(numbers, repeat=2): + for op in "+-*/": + check_rational(x, y, op) + rational_cases += 1 + print(json.dumps(dict(integer_pairs=len(pairs), rational_cases=rational_cases, **clock()), indent=2)) + + +if __name__ == "__main__": + main() diff --git a/research/tiered-native-multiplier/grades.py b/research/tiered-native-multiplier/grades.py new file mode 100644 index 0000000000..18b3041f68 --- /dev/null +++ b/research/tiered-native-multiplier/grades.py @@ -0,0 +1,75 @@ +"""Generate the chronological grades of the dilated numerical source.""" + +from collections import Counter +from fractions import Fraction +from functools import cache + +SCALES = (1, 79) +SPLITS = 1008 +HALF = Fraction(1, 2) + + +class Grades: + """Use the fixed role segments for each copy and each chronological split.""" + + def __init__(self, ports, splits=0): + self.ports = ports + self.splits = splits + raw = Counter() + counts = {} + for prefix, entries in ports.segments: + key = id(entries) + if key not in counts: + ranks = (p.rank for p in entries) if prefix is None else (r for _, r in entries) + counts[key] = Counter(ranks) + raw.update(counts[key]) + if raw[1] < splits: + raise ValueError("The base copy has too few rank-one loans") + self.histogram = Counter() + for scale in SCALES: + for rank, count in raw.items(): + self.histogram[scale * rank] += count + if splits: + self.histogram[1] -= splits + self.histogram[HALF] += 2 * splits + + def __len__(self): + return len(SCALES) * len(self.ports) + self.splits + + def __iter__(self): + for scale in SCALES: + remaining = self.splits if scale == 1 else 0 + for rank in self.ports.ranks(): + if remaining and rank == 1: + yield HALF + yield HALF + remaining -= 1 + else: + yield scale * rank + + +@cache +def numerical_source(): + from upstream import HERE, install + _, _, _, source = install() + from clock_ports import clock_word + from installations import GAUSSIAN_C + from strong_complex import artifacts + from unpowered_price import certify + + atlas = artifacts(source / "research/grade14-native-realization", HERE / "inputs") + word = clock_word(atlas) + targets, paid = Grades(word.targets), Grades(word.paid, SPLITS) + margin, cells = certify(GAUSSIAN_C, (targets.histogram, paid.histogram)) + if cells is None or margin <= 0: + raise ArithmeticError("The numerical source cannot pay its physical loans") + return atlas, word, targets, paid, cells + + +@cache +def numerical_recipe(rank_log): + from installations import GAUSSIAN_C + from transport import Recipe + + _, word, targets, paid, cells = numerical_source() + return Recipe(rank_log, max(SCALES) * word.ambient, targets, paid, cells, GAUSSIAN_C) diff --git a/research/tiered-native-multiplier/independent_price.py b/research/tiered-native-multiplier/independent_price.py new file mode 100644 index 0000000000..f3e098a35d --- /dev/null +++ b/research/tiered-native-multiplier/independent_price.py @@ -0,0 +1,95 @@ +"""Check both numerical grade inventories with independent log and exp intervals.""" + +from collections import Counter +from fractions import Fraction as Q +from pathlib import Path +import sys + +sys.path.insert(0, str(Path(sys.argv[1]).resolve())) +from upstream import HERE, install +install() +from independent_binary_price import log_rank, rank_price +from installations import GAUSSIAN_C, TERMINAL +from strong_complex import load_changed, word +from unpowered_price import certify + +raw = word(*load_changed(HERE/"inputs")) +targets = Counter(p.rank for p in raw.targets) +paid = Counter(p.rank for p in raw.paid) + + +def histogram(scale): + h = Counter(targets) + h.subtract(paid) + for r in targets.keys() | paid.keys(): + h[scale*r] += targets[r]-paid[r] + h[1] += 1008 + h[Q(1,2)] -= 2016 + return h + + +def power(r,t): + r = Q(r) + a,b = rank_price(r.numerator,t) + d,e = rank_price(r.denominator,t) + return a/e,b/d + + +def margin(h,c): + lower = upper = 0 + for r,n in h.items(): + a,b = power(r,1-c) + lower += min(n*a,n*b) + upper += max(n*a,n*b) + return lower,upper + + +def doubled(counts): + result = counts.copy() + for grade, count in counts.items(): + result[8*grade] += count + return result + + +old_target, old_paid = doubled(targets), doubled(paid) +old_paid[1] -= 1008 +old_paid[Q(1, 2)] += 2016 +before, old_cells = certify(Q(2092819, 2**29), (old_target, old_paid)) +after, revised_cells = certify(Q(1071523491, 2**38), (old_target, old_paid)) +assert min(before, after) > 0 and old_cells.keys() == revised_cells.keys() +assert len(revised_cells) == 54 and sum(v != revised_cells[k] for k, v in old_cells.items()) == 45 +old = histogram(8) +lo,hi = Q(".0038981803447950341293615588"),Q(".0038981803447950341293615589") +assert margin(old,lo)[0] > 0 and margin(old,hi)[1] < 0 +assert margin(old,TERMINAL.kappa)[1] < -Q(17,100) + + +def certify_derivative(h): + for j in range(16): + # Differentiate sum h_r*(r/16)^t. Bound the signed derivative on the full interval. + derivative = 0 + for r,n in h.items(): + q = Q(r)/16 + a,b = log_rank(q.numerator) + d,e = log_rank(q.denominator) + endpoints = (*power(q,Q(j,16)), *power(q,Q(j+1,16))) + derivative += min(n*z*y for z in (a-e,b-d) for y in (min(endpoints),max(endpoints))) + assert derivative > 300000 + + +certify_derivative(old) +two_returns = old.copy() +two_returns[1] -= 2 +two_returns[Q(1, 2)] += 4 +unsplit_paid = old_paid.copy() +unsplit_paid[1] += 2 +unsplit_paid[Q(1, 2)] -= 4 +peer_margin, peer_cells = certify(Q(133940467, 2**35), (old_target, unsplit_paid)) +assert sum(unsplit_paid.values()) == 564142 and peer_margin > 0 and len(peer_cells) == 54 +assert margin(two_returns,Q(".003898180942171"))[0] > 0 +assert margin(two_returns,Q(".003898180942173"))[1] < 0 +assert margin(two_returns,TERMINAL.kappa)[1] < -Q(17,100) +certify_derivative(two_returns) +assert margin(histogram(79),GAUSSIAN_C)[0] > 0 +assert TERMINAL.kappa > hi +print("PASS_INDEPENDENT_RAW_CROSSING",lo,hi,"and funded 79-column dilation") diff --git a/research/tiered-native-multiplier/installations.py b/research/tiered-native-multiplier/installations.py new file mode 100644 index 0000000000..9bc60df559 --- /dev/null +++ b/research/tiered-native-multiplier/installations.py @@ -0,0 +1,37 @@ +"""Select both complete native stages from the signed controller's public width.""" + +from dataclasses import dataclass +from fractions import Fraction as Q + +BINARY_C = Q(4391986206293, 2**50) +GAUSSIAN_C = Q(2143194013, 2**39) + + +@dataclass(frozen=True) +class Profile: + rank_logs: tuple + complex_log: int + kappa: Q + eta: Q = Q(39, 10000) + positive_stop_denominator: int = 10**18 + + @property + def ordinary(self): + return self.kappa + Q(5, self.positive_stop_denominator) + + +ENTRY = Profile((3000, 3080), 1024, Q(".00345")) +TERMINAL = Profile((35327, 559005), 680000, Q(".0038982")) +PROFILES = {"entry": ENTRY, "terminal": TERMINAL} + + +def activation(profile): + from linear_geometry import connected_exponent + from staged_carriers import entrance_logs + + return connected_exponent(entrance_logs(profile.rank_logs)[-1], profile.complex_log) + + +def at_public(public): + """The magnitude scan and square-side selector have already computed public.""" + return TERMINAL if public.bit_length() > activation(TERMINAL) else ENTRY diff --git a/research/tiered-native-multiplier/measure_setup.py b/research/tiered-native-multiplier/measure_setup.py new file mode 100644 index 0000000000..75bbf0bb33 --- /dev/null +++ b/research/tiered-native-multiplier/measure_setup.py @@ -0,0 +1,73 @@ +"""Measure complete fixed preparation in one fresh process per observation.""" + +from argparse import ArgumentParser +from hashlib import sha256 +from importlib.util import module_from_spec, spec_from_file_location +import json +from pathlib import Path +import platform +import resource +from subprocess import run +import sys +from tempfile import TemporaryDirectory +from time import perf_counter + +HERE = Path(__file__).resolve().parent + + +def load_file(name, path): + spec = spec_from_file_location(name, path) + module = module_from_spec(spec) + spec.loader.exec_module(module) + return module + + +def cpu(): + rows = [resource.getrusage(who) for who in (resource.RUSAGE_SELF,resource.RUSAGE_CHILDREN)] + return sum(x.ru_utime+x.ru_stime for x in rows) + + +def measure(peer, revision): + start, used = perf_counter(), cpu() + with TemporaryDirectory(prefix="tier-timing-") as tmp: + work = Path(tmp) + machine = work / "machine" + if peer is None: + load_file("candidate_setup",HERE/"bootstrap.py").install(machine) + else: + src = work / "peer" + if revision == "8054": + wrapper = load_file("unsplit_source", peer/"prepare.py") + wrapper.materialize(peer/"peer8053", src) + else: + wrapper = load_file("fixed_carrier_source",peer/"verify.py") + src.mkdir() + wrapper.restore(src) + wrapper.edit_installation(src) + run([sys.executable,"-IB",str(src/"bootstrap.py"),str(machine)],check=True) + sys.path.insert(0,str(machine)) + from band_product import prepare_native + from installations import PROFILES + if peer is None: + rows = prepare_native() + else: + rows = (prepare_native(PROFILES["extended"]),) + contracts = [[(r.rank_log,len(r.targets),len(r.paid),len(r.cells)) for r in tier] for tier in rows] + loans = 564142 if revision == "8054" else 564144 + assert all(len(tier)==3 and tier[-1][1:3]==(105216,loans) for tier in contracts) + digest = sha256((machine/"strong-bit.json.gz").read_bytes()).hexdigest() + rss = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss + print(json.dumps(dict(revision=revision,wall=perf_counter()-start, + cpu=cpu()-used,rss_bytes=rss if sys.platform=="darwin" else rss*1024, + python=sys.version.split()[0],system=platform.platform(),machine=platform.machine(), + installed=contracts,binary_sha256=digest))) + + +if __name__ == "__main__": + args = ArgumentParser(description=__doc__) + group = args.add_mutually_exclusive_group() + group.add_argument("--peer-8053",type=Path) + group.add_argument("--peer-8054",type=Path) + options = args.parse_args() + measure(options.peer_8053 or options.peer_8054, + "8054" if options.peer_8054 else "8053" if options.peer_8053 else "candidate") diff --git a/research/tiered-native-multiplier/receipt.py b/research/tiered-native-multiplier/receipt.py new file mode 100644 index 0000000000..39f2ef7ae8 --- /dev/null +++ b/research/tiered-native-multiplier/receipt.py @@ -0,0 +1,129 @@ +"""Recompute the complete rate, calendar, stock and fixed-tape bounds.""" + +from collections import Counter +from fractions import Fraction as Q +from pathlib import Path +import json +import sys + +PACKAGE = Path(__file__).resolve().parent +sys.path.insert(0, str(Path(sys.argv[1]).resolve())) +from upstream import install +install() +sys.path.append(str(PACKAGE / "source")) +from activation import resource_receipt +from band_product import prepare_native +from grades import SCALES +from independent_binary_price import raw_moments +from installations import BINARY_C, GAUSSIAN_C, ENTRY, TERMINAL, activation, at_public +from linear_geometry import entrance_geometry +from ordinary_clock import first_stage_bound, polynomial_to_fibre_bound +from outer_budget import qualify +from outer_clock import financial_checks +from raw_binary_stage import binary_word +from strong_binary import caller, graph +from strict_moment import UNIT, power_interval +from unpowered_price import certify, intervals + + +def ceil(x): + return -(-x.numerator // x.denominator) + + +def tariff(recipe, target, paid): + c = recipe.trial + margin, cells = certify(c, (target, paid)) + assert cells == recipe.cells and margin > 0 + assert min(cells.values()) / sum(target.values()) > Q(1, 2**64) + assert max(max(v.numerator.bit_length(), v.denominator.bit_length()) for v in cells.values()) < 512 + assert all(5*r <= 4*k for r,k in cells) + t = 1 - c + p = sum(n * Q(intervals(r,t)[0], UNIT) for r,n in paid.items()) + total = sum(n * Q(intervals(k,t)[1], UNIT) for k,n in target.items()) + assert p > 10 and p / total > Q(99,100) + assert t > Q(996,1000) and power_interval(max(target),c)[1] * 100 < 106*UNIT + lower, delta = 32768, Q(1, 2**128) + factor = (Q(256,255)*Q(4097,4096)*Q(1028,1024) + *Q(power_interval(1024*recipe.ambient*lower,c)[1], UNIT) + *(1+Q(64,lower)+delta)/((1-Q(10,lower))*(1-delta)**3)) + if c == BINARY_C: + assert (factor*Q(47,20))**8 < 2**11 and Q(75,32)/Q(47,20) == Q(375,376) + else: + assert recipe.ambient == 12087 and len(cells) == 62 + assert max(Q(k)/r for r, k in cells) == 9 + assert cells[4424,10191] == 1 and target[10191] == 624 + assert factor < Q(power_interval(2,Q(43,256))[0],UNIT) + return dict(targets=target.total(), paid=paid.total(), margin=str(margin), + transport_cells=len(cells), physical_factor_upper_millionths=ceil(factor*10**6)) + + +def bank(profile): + stages = profile.rank_logs + previous = Q(0) + rates = [] + for i, h in enumerate(stages): + funded = min(profile.eta,(249*(BINARY_C-Q(11,8*h))+previous)/250) + rate = (profile.ordinary if i+1==len(stages) + else Q(int(funded*10**21)-1,10**21)) + assert previous < rate < funded + rates.append(str(rate)) + previous = rate + num = profile.complex_log + positive = GAUSSIAN_C-Q(43,256*num) + stock = resource_receipt(profile) + A = activation(profile) + assert A == stock["public_exponent_A"] and min(stages) >= 3000 + signed = qualify(profile.kappa,Q(1,profile.positive_stop_denominator),previous,positive) + if min(stages) >= 8192: + assert 2660000*32 < 2**30 + ordinary = 128+320*sum(stages) + extra = [] + else: + expense = [first_stage_bound(profile.eta), polynomial_to_fibre_bound()] + extra = [max(0,e-944*h) for e,h in zip(expense,stages,strict=True)] + assert Q(376*7,10)**len(stages) < 2**17 + ordinary = 40+17+16384*sum(stages)+sum(extra) + E = max(84500001,1602+220*num+ordinary) + return dict(kappa=str(profile.kappa), binary_H=stages, gaussian_H=num, + width_exponents=[92*h for h in (*stages,num)], rates=rates, + positive_rate=str(positive), signed=signed, stock=stock, + geometry=entrance_geometry(A), variable_cost_surcharges=extra, + log2_B=ordinary, log2_C=E) + + +def verify(): + early_rec, late_rec = prepare_native() + early_bit, _, early_num = early_rec + bit, _, num = late_rec + assert bit.cells is early_bit.cells and num.targets is early_num.targets + assert num.cells is early_num.cells and num.paid is early_num.paid + btarget, bpaid = raw_moments(graph(), caller()) + assert (btarget,bpaid) == (Counter(binary_word().targets),Counter(binary_word().paid)) + assert sum(r*n for r,n in btarget.items()) == 286098 + assert sum(r*n for r,n in bpaid.items()) == 284592 + actual = Counter(num.targets), Counter(num.paid) + assert actual == (num.targets.histogram,num.paid.histogram) + assert (len(num.targets),len(num.paid)) == (105216,564144) and SCALES == (1,79) + b_receipt = tariff(bit,btarget,bpaid) + n_receipt = tariff(num,*actual) + early, late = bank(ENTRY), bank(TERMINAL) + boundary = activation(TERMINAL) + threshold = 1 << boundary + assert at_public(threshold-1) is ENTRY and at_public(threshold) is TERMINAL + # Public precision is a multiple of six. Exercise the last and first such headers. + first_public = threshold + (-threshold)%6 + assert at_public(first_public-6) is ENTRY and at_public(first_public) is TERMINAL + premium = ceil((TERMINAL.kappa-ENTRY.kappa)*boundary) + cost = 1+max(early["log2_C"]+premium,late["log2_C"]) + assert (premium,cost) == (572,339787971) + delta = TERMINAL.kappa-Q(".0038981730255") + assert delta == Q(53949,2*10**12) and delta > 0 + prefix = financial_checks() + return dict(binary=b_receipt,gaussian=n_receipt,entry=early,terminal=late, + old_rate=".0038981730255",rate_delta=str(delta),entry_premium=premium, + complete_log2_C=cost,prefix=prefix) + + +if __name__ == "__main__": + actual = verify() + print(json.dumps(actual,indent=2)) diff --git a/research/tiered-native-multiplier/runtime.patch b/research/tiered-native-multiplier/runtime.patch new file mode 100644 index 0000000000..cd895f6240 --- /dev/null +++ b/research/tiered-native-multiplier/runtime.patch @@ -0,0 +1,239 @@ +--- a/band_product.py ++++ b/band_product.py +@@ -10,7 +10,8 @@ + from retimed_supplier import Positive + from binary_io import magnitude_limbs + from fiscal_scans import magnitude_bits +-from installations import COMPACT, PROFILES ++from installations import ENTRY, PROFILES, at_public ++from grades import numerical_recipe + from inputs.triangular.multiplier import Product as PackProduct, precision + from linear_geometry import parameters, square_sides + from ordinary_carrier import ordinary_swap +@@ -23,17 +24,18 @@ + return Positive(rank_log, stop_denominator) + + +-def prepare_native(profile=COMPACT): ++def prepare_native(profile=None): + """Generate the raw labels, both signed circuits, the atlas and the two grade couplings.""" + from raw_binary_stage import binary_recipe + ++ if profile is None: ++ return tuple(prepare_native(tier) for tier in PROFILES.values()) + binary = tuple(binary_recipe(height) for height in profile.rank_logs) +- positive = production_supplier(profile.complex_log, profile.positive_stop_denominator) +- return (*binary, positive.recipe) ++ return (*binary, numerical_recipe(profile.complex_log)) + + + class Product(PackProduct): +- def __init__(self, sides, b, P, exchange=None, *, engine=None, profile=COMPACT): ++ def __init__(self, sides, b, P, exchange=None, *, engine=None, profile=ENTRY): + self.profile = profile + exchange = partial(ordinary_swap, profile=profile) if exchange is None else exchange + super().__init__(sides, b, P, exchange, engine=engine) +@@ -60,7 +62,7 @@ + left_negative=False, + right_negative=False, + engine=None, +- profile=COMPACT, ++ profile=None, + ): + """Return the sign and length of the product. Restore both input heads.""" + if output is left or output is right: +@@ -77,6 +79,8 @@ + raw = result.to_bytes(max(1, (result.bit_length() + 7) // 8), "little") + output.write(raw) + return bool(negative and all(lengths)), len(raw) ++ if profile is None: ++ profile = at_public(shape.public) + sides = tuple(square_sides(shape)) + machine = Product( + sides, +@@ -89,7 +93,7 @@ + return sign, size + + +-def multiply(left, right, *, profile=COMPACT): ++def multiply(left, right, *, profile=None): + raw = [abs(v).to_bytes((abs(v).bit_length() + 7) // 8, "little") for v in (left, right)] + out = BytesIO() + sign, _ = multiply_tapes( +@@ -110,6 +114,6 @@ + args = ArgumentParser(description=__doc__) + args.add_argument("left", type=lambda x: int(x, 0)) + args.add_argument("right", type=lambda x: int(x, 0)) +- args.add_argument("--profile", choices=PROFILES, default="compact") ++ args.add_argument("--profile", choices=PROFILES) + call = args.parse_args() +- print(multiply(call.left, call.right, profile=PROFILES[call.profile])) ++ print(multiply(call.left, call.right, profile=PROFILES.get(call.profile))) +--- a/binary_receiver.py ++++ b/binary_receiver.py +@@ -1,6 +1,6 @@ + """Run the funded binary graph in the public bank and return every physical loan.""" + +-from installations import COMPACT ++from installations import ENTRY + from raw_binary_stage import binary_recipe, binary_word, run + from module_atoms import chart_width, total_width + from periodic import Job +@@ -13,7 +13,7 @@ + + class Receiver(PhysicalReceiver): + def __init__( +- self, dimension, layout, previous=cold_swap_tape, *, direct=False, profile=COMPACT ++ self, dimension, layout, previous=cold_swap_tape, *, direct=False, profile=ENTRY + ): + if dimension < 2: + raise ValueError("Use a native rank of at least two") +--- a/independent_binary_price.py ++++ b/independent_binary_price.py +@@ -75,7 +75,7 @@ + paid[1] += ports + elif row[0] == "IDLE_ONE": + paid[len(row[2]) * caller["body_rank"]] += ports +- assert targets.total() == 18_906 and paid.total() == 104_904 ++ assert targets.total() == 18_906 and paid.total() == 104_652 + return targets, paid + + +--- a/ordinary_carrier.py ++++ b/ordinary_carrier.py +@@ -7,7 +7,7 @@ + + install() + from binary_receiver import Receiver +-from installations import COMPACT ++from installations import ENTRY + from module_atoms import ceil_root + from ordinary import least_power + from staged_carriers import entrance_logs +@@ -55,7 +55,7 @@ + root_body(source, target, digits, 1, gap, suffix, backend) + + +-def ordinary_swap(source, target, bits, prefix, gap, suffix, *, profile=COMPACT): ++def ordinary_swap(source, target, bits, prefix, gap, suffix, *, profile=ENTRY): + rank_logs = profile.rank_logs + if bits < 0 or min(prefix, gap, suffix) < 1: + raise ValueError("Use a nonnegative width and positive field dimensions") +--- a/retimed_supplier.py ++++ b/retimed_supplier.py +@@ -1,7 +1,5 @@ + """Run two column scales of the tagged 48-call word in the signed positive receiver.""" + +-from fractions import Fraction as F +-from collections import Counter + + from upstream import HERE, install + +@@ -10,15 +8,7 @@ + from periodic import Job + from raw48 import ComplexRaw + from spool import scratch, snapshot, transfer +-from strong_complex import artifacts +-from clock_ports import clock_word +-from transport import Recipe +-from installations import GAUSSIAN_C +-from unpowered_price import certify +- +- +-SCALES = (1, 8) +-SMALL_SPLITS = 1008 ++from grades import SCALES, SPLITS, numerical_source, numerical_recipe + + + class Raw: +@@ -48,45 +38,21 @@ + tag, job = next(actual) + if tag != label.tag or len(job.axes) != label.rank * width: + raise ArithmeticError("The physical cut differs from the installed word") +- if scale == 1 and label.rank == 1 and splits < SMALL_SPLITS: ++ if scale == 1 and label.rank == 1 and splits < SPLITS: + yield job.select(range(width // 2)) + yield job.select(range(width // 2, width)) + splits += 1 + else: + yield job +- if next(actual, None) is not None or (scale == 1 and splits != SMALL_SPLITS): ++ if next(actual, None) is not None or (scale == 1 and splits != SPLITS): + raise ArithmeticError("The numerical word did not close at its final loan") + + +-def source_ranks(tagged): +- targets = tuple(scale*p.rank for scale in SCALES for p in tagged.targets) +- slots = [] +- for scale in SCALES: +- splits = 0 +- for port in tagged.paid: +- if scale == 1 and port.rank == 1 and splits < SMALL_SPLITS: +- slots.extend((F(1, 2), F(1, 2))) +- splits += 1 +- else: +- slots.append(scale * port.rank) +- if scale == 1 and splits != SMALL_SPLITS: +- raise ArithmeticError("The base copy has too few rank-one requests") +- return targets, tuple(slots) +- +- + class Positive(RetainedPositive): +- def __init__(self, rank_log, denominator=10**14): +- atlas = artifacts( +- source / "research/grade14-native-realization", HERE / "inputs" +- ) +- native = clock_word(atlas) ++ def __init__(self, rank_log, denominator): ++ atlas, native, _, _, _ = numerical_source() + super().__init__(native, atlas, 1 << rank_log, denominator) +- +- targets, paid = source_ranks(native) +- margin, cells = certify(GAUSSIAN_C, (Counter(targets), Counter(paid))) +- if cells is None or margin <= 0: +- raise ArithmeticError("The Gaussian word has insufficient column capacity") +- self.recipe = Recipe(rank_log, max(SCALES)*native.ambient, targets, paid, cells, GAUSSIAN_C) ++ self.recipe = numerical_recipe(rank_log) + + @property + def owners(self): +--- a/strong_binary.py ++++ b/strong_binary.py +@@ -15,7 +15,7 @@ + from tagged_sources import BIT_CALLER, BIT_PIN, binary_ports, packed, pinned + + +-SOURCE_SHA256 = "74e93daf2b7acf794ffb51f92f03f51556f68126d41ee13a8969bddb4cbe6326" ++SOURCE_SHA256 = "9e7392c52bcf29c0cc58c54c619f95c28f476394c33e8e0a5aa30c9557d31362" + + + @cache +--- a/transport.py ++++ b/transport.py +@@ -102,6 +102,7 @@ + self.source_width = 0 + t = F(t) + measure = Measure(t, volume, max(256, 64 * n.bit_length())) ++ targets, paid = self.targets, self.paid + ids = defaultdict(list) + for i, k in enumerate(targets): + ids[k].append(i) +--- a/unpowered_price.py ++++ b/unpowered_price.py +@@ -11,13 +11,9 @@ + + + def ranks(): +- graph, layout = load_changed(HERE / "inputs") +- raw = word(graph, layout) +- target = Counter(scale*p.rank for scale in (1, 8) for p in raw.targets) +- paid = Counter(scale*p.rank for scale in (1, 8) for p in raw.paid) +- paid[1] -= 1008 +- paid[F(1, 2)] = 2016 +- return target, paid ++ from grades import numerical_source ++ _, _, targets, paid, _ = numerical_source() ++ return targets.histogram, paid.histogram + + + def intervals(r, t): diff --git a/research/tiered-native-multiplier/serial_setup.py b/research/tiered-native-multiplier/serial_setup.py new file mode 100644 index 0000000000..e3b51bf416 --- /dev/null +++ b/research/tiered-native-multiplier/serial_setup.py @@ -0,0 +1,139 @@ +"""Serial bit operations for the fixed installer's reduced rational arithmetic.""" + +from itertools import zip_longest + + +def canonical(word): + return word.lstrip("0") or "0" + + +def compare(a, b): + """Scan two canonical magnitudes from their high ends.""" + first = 0 + for x, y in zip_longest(a, b): + if x is None: + return -1 + if y is None: + return 1 + if not first: + first = (x > y) - (x < y) + return first + + +def combine(a, b, subtract=False): + """Add two magnitudes, or subtract b from a when a >= b.""" + output = [] + carry = 0 + for x, y in zip_longest(reversed(a), reversed(b), fillvalue="0"): + digit = (x == "1") + carry + (-1 if subtract else 1) * (y == "1") + carry, bit = divmod(digit, 2) + output.append("01"[bit]) + if carry == 1: + output.append("1") + if carry < 0: + raise ArithmeticError("negative magnitude") + return "".join(reversed(output)) + + +def times(a, b): + """Use one shift and at most one addition per digit of b.""" + r = "0" + for digit in b: + r = r + "0" + if digit == "1": + r = combine(r, a) + r = canonical(r) + return r + + +def quotient_remainder(a, b): + """Return the exact quotient and remainder of two canonical magnitudes.""" + if b == "0": + raise ZeroDivisionError + tail = iter(a) + for _ in b: + if next(tail, None) is None: + return "0", a + zero_tail = "".join("0" for _ in tail) + divisor = b + zero_tail + quotient = [] + for _ in "1" + zero_tail: + # The two words retain the dividend width throughout this loop. + take = a >= divisor + quotient.append("1" if take else "0") + if take: + a = combine(a, divisor, subtract=True) + divisor = "0" + divisor[:-1] + return canonical("".join(quotient)), canonical(a) + + +def signed(sign, mag): + return (1 if mag == "0" else sign, mag) + + +def sum_signed(x, y): + sx, a = x + sy, b = y + if sx == sy: + return signed(sx, canonical(combine(a, b))) + if compare(a, b) < 0: + sx, a, b = sy, b, a + return signed(sx, canonical(combine(a, b, subtract=True))) + + +def neg(x): + return signed(-x[0], x[1]) + + +def product_signed(x, y): + return signed(x[0] * y[0], times(x[1], y[1])) + + +def bezout(a, b): + """Return g,u,v with g >= 0 and u*a + v*b = g for signed integers.""" + sa, a = a + sb, b = b + unit, zero = (1, "1"), (1, "0") + rows = ((unit, zero), (zero, unit)) + if compare(a, b) < 0: + a, b = b, a + rows = rows[::-1] + while b != "0": + q, r = quotient_remainder(a, b) + old, current = rows + after = tuple(sum_signed(u, neg(product_signed(v, (1, q)))) + for u, v in zip(old, current)) + rows = current, after + a, b = b, r + x, y = rows[0] + return a, signed(sa * x[0], x[1]), signed(sb * y[0], y[1]) + + +def exact_quotient(a, b): + q, r = quotient_remainder(a, b) + if r != "0": + raise ArithmeticError("inexact division") + return q + + +def reduced(num, den): + if den[1] == "0": + raise ZeroDivisionError + g = bezout(num, den)[0] + return signed(num[0] * den[0], exact_quotient(num[1], g)), exact_quotient(den[1], g) + + +def rational(op, x, y): + """Evaluate a field operation on pairs of signed numerator and positive denominator.""" + a, b = x + c, d = y + if op == "/": + return reduced(product_signed(a, (1, d)), product_signed((1, b), c)) + denominator = product_signed((1, b), (1, d)) + if op == "*": + return reduced(product_signed(a, c), denominator) + if op not in ("+", "-"): + raise ValueError(op) + left = product_signed(a, (1, d)) + right = product_signed(c, (1, b)) + return reduced(sum_signed(left, right if op == "+" else neg(right)), denominator) diff --git a/research/tiered-native-multiplier/source/INSTALLER-NOTICE.md b/research/tiered-native-multiplier/source/INSTALLER-NOTICE.md new file mode 100644 index 0000000000..5299fe7196 --- /dev/null +++ b/research/tiered-native-multiplier/source/INSTALLER-NOTICE.md @@ -0,0 +1,9 @@ +Ali Romman directed this replacement of the fixed Gaussian setup, its binary quadratic path-sum implementation and the integration checks. The work received substantial OpenAI Codex assistance. The source graph, numerical compiler basis convention, physical multiplier and historical proofs retain their original attribution and Apache 2.0 notices. The frozen archive includes the notices for every directly consumed package. + +* Ali Romman's retimed program supplies the binary and numerical words, signed entry, growing precision and resource contracts. Clear1nsight supplied the six-stage comparator and the competing retimed endpoint. This package changes fixed generation and stored role descriptions at the seven-stage source's own price. [Retimed source and credits](https://github.com/aliromman/integer-mult-bounds/blob/dfd25d553a843a946ca0b94130a5ff8943e98fdd/research/retimed-native-multiplier/NOTICE.md) · [PR #8042](https://github.com/CrocSwap/integer-mult-bounds/pull/8042) · [PR #8044](https://github.com/CrocSwap/integer-mult-bounds/pull/8044) · [PR #8050](https://github.com/CrocSwap/integer-mult-bounds/pull/8050) +* The original P104 rational word, its directed helper changes and the 48-call schedule come from the real source consumed by the retimed construction. The sparse journal uses those signed formulas and chronological tie order. [PR #8027](https://github.com/CrocSwap/integer-mult-bounds/pull/8027) · [Physical catalogue and predecessor credit](https://github.com/aliromman/integer-mult-bounds/blob/6285dd829114705862e8d91facaedc1f31d3cfcb/research/single-band-native-carriers/NOTICE.md) +* The grade-14 source supplies the canonical frame construction, reduction to a paid Fourier rank, and the original independent all-column checker. The replacement reuses its signed Pauli arithmetic. Its new part computes the absolute phase by a binary quadratic sum and uses that calculation in the complete factor emitter. [Original grade construction and attribution](https://github.com/CrocSwap/integer-mult-bounds/blob/a7f99a5f5f919dd3ffb2987f90c1e7d6527feb1e/research/grade14-native-realization/NOTICE.md) · [Original Clifford compiler](https://github.com/CrocSwap/integer-mult-bounds/blob/e54523517d0f03e58352e647c403a5af3e525a57/research/shared-wire-split-composition/frozen/clifford_exact.py) + +Binary quadratic forms are an established representation of Clifford operations. Jeroen Dehaene and Bart De Moor describe that representation. Niel de Beaudrap and Steven Herbert give algorithms for stabilizer simulation with quadratic forms. Here the path sum produces the absolute phase of the repository's individual chart circuits and supplies the installed multiplier. [Dehaene and De Moor](https://arxiv.org/abs/quant-ph/0304125) · [de Beaudrap and Herbert](https://quantum-journal.org/papers/q-2022-09-15-803/) + +The historically selected result remains the authority for main. Peer review of the conditional scientific premises remains open. [Selected record](https://github.com/CrocSwap/integer-mult-bounds/blob/e54523517d0f03e58352e647c403a5af3e525a57/certificates/selected-result.json) diff --git a/research/tiered-native-multiplier/source/K7-NOTICE.md b/research/tiered-native-multiplier/source/K7-NOTICE.md new file mode 100644 index 0000000000..d1a9e0924d --- /dev/null +++ b/research/tiered-native-multiplier/source/K7-NOTICE.md @@ -0,0 +1,18 @@ +# Predecessor Credits and License Notice + +This package inherits code, mathematical constructions, pinned archives, and verification structure from prior work in `CrocSwap/integer-mult-bounds` under the Apache License, Version 2.0 (`LICENSE`). + +## Pinned Predecessor Contributions + +- **Ali Romman** (`PR #8027`, `PR #8030`, `PR #8040`, `PR #8042`): + - Original 111-port strong binary catalogue and word (`#8027`, `fb9b6a7b0d27da1cf98430893a3016bf811e2aa4`), retimed machine and archive baseline (`#8030`, `6285dd829114705862e8d91facaedc1f31d3cfcb`), and unpowered retimed seven-stage native multiplier architecture (`#8042`, `dfd25d553a843a946ca0b94130a5ff8943e98fdd`, including `transport.py`, `unpowered_price.py`, `retimed_supplier.py`, `raw_binary_stage.py`, `five_exchange.py`, `fiscal_scans.py`, `activation.py`, and verifier suite). +- **Clear1nsight** (`PR #8031`–`#8050`): + - Powered 6-stage retimed margin construction (`#8035`, `ea776471bf8ed143a0625cf2d7532f65d15eb5f9`), seven-stage dyadic endpoint refit at `numerical_H = 36000` (`#8050`, `328b858e24709495843abc751fcbf5df35a89da8`, `κ ≥ 0.003890115286594461`), and `binary` vs `Gaussian` sensitivity characterization. +- **ToikY** (`PR #8026`, `PR #8029`): + - Prior outer-caller and binary optimization groundwork feeding into the `strong-bit` construction family. +- **DreamingOfClouds** (`PR #7852`) & **Jerry Chen / CubeJerry** (`PR #7257`, `PR #7914`, `PR #7981`): + - Physical bank machine, 36-call catalogue interpreter, sparse weighted oracle verification (`#7981`), counted compiler (`1ca6b8111297ac2cc2dcfe5da0027656898f7589`), and CI research-package validator harness (`#7257`, `0618e75a22cec54d1651394ef83d088551b7f026`). + +## Present Contribution (`p104-k7-retimed-binary`) + +- Constructive 6-round (`k=2..7`) binary circuit modification `strong-bit-k7.json.gz` reducing `MOVE` instructions (`2803 -> 2796`), dirty private clears (`3433 -> 3426`), and paid linear rank sum (`285,600 -> 284,592`; `104,904 -> 104,652` paid ports) while preserving exact register semantics and unchanged 2-scale Gaussian receiver coupling (`GAUSSIAN_C = 2092819/2^29`). diff --git a/research/tiered-native-multiplier/source/K7-STACK-LEDGER.json b/research/tiered-native-multiplier/source/K7-STACK-LEDGER.json new file mode 100644 index 0000000000..2add885cf9 --- /dev/null +++ b/research/tiered-native-multiplier/source/K7-STACK-LEDGER.json @@ -0,0 +1,230 @@ +{ + "description": "Constructive binary graph reduction steps reaching seed_k7 from PR #8027/#8035 baseline", + "baseline_8027": { + "moves": 2803, + "dirty_clears": 3433, + "frames": 636, + "pairs": 2352, + "frame_gates": 44825, + "n_targets": 18906, + "n_paid": 104904, + "linear_paid_sum": 285600 + }, + "final_k7": { + "moves": 2796, + "dirty_clears": 3426, + "frames": 636, + "pairs": 2353, + "frame_gates": 44734, + "n_targets": 18906, + "n_paid": 104652, + "linear_paid_sum": 284592, + "gz_sha256": "9e7392c52bcf29c0cc58c54c619f95c28f476394c33e8e0a5aa30c9557d31362", + "raw_sha256": "f4a43e4e36ac734dea10a73dca496bf4a4f4a9804b903ea379483d0513d7abc3" + }, + "steps": [ + { + "k": 2, + "method": "quad_toggle_plus_thirdperm", + "details": { + "toggle": { + "D4": 519, + "q": 307, + "d2_cell": 134, + "d6_H": 398, + "d7s": [ + 551, + 546 + ], + "rk0": 7, + "rk_new": 8, + "rk_v1": 504, + "rk_tot": 519 + } + }, + "seed_name": "seed_k2.json.gz", + "gz_sha256": "10eebd653d0725b8229be327ede06cf546b3018d8d3ff6c6c7ad9a2872638fdf", + "raw_sha256": "f47580954b437dfdcef93e271fbbb19a836682a436cb54deaef4d5c4849a48da", + "moves": 2801, + "adds": 30960, + "dirty_clears": 3431, + "charts": { + "frames": 636, + "pairs": 2353, + "frame_gates": 44841 + }, + "n_targets": 18906, + "n_paid": 104832, + "linear_paid_sum": 285312, + "linear_target_sum": 286818, + "raw_c0_float": 0.003893181247910902 + }, + { + "k": 3, + "method": "quad_toggle_plus_thirdperm", + "details": { + "toggle": { + "D4": 522, + "q": 323, + "d2_cell": 213, + "d6_H": 471, + "d7s": [ + 628, + 527 + ], + "rk0": 7, + "rk_new": 8, + "rk_v1": 503, + "rk_tot": 519 + } + }, + "seed_name": "seed_k3.json.gz", + "gz_sha256": "5baf5494c8d073c6ff410b108ad909c2d12ed548479a2ec6e021b8f821f90ea6", + "raw_sha256": "69e7e3e66be4baeec96a8d1090f0037f98df7841323f2389f11690cad2c26669", + "moves": 2800, + "adds": 30899, + "dirty_clears": 3430, + "charts": { + "frames": 636, + "pairs": 2353, + "frame_gates": 44822 + }, + "n_targets": 18906, + "n_paid": 104796, + "linear_paid_sum": 285168, + "linear_target_sum": 286674, + "raw_c0_float": 0.003894716044279911 + }, + { + "k": 4, + "method": "quad_toggle_plus_thirdperm", + "details": { + "toggle": { + "D4": 523, + "q": 322, + "d2_cell": 231, + "d6_H": 453, + "d7s": [ + 631, + 526 + ], + "rk0": 8, + "rk_new": 9, + "rk_v1": 502, + "rk_tot": 519 + } + }, + "seed_name": "seed_k4.json.gz", + "gz_sha256": "8876015ef6c172da589f26e64a818b752feef266244ee49e4232fa8fe7173de8", + "raw_sha256": "f1c159a5d23dc09c9118ffbff957e277a7f3d542c7c3604b4b67783cc34547ac", + "moves": 2799, + "adds": 30961, + "dirty_clears": 3429, + "charts": { + "frames": 636, + "pairs": 2353, + "frame_gates": 44780 + }, + "n_targets": 18906, + "n_paid": 104760, + "linear_paid_sum": 285024, + "linear_target_sum": 286530, + "raw_c0_float": 0.003896252053038069 + }, + { + "k": 5, + "method": "thirdperm_rcv", + "details": { + "D4": 521 + }, + "seed_name": "seed_k5.json.gz", + "gz_sha256": "8dba3630679cdd232bba66234ea843011b097a2dc0cdbf61e4a608aea4099567", + "raw_sha256": "91a70d9c7aeecf56586f6bb63ec27c036294df6824372d6ccac2a7517e31a067", + "moves": 2798, + "adds": 30834, + "dirty_clears": 3428, + "charts": { + "frames": 636, + "pairs": 2353, + "frame_gates": 44769 + }, + "n_targets": 18906, + "n_paid": 104724, + "linear_paid_sum": 284880, + "linear_target_sum": 286386, + "raw_c0_float": 0.003897789275624352 + }, + { + "k": 6, + "method": "simul_quad_toggle", + "details": { + "toggle": { + "D4": 520, + "q": 292, + "d2_cell": 172, + "d6_H": 370, + "d7s": [ + 555, + 607 + ], + "rk0": 8, + "rk_new": 9, + "rk_v1": 499, + "rk_tot": 518 + } + }, + "seed_name": "seed_k6.json.gz", + "gz_sha256": "034cded61ad647b259ecb9f44425102960ae762949512a430dae960b9926bca5", + "raw_sha256": "98710327e4ebd9d4172dcbd0188be9091b1de19096e3fd1e5fea5b18a430126a", + "moves": 2797, + "adds": 30765, + "dirty_clears": 3427, + "charts": { + "frames": 636, + "pairs": 2353, + "frame_gates": 44756 + }, + "n_targets": 18906, + "n_paid": 104688, + "linear_paid_sum": 284736, + "linear_target_sum": 286242, + "raw_c0_float": 0.0038993277134807035 + }, + { + "k": 7, + "method": "simul_quad_toggle_thirdperm", + "details": { + "toggle": { + "D4": 524, + "q": 266, + "d2_cell": 248, + "d6_H": 439, + "d7s": [ + 632, + 629 + ], + "rk0": 8, + "rk_new": 9, + "rk_v1": 498, + "rk_tot": 518 + } + }, + "seed_name": "seed_k7.json.gz", + "gz_sha256": "9e7392c52bcf29c0cc58c54c619f95c28f476394c33e8e0a5aa30c9557d31362", + "raw_sha256": "f4a43e4e36ac734dea10a73dca496bf4a4f4a9804b903ea379483d0513d7abc3", + "moves": 2796, + "adds": 30588, + "dirty_clears": 3426, + "charts": { + "frames": 636, + "pairs": 2353, + "frame_gates": 44734 + }, + "n_targets": 18906, + "n_paid": 104652, + "linear_paid_sum": 284592, + "linear_target_sum": 286098, + "raw_c0_float": 0.0039008673680502896 + } + ] +} diff --git a/research/tiered-native-multiplier/source/activation.py b/research/tiered-native-multiplier/source/activation.py new file mode 100644 index 0000000000..20525c7fa3 --- /dev/null +++ b/research/tiered-native-multiplier/source/activation.py @@ -0,0 +1,80 @@ +"""Check the complete connected activation of a streamed raw-transport installation.""" + +from fractions import Fraction + + +def ceil_log2(n): + return (n-1).bit_length() + + +def binary_entries(rank_logs): + cuts = [] + for h in rank_logs: + minimum = (250*(h+64)+248)//249 + cuts.append(max(minimum,h+64+cuts[-1] if cuts else 0)) + return cuts + + +def full_entrance(last_cut, numerical): + target = last_cut + numerical + 102 + s = max(512,target) + while s - 7*ceil_log2(s) < target: + s = target + 7*ceil_log2(s) + log = ceil_log2(s) + after = 7*(log+1) + target + if (1<=target + assert (1<=target + return s-1 + + +def resource_receipt(profile): + ranks=tuple(profile.rank_logs) + num=profile.complex_log + m=len(ranks) + assert 1<=m<=7 + cuts=binary_entries(ranks) + A=full_entrance(cuts[-1],num) + s=A+1 + assert s>=6000 + # 8E < 33L/s and L <= p/6+3. The remaining excess is <= 34s+8. + # Then 5.5/s <= 11/12000, and p/12000 covers 34s+9 for every s>=6000. + assert (12000*(34*s+9)).bit_length() <= s-2 + for h in (num,*ranks): + assert h>=1024 + assert 68+83*h<92*h + assert 92*h<105*h and 92*h<448*h + assert (700*h).bit_length()<=h and (872*(4*h+1)).bit_length()<=h + assert (30*1024*h+120).bit_length()<=h-1 + for i,h in enumerate(ranks): + assert not i or cuts[i-1]+2=num+cuts[-1]+2 + assert profile.eta1024 and tail>1024 + delta=(-pow(2,A,6))%6 + assert delta in (2,4) + return {"binary_cuts":cuts,"public_exponent_A":A,"first_public_offset":delta, + "initial_s":s,"stage_and_outer_fixed_log_overhead":local, + "retimed_first_stripe_margin":slack,"retimed_all_size_margin_floor":tail, + "absolute_log2_private_control_envelope":job_log, + "storage_upper":"6.2 p T < 297.6 n bits"} diff --git a/research/tiered-native-multiplier/source/check_binary_k7.py b/research/tiered-native-multiplier/source/check_binary_k7.py new file mode 100644 index 0000000000..5d5d9173f4 --- /dev/null +++ b/research/tiered-native-multiplier/source/check_binary_k7.py @@ -0,0 +1,434 @@ +"""Check the constructive k7 binary circuit: replays, charts, sparse oracle, tariff, and #8027 control.""" + +from collections import Counter +from fractions import Fraction +from functools import cache +import gzip +from hashlib import sha256 +import json +from math import lcm +from pathlib import Path +from random import Random +import tarfile + +from installations import BINARY_C +from unpowered_price import certify + +PACKAGE_DIR = Path(__file__).resolve().parent +K7_GZ_SHA256 = "9e7392c52bcf29c0cc58c54c619f95c28f476394c33e8e0a5aa30c9557d31362" +K7_RAW_SHA256 = "f4a43e4e36ac734dea10a73dca496bf4a4f4a9804b903ea379483d0513d7abc3" +OLD_8027_GZ_SHA256 = "74e93daf2b7acf794ffb51f92f03f51556f68126d41ee13a8969bddb4cbe6326" + + +def check_archives_and_ledger(): + gz_bytes = (PACKAGE_DIR / "strong-bit-k7.json.gz").read_bytes() + assert sha256(gz_bytes).hexdigest() == K7_GZ_SHA256 + raw_bytes = gzip.decompress(gz_bytes) + assert sha256(raw_bytes).hexdigest() == K7_RAW_SHA256 + ledger = json.loads((PACKAGE_DIR / "K7-STACK-LEDGER.json").read_text(encoding="utf-8")) + final = ledger["final_k7"] + assert final["moves"] == 2796 + assert final["dirty_clears"] == 3426 + assert (final["frames"], final["pairs"], final["frame_gates"]) == (636, 2353, 44734) + assert (final["n_targets"], final["n_paid"], final["linear_paid_sum"]) == (18906, 104652, 284592) + assert final["gz_sha256"] == K7_GZ_SHA256 and final["raw_sha256"] == K7_RAW_SHA256 + return json.loads(raw_bytes) + + +def run_registers(program, starts, ends, ports): + count = len(starts) + frames = dict(enumerate(starts)) + values = {i: 1 << i for i in range(count)} + dirty = 0 + moves = 0 + for op, dest, *args in program: + if op == "MOVE": + before, after = args + assert frames[dest] == before + frames[dest] = after + moves += 1 + elif op == "ADD": + read, site = args + assert frames[dest] == frames[read] == site + values[dest] ^= values[read] + elif op == "SWAP": + (read,) = args + frames[dest], frames[read] = frames[read], frames[dest] + values[dest], values[read] = values[read], values[dest] + elif op == "INIT": + assert dest >= count and dest not in frames + frames[dest], values[dest] = args[0], 0 + elif op == "CLEAR": + assert dest >= count and frames.pop(dest) == args[0] + dirty += int(bool(values.pop(dest))) + else: + raise ValueError("Unknown graph instruction") + assert frames == dict(enumerate(ends)) + assert len(values) == count == 630 and ports == 111 + for i in range(count): + expected = 1 << i + if ports <= i < 2 * ports: + expected ^= 1 << (i - ports) + assert values[i] == expected + return dirty, moves + + +def check_outer_word(root): + def shift(terms, mask): + return {(role, exponent ^ mask) for role, exponent in terms} + + def stage_mask(stages): + mask = 0 + for stage in stages: + mask ^= 1 << stage + return mask + + head = 1 + words = [{(i, 0)} for i in range(root["roles"])] + for op, *args in root["events"]: + if op == "LOCAL": + stage, x, y = args + body = stage_mask((stage,)) + first, second = words[x], words[y] + words[x] = shift(first, body) + words[y] = shift(first, body ^ head) ^ shift(second, body) + elif op == "IDLE_ONE": + x, stages = args + words[x] = shift(words[x], stage_mask(stages)) + elif op == "QUERY": + x, y = args + words[x] ^= shift(words[y], head) + elif op == "ADD": + x, y = args + words[x] ^= words[y] + elif op == "SWAP": + x, y = args + words[x], words[y] = words[y], words[x] + else: + raise ValueError("Unknown caller instruction") + for i, (answer, diag) in enumerate(zip(words, root["diagonal"], strict=True)): + assert diag["q"] == 1 + assert answer == {(i, head ^ stage_mask(diag["stages"]))} + + +def matrix_product(a, b): + cols = list(zip(*b, strict=True)) + return [[sum(x * y for x, y in zip(u, v, strict=True)) for v in cols] for u in a] + + +def integer_matrix(a): + den = lcm(*(v.denominator for row in a for v in row)) + assert den % 3 + return den, [[int(v * den) for v in row] for row in a] + + +def rational_word(frame): + from factored_frames import inverse_word + from ternary_frames import identity + from vendor.cover import row_program + + word = row_program(frame, 3) + back = tuple(inverse_word(word)) + for program, base, goal in [ + (word, identity(len(frame)), frame), + (back, frame, identity(len(frame))), + ]: + rows = [list(row) for row in base] + for op, i, *args in program: + if op in ("scale", "add"): + q = Fraction(args[-1]) + assert q.denominator % 3 and max(abs(q.numerator), q.denominator) <= 20 + if op == "scale": + assert q.numerator % 3 + for row in rows: + if op == "scale": + row[i] *= q + elif op == "add": + row[i] += row[args[0]] * q + elif op == "swap": + j = args[0] + row[i], row[j] = row[j], row[i] + else: + raise ValueError("Unknown frame instruction") + assert rows == goal + return len(word) + + +def check_charts(data, ports): + from ternary_frames import frame_at_three, identity, projector, transpose + + frames, starts, ends = data["frames"], data["start"], data["final"] + ops = data["program"] + projectors, splits = [], [] + ident = identity(8) + for i in range(len(frames)): + spec = frames[str(i)] + p = projector(transpose(spec["B"] + spec["A"]), spec["dim"]) + projectors.append(p) + den, m = integer_matrix(p) + assert matrix_product(m, m) == [[den * x for x in row] for row in m] + splits.append((den, m)) + pairs = {tuple(row[2:]) for row in ops if row[0] == "MOVE"} + pairs.update(zip(starts[2 * ports :], ends[2 * ports :], strict=True)) + pairs = {tuple(sorted(pair, key=lambda j: frames[str(j)]["dim"])) for pair in pairs} + steps = 0 + for i, j in sorted(pairs): + di, pi = splits[i] + dj, pj = splits[j] + lifted = [[dj * x for x in row] for row in pi] + assert matrix_product(pi, pj) == matrix_product(pj, pi) == lifted + delta = [ + [y - x for x, y in zip(a, b, strict=True)] + for a, b in zip(projectors[i], projectors[j], strict=True) + ] + basis, rank = frame_at_three(delta) + assert rank == frames[str(j)]["dim"] - frames[str(i)]["dim"] + den, m = integer_matrix(delta) + assert matrix_product(m, basis) == [ + [den * v if col < rank else 0 for col, v in enumerate(row)] for row in basis + ] + steps += rational_word(basis) + for i in range(ports): + head, body = projectors[starts[i]], projectors[ends[ports + i]] + assert len(frames[str(starts[i])]["B"]) == 1 + assert projectors[ends[i]] == ident + assert all(x == 0 for row in projectors[starts[ports + i]] for x in row) + assert [ + [x + y for x, y in zip(a, b, strict=True)] for a, b in zip(head, body, strict=True) + ] == ident + basis = transpose(frames[str(starts[i])]["B"] + frames[str(ends[ports + i])]["B"]) + steps += rational_word(basis) + return len(projectors), len(pairs), steps + + +def raw_moments(data, root): + ports = root["ports"] + dims = {int(idx): frame["dim"] for idx, frame in data["frames"].items()} + targets = Counter() + paid = Counter() + local = sum(row[0] == "LOCAL" for row in root["events"]) + for row in root["diagonal"]: + targets[1 + root["body_rank"] * len(row["stages"])] += ports + for src, dst in zip(data["start"][2 * ports :], data["final"][2 * ports :], strict=True): + targets[abs(dims[dst] - dims[src])] += local + for row in data["program"]: + if row[0] == "MOVE": + paid[abs(dims[row[3]] - dims[row[2]])] += local + for row in root["events"]: + if row[0] == "QUERY": + paid[1] += ports + elif row[0] == "IDLE_ONE": + paid[len(row[2]) * root["body_rank"]] += ports + return targets, paid + + +def check_weighted_sparse(data, root): + from check_raw_delta import Sparse, right_columns + from strong_binary import StrongBinarySource + from direct_body import direct_actions, direct_factors + from factored_frames import Frame, inverse_word + from periodic import Job + from raw_binary import Axis, job_frame + from tagged_sources import binary_ports + from ternary_frames import residue + + source = binary_ports(data, root) + seeds = {0, 111, 114, len(source.targets) - 1} + for grade in (4, 8): + seeds.add( + next( + i + for i, port in enumerate(source.targets) + if port.tag[0] == "helper" and port.rank == grade + ) + ) + for modulus, columns in ((3, 1), (9, 2)): + n = source.ambient * columns + ident = tuple(bytes(int(x == y) for x in range(n)) for y in range(n)) + rng = Random(7914) + units = [x for x in range(modulus) if x % 3] + A = [rng.choice(units) for _ in range(n)] + Ai = [pow(a, -1, modulus) for a in A] + + @cache + def scaled_word(word): + out = [] + for op, tail, i, j, coeff in direct_actions(word, 1): + a = residue(coeff, modulus) + if not tail and op == "swap": + a = A[i] * Ai[j] % modulus + elif not tail and op == "add": + a = a * A[j] * Ai[i] % modulus + out.append((op, tail, i, j, a)) + return tuple(out) + + @cache + def factors(word, axis): + u, v = direct_factors(Frame(n, word, (axis,)), modulus) + return bytes(u), bytes(v) + + class DirectSparse(Sparse): + dimension = n + + def route(self, owner, word): + if not self.values[owner]: + return + self.active_routes += 1 + out = set() + for label, h, t in self.values[owner]: + pair = list(h), list(t) + for op, tail, i, j, a in scaled_word(word): + bank = pair[tail] + if op == "swap": + bank[i], bank[j] = ( + a * bank[j] % modulus, + pow(a, -1, modulus) * bank[i] % modulus, + ) + elif op == "scale": + bank[i] = a * bank[i] % modulus + else: + bank[j] = (bank[j] + a * bank[i]) % modulus + out.add((label, bytes(pair[0]), bytes(pair[1]))) + self.values[owner] = out + + def pay(self, job): + if not self.values[job.owner]: + return + self.active_paid += 1 + frame = job_frame(job, n) + out = set() + for label, h, t in self.values[job.owner]: + d = [(y - ai * x) % modulus for x, ai, y in zip(h, Ai, t, strict=True)] + change = [0] * n + for axis in frame.mask: + u, v = factors(frame.word, axis) + coeff = sum(x * y for x, y in zip(v, d, strict=True)) % modulus + if coeff: + change = [ + (x + coeff * y) % modulus for x, y in zip(change, u, strict=True) + ] + self.moved += any(change) + out.add( + ( + label, + bytes( + (x + a * v) % modulus for x, a, v in zip(h, A, change, strict=True) + ), + bytes((y - v) % modulus for y, v in zip(t, change, strict=True)), + ) + ) + self.values[job.owner] = out + + banks = DirectSparse(None, modulus) + entries, expected = [], {} + for i, port in enumerate(source.targets): + owner = banks.zero() + if i in seeds: + g = ( + ("add", 7, 113, Fraction(4, 5)), + ("swap", 0, 126), + ("scale", 4, Fraction(-2)), + ("add", 0, 32, 2), + ("add", 7, 0, i % 4 + 1), + ) + axes = tuple(Axis(g, j) for j in range(port.rank * columns)) + h, t = (bytes(rng.randrange(modulus) for _ in range(n)) for _ in range(2)) + banks.values[i].add((i, h, t)) + data_mat = right_columns(ident, g, modulus) + inv = right_columns(ident, tuple(inverse_word(g)), modulus) + diff = [(y - ai * x) % modulus for x, ai, y in zip(h, Ai, t, strict=True)] + local = [ + sum(col[j] * x for col, x in zip(inv, diff, strict=True)) % modulus + for j in range(port.rank * columns) + ] + change = [ + sum(data_mat[j][k] * entry for j, entry in enumerate(local)) % modulus + for k in range(n) + ] + expected[i] = { + ( + i, + bytes((x + a * v) % modulus for x, a, v in zip(h, A, change, strict=True)), + bytes((y - v) % modulus for y, v in zip(t, change, strict=True)), + ) + } + else: + axes = tuple(range(port.rank * columns)) + entries.append((port.tag, Job(owner, axes))) + count = 0 + for (tag, job), paid in zip( + StrongBinarySource(banks).raw(entries, columns), source.paid, strict=True + ): + assert tag == paid.tag and len(job.axes) == paid.rank * columns + banks.pay(job) + count += 1 + assert count == 104652 and len(banks.values) == len(entries) == 18906 + wrong = [k for k, v in banks.values.items() if v != expected.get(k, set())] + assert not wrong, wrong[:3] + + +def check_predecessor_8027_fails_binary_c(root): + tar_path = PACKAGE_DIR / "predecessor" / "predecessor-8030.tar.gz" + with tarfile.open(tar_path, "r:gz") as archive: + member = archive.getmember("strong-bit.json.gz") + with archive.extractfile(member) as f: + old_gz = f.read() + assert sha256(old_gz).hexdigest() == OLD_8027_GZ_SHA256 + old_data = json.loads(gzip.decompress(old_gz)) + old_targets, old_paid = raw_moments(old_data, root) + assert (old_targets.total(), old_paid.total()) == (18906, 104904) + try: + margin, cells = certify(BINARY_C, (old_targets, old_paid)) + except (AssertionError, ValueError): + return + assert cells is None or margin <= 0, "PR #8027 binary source unexpectedly certified at k7 BINARY_C" + + +def check(): + from strong_binary import caller, graph + + k7_from_pkg = check_archives_and_ledger() + data, root = graph(), caller() + assert data == k7_from_pkg + assert sum(r[0] == "LOCAL" for r in root["events"]) == 36 + dirty, moves = run_registers(data["program"], data["start"], data["final"], root["ports"]) + assert (dirty, moves) == (3426, 2796) + check_outer_word(root) + frames, pairs, steps = check_charts(data, root["ports"]) + assert (frames, pairs, steps) == (636, 2353, 44734) + + targets, paid = raw_moments(data, root) + assert (targets.total(), paid.total()) == (18906, 104652) + linear_t = sum(r * c for r, c in targets.items()) + linear_p = sum(r * c for r, c in paid.items()) + assert (linear_t, linear_p) == (286098, 284592) + signed = {r: targets[r] - paid[r] for r in targets.keys() | paid.keys() if targets[r] != paid[r]} + expected_signed = dict(enumerate((-48720, -45144, -1980, -396, -1296, -2664, -480), 1)) + expected_signed.update({8: 14268, 64: 444, 127: 222}) + for low in range(14, 57, 7): + expected_signed[low] = -444 + expected_signed[low + 1] = 444 + assert signed == expected_signed + + margin, cells = certify(BINARY_C, (targets, paid)) + assert cells is not None and len(cells) == 24 and margin > 0 + + check_weighted_sparse(data, root) + check_predecessor_8027_fails_binary_c(root) + print( + "PASS_K7_BINARY_CIRCUIT", + f"moves={moves}", + f"dirty={dirty}", + f"targets={targets.total()}", + f"paid={paid.total()}", + f"linear_paid={linear_p}", + f"frames={frames}", + f"pairs={pairs}", + f"frame_gates={steps}", + f"cells={len(cells)}", + "control_8027=rejected", + ) + + +if __name__ == "__main__": + check() diff --git a/research/tiered-native-multiplier/source/installer.tar.gz b/research/tiered-native-multiplier/source/installer.tar.gz new file mode 100644 index 0000000000..2595a83633 Binary files /dev/null and b/research/tiered-native-multiplier/source/installer.tar.gz differ diff --git a/research/tiered-native-multiplier/source/ordinary_clock.py b/research/tiered-native-multiplier/source/ordinary_clock.py new file mode 100644 index 0000000000..87c72664af --- /dev/null +++ b/research/tiered-native-multiplier/source/ordinary_clock.py @@ -0,0 +1,49 @@ +"""Check integer envelopes in the ordinary fixed-tape clock proof.""" + +from fractions import Fraction + +RANKS = { + '8030-compact': (260_000, 1_600_000), + '8030-high': (25_000_000, 160_000_000, 1_000_000_000, 6_000_000_000, 36_000_000_000, 224_000_000_000), + '8030-match': tuple(7*x for x in (25_000_000, 160_000_000, 1_000_000_000, 6_000_000_000, 36_000_000_000, 224_000_000_000)), + '8035-near': (6_835_937_536, 109_375_000_000, 1_750_000_000_000, 28_000_000_000_000, 448_000_000_000_000, 7_168_000_000_000_000), + '8035-fixed': (106_811_524, 1_708_984_375, 27_343_750_000, 437_500_000_000, 7_000_000_000_000, 112_000_000_000_000), +} + + +def polynomial_to_fibre_bound(): + # X=2^16 N^4 (D+1)(w+1)^252, D+1<=256(w+1). + # w+1<=2^259*u^258; u^a/3^(u-1)<=3*a^a. + degree = 20 * 253 + a = 258 * degree + return 20 * (16 + 8) + 259 * degree + 2 + a * (a - 1).bit_length() + + +def first_stage_bound(eta): + assert eta >= Fraction(97,25000) and 2*eta > Fraction(1,250) + # u >= ceil(e^eta)/2, hence w+1 <= 9u^2. Bound u^a/3^(u-1) by 3a^a. + degree = 20*253 + a = 2*degree + return 20*(16+8)+4*degree+2+a*(a-1).bit_length() + + +def full_log2_B(ranks): + # B0=2^100, B_i<=J_i^14(1+Bprev); root binary rectangle and digit rounding. + return 40 + 16 * 1024 * sum(ranks) + + +def main(): + extra = polynomial_to_fibre_bound() + assert Fraction(9*16, 15*32) == Fraction(3, 10) + assert Fraction(1,1) / (1-Fraction(3,10)) == Fraction(10,7) + assert all((1+y)**5 <= 2**14 * max(1, 2**(y-1)) for y in range(1, 11)) + assert all((z+1)**5 <= 2**10*3**z for z in range(1, 8)) + assert all((e+1)**5 <= 32*4**e for e in range(1, 8)) + assert all(extra + 80*min(H) < 1024*min(H) for H in RANKS.values()) + print('log2 fixed variable-amortization factor <=', extra, 'plus 80 H') + for name, H in RANKS.items(): + print(name, 'sum H', sum(H), 'log2 B <=', full_log2_B(H)) + + +if __name__ == '__main__': + main() diff --git a/research/tiered-native-multiplier/source/outer_budget.py b/research/tiered-native-multiplier/source/outer_budget.py new file mode 100644 index 0000000000..35dd5cf836 --- /dev/null +++ b/research/tiered-native-multiplier/source/outer_budget.py @@ -0,0 +1,40 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Directed rational outer inequalities for the inherited parameterized signed caller. + +The 54 strict and four functional expressions follow the P104 dual-supplier +gate at 4f7c67ae387cc91580f469aeda4d508b372b9ec1. The positive and ordinary +caps come independently from the actual single-band profiles. +""" +from fractions import Fraction as Q + + +def margins(k,g,ordinary,positive): + a,b,q=k+4*g,k+5*g,k+3*g + ep,be=1-g,1-3*g + r0=g/10 + sigma,tau=1-b,1-a + internal=tau+(1-g)*max(sigma-tau,0) + leaf=sigma+g*(1-sigma) + lam=1-(q+a)/2 + xi=ep*(1+q)-Q(3,32)+g + key=be+1-ep + powers=[ep*q,a,1-ep+q*be,1-ep+a*be,1-ep+be,Q(3,32)+xi-ep, + xi+Q(1,2)-ep,ep,1-(ep+be+48-128+2)] + strict=[ordinary-a,b-a,q,b-q,a-q,g,1-g,(1-g)*b-a,1-internal-q,1-leaf-q, + lam-tau,lam-sigma,lam-internal,1-q-lam,1-q-leaf,ep,1-ep,xi-Q(1,2),ep-xi, + be,ep-be,1-be,1-(2*xi-2)-r0-be,1-(2*xi-2)-be,1-ep-r0,1-ep,r0,1-key, + 1-be-2*(1-ep),128-48-be,g,ep-a,Q(1,32)-b,Q(2**45-7**16),Q(2),2-xi, + Q(5),1-be,1-be,1-ep,powers[2]-powers[0],g,k-Q('.001730970419199163702738'), + 1-ep,Q(11,2)]+[x-k for x in powers] + functional=[1-be,be*(1-Q(3,1000)),128-48-ep-be-1,be*(1-Q(1,250))] + assert len(strict)==54 and len(functional)==4 + return strict,functional,positive-b + + +def qualify(k,g,ordinary,positive): + strict,functional,paid=margins(k,g,ordinary,positive) + if min(*strict,*functional,paid)<=0: + raise ArithmeticError('signed outer budget has an unfunded inequality') + return {'strict':len(strict),'functional':len(functional), + 'smallest_margin':str(min(*strict,*functional,paid)), + 'ordinary_margin':str(ordinary-k-4*g),'positive_margin':str(paid)} diff --git a/research/tiered-native-multiplier/source/outer_clock.py b/research/tiered-native-multiplier/source/outer_clock.py new file mode 100644 index 0000000000..3c4fa183a0 --- /dev/null +++ b/research/tiered-native-multiplier/source/outer_clock.py @@ -0,0 +1,114 @@ +"""Check the finite endpoints and the dyadic induction comparisons for the outer clock.""" + +from fractions import Fraction +from itertools import chain + + +def width_cap(s): + if s < 512: + return 128 * s * s + return 1024 * s + 2560 + + +def private_log(s): + # X=2^64(t+2)(P+2), P<2^20 p, d<=p<2^s. + return s + 1024 * (width_cap(s) + s + 88) + + +def controls_log(s): + # Dense Beneš, inverse modulo the true side, restored left child, and all copies. + return 60 + 16 * (s + 1) + 10 * (width_cap(s) + 1) + + +def exact_shape_check(package): + from pathlib import Path + import sys + + sys.path.insert(0, str(Path(package).resolve())) + import band_product + from linear_geometry import parameters, square_sides + + first = (18508 << 18493) + 1 + assert parameters(first - 1) is None + shape = parameters(first) + assert shape.count == 1 + side, = square_sides(shape) + bits = next(shape.axes()) + assert side.bit_length() == bits + actual_precision = band_product.precision(shape.public, shape.extent_bits, shape.count) + # The production fourier_axis function calls [Fraction(1)] * r. This reproduces + # its host list limit before any large allocation. It is not a Turing lower bound. + try: + [None] * side + except OverflowError as exc: + host = type(exc).__name__ + else: + raise AssertionError("The first side unexpectedly fit a host list") + + # The two-endpoint assertions bind all advertised finite constants to the producer. + return {"first_b": shape.public // 6, "first_L": bits, "first_P": actual_precision, + "first_side_bit_length": side.bit_length(), "host_list": host} + + +def financial_checks(): + # At s>=32 the private setup fits in n. Compare one term with an exponential + # and use (s+2)^2<2(s+1)^2 on the tail. The linear cap only decreases at s=512. + # p=6b, s=ceil(log2(6b+2)), and n>2^(b-1) when n>1. + def prefix_log(s): + lower = max(0, ((1 << (s-1))-2)//6-1) + return private_log(s)-lower + prefix = max(prefix_log(s) for s in range(1,32)) + assert prefix < 84_500_000-1000 and prefix == prefix_log(27) + assert 32 + 1024 * (128 * 32**2 + 32 + 88) < 1 << (32 - 4) + assert max(controls_log(s) for s in range(1, 64)) < 1 << 23 + assert 128 * 63**2 == 508_032 + for s in chain(range(32, 1025), (4096, 8192)): + assert private_log(s) < 1 << (s - 4) + if s >= 64: + # Use p>=2^(s-1)-1 and L>=p/12. The polynomial has its + # maximum relative to the exponential at the first endpoint. + p_min = (1 << (s - 1)) - 1 + L_min = p_min // 12 + G_max = 64 * (width_cap(s) + s) + assert L_min >= 10100 * G_max + assert L_min // (2 * width_cap(s)) >= 51_200 + H_min = L_min // 101 + assert controls_log(s) + 16 < H_min + assert private_log(s) + 16 < H_min + # Scalar fallback is impossible at b >= 2^15. On 2^j<=b<2^(j+1), + # ceil(log2(p+2))<=j+4; L >= 2^j-j-1. Growth closes all later j. + for j in range(15, 128): + assert (1 << j) - j - 1 >= 64 * (j + 4)**2 + assert 2 * (j + 4)**2 >= (j + 5)**2 + for s in (512, 1023, 1024, 4096): + ell = width_cap(s) + h_mixing_class = 80_000 * (ell + 2)**6 + 2048 * s + 2 + pack_pass = 40_000 * (ell + 2)**6 + 4 + assert 3 * h_mixing_class * pack_pass < (1 << 168) * (s + 1)**12 + # Each switch has at most 20 whole swaps, and each tail has two. + K = 64 * 64 * (ell + s) + crt_dispatch = 3 * s * 2 * ell * (1 << 18) * (10 + 32 * K + 4 * K*K) + assert crt_dispatch < (1 << 90) * (s + 1)**4 + g = Fraction(1, 10**17) + assert (Fraction(128, 1) / g)**16 < 1 << 1024 + assert 17**16 * 10**(21*16) < 1 << 1182 + assert 400 + 1182 + 9 + 2 < 1600 + return {"small_stop_tail_factor_log2":1591, "private_prefix_log2": max(private_log(s) for s in range(1, 32)), + "controls_prefix_log2": max(controls_log(s) for s in range(1, 64)), + "private_prefix_after_input_log2": prefix, + "early_log2_C_bound": 84_500_000, + "tail_log2_fixed_factor_including_b_to_n": 1434, + "tail_unit": "(1 + B + Z) * n * (1 + log2(n))^(1-kappa)"} + + +if __name__ == "__main__": + from argparse import ArgumentParser + import json + + command = ArgumentParser(description=__doc__) + command.add_argument("package", nargs="?") + args = command.parse_args() + report = financial_checks() + if args.package: + report.update(exact_shape_check(args.package)) + print(json.dumps(report, sort_keys=True)) diff --git a/research/tiered-native-multiplier/source/strong-bit-k7.json.gz b/research/tiered-native-multiplier/source/strong-bit-k7.json.gz new file mode 100644 index 0000000000..f334b505e6 Binary files /dev/null and b/research/tiered-native-multiplier/source/strong-bit-k7.json.gz differ diff --git a/research/tiered-native-multiplier/verify.py b/research/tiered-native-multiplier/verify.py new file mode 100644 index 0000000000..e87b02c8d9 --- /dev/null +++ b/research/tiered-native-multiplier/verify.py @@ -0,0 +1,90 @@ +"""Replay one scope on a fresh, authenticated signed multiplier.""" + +from pathlib import Path +from tempfile import TemporaryDirectory +from subprocess import run +import json +import sys + +PACKAGE = Path(__file__).resolve().parent +sys.path.insert(0, str(PACKAGE)) +from bootstrap import install + + +def worker(name, target): + cmd = [sys.executable, "-IB", str(PACKAGE / name), str(target)] + return run(cmd, check=True, capture_output=True, text=True).stdout + + +def check_binary(): + from upstream import install as activate + activate() + sys.path.append(str(PACKAGE / "source")) + from check_binary_k7 import check_archives_and_ledger, check_charts, check_outer_word + from check_binary_k7 import check_weighted_sparse, run_registers + from strong_binary import caller, graph + g, root = graph(), caller() + assert g == check_archives_and_ledger() + assert sum(v[0]=="LOCAL" for v in root["events"]) == 36 + assert run_registers(g["program"], g["start"], g["final"], root["ports"]) == (3426,2796) + check_outer_word(root) + assert check_charts(g,root["ports"]) == (636,2353,44734) + check_weighted_sparse(g,root) + print("PASS_K7_ALL_630_ROLES_AND_WEIGHTED_ROUTES") + + +def check_product(): + from band_product import multiply, multiply_tapes + from check_product import physical_product + from installations import ENTRY, TERMINAL + from io import BytesIO + + for a,b in ((0,0),(-1,0),(-1,-1),(-741503,466013),(741503,466013), + (2**127-1,-2**73+3),(-(2**4096+9),2**41-1)): + assert multiply(a,b) == a*b + for profile in (ENTRY,TERMINAL): + left = BytesIO(b"pre"+(741503).to_bytes(6,"little")+b"post") + right = BytesIO(b"pre"+(466013).to_bytes(5,"little")+b"end") + left.seek(3) + right.seek(3) + out = BytesIO() + sign, size = multiply_tapes(left,6,right,5,out,left_negative=True,profile=profile) + assert sign and size == 5 and -int.from_bytes(out.getvalue(),"little") == -345550037539 + assert left.tell()==3 and right.tell()==3 + result = physical_product(ENTRY) + assert result["coefficients_prefix"] == [11811,10996,4152,868,77] + print(json.dumps(result,sort_keys=True)) + print("PASS_SIGNED_PRODUCT_AND_RESTORATION") + + +def main(scope): + if not __debug__: + raise RuntimeError("Enable Python assertions for this replay") + with TemporaryDirectory(prefix="tier-machine-") as name: + dst = Path(name) + install(dst) + sys.path.insert(0, str(dst)) + if scope == "price": + receipt = json.loads(worker("receipt.py",dst)) + assert receipt == json.loads((PACKAGE/"RESULT.json").read_bytes()) + print(worker("check_placement.py",dst),end="") + print("PASS_COMPLETE_RATE_STOCK_AND_CLOCK",receipt["complete_log2_C"]) + elif scope == "binary": + check_binary() + elif scope == "gaussian": + print(worker("check_gaussian.py",dst),end="") + print(worker("check_phase_passes.py",dst),end="") + elif scope == "setup": + measured = json.loads(worker("check_serial_setup.py",dst)) + assert measured == json.loads((PACKAGE/"MEASUREMENTS.json").read_bytes())["serial_setup"] + print("PASS_SERIAL_FIXED_INSTALL", measured["setup_exponent"]) + elif scope == "product": + check_product() + elif scope == "interval": + print(worker("independent_price.py",dst),end="") + else: + raise ValueError("Unknown replay scope") + + +if __name__ == "__main__": + main(sys.argv[1])