summaryrefslogtreecommitdiff
path: root/experiments/oral_a_v3_calibration_screen.py
blob: d353b3c512a8f475396afab8fe9ff02deff4728a (plain)
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
#!/usr/bin/env python3
"""Run a shard of the frozen Oral-A-v3 causal-capture screen."""
import argparse
import os
import subprocess
import sys


def main():
    parser = argparse.ArgumentParser()
    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")
    common = [
        sys.executable, "experiments/conv_run.py",
        "--mode", "sdil", "--device", args.device,
        "--depth", "20", "--width", "16", "--seed", "0",
        "--loader_seed", "0", "--batch_size", "128", "--epochs", "0",
        "--train_limit", "10000", "--val_examples", "5000",
        "--split_seed", "2027", "--eval_split", "validation",
        "--eval_every", "0", "--augment_train", "1",
        "--lr", "0.03", "--output_lr", "0.1",
        "--lr_schedule", "constant", "--warmup_epochs", "0",
        "--momentum", "0.9", "--weight_decay", "1e-4",
        "--normalization", "batchnorm", "--vectorizer_mode", "channel_gated",
        "--a_scale", "0", "--a_warmup_steps", "400",
        "--pert_sigma", "0.01", "--pert_directions", "1",
        "--pert_every", "4", "--perturb_seed", "1000",
        "--alignment_probe", "64",
    ]
    jobs = [
        ("channel_subspace_etaA0.01", common + [
            "--apical_calibration_mode", "channel_subspace",
            "--eta_A", "0.01",
            "--out", "results/oral_a_v3_calibration/channel_subspace_etaA0.01.json",
        ])
    ]
    for rate in (0.01, 0.1, 1.0):
        tag = f"vectorizer_subspace_etaA{rate}"
        jobs.append((tag, common + [
            "--apical_calibration_mode", "vectorizer_subspace",
            "--eta_A", str(rate),
            "--out", f"results/oral_a_v3_calibration/{tag}.json",
        ]))
    os.makedirs("results/oral_a_v3_calibration", exist_ok=True)
    for index, (tag, command) in enumerate(jobs):
        if index % args.num_shards != args.shard_index:
            continue
        print(tag, " ".join(command), flush=True)
        if not args.dry_run:
            subprocess.run(command, check=True)


if __name__ == "__main__":
    main()