zefancainlp's picture
download
raw
5.32 kB
"""GPU verification of original and split Step0, with no model API calls."""
import argparse
from concurrent.futures import ThreadPoolExecutor
import json
from pathlib import Path
import time
import traceback
import uuid
from common import atomic, read, sha, IMAGE
from pool_judge import Client
def run(root):
plan = read(root / 'control/plan.json')
client = Client(plan['judge_url'], plan['judge_token'], root.name)
health = client.health()
states = health['states']
if [s['gpu'] for s in states] != [6, 7] or any(s['pids'] or s['memory_mib'] >= 100 or s['temperature'] >= 75 for s in states):
raise RuntimeError('Authorized idle H100 pair unavailable')
codes = {name: (root / 'inputs' / ('kernel.Step0.' + name + '.py')).read_text() for name in ['original', 'split']}
rows = []
def evaluate(pair):
name, gpu = pair
code = codes[name]
rid = sha(root.name + '-calibration-' + name + str(gpu))[:32]
result = client._request('/evaluate', dict(code=code, request_id=rid, timeout=530, gpu=gpu), timeout=3600)
if result.get('infrastructure_error'):
raise RuntimeError(result['infrastructure_error'])
if result.get('program_sha256') != sha(code) or result.get('canonical_image_config_sha256') != IMAGE:
raise RuntimeError('Calibration code/image mismatch')
atomic(root / 'control/calibration_runs' / (name + '-gpu' + str(gpu) + '.json'), result)
print(json.dumps(dict(program=name, gpu=gpu, correctness=result['correctness'], score_us=result['score_us'])), flush=True)
return dict(program=name, **result)
with ThreadPoolExecutor(2) as ex:
rows.extend(ex.map(evaluate, [('original', 6), ('split', 7)]))
rows.extend(ex.map(evaluate, [('split', 6), ('original', 7)]))
if not all(r['correctness'] == 1 for r in rows):
raise RuntimeError('Original/split full correctness verification failed; no API launch')
root_us = next(r['score_us'] for r in rows if r['program'] == 'split' and r['gpu_index'] == 6)
proof = dict(success=True, image=IMAGE, gpu_uuids=[s['uuid'] for s in states],
runs=rows, new_root_us=root_us, new_root_source='actual split Step0 on primary GPU6',
official_correctness_cases=18, official_timing_cases=7, paid_requests=0, time=time.time())
atomic(root / 'control/gpu_preflight.json', proof)
code = codes['split']
best = dict(type='State', id=str(uuid.uuid5(uuid.NAMESPACE_URL, sha(code))), timestep=0,
code=code, value=-root_us, construction=[])
payload = dict(schema='ttt-shared-step0-v1', task='trimul', policy_updates=0,
best_candidate=best, baseline_sampler=dict(states=[best], initial_states=[]),
candidates=[dict(state=best, parent=None)], provenance=dict(
original_program_sha256=sha(codes['original']), split_program_sha256=sha(code),
original_historical_us=5472.479937439972, root_score_remeasured=True,
original_ast_restored_by_reinlining=True, operations_unchanged=True,
starting_policy='fresh base', trained_weights_imported=False))
atomic(root / 'control/shared_step0.json', payload)
plan['step0_sha256'] = sha((root / 'control/shared_step0.json').read_bytes())
atomic(root / 'control/plan.json', plan)
(root / 'control/plan.json').chmod(0o600)
scientific = dict(task='trimul', method='single_anchor_private', new_steps=3,
shared_Step0_sha256=plan['step0_sha256'], Step0_resampled=False, Step0_updated=False,
starting_program='modularized Step0, 3 to 10 functions; same computations',
initial_policy='fresh base LoRA; no old weights/Adam imported', model='openai/gpt-oss-120b',
lora_rank=32, learning_rate=4e-5, temperature=1., kl_penalty_coef=.1,
groups=8, group_size=64, total_new_episodes=1536, phase1_max_tokens=26000,
context_window=32768, eval_timeout=530, batch_grading_deadline=None,
official_correctness_cases=18, official_timing_cases=7, judge_image=IMAGE,
reward='correct ? 1500 / geometric_mean_latency_us : 0',
advantage='original entropic_adaptive_beta; candidate-weight KL=ln(2)',
loss='importance_sampling', parent_selection='original PUCT and top2 per parent',
training_data='original 512 trajectories and own rewards only', extra_search_evaluations=0,
extra_probes=0, value_model=False, model_backend='Tinker API',
evaluator_transport='unchanged Docker judge; one candidate per GPU; two independent GPUs',
judge_node=plan['judge_node'], judge_gpus=[6, 7], root_us=root_us,
checkpoint_storage='node adapters/tree/rollouts only; export, verify, delete temporary cloud copy',
optimizer_storage='live API actor only; node adapter is not an Adam checkpoint')
atomic(root / 'control/scientific_config.json', scientific)
print(json.dumps(dict(success=True, root_us=root_us, paid_requests=0)), flush=True)
if __name__ == '__main__':
p = argparse.ArgumentParser()
p.add_argument('--root', type=Path, required=True)
root = p.parse_args().root
try:
run(root)
except BaseException as exc:
atomic(root / 'control/calibration_failure.json', dict(error=repr(exc), traceback=traceback.format_exc()))
raise

Xet Storage Details

Size:
5.32 kB
·
Xet hash:
6cdf00b81de0a548bdd9caa6530ce0747f0dec4681057170019baf80180b4569

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.