File size: 2,126 Bytes
8f46582
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 bash
# Summarize backtrack frequency by frontier stage for the W=1 tight-gate runs.
cd /egr/research-slim/ghoshavr/reasoning-by-superposition-main
python3 - <<'PY'
import re, sys
from collections import defaultdict

runs = [
    "L15_w1_prom098_bt098",
    "L15_w1_prom099_bt099",
    "L15_w2_prom095_bt095",
    "L15_w5_prom095_bt095",
    "L15_push_2L_ce95_100k_w1",  # baseline W=1 prom/bt 0.95
]
for name in runs:
    path = f"logs/{name}.log"
    try:
        lines = open(path, errors="ignore")
    except FileNotFoundError:
        print(f"=== {name}: no log yet ===\n")
        continue
    frontier = 6
    by = defaultdict(lambda: {"evals": 0, "bt": 0, "targets": defaultdict(int)})
    prom = 0
    ep = 0
    for line in lines:
        m = re.search(r"train epoch (\d+)/", line)
        if m:
            ep = int(m.group(1))
        m = re.search(r"PROMOTE stage (\d+) -> (\d+)", line)
        if m:
            frontier = int(m.group(2)); prom += 1
        m = re.search(r"HOLD at stage (\d+)", line)
        if m:
            frontier = int(m.group(1))
        m = re.search(r"target_stage=(\d+|None)", line)
        if m:
            by[frontier]["evals"] += 1
            if m.group(1) == "None":
                continue
            by[frontier]["bt"] += 1
            by[frontier]["targets"][int(m.group(1))] += 1
    total_e = sum(d["evals"] for d in by.values())
    total_b = sum(d["bt"] for d in by.values())
    hold = ""
    for line in open(path, errors="ignore"):
        if "[acc-stage]" in line:
            hold = line.strip()
    print(f"=== {name}  ep={ep} promotes={prom}  BT={total_b}/{total_e} ({(total_b/total_e if total_e else 0):.0%}) ===")
    print(f"  {hold}")
    print(f"  {'front':>5} {'evals':>5} {'BT':>4} {'rate':>5}  repair targets")
    for f in sorted(by):
        d = by[f]
        rate = d["bt"] / d["evals"] if d["evals"] else 0
        tops = sorted(d["targets"].items(), key=lambda x: -x[1])[:4]
        ts = ", ".join(f"s{t}x{c}" for t, c in tops) if tops else "-"
        print(f"  {f:>5} {d['evals']:>5} {d['bt']:>4} {rate:>4.0%}  {ts}")
    print()
PY