1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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)")
|