"""X30-S notes (written after the runs, descriptive): (1) the PREREG section 1 self-check, recomputed from the files: x28_eval at clip 1 on X21 clL seed 0 with t-repair vs the stored X21 output; (2) the clip comparison asked by dc_presentation: the same poles checkpoints sampled at clip 1 (X30) and at their validation-chosen clip (X28's stored test runs, results/icml_r3/X28/val_clip_choice.json), and the C+phi coefficient model seed 0 at clip 1 and at its chosen clip 3. Every arm scored the same way (b = 16, J* = min(J_Fonly, X28 test joint labels), uncertified = 1e3). Run: PYTHONPATH=. python -m nonlinear.experiments.x30_siso_notes -> results/icml_r3/X30/siso/notes.txt""" import json import numpy as np E30, E28, E21 = "results/icml_r3/X30/siso/eval_test", "results/icml_r3/X28/eval_test", "results/icml_r3/X21/test_eval" def score(path, ids, Jst, b=16): z = np.load(path) assert (z["ref_i"] == ids).all() Jb = z["J"][:, :b].min(1) ok = np.isfinite(Jb) return ok.mean() * 100, np.median(np.where(ok, (Jb - Jst) / Jst, 1e3)) * 100 def main(): z0 = np.load(f"{E30}/x21_fgen_clL_best_tr_K16_clip1.npz") ids, Jst = z0["ref_i"], z0["ref_J_star"] L = ["X30-S notes (descriptive, written after the runs). Scoring: b = 16, regret vs J* = min(J_Fonly, X28 test joint labels), uncertified = 1e3."] s = np.load(f"{E21}/x21_fgen_clL_best_w1_tr.npz") J30, J21 = z0["J"][:, :16], s["J"][:, :16] c30, c21 = np.isfinite(J30), np.isfinite(J21) both = c30 & c21 rel = np.abs(J30[both] - J21[both]) / np.abs(J21[both]) F30, F21 = z0["F"][:, :16], s["F"][:, :16] if "F" in s.files else None L.append("\n== (1) PREREG self-check: x28_eval (clip 1, t-repair) on X21 clL seed 0 vs the stored X21 output (x21_fgen_clL_best_w1_tr.npz)") L.append(f" certified candidates: x28_eval {c30.sum()}, stored {c21.sum()} of {c30.size}; same certified set: {bool((c30 == c21).all())} ({int((c30 != c21).sum())} differ)") L.append(f" J on the candidates certified by both: max rel diff {rel.max():.2e}, median {np.median(rel):.2e}; within 1e-6 on {int((rel <= 1e-6).sum())} of {both.sum()}") if F21 is not None and F21.shape == F30.shape: L.append(f" sampled F identical: {bool(np.allclose(F30, F21, rtol=0, atol=0))}; max abs diff {float(np.nanmax(np.abs(F30 - F21))):.3e}") L.append(" -> " + ("PASSED" if (c30 == c21).all() and (rel <= 1e-6).all() else "FAILED: the draws differ, so every C-only arm is re-run through x28_eval (PREREG section 1)")) ch = json.load(open("results/icml_r3/X28/val_clip_choice.json")) L.append("\n== (2) clip: the same checkpoints at clip 1 (X30 runs) and at the validation-chosen clip (X28 stored test runs); t-repair on every row") rows = [("C-only poles", [("x21_fgen_clL", "x21_fgen_clL_best_tr"), ("x21_fgen_clL_s1", "x21_fgen_clL_s1_best_tr"), ("x21_fgen_clL_s2", "x21_fgen_clL_s2_best_tr")]), ("C+phi poles", [("x28_clS_s0", "x28_clS_s0_best_tr"), ("x28_clS_s1", "x28_clS_s1_best_tr"), ("x28_clS_s2", "x28_clS_s2_best_tr")]), ("C+phi coefficients", [("x28_coefS_s0", "x28_coefS_s0_best_tr")])] out = {} for name, tags in rows: a = [score(f"{E30}/{t}_best_tr_K16_clip1.npz", ids, Jst) for t, _ in tags] cl = [ch[k]["clip"] for _, k in tags] b = [score(f"{E28}/{t}_best_tr_K16_clip{c}.npz", ids, Jst) for (t, _), c in zip(tags, cl)] f = lambda r: " / ".join(f"{x:.1f}% cert, {y:.2f}%" for x, y in r) L.append(f" {name:19s} seeds {len(tags)}: clip 1: {f(a)} | chosen clip {'/'.join(cl)}: {f(b)}") out[name] = dict(clip1=a, chosen_clip=cl, chosen=b) L.append(" C-only coefficient models (X21 base): never clip-validated (X21 validated the poles model only, results/icml_r3/X21/clip_val_report.txt)") open("results/icml_r3/X30/siso/notes.txt", "w").write("\n".join(L) + "\n") json.dump(out, open("results/icml_r3/X30/siso/notes.json", "w"), indent=1) print("\n".join(L)) if __name__ == "__main__": main()