scaleup_plan.py
python · 26 lines · Exact bytes
Version & provenance · foundation-20261029
Recorded SHA-256 0b8bd4d8174ba56ffb8780fbb77ee33ed519b19779ad2fc5f892dc70d95c2012Rendered SHA-256 43b87dabff90223a0ec033702309ab2e738e4c0faf96169f225a439b7116cb87
Original project code: Apache-2.0. Dependency licenses remain separate. License notes. Line links are stable within this snapshot. Allowlisted foundation training and frozen evaluation source; recorded hashes refer to original files, rendered hashes identify any path-redacted derivatives. This subset is not a standalone training distribution; no host configs, credentials, optimizer state or dataset bulk included.
1"""CPU-only four-hour planning rules; no model-result-based selection."""
2import math
3
4def choose_schedule(probe,config,remaining_seconds):
5 if probe.get('status')!='passed' or probe.get('parameters')!=85940736:raise ValueError('invalid model probe')
6 cases=probe['results']
7 if [c['shape'] for c in cases]!=['representative','longest']:raise ValueError('missing representative/longest probe')
8 for case in cases:
9 if case['microbatch_per_gpu']!=config['micro'] or case['accumulation']!=config['accum']:raise ValueError('probe configuration mismatch')
10 if len(case['memory'])!=2 or {m['rank'] for m in case['memory']}!={0,1}:raise ValueError('requires both GPUs')
11 for m in case['memory']:
12 if m['device_free_bytes_after_shape']<config['minimum_device_free_bytes']:raise ValueError('insufficient coexistence memory margin')
13 rate=cases[0]['useful_targets_per_second']
14 if isinstance(rate,bool) or not isinstance(rate,(float,int)) or not math.isfinite(rate) or rate<=0:raise ValueError('invalid measured throughput')
15 available=remaining_seconds-config['non_optimizer_reserve_seconds']
16 if available<600:raise TimeoutError('insufficient original budget after startup/probe')
17 planned_targets=available*rate*config['throughput_discount']
18 full=config['epoch_optimizer_updates'];targets=config['train_prediction_targets']
19 if full<2 or targets<=0:raise ValueError('invalid corpus planning counts')
20 horizon=max(2,min(full,math.floor(full*planned_targets/targets)))
21 return {'max_updates':full,'epochs':1,'schedule_steps':horizon,'warmup_steps':max(1,min(horizon-1,round(horizon*.05))),
22 'validation_every_steps':max(1,horizon//config['planned_validation_checks']),
23 'measured_probe_targets_per_second':rate,'planning_targets':min(targets,planned_targets),
24 'remaining_seconds_at_selection':remaining_seconds,
25 'policy':'one unique shuffled pass; continue to full-pass cap or original deadline; cosine horizon estimated from bounded coexistence probe'}
26