80 lines
7.8 KiB
Python
80 lines
7.8 KiB
Python
"""Metadata and opaque hashes only; original552 B13 cache, no new geometry/labels/fits."""
|
|
import time
|
|
from pathlib import Path
|
|
from phase2_h1_worker_v2 import checked,sha,save
|
|
from phase3_item_b_common import ROOT,read
|
|
from phase2_gate_outcome_review import validate_review
|
|
from track_a_h2_prepare import local_code_closure
|
|
from phase3_shared_capacity import PHASE_RESERVES
|
|
|
|
B=Path(__file__).resolve().parents[1]
|
|
H=Path('/home/frank14f/MeltMind-runs')
|
|
|
|
|
|
def main():
|
|
start=time.process_time()
|
|
if ROOT.exists():raise FileExistsError('Sole item b root already exists')
|
|
prior=H/'phase3-item-1b-2026-11-18';validate_review(prior)
|
|
pc=read(prior/'contract.json');pilot=read(pc['pilot_contract'])
|
|
spec=B/'references/2026-11-18/phase3-item-b/mold-regional-context-spec.md'
|
|
checked(spec,'de120e9dc5527c01af5247a27c8cf529985c206821553bacb01be6071f2cdab5')
|
|
old=B/'artifacts/phase2-b13-e1b-2026-11-17';oc=read(old/'contract.json')
|
|
if read(old/'complete.json')['status']!='COMPLETE' or oc['new_geometry_indices'] or len(oc['reused_geometry'])!=552:
|
|
raise ValueError('Original complete552 context reuse required')
|
|
source=dict(pc['source_sha256'])
|
|
for p in [spec,prior/'contract.json',prior/'review.json',prior/'expected-review-binding.json',prior/'implementation-review-git-freeze.json',prior/'implementation-review-authorization.json',old/'contract.json',old/'features-manifest.json',old/'complete.json']:
|
|
source[str(p)]=sha(p)
|
|
entries={r['case']:r for r in read(old/'features-manifest.json')['entries']}
|
|
reused={r['case']:r for r in oc['reused_geometry']};context={}
|
|
roster={r['case']:r for r in read(pc['query_roster_contract'])['rows']}
|
|
if set(entries)!=set(roster) or len(entries)!=552:raise ValueError('Original full roster differs')
|
|
for row in oc['parts']:
|
|
case=row['case'];r=pilot['parts'][case];e=entries[case];reuse=reused[case]
|
|
if row['nodes']!=r['nodes'] or row['component_id']!=roster[case]['component_id'] or row['v5_cache']['output_sha256']!=r['output_sha256'] or row['preparation']!=roster[case]['preparation']:
|
|
raise ValueError('Frozen context node/geometry/cache/query identity')
|
|
p=old/'parts'/f"{e['index']:04d}";result=read(checked(p/'result.json',e['result_sha256']))
|
|
if reuse['index']!=e['index'] or reuse['result_sha256']!=e['result_sha256'] or reuse['extra_sha256']!=result['extra_sha256'] or result['case']!=case:
|
|
raise ValueError('Original E1b immutable reused entry differs')
|
|
if result['status'] not in ('GEOMETRY_COMPLETE','SCIENTIFIC_MISSING') or result['kind']!='B13' or result['labels_read']:
|
|
raise ValueError('Only actual scientific missingness, no engineering substitution')
|
|
extra=checked(p/'extra.npy',result['extra_sha256'])
|
|
for q in (p/'result.json',extra):source[str(q)]=sha(q)
|
|
context[case]=dict(case=case,nodes=r['nodes'],status=result['status'],result=str(p/'result.json'),result_sha256=sha(p/'result.json'),extra=str(extra),extra_sha256=sha(extra),raw_ids_sha256=r['output_sha256']['raw_ids.npy'],features_sha256=r['output_sha256']['features.npy'],component_id=row['component_id'])
|
|
jobs=[dict(j,target_steps=200*len(j['learning']),cpu_seconds=60000) for j in pc['jobs']]
|
|
files=sorted(B.glob('tools/phase3_item_b_*.py'))+[Path(__file__).resolve(),B/'tools/test_phase3_item_b.py']
|
|
codes=local_code_closure(files+sorted((B/'tools/s2_models').glob('*.py')))
|
|
for p,h in pc['code_sha256'].items():codes.setdefault(p,h)
|
|
for p,h in {**source,**codes}.items():checked(p,h)
|
|
comparison=dict(version='item-b-training-v1',spec_sha256=sha(spec),parallel_ruling='1795006714.455999',budget_ruling='1795007580.895539',entry_ruling='1795011607.907609',
|
|
folds=pilot['folds'],roster_parts=552,components=204,seed=0,epochs=200,inputs=22,added_parameters=384,
|
|
intervention='original H2 plus frozen two B13 context means and joint valid flag; full roster retained',
|
|
initialization='original shared seed0 weights and RNG preserved; encoder19->22/head83->86 added weights zero',
|
|
normalization='original19 unchanged; context mean/population scale from valid learning nodes only, unit node weighting, zero variance scale1; invalid standardized context0 flag0, valid flag1',
|
|
missingness='whole-part joint NaN only with historical SCIENTIFIC_MISSING; asymmetric/nonfinite/ID/cache errors stop',
|
|
geometry='all552 frozen B13 readouts reused by original result/extra/node/feature/geometry identity; no new METIS/partition/K/seed',
|
|
recipe='same cF FP64 residual and final200epoch schedule/seed0/MSE/AdamW/clipping/part shuffle; diagnostic validation every10 only',
|
|
baseline_models=pc['baseline_models'],seed1_root=str(H/'phase3-seed1-v2-2026-11-18'),
|
|
test=dict(requires_separate_pre_score_review=True,requires_seed_reference_for_decision=True,parts=552,components=204,
|
|
upper_delta_relativeL2_strictly_below=-.001,absolute_effect_strictly_above_absolute_pooled_seed_difference=True,
|
|
bootstrap=2000,bootstrap_seed=2026111408,paired_components=True,confidence=.95,
|
|
report=['signed means and CI','seed difference same endpoint','G valid/invalid parts and components','G subgroup paired differences','per-fold','hard last-point/Rg','tau','negative times','end-to-end runtime including uncached partition cost as unmeasured']),
|
|
postfit='only after five terminal models frozen and all workers exit; own reviewed implementation, no automatic postfit in queue',
|
|
limitations=['increment of two context columns and missingness together','benefit on invalid subset not spatial attribution','restricted development-exposed corpus not fresh family proof','not flow conservation','does not close independent type/connectivity/O1 hypotheses'])
|
|
ROOT.mkdir();save(ROOT/'comparison-contract.json',comparison)
|
|
c=dict(version='phase3-item-b-v1',approval='1795011607.907609',parallel_approval='1795006714.455999',budget_approval='1795007580.895539',
|
|
seed=0,epochs=200,new_fits=5,inputs=22,added_parameters=384,no_retry=True,gpu_cap=178200,postfit_gpu_reserve=7200,postfit_cpu_cap=3600,
|
|
phase3_gpu_cap=720000,phase_reservations=PHASE_RESERVES,preparation_charge_gpu_seconds=600,preparation_cpu_cap=600,
|
|
runaway_gpu_seconds=60000,decision_requires_seed_reference=True,dispatch_order=[0,1,2,3,4],
|
|
waiting_charge='all5 from queue start to own terminal; includes pending never-dispatched waits/failures;60s setup per fold',
|
|
projection='actual+1.5 remaining200epoch training and20 diagnostic validations+120 cleanup; total gate, no per-fold projection stop',
|
|
validation_targets_read='diagnostic only every10epochs after reviewed launch',test_targets_read=False,postfit_started=False,track_a_ledger='separate',
|
|
shared_rule_module='phase3_shared_capacity.py unchanged reviewed2ddecef3/e30612ea',capacity_adapter='b key/cap and GPU0..2 only; shared admission/registry/leases unchanged',
|
|
jobs=jobs,pilot_contract=pc['pilot_contract'],query_roster_contract=pc['query_roster_contract'],baseline_models=pc['baseline_models'],context=context,
|
|
source_sha256=source,code_sha256=codes,comparison_contract=str(ROOT/'comparison-contract.json'),comparison_contract_sha256=sha(ROOT/'comparison-contract.json'))
|
|
save(ROOT/'contract.json',c)
|
|
save(ROOT/'preparation-audit.json',dict(status='PREPARED_PENDING_ASSIST_REVIEW',contract_sha256=sha(ROOT/'contract.json'),code_files=len(codes),source_files=len(source),context_parts=len(context),valid_parts=sum(x['status']=='GEOMETRY_COMPLETE' for x in context.values()),scientific_missing_parts=sum(x['status']=='SCIENTIFIC_MISSING' for x in context.values()),opaque_cache_hashes_only=True,metadata_cpu_seconds=time.process_time()-start,labels_decoded=False,arrays_decoded=False,models_loaded=False,new_fits_started=False))
|
|
print(read(ROOT/'preparation-audit.json'))
|
|
|
|
|
|
if __name__=='__main__':main()
|