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

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/gpu_priority.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Own exactly nine x1 diffusion units; preserve x4 process and all in-flight children."""
2
+ from pathlib import Path
3
+ import os,sys,json,signal,subprocess,threading,fcntl,time
4
+ from concurrent.futures import ThreadPoolExecutor
5
+ R=Path(__file__).resolve().parent;S=R.parents[1];M=S.parents[1];X=M/'plans/f01_trunk4x_complete_20261013'
6
+ sys.path[:0]=[str(S/'tools'),str(X/'tools')]
7
+ import campaign
8
+ from runtime import Runtime,atomic_json,stamp
9
+ from dual_runtime import RemoteRuntime,ssh
10
+ from two_host_resume import unit_support
11
+ LOCK=threading.Lock();STOP=threading.Event()
12
+ def state(**kw):
13
+ with LOCK:
14
+ f=R/'GPU_STATUS.json';j=json.loads(f.read_text()) if f.exists() else {'completed':[],'running':{}}
15
+ j.update(kw,at=stamp());atomic_json(f,j)
16
+ class RemoteX1(RemoteRuntime):
17
+ def execute(self,name,argv,**kw):
18
+ self.pending_outputs=[str(p) for p in kw.get('outputs',[])]
19
+ return super().execute(name,argv,**kw)
20
+ def wrapped_command(self,name,argv,resource,memory_gib,threads):
21
+ command=super().wrapped_command(name,argv,resource,memory_gib,threads)
22
+ req=R/'transport'/f'{name}.json'
23
+ atomic_json(req,{'command':command,'outputs':self.pending_outputs,'receipt':str(req.with_suffix('.verified.json'))})
24
+ return [sys.executable,str(R/'transport.py'),str(req)]
25
+ def execution_metadata(self,argv=None,command=None):
26
+ j=super().execution_metadata(argv,command);j['canonical_output_transfer']='Verified remote SHA256 -> server_1';return j
27
+
28
+ def main():
29
+ units=json.loads((R/'GPU_UNITS.json').read_text());owners=json.loads((R/'OWNERS.json').read_text())
30
+ assert len(units)==len(set(units))==9 and set(units)==set(owners)
31
+ audit=json.loads((R/'reuse/REUSE_AUDIT.json').read_text())
32
+ assert audit['state']=='pass_no_exact_reuse_found' and {u['unit'] for u in audit['units']}==set(units)
33
+ with (S/'.campaign.lock').open('a') as lock:
34
+ fcntl.flock(lock,fcntl.LOCK_EX|fcntl.LOCK_NB)
35
+ matches=[]
36
+ for proc in Path('/proc').iterdir():
37
+ if not proc.name.isdigit():continue
38
+ try:argv=proc.joinpath('cmdline').read_bytes().split(b'\0')
39
+ except (FileNotFoundError,ProcessLookupError,PermissionError):continue
40
+ if argv[0].endswith(b'/python') and str(X/'tools/downstream.py').encode() in argv:matches.append(proc)
41
+ assert len(matches)==1,[(p.name,(p/'cmdline').read_bytes()) for p in matches]
42
+ proc=matches[0];j={'pid':int(proc.name),'start_ticks':(proc/'stat').read_text().split()[21],'cmdline':(proc/'cmdline').read_bytes().decode().replace('\0',' '),'at':stamp(),'scope':'Coordinator only; active systemd/SSH compute children continue; receipt wall_seconds includes pause'}
43
+ atomic_json(R/'X4_PAUSE.json',j);os.kill(j['pid'],signal.SIGSTOP);state(phase='x1_priority_x4_scheduler_suspended')
44
+ def lane(host):
45
+ rt=Runtime(S) if host=='server_1' else RemoteX1(S)
46
+ for u in units:
47
+ if STOP.is_set():return
48
+ if owners[u]!=host:continue
49
+ try:
50
+ with LOCK:
51
+ q=json.loads((R/'GPU_STATUS.json').read_text());q['running'][host]=u;q['at']=stamp();atomic_json(R/'GPU_STATUS.json',q)
52
+ path,_,support=unit_support(S,u);campaign.run_diffusion(rt,path)
53
+ atomic_json(R/'units'/f'{u}.json',{'state':'diffusion_completed','host':host,'support_sha256':support['sha256'],'at':stamp(),'scsemi':'separate existing protocol; not required to finish PBISC x1 generation'})
54
+ with LOCK:
55
+ q=json.loads((R/'GPU_STATUS.json').read_text());q['completed'].append(u);q['running'].pop(host,None);q['at']=stamp();atomic_json(R/'GPU_STATUS.json',q)
56
+ except BaseException:
57
+ STOP.set();raise
58
+ with ThreadPoolExecutor(max_workers=2) as pool:
59
+ futures=[pool.submit(lane,h) for h in ['server_1','server_2']]
60
+ for f in futures:f.result()
61
+ state(phase='all_nine_diffusion_completed')
62
+
63
+ def terminated(*_):raise SystemExit('Controller stop requested; x4 resumed in finally')
64
+ if __name__=='__main__':
65
+ signal.signal(signal.SIGTERM,terminated);signal.signal(signal.SIGINT,terminated)
66
+ try:main()
67
+ except BaseException as e:state(phase='stopped_needs_inspection',error=str(e));raise
68
+ finally:subprocess.run([sys.executable,str(R/'resume_x4.py')],check=True)
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/mirror_diffusion.py ADDED
@@ -0,0 +1,331 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Mirror exactly nine finished x1 diffusion units, with no training or generation.
3
+
4
+ The original Runtime.can_skip contract is replayed on both hosts. Existing
5
+ different files are preserved, never replaced. Run --self-test during compute;
6
+ the default action refuses to transfer before all nine GPU units are complete.
7
+ """
8
+ from __future__ import annotations
9
+
10
+ import argparse
11
+ from contextlib import contextmanager
12
+ from datetime import datetime, timezone
13
+ import fcntl
14
+ import hashlib
15
+ import json
16
+ import os
17
+ from pathlib import Path
18
+ import shlex
19
+ import subprocess
20
+ import sys
21
+ import tempfile
22
+ import unittest
23
+
24
+ R = Path(__file__).resolve().parent
25
+ S = R.parents[1]
26
+ DEST = R / 'mirror'
27
+ REMOTE_PY = '/home/sj_server_2/miniforge3/envs/b2sc-infer/bin/python'
28
+ CPU_PY = '/home/sj_server_1/miniforge3/envs/cxg_corpus/bin/python'
29
+ HOST = 'spark-0110'
30
+ UNITS = [f'ji2025_chili-disease-draw{i}' for i in (2, 3, 4)] + [
31
+ f'immicro-healthy-fold{fold}-n{n}' for fold in (0, 1) for n in (10, 20, 40)]
32
+ SSH = ['ssh', '-o', 'BatchMode=yes', '-o', 'ConnectTimeout=15',
33
+ '-o', 'ServerAliveInterval=15', '-o', 'ServerAliveCountMax=3', HOST]
34
+
35
+
36
+ def digest(path: Path) -> str:
37
+ with path.open('rb') as f:
38
+ return hashlib.file_digest(f, 'sha256').hexdigest()
39
+
40
+
41
+ def encoded(value: object) -> bytes:
42
+ return (json.dumps(value, indent=2, sort_keys=True, allow_nan=False) + '\n').encode()
43
+
44
+
45
+ def once(path: Path, data: bytes) -> None:
46
+ """Atomic create only; accept exact bytes on a repeated invocation."""
47
+ path.parent.mkdir(parents=True, exist_ok=True)
48
+ if path.exists() or path.is_symlink():
49
+ if path.is_symlink() or not path.is_file() or path.read_bytes() != data:
50
+ raise RuntimeError(f'Existing different file preserved: {path}')
51
+ return
52
+ fd, name = tempfile.mkstemp(prefix='.mirror-', dir=path.parent)
53
+ temp = Path(name)
54
+ try:
55
+ with os.fdopen(fd, 'wb') as f:
56
+ f.write(data)
57
+ f.flush()
58
+ os.fsync(f.fileno())
59
+ try:
60
+ os.link(temp, path)
61
+ except FileExistsError:
62
+ if path.is_symlink() or path.read_bytes() != data:
63
+ raise RuntimeError(f'Concurrent different file preserved: {path}') from None
64
+ finally:
65
+ temp.unlink(missing_ok=True)
66
+
67
+
68
+ def ssh_python(code: str, args: list[str] | None = None,
69
+ data: object | None = None) -> str:
70
+ argv = [REMOTE_PY, '-c', code, *(args or [])]
71
+ return subprocess.check_output(SSH + [shlex.join(argv)], text=True,
72
+ input=None if data is None else json.dumps(data))
73
+
74
+
75
+ @contextmanager
76
+ def locks():
77
+ """Both original worker locks stay held throughout copying and skip proof."""
78
+ with (S / '.campaign.lock').open('a') as local:
79
+ fcntl.flock(local, fcntl.LOCK_EX | fcntl.LOCK_NB)
80
+ code = ('import fcntl,sys; f=open(sys.argv[1],"a"); '
81
+ 'fcntl.flock(f,fcntl.LOCK_EX|fcntl.LOCK_NB); '
82
+ 'print("LOCKED",flush=True); sys.stdin.read()')
83
+ process = subprocess.Popen(SSH + [shlex.join([REMOTE_PY, '-c', code,
84
+ str(S / '.campaign.lock')])],
85
+ text=True, stdin=subprocess.PIPE,
86
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
87
+ try:
88
+ assert process.stdout is not None
89
+ if process.stdout.readline().strip() != 'LOCKED':
90
+ error = process.stderr.read() if process.stderr else ''
91
+ raise RuntimeError('Remote campaign lock unavailable: ' + error)
92
+ yield
93
+ if process.poll() is not None:
94
+ raise RuntimeError('Remote lock session ended before verification')
95
+ finally:
96
+ if process.stdin:
97
+ process.stdin.close()
98
+ try:
99
+ code = process.wait(timeout=20)
100
+ except subprocess.TimeoutExpired:
101
+ process.terminate()
102
+ code = process.wait(timeout=10)
103
+ if code and sys.exc_info()[0] is None:
104
+ raise RuntimeError(f'Remote lock session failed: {code}')
105
+
106
+
107
+ def relative(unit: str) -> Path:
108
+ if unit not in UNITS:
109
+ raise ValueError('Outside the exact requested nine units')
110
+ for p in (S / 'protocol/splits').glob('**/support.json'):
111
+ rel = p.relative_to(S / 'protocol/splits').parent
112
+ if '-'.join(rel.parts) == unit:
113
+ return rel
114
+ raise ValueError('Missing support manifest: ' + unit)
115
+
116
+
117
+ def output_contract(unit: str, suffix: str) -> list[Path]:
118
+ rel = relative(unit)
119
+ if suffix == 'train':
120
+ return [S / 'runs' / rel / 'lora/checkpoint_ft.pt',
121
+ S / 'runs' / rel / 'lora/RUN.json']
122
+ if suffix not in ('lora', 'pairedcal'):
123
+ raise ValueError('Unknown diffusion operation')
124
+ return [S / 'generated' / rel / f'{suffix}.npz',
125
+ S / 'generated' / rel / f'{suffix}.log']
126
+
127
+
128
+ def validate_completed(record: dict, expected: list[Path]) -> None:
129
+ if record.get('state') != 'completed' or not record.get('signature'):
130
+ raise RuntimeError('Only signed completed receipts can be mirrored')
131
+ outputs = record.get('outputs', [])
132
+ if [row.get('path') for row in outputs] != [str(p.resolve()) for p in expected]:
133
+ raise RuntimeError('Receipt output contract differs from exact nine-unit scope')
134
+ if any(not isinstance(x.get('sha256'), str) or len(x['sha256']) != 64 for x in outputs):
135
+ raise RuntimeError('Receipt lacks output SHA256')
136
+
137
+
138
+ PROBE = '''from pathlib import Path
139
+ import sys,json
140
+ S=Path(sys.argv[1]);units=json.loads(sys.argv[2]);sys.path.insert(0,str(S/'tools'))
141
+ import campaign
142
+ from runtime import Runtime
143
+ class Probe(Runtime):
144
+ def __init__(self,root):super().__init__(root);self.results=[]
145
+ def execute(self,name,argv,**kw):
146
+ sig=self.signature(argv,kw.get('inputs',[]))
147
+ if not self.can_skip(name,sig,kw.get('outputs',[])):
148
+ raise RuntimeError('Would launch an operation; no execution allowed: '+name)
149
+ self.results.append({'operation':name,'signature':sig,'verified_skip':True})
150
+ return False
151
+ def preflight(self,*args,**kw):raise AssertionError('Probe must never launch compute')
152
+ def wrapped_command(self,*args,**kw):raise AssertionError('Probe must never create a command')
153
+ rt=Probe(S)
154
+ for unit in units:
155
+ matches=[p for p in campaign.discover_units() if campaign.name(p)==unit]
156
+ assert len(matches)==1
157
+ campaign.run_diffusion(rt,matches[0])
158
+ assert len(rt.results)==27 and len({x['operation'] for x in rt.results})==27
159
+ print(json.dumps({'state':'verified_skip_only','operations':rt.results,'gpu_launched':False}))
160
+ '''
161
+
162
+
163
+ def source_probe() -> dict:
164
+ env = dict(os.environ, CUDA_VISIBLE_DEVICES='', PYTHONDONTWRITEBYTECODE='1',
165
+ OPENBLAS_NUM_THREADS='1', OMP_NUM_THREADS='1')
166
+ return json.loads(subprocess.check_output([CPU_PY, '-c', PROBE,
167
+ str(S), json.dumps(UNITS)], env=env, text=True))
168
+
169
+
170
+ REMOTE_STAT = '''from pathlib import Path
171
+ import sys,json,hashlib
172
+ out={}
173
+ for raw in json.load(sys.stdin):
174
+ p=Path(raw)
175
+ if p.is_symlink():raise RuntimeError('Symlink target preserved: '+raw)
176
+ if not p.exists():out[raw]=None;continue
177
+ if not p.is_file():raise RuntimeError('Non-file target preserved: '+raw)
178
+ st=p.stat();out[raw]={'path':str(p.resolve()),'bytes':st.st_size,'mtime_ns':st.st_mtime_ns,'sha256':hashlib.file_digest(p.open('rb'),'sha256').hexdigest()}
179
+ print(json.dumps(out))
180
+ '''
181
+
182
+
183
+ INSTALL = '''from pathlib import Path
184
+ import sys,os,hashlib,json
185
+ src=Path(sys.argv[1]);dst=Path(sys.argv[2]);expected=sys.argv[3]
186
+ def sha(p):return hashlib.file_digest(p.open('rb'),'sha256').hexdigest()
187
+ assert src.is_file() and not src.is_symlink() and sha(src)==expected
188
+ dst.parent.mkdir(parents=True,exist_ok=True)
189
+ try:os.link(src,dst)
190
+ except FileExistsError:
191
+ assert dst.is_file() and not dst.is_symlink() and sha(dst)==expected,'Conflicting destination preserved: '+str(dst)
192
+ assert sha(dst)==expected
193
+ src.unlink()
194
+ print(json.dumps({'state':'verified','path':str(dst),'sha256':expected}))
195
+ '''
196
+
197
+
198
+ def copy_if_missing(source: Path, target: Path, expected: str, known: dict | None) -> None:
199
+ if known is not None:
200
+ if known['sha256'] != expected:
201
+ raise RuntimeError('Conflicting remote file preserved: ' + str(target))
202
+ return
203
+ staging = DEST / 'staging' / (hashlib.sha256(str(target).encode()).hexdigest() + '-' + expected)
204
+ ssh_python('from pathlib import Path; import sys; Path(sys.argv[1]).mkdir(parents=True,exist_ok=True)',
205
+ [str(staging.parent)])
206
+ subprocess.run(['rsync', '-a', '--protect-args', str(source), HOST + ':' + str(staging)], check=True)
207
+ ssh_python(INSTALL, [str(staging), str(target), expected])
208
+
209
+
210
+ def normalize_receipt(record: dict, stats: dict, raw: Path, raw_sha: str) -> dict:
211
+ result = json.loads(json.dumps(record))
212
+ for output in result['outputs']:
213
+ actual = stats[output['path']]
214
+ if actual is None or actual['sha256'] != output['sha256'] or actual['bytes'] != output['bytes']:
215
+ raise RuntimeError('Destination payload differs from canonical source receipt')
216
+ output.update({key:actual[key] for key in ('path', 'bytes', 'mtime_ns')})
217
+ result['mirror_provenance'] = {
218
+ 'schema': 'pbisc.strict9.diffusion-mirror.v1',
219
+ 'source_receipt_host': 'server_1',
220
+ 'source_receipt': str(raw),
221
+ 'source_receipt_sha256': raw_sha,
222
+ 'destination_host': 'server_2',
223
+ 'normalization': 'Destination output path, bytes and mtime_ns only; original execution metadata and signature preserved'}
224
+ return result
225
+
226
+
227
+ def main() -> None:
228
+ status = json.loads((R / 'GPU_STATUS.json').read_text())
229
+ if (status.get('phase') != 'all_nine_diffusion_completed' or
230
+ set(status.get('completed', [])) != set(UNITS) or
231
+ len(status.get('completed', [])) != 9):
232
+ raise RuntimeError('Nine GPU units have not all completed; no transfer attempted')
233
+ if set(json.loads((R / 'GPU_UNITS.json').read_text())) != set(UNITS):
234
+ raise RuntimeError('GPU unit ownership differs from the exact requested nine')
235
+ audit = json.loads((R / 'reuse/REUSE_AUDIT.json').read_text())
236
+ if audit.get('state') != 'pass_no_exact_reuse_found':
237
+ raise RuntimeError('No passing reuse audit')
238
+ DEST.mkdir(parents=True, exist_ok=True)
239
+ with locks():
240
+ checked_source = source_probe()
241
+ once(DEST / 'SOURCE_PROBE.json', encoded(checked_source))
242
+ receipts=[]
243
+ outputs={}
244
+ for unit in UNITS:
245
+ for suffix in ('train', 'lora', 'pairedcal'):
246
+ name=f'{unit}-{suffix}'
247
+ path=S/'receipts'/f'{name}.json'
248
+ raw=DEST/'source_receipts'/path.name
249
+ blob=path.read_bytes();record=json.loads(blob)
250
+ validate_completed(record,output_contract(unit,suffix))
251
+ once(raw,blob)
252
+ receipts.append((name,record,raw,hashlib.sha256(blob).hexdigest()))
253
+ for output in record['outputs']:
254
+ if output['path'] in outputs and outputs[output['path']]!=output['sha256']:
255
+ raise RuntimeError('Inconsistent source output hashes')
256
+ outputs[output['path']]=output['sha256']
257
+ if len(receipts)!=27 or len(outputs)!=54:
258
+ raise RuntimeError('Unexpected operation/artifact count')
259
+ remote_stats=json.loads(ssh_python(REMOTE_STAT,data=list(outputs)))
260
+ for raw,expected in outputs.items():
261
+ if digest(Path(raw))!=expected:
262
+ raise RuntimeError('Canonical source changed after probe: '+raw)
263
+ copy_if_missing(Path(raw),Path(raw),expected,remote_stats[raw])
264
+ # Re-read every output after all transfers; normalized receipts are installed only afterward.
265
+ remote_stats=json.loads(ssh_python(REMOTE_STAT,data=list(outputs)))
266
+ for name,record,raw,raw_sha in receipts:
267
+ remote_raw=json.loads(ssh_python(REMOTE_STAT,data=[str(raw)]))[str(raw)]
268
+ copy_if_missing(raw,raw,raw_sha,remote_raw)
269
+ normalized=normalize_receipt(record,remote_stats,raw,raw_sha)
270
+ staged=DEST/'normalized_receipts'/f'{name}.json'
271
+ once(staged,encoded(normalized))
272
+ target=S/'receipts'/f'{name}.json'
273
+ existing=json.loads(ssh_python(REMOTE_STAT,data=[str(target)]))[str(target)]
274
+ copy_if_missing(staged,target,digest(staged),existing)
275
+ # CUDA is explicitly hidden. Probe overrides execute, preflight and wrapper: no launch path exists.
276
+ remote_probe_code="import os;os.environ['CUDA_VISIBLE_DEVICES']='';os.environ['PYTHONDONTWRITEBYTECODE']='1';os.environ['OPENBLAS_NUM_THREADS']='1';os.environ['OMP_NUM_THREADS']='1';\n"+PROBE
277
+ checked_remote=json.loads(ssh_python(remote_probe_code,[str(S),json.dumps(UNITS)]))
278
+ once(DEST/'REMOTE_PROBE.json',encoded(checked_remote))
279
+ evidence={'schema':'pbisc.strict9.diffusion-mirror.v1','state':'verified','units':UNITS,
280
+ 'source_host':'server_1','destination_host':'server_2','completed_receipts':27,
281
+ 'artifacts':54,'remote_verified_skips':len(checked_remote['operations']),
282
+ 'gpu_launched':False,'source_probe_sha256':digest(DEST/'SOURCE_PROBE.json'),
283
+ 'remote_probe_sha256':digest(DEST/'REMOTE_PROBE.json'),
284
+ 'source_receipts':[{ 'operation':n,'path':str(p),'sha256':h} for n,_,p,h in receipts],
285
+ 'outputs':remote_stats}
286
+ once(R/'MIRROR_VERIFIED.json',encoded(evidence))
287
+ print(json.dumps({'state':'verified','operations':27,'artifacts':54,'receipt':str(R/'MIRROR_VERIFIED.json')}))
288
+
289
+
290
+ class Tests(unittest.TestCase):
291
+ def test_exact_scope(self):
292
+ self.assertEqual(len(UNITS),9)
293
+ self.assertEqual(len(set(UNITS)),9)
294
+ with self.assertRaises(ValueError):relative('unexpected')
295
+
296
+ def test_once_reuses_exact_and_preserves_conflict(self):
297
+ with tempfile.TemporaryDirectory() as folder:
298
+ p=Path(folder)/'record.json';once(p,b'one');once(p,b'one')
299
+ with self.assertRaises(RuntimeError):once(p,b'two')
300
+ self.assertEqual(p.read_bytes(),b'one')
301
+
302
+ def test_normalize_only_stats_and_provenance(self):
303
+ row={'state':'completed','signature':'unchanged','execution':{'host':'source'},
304
+ 'outputs':[{'path':'/same','bytes':3,'mtime_ns':1,'sha256':'a'*64}]}
305
+ result=normalize_receipt(row,{'/same':{'path':'/same','bytes':3,'mtime_ns':9,'sha256':'a'*64}},Path('/raw'),'b'*64)
306
+ self.assertEqual(row['outputs'][0]['mtime_ns'],1)
307
+ self.assertEqual(result['outputs'][0]['mtime_ns'],9)
308
+ self.assertEqual(result['signature'],row['signature'])
309
+ self.assertEqual(result['execution'],row['execution'])
310
+ result.pop('mirror_provenance');result['outputs'][0]['mtime_ns']=1
311
+ self.assertEqual(result,row)
312
+
313
+ def test_bad_hash_blocks_receipt(self):
314
+ row={'outputs':[{'path':'/same','bytes':3,'sha256':'a'*64}]}
315
+ with self.assertRaises(RuntimeError):
316
+ normalize_receipt(row,{'/same':{'path':'/same','bytes':3,'mtime_ns':9,'sha256':'b'*64}},Path('/raw'),'c'*64)
317
+
318
+ def test_noncompleted_and_out_of_scope_blocked(self):
319
+ with self.assertRaises(RuntimeError):validate_completed({'state':'running'},[])
320
+ with self.assertRaises(RuntimeError):
321
+ validate_completed({'state':'completed','signature':'s','outputs':[{'path':'/other','sha256':'a'*64}]},[Path('/expected')])
322
+
323
+
324
+ if __name__=='__main__':
325
+ parser=argparse.ArgumentParser(description=__doc__)
326
+ parser.add_argument('--self-test',action='store_true')
327
+ args=parser.parse_args()
328
+ if args.self_test:
329
+ result=unittest.TextTestRunner(verbosity=2).run(unittest.defaultTestLoader.loadTestsFromTestCase(Tests))
330
+ raise SystemExit(0 if result.wasSuccessful() else 1)
331
+ 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/resume_x4.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ from pathlib import Path
2
+ import os,signal,json,datetime
3
+ R=Path(__file__).resolve().parent
4
+ p=R/'X4_PAUSE.json'
5
+ if p.exists():
6
+ j=json.loads(p.read_text());proc=Path('/proc')/str(j['pid'])
7
+ if proc.exists() and proc.joinpath('stat').read_text().split()[21]==j['start_ticks'] and b'/f01_trunk4x_complete_20261013/tools/downstream.py' in proc.joinpath('cmdline').read_bytes():
8
+ os.kill(j['pid'],signal.SIGCONT)
9
+ (R/'X4_RESUMED.json').write_text(json.dumps({'pid':j['pid'],'at':datetime.datetime.now(datetime.timezone.utc).isoformat(),'reason':'x1 GPU stage ended or controller stopped; existing x4 coordinator preserved'},indent=2)+'\n')
paper-releases/pbisc-diffusion/updates/20261015T121654Z-x1-nine-core40-deck/diffusion/dataset/server_1/model8/plans/paper_figures_strictpairs_20261012/runs/immicro/healthy/fold1/n40/lora/RUN.json ADDED
@@ -0,0 +1,450 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schema": "pbisc_sdd.ft_intradataset.run.v1",
3
+ "source_checkpoint": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/runs/f01_6k_1x_seed20260627/checkpoint_epoch_016.pt",
4
+ "source_checkpoint_sha256": "8c7cd0e83e2bc19fe03dfcbc084919a1e2f61be8cc8bc12f4caf543dfda91633",
5
+ "dataset_dir": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/paired_finetune_intradataset_20260927/data/immicro",
6
+ "condition_npz": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/paired_finetune_intradataset_20260927/data/immicro/conditions_raw_fixed.npz",
7
+ "condition_npz_sha256": "2be5717d19e86bdf38e4838d4bd2886a211ba78bfbfe749c458305a3e0ac2dcc",
8
+ "fold": 0,
9
+ "mode": "lora",
10
+ "trainable": {
11
+ "mode": "lora",
12
+ "lora_layers": [
13
+ "time_encoder.0",
14
+ "time_encoder.2",
15
+ "condition_encoder.0",
16
+ "condition_encoder.3",
17
+ "context_mixer.2",
18
+ "down_blocks.0.input_projection",
19
+ "down_blocks.0.context_projection.1",
20
+ "down_blocks.1.input_projection",
21
+ "down_blocks.1.context_projection.1",
22
+ "down_blocks.2.input_projection",
23
+ "down_blocks.2.context_projection.1",
24
+ "down_blocks.3.input_projection",
25
+ "down_blocks.3.context_projection.1",
26
+ "up_blocks.0.input_projection",
27
+ "up_blocks.0.context_projection.1",
28
+ "up_blocks.1.input_projection",
29
+ "up_blocks.1.context_projection.1",
30
+ "up_blocks.2.input_projection",
31
+ "up_blocks.2.context_projection.1",
32
+ "output_trunk.0",
33
+ "value_head",
34
+ "active_head"
35
+ ],
36
+ "lora_rank": 16,
37
+ "lora_alpha": 16.0,
38
+ "n_trainable": 1296224,
39
+ "n_total_base": 54185184,
40
+ "trainable_tensors": 44
41
+ },
42
+ "lr": 0.0005,
43
+ "warmup": 200,
44
+ "batch_size": 256,
45
+ "ema_decay": 0.999,
46
+ "max_steps": 3000,
47
+ "steps_run": 3000,
48
+ "eval_every": 250,
49
+ "patience": 8,
50
+ "train_subset": null,
51
+ "train_donors_file": null,
52
+ "support_manifest": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/paper_figures_strictpairs_20261012/protocol/splits/immicro/healthy/fold1/n40/support.json",
53
+ "support_sha256": "e4909b732024af62d8332b9fc37adb0f7bda2024884b74ac3b4059ecf371d2c5",
54
+ "train_donor_ids": [
55
+ "HS25",
56
+ "HS95",
57
+ "HS77",
58
+ "HS14",
59
+ "HS108",
60
+ "HS58",
61
+ "HS90",
62
+ "HS102",
63
+ "HS27",
64
+ "HS45",
65
+ "HS66",
66
+ "HS75",
67
+ "HS83",
68
+ "HS43",
69
+ "HS107",
70
+ "HS1",
71
+ "HS97",
72
+ "HS73",
73
+ "HS103",
74
+ "HS23",
75
+ "HS52",
76
+ "HS4",
77
+ "HS40",
78
+ "HS85",
79
+ "HS89",
80
+ "HS67",
81
+ "HS60",
82
+ "HS8",
83
+ "HS31",
84
+ "HS37",
85
+ "HS106",
86
+ "HS62",
87
+ "HS15",
88
+ "HS38",
89
+ "HS63",
90
+ "HS87",
91
+ "HS98",
92
+ "HS28",
93
+ "HS69",
94
+ "HS78"
95
+ ],
96
+ "excluded_selected_donor_visits": [],
97
+ "fixed_steps": 3000,
98
+ "selected_step": 3000,
99
+ "selected_inner_val_loss": NaN,
100
+ "pretrained_inner_val_loss": NaN,
101
+ "train_rows": [
102
+ "HS1",
103
+ "HS4",
104
+ "HS8",
105
+ "HS14",
106
+ "HS15",
107
+ "HS23",
108
+ "HS25",
109
+ "HS27",
110
+ "HS28",
111
+ "HS31",
112
+ "HS37",
113
+ "HS38",
114
+ "HS40",
115
+ "HS43",
116
+ "HS45",
117
+ "HS52",
118
+ "HS58",
119
+ "HS60",
120
+ "HS62",
121
+ "HS63",
122
+ "HS66",
123
+ "HS67",
124
+ "HS69",
125
+ "HS73",
126
+ "HS75",
127
+ "HS77",
128
+ "HS78",
129
+ "HS83",
130
+ "HS85",
131
+ "HS87",
132
+ "HS89",
133
+ "HS90",
134
+ "HS95",
135
+ "HS97",
136
+ "HS98",
137
+ "HS102",
138
+ "HS103",
139
+ "HS106",
140
+ "HS107",
141
+ "HS108"
142
+ ],
143
+ "inner_val_rows": [],
144
+ "test_rows_never_loaded_for_training": [
145
+ "HS2",
146
+ "HS12",
147
+ "HS16",
148
+ "HS17",
149
+ "HS21",
150
+ "HS35",
151
+ "HS36",
152
+ "HS39",
153
+ "HS44",
154
+ "HS46",
155
+ "HS47",
156
+ "HS48",
157
+ "HS51",
158
+ "HS56",
159
+ "HS57",
160
+ "HS65",
161
+ "HS68",
162
+ "HS72",
163
+ "HS84",
164
+ "HS92",
165
+ "HS96",
166
+ "HS109"
167
+ ],
168
+ "max_abs_weight_change": 0.8787888884544373,
169
+ "n_tensors_changed": 22,
170
+ "seed": 20260927,
171
+ "wall_seconds": 124.6,
172
+ "written_utc": "2026-10-15T11:54:59.625799+00:00",
173
+ "support_expression_isolation": {
174
+ "schema": "pbisc.paper.support-expression-isolation.v1",
175
+ "support_manifest": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/paper_figures_strictpairs_20261012/protocol/splits/immicro/healthy/fold1/n40/support.json",
176
+ "support_sha256": "e4909b732024af62d8332b9fc37adb0f7bda2024884b74ac3b4059ecf371d2c5",
177
+ "cohort": "immicro",
178
+ "unit": "fold1_n40",
179
+ "train_sample_ids": [
180
+ "HS25",
181
+ "HS95",
182
+ "HS77",
183
+ "HS14",
184
+ "HS108",
185
+ "HS58",
186
+ "HS90",
187
+ "HS102",
188
+ "HS27",
189
+ "HS45",
190
+ "HS66",
191
+ "HS75",
192
+ "HS83",
193
+ "HS43",
194
+ "HS107",
195
+ "HS1",
196
+ "HS97",
197
+ "HS73",
198
+ "HS103",
199
+ "HS23",
200
+ "HS52",
201
+ "HS4",
202
+ "HS40",
203
+ "HS85",
204
+ "HS89",
205
+ "HS67",
206
+ "HS60",
207
+ "HS8",
208
+ "HS31",
209
+ "HS37",
210
+ "HS106",
211
+ "HS62",
212
+ "HS15",
213
+ "HS38",
214
+ "HS63",
215
+ "HS87",
216
+ "HS98",
217
+ "HS28",
218
+ "HS69",
219
+ "HS78"
220
+ ],
221
+ "train_donor_ids": [
222
+ "HS25",
223
+ "HS95",
224
+ "HS77",
225
+ "HS14",
226
+ "HS108",
227
+ "HS58",
228
+ "HS90",
229
+ "HS102",
230
+ "HS27",
231
+ "HS45",
232
+ "HS66",
233
+ "HS75",
234
+ "HS83",
235
+ "HS43",
236
+ "HS107",
237
+ "HS1",
238
+ "HS97",
239
+ "HS73",
240
+ "HS103",
241
+ "HS23",
242
+ "HS52",
243
+ "HS4",
244
+ "HS40",
245
+ "HS85",
246
+ "HS89",
247
+ "HS67",
248
+ "HS60",
249
+ "HS8",
250
+ "HS31",
251
+ "HS37",
252
+ "HS106",
253
+ "HS62",
254
+ "HS15",
255
+ "HS38",
256
+ "HS63",
257
+ "HS87",
258
+ "HS98",
259
+ "HS28",
260
+ "HS69",
261
+ "HS78"
262
+ ],
263
+ "source_cells": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/paired_finetune_intradataset_20260927/data/immicro/cells_panel6k.npz",
264
+ "source_cells_sha256": "e1168468b621183604038b79280f46961c5819fe2386d9da0b454f7db642742a",
265
+ "source_folds_sha256": "0adc10f4ac973e5b7558effbea0fd6950a6bf59e5af1d3a376e12eb00bf6a643",
266
+ "isolated_cells": "/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/paper_figures_strictpairs_20261012/isolated/immicro/healthy/fold1/n40/cells_support_only.npz",
267
+ "isolated_cells_sha256": "0d8c6a634556786cc437b600999e4f85294543d860489366d98b10818515e11a",
268
+ "builder_sha256": "762f5f7bbf908c478544b0c5c05a8fbf6c3bf63eff6a2d7af88105473c1c20a2",
269
+ "audit": {
270
+ "selected_sample_rows": [
271
+ 0,
272
+ 3,
273
+ 6,
274
+ 12,
275
+ 13,
276
+ 20,
277
+ 22,
278
+ 24,
279
+ 25,
280
+ 28,
281
+ 33,
282
+ 34,
283
+ 36,
284
+ 39,
285
+ 41,
286
+ 48,
287
+ 54,
288
+ 56,
289
+ 58,
290
+ 59,
291
+ 62,
292
+ 63,
293
+ 65,
294
+ 69,
295
+ 71,
296
+ 73,
297
+ 74,
298
+ 79,
299
+ 81,
300
+ 83,
301
+ 85,
302
+ 86,
303
+ 91,
304
+ 93,
305
+ 94,
306
+ 97,
307
+ 98,
308
+ 101,
309
+ 102,
310
+ 103
311
+ ],
312
+ "selected_cells": 140043,
313
+ "selected_nonzero_entries": 52912313,
314
+ "original_cell_rows": 392251,
315
+ "nonselected_expression_rows_empty": true,
316
+ "original_expression_ranges": [
317
+ [
318
+ 0,
319
+ 1504797
320
+ ],
321
+ [
322
+ 4825033,
323
+ 6639911
324
+ ],
325
+ [
326
+ 9933542,
327
+ 11206953
328
+ ],
329
+ [
330
+ 19315918,
331
+ 23069429
332
+ ],
333
+ [
334
+ 31194465,
335
+ 31896242
336
+ ],
337
+ [
338
+ 32541625,
339
+ 33326602
340
+ ],
341
+ [
342
+ 34426292,
343
+ 37519677
344
+ ],
345
+ [
346
+ 41950421,
347
+ 43870037
348
+ ],
349
+ [
350
+ 48911773,
351
+ 51123627
352
+ ],
353
+ [
354
+ 51906420,
355
+ 53172512
356
+ ],
357
+ [
358
+ 55272483,
359
+ 57119283
360
+ ],
361
+ [
362
+ 58712027,
363
+ 59539601
364
+ ],
365
+ [
366
+ 68718214,
367
+ 70214002
368
+ ],
369
+ [
370
+ 76988645,
371
+ 77540432
372
+ ],
373
+ [
374
+ 79384968,
375
+ 80446582
376
+ ],
377
+ [
378
+ 81206228,
379
+ 84515194
380
+ ],
381
+ [
382
+ 87119554,
383
+ 90363220
384
+ ],
385
+ [
386
+ 91403069,
387
+ 92080438
388
+ ],
389
+ [
390
+ 97565938,
391
+ 98898035
392
+ ],
393
+ [
394
+ 100819709,
395
+ 101647131
396
+ ],
397
+ [
398
+ 102941774,
399
+ 105564211
400
+ ],
401
+ [
402
+ 110990986,
403
+ 111937275
404
+ ],
405
+ [
406
+ 113055026,
407
+ 114897365
408
+ ],
409
+ [
410
+ 115360655,
411
+ 117056907
412
+ ],
413
+ [
414
+ 118976164,
415
+ 120737395
416
+ ],
417
+ [
418
+ 125793775,
419
+ 127286443
420
+ ],
421
+ [
422
+ 128077095,
423
+ 131666404
424
+ ],
425
+ [
426
+ 135086776,
427
+ 136903807
428
+ ],
429
+ [
430
+ 140808934,
431
+ 144456310
432
+ ]
433
+ ],
434
+ "cell_row_indexing": "unchanged original cell-row indices; non-support rows have empty CSR rows",
435
+ "data_sha256": "4fd5e20f1fd29912a4ea04875dd5b240a4f3e8ae2b0873a560f602b1f67121b7",
436
+ "indices_sha256": "ffd436f0c2c2e4c6d71cdc0a9abb4d3e8b65ffec75fbc3480294b522b69ee08b"
437
+ },
438
+ "expression_access": "Only selected CSR ranges interpreted. Nonselected compressed bytes may be streamed and discarded.",
439
+ "target_sc_aggregate_keys_accessed": [],
440
+ "permitted_all_row_metadata": [
441
+ "indptr",
442
+ "row_sample",
443
+ "shape",
444
+ "panel_gene_ids",
445
+ "panel_measured"
446
+ ]
447
+ },
448
+ "checkpoint_sha256": "e4877d6f68387128ce43a3d2de497754090c9b95d621f001c24a6e45e19062f8",
449
+ "reload_forward_max_abs_diff": 0.0
450
+ }