summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuren Hao <yurenh2@illinois.edu>2026-07-07 05:48:58 -0500
committerYuren Hao <yurenh2@illinois.edu>2026-07-07 05:48:58 -0500
commited367116af71e4688cb3154fa85b20cdca564b32 (patch)
tree0799484b66298c46fbe2b2e8d28c6d2644ed7af6
parent6604a012b96ea9b18d95fabf152072c8728df31b (diff)
SPECTRAL GOVERNOR (--governor): the from-scratch recipe candidate, dip-map-calibrated
Dip screening (4/4 seeds have dips; first-dip cluster 1200-1700, width 100-300 steps, depth |lam|~0.998 = s2000-class; s2 shows excursion->dip in sequence): reg-free until a scout (warm lead_rho, every gov_k=100, deep-400 subbatch) flags rho<0.985 after gov_min=1000, then ARPACK-certify all top-3 |lam|<1 -> leash ON (pair regs). Post-engagement: sustained rho_scout>1.02 x2 -> rescue boost (resreg x3 for 500 steps; the proven hr2 maneuver). abl_delay's fixed-2000 death explained: it engaged AFTER the dip cluster, mid-excursion. Two governor seeds launched on 107 (trained-state engagement is Pascal-safe per hr2 precedent). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014FAPDWQ49M5Ye3NpTndTpn
-rw-r--r--ep_run/lt_ep_train.py40
1 files changed, 38 insertions, 2 deletions
diff --git a/ep_run/lt_ep_train.py b/ep_run/lt_ep_train.py
index 0fd9180..2e555f9 100644
--- a/ep_run/lt_ep_train.py
+++ b/ep_run/lt_ep_train.py
@@ -491,6 +491,11 @@ def main():
ap.add_argument('--holoavg', action='store_true') # trend-aware stop + plateau-avg track (gate: 0.913->0.936 @t2sel160)
ap.add_argument('--fastfp', action='store_true') # Anderson-accelerated free phase (pure-speed opt-in; alters resreg semantics)
ap.add_argument('--bf16polish', type=int, default=0) # bf16 bulk relax + fp32 last-K polish (0=off; gate before use)
+ ap.add_argument('--governor', action='store_true') # spectral governor: reg-free until a certified stability DIP, then leash; rescue-boost on breakout
+ ap.add_argument('--gov_min', type=int, default=1000) # no engagement before this step (dip cluster: 1200-1700 per dipfarm)
+ ap.add_argument('--gov_k', type=int, default=100) # scout cadence (steps)
+ ap.add_argument('--gov_scout', type=float, default=0.985) # scout rho threshold to trigger ARPACK confirmation
+ ap.add_argument('--gov_boost', type=float, default=3.0) # resreg multiplier during rescue mode
ap.add_argument('--rt_final', type=float, default=0.0) # anneal res_target to this (0=off), 25%-75% of run
ap.add_argument('--nudge_brake', type=float, default=0.0) # kappa: anchor spring during nudge (Tikhonov adjoint)
ap.add_argument('--init_ckpt', type=str, default='') # warm-start weights from a saved ckpt
@@ -634,15 +639,46 @@ def main():
print(f"[fingerprint] ckpt={cfg.init_ckpt or 'scratch'} | res={fp['res']:.2e} cos(EP,BPTT)={fp['cos']:.4f} "
f"rho={fp['rho']:.5f} Re_mu={fp['mu_re']:+.4f} val={fp['val']:.4f}", flush=True)
return
+ gov = {'engaged': not cfg.governor, 'boost_until': 0, 'hi': 0, 'cache': {}}
for step in range(start_step, cfg.steps + 1):
+ if cfg.governor and step % cfg.gov_k == 0 and step > 0:
+ from eig_control import lead_rho
+ idxg, _ = get_batch('train', 4, cfg.T)
+ xing = blk.embed(idxg).detach()
+ zg = relax(blk, xing.clone(), xing, 400, cfg.eps)
+ _, rho_s, _mu_s = lead_rho(blk, zg, cfg.eps, blk.c, gov['cache'], iters=8)
+ if not gov['engaged'] and step >= cfg.gov_min and rho_s < cfg.gov_scout:
+ import numpy as _np, scipy.sparse.linalg as _sla # ARPACK dip confirmation
+ _sh, _n = zg.shape, zg.numel()
+ _kk = 1.0 - cfg.eps * (1.0 + blk.c)
+ def _mv(x, z=zg, sh=_sh):
+ v = torch.from_numpy(_np.asarray(x, dtype=_np.float32)).to(dev).view(sh)
+ with torch.no_grad():
+ Mv = _kk * v + cfg.eps * torch.autograd.functional.jvp(blk.nc_force, z, v)[1]
+ return Mv.reshape(-1).double().cpu().numpy()
+ try:
+ _vals = _sla.eigs(_sla.LinearOperator((_n, _n), matvec=_mv, dtype=_np.float64),
+ k=3, which='LM', return_eigenvectors=False, maxiter=1500, tol=2e-4)
+ if all(abs(l) < 1.0 for l in _vals):
+ gov['engaged'] = True
+ print(f"[governor] DIP CERTIFIED @step {step}: " +
+ " ".join(f"{abs(l):.5f}" for l in _vals) + " -> leash ON", flush=True)
+ except Exception as _e:
+ print(f"[governor] confirm failed {type(_e).__name__}", flush=True)
+ elif gov['engaged']:
+ gov['hi'] = gov['hi'] + 1 if rho_s > 1.02 else 0
+ if gov['hi'] >= 2 and step >= gov['boost_until']:
+ gov['boost_until'] = step + 500
+ print(f"[governor] breakout (rho_scout {rho_s:.4f}) -> rescue boost x{cfg.gov_boost} until {gov['boost_until']}", flush=True)
idx, y = get_batch('train', cfg.B, cfg.T)
if cfg.mode == 'ep':
sw = hw_swap() if hw_on else None
- dly = step < cfg.reg_delay # reg-free early phase (magic-ckpt hypothesis: reach the edge unleashed)
+ dly = (step < cfg.reg_delay) or (cfg.governor and not gov['engaged'])
+ _rr = cfg.resreg * (cfg.gov_boost if step < gov['boost_until'] else 1.0)
grads, res = ep_step(blk, idx, y, cfg.T1, cfg.T2, cfg.eps, cfg.beta, 0.0 if dly else jr,
cfg.holo, cfg.hr,
cfg.t1max, cfg.res_est, cfg.t2sel, cfg.corr_every, cfg.res_gate,
- 0.0 if dly else cfg.resreg,
+ 0.0 if dly else _rr,
cfg.eigreg, cfg.eig_margin, 0.0 if dly else cfg.floss,
cfg.floss_q, cfg.floss_rho, cfg.floss_bsub)
if sw is not None: