junidude14 commited on
Commit
d75e6bf
·
verified ·
1 Parent(s): 4a0c86c

Archive 4 checkpoints (1-4)

Browse files
paper-releases/pbisc-diffusion/updates/20261015T121654Z-x1-nine-core40-deck/diffusion/dataset/server_1/model8/plans/paper_figures_strictpairs_20261012/recoveries/x1_priority_completion_20261015/deck_refresh.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Refresh complete master from admitted results, atomically update user aliases, archive final evidence."""
2
+ from pathlib import Path
3
+ import os,sys,json,time,subprocess,hashlib,shutil,datetime
4
+ R=Path(__file__).resolve().parent;S=R.parents[1];M=S.parents[1];E=R/'evaluation';D=M/'presentations/2026-09-30--paper-summary--r00';A=D/'data/x1_priority_20261015';X=M/'plans/f01_trunk4x_complete_20261013'
5
+ sys.path.insert(0,str(S/'tools'));from runtime import Runtime,atomic_json,stamp,sha256
6
+ PY='/home/sj_server_1/miniforge3/bin/python';CPU='/home/sj_server_1/miniforge3/envs/cxg_corpus/bin/python'
7
+ def refresh():
8
+ available=next(int(v.split()[1])/1048576 for v in Path('/proc/meminfo').read_text().splitlines() if v.startswith('MemAvailable:'))
9
+ if available<96:return False
10
+ rt=Runtime(R/'deck_runtime');rt.preflight('cpu',8)
11
+ cmd=rt.wrapped_command('refresh-x1-master',[PY,str(D/'tools/build_x1_priority_master_20261015.py'),'--if-changed'],'cpu',8,2)
12
+ with (R/'deck_refresh.log').open('a') as f:subprocess.run(cmd,stdout=f,stderr=subprocess.STDOUT,check=True)
13
+ v=json.loads((A/'VERIFIED.json').read_text());assert v['status'] in ['verified','automated_pass_visual_pending']
14
+ qa=json.loads(Path(v['verification']).read_text());assert not qa['failures'] and not qa['source_rejections'] and qa['parent156_preserved'] and qa['original76_preserved'] and qa['Figure1_parent_pages7to10_preserved'],qa
15
+ for src,digest in v['outputs'].items():
16
+ src=Path(src);assert sha256(src)==digest
17
+ target=D/('PBISC-Diffusion_expanded_master_20261015_figure1_focused'+src.suffix)
18
+ if target.exists() and sha256(target)==digest:continue
19
+ temporary=target.with_suffix(target.suffix+'.x1update');shutil.copy2(src,temporary);assert sha256(temporary)==digest;temporary.replace(target)
20
+ record={'at':stamp(),'build':v['build'],'slides':v['slides'],'verified_output_hashes':v['outputs'],'current_user_pptx':str(D/'PBISC-Diffusion_expanded_master_20261015_figure1_focused.pptx'),'current_user_pdf':str(D/'PBISC-Diffusion_expanded_master_20261015_figure1_focused.pdf'),'original156_preserved':str(A/'base/BASE_VERIFIED.json'),'qa_status':v['status'],'scope':'Completed core and full statistics are distinct; incomplete arms remain explicit.'}
21
+ atomic_json(R/'DECK_CURRENT.json',record);atomic_json(D/'CURRENT_MASTER.json',record)
22
+ return True
23
+
24
+ def archive_final():
25
+ release=M.parents[1]/'paper-release-20260928';assets=[];seen=set();locations=[]
26
+ def add(f,kind):
27
+ if str(f) not in seen:assets.append({'host':'server_1','source':str(f),'kind':kind,'state':'completed'});seen.add(str(f))
28
+ for unit in json.loads((R/'GPU_UNITS.json').read_text()):
29
+ from two_host_resume import unit_support
30
+ _,rel,_=unit_support(S,unit)
31
+ add(S/'runs'/rel/'lora/checkpoint_ft.pt','checkpoint');add(S/'runs'/rel/'lora/RUN.json','report')
32
+ for name in ['lora','pairedcal']:
33
+ f=S/'generated'/rel/f'{name}.npz';rec=json.loads(f.with_suffix('.log').read_text());locations.append({'host':'server_1','path':str(f),'state':'completed','receipt':str(f.with_suffix('.log')),'sha256':rec['output_sha256'],'reason':'Exactly requested x1missing9; newonlyafterzeroexactreuseaudit; server2mirrorverified.'})
34
+ status=json.loads((E/'STATUS.json').read_text());atomic_json(R/'FINAL_EVALUATION_SNAPSHOT.json',status);add(R/'FINAL_EVALUATION_SNAPSHOT.json','report')
35
+ for folder in [E/'units',E/'aggregates']:
36
+ for f in folder.rglob('*'):
37
+ if f.is_file() and f.suffix in ['.json','.csv'] and f.stat().st_size<4*2**20:add(f,'table' if f.suffix=='.csv' else 'report')
38
+ v=json.loads((A/'VERIFIED.json').read_text());build=Path(v['build'])
39
+ for f in build.rglob('*'):
40
+ if f.is_file() and f.suffix in ['.pptx','.pdf','.png','.svg','.csv','.json'] and ('qa' not in f.parts or f.name in ['VERIFICATION.json','visual_review.json']):add(f,'figure' if f.suffix in ['.pptx','.pdf','.png','.svg'] else 'report')
41
+ for n in ['GPU_STATUS.json','X4_PAUSE.json','X4_RESUMED.json','MIRROR_VERIFIED.json','DECK_CURRENT.json']:
42
+ if (R/n).exists():
43
+ f=R/'final_records'/n;f.parent.mkdir(exist_ok=True);shutil.copy2(R/n,f);add(f,'report')
44
+ ident=datetime.datetime.now(datetime.timezone.utc).strftime('%Y%m%dT%H%M%SZ')+'-x1-priority-full-deck';request=R/'FINAL_ARCHIVE_REQUEST.json';atomic_json(request,{'project_id':'pbisc-diffusion','summary':'Requestedx1missing9 completed withoutduplicates; fullCPUevaluation ofavailablearms and complete master updated preserving156parents. MissingnewscSemi arms explicit.','assets':assets,'inference_locations':locations})
45
+ with (R/'final_archive.log').open('x') as log:
46
+ for args in [['prepare','--request',str(request),'--id',ident],['publish',ident,'--execute']]:subprocess.run([PY,str(release/'maintenance/update.py'),*args],stdout=log,stderr=subprocess.STDOUT,check=True)
47
+ receipt=release/'maintenance/updates'/ident/'UPDATE_VERIFIED.json';assert json.loads(receipt.read_text())['status']=='PASS';atomic_json(R/'FINAL_ARCHIVE_VERIFIED.json',{'id':ident,'receipt':str(receipt),'sha256':sha256(receipt)})
48
+
49
+ def main():
50
+ last=None;last_time=0
51
+ while True:
52
+ if (E/'ERROR.json').exists():raise RuntimeError((E/'ERROR.json').read_text())
53
+ if not (E/'STATUS.json').exists():time.sleep(30);continue
54
+ j=json.loads((E/'STATUS.json').read_text());states=[(u['unit'],a,v['state']) for u in j['units'] for a,v in u['arms'].items()]
55
+ fingerprint=hashlib.sha256(json.dumps(states,sort_keys=True).encode()).hexdigest()
56
+ workers=[E/f'WORKER_{i}.json' for i in [0,1]];done=all(f.exists() and json.loads(f.read_text())['phase']=='assigned_ready_arms_completed' for f in workers)
57
+ gpu=(R/'GPU_STATUS.json').exists() and json.loads((R/'GPU_STATUS.json').read_text())['phase']=='all_nine_diffusion_completed'
58
+ if fingerprint!=last and (last is None or time.monotonic()-last_time>900 or done):
59
+ if refresh():last=fingerprint;last_time=time.monotonic()
60
+ if done and gpu and (R/'MIRROR_VERIFIED.json').exists():
61
+ rt=Runtime(R/'deck_runtime');rt.preflight('cpu',4)
62
+ with (R/'aggregate.log').open('a') as log:subprocess.run(rt.wrapped_command('final-x1-aggregate',[CPU,str(E/'aggregate.py')],'cpu',4,2),stdout=log,stderr=subprocess.STDOUT,check=True)
63
+ if not refresh():time.sleep(60);continue
64
+ archive_final();atomic_json(R/'FINAL_STATUS.json',{'phase':'completed_available_evidence_deck_archived','at':stamp(),'x1_full_units':j['x1_full_units'],'missing_scsemi':j['missing_scsemi'],'deck':str(R/'DECK_CURRENT.json')});return
65
+ atomic_json(R/'DECK_STATUS.json',{'phase':'watching_completed_evidence','at':stamp(),'x1_full_units':j['x1_full_units'],'last_render_fingerprint':last,'missing_scsemi':j['missing_scsemi']})
66
+ time.sleep(60)
67
+ if __name__=='__main__':
68
+ try:main()
69
+ except BaseException as e:atomic_json(R/'DECK_STATUS.json',{'phase':'stopped_needs_inspection','at':stamp(),'error':str(e)});raise
paper-releases/pbisc-diffusion/updates/20261015T121654Z-x1-nine-core40-deck/diffusion/dataset/server_1/model8/plans/paper_figures_strictpairs_20261012/recoveries/x1_priority_completion_20261015/evaluation/test_readiness.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import hashlib
2
+ import json
3
+ from pathlib import Path
4
+ import tempfile
5
+ import unittest
6
+ from readiness import generation_readiness
7
+
8
+
9
+ class ReadinessTests(unittest.TestCase):
10
+ def setUp(self):
11
+ self.temp = tempfile.TemporaryDirectory()
12
+ self.plan = Path(self.temp.name)
13
+ self.rel = Path("immicro/healthy/fold0/n20")
14
+ self.folder = self.plan / "generated" / self.rel
15
+ self.folder.mkdir(parents=True)
16
+ (self.plan / "receipts").mkdir()
17
+ self.receipt = self.plan / "receipts/immicro-healthy-fold0-n20-lora.json"
18
+ self.npz, self.log = self.folder / "lora.npz", self.folder / "lora.log"
19
+
20
+ def tearDown(self):
21
+ self.temp.cleanup()
22
+
23
+ def gate(self):
24
+ return generation_readiness(self.plan, self.rel, "lora")
25
+
26
+ def completed(self):
27
+ self.npz.write_bytes(b"existing output fixture")
28
+ digest = hashlib.sha256(self.npz.read_bytes()).hexdigest()
29
+ self.log.write_text(json.dumps({"output": str(self.npz), "output_sha256": digest}))
30
+ outputs = [{"path": str(p), "bytes": p.stat().st_size, "sha256": hashlib.sha256(p.read_bytes()).hexdigest()}
31
+ for p in (self.npz, self.log)]
32
+ self.receipt.write_text(json.dumps({"state": "completed", "outputs": outputs}))
33
+
34
+ def test_inflight_empty_sampler_waits(self):
35
+ self.npz.write_bytes(b"partially written")
36
+ self.log.write_text("")
37
+ self.receipt.write_text(json.dumps({"state": "running"}))
38
+ self.assertFalse(self.gate()["ready"])
39
+ self.assertEqual(self.gate()["state"], "waiting_generation")
40
+
41
+ def test_completed_receipt_passes(self):
42
+ self.completed()
43
+ self.assertTrue(self.gate()["ready"])
44
+
45
+ def test_failed_operation_never_admitted(self):
46
+ self.completed()
47
+ operation = json.loads(self.receipt.read_text())
48
+ operation["state"] = "failed"
49
+ self.receipt.write_text(json.dumps(operation))
50
+ self.assertFalse(self.gate()["ready"])
51
+ self.assertEqual(self.gate()["state"], "generation_failed_needs_inspection")
52
+
53
+ def test_missing_operation_never_admitted(self):
54
+ self.completed()
55
+ self.receipt.unlink()
56
+ self.assertFalse(self.gate()["ready"])
57
+
58
+ def test_completed_but_truncated_sampler_never_admitted(self):
59
+ self.completed()
60
+ self.log.write_text("")
61
+ self.assertFalse(self.gate()["ready"])
62
+
63
+
64
+ if __name__ == "__main__":
65
+ unittest.main()
paper-releases/pbisc-diffusion/updates/20261015T121654Z-x1-nine-core40-deck/diffusion/dataset/server_1/model8/plans/paper_figures_strictpairs_20261012/recoveries/x1_priority_completion_20261015/followup.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Durable CPU scheduling/mirroring and restore the pre-existing scSemi queue without duplicates."""
2
+ from pathlib import Path
3
+ import json,sys,subprocess,time,shlex
4
+ R=Path(__file__).resolve().parent;S=R.parents[1];M=S.parents[1];E=R/'evaluation';X=M/'plans/f01_trunk4x_complete_20261013'
5
+ sys.path.insert(0,str(S/'tools'));from runtime import atomic_json,stamp
6
+ PY='/home/sj_server_1/miniforge3/envs/cxg_corpus/bin/python'
7
+ def state(phase,**kw):atomic_json(R/'FOLLOWUP_STATUS.json',{'phase':phase,'at':stamp(),**kw})
8
+ def launch_worker1():
9
+ unit='pbisc-x1-full-cpu1-20261015'
10
+ subprocess.run(['systemd-run','--user',f'--unit={unit}','--slice=app.slice','-p','MemoryMax=4G','-p','MemorySwapMax=0','-p','OOMPolicy=kill','-p','OOMScoreAdjust=500','-p','Restart=no','-p',f'StandardOutput=append:{E}/worker1.log','-p','StandardError=inherit','/usr/bin/env','CUDA_VISIBLE_DEVICES=','PYTHONDONTWRITEBYTECODE=1','OMP_NUM_THREADS=2','OPENBLAS_NUM_THREADS=2',PY,'-u',str(E/'cpu_queue.py'),'--run','--prepare-caches','--workers','2','--worker-index','1','--memory-gib','16'],check=True)
11
+ atomic_json(R/'CPU1_LAUNCHED.json',{'unit':unit,'at':stamp(),'memory_policy':'Only after16GiB core worker exited; full16+full16+x4score32 <=64GiB CPU caps'})
12
+ def resume_scsemi():
13
+ assert (R/'mirror/MIRROR_VERIFIED.json').exists() or (R/'MIRROR_VERIFIED.json').exists()
14
+ old=S/'recoveries/priority_server2_20261014';unit='pbisc-strict-priority-remote-v2-20261015'
15
+ args=['/usr/bin/env','XDG_RUNTIME_DIR=/run/user/1000','DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus','systemd-run','--user',f'--unit={unit}','--slice=app.slice','-p','MemoryMax=2G','-p','MemorySwapMax=0','-p','OOMPolicy=kill','-p','OOMScoreAdjust=500','-p','Restart=no','-p',f'StandardOutput=append:{old}/worker.log','-p','StandardError=inherit','/usr/bin/env','CUDA_VISIBLE_DEVICES=','PYTHONDONTWRITEBYTECODE=1','OMP_NUM_THREADS=1','OPENBLAS_NUM_THREADS=1',f'PBISC_STRICT_EXECUTION_MAP={S}/recoveries/two_host/execution_map_server2.json','/home/sj_server_2/miniforge3/envs/b2sc-infer/bin/python','-u',str(old/'worker.py'),'run','--stage','compute','--unit-list',str(old/'units.json')]
16
+ subprocess.run(['ssh','spark-0110',shlex.join(args)],check=True)
17
+ atomic_json(R/'SCSEMI_CONTINUATION.json',{'unit':unit,'at':stamp(),'policy':'New x1diffusion receipts verifiedskip; remaining scSemi work still yields to x4 until HFcoreverified'})
18
+ def main():
19
+ while True:
20
+ g=json.loads((R/'GPU_STATUS.json').read_text())
21
+ if g['phase']=='stopped_needs_inspection':raise RuntimeError(g.get('error'))
22
+ core=E/'CORE_STATUS.json'
23
+ if core.exists() and json.loads(core.read_text())['phase']=='complete' and not (R/'CPU1_LAUNCHED.json').exists():
24
+ # Completionfile iswrittenjustbeforeexit; waituntilthecorecontrollerhasactuallystopped.
25
+ active=subprocess.run(['systemctl','--user','is-active','--quiet','pbisc-x1-core-cpu-20261015.service']).returncode==0
26
+ if not active:launch_worker1()
27
+ if g['phase']=='all_nine_diffusion_completed' and not (R/'SCSEMI_CONTINUATION.json').exists():
28
+ state('mirroring_completed_x1')
29
+ subprocess.run([PY,str(R/'mirror_diffusion.py')],check=True)
30
+ resume_scsemi()
31
+ hf=X/'HF_CORE_VERIFIED.json';release=X/'payload/priority/LOW_PRIORITY_RELEASE.json'
32
+ if hf.exists() and json.loads(hf.read_text()).get('state')=='verified' and not release.exists():
33
+ atomic_json(release,{'reason':'x4corecomputationandHFbackupverified','receipt':str(hf),'at':stamp()})
34
+ state('watching',x1_gpu_completed=len(g['completed']),cpu1_started=(R/'CPU1_LAUNCHED.json').exists(),scsemi_continuation=(R/'SCSEMI_CONTINUATION.json').exists())
35
+ if (R/'CPU1_LAUNCHED.json').exists() and (R/'SCSEMI_CONTINUATION.json').exists() and release.exists():return
36
+ time.sleep(30)
37
+ if __name__=='__main__':
38
+ try:main()
39
+ except BaseException as e:state('stopped_needs_inspection',error=str(e));raise
paper-releases/pbisc-diffusion/updates/20261015T121654Z-x1-nine-core40-deck/diffusion/dataset/server_1/model8/plans/paper_figures_strictpairs_20261012/recoveries/x1_priority_completion_20261015/transport.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pathlib import Path
2
+ import sys,json,subprocess,shlex,hashlib
3
+ r=json.loads(Path(sys.argv[1]).read_text())
4
+ subprocess.run(r['command'],check=True)
5
+ files=r['outputs']
6
+ code='import pathlib,hashlib,json,sys; print(json.dumps({p:hashlib.file_digest(pathlib.Path(p).open("rb"),"sha256").hexdigest() for p in json.load(sys.stdin)}))'
7
+ hashes=json.loads(subprocess.check_output(['ssh','spark-0110',shlex.join(['python3','-c',code])],input=json.dumps(files).encode()))
8
+ for f,h in hashes.items():
9
+ p=Path(f);p.parent.mkdir(parents=True,exist_ok=True)
10
+ if p.exists():assert hashlib.file_digest(p.open('rb'),'sha256').hexdigest()==h,'Conflicting local result preserved'
11
+ else:subprocess.run(['rsync','-a','--protect-args','spark-0110:'+f,str(p)],check=True)
12
+ assert hashlib.file_digest(p.open('rb'),'sha256').hexdigest()==h
13
+ Path(r['receipt']).write_text(json.dumps({'host':'server_2','sha256':hashes,'state':'verified'},indent=2)+'\n')