summaryrefslogtreecommitdiff
path: root/ep_run/r_sweep.py
blob: 9e941073c91c7e0b4de93d77776498e72b395fea (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
"""THE r-sweep (nudge-amplitude bias/variance dial): cos(EP,BPTT) vs r on two operators.
Estimator variance ~ (state noise / 2r)^2 amplified by the T2 dynamics (measured: 50% single-shot at
r=0.02); holomorphic bias ~ O(r^2). Winners (redx seed-maker, warm_fast record) ran hr=0.2; the
plateauing proven-scratch line ran hr=0.02 — if cos(r=0.2) >> cos(r=0.02), the default flips and part
of the 'recipe difference' story was estimator SNR all along. Track path, 2 batches per (ckpt, r)."""
import torch
import lt_ep_train as L
from diag_cos import cos_ep_bptt

CKPTS = [('s2000', 'runs/redx_traj/s2000.pt'), ('fast-adaptive@2.18', 'runs/ep_fast_adaptive.pt')]
RS = [0.02, 0.05, 0.1, 0.2, 0.4]

for name, path in CKPTS:
    torch.manual_seed(0)
    blk = L.EQBlock(512, 16, 256, 256, c=1.0, attn_mode='thick'); blk.qknorm = True
    ck = torch.load(path, map_location=L.dev)
    with torch.no_grad():
        for p, w in zip(blk.allp, ck['allp']):
            p.copy_(w.to(L.dev))
    blk.track = True
    torch.manual_seed(11)
    batches = [L.get_batch('train', 24, 256) for _ in range(2)]
    print(f"=== {name} ===", flush=True)
    for r in RS:
        cs = []
        for idx, y in batches:
            c, _ = cos_ep_bptt(blk, idx, y, 150, 20, 0.1, 0.02, holo=2, hr=r, t2sel=40)
            cs.append(c)
        print(f"  r={r:<5} cos={' '.join(f'{c:.4f}' for c in cs)}  mean={sum(cs)/len(cs):.4f}", flush=True)
print("R_SWEEP_DONE", flush=True)