summaryrefslogtreecommitdiff
path: root/experiments/kp_dynamic_projection_development.py
blob: 1a6be9068373059e0f047110464ebfd8dec0e15c (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
#!/usr/bin/env python3
"""Run the sole frozen D1 dynamic neutral-projection candidate."""
import argparse
import json
import os
import subprocess
import sys


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--device", default="cuda")
    parser.add_argument("--dry_run", action="store_true")
    parser.add_argument(
        "--s0_gate", default="results/kp_innovation_stability_gate.json")
    parser.add_argument(
        "--out", default="results/kp_dynamic_projection/dynamic.json")
    args = parser.parse_args()
    with open(args.s0_gate) as handle:
        gate = json.load(handle)
    if (gate.get("protocol") != "kp_stability_margin_training_prefix_v1"
            or gate.get("status") != "failed_no_eligible_margin"):
        raise ValueError("D1 requires the audited failed S0 gate")
    command = [
        sys.executable,
        "experiments/diagnose_kp_traffic_nonfinite.py",
        "--rule", "innovation",
        "--predictor_mode", "closed_form",
        "--predictor_every", "0",
        "--stability_margin", "0",
        "--neutral_projection",
        "--device", args.device,
        "--max_steps", "352",
        "--out", args.out,
    ]
    print(" ".join(command), flush=True)
    if not args.dry_run:
        os.makedirs(os.path.dirname(os.path.abspath(args.out)), exist_ok=True)
        subprocess.run(command, check=True)


if __name__ == "__main__":
    main()