junidude14 commited on
Commit
fe5f39d
·
verified ·
1 Parent(s): 41fa329

Archive 4 checkpoints (1-4)

Browse files
paper-releases/pbisc-diffusion/updates/20261014T111854Z-strict-server2-priority/diffusion/dataset/server_1/model8/plans/paper_figures_strictpairs_20261012/recoveries/priority_server2_20261014/collect.py ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Collect completed remote units only, keep original receipts, then CPU-score and archive."""
2
+ from pathlib import Path
3
+ import sys,json,subprocess,shlex,threading,time,fcntl,hashlib,copy,os
4
+ R=Path(__file__).resolve().parent;S=R.parents[1];M=S.parents[1]
5
+ sys.path[:0]=[str(R),str(S/'tools')]
6
+ import campaign
7
+ from worker import LowPriorityRuntime,X
8
+ from runtime import atomic_json,sha256,stat_record,stamp
9
+ from two_host_resume import unit_support,validate_snapshot
10
+ PY='/home/sj_server_2/miniforge3/envs/b2sc-infer/bin/python'
11
+ def remote(argv,**kw):return subprocess.run(['ssh','-o','BatchMode=yes','spark-0110',shlex.join(argv)],check=True,**kw)
12
+ def state(phase,**kw):atomic_json(R/'COLLECT_STATUS.json',{'phase':phase,'at':stamp(),**kw})
13
+ def release_watch():
14
+ while True:
15
+ p=X/'HF_CORE_VERIFIED.json'
16
+ if p.exists() and json.loads(p.read_text()).get('state')=='verified':
17
+ atomic_json(X/'payload/priority/LOW_PRIORITY_RELEASE.json',{'reason':'x4 core computation and HF backup verified','receipt':str(p),'sha256':sha256(p),'at':stamp()});return
18
+ time.sleep(30)
19
+ def collect(unit):
20
+ dest=R/'imported'/unit;dest.mkdir(parents=True,exist_ok=True)
21
+ done=dest/'IMPORTED.json'
22
+ if done.exists():return
23
+ snapshot=json.loads(remote([PY,str(S/'tools/two_host_resume.py'),'snapshot','--unit',unit],capture_output=True,text=True).stdout)
24
+ validate_snapshot(S,unit,snapshot)
25
+ atomic_json(dest/'snapshot.json',snapshot)
26
+ for row in snapshot['files']:
27
+ rel=Path(row['path']);target=dest/rel if rel.parts[0] in ['receipts','unit_status'] else S/rel
28
+ target.parent.mkdir(parents=True,exist_ok=True)
29
+ if target.exists() and sha256(target)!=row['sha256']:
30
+ # Only pre-existing mutable state/logs from the migrated partial unit may advance.
31
+ allowed=unit=='imperial_eskd-disease-draw3' and rel.parts[0] in ['scsemi','logs']
32
+ assert allowed,('unexpected conflicting artifact',target)
33
+ saved=dest/'before_import'/rel;saved.parent.mkdir(parents=True,exist_ok=True)
34
+ if not saved.exists():subprocess.run(['cp','-p',str(target),str(saved)],check=True)
35
+ subprocess.run(['rsync','-a','--protect-args','spark-0110:'+str(S/rel),str(target)],check=True)
36
+ assert target.stat().st_size==row['bytes'] and sha256(target)==row['sha256']
37
+ for raw in (dest/'receipts').glob('*.json'):
38
+ record=json.loads(raw.read_text());assert record['state']=='completed'
39
+ for out in record.get('outputs',[]):
40
+ f=Path(out['path']);assert sha256(f)==out['sha256'];out.update(stat_record(f))
41
+ original=S/'receipts'/raw.name
42
+ if original.exists():
43
+ old=json.loads(original.read_text());assert old['state']=='completed' and old['signature']==record['signature']
44
+ assert [o['sha256'] for o in old.get('outputs',[])]==[o['sha256'] for o in record.get('outputs',[])]
45
+ # Original source receipt remains unchanged; rsync preserved timestamps of immutable outputs.
46
+ for o in old.get('outputs',[]):assert stat_record(Path(o['path']))=={k:o[k] for k in ['path','bytes','mtime_ns']}
47
+ else:
48
+ record['remote_provenance']={'host':'server_2','raw_receipt':str(raw),'sha256':sha256(raw)};atomic_json(original,record)
49
+ atomic_json(done,{'state':'verified','unit':unit,'snapshot_sha256':sha256(dest/'snapshot.json'),'at':stamp()})
50
+ def main():
51
+ threading.Thread(target=release_watch,daemon=True).start()
52
+ units=json.loads((R/'units.json').read_text());rt=LowPriorityRuntime(S)
53
+ with (S/'.campaign.lock').open('a') as lock:
54
+ fcntl.flock(lock,fcntl.LOCK_EX|fcntl.LOCK_NB)
55
+ for unit in units:
56
+ state('waiting_remote',unit=unit)
57
+ while True:
58
+ code='import pathlib,json,sys; p=pathlib.Path(sys.argv[1]); print(p.read_text() if p.exists() else "null")'
59
+ marker=json.loads(remote(['python3','-c',code,str(S/'unit_status'/f'{unit}.json')],capture_output=True,text=True).stdout)
60
+ if marker and marker.get('state')=='completed' and marker.get('stage')=='compute':break
61
+ props=remote(['/usr/bin/env','XDG_RUNTIME_DIR=/run/user/1000','DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus','systemctl','--user','show','pbisc-strict-priority-remote-20261014.service','-p','ActiveState','-p','SubState'],capture_output=True,text=True).stdout
62
+ if 'ActiveState=failed' in props or 'ActiveState=inactive' in props:raise RuntimeError('Remote worker stopped before unit completion: '+props)
63
+ time.sleep(30)
64
+ state('collecting',unit=unit);collect(unit)
65
+ path,_,manifest=unit_support(S,unit)
66
+ state('scoring',unit=unit);campaign.run_score(rt,path)
67
+ atomic_json(S/'unit_status'/f'{unit}.json',{'state':'completed','stage':'all','support_sha256':manifest['sha256'],'at':stamp(),'source':'priority server2 migration'})
68
+ state('unit_completed',unit=unit)
69
+ state('all_18_completed',units=units)
70
+ assets=[];locations=[]
71
+ for unit in units:
72
+ path,rel,_=unit_support(S,unit)
73
+ assets.extend([{'host':'server_1','source':str(path),'kind':'metadata','state':'completed'},
74
+ {'host':'server_1','source':str(S/'runs'/rel/'lora/checkpoint_ft.pt'),'kind':'checkpoint','state':'completed'}])
75
+ for f in (S/'scores'/rel).rglob('*'):
76
+ if f.is_file() and f.suffix in ['.json','.csv'] and f.stat().st_size<4*2**20:
77
+ assets.append({'host':'server_1','source':str(f),'kind':'report' if f.suffix=='.json' else 'table','state':'completed'})
78
+ for f in (S/'generated'/rel).glob('*.npz'):
79
+ locations.append({'host':'server_1','path':str(f),'state':'completed','sha256':sha256(f),'reason':'Completed transferred strict-pair comparator output; source server_2 and imported receipts retained.'})
80
+ request={'project_id':'pbisc-diffusion','summary':'Completed 18 transferred strict-pair comparator units; original Imperial draw3 120 targets reused; x4 priority preserved.','assets':assets,'inference_locations':locations}
81
+ atomic_json(R/'FINAL_ARCHIVE_REQUEST.json',request)
82
+ from datetime import datetime,timezone
83
+ ident=datetime.now(timezone.utc).strftime('%Y%m%dT%H%M%SZ')+'-strict-priority-results'
84
+ release=M.parents[1]/'paper-release-20260928';cli=release/'maintenance/update.py'
85
+ with (R/'final_archive.log').open('x') as log:
86
+ for args in [['prepare','--request',str(R/'FINAL_ARCHIVE_REQUEST.json'),'--id',ident],['publish',ident,'--execute']]:
87
+ subprocess.run(['/home/sj_server_1/miniforge3/bin/python',str(cli),*args],check=True,stdout=log,stderr=subprocess.STDOUT)
88
+ receipt=release/'maintenance/updates'/ident/'UPDATE_VERIFIED.json';assert json.loads(receipt.read_text())['status']=='PASS'
89
+ state('complete_and_archived',units=units,archive_id=ident,receipt=str(receipt))
90
+ if __name__=='__main__':
91
+ try:main()
92
+ except BaseException as e:state('stopped_needs_inspection',error=str(e));raise
paper-releases/pbisc-diffusion/updates/20261014T111854Z-strict-server2-priority/diffusion/dataset/server_1/model8/plans/paper_figures_strictpairs_20261012/recoveries/priority_server2_20261014/probe.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pathlib import Path
2
+ import sys
3
+ R=Path(__file__).resolve().parent;S=R.parents[1];sys.path.insert(0,str(S/'tools'))
4
+ import campaign
5
+ from runtime import Runtime
6
+ from two_host_resume import unit_support
7
+ class Probe(Runtime):
8
+ def execute(self,name,argv,**kw):
9
+ sig=self.signature(argv,kw.get('inputs',[]))
10
+ if self.can_skip(name,sig,kw.get('outputs',[])):print('VERIFIED_REUSE',name,flush=True);return False
11
+ print('NEXT_OPERATION',name,flush=True)
12
+ assert name=='imperial_eskd-disease-draw3-scinfer-120';raise SystemExit(0)
13
+ p,_,_=unit_support(S,'imperial_eskd-disease-draw3');r=Probe(S)
14
+ campaign.run_diffusion(r,p);campaign.run_scsemi(r,p)
15
+ raise RuntimeError('Expected remaining inference was not reached')
paper-releases/pbisc-diffusion/updates/20261014T111854Z-strict-server2-priority/diffusion/dataset/server_1/model8/plans/paper_figures_strictpairs_20261012/recoveries/priority_server2_20261014/stage.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pathlib import Path
2
+ import sys,json,subprocess,shlex,hashlib
3
+ R=Path(__file__).resolve().parent;S=R.parents[1];M=S.parents[1]
4
+ sys.path.insert(0,str(S/'tools'));from two_host_resume import unit_support
5
+ units=json.loads((R/'units.json').read_text());files=set()
6
+ for directory in [S/'tools',S/'data',S/'protocol']:
7
+ files.update(f for f in directory.rglob('*') if f.is_file() and '__pycache__' not in str(f))
8
+ for unit in units:
9
+ _,rel,_=unit_support(S,unit)
10
+ for tree in ['runs','generated','scsemi','isolated']:
11
+ files.update(f for f in (S/tree/rel).rglob('*') if f.is_file())
12
+ files.update((S/'receipts').glob(unit+'-*.json'))
13
+ files.update([R/'worker.py',R/'units.json'])
14
+ # These two unexecuted presentation/deconvolution helpers differ in the historical remote replica.
15
+ # The remote worker runs compute only; CPU scoring stays local. Preserve both remote originals.
16
+ files.difference_update([S/'tools/deconv_strict.py',S/'tools/finalize_campaign.py'])
17
+ assert all(not f.is_symlink() for f in files),'explicit symlink handling required'
18
+ # --ignore-existing prevents changing any pre-existing completed remote results.
19
+ subprocess.run(['rsync','-aR','--no-implied-dirs','--omit-dir-times','--ignore-existing',*[str(f) for f in sorted(files)],'spark-0110:/'],check=True)
20
+ bindings={str(f):hashlib.file_digest(f.open('rb'),'sha256').hexdigest() for f in sorted(files)}
21
+ code='import sys,json,pathlib,hashlib; b=json.load(sys.stdin); bad=[p for p,h in b.items() if hashlib.file_digest(pathlib.Path(p).open("rb"),"sha256").hexdigest()!=h];print(json.dumps({"files":len(b),"mismatches":bad}));sys.exit(bool(bad))'
22
+ r=subprocess.run(['ssh','spark-0110',shlex.join(['python3','-c',code])],input=json.dumps(bindings),text=True,capture_output=True);print(r.stdout);r.check_returncode()
23
+ (R/'STAGED.json').write_text(json.dumps({'files':bindings,'verified':True},indent=2)+'\n')
24
+ # Preserve raw imported receipts, normalize only output stat metadata on the destination.
25
+ code='''import pathlib,json,shutil,hashlib
26
+ S=pathlib.Path("'''+str(S)+'''"); R=pathlib.Path("'''+str(R)+'''")
27
+ for u in json.loads((R/'units.json').read_text()):
28
+ for p in (S/'receipts').glob(u+'-*.json'):
29
+ j=json.loads(p.read_text());assert j['state']=='completed',str(p)
30
+ raw=R/'source_receipts'/p.name;raw.parent.mkdir(exist_ok=True)
31
+ assert not raw.exists();shutil.copy2(p,raw)
32
+ for o in j.get('outputs',[]):
33
+ f=pathlib.Path(o['path']);assert hashlib.file_digest(f.open('rb'),'sha256').hexdigest()==o['sha256'];o['mtime_ns']=f.stat().st_mtime_ns;o['bytes']=f.stat().st_size
34
+ j['migration']={'source_host':'server_1','raw_receipt':str(raw),'raw_sha256':hashlib.file_digest(raw.open('rb'),'sha256').hexdigest()}
35
+ p.write_text(json.dumps(j,indent=2)+'\\n')
36
+ print('Receipt hashes verified and destination stat metadata normalized')
37
+ '''
38
+ subprocess.run(['ssh','spark-0110',shlex.join(['python3','-c',code])],check=True)
paper-releases/pbisc-diffusion/updates/20261014T111854Z-strict-server2-priority/diffusion/dataset/server_1/model8/plans/paper_figures_strictpairs_20261012/recoveries/priority_server2_20261014/worker.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Resume only transferred units; checkpoint-bound x4 priority at operation boundaries."""
2
+ from pathlib import Path
3
+ import sys,json,os,time
4
+ R=Path(__file__).resolve().parent;S=R.parents[1];M=S.parents[1]
5
+ sys.path.insert(0,str(S/'tools'))
6
+ import campaign
7
+ from runtime import Runtime,atomic_json,stamp
8
+ X=M/'plans/f01_trunk4x_complete_20261013'
9
+ def priority(payload):
10
+ # Fail closed if NAS disappears. The marker is shared by both hosts.
11
+ if not (payload/'pretrain').is_dir():return True
12
+ return (payload/'pretrain/f01_6k_trunk4x_seed20260627/checkpoint_epoch_016.pt').exists() and not (payload/'priority/LOW_PRIORITY_RELEASE.json').exists()
13
+ class LowPriorityRuntime(Runtime):
14
+ def preflight(self,resource,memory_gib):
15
+ if priority(X/'payload'):
16
+ atomic_json(R/'PRIORITY_STATUS.json',{'state':'yielding_to_x4','at':stamp(),'policy':'no new operations until verified x4 core completion'})
17
+ raise BlockingIOError('x4 downstream has priority')
18
+ super().preflight(resource,memory_gib)
19
+ def execute(self,*args,**kwargs):
20
+ kwargs.setdefault('wait_seconds',14*86400)
21
+ return super().execute(*args,**kwargs)
22
+ if __name__=='__main__':
23
+ campaign.Runtime=LowPriorityRuntime
24
+ campaign.main()