Seal Phase4AE same-precision GPU numerical gate and audit limits
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
"""Copy small sealed evidence and compute descriptive cross-precision comparison."""
|
||||
import json
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import sys
|
||||
import numpy as np
|
||||
|
||||
ROOT=Path('/data/digital-drosophila');MODEL=ROOT/'models/male-cns-lif/author-runtime-lab-v1';EXP=ROOT/'experiments/phase4ae-author-runtime'
|
||||
sys.path.insert(0,str(MODEL))
|
||||
from context import save,digest,check
|
||||
sys.path.insert(0,str(ROOT/'models/male-cns-lif/terminal-scope-diagnostic-v1'))
|
||||
from diagnostic import manifest_check
|
||||
check();verification={str(p.relative_to(ROOT)):manifest_check(p,digest) for p in (MODEL,EXP)}
|
||||
assert all(v['pass'] for v in verification.values())
|
||||
registry=ROOT/'registry/phase4ae-author-runtime';registry.mkdir(exist_ok=False);records=[]
|
||||
manifest=json.loads((EXP/'manifest.json').read_text())
|
||||
for p in [EXP/r['path'] for r in manifest['files']]+[EXP/'manifest.json',EXP/'checksums.sha256']:
|
||||
if p.stat().st_size>4*1024**2 or p.suffix not in ('.json','.csv','.md','.sha256'):continue
|
||||
dst=registry/'evidence'/p.relative_to(EXP);dst.parent.mkdir(parents=True,exist_ok=True)
|
||||
with p.open('rb') as src,dst.open('xb') as out:shutil.copyfileobj(src,out)
|
||||
assert digest(dst)==digest(p)
|
||||
records.append(dict(source=str(p.relative_to(ROOT)),copy=str(dst.relative_to(registry)),sha256=digest(p),bytes=p.stat().st_size))
|
||||
save(registry/'evidence-index.json',records);save(registry/'seal-verification.json',verification)
|
||||
cross=[]
|
||||
for case in sorted((EXP/'cases').iterdir()):
|
||||
paths=[EXP/'oracle'/(case.name+'-'+p)/'state.npz' for p in ('float64','float32')]
|
||||
with np.load(paths[0]) as a,np.load(paths[1]) as b:
|
||||
events=bool(np.array_equal(a['step'],b['step']) and np.array_equal(a['neuron_idx'],b['neuron_idx']))
|
||||
first=None
|
||||
if not events:
|
||||
for tick in range(len(a['history'])):
|
||||
if not np.array_equal(a['neuron_idx'][a['step']==tick],b['neuron_idx'][b['step']==tick]):first=tick;break
|
||||
cross.append(dict(case=case.name,event_equal=events,events_float64=len(a['step']),events_float32=len(b['step']),
|
||||
first_event_divergence_step=first,max_vg_abs_volt=float(np.max(np.abs(a['history'][:,:2].astype(np.float64)-b['history'][:,:2].astype(np.float64)))),
|
||||
input_hashes={str(p.relative_to(ROOT)):digest(p) for p in paths}))
|
||||
save(registry/'cross-precision-description.json',dict(cases=cross,
|
||||
meaning='Descriptive only; no changed tolerances, no variant selected by activity. Each GPU arm is validated against its own precision Brian oracle.'))
|
||||
target=ROOT/'docs/progress/phase4ae-author-runtime.md'
|
||||
with (EXP/'REPORT.md').open('rb') as src,target.open('xb') as out:shutil.copyfileobj(src,out)
|
||||
print(json.dumps(dict(copied=len(records),cross_precision_event_differences=[r for r in cross if not r['event_equal']]),ensure_ascii=False))
|
||||
Reference in New Issue
Block a user