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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"schema_version": 1,
"scope": "Written all-size characteristic-zero proof; finite evidence is not a kernel theorem or physical supplier.",
"source_sha256": {
"research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962",
"research/selector-batching/README.md": "e50bae87f9bfa2dee515468aeb56d47676410ca3adfdf0e83d11bf0e31fadf2d"
},
"uniform": {
Expand Down
11 changes: 9 additions & 2 deletions research/clifford-reciprocal-basis-obstruction/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ higher-rank tensor Clifford child into independent equal-width children with
the same direction. This holds for every invertible linear basis, including
nonmonomial bases, and for arbitrary dirty padding that must be restored.

**Status note:** production multicold `clifford_exact.py` now ships gate-table
`zero_state` (`research/clifford-state-production/`). This package keeps the
pairwise-era digest as provenance only and drops that path from VERIFY inputs;
`dense.py` still loads the working oracle for native column cross-checks.

The direction premise is essential: two opposite-direction width-f lanes are
similar to a phase times a width-(f+1) tensor child exactly when f is odd. We
give actual rational encoding/decoding matrices. Even with those conversions
Expand All @@ -20,8 +25,10 @@ Work over any characteristic-zero field K containing i, with i²=-1. Let
`C = ((1+i)I + (1-i)X)/2`, `X = [[0,1],[1,0]]`, and `C_f = C^⊗f`.

Thus C has eigenvalues 1 and i, C²=X and C⁴=I. An inverse child is C_f⁻¹.
The source kernel in [SOURCES.json](SOURCES.json) implements this convention;
the dense checker compares its complete matrices in both directions.
The multicold `clifford_exact.py` oracle implements this convention; after
`research/clifford-state-production/` it is provenance in [SOURCES.json](SOURCES.json)
(not a live VERIFY pin). The dense checker still loads the working oracle and
compares its complete matrices in both directions.

For integers f,h,q,t≥1 and d≥0, the desired full-space map is

Expand Down
5 changes: 3 additions & 2 deletions research/clifford-reciprocal-basis-obstruction/SOURCES.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
},
{
"path": "research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py",
"usage": "input",
"usage": "provenance",
"git_blob": "166841a037f069249f6f7f6dedb89248812f59e2",
"sha256": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962"
"sha256": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962",
"note": "Pairwise-era digest at this package base_commit. After research/clifford-state-production/, working multicold clifford_exact.py ships gate-table zero_state; dense.py still loads the working oracle for native column cross-checks, but the path is not a live VERIFY pin."
},
{
"path": "research/selector-batching/README.md",
Expand Down
1 change: 0 additions & 1 deletion research/clifford-reciprocal-basis-obstruction/VERIFY.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"python": "3.12",
"requirements": [],
"inputs": [
"research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py",
"research/selector-batching/README.md"
],
"commands": [
Expand Down
19 changes: 14 additions & 5 deletions research/clifford-reciprocal-basis-obstruction/test_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,24 @@
class VerificationTests(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.scratch = V.ROOT.parent / 'contribution1319-test-temp'
cls.scratch.mkdir(exist_ok=True)
# Prefer a sibling of the repo (historical layout); fall back to /tmp when
# that parent is not writable (common in containerized checkouts).
preferred = V.ROOT.parent / 'contribution1319-test-temp'
try:
preferred.mkdir(exist_ok=True)
cls.scratch = preferred
except OSError:
cls.scratch = Path(tempfile.gettempdir()) / 'contribution1319-test-temp'
cls.scratch.mkdir(exist_ok=True)

def export(self, directory):
root = Path(directory) / 'export'
package = root / 'research' / V.PKG.name
package.mkdir(parents=True)
for name in ('verify.py','dense.py','SOURCES.json','CERTIFICATE.json','DENSE.json'):
shutil.copy2(V.PKG / name, package / name)
for name in V.INPUTS:
# Live inventory pins plus the demoted runtime oracle used by dense.py.
for name in sorted(V.INPUTS | {V.KERNEL}):
dest = root / name
dest.parent.mkdir(parents=True, exist_ok=True)
shutil.copy2(V.ROOT / name, dest)
Expand Down Expand Up @@ -73,9 +81,10 @@ def test_invalid_integer_domains_and_duplicate_json(self):
json.loads('{"a":1,"a":2}',object_pairs_hook=V.unique_object)

def test_source_and_inventory_corruption_reject_both_engines(self):
live = sorted(V.INPUTS)[0]
with tempfile.TemporaryDirectory(dir=self.scratch) as directory:
root, package = self.export(directory)
source = root / V.KERNEL
source = root / live
original = source.read_bytes()
source.write_bytes(original+b'\n# source drift\n')
for script in ('verify.py','dense.py'):
Expand All @@ -84,7 +93,7 @@ def test_source_and_inventory_corruption_reject_both_engines(self):
self.assertIn('source SHA256 mismatch',result.stdout+result.stderr)
source.write_bytes(original)
manifest = V.read_json(package / 'SOURCES.json')
manifest['files'] = [r for r in manifest['files'] if r['path'] != V.KERNEL]
manifest['files'] = [r for r in manifest['files'] if r['path'] != live]
(package / 'SOURCES.json').write_text(json.dumps(manifest),encoding='utf-8')
for script in ('verify.py','dense.py'):
result = self.run_cli(root,script)
Expand Down
4 changes: 3 additions & 1 deletion research/clifford-reciprocal-basis-obstruction/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@

PKG = Path(__file__).resolve().parent
ROOT = PKG.parents[1]
# Runtime native oracle for dense.py; demoted from live SOURCES/VERIFY pins after
# research/clifford-state-production/ rewrote the working multicold evaluator.
KERNEL = 'research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py'
INPUTS = {KERNEL, 'research/selector-batching/README.md'}
INPUTS = {'research/selector-batching/README.md'}


def require(ok, message):
Expand Down
8 changes: 7 additions & 1 deletion research/clifford-state-performance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ This optional adapter accelerates the complete selected helper-interface check b
Seven alternating pairs give median times of **1.289 seconds** and **0.460 seconds**.
Every output receipt matches the original byte for byte.

After `research/clifford-state-production/`, the multicold production
`clifford_exact.py` ships the same gate-table `zero_state`. This package vendors
the pairwise-era bytes as `baseline.py` and pins production separately so
opt-in differential replay does not fail working-source drift.

The change affects verification speed only.
The selected conditional bound remains `51110230636731/31250000000000000`.
No frozen source, selected certificate, circuit, or default verification command changes.
No selected certificate, circuit, or default verification command changes beyond
the production evaluator wiring above.

## Reproduce

Expand Down
10 changes: 8 additions & 2 deletions research/clifford-state-performance/SOURCE.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{
"base_commit": "66849e1475c930fd7732b1a0067ffee7e1e95f60",
"clifford": "research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py",
"clifford": "research/clifford-state-performance/baseline.py",
"production_clifford": "research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py",
"checker": "scripts/verify_cold617_interface.py",
"runs": [
"research/community-k492-audit/pr622/replay/ck-local",
"research/community-k492-audit/pr622/replay/jp8-local"
],
"files": {
"research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962",
"research/clifford-state-performance/baseline.py": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962",
"research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py": "9b360d58055de706a27abe5211a14115225e47f0c6096e4fb8818e99a4772abd",
"scripts/verify_cold617_interface.py": "95d7a9094c05ad975fb72f5ab7605593003245a503c8456764987e512028fa6a",
"scripts/verify_hpe_lean_binding.py": "52aa1d23641e4c716b43c98f6b883ad042087dd03a9d01369e8e6a735b07aa03",
"research/hyperplane-end-lean/HyperplaneEnd/Exact.lean": "eebf3a3982af7ab9be45777b272a6aaa523206fa7667ceb6df63ad6589fd8183",
Expand All @@ -17,5 +19,9 @@
"research/community-k492-audit/pr622/replay/jp8-local/CANONICAL-WORD.json.gz": "7a3fec1022d3b2b1bd986302a327735ec521d17b043f4a5acb96253a56f6193c",
"research/community-k492-audit/pr622/replay/jp8-local/RESIDUAL-ADAPTERS.json": "bdb44cf523636f307ebb3617da548f2e3a8af74321eabe24aef40186e280a917"
},
"provenance_sha256": {
"research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py@pre-production": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962"
},
"note": "After research/clifford-state-production/, working multicold clifford_exact.py is the gate-table production source. baseline.py vendors the pairwise-era bytes; the opt-in adapter compares baseline vs fast_state / production without re-transforming production.",
"expected_receipt_sha256": "8e775e5927b2f05c1671902680e25995adba6a2d2236f5dc116683b18ac4a42c"
}
149 changes: 149 additions & 0 deletions research/clifford-state-performance/baseline.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
"""Small exact Gaussian-dyadic Clifford compiler, independent of gx internals.
Paulis use i^p X^x Z^z. State vectors use integer Gaussian numerators / 2^d.
The tableau is supplemented by a literal circuit, so global phases are kept.
"""
from dataclasses import dataclass

def parity(x):return x.bit_count()&1
def rank(rows):
p={}
for x in rows:
while x:
b=x.bit_length()-1
if b not in p:p[b]=x;break
x^=p[b]
return len(p)
def transpose(rows,n):return tuple(sum(((rows[j]>>i)&1)<<j for j in range(n)) for i in range(n))
def mv(rows,x):return sum(parity(r&x)<<i for i,r in enumerate(rows))
def inv(rows,n):
a=[r|(1<<(n+i)) for i,r in enumerate(rows)]
for j in range(n):
k=next(i for i in range(j,n) if a[i]>>j&1);a[j],a[k]=a[k],a[j]
for i in range(n):
if i!=j and a[i]>>j&1:a[i]^=a[j]
assert [r&((1<<n)-1) for r in a]==[1<<i for i in range(n)]
return tuple(r>>n for r in a)
def basis_extend(cols,n):
out=[]
for x in list(cols)+[1<<i for i in range(n)]:
if rank(out+[x])>len(out):out.append(x)
assert len(out)==n
return tuple(out)
def nullspace(rows,n):
a=list(rows);p=[];k=0
for j in range(n):
t=next((i for i in range(k,len(a)) if a[i]>>j&1),None)
if t is None:continue
a[t],a[k]=a[k],a[t]
for i in range(len(a)):
if i!=k and a[i]>>j&1:a[i]^=a[k]
p.append(j);k+=1
return tuple((1<<j)|sum(((a[i]>>j)&1)<<v for i,v in enumerate(p)) for j in range(n) if j not in p)
def pmul(a,b):
x,z,p=a;y,w,q=b
return x^y,z^w,(p+q+2*parity(z&y))%4
def identity(n):return tuple([(1<<i,0,0) for i in range(n)]+[(0,1<<i,0) for i in range(n)])
def apply(T,p):
n=len(T)//2;x,z,ph=p;out=(0,0,ph)
for i in range(n):
if x>>i&1:out=pmul(out,T[i])
for i in range(n):
if z>>i&1:out=pmul(out,T[n+i])
return out
def compose(A,B):return tuple(apply(A,p) for p in B)
def inverse(T):
n=len(T)//2;cols=[x|(z<<n) for x,z,p in T];rows=transpose(cols,2*n);cols_inv=transpose(inv(rows,2*n),2*n);out=[]
for j,w in enumerate(cols_inv):
x=w&((1<<n)-1);z=w>>n;u,v,p=apply(T,(x,z,0));assert (u,v)==identity(n)[j][:2];out.append((x,z,(-p)%4))
return tuple(out)
def qvalue(Q,alpha,x,n):
return (sum(alpha[i] for i in range(n) if x>>i&1)+2*sum(parity((Q[i]>>(i+1))&(x>>(i+1))) for i in range(n) if x>>i&1))%4
def mul_i(a,p):
x,y=a;p%=4
return [(x,y),(-y,x),(-x,-y),(y,-x)][p]
@dataclass
class Op:
n:int
tab:tuple
circuit:list
def then(self,b):
assert self.n==b.n
return Op(self.n,compose(b.tab,self.tab),self.circuit+b.circuit)
def adjoint(self):
circ=[]
for e in reversed(self.circuit):
if e[0]=='P':circ.append(('P',inv(e[1],self.n)))
elif e[0]=='D':circ.append(('D',e[1],tuple((-x)%4 for x in e[2])))
elif e[0]=='C':circ.append(('C',e[1],-e[2]))
elif e[0]=='phase':circ.append(('phase',(-e[1])%4))
else:circ.append(e)
return Op(self.n,inverse(self.tab),circ)
def zero_state(self,basis=0):
N=1<<self.n;vec=[(0,0)]*N;vec[basis]=(1,0);den=0
for e in self.circuit:
if e[0]=='P':
v=[(0,0)]*N
for x,a in enumerate(vec):v[mv(e[1],x)]=a
vec=v
elif e[0]=='X':vec=[vec[x^e[1]] for x in range(N)]
elif e[0]=='D':vec=[mul_i(a,qvalue(e[1],e[2],x,self.n)) for x,a in enumerate(vec)]
elif e[0]=='phase':vec=[mul_i(a,e[1]) for a in vec]
elif e[0]=='C':
q,sgn=e[1:];v=[]
for x,(a,b) in enumerate(vec):
c,d=vec[x^q]
# C=(1+i)I/2+(1-i)X/2; inverse conjugates both coefficients.
v.append((a-sgn*b+c+sgn*d,b+sgn*a+d-sgn*c))
vec=v;den+=1
else:raise AssertionError(e)
while den and all((a&1)==(b&1)==0 for a,b in vec):vec=[(a//2,b//2) for a,b in vec];den-=1
return vec,den
def ident(n):return Op(n,identity(n),[])
def perm(n,G):
cols=transpose(G,n);gi=inv(G,n)
return Op(n,tuple([(a,0,0) for a in cols]+[(0,a,0) for a in gi]),[('P',tuple(G))])
def diag(n,Q,alpha=None):
Q=tuple(Q);assert transpose(Q,n)==Q
alpha=tuple(alpha) if alpha is not None else tuple((Q[i]>>i)&1 for i in range(n))
assert all(alpha[i]%2==(Q[i]>>i)&1 for i in range(n))
return Op(n,tuple([(1<<i,Q[i],alpha[i]) for i in range(n)]+[(0,1<<i,0) for i in range(n)]),[('D',Q,alpha)])
def cgate(n,q,sgn=1):
return Op(n,tuple([(1<<i,0,0) for i in range(n)]+[(q if q>>i&1 else 0,1<<i,(3*sgn)%4 if q>>i&1 else 0) for i in range(n)]),[('C',q,sgn)])
def xgate(n,b):return Op(n,tuple([(1<<i,0,0) for i in range(n)]+[(0,1<<i,2*((b>>i)&1)) for i in range(n)]),[('X',b)])
def fourier(n,axes=None):
out=ident(n)
for i in range(n) if axes is None else axes:out=out.then(cgate(n,1<<i))
return out
def hadamard(n,axes):
axes=list(axes);Q=tuple(1<<i if i in axes else 0 for i in range(n));S=diag(n,Q)
return S.then(fourier(n,axes)).then(S)
def canonical_frame(n,U):
r=len(U)
if r==0:return ident(n)
if r==n:return fourier(n)
G=transpose(basis_extend(U,n),n);gi=inv(G,n);Q=tuple((1<<i)^sum(parity(gi_i&gi_j)<<j for j,gi_j in enumerate(transpose(gi,n))) for i,gi_i in enumerate(transpose(gi,n)))
K=perm(n,G).then(diag(n,Q))
return K.adjoint().then(fourier(n,range(r))).then(K)
def monomial(op):
n=op.n;T=op.tab;assert all(x==0 and p%2==0 for x,z,p in T[n:]);G=transpose([x for x,z,p in T[:n]],n);b=mv(G,sum((p//2)<<i for i,(x,z,p) in enumerate(T[n:])))
gt=transpose(G,n);cols=[mv(gt,z) for x,z,p in T[:n]];Q=transpose(cols,n);alpha=[(p-2*parity(b&z))%4 for x,z,p in T[:n]]
out=diag(n,Q,alpha).then(perm(n,G)).then(xgate(n,b));assert out.tab==T
vec,den=op.zero_state();assert den==0 and all(a==(0,0) for i,a in enumerate(vec) if i!=b);phase=[(1,0),(0,1),(-1,0),(0,-1)].index(vec[b]);out=out.then(Op(n,identity(n),[('phase',phase)]));assert out.zero_state()==op.zero_state()
return out,dict(matrix_rows=G,offset=b,quadratic_rows=Q,linear_Z4=alpha,phase=phase)
def lower_child(op):
n=op.n;Bcols=[x for x,z,p in op.tab[n:]];r=rank(Bcols)
if not r:
mon,rec=monomial(op);return dict(rank=0,left=rec,right=None),mon
G=transpose(basis_extend(Bcols,n),n);A=inv(G,n);PA=perm(n,A);part=op.then(PA);Bcols=[x for x,z,p in part.tab[n:]];Dcols=[z for x,z,p in part.tab[n:]]
picks=[];selected=[]
for j,x in enumerate(Bcols):
if rank(selected+[x])>len(selected):picks.append(j);selected.append(x)
assert len(picks)==r and all(x>>r==0 for x in Bcols)
Br=transpose(selected,r);Bi=inv(Br,r);Dr=transpose([Dcols[j]&((1<<r)-1) for j in picks],r)
Qsmall=tuple(sum(parity(row&col)<<j for j,col in enumerate(transpose(Bi,r))) for row in Dr);Q=Qsmall+(0,)*(n-r);DQ=diag(n,Q)
V=part.then(DQ).then(hadamard(n,range(r)));assert all(x==0 for x,z,p in V.tab[n:]);Vmon,Vrec=monomial(V)
S=diag(n,tuple(1<<i if i<r else 0 for i in range(n)))
left=S.adjoint().then(DQ.adjoint()).then(PA.adjoint());right=Vmon.then(S.adjoint()).then(xgate(n,(1<<r)-1))
lmon,lrec=monomial(left);rmon,rrec=monomial(right);compiled=rmon.then(fourier(n,range(r))).then(lmon)
assert compiled.tab==op.tab and compiled.zero_state()==op.zero_state()
return dict(rank=r,left=lrec,right=rrec),compiled
10 changes: 8 additions & 2 deletions research/clifford-state-performance/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ def verify_sources(root=ROOT):
raise ValueError('Pinned source changed: ' + relative)


def load_clifford():
path = ROOT / SOURCE['clifford']
def load_clifford(which='baseline'):
"""Load the pairwise baseline (default) or the production multicold evaluator.

Registers the module as ``clifford_exact`` so the helper-interface adapters
reuse this object instead of re-importing the on-disk multicold file.
"""
key = 'clifford' if which == 'baseline' else 'production_clifford'
path = ROOT / SOURCE[key]
spec = importlib.util.spec_from_file_location('clifford_exact', path)
module = importlib.util.module_from_spec(spec)
sys.modules[spec.name] = module
Expand Down
4 changes: 3 additions & 1 deletion research/clifford-state-performance/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ def main():
verify_sources()
if args.out.exists():
raise ValueError('Use a fresh output file')
clifford = load_clifford()
# reference/fast still use vendored pairwise baseline bytes; fast monkeypatches
# zero_state. Production multicold clifford_exact.py is pinned separately.
clifford = load_clifford('baseline')
if args.engine == 'fast':
fast_state.clear_caches()
clifford.Op.zero_state = fast_state.zero_state
Expand Down
17 changes: 17 additions & 0 deletions research/clifford-state-production/NOTICE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Notice

Production wiring of the exact Clifford gate-table evaluator into the
multicold `clifford_exact.py` used by `scripts/verify_cold617_interface.py`.

## Credit

- Charles Bethin / [CrocSwap/integer-mult-bounds#662](https://github.com/CrocSwap/integer-mult-bounds/pull/662)
(`research/clifford-state-performance/`): proved opt-in exact gate tables with
identical helper-interface receipts.
- icekylinx / eumemic / PR531–PR558 Clifford compiler lineage for
`clifford_exact.py`.
- Jeremy Kothe / PR622 archived native fixtures used by the helper-interface
checker.

Prepared by Wentao Li (VictorLiwentao, @Is__Victor, wentaol4@illinois.edu)
with substantial AI assistance. Apache-2.0.
Loading