From cbecb171b1af77fe6510fd60f1dfa4c7938a20d6 Mon Sep 17 00:00:00 2001 From: Yuren Hao Date: Sun, 5 Jul 2026 03:53:57 -0500 Subject: =?UTF-8?q?holofast:=20exact=20halved-jvp=20AEP=20track=20?= =?UTF-8?q?=E2=80=94=201.55x=20nudged=20phase,=20gradient-gate=20passed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit holo_a_track computed the doubled-batch jvp/vjp on [v0; -v0] at a shared anchor zbar — exact antisymmetric redundancy (phase deviations from the common mode are exact negatives). holo_a_track_fast computes at batch B and mirrors: single-eval parity 6e-7 (exact); trajectory-level 45% divergence SHARED with the original's own FD noise floor (1e-6 state noise -> 49% self-divergence — the 2r=0.04 finite difference amplifies fp noise; training averages it via pema/momentum). Ship gate: cos(EP,BPTT) orig vs fast indistinguishable (0.907/0.912, 0.853/0.853, 0.918/0.918). Timing 6.43->4.16s on the T2=40 nudged phase (contended GPU, relative). --holofast flag, default off; queued ablation arms deliberately stay on orig for fidelity. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_014FAPDWQ49M5Ye3NpTndTpn --- ep_run/holo_fast_parity.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 ep_run/holo_fast_parity.py (limited to 'ep_run/holo_fast_parity.py') diff --git a/ep_run/holo_fast_parity.py b/ep_run/holo_fast_parity.py new file mode 100644 index 0000000..d2df0da --- /dev/null +++ b/ep_run/holo_fast_parity.py @@ -0,0 +1,33 @@ +"""Parity + timing for holo_a_track_fast (exact halved-jvp restructure) vs holo_a_track. +Same ckpt (s2000), same batch, same T2max: a_best must match to fp noise, t_best exactly; +timing over 3 reps each (GPU contended — relative ratio is the signal).""" +import time, torch +import lt_ep_train as L +from holo_ep import holo_a_track, holo_a_track_fast + +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)) +torch.manual_seed(42) +idx, y = L.get_batch('train', 24, 256) +xin = blk.embed(idx).detach() +zs = L.relax(blk, xin.clone(), xin, 150, 0.1) + +r, T2, eps = 0.02, 40, 0.1 +a0, t0 = holo_a_track(blk, zs, xin, y, r, T2, eps) # warmup + reference +a1, t1 = holo_a_track_fast(blk, zs, xin, y, r, T2, eps) +rel = ((a1 - a0).norm() / (a0.norm() + 1e-12)).item() +cos = torch.nn.functional.cosine_similarity(a0.flatten(), a1.flatten(), dim=0).item() +print(f"parity: rel_diff={rel:.2e} cos={cos:.8f} t_best {t0} vs {t1}", flush=True) + +for name, fn in (('orig', holo_a_track), ('fast', holo_a_track_fast)): + ts = [] + for _ in range(3): + torch.cuda.synchronize(); t = time.time() + fn(blk, zs, xin, y, r, T2, eps) + torch.cuda.synchronize(); ts.append(time.time() - t) + print(f"{name}: {min(ts):.3f}s (best of 3)", flush=True) +print("HOLO_FAST_PARITY_DONE", flush=True) -- cgit v1.2.3