summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ep_run/fix_probe.log12
-rw-r--r--ep_run/fix_probe.py42
-rw-r--r--ep_run/t2_probe.log7
-rw-r--r--ep_run/t2_probe.py26
4 files changed, 87 insertions, 0 deletions
diff --git a/ep_run/fix_probe.log b/ep_run/fix_probe.log
new file mode 100644
index 0000000..66ccbd6
--- /dev/null
+++ b/ep_run/fix_probe.log
@@ -0,0 +1,12 @@
+(1) deep anchor: cos at matched T1
+/home/yurenh2/miniconda3/lib/python3.13/site-packages/torch/autograd/graph.py:865: UserWarning: Attempting to run cuBLAS, but there was no current CUDA context! Attempting to set the primary context... (Triggered internally at /pytorch/aten/src/ATen/cuda/CublasHandlePool.cpp:330.)
+ return Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass
+ T1=150 cos=0.9145 0.8368 mean=0.8757 (res~4.7e-03)
+ T1=400 cos=0.7801 0.8977 mean=0.8389 (res~3.9e-05)
+(2) kappa brake at T1=150:
+ kappa=0.0 cos=0.9145 0.8368 mean=0.8757
+ kappa=0.02 cos=0.9115 0.8365 mean=0.8740
+ kappa=0.05 cos=0.9114 0.8304 mean=0.8709
+ kappa=0.1 cos=0.9040 0.8238 mean=0.8639
+ kappa=0.2 cos=0.8876 0.8089 mean=0.8483
+FIX_PROBE_DONE
diff --git a/ep_run/fix_probe.py b/ep_run/fix_probe.py
new file mode 100644
index 0000000..611cf85
--- /dev/null
+++ b/ep_run/fix_probe.py
@@ -0,0 +1,42 @@
+"""The two measurement-side fixes, judged by cos(EP,BPTT) on the near-edge s2000 operator:
+(1) DEEP ANCHOR — relax 400 instead of 150 before measuring (anchor res 2.65 -> 0.046: if the
+ anchor error is the dominant amplified delta, cos jumps). Matched BPTT reference at same T1.
+(2) KAPPA BRAKE — nbrake Tikhonov leak on the nudged dynamics only (shifts the measurement
+ spectrum left by kappa, clips the non-normal transient): cos vs kappa at T1=150.
+bsub kept small for the BPTT unroll memory."""
+import torch
+import lt_ep_train as L
+from diag_cos import cos_ep_bptt
+
+torch.manual_seed(0)
+blk = L.EQBlock(512, 16, 256, 256, c=1.0, attn_mode='thick'); blk.qknorm = True
+ck = torch.load('runs/redx_traj/s2000.pt', 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("(1) deep anchor: cos at matched T1", flush=True)
+for T1, bs in ((150, 4), (400, 3)):
+ cs = []
+ for idx, y in batches:
+ try:
+ c, r = cos_ep_bptt(blk, idx, y, T1, 20, 0.1, 0.02, holo=2, hr=0.02, t2sel=40, bsub=bs)
+ except torch.cuda.OutOfMemoryError:
+ torch.cuda.empty_cache()
+ c, r = cos_ep_bptt(blk, idx, y, T1, 20, 0.1, 0.02, holo=2, hr=0.02, t2sel=40, bsub=2)
+ cs.append(c)
+ print(f" T1={T1:<4} cos={' '.join(f'{c:.4f}' for c in cs)} mean={sum(cs)/len(cs):.4f} (res~{r:.1e})", flush=True)
+
+print("(2) kappa brake at T1=150:", flush=True)
+for kap in (0.0, 0.02, 0.05, 0.1, 0.2):
+ blk.nbrake = kap
+ cs = []
+ for idx, y in batches:
+ c, _ = cos_ep_bptt(blk, idx, y, 150, 20, 0.1, 0.02, holo=2, hr=0.02, t2sel=40, bsub=4)
+ cs.append(c)
+ print(f" kappa={kap:<5} cos={' '.join(f'{c:.4f}' for c in cs)} mean={sum(cs)/len(cs):.4f}", flush=True)
+blk.nbrake = 0.0
+print("FIX_PROBE_DONE", flush=True)
diff --git a/ep_run/t2_probe.log b/ep_run/t2_probe.log
new file mode 100644
index 0000000..f0a9814
--- /dev/null
+++ b/ep_run/t2_probe.log
@@ -0,0 +1,7 @@
+/home/yurenh2/miniconda3/lib/python3.13/site-packages/torch/autograd/graph.py:865: UserWarning: Attempting to run cuBLAS, but there was no current CUDA context! Attempting to set the primary context... (Triggered internally at /pytorch/aten/src/ATen/cuda/CublasHandlePool.cpp:330.)
+ return Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass
+t2sel=40 cos=0.9145 0.8368 0.9153 mean=0.8889
+t2sel=80 cos=0.9631 0.8890 0.9561 mean=0.9361
+t2sel=160 cos=0.9651 0.8781 0.8942 mean=0.9124
+t2sel=320 cos=0.9651 0.8781 0.8748 mean=0.9060
+T2_PROBE_DONE
diff --git a/ep_run/t2_probe.py b/ep_run/t2_probe.py
new file mode 100644
index 0000000..9463ba0
--- /dev/null
+++ b/ep_run/t2_probe.py
@@ -0,0 +1,26 @@
+"""Adjoint-truncation hypothesis: the cos(EP,BPTT) ceiling at near-edge operators is the finite-T2
+window (adjoint needs ~1/|Re mu| ~ 50-500 steps there; deep-contraction ops converge fast -> 0.98).
+Sweep the tracking window t2sel in {40, 80, 160, 320} at s2000, everything else fixed (bsub=4, T1=150,
+3 batches). Prediction: cos climbs with window; the climb rate quantifies the truncation bias that the
+2.40-plateau memory called the 'estimator bias-floor'."""
+import torch
+import lt_ep_train as L
+from diag_cos import cos_ep_bptt
+
+torch.manual_seed(0)
+blk = L.EQBlock(512, 16, 256, 256, c=1.0, attn_mode='thick'); blk.qknorm = True
+ck = torch.load('runs/redx_traj/s2000.pt', 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(3)]
+
+for w in (40, 80, 160, 320):
+ cs = []
+ for idx, y in batches:
+ c, _ = cos_ep_bptt(blk, idx, y, 150, 20, 0.1, 0.02, holo=2, hr=0.02, t2sel=w, bsub=4)
+ cs.append(c)
+ print(f"t2sel={w:<4} cos={' '.join(f'{c:.4f}' for c in cs)} mean={sum(cs)/len(cs):.4f}", flush=True)
+print("T2_PROBE_DONE", flush=True)