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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions research/complex-center-quarter/SOURCES.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
"mode": "bytes",
"sha256": "36e9e421230c4cb7b6a537d76a4bdfb6f667730d383e56062d4e45957484ab9e"
},
"research/complex-k492-owner-repair/code/hpe_audit_local.py": {
"mode": "bytes",
"sha256": "6bd9a1e279c9c9e4f3767d9f82e537b559292906feb2ddab02f380fb6523a810"
},
"research/complex-k492-owner-repair/code/hpe_emit_local.py": {
"mode": "bytes",
"sha256": "7e4a6fbc38c8228157b6311457d1496bf460291393043932d2c365f004f77805"
Expand Down Expand Up @@ -63,6 +59,10 @@
"research/complex-k492-owner-repair/code/invoice_allcold.py": {
"mode": "bytes",
"sha256": "141bd2fd58bbfb5b8d0fc8f56f61c45586d5608a5af3487c6b883dd987f998ec"
},
"research/complex-sw4-frame8/local/hpe_audit_local.py": {
"mode": "bytes",
"sha256": "6bd9a1e279c9c9e4f3767d9f82e537b559292906feb2ddab02f380fb6523a810"
}
}
}
11 changes: 9 additions & 2 deletions research/complex-center-quarter/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
SELECTED = "certificates/selected-result.json"
SPEC = "research/complex-k492-owner-repair/data/SPEC.json"
INVENTORY = "research/community-k492-audit/SELECTED-SOURCE.json"
AUDITOR = "research/complex-k492-owner-repair/code/hpe_audit_local.py"
AUDITOR = "research/complex-sw4-frame8/local/hpe_audit_local.py"
EMITTER = "research/complex-k492-owner-repair/code/hpe_emit_local.py"
INVOICE = "research/complex-k492-owner-repair/code/invoice_allcold.py"
REPLAY = "research/community-k492-audit/pr626/replay/mixed-global/base/providers"
Expand Down Expand Up @@ -67,8 +67,15 @@ def check_sources():
require(selection["audited_source_head"] == pins["reviewed_heads"]["626"], "selected head")
for pr, head in pins["reviewed_heads"].items():
require(selection["reviewed_dependency_heads"][pr] == head, "reviewed head: " + pr)
inventory_keys = {
SPEC: SPEC,
AUDITOR: "research/complex-k492-owner-repair/code/hpe_audit_local.py",
EMITTER: EMITTER,
INVOICE: INVOICE,
}
for rel in (SPEC, AUDITOR, EMITTER, INVOICE):
require(inventory["files"][rel] == pins["files"][rel]["sha256"], "inventory pin: " + rel)
require(inventory["files"][inventory_keys[rel]] == pins["files"][rel]["sha256"],
"inventory pin: " + rel)
for name in PROVIDERS:
desc = spec["providers"][name]
for filename in ("CANONICAL-WORD.json.gz", "LOCAL-PROGRAMS.json.gz"):
Expand Down
77 changes: 67 additions & 10 deletions research/complex-k492-owner-repair/code/hpe_audit_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,65 @@
import copy,gzip,hashlib,json,sys
from collections import Counter
from fractions import Fraction as Q

# Production integer-row acceleration from research/emitted-local-integer-replay-seed90.
# Identical receipts to pairwise Fraction-dict rows; see research/emitted-local-integer-production/.
class Row:
"""Sparse integer numerators divided by 2**exponent."""

def __init__(self, values=None):
self.values = {}
self.exponent = 0
if values:
self.values = {k: int(v) for k, v in values.items()}
if any((Q(v).denominator != 1 for v in values.values())):
raise ValueError('initial Row must be integral')

def clone(self):
result = Row()
result.values = self.values.copy()
result.exponent = self.exponent
return result

def scale(self, q):
a, b = (q.numerator, q.denominator)
if b & b - 1:
raise ValueError('non-dyadic row scale')
result = self.clone()
result.exponent += b.bit_length() - 1
result.values = {k: a * v for k, v in self.values.items()}
return result

def add_scaled(self, other, q):
a, b = (q.numerator, q.denominator)
if b & b - 1:
raise ValueError('non-dyadic row addition')
source_exp = other.exponent + b.bit_length() - 1
exponent = max(self.exponent, source_exp)
left_shift = exponent - self.exponent
right_shift = exponent - source_exp
if left_shift:
self.values = {k: v << left_shift for k, v in self.values.items()}
for k, v in other.values.items():
total = self.values.get(k, 0) + (a * v << right_shift)
if total:
self.values[k] = total
else:
self.values.pop(k, None)
self.exponent = exponent

def __bool__(self):
return bool(self.values)

def __eq__(self, other):
if isinstance(other, Row):
exponent = max(self.exponent, other.exponent)
return {k: v << exponent - self.exponent for k, v in self.values.items()} == {k: v << exponent - other.exponent for k, v in other.values.items()}
if isinstance(other, dict):
if set(self.values) != set(other):
return False
return all((v * Q(other[k]).denominator == Q(other[k]).numerator * (1 << self.exponent) for k, v in self.values.items()))
return NotImplemented
from pathlib import Path
OUT=Path(sys.argv[1])
c=json.load(gzip.open(OUT/'CANONICAL-WORD.json.gz'))
Expand All @@ -25,7 +84,7 @@ def contains(a,b):
# COLD-HPE: cold helpers (start frame 0) ending at U carry the (0, U) wrappers too; without cold ends wrapped == entering
cold=sorted(hpe-set(entering));wrapped=sorted(set(entering)|hpe);plain={r for r in range(n) if r not in set(wrapped)}
def local(events,back):
rows={('L',r):{r:Q(1)} for r in range(n)}
rows={('L',r):Row({r:1}) for r in range(n)}
norm={('L',r):Q(1) for r in range(n)};prefix=Q(1);cur=c['start'].copy();private={}
hist=Counter();phases=[];entry=[];exit=[];centers=[];matrix_hash=hashlib.sha256();chain={};wrappers=[]
wset=set(wrapped);pre_seen=set();post_seen=set() # WRAPPER ORDER (Lemma A): R^-1 precedes, L^-1 follows, every scalar touching a wrapped helper
Expand Down Expand Up @@ -76,12 +135,12 @@ def local(events,back):
else:
if r==target and r not in private:private[r]=f
assert private[r]==f
if op=='clear':rows[target]={};norm[target]=Q(0)
elif op=='copy':rows[target]=dict(rows[source]);norm[target]=norm[source]
if op=='clear':rows[target]=Row();norm[target]=Q(0)
elif op=='copy':rows[target]=rows[source].clone();norm[target]=norm[source]
elif op=='scale':
q=Q(e[2],e[3]);a,b=abs(q.numerator),q.denominator
assert a&(a-1)==0 and b&(b-1)==0
rows[target]={j:q*x for j,x in rows[target].items()};norm[target]*=abs(q)
rows[target]=rows[target].scale(q);norm[target]*=abs(q)
else:
q=Q(e[3],e[4]);a,b=abs(q.numerator),q.denominator
assert source!=target and b&(b-1)==0
Expand All @@ -91,11 +150,8 @@ def local(events,back):
assert Q(w,b)*(1 if q>0 else -1)==q
prefix=max(prefix,Q(a)*norm[source])
norm[target]=norm.get(target,Q(0))+abs(q)*norm[source]
row=rows.setdefault(target,{})
for j,x in list(rows[source].items()):
z=row.get(j,Q(0))+q*x
if z:row[j]=z
else:row.pop(j,None)
row=rows.setdefault(target,Row())
row.add_scaled(rows[source],q)
prefix=max(prefix,norm[target])
else:raise AssertionError(tag)
assert phases==allowed and set(centers)==set(range(len(c['centers']))) and not private
Expand All @@ -122,6 +178,7 @@ def local(events,back):
assert dict(profiles[name])=={int(r):z for r,z in c['local_profile'].items()}
print('independent emitted replay PASS',name,flush=True)
controls=[]
_encoded_program=json.dumps(ir['local_programs']['forward'])
for name,mut in [
('wrong_scale',lambda es:next(e for e in es if e[0]=='scalar' and e[1][0]=='scale')[1].__setitem__(2,3)),
('missing_center',lambda es:es.pop(next(i for i,e in enumerate(es) if e[0]=='center'))),
Expand Down Expand Up @@ -155,7 +212,7 @@ def local(events,back):
('cold_hpe_post_wrapper_wrong_terminal_frame',lambda es:next(e for e in es if e[0]=='residual_adapter' and e[1]=='post' and e[2]==cold[0]).__setitem__(4,1)),
('cold_hpe_premix_gate_before_pre_wrapper',lambda es:(lambda ev:es.insert(next(i for i,e in enumerate(es) if e[0]=='residual_adapter' and e[1]=='pre' and e[2]==cold[0]),ev))(es.pop(next(i for i,e in enumerate(es) if e[0]=='scalar' and (('L',cold[0]) in [tuple(e[1][1])]+([tuple(e[1][2])] if e[1][0] in ('add','copy') else []))))) ),
] if cold else []):
es=copy.deepcopy(ir['local_programs']['forward']);mut(es)
es=json.loads(_encoded_program);mut(es)
try:local(es,False)
except (AssertionError,KeyError):controls.append(name)
else:raise AssertionError('mutation accepted: '+name)
Expand Down
12 changes: 10 additions & 2 deletions research/complex-signed-prefix-audit/SOURCES.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
},
{
"path": "research/complex-k492-owner-repair/code/hpe_audit_local.py",
"usage": "input",
"usage": "provenance",
"git_blob": "17bccb64fdca54f329a3ce16e369449cb76c2802",
"sha256": "6bd9a1e279c9c9e4f3767d9f82e537b559292906feb2ddab02f380fb6523a810"
"sha256": "6bd9a1e279c9c9e4f3767d9f82e537b559292906feb2ddab02f380fb6523a810",
"note": "Pairwise-era digest retained as provenance after research/emitted-local-integer-production/; working k492 checker ships integer rows. Live checker retargeted to complex-sw4-frame8/local/hpe_audit_local.py (SELECTED-SOURCE-bound, still pairwise)."
},
{
"path": "research/gauge44-slots-t16/code/invoice_allcold.py",
Expand All @@ -49,6 +50,13 @@
"usage": "input",
"git_blob": "a94a2ac168c088a1282ea411766bc859178620df",
"sha256": "1cbce5cf0ff0152f71e8ae7bef25841d1ce13010af248ff7209182d2328c21c9"
},
{
"path": "research/complex-sw4-frame8/local/hpe_audit_local.py",
"usage": "input",
"git_blob": "17bccb64fdca54f329a3ce16e369449cb76c2802",
"sha256": "6bd9a1e279c9c9e4f3767d9f82e537b559292906feb2ddab02f380fb6523a810",
"note": "SELECTED-SOURCE-bound local checker; byte-identical to pairwise-era k492 hpe_audit_local.py."
}
]
}
4 changes: 2 additions & 2 deletions research/complex-signed-prefix-audit/VERIFY.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"inputs": [
"research/community-frontier1094-audit/SELECTED-SOURCE.json",
"research/community-frontier1094-audit/selected-replay.tar.gz",
"research/complex-k492-owner-repair/code/hpe_audit_local.py",
"research/gauge44-slots-t16/code/invoice_allcold.py",
"research/e8-lemma-g-lean/PROOF.md",
"research/hyperplane-end-lean/PROOF.md"
"research/hyperplane-end-lean/PROOF.md",
"research/complex-sw4-frame8/local/hpe_audit_local.py"
],
"commands": [
{
Expand Down
2 changes: 1 addition & 1 deletion research/complex-signed-prefix-audit/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
ROOT = PACKAGE.parent.parent
ARCHIVE = "research/community-frontier1094-audit/selected-replay.tar.gz"
MANIFEST = "research/community-frontier1094-audit/SELECTED-SOURCE.json"
LOCAL_CHECKER = "research/complex-k492-owner-repair/code/hpe_audit_local.py"
LOCAL_CHECKER = "research/complex-sw4-frame8/local/hpe_audit_local.py"
INVOICE = "research/gauge44-slots-t16/code/invoice_allcold.py"
BASE = "candidate/strict/global/base/providers/gauge44/"
INPUTS = {ARCHIVE, MANIFEST, LOCAL_CHECKER, INVOICE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"research/community-frontier1042-audit/ASSEMBLY.json": "093f35445812ea96fe1bfe6a3af7d769cb7f274e08f4fb30f71a17ed1161e54e",
"research/community-frontier1042-audit/selected-replay.tar.gz": "22c3f4dce4b897a1d423d1388801933e288b6a6b1906cb15e1b16a5eb68db754",
"research/complex-dyadic-lowering/lower.py": "eb37d00063dc09323e9aca041d23da749ce17fbd71dade9aaf1c059cab0b9753",
"research/complex-k492-owner-repair/code/hpe_audit_local.py": "6bd9a1e279c9c9e4f3767d9f82e537b559292906feb2ddab02f380fb6523a810",
"research/complex-k492-owner-repair/code/hpe_emit_local.py": "7e4a6fbc38c8228157b6311457d1496bf460291393043932d2c365f004f77805"
"research/complex-k492-owner-repair/code/hpe_emit_local.py": "7e4a6fbc38c8228157b6311457d1496bf460291393043932d2c365f004f77805",
"research/complex-sw4-frame8/local/hpe_audit_local.py": "6bd9a1e279c9c9e4f3767d9f82e537b559292906feb2ddab02f380fb6523a810"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pathlib import Path
HERE=Path(__file__).resolve().parent;ROOT=HERE.parents[1]
ARCHIVE='research/community-frontier1042-audit/selected-replay.tar.gz'
CHECKER='research/complex-k492-owner-repair/code/hpe_audit_local.py'
CHECKER='research/complex-sw4-frame8/local/hpe_audit_local.py'
LOWER='research/complex-dyadic-lowering/lower.py'
HORNER='research/complex-k492-owner-repair/code/hpe_emit_local.py'
REQUIRED={ARCHIVE,CHECKER,LOWER,HORNER,'research/community-frontier1042-audit/ASSEMBLY.json'}
Expand Down
5 changes: 3 additions & 2 deletions research/dyadic-fractional-grid/SOURCES.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
"git_blob_of_committed_file": "534fdc71f7641c704575efc038363d7eb206b2df"
},
{
"path": "research/complex-k492-owner-repair/code/hpe_audit_local.py",
"path": "research/complex-sw4-frame8/local/hpe_audit_local.py",
"encoding": "file",
"sha256": "6bd9a1e279c9c9e4f3767d9f82e537b559292906feb2ddab02f380fb6523a810",
"git_blob_of_committed_file": "17bccb64fdca54f329a3ce16e369449cb76c2802"
"git_blob_of_committed_file": "17bccb64fdca54f329a3ce16e369449cb76c2802",
"note": "Retargeted to SELECTED-SOURCE-bound pairwise checker after research/emitted-local-integer-production/ rewrote k492 hpe_audit_local.py."
},
{
"path": "research/complex-k492-owner-repair/code/invoice_allcold.py",
Expand Down
8 changes: 6 additions & 2 deletions research/dyadic-horner-direction/SOURCES.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@
"sha256": "7e4a6fbc38c8228157b6311457d1496bf460291393043932d2c365f004f77805"
},
{
"path": "research/complex-k492-owner-repair/code/hpe_audit_local.py",
"path": "research/complex-sw4-frame8/local/hpe_audit_local.py",
"encoding": "file",
"sha256": "6bd9a1e279c9c9e4f3767d9f82e537b559292906feb2ddab02f380fb6523a810"
"sha256": "6bd9a1e279c9c9e4f3767d9f82e537b559292906feb2ddab02f380fb6523a810",
"archived_paths": [
"research/complex-sw4-frame8/local/hpe_audit_local.py"
],
"note": "Retargeted to SELECTED-SOURCE-bound pairwise checker after research/emitted-local-integer-production/."
},
{
"path": "research/complex-k492-owner-repair/code/invoice_allcold.py",
Expand Down
16 changes: 16 additions & 0 deletions research/emitted-local-integer-production/NOTICE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Notice

Production wiring of the exact shared-denominator integer-row emitted-local
audit into `research/complex-k492-owner-repair/code/hpe_audit_local.py`.

## Credit

- woklerx / [CrocSwap/integer-mult-bounds#1184](https://github.com/CrocSwap/integer-mult-bounds/pull/1184)
(`research/emitted-local-integer-replay-seed90/`): proved opt-in integer rows
with identical complete local-audit receipts.
- icekylinx for the independent local checker lineage retained in PR514/PR433
and later cold14/k492 packages.
- Shared-denominator representation follows prior PR367/824/1137/1156 work.

Prepared by Wentao Li (VictorLiwentao, @Is__Victor, wentaol4@illinois.edu)
with substantial AI assistance. Apache-2.0.
95 changes: 95 additions & 0 deletions research/emitted-local-integer-production/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Production integer-row emitted local audit

**Tooling improvement; no new kappa.** At base
`0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2`,
`research/complex-k492-owner-repair/code/hpe_audit_local.py` still stored every
scalar row as a dictionary of `Fraction` values. woklerx’s opt-in adapter
`research/emitted-local-integer-replay-seed90/` (incorporated
[#1184](https://github.com/CrocSwap/integer-mult-bounds/pull/1184)) already
proved shared-denominator sparse integer rows with identical complete local-audit
receipts. This package wires that equivalent rewrite into the **production**
k492 checker used by emitted-local tooling.

SELECTED-SOURCE-bound
`research/complex-sw4-frame8/local/hpe_audit_local.py` copies are intentionally
left pairwise so the selected inventory stays untouched. Dependent VERIFY
packages that previously live-pinned the k492 path retarget to that sw4 checker.

## Reproduce

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

```sh
python3.12 -I -B research/emitted-local-integer-production/verify.py
python3.12 -I -O -B research/emitted-local-integer-production/verify.py
python3.12 -B scripts/research_package.py --package research/emitted-local-integer-production
taskset -c 0 python3.12 -I -B research/emitted-local-integer-production/benchmark.py --rounds 5 --write-result
```

Expected:

```text
PASS_EMITTED_LOCAL_INTEGER_PRODUCTION assertions=… controls=25 corruption=… certs=1 no_new_kappa
PASS_REGISTERED_RESEARCH_PACKAGE research/emitted-local-integer-production outcome=completed
PASS_IDENTICAL_EMITTED_LOCAL_INTEGER_PRODUCTION_RECEIPTS
```

Default verify is read-only. Temp-copy ADD-drop foil rejects via audit failure
or receipt divergence. Package gates under `-O` still launch asserting checker
children (`python -B` with `PYTHONOPTIMIZE` cleared). Full `make verify`,
selected cold replay, Lean, and multiplication-theorem obligations were not
rerun for this isolated historical-checker change.

## Result

On Linux / CPython 3.12.3 with `taskset -c 0`, five alternating fresh-process
pairs gave median complete selected-R480 local-audit wall time **7.080 → 3.131 s (2.26×)**. Details are in
[`RESULT.json`](RESULT.json). Timing is host-descriptive and is not a
correctness gate. Every receipt matches digest
`13dd18297162569532983db1a2ab67926b064330cd7edd3587e7b546b2dedf17`
(25 retained negative controls).

## Why the integer rows are equivalent

Each row stores integer numerators over a shared power-of-two denominator
(`2**exponent`). Scale and ADD updates shift exponents exactly when the
coefficient is dyadic, matching `Fraction` arithmetic on this dyadic scalar
macro language. Zero entries are omitted just as in the original dictionaries.
JSON mutation fixtures are decoded once and reloaded per control, preserving
the original deepcopy isolation. See
`research/emitted-local-integer-replay-seed90/PROOF.md`.

## Overlap and credit

Closest priors (different delivery):

- `research/emitted-local-integer-replay-seed90/` / [#1184](https://github.com/CrocSwap/integer-mult-bounds/pull/1184)
— opt-in integer rows; this is the production wiring.
- [CrocSwap/integer-mult-bounds#756](https://github.com/CrocSwap/integer-mult-bounds/pull/756)
— identical-receipt tooling quality bar.
- Open leave-alone tooling on other objects (#1922 joint frames, #2039/#2054
shared-point, #2100 ternary, #2117 DisjointTensor, #2150 mixed-point,
#2194/#2210/#2231/#2239/#2257/#2263/#2276/#2320/#2329/#2348 production
rewrites; #1076 quadratic-affine) was not reopened.

Credit woklerx, icekylinx, and the retained local-checker lineage. Prepared by
Wentao Li ([VictorLiwentao](https://github.com/VictorLiwentao),
[@Is__Victor](https://x.com/Is__Victor)) with substantial AI assistance, under
Apache-2.0.

## Open next questions

1. **Question:** Should the SELECTED-SOURCE-bound sw4 `hpe_audit_local.py`
copies adopt the same integer-row rewrite with a coordinated
`SELECTED-SOURCE.json` digest refresh?
**Why it matters:** Selected cold-chain local-replay still runs the pairwise
checker.
**First step:** Enumerate SELECTED-SOURCE paths with sha256 `6bd9a1e2…` and
dependent VERIFY binders.
**Blocked by:** Maintainer inventory-refresh preference.

2. **Question:** Should other byte-identical vendored `hpe_audit_local.py`
copies adopt the same rewrite?
**Why it matters:** Historical trees still pin pairwise-era digests.
**First step:** Diff each copy against the production transform site.
**Blocked by:** One-object stop rule.
Loading
Loading