Files
MeltMind/tools/g1_registration_checkpoint.py

27 lines
2.2 KiB
Python

"""First fixed-rank block cost projection; no fitting or changes to k/thresholds."""
from statistics import mean
def first_block_projection(records,total_pairs):
if len(records)!=100:raise ValueError('First checkpoint requires exactly 100 terminal pairs')
cpu=[r['cpu_seconds'] for r in records];good=[r for r in records if r['status']=='PASS']
failed=len(records)-len(good);starts=sum(r.get('max_starts_per_branch',14)>=14 for r in records)
central=mean(cpu)*total_pairs/3600
successes=mean(r['cpu_seconds'] for r in good)*total_pairs/3600 if good else central
loads=[r.get('geometry_load_wall_seconds',0) for r in good]
load_delta=max(loads)-mean(loads) if loads else 0
sensitivity=max(central,successes)+load_delta*total_pairs/3600
by_cohort={str(heavy):[r['cpu_seconds'] for r in good if (r.get('max_starts_per_branch',0)>=14)==heavy] for heavy in [False,True]}
reasons=[]
if failed/100>.02:reasons.append('failure_rate_over_2_percent')
if starts/100>.85:reasons.append('fourteen_or_more_start_share_over_85_percent')
if max(central,sensitivity)>100:reasons.append('projected_worker_cpu_over_100_hours')
return {'pairs':100,'total_queue_pairs':total_pairs,'mean_worker_cpu_seconds':mean(cpu),
'projected_worker_cpu_hours':central,'successful_pair_mean_projection_hours':successes,
'high_load_as_cpu_sensitivity_hours':sensitivity,'fourteen_or_more_start_pairs':starts,
'fourteen_or_more_start_share':starts/100,'failed_pairs':failed,
'worker_cpu_by_start_cohort':{k:mean(v) if v else None for k,v in by_cohort.items()},
'geometry_load_wall_seconds_mean':mean(loads) if loads else None,'geometry_load_wall_seconds_max':max(loads) if loads else None,
'cache_note':'OS cache not flushed; fingerprint preparation warms it. Measured NPZ/hash load included in worker CPU. High-load sensitivity charges max-minus-mean observed load wall time as extra CPU, not a measured cold-cache guarantee.',
'sampling_note':'First 100 in fixed min-rank order; not a random cost sample or certified upper bound',
'decision':'STOP_AND_REPORT' if reasons else 'CONTINUE','stop_reasons':reasons}