add read-only capture diagnostic for the 4096-cap parity bug
Browse files461 unmodified lines462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491461 unmodified linesreport["row_fresh_raw_vs_behavior"] = stats([abs(a - b) for a, b in zip(fresh_raw, behavior)])print("\n== which stored array does each recomputation reproduce? ==")for key in ("padded_vs_row_fresh_T", "padded_fresh_T_vs_behavior","padded_fresh_T_vs_stored_trainer", "row_fresh_T_vs_behavior","row_fresh_T_vs_stored_trainer"):if key in report:r_ = report[key]elif key == "row_fresh_T_vs_behavior":r_ = report["guard_fresh_T_vs_behavior"]else:r_ = report["trainer_fresh_T_vs_stored_trainer"]print(f" {key:36s} mean={r_['mean']:.6f} p99={r_['p99']:.4f} "f"max={r_['max']:.4f} >0.5={r_['above_0p5']}")print(" temperature probe on the TRAINER side (raw reference):")for key in ("row_fresh_raw_vs_stored_trainer", "padded_fresh_raw_vs_stored_trainer"):r_ = report[key]print(f" {key:34s} mean={r_['mean']:.6f} p99={r_['p99']:.4f} "f"max={r_['max']:.4f} >0.5={r_['above_0p5']}")close = {"padded": report["padded_fresh_T_vs_stored_trainer"]["max"],"row": report["trainer_fresh_T_vs_stored_trainer"]["max"]}report["which_recomputation_matches_the_trainer_array"] = ("padded_batch" if close["padded"] < close["row"] / 3 else"per_row" if close["row"] < close["padded"] / 3 else "neither_clearly")print(f" => the trainer's stored array is reproduced by: "f"{report['which_recomputation_matches_the_trainer_array']}"f" (padded max={close['padded']:.4f}, row max={close['row']:.4f})")d_raw = [abs(a - b) for a, b in zip(fresh_raw, behavior)]d_trainer = [abs(a - b) for a, b in zip(fresh_T, trainer)]d_trainer_raw = [abs(a - b) for a, b in zip(fresh_raw, trainer)]461 unmodified lines462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502461 unmodified linesreport["row_fresh_raw_vs_behavior"] = stats([abs(a - b) for a, b in zip(fresh_raw, behavior)])print("\n== which stored array does each recomputation reproduce? ==")# Tolerant lookup: the guard comparisons are built further down, and an earlier# build of this block indexed them directly and crashed before printing the# engine cross-check (the padded numbers had already printed, so the root cause# was still visible -- but a crash must not truncate the report).for key, alias in (("padded_vs_row_fresh_T", None),("padded_fresh_T_vs_behavior", None),("padded_fresh_T_vs_stored_trainer", None),("row_fresh_T_vs_behavior", "guard_fresh_T_vs_behavior"),("row_fresh_T_vs_stored_trainer","trainer_fresh_T_vs_stored_trainer")):r_ = report.get(key) or (report.get(alias) if alias else None)if not r_:print(f" {key:36s} (not available yet in this build)")continuereport.setdefault(key, r_)print(f" {key:36s} mean={r_['mean']:.6f} p99={r_['p99']:.4f} "f"max={r_['max']:.4f} >0.5={r_['above_0p5']}")print(" temperature probe on the TRAINER side (raw reference):")for key in ("row_fresh_raw_vs_stored_trainer", "padded_fresh_raw_vs_stored_trainer"):r_ = report.get(key)if not r_:continueprint(f" {key:34s} mean={r_['mean']:.6f} p99={r_['p99']:.4f} "f"max={r_['max']:.4f} >0.5={r_['above_0p5']}")padded_ref = report.get("padded_fresh_T_vs_stored_trainer")row_ref = report.get("row_fresh_T_vs_stored_trainer") or report.get("trainer_fresh_T_vs_stored_trainer")if padded_ref and row_ref:close = {"padded": padded_ref["max"], "row": row_ref["max"]}report["which_recomputation_matches_the_trainer_array"] = ("padded_batch" if close["padded"] < close["row"] / 3 else"per_row" if close["row"] < close["padded"] / 3 else "neither_clearly")print(f" => the trainer's stored array is reproduced by: "f"{report['which_recomputation_matches_the_trainer_array']}"f" (padded max={close['padded']:.4f}, row max={close['row']:.4f})")d_raw = [abs(a - b) for a, b in zip(fresh_raw, behavior)]d_trainer = [abs(a - b) for a, b in zip(fresh_T, trainer)]d_trainer_raw = [abs(a - b) for a, b in zip(fresh_raw, trainer)]
diag/diagnose_parity_capture.py+29-18