backtracking sweep summarizer
Browse files
latent_multi_output_cell_policy/backtracking/summarize_sweep.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Aggregate the S2 backtracking sweep: latest frontier + per-stage eval per combo."""
|
| 3 |
+
import glob, os, re, sys
|
| 4 |
+
|
| 5 |
+
root = sys.argv[1] if len(sys.argv) > 1 else sorted(glob.glob("/home/ubuntu/bt_runs/s2_sweep_*"))[-1]
|
| 6 |
+
logs = sorted(glob.glob(os.path.join(root, "logs", "*.log")))
|
| 7 |
+
|
| 8 |
+
frontier_re = re.compile(r"eval/.*") # unused; we parse the debug-free summary lines
|
| 9 |
+
bt_re = re.compile(r"\[backtrack eval\] stage=(\d+) k=(\d+) exact=([\d.]+) prec=([\d.]+) rec=([\d.]+) solve=([\d.]+)")
|
| 10 |
+
rcur_re = re.compile(r"\[backtrack\] r_current=(\d+) min_stage_exact=([\d.]+)")
|
| 11 |
+
step_re = re.compile(r"train step (\d+)")
|
| 12 |
+
# frontier eval when backtracking is OFF prints via run_eval summary; grab solve/exact if present
|
| 13 |
+
summ_re = re.compile(r"exact_set_match_rate[\"']?\s*[:=]\s*([\d.]+)")
|
| 14 |
+
|
| 15 |
+
print(f"Sweep root: {root}\n")
|
| 16 |
+
header = f"{'combo':16} {'step':>5} {'S1 exact':>8} {'S2 exact':>8} {'S2 prec':>7} {'S2 rec':>7} {'S2 solve':>8} {'r_cur':>5}"
|
| 17 |
+
print(header)
|
| 18 |
+
print("-" * len(header))
|
| 19 |
+
for lg in logs:
|
| 20 |
+
name = os.path.basename(lg)[:-4]
|
| 21 |
+
txt = open(lg, errors="ignore").read()
|
| 22 |
+
step = step_re.findall(txt)
|
| 23 |
+
laststep = step[-1] if step else "-"
|
| 24 |
+
# collect last per-stage block
|
| 25 |
+
stages = {}
|
| 26 |
+
for m in bt_re.finditer(txt):
|
| 27 |
+
s = int(m.group(1)); stages[s] = tuple(float(x) for x in m.groups()[2:])
|
| 28 |
+
rc = rcur_re.findall(txt)
|
| 29 |
+
if stages:
|
| 30 |
+
s1 = stages.get(1, (float('nan'),)*4)[0]
|
| 31 |
+
s2 = stages.get(2, (float('nan'),)*4)
|
| 32 |
+
rcv = rc[-1][0] if rc else "-"
|
| 33 |
+
print(f"{name:16} {laststep:>5} {s1:8.3f} {s2[0]:8.3f} {s2[1]:7.3f} {s2[2]:7.3f} {s2[3]:8.3f} {rcv:>5}")
|
| 34 |
+
else:
|
| 35 |
+
# no-backtrack combos: frontier metrics not in this regex; report step only
|
| 36 |
+
print(f"{name:16} {laststep:>5} {'(no per-stage eval — control)':>50}")
|