Publish fixed regional-context item b entry and adopted item1b review with capacity hold
This commit is contained in:
1 parent
ffd5c92958
commit
31a20abd43
34 files changed
+16026
No files matched your search
@@ -0,0 +1,112 @@
|
||||
"""Item b immutable scope, assignments and conservative total-cost projection."""
|
||||
import json
|
||||
import math
|
||||
import statistics
|
||||
from pathlib import Path
|
||||
from phase2_h1_worker_v2 import checked, sha
|
||||
from phase2_home_freeze_io import verify
|
||||
from phase3_seed1_v2_common import fold_view
|
||||
|
||||
ROOT = Path('/home/frank14f/MeltMind-runs/phase3-item-b-2026-11-18')
|
||||
|
||||
|
||||
def read(p):
|
||||
return json.loads(Path(p).read_text())
|
||||
|
||||
|
||||
def config(root):
|
||||
if root.resolve() != ROOT:
|
||||
raise PermissionError('Sole item b root')
|
||||
c = read(root/'contract.json')
|
||||
verify(root, 'implementation')
|
||||
expected = dict(approval='1795011607.907609', seed=0, epochs=200, new_fits=5,
|
||||
gpu_cap=178200, postfit_gpu_reserve=7200, postfit_cpu_cap=3600,
|
||||
phase3_gpu_cap=720000, no_retry=True)
|
||||
if any(c.get(k) != v for k,v in expected.items()):
|
||||
raise PermissionError('Fixed item_b scope/budgets')
|
||||
for p,h in {**c['source_sha256'], **c['code_sha256']}.items():
|
||||
checked(p,h)
|
||||
pilot = read(c['pilot_contract'])
|
||||
import numpy as np
|
||||
import torch
|
||||
if np.__version__ != pilot['versions']['numpy'] or torch.__version__ != pilot['versions']['torch']:
|
||||
raise ValueError('Original environment versions')
|
||||
if [j['id'] for j in c['jobs']] != list(range(5)):
|
||||
raise ValueError('Exactly five folds')
|
||||
tests = []
|
||||
for job in c['jobs']:
|
||||
f = fold_view(pilot, job['id'])['folds'][0]
|
||||
tests.extend(f['test'])
|
||||
if job['target_steps'] != 200*len(f['learning']):
|
||||
raise ValueError('Full fixed epochs')
|
||||
for k in ('learning','validation','test','c','clock_sha256','learning_nodes'):
|
||||
if job[k] != f[k]:
|
||||
raise ValueError('Original fold identity changed')
|
||||
if len(tests) != 552 or len(set(tests)) != 552:
|
||||
raise ValueError('Original552 roster')
|
||||
rows=read(c['query_roster_contract'])['rows']
|
||||
if len(rows)!=552 or {r['case'] for r in rows}!=set(tests) or len({r['component_id'] for r in rows})!=204:
|
||||
raise ValueError('552 parts /204 components query roster')
|
||||
for r in rows:
|
||||
p=pilot['parts'][r['case']]
|
||||
if r['v5_cache']['output_sha256']!=p['output_sha256'] or r['nodes']!=p['nodes'] or r['component_id']!=p['clock_group']:
|
||||
raise ValueError('Learning query/geometry/cache identity')
|
||||
if c['inputs']!=22 or c['added_parameters']!=384 or c['budget_approval']!='1795007580.895539' or not c['decision_requires_seed_reference']:
|
||||
raise PermissionError('Fixed regional context scope')
|
||||
checked(c['comparison_contract'], c['comparison_contract_sha256'])
|
||||
return c,pilot
|
||||
|
||||
|
||||
def assignment(root,c,index,digest):
|
||||
a = read(checked(root/'jobs'/str(index)/'assignment.json',digest))
|
||||
if a['id'] != index or a['contract_sha256'] != sha(root/'contract.json'):
|
||||
raise PermissionError('Assignment identity')
|
||||
return dict(c['jobs'][index], **{k:a[k] for k in ('gpu_uuid','worker_cpus','token','queue_identity')})
|
||||
|
||||
|
||||
def first_epoch_release(root,index):
|
||||
if (root/'global-stop.json').exists():
|
||||
raise RuntimeError('Global stop')
|
||||
p = root/'jobs'/str(index)/'first-epoch-projection.json'
|
||||
if not p.exists():
|
||||
return False
|
||||
d = read(p)
|
||||
if d['status'] != 'PASS' or d['contract_sha256'] != sha(root/'contract.json'):
|
||||
raise RuntimeError('First-epoch gate not passed')
|
||||
return True
|
||||
|
||||
|
||||
def project(c, charges, histories, terminal):
|
||||
if set(charges) != set(range(5)) or set(histories)-set(charges) or set(terminal)-set(charges):
|
||||
raise ValueError('Cost ledger fold identity')
|
||||
values = {}
|
||||
for i,v in charges.items():
|
||||
if not math.isfinite(v) or v < 0:
|
||||
raise ValueError('Invalid actual cost')
|
||||
if i in terminal:
|
||||
values[i] = v
|
||||
elif histories.get(i):
|
||||
rows = histories[i]
|
||||
e = max(r['epoch'] for r in rows)
|
||||
if sorted(r['epoch'] for r in rows) != list(range(1,e+1)) or e > 200:
|
||||
raise ValueError('Incomplete epoch history')
|
||||
t = max(r['train_epoch_seconds'] for r in rows)
|
||||
if not math.isfinite(t) or t <= 0:
|
||||
raise ValueError('Invalid measured epoch')
|
||||
# Factor1.5 applies to remaining training, never to already charged cost.
|
||||
validation=max(c['jobs'][i]['validation_seconds_bound'],max(r.get('validation_seconds',0) for r in rows))
|
||||
if not math.isfinite(validation) or validation<0:raise ValueError('Invalid validation timing')
|
||||
values[i] = v + 1.5*((200-e)*t+(20-e//10)*validation) + 120
|
||||
initial = (c['gpu_cap']-c['postfit_gpu_reserve']-c['preparation_charge_gpu_seconds'])/5
|
||||
median = statistics.median(values.values()) if values else initial
|
||||
for i in charges:
|
||||
if i not in values:
|
||||
values[i] = max(charges[i]+120, initial, median)
|
||||
actual = c['preparation_charge_gpu_seconds']+sum(charges.values())
|
||||
projected = c['preparation_charge_gpu_seconds']+sum(values.values())+c['postfit_gpu_reserve']
|
||||
ok = projected <= c['gpu_cap'] and actual+c['postfit_gpu_reserve'] <= c['gpu_cap']
|
||||
ok &= all(charges[i] < c['runaway_gpu_seconds'] for i in charges if i not in terminal)
|
||||
return dict(status='PASS' if ok else 'STOP_BUDGET', projected_gpu_seconds=projected,
|
||||
actual_training_and_preparation_gpu_seconds=actual,
|
||||
folds={str(i):dict(charged=charges[i], projected=values[i]) for i in charges},
|
||||
postfit_gpu_reserve=c['postfit_gpu_reserve'], safety_factor=1.5)
|
||||
Reference in new issue
Block a user