File size: 3,095 Bytes
8f46582
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env python3
"""Write L15 diag configs with SEPARATE promote vs backtrack gates.

Naming: diag_L15_prom{F|CE}{thr}_bt{F|CE|NONE}{thr}
  promF095  = promote on hop-accuracy (frontier) >= 0.95
  btCE090   = backtrack on both-arms score (ce_score) < 0.90
  btNONE    = no backtracking
"""
from pathlib import Path

ROOT = Path(__file__).resolve().parents[1] / "args"

TEMPLATE = """\
# L15 DIAG — SEPARATE gates
#   PROMOTE   (stage i -> i+1): {promote_metric} >= {promote_threshold}
#   BACKTRACK (retrain earlier): {bt_desc}
project: coconut
save_path: ckpts
name: "{name}"

only_eval: False
coconut: True
cot: False
no_thoughts: False
no_cot: False

c_thought: 1
max_latent_stage: 15
pad_latent_to_max: True

accuracy_staging: True
init_stage: 0
promote_metric: {promote_metric}
promote_threshold: {promote_threshold}
promote_on_current_only: {promote_on_current_only}
epochs_per_stage: 25

backtrack: {backtrack}
backtrack_metric: {backtrack_metric}
backtrack_detect_threshold: {backtrack_detect_threshold}
remember_rate: 0.3
revert_staging: False

eval_every: 10
log_every: 5
perhop_val_samples: 256
perhop_train_samples: 64
eval_print_full: False

backprop_depth: null
train_size: 50000
save_only_improve: False
save_every: 200
uniform_prob: 0.1
model_id: configs/symbol-2layer-8head-768dim-L20.json
load_model_path: ckpts/star-coconut-L15-bfs-stage0-warm/checkpoint_99
seed: 0
resume: 0
bf16: True
train_path: data/star_2arm_L15_train_fo_bfs.json
val_path: data/star_2arm_L15_valid_fo_bfs.json
reset_optimizer: False
batch_size_training: 128
debug: False
gradient_accumulation_steps: 1
num_epochs: 3000
lr: !!float "1e-4"
grad_clip: !!float "1.0"
warmup_steps: 200
weight_decay: 0.01
bfs_variant: True
"""

# (basename, promote_metric, promote_thr, bt_on, bt_metric, bt_thr, prom_cur_only)
ARMS = [
    ("diag_L15_promF095_btCE050", "frontier", 0.95, True, "ce_score", 0.50, False),
    ("diag_L15_promF095_btCE090", "frontier", 0.95, True, "ce_score", 0.90, False),
    ("diag_L15_promF095_btCE095", "frontier", 0.95, True, "ce_score", 0.95, False),
    ("diag_L15_promF099_btCE090", "frontier", 0.99, True, "ce_score", 0.90, False),
    ("diag_L15_promF095_btF095", "frontier", 0.95, True, "frontier", 0.95, False),
    ("diag_L15_promCE090_btCE090", "ce_score", 0.90, True, "ce_score", 0.90, False),
    ("diag_L15_promF095_btNONE", "frontier", 0.95, False, "frontier", 0.95, True),
    ("diag_L15_promF099_btCE050", "frontier", 0.99, True, "ce_score", 0.50, False),
]


def main():
    for name, pm, pt, bt, bm, bt_thr, cur_only in ARMS:
        bt_desc = "OFF" if not bt else f"{bm} < {bt_thr} triggers retrain"
        text = TEMPLATE.format(
            name=name,
            promote_metric=pm,
            promote_threshold=pt,
            promote_on_current_only=str(cur_only),
            backtrack=str(bt),
            backtrack_metric=bm,
            backtrack_detect_threshold=bt_thr,
            bt_desc=bt_desc,
        )
        path = ROOT / f"{name}.yaml"
        path.write_text(text)
        print("wrote", path.name)


if __name__ == "__main__":
    main()