research: preserve solver experiments and reproducible benchmarks

This commit is contained in:
Yaossg 2026-10-11 12:28:02 +08:00
parent 12e4266950
commit e93bc20b0a
85 changed files with 518443 additions and 0 deletions

View file

@ -0,0 +1,28 @@
#!/usr/bin/env python3
import json,subprocess,random,hashlib
from pathlib import Path
H=Path(__file__).resolve().parent
OLD=H.parent/'full_search_feasibility'
POS=H/'pipeline_positions';OUT=H/'pipeline_results'
rows=[json.loads(l) for l in (OLD/'results/random4096.jsonl').read_text().splitlines()]
counts=next(r['counts'] for r in rows if r['type']=='root_counts')
points=[tuple(map(int,l.split())) for l in (OLD/'positions/random4096.txt').read_text().splitlines()]
x,z=points[counts.index(0)]
zero=[(xx,zz) for xx in range(-1875000+(x+1875000)%65536,1875000,65536) for zz in range(-1875000+(z+1875000)%131072,1875000,131072)]
p=POS/'zero_lifts.txt';p.write_text(''.join(f'{x} {z}\n' for x,z in zero))
shuffled=(POS/'mixed512.txt').read_text().splitlines();random.Random(2026101106).shuffle(shuffled)
q=POS/'shuffled_mixed.txt';q.write_text('\n'.join(shuffled)+'\n')
subprocess.run(['nvcc','-O3','-std=c++17','-arch=sm_86',str(H/'pipeline_bench.cu'),'-o','/tmp/slime_pipeline_cuda'],check=True)
checks={}
for name,path in [('zero_lifts',p),('stress',OLD/'positions/stress.txt'),('shuffled_mixed',q)]:
r=subprocess.run(['/tmp/slime_pipeline_cuda',str(path),'1'],capture_output=True,text=True,timeout=120)
(OUT/(name+'.jsonl')).write_text(r.stdout);(OUT/(name+'.stderr')).write_text(r.stderr)
if r.returncode:raise RuntimeError(r.stderr)
rows=[json.loads(l) for l in r.stdout.splitlines()]
checks[name]={'validation':next(r for r in rows if r['type']=='validation'),'modes':[r for r in rows if r['type']=='pipeline']}
if name=='zero_lifts':assert all(r['jobs']==0 and r['matches']==0 for r in checks[name]['modes'])
if name=='stress':assert len(checks[name]['validation']['matches'])==24
print(name,'passed',flush=True)
checks['source_sha256']={n:hashlib.sha256((H/n).read_bytes()).hexdigest() for n in ['pipeline_bench.cu','cuda_bench.cu','grouped.hpp','verify_pipeline_edges.py']}
checks['shared_headers_sha256']={name:hashlib.sha256((H.parents[2]/'include'/'slime'/name).read_bytes()).hexdigest() for name in ['solver_core.hpp','upper_interval.hpp']}
(OUT/'edge_validation.json').write_text(json.dumps(checks,indent=2))