64 lines
5.0 KiB
Python
64 lines
5.0 KiB
Python
"""Metadata-only pilot contract from frozen H1 inputs; never accesses labels."""
|
|
import ast
|
|
import json
|
|
from pathlib import Path
|
|
import sys
|
|
import numpy as np
|
|
import torch
|
|
from phase2_h1_worker_v2 import sha,save,checked
|
|
|
|
BASE=Path('/home/frank14f/optane/MeltMind')
|
|
|
|
def closure(names):
|
|
pending=list(names);done={}
|
|
while pending:
|
|
name=pending.pop();path=BASE/'tools'/Path(*name.split('.')).with_suffix('.py')
|
|
if not path.exists() or name in done:continue
|
|
done[name]=path
|
|
for node in ast.walk(ast.parse(path.read_text())):
|
|
if isinstance(node,ast.Import):pending.extend(a.name for a in node.names)
|
|
elif isinstance(node,ast.ImportFrom) and node.module:pending.append(node.module)
|
|
return {str(p.relative_to(BASE)):sha(p) for p in done.values()}
|
|
|
|
def run(acceptance):
|
|
acc=json.loads(acceptance.read_text())
|
|
if acc['status']!='PASS':raise ValueError('Final acceptance not PASS')
|
|
for p,h in acc['code_sha256'].items():checked(BASE/p,h)
|
|
oldroot=BASE/'artifacts/phase2-h1-execution-2026-11-17';sources={}
|
|
def read(p):
|
|
p=Path(p);sources[str(p.relative_to(BASE))]=sha(p);return json.loads(p.read_text())
|
|
old=read(oldroot/'contract.json');models=read(oldroot/'models-terminal.json')['models'];gm=read(oldroot/'geometry/manifest.json')
|
|
geometry={r['case']:r for r in gm['records'] if r['protocol']=='grouped'};folds=[]
|
|
for fold in range(5):
|
|
job=next(j for j in old['jobs'] if j['protocol']=='grouped' and j['pool']==100 and j['fold']==fold)
|
|
model=next(m for m in models if m['index']==job['index']);assert model['status']=='PASS';checked(model['clock_path'],model['clock_sha256']);clock=read(model['clock_path']);assert clock['parts']==job['learning']
|
|
rows=old['grouped_rows'];validation=sorted(case for case,r in rows.items() if next(a for a in r['assignments'] if a['fold']==fold)['role']=='validation')
|
|
f=dict(fold=fold,learning=job['learning'],validation=validation,test=job['test'],c=clock['c'],clock_sha256=model['clock_sha256'],clock_path=model['clock_path'])
|
|
for role in ['learning','validation','test']:
|
|
f[role+'_nodes']=sum(geometry[case]['nodes'] for case in f[role]);f[role+'_edges']=sum(geometry[case]['directed_edges'] for case in f[role])
|
|
assert not(set(f['learning'])&set(f['validation']) or set(f['learning'])&set(f['test']) or set(f['validation'])&set(f['test']))
|
|
folds.append(f)
|
|
reps=[]
|
|
for key in ['nodes','directed_edges']:
|
|
order=sorted(folds[0]['learning'],key=lambda case:(geometry[case][key],case))
|
|
for i in [0,len(order)//2,len(order)-1]:
|
|
if order[i] not in reps:reps.append(order[i])
|
|
for rel in ['docs/phase2-h2-architecture-2026-11-17.md','references/2026-11-17/phase2-design/mold-h2-review-3541052d.md','docs/phase2-h2-execution-contract-2026-11-17.md']:
|
|
sources[rel]=sha(BASE/rel)
|
|
sources[str(acceptance.relative_to(BASE))]=sha(acceptance)
|
|
root=BASE/'artifacts/phase2-h2-pilot-2026-11-17';root.mkdir(exist_ok=False)
|
|
names=['phase2_h2_model','phase2_h2_data','phase2_h2_pilot_worker','phase2_h2_guard','phase2_h2_prepare']
|
|
save(root/'contract.json',dict(version='phase2-h2-pilot-v1',approval='1794900702.867059',initial_pilot_approval='1794900338.137689',mode='PILOT_ONLY',full_after_cost_gate_authorized=True,
|
|
parts=old['parts']['grouped'],geometry=geometry,folds=folds,representatives=reps,code_sha256=closure(names),source_sha256=sources,
|
|
gpu_uuid='GPU-e8853ae7-a302-6a17-bcfa-aa767e9ed20c',gpu_index=0,worker_cpus=[0,1],guard_cpus=[2],gpu_seconds=7200,cpu_seconds=7200,pilot_setup_charge_seconds=60,future_setup_reserve_seconds=300,
|
|
rss_bytes=16*2**30,vram_bytes=15*2**30,disk_bytes=20*2**30,versions=dict(torch=torch.__version__,numpy=np.__version__,cuda_build=torch.version.cuda),
|
|
model=dict(width=64,blocks=4,tokens_per_physical_component=64,attention_heads=4,edge_chunk=65536,node_chunk=8192,activation_checkpoint='each full block, non-reentrant',dtype='FP32',dropout=0),
|
|
pilot='learning-only normalization; small/median/max node and edge representatives two steps each; fresh seed0 complete fold0 epoch; complete validation forward timing with no targets',
|
|
optimizer='AdamW lr1e-3 betas.9/.999 eps1e-8 weight_decay1e-4 except biases/norm; clip1; one full-part step weighted Nparts*Ni/Ntotal',
|
|
schedule='1-based e1..10:1e-4+(e-1)*9e-4/9; e11..200:1e-5+(.001-.00001)*(1+cos(pi*(e-10)/190))/2; step after complete epoch',
|
|
normalization='learning-only original19 float64 parallel-Welford population std; zero std=>1; standardized network FP32; separate originalFP64 Vf skip',
|
|
limits_sampled=True,no_new_decodes=True,no_test_targets=True,no_retry=True,full_epochs=200,full_folds=5,full_seed=0,full_gpu_seconds_including_pilot=57600,full_max_parallel_gpus=4))
|
|
print(json.dumps(dict(root=str(root),contract_sha256=sha(root/'contract.json'),representatives=reps,code_files=len(closure(names)),fold0_learning=len(folds[0]['learning']),validation=len(folds[0]['validation']))))
|
|
|
|
if __name__=='__main__':run(Path(sys.argv[1]).resolve())
|