File size: 3,152 Bytes
13cc860
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"""Paired fresh reference: only mathematical difference is 100x effective LR."""
import copy
import datetime
import json
from pathlib import Path
import shutil
import train_reference_baseline_fresh as run

ORIGINAL = run.LOCAL
run.LOCAL = ORIGINAL.with_name('baseline_reference_highlr_20261008')
run.ARCHIVE = run.ROOT/'scale/baseline_reference_highlr_20261008'
# Reuse the immutable byte-identical source snapshot, not the scale implementation.
run.SOURCE = ORIGINAL/'source'
run.GPU = 1
run.PORT = 29637


def prepare():
    path=run.LOCAL/'fresh_config.json'
    if path.exists():
        return path
    hashes=json.loads((run.ROOT/'scale/audits/training_baseline_20261008/source_hashes.json').read_text())
    for rel,digest in hashes.items():
        if run.digest(run.SOURCE/rel)!=digest:
            raise RuntimeError(f'Reference code changed: {rel}')
    original=json.loads((ORIGINAL/'fresh_config.json').read_text())
    cfg=copy.deepcopy(original)
    cfg['exp']='baseline_reference_official_omni_random_action_highlr'
    cfg['timestamp']=datetime.datetime.now().strftime('%y%m%d%H%M%S')
    cfg['train']['learning_rate']*=100
    cfg['model']['lang_backbone_lr']*=100
    # Only writable output/cache/statistics paths are relocated.
    def relocate(value):
        if isinstance(value,dict):return {k:relocate(v) for k,v in value.items()}
        if isinstance(value,list):return [relocate(v) for v in value]
        if isinstance(value,str):return value.replace(str(ORIGINAL),str(run.LOCAL))
        return value
    cfg=relocate(cfg)
    # Kinematics remains inside the original immutable source snapshot.
    cfg['train']['jerk_kinematics_path']=original['train']['jerk_kinematics_path']
    shutil.copytree(ORIGINAL/'cache/records',run.LOCAL/'cache/records',dirs_exist_ok=True)
    shutil.copy2(ORIGINAL/'dataset_statistics.json',run.LOCAL/'dataset_statistics.json')
    if (ORIGINAL/'startup_pose_motion36.json').exists():
        shutil.copy2(ORIGINAL/'startup_pose_motion36.json',run.LOCAL/'startup_pose_motion36.json')
    # Validate all other logical fields after reversing relocation/identity changes.
    inverse=json.loads(json.dumps(cfg).replace(str(run.LOCAL),str(ORIGINAL)))
    inverse['exp']=original['exp'];inverse['timestamp']=original['timestamp']
    inverse['train']['learning_rate']=original['train']['learning_rate']
    inverse['model']['lang_backbone_lr']=original['model']['lang_backbone_lr']
    assert inverse==original, 'Unexpected non-LR configuration difference'
    assert cfg['seed']==original['seed']
    run.save(path,cfg)
    run.save(run.LOCAL/'provenance.json',dict(reference=str(ORIGINAL/'fresh_config.json'),
        only_mathematical_changes={'effective_action_lr':[1e-6,1e-4], 'effective_omni_lr':[1e-7,1e-5]},
        fresh=True,seed=cfg['seed'],gpu=1,source_hashes=hashes,
        nonmathematical_changes='run identity, output/cache paths, GPU and rendezvous port'))
    for name in ('fresh_config.json','provenance.json','dataset_statistics.json'):
        run.copy_verified(run.LOCAL/name,run.ARCHIVE/name)
    return path


if __name__=='__main__':
    run.prepare=prepare
    run.main()