Buckets:
| """Zero-paid-work API integration preflight, then seal exact source/Step0/GPU.""" | |
| from __future__ import annotations | |
| import argparse | |
| import asyncio | |
| import json | |
| import os | |
| from pathlib import Path | |
| import re | |
| import shutil | |
| import sys | |
| import time | |
| from common import IMAGE, atomic, read, sha | |
| def prepare(root, prepared, adapters, tokenizer, transfer): | |
| if root.exists(): | |
| raise FileExistsError('Never overwrite an API experiment root') | |
| prior = read(prepared/'control/ready.json') | |
| if not prior['ready_for_user_review'] or prior['total_cpu_tests'] != 86: | |
| raise RuntimeError('Expected CPU-validated private-entry implementation') | |
| for relative, expected in prior['source_manifest'].items(): | |
| if sha((prepared/'source'/relative).read_bytes()) != expected: | |
| raise RuntimeError('Prepared native source changed: ' + relative) | |
| root.mkdir(parents=True) | |
| for name in ['control','run','code']: | |
| (root/name).mkdir() | |
| shutil.copytree(prepared/'source',root/'source',symlinks=True, | |
| ignore=shutil.ignore_patterns('__pycache__','*.pyc','.pytest_cache','.venv*')) | |
| for path in Path(__file__).parent.glob('*.py'): | |
| shutil.copy2(path,root/'code'/path.name) | |
| for name in ['api_transport.py','local_storage.py']: | |
| shutil.copy2(adapters/name,root/'code'/name) | |
| shutil.copy2(prepared/'control/shared_step0.json',root/'control/shared_step0.json') | |
| step0_hash = sha((root/'control/shared_step0.json').read_bytes()) | |
| plan = dict(task='trimul',method='single_anchor_private',maximum_new_steps=3, | |
| tokenizer=str(tokenizer),step0_sha256=step0_hash,source_preparation=str(prepared), | |
| judge_url='http://100.113.206.109:8786',judge_token=(transfer/'judge_token.txt').read_text().strip(), | |
| judge_node='n1-3/lucia6750000000',judge_gpu=1,judge_image=IMAGE, | |
| API_actor_on_node='n4-2/datava270000001',sampling_concurrency=32, | |
| launch_authorized=True,authorization='User authorized API, original Step0, three new steps; other settings unchanged') | |
| atomic(root/'control/plan.json',plan) | |
| (root/'control/plan.json').chmod(0o600) | |
| atomic(root/'control/scientific_config.json',dict(task='trimul',method='single_anchor_private',new_steps=3, | |
| shared_Step0_sha256=step0_hash,Step0_resampled=False,Step0_updated=False, | |
| 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='same original Docker image on identical isolated H100; CPU queue is not execution time', | |
| judge_node=plan['judge_node'],judge_gpu=1,checkpoint_storage='node adapters/tree/rollouts only; export, verify, delete cloud copy', | |
| optimizer_storage='live API actor only; node adapter is not an Adam checkpoint')) | |
| atomic(root/'control/status.json',dict(status='prepared_not_started',paid_requests=0,time=time.time())) | |
| def preflight(root, seal=False): | |
| os.environ.update(CUDA_VISIBLE_DEVICES='',WANDB_MODE='disabled',PYTHONDONTWRITEBYTECODE='1') | |
| sys.path[:0] = [str(root/'code'),str(root/'source')] | |
| import tinker | |
| if not hasattr(tinker.TrainingClient,'save_weights_external_async'): | |
| raise RuntimeError('Node-only weight export SDK is required') | |
| def forbidden(*a,**k): | |
| raise AssertionError('No API clients or paid computation during preflight') | |
| tinker.ServiceClient = forbidden | |
| import integration | |
| from train_api import config_for | |
| from examples.gpu_mode.env import GpuModeEnv | |
| runtime = integration.configure(root) | |
| cfg = config_for(root) | |
| dataset = asyncio.run(cfg.dataset_builder()) | |
| states = dataset.sampler._states | |
| payload = read(root/'control/shared_step0.json') | |
| if len(states)!=8 or len({s.id for s in states})!=8: | |
| raise RuntimeError('Expected eight independent parent IDs from the SAME shared Step0 program') | |
| if any(s.code!=payload['best_candidate']['code'] or s.value!=payload['best_candidate']['value'] for s in states): | |
| raise RuntimeError('Step0 root or value drift') | |
| env = integration.Env(dataset.renderer,initial_state=states[0],sampler=dataset.sampler,config=cfg.dataset_builder.config) | |
| prompt_text = env.get_question() | |
| official = GpuModeEnv.get_question(env) | |
| if not prompt_text.startswith(official) or '## Single-anchor program editing' in prompt_text: | |
| raise RuntimeError('Wrong task prefix or old method prompt leaked') | |
| prompt = dataset.renderer.build_generation_prompt([dict(role='user',content=prompt_text)]) | |
| if prompt.length>=26000: | |
| raise RuntimeError('Initial context exceeds unchanged budget') | |
| (root/'control/initial_prompt.txt').write_text(prompt_text) | |
| dataset.sampler.flush(0) | |
| proof = dict(success=True,paid_requests=0,API_actor_created=False,CUDA_initialized=False, | |
| Step0_policy_updates=0,root_us=-states[0].value,original_root_program_sha256=sha(states[0].code), | |
| shared_Step0_sha256=runtime.plan['step0_sha256'],initial_prompt_tokens=prompt.length, | |
| official_task_prompt_exact=True,eight_independent_parent_ids=True,single_step_episodes=512, | |
| new_steps=3,learning_rate=cfg.learning_rate,kl_penalty_coef=cfg.kl_penalty_coef, | |
| phase1_max_tokens=cfg.phase1_max_tokens,lora_rank=cfg.lora_rank, | |
| compiler_sha256=sha((root/'source/examples/gpu_mode/private_entry.py').read_bytes()), | |
| original_MaxRL_PUCT_untouched=True,no_component_search=True,no_extra_training_samples=True) | |
| import torch | |
| proof['CUDA_initialized'] = torch.cuda.is_initialized() | |
| if proof['CUDA_initialized']: | |
| raise RuntimeError('CPU preflight unexpectedly initialized CUDA') | |
| atomic(root/'control/cpu_preflight.json',proof) | |
| if seal: | |
| tests = (root/'control/api_cpu_tests.log').read_text() | |
| if not re.search(r'\b14 passed\b',tests) or re.search(r'\b(?:FAILED|ERRORS)\b',tests): | |
| raise RuntimeError('The 14 CPU API/transport tests must pass before launch') | |
| health = runtime.judge.health() | |
| calibration = read(root/'control/gpu_preflight.json') | |
| if not calibration['success'] or calibration['gpu_uuids'] != [s['uuid'] for s in health['states']]: | |
| raise RuntimeError('Exact timing GPU did not pass original calibration') | |
| states = health['states'] | |
| state = states[0] | |
| if any(s['pids'] or s['temperature'] >= 75 or s['memory_mib'] >= 100 for s in states): | |
| raise RuntimeError('Timing GPU currently occupied or hot') | |
| if calibration['image']!=IMAGE or not all(r['correctness']==1 for r in calibration['runs']): | |
| raise RuntimeError('Original full-program calibration failed') | |
| files = {str(p.relative_to(root)):sha(p.read_bytes()) for folder in ['code','source'] | |
| for p in (root/folder).rglob('*.py')} | |
| for name in ['plan.json','scientific_config.json','shared_step0.json','gpu_preflight.json']: | |
| files['control/'+name] = sha((root/'control'/name).read_bytes()) | |
| atomic(root/'control/ready.json',dict(ready=True,maximum_new_steps=3,paid_preflight_requests=0, | |
| CPU_tests_passed=14,CPU_test_log_sha256=sha(tests),GPU_preflight_complete=True,files=files,time=time.time())) | |
| print(json.dumps(proof),flush=True) | |
| if __name__ == '__main__': | |
| p=argparse.ArgumentParser(description=__doc__) | |
| p.add_argument('--root',type=Path,required=True) | |
| p.add_argument('--prepared',type=Path) | |
| p.add_argument('--adapters',type=Path) | |
| p.add_argument('--tokenizer',type=Path) | |
| p.add_argument('--transfer',type=Path) | |
| p.add_argument('--existing',action='store_true') | |
| p.add_argument('--seal',action='store_true') | |
| a=p.parse_args();r=a.root.resolve() | |
| if not a.existing: | |
| if any(x is None for x in [a.prepared,a.adapters,a.tokenizer,a.transfer]):p.error('Fresh preparation requires all paths') | |
| prepare(r,a.prepared,a.adapters,a.tokenizer,a.transfer) | |
| elif (r/'control/actor_create_intent.json').exists(): | |
| raise RuntimeError('Never reprepare an experiment with a paid actor intent') | |
| preflight(r,a.seal) | |
Xet Storage Details
- Size:
- 8.76 kB
- Xet hash:
- f9eeb7959f7dd14483add2928ed33d2234469e8914e1473adea6f363f85b6278
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.