AsianPlayer/TriDrive / code /aide /eval /report_driverwm_headtohead.py
AsianPlayer's picture
download
raw
85.7 kB
#!/usr/bin/env python
"""Row-by-row head-to-head of our AIDE results against the THREE tables of the Driver-WM paper (arXiv 2605.05092v2).
Outputs (new files only): aide/results/tables/driverwm_tables_headtohead.md and .json; appends ONE row to docs/decisions.md.
Read-only on aide/results/runs. No training is launched; the runs that would complete the mirror are listed with their cost.
Sources, in order of preference:
* our geometry / semantic LEVELS (mean ± sd over seeds): `aide/results/tables/master_aide.json` (report_master_aide.py; every
value recomputed from pred_test.npz and cross-checked against metrics_test.json, 0 mismatches) — nothing is retyped;
* the 95 % CI of a group level and every PAIRED Δ: recomputed here from `pred_test.npz` with `aide/eval/metrics.py` on the
`load_split("test")` ground truth (clip bootstrap, 10k resamples, seed 0; F1: 2k joint resamples), because master_aide.json
carries no CIs; per-clip errors are averaged over the group's seeds before resampling (= CI of the seed-mean level);
* runs that master_aide.json does not group (kp+sem no-vision (ii), semantic-only, vis_pooled, recursive rollout): computed
here from pred_test.npz / metrics_test.json with the same functions;
* interventions: `aide/results/tables/run_interventions_latest.json` (aide/eval/interventions.py) with every per-run
`<run>__do_<x>/metrics_test.json` re-read and compared to the summary (tolerance 1e-6);
* published numbers: typed by the owner in the brief (OWNER_TYPED_* below) and cross-checked against
`aide/eval/paper_rows.py`; any discrepancy is reported in §0.
"""
from __future__ import annotations
import argparse
import json
import os
import sys
import time
from pathlib import Path
import numpy as np
ROOT = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(ROOT))
from aide.data import protocol as P # noqa: E402
from aide.eval import metrics as M # noqa: E402
from aide.eval.harness import align, load_split # noqa: E402
from aide.eval.paper_rows import COLS, LOWER_IS_BETTER, NON_CAUSAL, PAPER_ROWS, PAPER_T3_FULL # noqa: E402
RUNS = ROOT / "aide/results/runs"
TABLES = ROOT / "aide/results/tables"
MASTER = TABLES / "master_aide.json"
INTERV = TABLES / "run_interventions_latest.json"
OUT_MD = TABLES / "driverwm_tables_headtohead.md"
OUT_JSON = TABLES / "driverwm_tables_headtohead.json"
DECISIONS = ROOT / "docs/decisions.md"
GEO = ("mpjpe_all", "dn_mpjpe", "mpjpe_hm", "dn_mpjpe_hm", "pck05")
F1S = ("f1_dbr", "f1_der", "f1_tcr", "f1_vcr")
COLNAME = {"mpjpe_all": "All-MPJPE", "dn_mpjpe": "d-nMPJPE", "mpjpe_hm": "HM-MPJPE", "dn_mpjpe_hm": "HM d-nMPJPE",
"pck05": "PCK@0.05", "f1_dbr": "F1 DBR", "f1_der": "F1 DER", "f1_tcr": "F1 TCR", "f1_vcr": "F1 VCR"}
ND = {"mpjpe_all": 2, "dn_mpjpe": 3, "mpjpe_hm": 2, "dn_mpjpe_hm": 3, "pck05": 2, "f1_dbr": 2, "f1_der": 2, "f1_tcr": 2, "f1_vcr": 2}
PUB_ND = {"mpjpe_all": 2, "dn_mpjpe": 2, "mpjpe_hm": 2, "dn_mpjpe_hm": 2, "pck05": 2, "f1_dbr": 2, "f1_der": 2, "f1_tcr": 2, "f1_vcr": 2}
# ----------------------------------------------------------------------------------------------- owner-typed tables (brief)
# Table 1 (main results, 5→5 rollout): All / d-n / HM / HM d-n / PCK@0.05 / F1 DBR / DER / TCR / VCR
OWNER_TYPED_T1 = [
("Zero-Velocity", "motion-only / offline baseline", (52.89, 2.40, 139.19, 6.32, 85.95, 8.27, 14.94, None, None)),
("ST-GCN", "motion-only / offline baseline", (110.98, 5.04, 158.10, 7.18, 60.97, 18.96, 22.66, None, None)),
("SiMLPe", "motion-only / offline baseline", (106.38, 4.83, 156.29, 7.09, 63.45, 37.26, 41.69, None, None)),
("MotionBERT", "motion-only / offline baseline", (73.51, 3.34, 141.53, 6.42, 78.01, 56.70, 52.71, None, None)),
("Offline Enc-Dec", "motion-only / offline baseline", (75.87, 3.45, 144.05, 6.54, 77.17, 53.82, 50.68, None, None)),
("Static pooling", "controlled contextual baseline (identical VLM interface; no rollout)", (68.50, 3.11, 134.56, 6.11, 72.55, 54.04, 60.07, 26.39, 14.00)),
("Single-stream", "controlled contextual baseline (identical VLM interface)", (90.87, 4.13, 147.44, 6.69, 59.63, 24.56, 24.35, 26.39, 14.00)),
("Late fusion", "controlled contextual baseline (identical VLM interface)", (82.59, 3.75, 143.31, 6.51, 65.07, 45.87, 49.10, 87.85, 65.97)),
("Cross-Attn only", "controlled contextual baseline (identical VLM interface)", (80.14, 3.64, 142.41, 6.47, 66.43, 62.52, 68.75, 87.94, 69.09)),
("Driver-WM main", "theirs (main)", (71.47, 3.24, 138.03, 6.27, 71.66, 68.07, 72.61, 90.15, 68.34)),
("full pretrained", "theirs (Driver-WM, full pretrained)", (72.68, 3.30, 138.03, 6.27, 70.99, 73.22, 73.97, 90.54, 62.09)),
("Non-causal", "theirs (Non-causal, bidir; reads future frames)", (72.15, 3.27, 136.50, 6.20, 71.39, 73.35, 74.46, 88.65, 68.82)),
]
# Table 2 (ablations)
OWNER_TYPED_T2 = [
("Driver-WM main", (71.47, 3.24, 138.03, 6.27, 71.66, 68.07, 72.61, 90.15, 68.34)),
("w/o ext context", (71.74, 3.26, 136.94, 6.21, 71.13, 71.33, 63.56, 26.39, 14.00)),
("RSSM/GRU", (78.42, 3.56, 136.46, 6.19, 67.48, 67.15, 72.29, 88.26, 63.74)),
("+Skeleton-Pre", (70.92, 3.22, 136.04, 6.18, 72.09, 69.55, 75.65, 88.33, 70.24)),
("KL bottleneck", (70.56, 3.20, 136.50, 6.20, 71.71, 69.89, 71.54, 88.84, 64.68)),
("no-prompt feat", (76.54, 3.47, 142.08, 6.45, 68.28, 68.88, 69.92, 76.87, 58.59)),
("no pose head", (None, None, None, None, None, 67.22, 70.92, 88.83, 69.44)),
]
T2_LABEL = {"RSSM/GRU": "RSSM/GRU dyn.", "no-prompt feat": "no-prompt feat."}
# Table 3 (controlled interventions; Δ px between intervened and factual rollouts): ΔAll / ΔHM / Δh=5 / ΔHead / ΔHands
OWNER_TYPED_T3 = [
("do(Ext=Swap_clip)", "swap", (5.363, 4.794, 8.042, 5.462, 3.502)),
("do(Ext=∅)", "remove ext", (12.953, 8.691, 15.208, 7.385, 12.937)),
("do(Ext=Shift_large)", "shift large", (0.793, 0.892, 1.009, 0.661, 0.018)),
("do(Ext=DropView)", "drop view", (0.419, 0.100, 0.478, 0.392, 0.265)),
("do(λ_CA=0)/do(g=0)", "disable pathway", (89.641, 62.232, 116.751, 36.783, 95.666)),
("do(λ_CA=1)/do(g=1)", "force", (26.733, 11.480, 42.170, 15.861, 26.727)),
("do(λ_CA=2)", "over-injection", (43.015, 23.959, 52.142, 33.909, 43.695)),
]
PAPER_MAIN_ALL = 71.47
PAPER_HM5_MAIN = 155.82
# ----------------------------------------------------------------------------------------------- formatting
def f(v, nd=2, sign=False):
if v is None or (isinstance(v, float) and np.isnan(v)):
return "–"
return f"{v:+.{nd}f}" if sign else f"{v:.{nd}f}"
def pm(mean, sd, nd=2):
return f(mean, nd) if sd is None else f"{mean:.{nd}f} ± {sd:.{nd}f}"
def ci(lo, hi, nd=2, sign=False):
return f"[{f(lo, nd, sign)}, {f(hi, nd, sign)}]"
def md_table(header, rows):
out = ["| " + " | ".join(header) + " |", "|" + "---|" * len(header)]
out += ["| " + " | ".join(str(c) for c in r) + " |" for r in rows]
return "\n".join(out)
# ----------------------------------------------------------------------------------------------- data access
class Store:
"""Aligned predictions / logits per run plus per-clip statistics (cached)."""
def __init__(self):
d = load_split("test")
self.clip_ids = d["clip_id"]
self.N = len(self.clip_ids)
self.gt = d["S10"][:, P.T_OBS:] # [N, 5, 136, 3] — the future block only (as report_master_aide.py)
self.hm, self.hm_thr, _ = M.hm_mask(self.gt)
self.labels = {t: np.asarray(d[f"y_{t}"]) for t in P.TASKS}
self.pck_thr = P.pck_threshold_px(0.05)
assert self.N == P.EXPECTED_SPLIT_SIZES["test"] and int(self.hm.sum()) == P.hm_top(self.N) == 60
self._cache = {}
def exists(self, run):
return (RUNS / run / "pred_test.npz").exists()
def load(self, run):
if run in self._cache:
return self._cache[run]
z = np.load(RUNS / run / "pred_test.npz", allow_pickle=False)
order = align(z, self.clip_ids)
pred = np.asarray(z["pred"], dtype=np.float64)[order]
logits = {t: np.asarray(z[f"logits_{t}"])[order] for t in P.TASKS if f"logits_{t}" in z.files}
err = M.joint_errors(pred, self.gt) # [N, 5, J]
pc = {
"mpjpe_all": err.mean(axis=(1, 2)),
"dn_mpjpe": 100.0 * err.mean(axis=(1, 2)) / P.DIAG,
"pck05": 100.0 * (err <= self.pck_thr).mean(axis=(1, 2)),
"h5": err[:, -1].mean(axis=1),
}
pc["mpjpe_hm"] = pc["mpjpe_all"][self.hm]
pc["dn_mpjpe_hm"] = pc["dn_mpjpe"][self.hm]
yhat = {t: lg.argmax(-1) for t, lg in logits.items()}
rec = {"mpjpe_all": float(err.mean()), "dn_mpjpe": 100.0 * float(err.mean()) / P.DIAG,
"mpjpe_hm": float(err[self.hm].mean()), "dn_mpjpe_hm": 100.0 * float(err[self.hm].mean()) / P.DIAG,
"pck05": 100.0 * float((err <= self.pck_thr).mean())}
for t, yh in yhat.items():
rec[f"f1_{t}"] = M.macro_f1(self.labels[t], yh)
self._cache[run] = {"pc": pc, "yhat": yhat, "level": rec}
return self._cache[run]
def harness(self, run):
return json.load(open(RUNS / run / "metrics_test.json"))["metrics"]
def macro_f1_fast(y, yh):
"""Macro-F1 (%) over the union of labels present in y or yh, zero_division=0 (== sklearn f1_score(average='macro'))."""
labs = np.union1d(y, yh)
f1s = []
for c in labs:
tp = np.sum((y == c) & (yh == c)); fp = np.sum((y != c) & (yh == c)); fn = np.sum((y == c) & (yh != c))
p = tp / (tp + fp) if tp + fp > 0 else 0.0
r = tp / (tp + fn) if tp + fn > 0 else 0.0
f1s.append(0.0 if p + r == 0 else 2 * p * r / (p + r))
return 100.0 * float(np.mean(f1s))
def group_level_ci(store: Store, runs, n_boot=10000, n_boot_f1=2000, seed=0):
"""CI of the SEED-MEAN level: per-clip statistics averaged over the runs, then clip bootstrap (geometry); for F1 a joint
clip resample is scored per seed and averaged over seeds. Returns {col: (lo, hi)} (F1 only if every run has logits)."""
recs = [store.load(r) for r in runs]
out = {}
for col in ("mpjpe_all", "dn_mpjpe", "pck05", "mpjpe_hm", "dn_mpjpe_hm"):
v = np.mean([r["pc"][col] for r in recs], axis=0)
out[col] = M.bootstrap_ci(v, n_boot, seed)
if all(rec["yhat"] for rec in recs):
rng = np.random.default_rng(seed)
idx = rng.integers(0, store.N, size=(n_boot_f1, store.N))
for t in P.TASKS:
y = store.labels[t]
# sanity: fast macro-F1 equals the sklearn one on the full set for every seed
for rec in recs:
assert abs(macro_f1_fast(y, rec["yhat"][t]) - M.macro_f1(y, rec["yhat"][t])) < 1e-9
b = np.array([np.mean([macro_f1_fast(y[i], rec["yhat"][t][i]) for rec in recs]) for i in idx])
out[f"f1_{t}"] = (float(np.quantile(b, 0.025)), float(np.quantile(b, 0.975)))
return out
def paired(store: Store, run_a, run_b, n_boot=10000, seed=0):
"""Paired per-clip Δ = A − B for All / HM / PCK / h=5 (negative = A better for errors)."""
a, b = store.load(run_a)["pc"], store.load(run_b)["pc"]
out = {}
for col in ("mpjpe_all", "mpjpe_hm", "pck05", "h5"):
d = M.paired_diff(a[col], b[col], n_boot, seed)
out[col] = {"delta": d["mean"], "ci_lo": d["ci_lo"], "ci_hi": d["ci_hi"], "a": float(a[col].mean()), "b": float(b[col].mean())}
return out
def verdict_from_pairs(deltas, lower_better=True):
"""BEATS / WORSE / NOT_WORSE / INCONCLUSIVE rule of baton_pretrain.md (≥ 2/3 seeds CI excl. 0, same sign on all)."""
n = len(deltas)
if n == 0:
return "–"
signs = [np.sign(d["delta"]) for d in deltas]
excl = [(d["ci_lo"] > 0) or (d["ci_hi"] < 0) for d in deltas]
same = len(set(signs)) == 1
if same and sum(excl) * 3 >= 2 * n and sum(excl) >= min(2, n):
improving = (signs[0] < 0) if lower_better else (signs[0] > 0)
return "BEATS" if improving else "WORSE"
if not any(excl) and all(abs(d["delta"]) < 0.25 for d in deltas):
return "NOT_WORSE"
return "INCONCLUSIVE"
# ----------------------------------------------------------------------------------------------- §0 cross-check
def cross_check():
problems = []
for name, _, vals in OWNER_TYPED_T1:
for c, v in zip(COLS, vals):
pv = PAPER_ROWS[name][c]
if (v is None) != (pv is None) or (v is not None and abs(v - pv) > 1e-9):
problems.append(f"Table 1 {name} / {COLNAME[c]}: brief {v} vs paper_rows.py {pv}")
for name, vals in OWNER_TYPED_T2:
for c, v in zip(COLS, vals):
pv = PAPER_ROWS[name][c]
if (v is None) != (pv is None) or (v is not None and abs(v - pv) > 1e-9):
problems.append(f"Table 2 {name} / {COLNAME[c]}: brief {v} vs paper_rows.py {pv}")
for _, key, vals in OWNER_TYPED_T3:
pv = PAPER_T3_FULL[key]
if any(abs(a - b) > 1e-9 for a, b in zip(vals, pv)):
problems.append(f"Table 3 {key}: brief {vals} vs paper_rows.py {pv}")
# the 18 rows of stage_bc.md §1b are generated from paper_rows.py (report_stage_bc.py) — parse them and compare too
sb = (TABLES / "stage_bc.md").read_text().splitlines()
i = next(k for k, l in enumerate(sb) if l.startswith("## 1b."))
rows = [l for l in sb[i:i + 30] if l.startswith("| ") and not l.startswith("| row") and "---" not in l]
seen = 0
for l in rows:
cells = [c.strip() for c in l.strip().strip("|").split("|")]
if len(cells) < 11 or cells[0] not in PAPER_ROWS:
continue
seen += 1
for c, s in zip(COLS, cells[2:11]):
pv = PAPER_ROWS[cells[0]][c]
v = None if s in ("–", "-", "") else float(s)
if (v is None) != (pv is None) or (v is not None and abs(v - pv) > 1e-9):
problems.append(f"stage_bc.md §1b {cells[0]} / {COLNAME[c]}: table {s} vs paper_rows.py {pv}")
return problems, seen
# ----------------------------------------------------------------------------------------------- §1
OUR_ROWS_1 = [
# (master_aide.json group key, label, note)
("zv", "Zero-velocity (ours; copy the last observed pose)", "analytic rule; no parameters; the paper's 52.89 on its own extraction"),
("K3", "CockpitWM (3 locked seeds 42 / 123 / 456)", "keypoint forecaster; geometry checkpoint (val All-MPJPE); 5.8 M params"),
("K5", "CockpitWM (5 seeds 42 / 123 / 456 / 789 / 1011)", "appendix seeds trained with the locked recipe verbatim"),
("K5_pre", "CockpitWM + BATON trunk pretraining (5 seeds)", "trunk-only init from BATON in-cabin pose pretraining (pre-registered replication BEATS on Δ All; adopted)"),
("KS3", "CockpitWM (+ semantic heads), B2 main recipe (3 seeds) — F1 reading (a)", "trunk-state semantic heads; geometry checkpoint (val All-MPJPE); this recipe has no dual selection, so (a) is its only F1 reading"),
("KSvg_a", "CockpitWM (+ semantic heads), view-gate attention heads (3 seeds) — reading (a)", "checkpoint selected on val All-MPJPE (geometry); F1 of that checkpoint"),
("KSvg_b", "CockpitWM (+ semantic heads), view-gate attention heads (3 seeds) — reading (b)", "DUAL SELECTION: checkpoint selected on val mean macro-F1 (`__f1sel`); geometry of that same checkpoint (+1–2 px All)"),
("DWMkp3", "Driver-WM architecture on CockpitWM tokens (3 seeds)", "the reproduction's exterior stream / Perceiver context / gated injection / ST-GCN decoder with CockpitWM's keypoint part tokens; shared recipe; 85.7 M params"),
("DWMrepro3", "Driver-WM reproduction (our port of the published architecture; 3 seeds)", "absolute-coordinate regression as published; F1 at the geometry checkpoint (the only checkpoint; no EMA)"),
("ensA3", "ensemble: logit ensemble of the three reading-(b) view-gate seeds (not a single model)", "mean of the members' saved coordinates and logits; n = 1"),
]
def pub_rows_with(col):
return [(r, v[col]) for r, v in PAPER_ROWS.items() if v[col] is not None]
def verdict_cell(col, ours):
rows = pub_rows_with(col)
lower = col in LOWER_IS_BETTER
beaten = [r for r, v in rows if (ours < v if lower else ours > v)]
not_beaten = sorted([(r, v) for r, v in rows if r not in beaten], key=lambda x: x[1], reverse=not lower)
word = "lower" if lower else "higher"
best = (min if lower else max)(rows, key=lambda x: x[1])
if len(beaten) == len(rows):
return f"{word} than every published row ({len(rows)}/{len(rows)}; best published {f(best[1], PUB_ND[col])} {best[0]}; margin {f(ours - best[1], ND[col], True)})"
above = "; ".join(f"{r}{'*' if r in NON_CAUSAL else ''} {f(v, PUB_ND[col])}" for r, v in not_beaten[:4])
more = f" (+{len(not_beaten) - 4} more)" if len(not_beaten) > 4 else ""
return f"{word} than {len(beaten)}/{len(rows)} published rows; not {word} than: {above}{more}"
def section1(store: Store, master: dict):
groups = master["groups"]
header = ["row", "n", *[COLNAME[c] for c in COLS]]
pub = []
for name, grp, vals in OWNER_TYPED_T1:
pub.append([f"{name} — {grp}", "1 (single seed)", *[f(v, PUB_ND[c]) for c, v in zip(COLS, vals)]])
ours_rows, ours_json = [], []
for key, label, note in OUR_ROWS_1:
g = groups[key]
runs = g["runs"]
cis = group_level_ci(store, runs)
cells = {}
line = [f"**{label}**", str(g["n"])]
for c in COLS:
cell = g["cells"].get(c)
if cell is None or cell.get("mean") is None:
line.append("—")
cells[c] = None
continue
lo, hi = cis.get(c, (float("nan"), float("nan")))
line.append(f"{pm(cell['mean'], cell['sd'], ND[c])} {ci(lo, hi, ND[c])}")
cells[c] = {"mean": cell["mean"], "sd": cell["sd"], "n": cell["n"], "per_seed": cell["per_seed"], "ci95_level": [lo, hi],
"verdict": verdict_cell(c, cell["mean"]), "vs_driverwm_main": cell["mean"] - PAPER_ROWS["Driver-WM main"][c]}
ours_rows.append(line)
ours_json.append({"key": key, "label": label, "note": note, "runs": runs, "n": g["n"], "selection": g["selection"],
"pretraining": g["pretraining"], "reading": g.get("reading"), "cells": cells})
# verdict table: rows = our rows, cols = metrics
vhead = ["row", *[COLNAME[c] for c in COLS]]
vrows = []
for r in ours_json:
vrows.append([r["label"], *[(r["cells"][c]["verdict"] if r["cells"][c] else "—") for c in COLS]])
# margin paragraph
k3 = groups["K3"]["cells"]
all_pub_all = [(r, v["mpjpe_all"]) for r, v in PAPER_ROWS.items() if v["mpjpe_all"] is not None and r != "Zero-Velocity"]
min_other = min(all_pub_all, key=lambda x: x[1])
every_ge_zv = all(v >= PAPER_ROWS["Zero-Velocity"]["mpjpe_all"] for _, v in all_pub_all)
margins = {}
for c in GEO:
rows = pub_rows_with(c)
best = (min if c in LOWER_IS_BETTER else max)(rows, key=lambda x: x[1])
m = k3[c]["mean"] - best[1]
margins[c] = {"best_published": best[1], "best_row": best[0], "ours_K3": k3[c]["mean"], "margin": m,
"margin_pct_of_best": 100.0 * m / best[1], "vs_driverwm_main": k3[c]["mean"] - PAPER_ROWS["Driver-WM main"][c],
"margin_in_seed_sd": (m / k3[c]["sd"]) if k3[c]["sd"] else None}
para = (
f"Every published row is at or above Zero-Velocity on All-MPJPE ({'verified' if every_ge_zv else 'NOT verified'}: the closest published "
f"model is {min_other[0]} at {min_other[1]:.2f} px, {min_other[1] - PAPER_ROWS['Zero-Velocity']['mpjpe_all']:+.2f} px above Zero-Velocity's 52.89; "
f"Driver-WM main is {PAPER_MAIN_ALL - 52.89:+.2f} px above it) — the paper regresses absolute coordinates and none of its rows recovers the "
f"copy-last-pose accuracy. CockpitWM (3 locked seeds, keypoint-anchored residual forecaster) is on the other side of that line on every geometry column; "
f"its margin over the BEST published row per metric: "
+ "; ".join(
f"{COLNAME[c]} {f(margins[c]['ours_K3'], ND[c])} vs {f(margins[c]['best_published'], PUB_ND[c])} ({margins[c]['best_row']}) → "
f"{f(margins[c]['margin'], ND[c], True)} ({margins[c]['margin_pct_of_best']:+.1f} % of the best published value"
+ (f", {margins[c]['margin_in_seed_sd']:+.0f} seed-sd" if margins[c]["margin_in_seed_sd"] is not None else "") + ")"
for c in GEO)
+ f". Against Driver-WM main itself: All {margins['mpjpe_all']['vs_driverwm_main']:+.2f} px, HM {margins['mpjpe_hm']['vs_driverwm_main']:+.2f} px, "
f"PCK@0.05 {margins['pck05']['vs_driverwm_main']:+.2f} points."
)
note = ("Published rows are single-seed numbers typed from the paper (its Table 8 gives the main model's 3-seed sd: All 0.3, HM 1.2, F1 1.0–1.8); "
"they were produced on the authors' own keypoint extraction and checkpoint selection and CANNOT be paired with our clips — no paired test "
"against a published row exists, and the verdicts are descriptive comparisons of levels. Our rows: mean ± sd over seeds (ddof 1) from "
"`master_aide.json`, followed by the 95 % clip-bootstrap CI of the seed-mean level (per-clip errors averaged over the seeds, 10k resamples; "
"F1: 2k joint resamples) computed here from `pred_test.npz`. * = the Non-causal row reads future frames. The paper's HM h=5 for Driver-WM main "
f"({PAPER_HM5_MAIN}) is not a Table-1 column and is treated in stage_bc.md (trade-off reading; ±51 px CI at n = 60).")
md = [
"## Section 1 — their Table 1 (main results, 5→5 rollout; horizon-averaged MPJPE px, d-nMPJPE %, PCK@0.05, macro-F1 DBR / DER / TCR / VCR)",
"",
"### 1.1 Published rows (verbatim, single seed) followed by our rows under the same columns",
"",
md_table(header, pub + [["*Ours — mean ± sd over seeds [95 % clip-bootstrap CI of the seed-mean level]; source of the levels: master_aide.json*"] + [""] * (len(header) - 1)] + ours_rows),
"",
note,
"",
"### 1.2 Verdict per metric (our row vs all published rows that report the column; 'lower' for errors, 'higher' for PCK / F1; * = non-causal row)",
"",
md_table(vhead, vrows),
"",
"### 1.3 Every published row is ≥ zero-velocity on All-MPJPE — margin of CockpitWM over the best published row",
"",
para,
]
return "\n".join(md), {"published": [{"row": n, "group": g, **{c: v for c, v in zip(COLS, vals)}} for n, g, vals in OWNER_TYPED_T1],
"ours": ours_json, "margins_K3": margins, "every_published_row_ge_zero_velocity_on_All": every_ge_zv,
"closest_published_to_ZV": {"row": min_other[0], "All": min_other[1]}, "note": note}
# ----------------------------------------------------------------------------------------------- §2
def their_delta(name):
main = PAPER_ROWS["Driver-WM main"]
row = PAPER_ROWS[name]
return {c: (None if row[c] is None or main[c] is None else row[c] - main[c]) for c in COLS}
def fmt_delta_row(d):
return " / ".join(f(d[c], ND[c] if c != "dn_mpjpe" and c != "dn_mpjpe_hm" else 2, True) for c in COLS)
def seed_pairs(prefix_a, prefix_b, seeds):
return [(f"{prefix_a}_s{s}_v2", f"{prefix_b}_s{s}_v2") for s in seeds]
def paired_block(store, pairs, label_a, label_b):
"""Per-seed paired Δ (A − B) for All / HM / PCK with verdicts, plus seed means of both sides."""
res = []
for a, b in pairs:
if not (store.exists(a) and store.exists(b)):
continue
r = paired(store, a, b)
r["run_a"], r["run_b"] = a, b
res.append(r)
if not res:
return None
out = {"label_a": label_a, "label_b": label_b, "n_pairs": len(res), "pairs": res}
for col, lower in (("mpjpe_all", True), ("mpjpe_hm", True), ("pck05", False), ("h5", True)):
ds = [r[col] for r in res]
out[col] = {"mean_delta": float(np.mean([d["delta"] for d in ds])),
"sd_delta": float(np.std([d["delta"] for d in ds], ddof=1)) if len(ds) > 1 else None,
"verdict": verdict_from_pairs(ds, lower), "per_seed": ds,
"level_a": float(np.mean([d["a"] for d in ds])), "level_b": float(np.mean([d["b"] for d in ds]))}
return out
def f1_block(store, runs_a, runs_b, label_a, label_b, harness_ci=True):
"""Seed-mean F1 of A and B (reading noted by the caller) and Δ; per-seed harness CIs of the levels."""
A = [r for r in runs_a if store.exists(r)]
B = [r for r in runs_b if store.exists(r)]
if not A or not B:
return None
out = {"label_a": label_a, "label_b": label_b, "runs_a": A, "runs_b": B}
for t in P.TASKS:
la = [store.load(r)["level"].get(f"f1_{t}") for r in A]
lb = [store.load(r)["level"].get(f"f1_{t}") for r in B]
if any(v is None for v in la + lb):
out[f"f1_{t}"] = None
continue
out[f"f1_{t}"] = {"a": float(np.mean(la)), "a_sd": float(np.std(la, ddof=1)) if len(la) > 1 else None,
"b": float(np.mean(lb)), "b_sd": float(np.std(lb, ddof=1)) if len(lb) > 1 else None,
"delta": float(np.mean(la) - np.mean(lb)),
"a_ci_per_seed": [[store.harness(r)[f"f1_{t}"]["ci_lo"], store.harness(r)[f"f1_{t}"]["ci_hi"]] for r in A] if harness_ci else None,
"b_ci_per_seed": [[store.harness(r)[f"f1_{t}"]["ci_lo"], store.harness(r)[f"f1_{t}"]["ci_hi"]] for r in B] if harness_ci else None}
return out
def seeds_of(pb):
import re
return [int(m.group(1)) for p in pb["pairs"] for m in [re.search(r"_s(\d+)_v2", p["run_a"])] if m]
def fmt_short(pb, col):
x = pb[col]
if x["sd_delta"] is None:
d = x["per_seed"][0]
return f"{f(x['mean_delta'], 2, True)} {ci(d['ci_lo'], d['ci_hi'], 2, True)}"
return f"{f(x['mean_delta'], 2, True)} ± {x['sd_delta']:.2f}"
def fmt_pb(pb, col):
if pb is None:
return "—"
x = pb[col]
per = "; ".join(f"{f(d['delta'], 2, True)} {ci(d['ci_lo'], d['ci_hi'], 2, True)}" for d in x["per_seed"])
m = f"{f(x['mean_delta'], 2, True)}" + (f" ± {x['sd_delta']:.2f}" if x["sd_delta"] is not None else "")
return f"{m} ({x['verdict']}; per seed {per})"
def fmt_f1b(fb):
if fb is None:
return "—"
parts = []
for t in P.TASKS:
x = fb[f"f1_{t}"]
parts.append("–" if x is None else f"{f(x['delta'], 2, True)} ({f(x['a'], 1)} vs {f(x['b'], 1)})")
return " / ".join(parts)
def section2(store: Store, master: dict):
groups = master["groups"]
locked = (42, 123, 456)
five = (42, 123, 456, 789, 1011)
axes = []
# --- w/o ext context
pb = paired_block(store, seed_pairs("cwm3d_kp", "cwm3d_vis_sem", locked), "CockpitWM (keypoint-only; no exterior input)", "CockpitWM (+ semantic heads), B2 main (exterior Qwen features)")
fb = f1_block(store, [f"cwm3d_kpsem_s{s}_v2" for s in locked], [f"cwm3d_vis_sem_s{s}_v2" for s in locked],
"kp+sem, no vision (ii) — heads on the trunk state without exterior features (reading (a))", "B2 main trunk-state heads with exterior features (reading (a))")
ks_a = groups["KS3"]["cells"]; vg_b = groups["KSvg_b"]["cells"]
axes.append({
"paper_row": "w/o ext context", "their_delta": their_delta("w/o ext context"),
"our_mapping": "geometry: CockpitWM keypoint-only (`cwm3d_kp_s<k>_v2`) − CockpitWM (+ semantic heads) B2 main (`cwm3d_vis_sem_s<k>_v2`), same seed, paired per clip; "
"semantics: kp+sem no-vision (ii) `cwm3d_kpsem_s<k>_v2` − B2 main, both reading (a); the view-gate attention heads (the model that reaches the published F1) "
"ATTEND OVER the exterior features, so 'without exterior' collapses them to the trunk-state heads = B2 main reading (a)",
"geometry": pb, "f1": fb,
"f1_viewgate_collapse": {t: {"viewgate_b": vg_b[f"f1_{t}"]["mean"], "trunk_state_a": ks_a[f"f1_{t}"]["mean"], "delta": ks_a[f"f1_{t}"]["mean"] - vg_b[f"f1_{t}"]["mean"]} for t in P.TASKS},
"reading": "Same qualitative picture as theirs, at a different accuracy: removing the exterior context costs us "
f"{f(pb['mpjpe_all']['mean_delta'], 2, True)} px All ({pb['mpjpe_all']['verdict']}) vs their +0.27 px — in both models the exterior features barely move geometry — "
f"while semantics drop hard: their DER −9.05 and TCR / VCR to chance (26.39 / 14.00); ours (trunk-state heads) DBR/DER/TCR/VCR "
+ " / ".join(f(fb[f'f1_{t}']['delta'], 1, True) for t in P.TASKS)
+ "; for the view-gate heads the exterior attention path is worth "
+ " / ".join(f(ks_a[f'f1_{t}']['mean'] - vg_b[f'f1_{t}']['mean'], 1, True) for t in P.TASKS) + " F1 ((a) trunk-state − (b) view-gate).",
"status": "mirrored (geometry paired, 3 seeds; semantics seed means)"})
# --- RSSM/GRU dyn.
pb = paired_block(store, seed_pairs("cwm3d_recursive", "cwm3d_kp", locked), "CockpitWM `--rollout recursive` (1-step recursive decoding, anchors recomputed each step)", "CockpitWM chunked 5-step decoding (main)")
nrec = pb["n_pairs"]
axes.append({
"paper_row": "RSSM/GRU", "their_delta": their_delta("RSSM/GRU"),
"our_mapping": f"closest existing run(s): `cwm3d_recursive_s<k>_v2` (recursive one-step rollout; Stage-A ablation recipe) − `cwm3d_kp_s<k>_v2`, same seed, {nrec} seed(s) [{', '.join(str(x) for x in seeds_of(pb))}]; "
"no recurrent latent (GRU / RSSM) dynamics variant of CockpitWM exists on AIDE. The BATON-side RSSM decoder (`results/tables/stage_F_rssm.md`, GPU-baselines E) "
"is a stochastic latent rollout for CAN-onset hazards on a different task and metric set (B3-style FAIL: 2 hazard-NLL cells WORSE, kill rule not triggered; "
"far below the pretrained direct heads) — quoted as a qualitative sibling only, not placed in this table.",
"geometry": pb, "f1": None,
"reading": f"Their recurrent dynamics cost +6.95 px All (−1.57 HM); our recursive decoding costs {fmt_short(pb, 'mpjpe_all')} px All and "
f"{fmt_short(pb, 'mpjpe_hm')} px HM at ≈ 3.4× the GPU time ({nrec} seed(s); {pb['mpjpe_all']['verdict']} on All"
+ (" — neutral, not to be claimed either way" if pb['mpjpe_all']['verdict'] in ("NOT_WORSE", "INCONCLUSIVE") else "") + ").",
"status": f"{'mirrored' if nrec >= 3 else 'partial'} (decoding-order analogue, {nrec} seed(s); no latent-dynamics variant)"})
# --- +Skeleton-Pre
pbK = paired_block(store, seed_pairs("cwm3d_kp_batonpre_trunkp123", "cwm3d_kp", five), "CockpitWM + BATON trunk (5 seeds)", "CockpitWM seed init (5 seeds)")
pbKS = paired_block(store, seed_pairs("cwm3d_vis_sem_batonpre_trunkp123", "cwm3d_vis_sem", locked), "CockpitWM (+ semantic heads) B2 main + BATON trunk", "B2 main seed init")
pbVG = paired_block(store, seed_pairs("cwm3d_vis_sema_vg_batonpre_trunkp123", "cwm3d_vis_sema_vg", locked), "view-gate heads (a) + BATON trunk", "view-gate heads (a) seed init")
fbVGa = f1_block(store, [f"cwm3d_vis_sema_vg_batonpre_trunkp123_s{s}_v2" for s in locked], [f"cwm3d_vis_sema_vg_s{s}_v2" for s in locked], "view-gate heads + BATON trunk, reading (a)", "view-gate heads seed init, reading (a)")
fbVGb = f1_block(store, [f"cwm3d_vis_sema_vg_batonpre_trunkp123_s{s}_v2__f1sel" for s in locked], [f"cwm3d_vis_sema_vg_s{s}_v2__f1sel" for s in locked], "view-gate heads + BATON trunk, reading (b)", "view-gate heads seed init, reading (b)")
axes.append({
"paper_row": "+Skeleton-Pre", "their_delta": their_delta("+Skeleton-Pre"),
"our_mapping": "BATON in-cabin pose pretraining of the trunk (tokenizer / blocks / ln_f), head at seed init (`*_batonpre_trunkp123_*` − seed-init run, same seed): "
"CockpitWM 5 seeds (pre-registered replication, adopted); B2 main 3 seeds (pre-registered, INCONCLUSIVE, not adopted); view-gate heads (a) 3 seeds (pre-registered, adopted); "
"F1 of the pretrained view-gate model under (a) and (b) descriptive (baton_pretrain.md §6–§8)",
"geometry": {"CockpitWM_5seeds": pbK, "B2_main_3seeds": pbKS, "viewgate_a_3seeds": pbVG}, "f1": {"viewgate_reading_a": fbVGa, "viewgate_reading_b": fbVGb},
"reading": f"Their skeleton pretraining gives −0.55 px All / +3.04 DER / +1.90 VCR / −1.82 TCR (single seed). Ours: CockpitWM {f(pbK['mpjpe_all']['mean_delta'], 2, True)} ± {pbK['mpjpe_all']['sd_delta']:.2f} px All "
f"({pbK['mpjpe_all']['verdict']}, 5 seeds), HM {f(pbK['mpjpe_hm']['mean_delta'], 2, True)} ± {pbK['mpjpe_hm']['sd_delta']:.2f} ({pbK['mpjpe_hm']['verdict']}); "
f"view-gate heads {f(pbVG['mpjpe_all']['mean_delta'], 2, True)} ± {pbVG['mpjpe_all']['sd_delta']:.2f} px All ({pbVG['mpjpe_all']['verdict']}); B2 main "
f"{f(pbKS['mpjpe_all']['mean_delta'], 2, True)} ± {pbKS['mpjpe_all']['sd_delta']:.2f} ({pbKS['mpjpe_all']['verdict']}). Semantics under pretraining move the OTHER way for us: reading (b) "
+ " / ".join(f(fbVGb[f'f1_{t}']['delta'], 1, True) for t in P.TASKS) + " (DBR/DER/TCR/VCR) and reading (a) "
+ " / ".join(f(fbVGa[f'f1_{t}']['delta'], 1, True) for t in P.TASKS) + " — the pose-only pretraining helps geometry with a paired CI, not the semantic heads.",
"status": "mirrored (paired, 3–5 seeds)"})
# --- KL bottleneck
axes.append({"paper_row": "KL bottleneck", "their_delta": their_delta("KL bottleneck"), "our_mapping": "none — CockpitWM has no stochastic latent on AIDE (the Laplace uncertainty head is a loss, not a bottleneck); no run to compare",
"geometry": None, "f1": None, "reading": "Their KL bottleneck is −0.91 px All / −1.07 DER (single seed). No mirror; listed under the runs needed.", "status": "none"})
# --- no-prompt feat.
vp_pairs = [(a_, b_) for a_, b_ in seed_pairs("cwm3d_vis_sem_vp", "cwm3d_vis_sem", locked) if store.exists(a_) and store.exists(b_)]
pb = paired_block(store, vp_pairs, "B2 main with `vis_key=vis_pooled` (vision-token-only pooled Qwen features, no prompt)", "B2 main with prompted `pooled` features")
fb = f1_block(store, [a_ for a_, _ in vp_pairs], [b_ for _, b_ in vp_pairs], "vis_pooled (iv), reading (a)", "B2 main, reading (a)")
nvp = pb["n_pairs"]
axes.append({
"paper_row": "no-prompt feat", "their_delta": their_delta("no-prompt feat"),
"our_mapping": f"`cwm3d_vis_sem_vp_s<k>_v2` (B2 (iv): `vis_key=vis_pooled`, the vision tokens pooled without the text prompt) − `cwm3d_vis_sem_s<k>_v2`, same seed, {nvp} seed(s) [{', '.join(str(x) for x in seeds_of(pb))}]; F1 reading (a) of both (trunk-state heads)",
"geometry": pb, "f1": fb,
"reading": f"Their no-prompt features cost +5.07 px All and −13.28 TCR; ours {fmt_short(pb, 'mpjpe_all')} px All ({pb['mpjpe_all']['verdict']}) and F1 " + fmt_f1b(fb)
+ f" ({nvp} seed(s), trunk-state heads at ≈ 40–80 F1; the view-gate heads were not run on vis_pooled).",
"status": f"{'mirrored' if nvp >= 3 else 'partial'} ({nvp} seed(s); trunk-state heads only)"})
# --- no pose head
fb = f1_block(store, [f"semonly_s{s}_v2" for s in locked], [f"cwm3d_vis_sema_vg_s{s}_v2__f1sel" for s in locked],
"semantic-only reference `semonly_s<k>_v2` (frozen features → heads, no pose trunk; selected on val F1)", "view-gate heads reading (b) (selected on val F1)")
axes.append({
"paper_row": "no pose head", "their_delta": their_delta("no pose head"),
"our_mapping": "semantic-only configuration `semonly_s<k>_v2` (frozen Qwen features → the reproduction's heads, no trunk, no pose loss; geometry = zero-velocity copy) − view-gate heads reading (b); both selected on val mean macro-F1",
"geometry": None, "f1": fb,
"reading": f"Their 'no pose head' costs −0.85 / −1.69 / −1.32 / +1.10 F1 (DBR/DER/TCR/VCR); ours " + fmt_f1b(fb)
+ " — dropping the pose trunk hurts DER most for us (the driver-emotion head profits from the forecaster state), the other heads within seed noise (sd 0.3–2.9).",
"status": "mirrored (F1 seed means, 3 seeds; geometry undefined for a semantics-only model)"})
# --- Non-causal
axes.append({"paper_row": "Non-causal", "their_delta": their_delta("Non-causal"),
"our_mapping": "none — CockpitWM's encoder is causal by construction (unit-tested); a bidirectional variant would read future frames and is not a forecasting row",
"geometry": None, "f1": None, "reading": "Their non-causal variant is +0.68 px All / −1.53 HM / +5.28 DBR / +1.85 DER (reads future frames). No mirror by design.", "status": "none (by design)"})
# markdown
header = ["their ablation", "their Δ vs Driver-WM main (All / d-n / HM / HM d-n / PCK / DBR / DER / TCR / VCR)", "our closest run(s)", "our Δ All [paired, per seed]", "our Δ HM", "our Δ PCK@0.05", "our Δ F1 DBR / DER / TCR / VCR (a − b)", "reading", "status"]
rows = []
for ax in axes:
g = ax["geometry"]
if isinstance(g, dict) and "pairs" not in g and g is not None: # +Skeleton-Pre: three blocks
dall = "<br>".join(f"{k}: {fmt_pb(v, 'mpjpe_all')}" for k, v in g.items() if v)
dhm = "<br>".join(f"{k}: {fmt_pb(v, 'mpjpe_hm')}" for k, v in g.items() if v)
dpck = "<br>".join(f"{k}: {fmt_pb(v, 'pck05')}" for k, v in g.items() if v)
f1s = "<br>".join(f"{k}: {fmt_f1b(v)}" for k, v in ax["f1"].items() if v)
else:
dall, dhm, dpck = fmt_pb(g, "mpjpe_all"), fmt_pb(g, "mpjpe_hm"), fmt_pb(g, "pck05")
f1s = fmt_f1b(ax["f1"]) if not isinstance(ax["f1"], dict) or "runs_a" in (ax["f1"] or {}) else "—"
rows.append([T2_LABEL.get(ax["paper_row"], ax["paper_row"]), fmt_delta_row(ax["their_delta"]), ax["our_mapping"], dall, dhm, dpck, f1s, ax["reading"], ax["status"]])
pub_header = ["row", *[COLNAME[c] for c in COLS], "Δ All vs main", "Δ DER vs main"]
pub_rows = []
for name, vals in OWNER_TYPED_T2:
d = their_delta(name)
pub_rows.append([T2_LABEL.get(name, name), *[f(v, 2) for v in vals], f(d["mpjpe_all"], 2, True) if name != "Driver-WM main" else "—", f(d["f1_der"], 2, True) if name != "Driver-WM main" else "—"])
md = [
"## Section 2 — their Table 2 (ablations; single seed) mapped to our closest existing runs",
"",
"### 2.1 Published Table 2 (verbatim)",
"",
md_table(pub_header, pub_rows),
"",
"### 2.2 Axis-by-axis mirror (their Δ = ablation − main; our Δ = ablated − main, paired per clip on the same seed, 10k clip bootstrap; verdict rule as baton_pretrain.md: BEATS / WORSE = CI excl. 0 on ≥ 2/3 seeds with the same sign, NOT_WORSE = all CIs cover 0 and |Δ| < 0.25, else INCONCLUSIVE; single-seed rows carry the CI only)",
"",
md_table(header, rows),
"",
"Selection note: every 'our' level is the test evaluation of the checkpoint selected on the validation split ((a) val All-MPJPE, (b) val mean macro-F1); the F1 Δ are differences of seed means without a paired test (per-seed harness CIs are in the JSON).",
]
return "\n".join(md), {"published": [{"row": n, **{c: v for c, v in zip(COLS, vals)}, "delta_vs_main": their_delta(n)} for n, vals in OWNER_TYPED_T2], "axes": axes}
# ----------------------------------------------------------------------------------------------- §3
MAP3 = { # paper key -> (KS = CockpitWM (+ semantic heads) B2 main, gated variant (iii), Driver-WM reproduction)
"swap": ("swap_ext", "swap_ext", "swap_ext"),
"remove ext": ("zero_ext", "zero_ext", "zero_ext"),
"shift large": ("shift_large", "shift_large", "shift_large"),
"drop view": ("drop_view_*", "drop_view_*", "drop_view_*"),
"disable pathway": ("ext_scale0", "gate_override0", "gate0"),
"force": (None, "gate_override1", "gate1"),
"over-injection": ("ext_scale2", "gate_override2", "gate2"),
}
MODELS3_UPDATE_EXTRA = [
("KSvg_a", "CockpitWM (+ semantic heads), view-gate heads — reading-(a) checkpoint", [f"cwm3d_vis_sema_vg_s{s}_v2" for s in (42, 123, 456)], 0),
("KS_pre", "CockpitWM (+ semantic heads) + BATON trunk (B2 main + trunk init)", [f"cwm3d_vis_sem_batonpre_trunkp123_s{s}_v2" for s in (42, 123, 456)], 0),
]
MODELS3 = [
("KS", "CockpitWM (+ semantic heads), B2 main — no traffic gate", [f"cwm3d_vis_sem_s{s}_v2" for s in (42, 123, 456)], 0),
("KSg", "CockpitWM (+ semantic heads) + traffic gate (iii)", [f"cwm3d_vis_sem_gate_s{s}_v2" for s in (42, 123, 456)], 1),
("repro", "Driver-WM reproduction (our port)", [f"driverwm_repro_s{s}_v2" for s in (42, 123, 456)], 2),
]
def latest_per_run(run):
"""Newest aide/results/runs/<run>/interventions_2*.json (the harness writes the same record there and in the tables summary)."""
c = sorted((RUNS / run).glob("interventions_2*.json"))
return (json.loads(c[-1].read_text()), str(c[-1].relative_to(ROOT))) if c else (None, None)
def load_interventions_per_run(models):
"""{run: record} from the per-run files (newest per run) for every run of `models`; missing runs are absent."""
S, src = {}, {}
for _, _, runs, _ in models:
for r in runs:
rec, path = latest_per_run(r)
if rec is not None:
S[r], src[r] = rec, path
return S, src
def section3(S=None, models=None, source_note=None, heading_suffix=""):
if S is None:
J = json.load(open(INTERV))
S = J["summary"]
else:
J = {}
models = models or MODELS3
models = [m for m in models if any(r in S for r in m[2])] # drop models with no intervention record at all
checks = []
def iv(run, key):
if key == "drop_view_*":
parts = [S[run]["interventions"][k] for k in ("drop_view_front", "drop_view_left", "drop_view_right")]
dev = {q: float(np.mean([p["deviation_px"][q] for p in parts])) for q in ("all", "hm", "h5", "head", "hands")}
dev["all_max_view"] = float(np.max([p["deviation_px"]["all"] for p in parts]))
gt_all = float(np.mean([p["gt"]["mpjpe_all"] for p in parts]))
gt_hm = float(np.mean([p["gt"]["mpjpe_hm"] for p in parts]))
diff = {"value": float(np.mean([p["diff_vs_factual_all"]["value"] for p in parts])),
"ci_lo": float(np.min([p["diff_vs_factual_all"]["ci_lo"] for p in parts])), "ci_hi": float(np.max([p["diff_vs_factual_all"]["ci_hi"] for p in parts])),
"note": "mean over the three views; CI = envelope"}
return dev, gt_all, gt_hm, diff
p = S[run]["interventions"][key]
# verify from the run output: re-read the intervened run's metrics_test.json
mj = Path(p["metrics_json"])
if mj.exists():
m = json.load(open(mj))["metrics"]
ok = abs(m["mpjpe_all"]["value"] - p["gt"]["mpjpe_all"]) < 1e-6 and abs(m["mpjpe_hm"]["value"] - p["gt"]["mpjpe_hm"]) < 1e-6
checks.append({"run": run, "do": key, "metrics_json": str(mj.relative_to(ROOT)), "match": bool(ok),
"mpjpe_all_json": m["mpjpe_all"]["value"], "mpjpe_all_summary": p["gt"]["mpjpe_all"]})
else:
checks.append({"run": run, "do": key, "metrics_json": str(mj), "match": None, "note": "file missing"})
return dict(p["deviation_px"]), p["gt"]["mpjpe_all"], p["gt"]["mpjpe_hm"], dict(p["diff_vs_factual_all"])
out_rows, out_json = [], []
header = ["paper intervention", "paper Δ All / HM / h=5 / Head / Hands (px)", "paper Δ/All"]
for _, label, _, _ in models:
header += [f"{label}: Δ All (Δ/All) · HM · h=5 · Head · Hands [n]", f"{label}: All-MPJPE under do(·) vs factual [paired Δ]"]
for pname, key, vals in OWNER_TYPED_T3:
row = [pname, " / ".join(f(v, 3) for v in vals), f"{100 * vals[0] / PAPER_MAIN_ALL:.1f} %"]
rj = {"paper": pname, "key": key, "paper_delta": dict(zip(("all", "hm", "h5", "head", "hands"), vals)), "paper_delta_over_all_pct": 100 * vals[0] / PAPER_MAIN_ALL, "ours": {}}
for mkey, label, runs, idx in models:
ik = MAP3[key][idx]
if ik is None:
row += ["n/a (λ_CA = 1 undefined: no gate)", "—"]
rj["ours"][mkey] = None
continue
per = []
for r in runs:
if r not in S or (ik != "drop_view_*" and ik not in S[r]["interventions"]):
continue
dev, gt_all, gt_hm, diff = iv(r, ik)
fact = S[r]["factual_gt"]["mpjpe_all"]
per.append({"run": r, "do": ik, "deviation_px": dev, "gt_all_intervened": gt_all, "gt_hm_intervened": gt_hm, "factual_gt_all": fact,
"diff_vs_factual_all": diff, "ci_excl_0": bool(diff["ci_lo"] > 0 or diff["ci_hi"] < 0)})
if not per:
row += ["not available (no intervention record)", "—"]
rj["ours"][mkey] = None
continue
mean = {q: float(np.mean([p["deviation_px"][q] for p in per])) for q in ("all", "hm", "h5", "head", "hands")}
fact_mean = float(np.mean([p["factual_gt_all"] for p in per]))
gt_mean = float(np.mean([p["gt_all_intervened"] for p in per]))
dmean = float(np.mean([p["diff_vs_factual_all"]["value"] for p in per]))
dsd = float(np.std([p["diff_vs_factual_all"]["value"] for p in per], ddof=1)) if len(per) > 1 else float("nan")
nexcl = sum(p["ci_excl_0"] for p in per)
extra = f" (max view {np.mean([p['deviation_px']['all_max_view'] for p in per]):.2f})" if ik == "drop_view_*" else ""
analog = " ᵃ" if (idx == 0 and ik in ("ext_scale0", "ext_scale2")) else ""
row += [f"{mean['all']:.2f} ({100 * mean['all'] / fact_mean:.1f} %){extra}{analog} · {mean['hm']:.2f} · {mean['h5']:.2f} · {mean['head']:.2f} · {mean['hands']:.2f} [n={len(per)}]",
f"{gt_mean:.2f} vs {fact_mean:.2f} [{dmean:+.2f} ± {dsd:.2f}; CI excl. 0 on {nexcl}/{len(per)} seeds]"]
rj["ours"][mkey] = {"label": label, "do": ik, "n": len(per), "mean_deviation_px": mean, "delta_over_factual_all_pct": 100 * mean["all"] / fact_mean,
"mean_gt_all_intervened": gt_mean, "mean_factual_gt_all": fact_mean, "mean_diff_vs_factual_all": dmean, "sd_diff_vs_factual_all": dsd,
"n_seeds_ci_excl_0": nexcl, "per_seed": per, "analogue": bool(analog)}
out_rows.append(row)
out_json.append(rj)
# ours-only: shift small
row = ["(ours only) do(Ext=Shift_small)", "–", "–"]
rj = {"paper": None, "key": "shift small", "ours": {}}
for mkey, label, runs, idx in models:
per = []
for r in runs:
if r not in S or "shift_small" not in S[r]["interventions"]:
continue
dev, gt_all, gt_hm, diff = iv(r, "shift_small")
per.append({"run": r, "deviation_px": dev, "gt_all_intervened": gt_all, "factual_gt_all": S[r]["factual_gt"]["mpjpe_all"], "diff_vs_factual_all": diff})
if not per:
row += ["not available", "—"]; rj["ours"][mkey] = None
continue
mean = {q: float(np.mean([p["deviation_px"][q] for p in per])) for q in ("all", "hm", "h5", "head", "hands")}
fact_mean = float(np.mean([p["factual_gt_all"] for p in per])); gt_mean = float(np.mean([p["gt_all_intervened"] for p in per]))
dmean = float(np.mean([p["diff_vs_factual_all"]["value"] for p in per]))
row += [f"{mean['all']:.2f} ({100 * mean['all'] / fact_mean:.1f} %) · {mean['hm']:.2f} · {mean['h5']:.2f} · {mean['head']:.2f} · {mean['hands']:.2f} [n={len(per)}]", f"{gt_mean:.2f} vs {fact_mean:.2f} [{dmean:+.2f}]"]
rj["ours"][mkey] = {"mean_deviation_px": mean, "mean_gt_all_intervened": gt_mean, "mean_factual_gt_all": fact_mean, "per_seed": per}
out_rows.append(row); out_json.append(rj)
# the sensitivity-without-accuracy point
ks_remove = next(r for r in out_json if r["key"] == "remove ext")["ours"].get("KS")
repro_remove = next(r for r in out_json if r["key"] == "remove ext")["ours"].get("repro")
if ks_remove is None or repro_remove is None: # the update block may be called on a subset of models
ks_remove = ks_remove or {"mean_deviation_px": {"all": float("nan")}, "delta_over_factual_all_pct": float("nan"), "mean_diff_vs_factual_all": float("nan"), "sd_diff_vs_factual_all": float("nan"), "n_seeds_ci_excl_0": 0, "mean_gt_all_intervened": float("nan"), "mean_factual_gt_all": float("nan")}
repro_remove = repro_remove or {"mean_deviation_px": {"all": float("nan")}, "mean_factual_gt_all": float("nan")}
their_acc_change = PAPER_ROWS["w/o ext context"]["mpjpe_all"] - PAPER_MAIN_ALL
point = {
"paper_remove_ext_deviation_px": 12.953, "paper_accuracy_change_without_context_px_table2": their_acc_change, "paper_factual_all": PAPER_MAIN_ALL,
"ours_remove_ext_deviation_px": ks_remove["mean_deviation_px"]["all"], "ours_accuracy_change_under_remove_ext_px": ks_remove["mean_diff_vs_factual_all"],
"ours_factual_all": ks_remove["mean_factual_gt_all"], "ours_all_under_remove_ext": ks_remove["mean_gt_all_intervened"],
"accuracy_advantage_px_factual": PAPER_MAIN_ALL - ks_remove["mean_factual_gt_all"],
"accuracy_advantage_px_under_remove_ext_vs_their_factual": PAPER_MAIN_ALL - ks_remove["mean_gt_all_intervened"],
"repro_remove_ext_deviation_px": repro_remove["mean_deviation_px"]["all"], "repro_factual_all": repro_remove["mean_factual_gt_all"],
}
para = (
f"Sensitivity without accuracy: the paper's rollout moves by {12.953:.2f} px when the exterior features are removed (Table 3, do(Ext=∅)) while its accuracy without "
f"exterior context changes by {their_acc_change:+.2f} px (Table 2, 71.47 → 71.74) — the deviation is 48× the accuracy change, i.e. the exterior pathway steers the rollout "
f"without making it more accurate. Ours: removing the exterior features moves the CockpitWM (+ semantic heads) rollout by {ks_remove['mean_deviation_px']['all']:.2f} px "
f"(n = 3; {ks_remove['delta_over_factual_all_pct']:.1f} % of its factual All) and costs {ks_remove['mean_diff_vs_factual_all']:+.2f} ± {ks_remove['sd_diff_vs_factual_all']:.2f} px of accuracy "
f"(paired, CI excl. 0 on {ks_remove['n_seeds_ci_excl_0']}/3 seeds): {ks_remove['mean_gt_all_intervened']:.2f} px under the intervention vs {ks_remove['mean_factual_gt_all']:.2f} factual, "
f"i.e. {PAPER_MAIN_ALL - ks_remove['mean_factual_gt_all']:.1f} px more accurate than Driver-WM main's factual rollout and still {PAPER_MAIN_ALL - ks_remove['mean_gt_all_intervened']:.1f} px more accurate "
f"with its exterior input removed. Our port of their architecture reproduces their behaviour in our hands: {repro_remove['mean_deviation_px']['all']:.2f} px deviation at "
f"{repro_remove['mean_factual_all'] if 'mean_factual_all' in repro_remove else repro_remove['mean_factual_gt_all']:.2f} px factual All. Deviations in px are not comparable across models whose "
f"factual error differs by 23 px, hence the Δ/All column; the paper reports single-seed deviations without CIs."
)
k_note = ("CockpitWM (keypoint-only) has no exterior input: every do(Ext=·) intervention is the identity on its inputs and every Δ is 0 by construction, so it is not a row here "
"(its All-MPJPE 48.63 ± 0.15 is the 'context removed at training time' level of the (+ semantic heads) model; Section 2 'w/o ext context').")
md = [
f"## Section 3{heading_suffix} — their Table 3 (controlled interventions; Δ px between intervened and factual rollouts) mirrored, with the ACCURACY under each intervention",
"",
"### 3.1 Published Table 3 (verbatim; Driver-WM main, single seed, no CIs)",
"",
md_table(["intervention", "ΔAll", "ΔHM", "Δh=5", "ΔHead", "ΔHands", "ΔAll / 71.47"], [[n, *[f(v, 3) for v in vals], f"{100 * vals[0] / PAPER_MAIN_ALL:.1f} %"] for n, _, vals in OWNER_TYPED_T3]),
"",
"### 3.2 Ours in the same layout (seed means, n = 3; Δ = deviation of the intervened five-step rollout from the factual rollout in px; Δ/All = Δ All ÷ the model's factual All-MPJPE; "
"'All-MPJPE under do(·)' = direct GT error of the intervened rollout, with the paired per-clip difference to the factual rollout and the number of seeds whose 2k-bootstrap CI excludes 0)",
"",
md_table(header, out_rows),
"",
"Operators (aide/eval/interventions.py): swap_ext = exterior features of another test clip (fixed derangement); zero_ext = exterior features zeroed on the observed window; shift_large / small = exterior features delayed 2 / 1 protocol steps "
"(edge-padded); drop_view_* = one exterior view zeroed (row = mean over front / left / right, max view in brackets; the paper's DropView is one number); ext_scale0 / 2 = CockpitWM exterior visual tokens × 0 / × 2 before the trunk "
"(ᵃ analogue of the paper's λ_CA = 0 / 2: the B2 main model has no traffic gate, and λ = 1 is bit-identical to the factual pass); gate_override0/1/2 = the traffic gate of variant (iii) clamped; gate0/1/2 = the reproduction's λ_CA clamped. "
"Head = face + body head joints; Hands = both hands.",
"",
k_note,
"",
"### 3.3 The point",
"",
para,
]
return "\n".join(md), {"published": [{"intervention": n, "key": k, **dict(zip(("all", "hm", "h5", "head", "hands"), v))} for n, k, v in OWNER_TYPED_T3],
"ours": out_json, "point": point, "run_output_checks": checks, "source": source_note or str(INTERV.relative_to(ROOT)),
"interventions_json_command": J.get("command"), "interventions_json_t_end_utc": J.get("t_end_utc"), "k_note": k_note,
"models": [{"key": m[0], "label": m[1], "runs": m[2]} for m in models]}
# ----------------------------------------------------------------------------------------------- verdict + runs needed
def runs_needed():
return [
{"cell": "Table 2 'w/o ext context' for the model that reaches the published F1 (view-gate attention heads)", "run": "not definable: the heads attend over the exterior features; the exterior-free reading is the trunk-state heads (= B2 main reading (a), already in the table)", "cost_gpu_min": 0},
{"cell": "Table 2 'RSSM/GRU dyn.' — recursive decoding at the other locked seeds", "run": "`cwm3d_recursive_s{123,456}_v2` (K recipe, `--rollout recursive`, 3.4× the K time) and `cwm3d_vis_sem_recursive_s{42,123,456}_v2`", "cost_gpu_min": "≈ 2 × 2.0 + 3 × 7 ≈ 25"},
{"cell": "Table 2 'RSSM/GRU dyn.' — recurrent latent dynamics", "run": "new decoder option (GRU state over the 5 future steps) on the K recipe, 3 seeds — needs code, not a flag", "cost_gpu_min": "≈ 3 × 0.6–1.0 after implementation"},
{"cell": "Table 2 'KL bottleneck'", "run": "KL-regularised latent between trunk and horizon head, KS recipe, 3 seeds — needs code", "cost_gpu_min": "≈ 3 × 2–3"},
{"cell": "Table 2 'no-prompt feat.' at the other locked seeds", "run": "`cwm3d_vis_sem_vp_s{123,456}_v2` (`--vis-key vis_pooled`, KS recipe verbatim)", "cost_gpu_min": "≈ 2 × 2–3"},
{"cell": "Table 2 'no-prompt feat.' for the view-gate heads", "run": "`cwm3d_vis_sema_vg_vp_s{42,123,456}_v2` (view-gate recipe with `vis_key=vis_pooled`)", "cost_gpu_min": "≈ 3 × 10–13"},
{"cell": "Table 2 'Non-causal (bidir)'", "run": "none — violates the causal forecasting protocol; not planned", "cost_gpu_min": 0},
{"cell": "Table 3 for the view-gate heads model (readings (a) and (b))", "run": "`aide/eval/interventions.py --run cwm3d_vis_sema_vg_s{42,123,456}_v2` (evaluation only; (b) needs the `__f1sel` checkpoint, which the run directory does not keep)", "cost_gpu_min": "≈ 1 GPU-min per run (eval only; the 9-run pass took 161 s)"},
{"cell": "Table 3 for CockpitWM + BATON trunk (+ semantic heads)", "run": "`aide/eval/interventions.py --run cwm3d_vis_sem_batonpre_trunkp123_s{42,123,456}_v2`", "cost_gpu_min": "≈ 1 GPU-min per run (eval only)"},
]
def verdict(sec1, sec2, sec3):
ours = {r["key"]: r for r in sec1["ours"]}
k3, vga, vgb, ens, repro, dwmkp = ours["K3"], ours["KSvg_a"], ours["KSvg_b"], ours["ensA3"], ours["DWMrepro3"], ours["DWMkp3"]
geo_all = all("every published row" in k3["cells"][c]["verdict"] for c in GEO)
def n_beaten(row, c):
v = row["cells"][c]
if v is None:
return None
rows = pub_rows_with(c); lower = c in LOWER_IS_BETTER
return sum(1 for _, pv in rows if (v["mean"] < pv if lower else v["mean"] > pv)), len(rows)
def vs_main(row):
return {c: (row["cells"][c]["vs_driverwm_main"] if row["cells"][c] else None) for c in F1S}
def not_beaten(row, c):
v = row["cells"][c]["mean"]; lower = c in LOWER_IS_BETTER
return sorted([(r, pv) for r, pv in pub_rows_with(c) if not (v < pv if lower else v > pv)], key=lambda x: x[1], reverse=not lower)
def best_pub(c):
return (min if c in LOWER_IS_BETTER else max)(pub_rows_with(c), key=lambda x: x[1])
n_geo_rows = len(pub_rows_with("mpjpe_all"))
t1 = {
"geometry": f"CockpitWM (3 seeds) is {('lower (errors) / higher (PCK) than every published row that reports the column (' + str(n_geo_rows) + ' of the 18 rows; no pose head reports no geometry) on all 5 geometry columns') if geo_all else 'NOT better than every published row on some geometry column'}; "
+ "; ".join(f"{COLNAME[c]} {f(sec1['margins_K3'][c]['margin'], ND[c], True)} vs best published ({sec1['margins_K3'][c]['best_row']})" for c in GEO)
+ f"; vs Driver-WM main All {sec1['margins_K3']['mpjpe_all']['vs_driverwm_main']:+.2f} px. Driver-WM's architecture on our tokens (Driver-WM-kp) also beats every published row on geometry "
f"(All {dwmkp['cells']['mpjpe_all']['mean']:.2f}) but is WORSE than CockpitWM paired on 3/3 seeds (arch_attribution.md §2: +1.63 / +1.91 / +2.51 px). BETTER.",
"semantics_a": "reading (a), view-gate heads (geometry checkpoint): " + "; ".join(f"{COLNAME[c]} {vga['cells'][c]['mean']:.2f} ({n_beaten(vga, c)[0]}/{n_beaten(vga, c)[1]} published rows below; vs main {vs_main(vga)[c]:+.2f})" for c in F1S)
+ " → above Driver-WM main on 3/4 heads (DBR below), above every published row on TCR only. EQUAL-to-BETTER vs main, WORSE than the best published on DBR / DER / VCR.",
"semantics_b": "reading (b), view-gate heads (val-F1 checkpoint, +1.1 px All): " + "; ".join(f"{COLNAME[c]} {vgb['cells'][c]['mean']:.2f} ({n_beaten(vgb, c)[0]}/{n_beaten(vgb, c)[1]}; vs main {vs_main(vgb)[c]:+.2f})" for c in F1S)
+ f" → above Driver-WM main on {sum(1 for c in F1S if vs_main(vgb)[c] > 0)}/4 heads by " + " / ".join(f"{vs_main(vgb)[c]:+.2f}" for c in F1S)
+ " (their 3-seed sd 1.0–1.8: " + ", ".join(f"{COLNAME[c][3:]} {'outside' if abs(vs_main(vgb)[c]) > 1.8 else 'within'} one sd" for c in F1S) + "); above every published row on "
+ (", ".join(COLNAME[c][3:] for c in F1S if not not_beaten(vgb, c)) or "no head") + "; not above: "
+ "; ".join(f"{COLNAME[c][3:]} — " + ", ".join(f"{r}{'*' if r in NON_CAUSAL else ''} {pv:.2f}" for r, pv in not_beaten(vgb, c)) for c in F1S if not_beaten(vgb, c))
+ ". BETTER than main, EQUAL to the best published variants (all within their 3-seed sd).",
"ensemble": "the 3-seed logit ensemble (not a single model): " + " / ".join(f"{ens['cells'][c]['mean']:.2f}" for c in F1S) + " — "
+ ("above every published row on all four heads (margins over the best published: " + ", ".join(f"{COLNAME[c][3:]} {ens['cells'][c]['mean'] - best_pub(c)[1]:+.2f} vs {best_pub(c)[0]}{'*' if best_pub(c)[0] in NON_CAUSAL else ''}" for c in F1S) + "; the DBR margin is within noise)."
if all(not not_beaten(ens, c) for c in F1S) else
"above every published row on " + (", ".join(COLNAME[c][3:] for c in F1S if not not_beaten(ens, c)) or "no head") + "; not above: "
+ "; ".join(f"{COLNAME[c][3:]} — " + ", ".join(f"{r} {pv:.2f}" for r, pv in not_beaten(ens, c)) for c in F1S if not_beaten(ens, c)) + "."),
"reproduction": f"our port of the published architecture lands at All {repro['cells']['mpjpe_all']['mean']:.2f} ± {repro['cells']['mpjpe_all']['sd']:.2f} (their 71.47) with F1 "
+ " / ".join(f"{repro['cells'][c]['mean']:.2f}" for c in F1S) + " — the semantic heads reproduce, the absolute-coordinate geometry does not (see stage_bc.md C1).",
}
axes = {a["paper_row"]: a for a in sec2["axes"]}
t2 = {
"mirrored": "4 of 7 axes have a run: w/o ext context (paired, 3 seeds), +Skeleton-Pre (paired, 3–5 seeds), no-prompt feat. (1 seed), no pose head (F1, 3 seeds); RSSM/GRU only as a decoding-order analogue (1 seed); KL bottleneck and Non-causal have no mirror.",
"agreement": (f"Direction agrees with theirs on 'w/o ext context' (geometry ≈ unchanged: ours {axes['w/o ext context']['geometry']['mpjpe_all']['mean_delta']:+.2f} px vs their +0.27; semantics collapse in both), "
f"on '+Skeleton-Pre' geometry (ours {axes['+Skeleton-Pre']['geometry']['CockpitWM_5seeds']['mpjpe_all']['mean_delta']:+.2f} px BEATS vs their −0.55) but NOT on its semantics (ours drop, theirs rise), "
f"and on 'no pose head' DER (ours {axes['no pose head']['f1']['f1_der']['delta']:+.2f} vs their −1.69). Our ablation Δs are an order of magnitude smaller in px than theirs because the "
"keypoint-anchored residual formulation pins the rollout to the last pose; theirs regress absolute coordinates."),
"verdict": "EQUAL in structure (same signs where mirrored), BETTER in evidence (paired CIs over seeds vs single-seed differences); 3 cells open (listed below).",
}
pt = sec3["point"]
by_key = {r["key"]: r for r in sec3["ours"]}
dis_ks = by_key["disable pathway"]["ours"]["KS"]["mean_deviation_px"]["all"]; dis_g = by_key["disable pathway"]["ours"]["KSg"]["mean_deviation_px"]["all"]
dv_ks = by_key["drop view"]["ours"]["KS"]["mean_deviation_px"]["all"]; dv_paper = by_key["drop view"]["paper_delta"]["all"]
t3 = {
"sensitivity": f"their do(Ext=∅) deviation 12.95 px (18.1 % of factual All) vs ours {pt['ours_remove_ext_deviation_px']:.2f} px ({100 * pt['ours_remove_ext_deviation_px'] / pt['ours_factual_all']:.1f} %); "
f"their do(λ_CA=0) {by_key['disable pathway']['paper_delta']['all']:.1f} px vs our token-scaling analogue {dis_ks:.2f} px (gated variant (iii) {dis_g:.2f} px); our reproduction of their architecture: {pt['repro_remove_ext_deviation_px']:.2f} px for do(Ext=∅).",
"accuracy": f"their accuracy without context changes by {pt['paper_accuracy_change_without_context_px_table2']:+.2f} px (Table 2) at 71.47 px; ours changes by {pt['ours_accuracy_change_under_remove_ext_px']:+.2f} px at "
f"{pt['ours_factual_all']:.2f} px — {pt['accuracy_advantage_px_factual']:.1f} px more accurate factual, {pt['accuracy_advantage_px_under_remove_ext_vs_their_factual']:.1f} px more accurate even with the exterior input removed.",
"verdict": f"BETTER: smaller, CI-bounded deviations with the paired accuracy cost reported, at {pt['accuracy_advantage_px_factual']:.0f} px better absolute accuracy; the paper's large deviations are sensitivity without accuracy. Their single-seed Δ carry no CI; the 'drop view' comparison ({dv_paper:.2f} theirs vs {dv_ks:.2f} ours, mean over three views) is the one cell where ours is the more sensitive model, on a 1-of-3-views operator whose paper definition is unspecified.",
}
return {"table1": t1, "table2": t2, "table3": t3, "runs_needed": runs_needed()}
def verdict_md(v):
md = ["## Verdict", "", "### Table 1 — main results", ""]
md += [f"- **Geometry:** {v['table1']['geometry']}", f"- **Semantics (a):** {v['table1']['semantics_a']}", f"- **Semantics (b):** {v['table1']['semantics_b']}",
f"- **Ensemble:** {v['table1']['ensemble']}", f"- **Reproduction:** {v['table1']['reproduction']}", "", "### Table 2 — ablations", "",
f"- {v['table2']['mirrored']}", f"- {v['table2']['agreement']}", f"- **Verdict:** {v['table2']['verdict']}", "", "### Table 3 — interventions", "",
f"- {v['table3']['sensitivity']}", f"- {v['table3']['accuracy']}", f"- **Verdict:** {v['table3']['verdict']}", "",
"### Runs that would complete the mirror (none launched; K ≈ 0.6 GPU-min, KS ≈ 2–3 GPU-min, view-gate heads ≈ 10–13 GPU-min per seed)", "",
md_table(["cell", "run needed", "cost (GPU-min)"], [[r["cell"], r["run"], str(r["cost_gpu_min"])] for r in v["runs_needed"]])]
return "\n".join(md)
# ----------------------------------------------------------------------------------------------- main
UPDATE_TRAININGS = ["cwm3d_recursive_s123_v2", "cwm3d_recursive_s456_v2", "cwm3d_vis_sem_vp_s123_v2", "cwm3d_vis_sem_vp_s456_v2"]
UPDATE_INTERV_RUNS = [r for m in MODELS3_UPDATE_EXTRA for r in m[2]]
PREREG = "docs/decisions.md 2026-09-14 PRE-REGISTRATION (2026-09-15T02:45:58Z) — mirror completion: DESCRIPTIVE, NO ADOPTION"
def run_status(run):
d = RUNS / run
js = sorted(d.glob(f"run_{run}_2*.json")) if d.exists() else []
if not js:
return {"run": run, "status": "missing"}
j = json.load(open(js[-1]))
m = json.load(open(d / "metrics_test.json"))["metrics"] if (d / "metrics_test.json").exists() else {}
return {"run": run, "status": "done", "gpu_minutes": j.get("gpu_minutes"), "best_epoch": j.get("best_epoch"), "epochs_run": j.get("epochs_run"),
"stop_reason": j.get("stop_reason"), "val_all_best": j.get("best_val_mpjpe_all"), "test_all": m.get("mpjpe_all", {}).get("value"),
"test_hm": m.get("mpjpe_hm", {}).get("value"), "notes": j.get("config", {}).get("notes"), "run_json": str(js[-1].relative_to(ROOT))}
def update_block(store, master, stamp):
tr = [run_status(r) for r in UPDATE_TRAININGS]
iv = []
for r in UPDATE_INTERV_RUNS:
rec, path = latest_per_run(r)
iv.append({"run": r, "status": "done" if rec else "missing", "file": path, "n_interventions": len(rec["interventions"]) if rec else 0,
"rebuild_maxdiff_px": rec.get("rebuild_maxdiff_px") if rec else None, "factual_all": rec["factual_gt"]["mpjpe_all"] if rec else None})
s2_md, s2 = section2(store, master)
s2_md = s2_md.replace("## Section 2 —", f"## Section 2 (update {stamp}) —", 1)
models = [MODELS3[0], MODELS3_UPDATE_EXTRA[0], MODELS3_UPDATE_EXTRA[1], MODELS3[1], MODELS3[2]]
S, src = load_interventions_per_run(models)
s3_md, s3 = section3(S, models, source_note="aide/results/runs/<run>/interventions_2*.json (newest per run; the tables' run_interventions_latest.json pointer is not used here)",
heading_suffix=f" (update {stamp})")
axes = {a["paper_row"]: a for a in s2["axes"]}
rec_ax, vp_ax = axes["RSSM/GRU"], axes["no-prompt feat"]
by_key = {r["key"]: r for r in s3["ours"] if r.get("key")}
def cell(key, mkey):
o = by_key[key]["ours"].get(mkey)
return o
lines = []
ks_r, vg_r, pre_r = cell("remove ext", "KS"), cell("remove ext", "KSvg_a"), cell("remove ext", "KS_pre")
ks_s, vg_s, pre_s = cell("swap", "KS"), cell("swap", "KSvg_a"), cell("swap", "KS_pre")
def dev_txt(o):
return "n/a" if not o else f"{o['mean_deviation_px']['all']:.2f} px ({o['delta_over_factual_all_pct']:.1f} % of factual All {o['mean_factual_gt_all']:.2f}); accuracy cost {o['mean_diff_vs_factual_all']:+.2f} ± {o['sd_diff_vs_factual_all']:.2f} px (CI excl. 0 on {o['n_seeds_ci_excl_0']}/{o['n']} seeds)"
verdict = {
"table2_rssm": f"RSSM/GRU dyn. ↔ recursive decoding, now {rec_ax['geometry']['n_pairs']} seeds: Δ All {fmt_short(rec_ax['geometry'], 'mpjpe_all')} px ({rec_ax['geometry']['mpjpe_all']['verdict']}), "
f"Δ HM {fmt_short(rec_ax['geometry'], 'mpjpe_hm')} ({rec_ax['geometry']['mpjpe_hm']['verdict']}), Δ PCK {fmt_short(rec_ax['geometry'], 'pck05')} ({rec_ax['geometry']['pck05']['verdict']}); "
"their recurrent dynamics cost +6.95 px All — the decoding order is not where their loss comes from.",
"table2_noprompt": f"no-prompt feat. ↔ vis_pooled, now {vp_ax['geometry']['n_pairs']} seeds: Δ All {fmt_short(vp_ax['geometry'], 'mpjpe_all')} px ({vp_ax['geometry']['mpjpe_all']['verdict']}), "
f"Δ HM {fmt_short(vp_ax['geometry'], 'mpjpe_hm')} ({vp_ax['geometry']['mpjpe_hm']['verdict']}); F1 Δ (a) " + fmt_f1b(vp_ax["f1"])
+ "; theirs +5.07 px All and −13.28 TCR — the prompt matters for their absolute-coordinate model, not for a residual forecaster whose heads read the trunk state.",
"table3_viewgate": f"view-gate (a) checkpoints (the model that reaches the published F1): do(Ext=∅) {dev_txt(vg_r)}; do(Ext=Swap) {dev_txt(vg_s)} — vs B2 main do(Ext=∅) {dev_txt(ks_r)}.",
"table3_batontrunk": f"CockpitWM (+ semantic heads) + BATON trunk: do(Ext=∅) {dev_txt(pre_r)}; do(Ext=Swap) {dev_txt(pre_s)}.",
"reading": "Every completed cell keeps the first block's reading: exterior interventions move CockpitWM rollouts by a few px at an accuracy cost of a fraction of a px, at ≈ 23 px better factual accuracy than Driver-WM main, whose do(Ext=∅) deviation is 12.95 px; nothing is adopted or changed in the headline rows.",
}
remaining = [r for r in runs_needed() if not (("recursive decoding at the other locked seeds" in r["cell"]) or ("'no-prompt feat.' at the other locked seeds" in r["cell"])
or ("Table 3 for the view-gate heads model" in r["cell"]) or ("Table 3 for CockpitWM + BATON trunk" in r["cell"]))]
remaining.append({"cell": "Table 3 for the view-gate reading-(b) checkpoints", "run": "not possible without retraining with checkpoint retention: the `__f1sel` checkpoints were not kept (only pred/metrics)", "cost_gpu_min": "≈ 3 × 10–13 (retrain) + eval"})
md = [
"", "", "---", "",
f"## Update {stamp} — mirror completion (pre-registered: {PREREG}; the first block above is unchanged)",
"",
"Runs added by `aide/train/run_mirror_completion.sh` (recipe verbatim, val-only selection, test evaluated once; launch gate: free VRAM ≥ need + 4 GB, MemAvailable ≥ 28 GB, < 2 trainers; log `aide/results/mirror_completion/lane.log`):",
"",
md_table(["training run", "status", "GPU min", "best epoch / epochs / stop", "val All (selection)", "test All", "test HM", "notes"],
[[r["run"], r["status"], f(r.get("gpu_minutes"), 2), f"{r.get('best_epoch')} / {r.get('epochs_run')} / {r.get('stop_reason')}" if r["status"] == "done" else "—",
f(r.get("val_all_best"), 2), f(r.get("test_all"), 2), f(r.get("test_hm"), 2), r.get("notes") or "—"] for r in tr]),
"",
md_table(["intervention pass (eval only, `aide/eval/interventions.py --cuda --n-boot 2000`)", "status", "file", "operators", "rebuild max abs(pred − stored) px", "factual All"],
[[r["run"], r["status"], r["file"] or "—", str(r["n_interventions"]), f(r["rebuild_maxdiff_px"], 6) if r["rebuild_maxdiff_px"] is not None else "—", f(r["factual_all"], 2)] for r in iv]),
"",
s2_md, "", s3_md, "",
"### Verdict (update)", "",
*[f"- {v}" for v in verdict.values()], "",
"### Still open after this update", "",
md_table(["cell", "run needed", "cost (GPU-min)"], [[r["cell"], r["run"], str(r["cost_gpu_min"])] for r in remaining]),
]
return "\n".join(md), {"stamp": stamp, "prereg": PREREG, "trainings": tr, "interventions": iv, "section2": s2, "section3": s3, "verdict": verdict, "remaining": remaining}
def decisions_update_row(upd):
tr = {r["run"]: r for r in upd["trainings"]}
axes = {a["paper_row"]: a for a in upd["section2"]["axes"]}
rec_g, vp_g = axes["RSSM/GRU"]["geometry"], axes["no-prompt feat"]["geometry"]
by_key = {r["key"]: r for r in upd["section3"]["ours"] if r.get("key")}
def dv(key, m):
o = by_key[key]["ours"].get(m)
return "n/a" if not o else f"{o['mean_deviation_px']['all']:.2f} px, accuracy {o['mean_diff_vs_factual_all']:+.2f} ± {o['sd_diff_vs_factual_all']:.2f} (CI excl. 0 on {o['n_seeds_ci_excl_0']}/{o['n']})"
gpu = sum((r.get("gpu_minutes") or 0) for r in upd["trainings"] if r["status"] == "done")
done_iv = sum(1 for r in upd["interventions"] if r["status"] == "done")
text = (f"**Mirror completion OUTCOME ({upd['stamp']}; descriptive, no adoption; pre-registered 2026-09-15T02:45:58Z).** Trainings ({gpu:.1f} GPU-min, all recipe verbatim, val-only selection, test once): "
+ "; ".join(f"`{r}` {tr[r]['status']}" + (f" (test All {tr[r]['test_all']:.2f}, {tr[r]['gpu_minutes']:.2f} GPU-min, best ep {tr[r]['best_epoch']})" if tr[r]["status"] == "done" else "") for r in UPDATE_TRAININGS)
+ f". Intervention passes: {done_iv}/{len(upd['interventions'])} done (`__do_*` run dirs + per-run interventions json; the tables' run_interventions_latest.json pointer now points at the last pass and is not used by the report). "
f"**Table 2:** RSSM/GRU dyn. ↔ recursive decoding at {rec_g['n_pairs']} seeds: Δ All {fmt_short(rec_g, 'mpjpe_all')} px ({rec_g['mpjpe_all']['verdict']}), Δ HM {fmt_short(rec_g, 'mpjpe_hm')} ({rec_g['mpjpe_hm']['verdict']}) vs their +6.95; "
f"no-prompt feat. ↔ vis_pooled at {vp_g['n_pairs']} seeds: Δ All {fmt_short(vp_g, 'mpjpe_all')} px ({vp_g['mpjpe_all']['verdict']}), F1 Δ (a) {fmt_f1b(axes['no-prompt feat']['f1'])} vs their +5.07 px / −13.28 TCR. "
f"**Table 3:** view-gate (a) do(Ext=∅) {dv('remove ext', 'KSvg_a')}, do(Swap) {dv('swap', 'KSvg_a')}; CockpitWM (+ semantic heads) + BATON trunk do(Ext=∅) {dv('remove ext', 'KS_pre')}, do(Swap) {dv('swap', 'KS_pre')}; "
f"B2 main reference do(Ext=∅) {dv('remove ext', 'KS')}; the paper's do(Ext=∅) is 12.95 px at 71.47 factual. New block `## Update {upd['stamp']}` appended to `driverwm_tables_headtohead.md` (first block unchanged), JSON key `updates`. "
"Still open: GRU-latent and KL-bottleneck variants (need code), vis_pooled on the view-gate heads (≈ 3 × 10–13 GPU-min), Table 3 on the (b) checkpoints (not kept). A stray LANE_DONE line from the DRY_RUN sits in pids.txt before the real START lines.")
assert "|" not in text
return (f"| 2026-09-14 | {text} | `aide/results/tables/driverwm_tables_headtohead.md` (update block), `.json` (`updates`), `aide/results/mirror_completion/lane.log`, `pids.txt`, run dirs `cwm3d_recursive_s{{123,456}}_v2`, "
f"`cwm3d_vis_sem_vp_s{{123,456}}_v2`, `<run>__do_*` | Nothing adopted; the head-to-head Table-2 mirror is 3-seed on 4 of 7 axes and Table 3 covers the view-gate and BATON-trunk models; paper wording unchanged. |\n")
def append_atomic(path: Path, text: str):
fd = os.open(path, os.O_WRONLY | os.O_APPEND)
try:
os.write(fd, text.encode("utf-8"))
finally:
os.close(fd)
def main(argv=None):
ap = argparse.ArgumentParser()
ap.add_argument("--no-decisions", action="store_true", help="do not append the decisions.md row")
ap.add_argument("--append-block", action="store_true", help="append the mirror-completion update block to the existing md/json instead of regenerating")
ap.add_argument("--preview", action="store_true", help="with --append-block: write the block to aide/results/mirror_completion/preview_headtohead.md only (no md/json/decisions change)")
ap.add_argument("--overwrite", action="store_true", help="allow regenerating the first block over an existing file")
a = ap.parse_args(argv)
t0 = time.time()
stamp = time.strftime("%Y%m%dT%H%M%SZ", time.gmtime())
master = json.load(open(MASTER))
store = Store()
if a.append_block:
upd_md, upd = update_block(store, master, stamp)
if a.preview:
out = ROOT / "aide/results/mirror_completion/preview_headtohead.md"
out.parent.mkdir(parents=True, exist_ok=True)
out.write_text(upd_md)
print(f"[headtohead] preview written to {out.relative_to(ROOT)} in {time.time() - t0:.1f} s")
return 0
assert OUT_MD.exists() and OUT_JSON.exists(), "first block missing; run without --append-block first"
append_atomic(OUT_MD, upd_md + "\n")
J = json.load(open(OUT_JSON))
J.setdefault("updates", []).append(upd)
OUT_JSON.write_text(json.dumps(J, indent=1, default=float))
print(f"[headtohead] appended update block {stamp} to {OUT_MD.relative_to(ROOT)} and .json in {time.time() - t0:.1f} s")
if not a.no_decisions:
append_atomic(DECISIONS, decisions_update_row(upd))
print("[headtohead] appended one decisions.md outcome row")
return 0
if OUT_MD.exists() and not a.overwrite:
print(f"[headtohead] {OUT_MD.relative_to(ROOT)} exists; pass --overwrite to regenerate the first block or --append-block to add an update")
return 2
problems, n_seen = cross_check()
s1_md, s1 = section1(store, master)
s2_md, s2 = section2(store, master)
s3_md, s3 = section3()
v = verdict(s1, s2, s3)
n_bad_checks = sum(1 for c in s3["run_output_checks"] if c["match"] is not True)
head = [
"# Driver-WM paper (arXiv 2605.05092v2) — three tables, row by row, against our AIDE results (official test split, n = 609)",
"",
f"Generated {stamp} by `aide/eval/report_driverwm_headtohead.py`. Naming: **CockpitWM** = our keypoint forecaster; **CockpitWM (+ semantic heads)** = the same trunk with the semantic heads and the exterior "
"Qwen features; **Driver-WM architecture on CockpitWM tokens** = the published architecture fed our keypoint part tokens (shared recipe); **Driver-WM reproduction** = our port of the published model. "
"Sources: our LEVELS from `aide/results/tables/master_aide.json` (report_master_aide.py; "
f"{master['check']['n_runs']} runs recomputed from `pred_test.npz`, max |Δ| vs metrics_test.json = {master['check']['max_abs_diff']:.0e}, {len(master['check']['mismatches'])} mismatches); "
"the 95 % CIs of the seed-mean levels and every paired Δ recomputed here from `pred_test.npz` with `aide/eval/metrics.py` (clip bootstrap 10k, seed 0; F1 2k joint resamples); runs that master_aide.json does not group "
"(kp+sem no-vision (ii), semantic-only, vis_pooled, recursive rollout) evaluated the same way; interventions from `run_interventions_latest.json` with every per-run `__do_*` metrics_test.json re-read "
f"({len(s3['run_output_checks'])} files, {n_bad_checks} mismatches). Locked protocol: driver `first`, grid `floor`, 5 → 5 protocol frames, HM top 60 (threshold {store.hm_thr:.2f} px), PCK@0.05 = {store.pck_thr:.0f} px. "
"Published numbers were typed by the owner in the brief and are the ground truth of what the paper reports.",
"",
"## 0. Cross-check of the typed tables",
"",
(f"Owner-typed Table 1 (12 rows), Table 2 (7 rows) and Table 3 (7 rows) vs `aide/eval/paper_rows.py` (PAPER_ROWS / PAPER_T3_FULL) and vs the {n_seen} published rows rendered in `stage_bc.md` §1b: "
+ ("**no discrepancy** (every cell identical)." if not problems else "**DISCREPANCIES:** " + "; ".join(problems))),
"",
]
md = "\n".join(head) + "\n" + s1_md + "\n\n" + s2_md + "\n\n" + s3_md + "\n\n" + verdict_md(v) + "\n"
out = {"generated_utc": stamp, "script": "aide/eval/report_driverwm_headtohead.py", "n_test": store.N, "protocol": {"hm_threshold_px": store.hm_thr, "pck05_threshold_px": store.pck_thr, "diag_px": P.DIAG},
"sources": {"levels": str(MASTER.relative_to(ROOT)), "master_check": master["check"], "master_generated_utc": master["generated_utc"], "interventions": str(INTERV.relative_to(ROOT)),
"paired_and_ci": "recomputed from aide/results/runs/<run>/pred_test.npz with aide/eval/metrics.py"},
"cross_check": {"problems": problems, "stage_bc_rows_checked": n_seen},
"section1": s1, "section2": s2, "section3": s3, "verdict": v, "wall_s": round(time.time() - t0, 1)}
OUT_MD.write_text(md)
OUT_JSON.write_text(json.dumps(out, indent=1, default=float))
print(f"[headtohead] wrote {OUT_MD.relative_to(ROOT)} and .json in {time.time() - t0:.1f} s; cross-check problems: {len(problems)}; intervention file checks: {len(s3['run_output_checks'])} ({n_bad_checks} bad)")
if not a.no_decisions:
k3 = s1["margins_K3"]; ours = {r["key"]: r for r in s1["ours"]}
vgb = ours["KSvg_b"]["cells"]; pt = s3["point"]
row = (f"| 2026-09-14 | **Driver-WM three-table head-to-head written** (`aide/results/tables/driverwm_tables_headtohead.md` + .json; generator `aide/eval/report_driverwm_headtohead.py`; "
f"levels from `master_aide.json` ({master['check']['n_runs']} runs, 0 mismatches), CIs / paired Δ recomputed from `pred_test.npz`, interventions from `run_interventions_latest.json` with the per-run `__do_*` metrics re-read; "
f"owner-typed Tables 1–3 vs `paper_rows.py` and `stage_bc.md` §1b: {len(problems)} discrepancies). **Table 1:** CockpitWM (3 seeds) lower / higher than every published row that reports the column (17/17) on all 5 geometry columns "
f"(All {k3['mpjpe_all']['ours_K3']:.2f} vs best published 52.89 Zero-Velocity → {k3['mpjpe_all']['margin']:+.2f} px, vs Driver-WM main {k3['mpjpe_all']['vs_driverwm_main']:+.2f}; HM {k3['mpjpe_hm']['margin']:+.2f} vs Static pooling; PCK {k3['pck05']['margin']:+.2f}); "
f"every published row is ≥ zero-velocity on All (closest: Static pooling 68.50). Semantics: view-gate heads (b) {vgb['f1_dbr']['mean']:.1f} / {vgb['f1_der']['mean']:.1f} / {vgb['f1_tcr']['mean']:.1f} / {vgb['f1_vcr']['mean']:.1f} above Driver-WM main on 4/4 heads, above every published row on VCR only "
f"((a): TCR only); ensemble above every row on all four. Published rows are single-seed and cannot be paired. **Table 2:** 4/7 axes mirrored (w/o ext context: geometry "
f"{s2['axes'][0]['geometry']['mpjpe_all']['mean_delta']:+.2f} px paired vs their +0.27, semantics collapse in both; +Skeleton-Pre: BATON trunk {s2['axes'][2]['geometry']['CockpitWM_5seeds']['mpjpe_all']['mean_delta']:+.2f} px BEATS (5 seeds) vs their −0.55, but our F1 falls where theirs rises; "
f"no-prompt 1 seed; no pose head F1 3 seeds); RSSM/GRU only as the recursive-decoding analogue (+0.18 px, 1 seed); KL bottleneck and Non-causal have no mirror. **Table 3:** their do(Ext=∅) moves the rollout 12.95 px while their accuracy without context changes 0.27 px (sensitivity without accuracy); "
f"ours moves {pt['ours_remove_ext_deviation_px']:.2f} px and costs {pt['ours_accuracy_change_under_remove_ext_px']:+.2f} px at {pt['accuracy_advantage_px_factual']:.1f} px better factual accuracy; our port of their architecture deviates {pt['repro_remove_ext_deviation_px']:.2f} px. "
f"No training launched; the runs that would complete the mirror are listed with cost (recursive at 2 more seeds ≈ 4 GPU-min, vis_pooled at 2 seeds ≈ 5, view-gate interventions eval-only ≈ 1/run; KL / GRU variants need code). | "
f"`aide/results/tables/driverwm_tables_headtohead.md`, `.json`; `master_aide.md`; `run_interventions_latest.json`; `arch_attribution.md` §2; `baton_pretrain.md` §6–8 | "
f"Paper wording: geometry claims 'lower than every published row' per column with the seed-mean CI; semantic claims 'above Driver-WM main on 4/4 heads under (b), single-seed published rows' — never 'SOTA'; Table-3 paragraph: sensitivity without accuracy (theirs) vs small CI-bounded deviations at 23 px better accuracy (ours). |\n")
fd = os.open(DECISIONS, os.O_WRONLY | os.O_APPEND)
try:
os.write(fd, row.encode("utf-8")) # one write, O_APPEND → atomic append of the whole row
finally:
os.close(fd)
print("[headtohead] appended one decisions.md row")
return 0
if __name__ == "__main__":
sys.exit(main())

Xet Storage Details

Size:
85.7 kB
·
Xet hash:
701a5a30d505b91a2f0fa1b6d6b85cbaa7c52cd180883480b804f6f8e06b9105

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.