summaryrefslogtreecommitdiff
path: root/ep_run/eval_relax_s3200.py
diff options
context:
space:
mode:
authorYuren Hao <yurenh2@illinois.edu>2026-07-03 05:56:50 -0500
committerYuren Hao <yurenh2@illinois.edu>2026-07-03 05:56:50 -0500
commitb83947778e2c776f757a07d4719b7ce961d7ed55 (patch)
treeb9cc01d7adda691d9156d9d04f4fb2f644674e96 /ep_run/eval_relax_s3200.py
Initial commit: ept — backprop-free equilibrium transformer (EP)
Code (ep_run/), organized docs (docs/{method,campaign,hardware,outreach,paper}), analysis scripts (scripts/), ONBOARDING.md entry point. Large data/checkpoints git-ignored (share separately). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014FAPDWQ49M5Ye3NpTndTpn
Diffstat (limited to 'ep_run/eval_relax_s3200.py')
-rw-r--r--ep_run/eval_relax_s3200.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/ep_run/eval_relax_s3200.py b/ep_run/eval_relax_s3200.py
new file mode 100644
index 0000000..49a8316
--- /dev/null
+++ b/ep_run/eval_relax_s3200.py
@@ -0,0 +1,23 @@
+import torch, pickle, math
+from pathlib import Path
+import lt_ep_train as L
+from lt_ep_train import EQBlock
+L.DD=Path('data/tinystories_bpe'); L.vocab=pickle.load(open(L.DD/'meta.pkl','rb'))['vocab_size']
+dev='cuda'; eps=0.1; B=8; T=256; N=6000
+torch.manual_seed(1234); idx,y=L.get_batch('val',B,T); idx=idx.to(dev) if hasattr(idx,'to') else idx
+blk=EQBlock(512,16,256,256,s=1.0,c=1.0,attn_mode='thick'); blk.qknorm=True
+ck=torch.load('runs/redx_traj/s3200.pt',map_location=dev)
+with torch.no_grad():
+ for p,w in zip(blk.allp,ck['allp']): p.copy_(w.to(dev))
+ xin=blk.embed(idx).detach(); z=xin.clone(); ress=[]
+ for t in range(N):
+ z2=z+eps*blk.force(z,xin).detach()
+ r=(z2-z).norm().item()/(z.norm().item()+1e-9); ress.append(r); z=z2
+ if not math.isfinite(r) or r>1e3: print(f"DIVERGED at t={t} r={r:.2e}"); break
+print("=== eval_relax redx s3200 (marginal, val 2.74) : CONVERGE-slow (rho<1) or LIMIT-CYCLE (floor/oscillate)? ===")
+for t in [50,150,500,1000,2000,4000,5999]:
+ if t<len(ress): print(f" res(t={t:4d}) = {ress[t]:.3e}")
+tail=ress[-1000:] if len(ress)>=1000 else ress
+mono=all(tail[i]>=tail[i+1]-1e-12 for i in range(len(tail)-1))
+print(f" tail(last1000): min={min(tail):.2e} max={max(tail):.2e} last={ress[-1]:.2e} monotone_decreasing={mono}")
+print(" VERDICT: res->~1e-5 monotone => SLOW CONVERGENCE (rho<1, finite-horizon budget); floored ~1e-2 + non-monotone => LIMIT CYCLE (forward non-convergence)")