File size: 2,072 Bytes
79cd64d
26d5881
 
79cd64d
 
26d5881
 
 
 
 
 
 
 
 
 
 
79cd64d
26d5881
 
 
79cd64d
26d5881
 
79cd64d
26d5881
 
 
 
 
 
 
 
 
 
 
 
 
 
79cd64d
26d5881
 
 
 
 
 
 
 
79cd64d
26d5881
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
import argparse, json, subprocess, sys, time
from datetime import datetime, timezone
from pathlib import Path

p = argparse.ArgumentParser()
p.add_argument("--degree", type=int, default=300)
p.add_argument("--path_len", type=int, default=5)
p.add_argument("--layers", type=int, default=8)
p.add_argument("--dim", type=int, default=384)
p.add_argument("--heads", type=int, default=8)
p.add_argument("--edge_epochs", type=int, default=10000)
p.add_argument("--path_epochs", type=int, default=3000)
p.add_argument("--lr", type=float, default=1e-3)
p.add_argument("--seed", type=int, default=42)
args = p.parse_args()

run_name = "hfjob_d{}_L{}_D{}_e{}_s{}".format(args.degree, args.layers, args.dim, args.edge_epochs, args.seed)
run_dir = Path("experiment_logs") / run_name
run_dir.mkdir(parents=True, exist_ok=True)

# Use absolute path from the mounted volume
training_script = "/scripts/training_status.py"

cmd = [
    sys.executable, training_script,
    "--graph", "star",
    "--degree", str(args.degree),
    "--path_len", str(args.path_len),
    "--layers", str(args.layers),
    "--dim", str(args.dim),
    "--heads", str(args.heads),
    "--edge_epochs", str(args.edge_epochs),
    "--path_epochs", str(args.path_epochs),
    "--lr", str(args.lr),
    "--seed", str(args.seed),
    "--output_dir", str(run_dir)
]

print("Running:", " ".join(cmd))
start = time.time()
try:
    res = subprocess.run(cmd, check=True, capture_output=True, text=True)
    exit_code = 0
except subprocess.CalledProcessError as e:
    exit_code = e.returncode
duration = time.time() - start

summary = {
    "run": run_name,
    "finished": exit_code == 0,
    "exit_code": exit_code,
    "duration_sec": round(duration),
    "degree": args.degree,
    "edge_epochs": args.edge_epochs,
    "path_epochs": args.path_epochs,
    "timestamp": datetime.now(timezone.utc).isoformat()
}
out = Path("repro/bundle") / f"{run_name}_summary.json"
out.parent.mkdir(parents=True, exist_ok=True)
json.dump(summary, open(out, "w"), indent=2)
print(json.dumps(summary, indent=2))