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
|
#!/usr/bin/env python3
"""Run a deterministic shard of the frozen A2b short accuracy grid."""
import argparse
import json
import os
import subprocess
import sys
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--selection", default="results/oral_a_apical_selection.json")
parser.add_argument("--device", default="cuda")
parser.add_argument("--shard_index", type=int, default=0)
parser.add_argument("--num_shards", type=int, default=1)
parser.add_argument("--dry_run", action="store_true")
args = parser.parse_args()
if not 0 <= args.shard_index < args.num_shards:
raise ValueError("invalid shard index")
with open(args.selection) as handle:
selection = json.load(handle)
if selection["status"] != "selected":
raise ValueError("A2a did not select both vectorizer families")
common = [
sys.executable, "experiments/conv_run.py", "--device", args.device,
"--depth", "20", "--width", "16", "--seed", "0", "--loader_seed", "0",
"--batch_size", "128", "--epochs", "20", "--train_limit", "10000",
"--val_examples", "5000", "--split_seed", "2027",
"--eval_split", "validation", "--eval_every", "0", "--augment_train", "1",
"--lr_schedule", "cosine", "--warmup_epochs", "0", "--momentum", "0.9",
"--weight_decay", "1e-4", "--normalization", "batchnorm",
]
jobs = []
jobs.append(("bp_lr0.1", common + [
"--mode", "bp", "--lr", "0.1",
"--out", "results/oral_a_short/bp_lr0.1.json"]))
for rate in (0.01, 0.03, 0.1):
jobs.append((f"dfa_lr{rate}", common + [
"--mode", "dfa", "--lr", str(rate), "--output_lr", "0.1",
"--a_scale", "1", "--vectorizer_mode", "spatial_template",
"--out", f"results/oral_a_short/dfa_lr{rate}.json"]))
for mode in ("spatial_template", "channel_gated"):
chosen = selection["selected"][mode]
for rate in (0.01, 0.03, 0.1):
tag = f"sdil_{mode}_lr{rate}"
jobs.append((tag, common + [
"--mode", "sdil", "--lr", str(rate), "--output_lr", "0.1",
"--vectorizer_mode", mode,
"--a_scale", str(chosen["a_scale"]),
"--eta_A", str(chosen["eta_A"]), "--a_warmup_steps", "100",
"--pert_sigma", "0.01", "--pert_directions", "1",
"--pert_every", "4", "--alignment_probe", "32",
"--out", f"results/oral_a_short/{tag}.json"]))
os.makedirs("results/oral_a_short", exist_ok=True)
selected_jobs = [job for index, job in enumerate(jobs)
if index % args.num_shards == args.shard_index]
for tag, command in selected_jobs:
print(tag, " ".join(command), flush=True)
if not args.dry_run:
subprocess.run(command, check=True)
if __name__ == "__main__":
main()
|