Buckets:
| #!/usr/bin/env python3 | |
| r"""gen_tables.py — regenerates paper/tables/tab_*.tex from the verified markdown result tables. | |
| Policy (paper/NUMBERS_POLICY.md): every number in an emitted .tex is copied VERBATIM from one of the | |
| source markdown tables listed in SOURCES below (no recomputation, no re-rounding); the source path and | |
| section are written into a LaTeX comment at the top of every emitted file and named in its \\caption. | |
| Verdict tokens (kill_checks.beats) are rendered with the agreed wording: BEATS -> "better" (significantly | |
| better), WORSE -> "worse" (significantly worse), INCONCLUSIVE -> "n.s.", NOT_WORSE -> "not worse" | |
| (both: no significant difference). Pre-registered PASS / FAIL stay PASS / FAIL. | |
| Usage: python3 paper/tables/gen_tables.py # regenerate every agreed table + run the number check | |
| python3 paper/tables/gen_tables.py --check # only verify that every source file exists | |
| python3 paper/tables/gen_tables.py --verify # only run the verbatim-number check on the emitted .tex | |
| python3 paper/tables/gen_tables.py --sample 5 # number of random tokens per table to print in the check | |
| python3 paper/tables/gen_tables.py --style iclr --out /home/USER/project/baton_paper/ICLR/tables | |
| # ICLR / AAAI-visual style (cwtable env, caption above, \headrow/\oursrow/\best, | |
| # short captions, CockpitWM names); --verify --style iclr --out DIR checks that dir | |
| --out DIR # output directory (default: paper/tables for ieee, ICLR_OUT for iclr) | |
| The ICLR style additionally emits the ICLR-only tables (ICLR_GENERATORS: four main-text tables, the user-study | |
| scaffold, the identifier map, the AIDE architecture-attribution supplement table and -- only when aide/results/tables/kv2_program.md | |
| exists -- the validation-screened-variant (K-v2) programme supplement table; only when master_aide.md exists -- the AIDE master table); | |
| the IEEE run is unchanged (same 19 tables, same files). Owner rule 2026-09-15: the ICLR output carries ONE model name, CockpitWM | |
| (see _NM / _FORBIDDEN_NAMES); tab_main_aide carries no re-instantiated generic encoder rows (owner decision 2026-09-15). | |
| Owner decisions 2026-09-17 (docs/decisions.md row 443, items 3 and 5): the ICLR output carries FOUR driver cells (the ENGAGED hand_leave / | |
| hand_return cells are dropped or rendered '--') and no MotionBERT architecture-family control row (OMIT_* below; emit_iclr() refuses survivors); | |
| tab_road_dynamics is a main-text table (owner item 7) and tab_supp_oracle_diag is the Supp. C oracle-feature diagnostic (owner item 8). | |
| """ | |
| from __future__ import annotations | |
| import argparse | |
| import datetime as _dt | |
| import pathlib | |
| import random | |
| import re | |
| import sys | |
| import textwrap | |
| ROOT = pathlib.Path("/home/USER/cwm3") | |
| OUT = ROOT / "paper" / "tables" | |
| BT = ROOT / "results" / "tables" # BATON tables | |
| AT = ROOT / "aide" / "results" / "tables" # AIDE tables | |
| DOCS = ROOT / "docs" | |
| TODAY = _dt.date.today().isoformat() | |
| # ---------------------------------------------------------------------------------------------- | |
| # output style: "ieee" (IEEE draft, table*/scriptsize, long captions) or "iclr" (ICLR 2027 manuscript, AAAI visual style) | |
| # ---------------------------------------------------------------------------------------------- | |
| STYLE = "ieee" | |
| ICLR_OUT = pathlib.Path("/home/USER/project/baton_paper/ICLR/tables") | |
| # model-name mapping for the ICLR manuscript (applied to every cell, header, group row and caption; longest first). | |
| # The string CWM3 / cwm3 must not survive in any ICLR output (checked by verify()). | |
| _NM = [(r"\texttt{cwm3/} repository root", "repository root"), | |
| # R2 WP1 (2026-09-16): the warning comparator is a 3-seed trained chain reproducing the logged openpilot attention alerts | |
| # (docs/dms_att_chain.md:24-32, 135-136, 216-217), not a version-matched replay of the openpilot rules -> "openpilot-derived surrogate". | |
| ("openpilot DMS attention chain", "openpilot-derived surrogate"), ("openpilot attention chain", "openpilot-derived surrogate"), | |
| ("DMS attention chain", "openpilot-derived surrogate"), ("openpilot DMS chain", "openpilot-derived surrogate"), | |
| (r"$\Delta$ vs DMS chain", r"$\Delta$ vs surrogate"), (r"$\Delta$ vs DMS (pooled)", r"$\Delta$ vs surrogate (pooled)"), | |
| (r"$\Delta$ vs DMS,", r"$\Delta$ vs surrogate,"), (r"$\Delta$ vs DMS = ", r"$\Delta$ vs surrogate = "), | |
| (r"vs DMS att@3\,s at", r"vs the surrogate (att@3\,s) at"), ("the DMS chain's", "the surrogate's"), | |
| ("the DMS row", "the surrogate row"), ("DMS row at", "surrogate row at"), | |
| ("DMS att@3s", "surrogate (att@3s)"), # operating_points.md score label of the comparator rows | |
| # owner rule 2026-09-15: the model has ONE name, CockpitWM. Every internal or earlier display name (CWM3-D-kp, CockpitWM-K, | |
| # CockpitWM-KS, K-v2, Driver-WM-kp) is rewritten into words; emit_iclr() refuses any survivor (_FORBIDDEN_NAMES). Longest first. | |
| # master_aide.md row labels, shortened so that the rows stay on one or two lines of the 0.23-linewidth label column. | |
| # Owner item 9 (2026-09-15): every configuration row names its checkpoint in words — "geometry checkpoint (a)" = selected on validation | |
| # All-MPJPE, "semantic checkpoint (b)" = selected on validation macro-F1 — plus "+ BATON pretraining" / "view-gate heads" and the seed set. | |
| ("CockpitWM-KS (n=3, locked seeds 42/123/456)", "CockpitWM-KS, geometry checkpoint (a), 3 seeds"), | |
| ("CockpitWM-KS (n=5, seeds 42/123/456/789/1011)", "CockpitWM-KS, geometry checkpoint (a), 5 seeds"), | |
| ("CockpitWM-KS + BATON trunk (n=3)", "CockpitWM-KS + BATON pretraining, geometry checkpoint (a), 3 seeds"), | |
| ("(n=3, locked seeds 42/123/456)", "(3 seeds)"), ("(n=5, seeds 42/123/456/789/1011)", "(5 seeds)"), | |
| (" + view-gate attention heads, (a) geometry-selected checkpoint (n=3)", ", view-gate heads, geometry checkpoint (a), 3 seeds"), | |
| (" + view-gate attention heads, (b) val-F1-selected checkpoint (n=3)", ", view-gate heads, semantic checkpoint (b), 3 seeds"), | |
| (" + view-gate heads + BATON trunk, (a) geometry-selected checkpoint (n=3)", ", view-gate heads, + BATON pretraining, geometry checkpoint (a), 3 seeds"), | |
| (" + view-gate heads + BATON trunk, (b) val-F1-selected checkpoint (n=3)", ", view-gate heads, + BATON pretraining, semantic checkpoint (b), 3 seeds"), | |
| # owner item 3 (2026-09-15): "single seed" for the published rows -> "single runs (Tables 1--3); Table 8 gives three seeds" (master group row, post-tx text) | |
| ("Published --- single seed, typed from the Driver-WM paper", "Published --- single runs (Tables 1--3 of the paper; its Table 8 gives three seeds for the main model), typed from the Driver-WM paper"), | |
| ("(n=5; K-v2 programme, not adopted)", "(5 seeds; not adopted)"), ("(n=5; not adopted)", "(5 seeds; not adopted)"), | |
| ("(n=5; MB-best of the K-v2 val grid)", "(5 seeds; validation-tuned)"), ("MotionBERT-kp, default recipe (n=5)", "MotionBERT-kp (5 seeds)"), | |
| ("Driver-WM reproduction (our port of the published architecture, n=3)", "Driver-WM reproduction (our port, 3 seeds)"), | |
| (" --- ensemble, not a single model", ""), ("(n=3)", "(3 seeds)"), ("(n=5)", "(5 seeds)"), | |
| ("+ BATON trunk", "+ BATON pretraining"), | |
| ("CockpitWM-K-v2 nospatial", "validation-screened CockpitWM variant (nospatial)"), | |
| ("CockpitWM-K-v2", "validation-screened CockpitWM variant"), | |
| ("MB-best of the K-v2 val grid", "MB-best of the validation grid"), | |
| ("K-v2 programme", "validation-screening programme"), | |
| ("K-v2", "validation-screened CockpitWM variant"), | |
| ("CWM3-D-kp", "CockpitWM"), ("CWM3-D vis+sem", "CockpitWM (+ semantic heads)"), ("CWM3-D vis + ", "CockpitWM (+ semantic heads), "), | |
| ("CockpitWM-KS", "CockpitWM (+ semantic heads)"), ("CockpitWM-K", "CockpitWM"), | |
| ("\\cwname-KS", "\\cwname{} with semantic heads"), ("\\cwname-K", "\\cwname{}"), | |
| ("Driver-WM-kp (Driver-WM architecture on the keypoint part tokens, n=3)", "Driver-WM architecture on CockpitWM tokens (3 seeds)"), | |
| ("Driver-WM-kp", "Driver-WM arch.\\ on CockpitWM tokens"), | |
| ("CWM3-D", "CockpitWM"), | |
| ("cwm3\\_W", "CockpitWM head"), ("cwm3_W", "CockpitWM head"), | |
| ("cwm3\\_I", "CockpitWM composition"), ("cwm3_I", "CockpitWM composition"), | |
| ("cwm3-native", "CockpitWM-native"), ("CWM3", "CockpitWM"), | |
| ("cwm2", "earlier system")] # the earlier CAN-only system is never named by its internal tag in the manuscript | |
| def nm(s: str) -> str: | |
| """ICLR name mapping (identity in IEEE style).""" | |
| if STYLE != "iclr": | |
| return s | |
| for a, b in _NM: | |
| s = s.replace(a, b) | |
| return re.sub(r"cwm3", "CockpitWM", s, flags=re.I) | |
| # ---------------------------------------------------------------------------------------------- | |
| # Owner presentation decision (2026-09-15): the SIX-EPOCH matched-baseline-pretraining experiment -- "MotionBERT architecture + BATON | |
| # pretraining" and "ST-GCN architecture + BATON pretraining" (run families motionbert_kp_batonpre_trunkp123_*, motionbert_kp_do0.1_batonpre_*, | |
| # stgcn_kp_batonpre_trunkp123_* and their pretraining runs) -- is NOT reported in the paper or the supplement; it is superseded by the | |
| # CONVERGED matched comparison of the pretraining programme (pretrain_variants.md §4, reported in tab_supp_pretrain_variants). Every generator that would emit one of these rows drops it | |
| # through this explicit list (label substrings, matched against the raw source label and against the rendered label); | |
| # emit_iclr() refuses any survivor. The internal result tables (aide/results/tables/*.md) are untouched and no remaining cell value | |
| # changes; the CockpitWM pretraining result itself (tab_main_transfer, tab_app_transfer, master rows "+ BATON pretraining") stays. | |
| # ---------------------------------------------------------------------------------------------- | |
| OMIT_ROWS_OWNER_20260915 = ( | |
| # master_aide.md §1 raw labels (and their rendered forms after _NM) | |
| "MotionBERT-kp + BATON trunk", "MotionBERT-kp, dropout 0.1 + BATON trunk", "ST-GCN-kp + BATON trunk", | |
| "MotionBERT-kp + BATON pretraining", "MotionBERT-kp, dropout 0.1 + BATON pretraining", "ST-GCN-kp + BATON pretraining", | |
| # arch_attribution.md §1.4 rows of the former block "(A) Gain from matched BATON pretraining" (the whole block is no longer built) | |
| "MotionBERT-kp (trunk only, pretraining seed 123)", "ST-GCN-kp (trunk only, pretraining seed 123)", | |
| # kv2_program.md: the MB-best + BATON trunk level row, the P2 endpoint and the two descriptive pairs of §3.1 that involve it | |
| "MotionBERT-kp, validation-tuned + BATON pretraining", "MotionBERT-kp (tuned), both + BATON pretraining", | |
| "MotionBERT-kp (tuned) + BATON pretraining", | |
| # run families of the SIX-EPOCH matched runs (a label that carries one of these run names is dropped too). Revised 2026-09-15 (owner | |
| # decision after the pretraining programme, docs/decisions.md): the CONVERGED matched runs `motionbert_kp_batonpre_conv_*` / | |
| # `stgcn_kp_batonpre_conv_*` and their pretraining `*_batonpre_pretrain_conv_s123` ARE reported (tab_supp_pretrain_variants, Supp. D), | |
| # so the patterns below name the six-epoch families explicitly instead of the whole `*_batonpre` prefix. | |
| "motionbert_kp_batonpre_trunkp", "motionbert_kp_batonpre_pretrain_s123", "motionbert_kp_batonpre_zeroshot", "motionbert_kp_do0.1_batonpre", | |
| "stgcn_kp_batonpre_trunkp", "stgcn_kp_batonpre_pretrain_s123", "stgcn_kp_batonpre_zeroshot", | |
| ) | |
| def omitted_row(label: str) -> bool: | |
| """True when a table row (raw source label, rendered label or the whole LaTeX row) belongs to the matched-baseline-pretraining | |
| experiment that the owner decision of 2026-09-15 keeps out of the manuscript (OMIT_ROWS_OWNER_20260915).""" | |
| t = label.replace("\\_", "_") | |
| return any(k in t for k in OMIT_ROWS_OWNER_20260915) | |
| # ---------------------------------------------------------------------------------------------- | |
| # Owner decisions of 2026-09-17 (docs/decisions.md row 443, items (3) and (5)); applied to the ICLR output only -- the IEEE draft | |
| # (default style) is untouched, like _NEG_ICLR_EDITS. | |
| # (3) ENGAGED hand_leave / hand_return cells leave the paper (main + supplement): every table with the six driver cells carries four | |
| # (manual hand_leave / hand_return / head_turn, engaged head_turn). Rows whose first two cells read "engaged & hand leave/return" | |
| # are dropped by the row filter in emit(); group-structured tables (regime as a group row: tab_baton_main, tab_main_baton_interaction), | |
| # column-structured ones (tab_ecan) and endpoint lists in text cells (tab_robustness) are handled in their generators through | |
| # omitted_cell() / strip_engaged_hand(); emit_iclr() refuses any survivor. tab_label_check (the label-validation record that is | |
| # generated but not \input, owner decision) is the only exemption. | |
| # (5) The paper's MotionBERT is the released-weights baseline only: every row of the architecture-family control (MotionBERT-kp / | |
| # 'MotionBERT architecture' / motionbert_kp / MB-best of the K-v2 grid) leaves the ICLR tables (archived in | |
| # aide/results/tables/motionbert_arch_control_archive.md); a block whose title names it, or that is left without a data row, is not | |
| # emitted. The published single-run MotionBERT row (73.51) and the released-weights rows stay: their labels do not carry these tokens. | |
| # ---------------------------------------------------------------------------------------------- | |
| OMIT_CELLS_OWNER_20260917 = {("engaged", "drv_onset/hand_leave/3s"), ("engaged", "drv_onset/hand_return/3s"), | |
| ("engaged", "hand_leave"), ("engaged", "hand_return")} | |
| OMIT_ROWS_OWNER_20260917_MBKP = ("MotionBERT-kp", "MotionBERT arch", "motionbert_kp", "MB-best") | |
| # Owner decision 2026-09-18 (docs/decisions.md row 496, manuscript round 5): the project's OWN small-architecture MotionBERT results leave the | |
| # paper AND the supplement INCLUDING the generated-table comment headers (source line pointers and the IEEE caption kept as a comment). | |
| # These tokens are scrubbed from every ICLR header comment (_scrub_mbkp_comment) and refused by emit_iclr() on comment lines as well. | |
| # The released-weights fine-tuned MotionBERT rows (tab_main_aide, tab_supp_motionbert_faithful) stay: their labels carry none of these tokens. | |
| OMIT_COMMENT_TOKENS_20260918 = OMIT_ROWS_OWNER_20260917_MBKP + ("MotionBERT architecture", "MotionBERT-architecture", "same-recipe MotionBERT") | |
| _ENGAGED_HAND_ROW_RE = re.compile(r"^(?:\\oursrow\s*)?engaged\s*&\s*(?:drv\.\\?\s*)?hand (?:leave|return)\b") | |
| _ENGAGED_HAND_FRAG_RE = re.compile(r";?\s*engaged hand\\?_(?:leave|return) \([^()]*\)") | |
| _ENGAGED_HAND_ANY_RE = re.compile(r"engaged (?:drv\.\\? )?hand(?:\\_| |-)(?:leave|return)") | |
| def _iclr() -> bool: | |
| return STYLE == "iclr" | |
| def omitted_cell(regime: str, cell: str) -> bool: | |
| """True (ICLR only) for the engaged hand_leave / hand_return cell (owner decision 2026-09-17 item 3); `cell` may be the endpoint id | |
| ('drv_onset/hand_leave/3s') or the bare event name ('hand_leave').""" | |
| if not _iclr(): | |
| return False | |
| r, c = regime.strip().lower(), cell.strip() | |
| return (r, c) in OMIT_CELLS_OWNER_20260917 or (r, c.split("/")[1] if "/" in c else c) in OMIT_CELLS_OWNER_20260917 | |
| def strip_engaged_hand(text: str) -> str: | |
| """Remove the 'engaged hand_leave (...)' / 'engaged hand_return (...)' fragments from a semicolon-separated endpoint list (ICLR only).""" | |
| if not _iclr(): | |
| return text | |
| return _ENGAGED_HAND_FRAG_RE.sub("", text).lstrip("; ").strip() | |
| def omitted_mbkp_row(label: str) -> bool: | |
| """True (ICLR only) when a rendered row, group title or block title belongs to the MotionBERT architecture-family control | |
| (owner decision 2026-09-17 item 5).""" | |
| if not _iclr(): | |
| return False | |
| t = label.replace("\\_", "_") | |
| return any(k in t for k in OMIT_ROWS_OWNER_20260917_MBKP) | |
| def omitted_mbkp_text(text: str) -> bool: | |
| """True (ICLR only) when any rendered line -- data row, block title OR header comment -- names the project's own small-architecture | |
| MotionBERT control (owner decisions 2026-09-17 item 5 and 2026-09-18, OMIT_COMMENT_TOKENS_20260918).""" | |
| if not _iclr(): | |
| return False | |
| t = text.replace("\\_", "_") | |
| return any(k in t for k in OMIT_COMMENT_TOKENS_20260918) | |
| def _scrub_mbkp_comment(text: str) -> str: | |
| """ICLR only: drop the clauses of a header-comment string (source line pointers or the IEEE caption kept as a comment) that name the | |
| small-architecture MotionBERT control. The string is split at sentence / semicolon boundaries; an offending clause is dropped, or, when it | |
| is a comma list, only its offending items are dropped, so a path or a section pointer that shares the line survives. Identity in IEEE style.""" | |
| if not _iclr() or not omitted_mbkp_text(text): | |
| return text | |
| kept = [] | |
| for clause in re.split(r"(?<=[.;])\s+", text): | |
| if not omitted_mbkp_text(clause): | |
| kept.append(clause) | |
| continue | |
| items = [q for q in clause.split(", ") if not omitted_mbkp_text(q)] | |
| if items: | |
| tail = clause.rstrip()[-1] if clause.rstrip().endswith((".", ";")) else "" | |
| kept.append(", ".join(items).rstrip(".;") + tail) | |
| out = " ".join(kept).strip().rstrip(";").strip() | |
| if omitted_mbkp_text(out): | |
| raise ValueError(f"_scrub_mbkp_comment: a token survived in {out[:120]!r}") | |
| return out | |
| def _omit_row_20260917(name: str, line: str) -> bool: | |
| if omitted_mbkp_row(line): | |
| return True | |
| return name != "tab_label_check" and _ENGAGED_HAND_ROW_RE.match(line.strip()) is not None | |
| def filter_rows(body: list, omit) -> list: | |
| """Drop the body rows for which omit(row) is True. A group row (\\multicolumn{..}{l}{\\emph{..}}) that matches drops its whole group | |
| (every row up to the next group row or \\midrule); \\midrule separators left leading, trailing or doubled are removed.""" | |
| out, skipping = [], False | |
| for l_ in body: | |
| st = l_.strip() | |
| if _GROUP_RE.match(st): | |
| skipping = bool(omit(l_)) | |
| if not skipping: | |
| out.append(l_) | |
| continue | |
| if st == r"\midrule": | |
| skipping = False | |
| out.append(l_) | |
| continue | |
| if skipping or omit(l_): | |
| continue | |
| out.append(l_) | |
| tidy: list = [] | |
| for l_ in out: | |
| if l_.strip() == r"\midrule" and (not tidy or tidy[-1].strip() == r"\midrule"): | |
| continue | |
| tidy.append(l_) | |
| while tidy and tidy[-1].strip() == r"\midrule": | |
| tidy.pop() | |
| return tidy | |
| def _apply_owner_20260917(name: str, blocks): | |
| """ICLR only: apply the two 2026-09-17 omissions to every block of a table; a block whose title names the MotionBERT control or that | |
| keeps no data row is not emitted (its later blocks keep their indices only if it was the last one -- true for every affected table).""" | |
| out = [] | |
| for title, colspec, header, body in blocks: | |
| if title and omitted_mbkp_row(title): | |
| continue | |
| body = filter_rows(list(body), lambda l_: _omit_row_20260917(name, l_)) | |
| if not any(not _GROUP_RE.match(l_.strip()) and l_.strip() != r"\midrule" for l_ in body): | |
| continue | |
| out.append((title, colspec, header, body)) | |
| return out | |
| def pm_style(s: str) -> str: | |
| """AAAI +- style for body cells: '0.773 $\\pm$ 0.002' -> '0.773$\\pm$.002' (value keeps its leading zero, sd loses it).""" | |
| s = re.sub(r"(\d)\s*\$\\pm\$\s*0\.(\d)", r"\1$\\pm$.\2", s) | |
| s = re.sub(r"\s*\$\\pm\$\s*(\d)", r"$\\pm$\1", s) | |
| return s | |
| _LEAD_NUM = re.compile(r"^\s*([-+]?\d+(?:\.\d+)?)") | |
| def lead_num(cell: str): | |
| """Leading number of a rendered cell ('48.63$\\pm$.15' -> 48.63; '--' -> None).""" | |
| s = cell.replace("$", "").replace("\\textbf{", "").replace("\\best{", "").replace("{", "").replace("}", "").strip() | |
| m = _LEAD_NUM.match(s) | |
| return float(m.group(1)) if m else None | |
| def count_cols(spec: str) -> int: | |
| s = re.sub(r"[>@!]\{[^{}]*\}", "", spec) | |
| n = len(re.findall(r"[pmb]\{[^{}]*\}", s)) | |
| s = re.sub(r"[pmb]\{[^{}]*\}", "", s) | |
| return n + sum(ch in "lcr" for ch in s) | |
| def caption_words(s: str) -> int: | |
| t = re.sub(r"\\[a-zA-Z]+\*?", " ", s) | |
| t = re.sub(r"[{}$]", " ", t) | |
| return len([w for w in t.split() if re.search(r"[A-Za-z0-9]", w)]) | |
| def tiny(spec: str) -> str: | |
| """Every column of a space-separated column spec set in \\tiny (for wide supplement tables).""" | |
| return " ".join(">{\\tiny}" + t for t in spec.split()) | |
| # ---------------------------------------------------------------------------------------------- | |
| # markdown helpers | |
| # ---------------------------------------------------------------------------------------------- | |
| _CACHE: dict[pathlib.Path, list[str]] = {} | |
| def lines_of(p: pathlib.Path) -> list[str]: | |
| if p not in _CACHE: | |
| _CACHE[p] = p.read_text(encoding="utf-8").splitlines() | |
| return _CACHE[p] | |
| def section(lines: list[str], heading_prefix: str, start: int = 0) -> tuple[list[str], int]: | |
| """Lines of the section whose heading (after the '#'s) starts with `heading_prefix`, up to the next | |
| heading of the same or a higher level. Returns (lines, 0-based index of the heading line).""" | |
| for i in range(start, len(lines)): | |
| ln = lines[i] | |
| if ln.startswith("#") and ln.lstrip("#").strip().startswith(heading_prefix): | |
| level = len(ln) - len(ln.lstrip("#")) | |
| j = i + 1 | |
| while j < len(lines): | |
| l2 = lines[j] | |
| if l2.startswith("#") and (len(l2) - len(l2.lstrip("#"))) <= level: | |
| break | |
| j += 1 | |
| return lines[i:j], i | |
| raise KeyError(f"heading not found: {heading_prefix!r}") | |
| def split_row(line: str, ncols: int | None = None, merge_col: int = 1) -> list[str]: | |
| s = line.strip() | |
| if s.startswith("|"): | |
| s = s[1:] | |
| if s.endswith("|"): | |
| s = s[:-1] | |
| cells = [c.strip() for c in s.split("|")] | |
| if ncols is not None and len(cells) > ncols: # a cell contained literal '|' characters | |
| extra = len(cells) - ncols | |
| merged = "|".join(cells[merge_col:merge_col + extra + 1]) | |
| cells = cells[:merge_col] + [merged] + cells[merge_col + extra + 1:] | |
| return cells | |
| def md_tables(lines: list[str], merge_col: int = 1) -> list[tuple[list[str], list[list[str]], int]]: | |
| """All markdown tables in `lines` -> [(header, rows, index of header line within `lines`)].""" | |
| out = [] | |
| i = 0 | |
| while i < len(lines): | |
| if lines[i].lstrip().startswith("|"): | |
| j = i | |
| while j < len(lines) and lines[j].lstrip().startswith("|"): | |
| j += 1 | |
| block = lines[i:j] | |
| header = split_row(block[0]) | |
| rows = [split_row(r, len(header), merge_col) for r in block[2:]] | |
| out.append((header, rows, i)) | |
| i = j | |
| else: | |
| i += 1 | |
| return out | |
| def first_table(path: pathlib.Path, heading_prefix: str, merge_col: int = 1, table_idx: int = 0): | |
| """(header, rows, absolute 1-based line number of the table header) of table `table_idx` in a section.""" | |
| ls = lines_of(path) | |
| sec, i0 = section(ls, heading_prefix) | |
| header, rows, k = md_tables(sec, merge_col)[table_idx] | |
| return header, rows, i0 + k + 1 | |
| def col(header: list[str], name_prefix: str) -> int: | |
| for i, h in enumerate(header): | |
| if h.replace("**", "").strip().startswith(name_prefix): | |
| return i | |
| raise KeyError(f"column not found: {name_prefix!r} in {header}") | |
| def find_row(rows: list[list[str]], c: int, prefix: str) -> list[str]: | |
| for r in rows: | |
| if r[c].replace("**", "").strip().startswith(prefix): | |
| return r | |
| raise KeyError(f"row not found: {prefix!r}") | |
| def find_line(path: pathlib.Path, prefix: str, start: int = 0) -> tuple[str, int]: | |
| for i in range(start, len(lines_of(path))): | |
| ln = lines_of(path)[i] | |
| if ln.strip().startswith(prefix): | |
| return ln.strip(), i + 1 | |
| raise KeyError(f"line not found: {prefix!r} in {path}") | |
| # ---------------------------------------------------------------------------------------------- | |
| # LaTeX helpers | |
| # ---------------------------------------------------------------------------------------------- | |
| _UNI = [("±", r"$\pm$"), ("Δ", r"$\Delta$"), ("−", "-"), ("–", "--"), ("—", "---"), ("×", r"$\times$"), | |
| ("σ", r"$\sigma$"), ("≈", r"$\approx$"), ("≥", r"$\geq$"), ("≤", r"$\leq$"), ("→", r"$\rightarrow$"), | |
| ("⊃", r"$\supset$"), ("✓", "yes"), ("λ", r"$\lambda$"), ("·", r"$\cdot$"), ("⟨", "("), ("⟩", ")"), | |
| ("§", r"\S{}"), ("α", r"$\alpha$"), ("≠", r"$\neq$"), ("∞", r"$\infty$"), ("″", "''"), ("’", "'")] | |
| _ESC = [("\\", "/"), ("&", r"\&"), ("%", r"\%"), ("#", r"\#"), ("_", r"\_"), ("{", r"\{"), ("}", r"\}"), ("$", r"\$")] | |
| def tx(s: str) -> str: | |
| """Escape a markdown cell for LaTeX text mode (numbers untouched).""" | |
| s = s.replace("**", "").replace("`", "") | |
| for a, b in _ESC: | |
| s = s.replace(a, b) | |
| for a, b in _UNI: | |
| s = s.replace(a, b) | |
| return s | |
| _VERD = {"BEATS": "better", "WORSE": "worse", "INCONCLUSIVE": "n.s.", "NOT_WORSE": "not worse", | |
| "INSUFFICIENT": "insufficient", "EQUAL": "equal", "PASS": "PASS", "FAIL": "FAIL", | |
| "NOT_CLAIMED": "not claimed", "FLAG": "FLAG", "OK": "OK", "ABOVE": "above", "BELOW": "below"} | |
| def vd(s: str) -> str: | |
| """Render a kill_checks verdict token with the agreed wording; the rest of the cell is kept.""" | |
| s0 = s.replace("**", "").strip() | |
| m = re.match(r"([A-Z_]+)\b(.*)$", s0) | |
| if m and m.group(1) in _VERD: | |
| return _VERD[m.group(1)] + tx(m.group(2)) | |
| return tx(s0) | |
| def strip_n(s: str) -> str: | |
| """'+0.0300 ± 0.0019 (n=3, pos=49993)' -> '+0.0300 ± 0.0019' (drops the row-count annotation only).""" | |
| return re.sub(r"\s*\(n=.*?\)\s*$", "", s).strip() | |
| _CELL = { | |
| "veh_onset/brake_on/3s": "veh.\\ brake on", "veh_onset/gas_on/3s": "veh.\\ gas on", | |
| "veh_onset/steer_phase_on/3s": "veh.\\ steer phase on", "veh_onset/veh_any_on/3s": "veh.\\ any on", | |
| "drv_onset/hand_leave/3s": "drv.\\ hand leave", "drv_onset/hand_return/3s": "drv.\\ hand return", | |
| "drv_onset/head_turn_onset/3s": "drv.\\ head turn", "d_onset/badas/3s": "D badas", "d_onset/decel/3s": "D decel", | |
| "d_onset/lane/3s": "D lane", "d_onset/steer_rate/3s": "D steer rate", "d_onset/ttc_drop/3s": "D ttc drop", | |
| "d_onset/ttc/3s": "D ttc", "C1_given_k": "C1 given k", "C1": "C1", | |
| "hand_leave": "hand leave", "hand_return": "hand return", "head_turn_onset": "head turn", | |
| } | |
| def cell_name(c: str) -> str: | |
| c = c.replace("|", "/") | |
| if c in _CELL: | |
| return _CELL[c] | |
| return tx(c.replace("/3s", "").replace("_", " ").replace("/", " ")) | |
| def emit(name: str, caption: str, sources: list[str], blocks: list[tuple[str | None, str, list[str], list[str]]], | |
| wide: bool = True, size: str = r"\scriptsize", colsep: str = "3pt") -> pathlib.Path: | |
| """blocks: [(panel title or None, colspec, header cells (already LaTeX), body lines (already LaTeX))]. | |
| colsep: \tabcolsep for the whole float (tighten to 2--2.5pt for wide tables instead of dropping columns). | |
| In ICLR style the float is delegated to emit_iclr (cwtable environment, caption above, short caption).""" | |
| if STYLE == "iclr": | |
| return emit_iclr(name, caption, sources, _apply_owner_20260917(name, blocks)) | |
| env = "table*" if wide else "table" | |
| out = [f"% {name}.tex --- GENERATED by paper/tables/gen_tables.py on {TODAY}; do not edit by hand.", | |
| "% Every number is copied verbatim from these sources (file : section / line):"] | |
| out += [f"% - {s}" for s in sources] | |
| out += [f"\\begin{{{env}}}[t]", r"\centering", size, f"\\setlength{{\\tabcolsep}}{{{colsep}}}", | |
| r"\renewcommand{\arraystretch}{1.05}", f"\\caption{{{caption}}}", | |
| f"\\label{{tab:{name}}}\\label{{tab:{name[4:] if name.startswith('tab_') else name}}}"] | |
| for k, (title, colspec, header, body) in enumerate(blocks): | |
| if title: | |
| out.append(f"\\par\\smallskip\\noindent\\textbf{{{title}}}\\par\\smallskip") | |
| hdr_rows = header if header and isinstance(header[0], list) else [header] | |
| out += [f"\\begin{{tabular}}{{{colspec}}}", r"\toprule"] | |
| out += [h if isinstance(h, str) else " & ".join(h) + r" \\" for h in hdr_rows] | |
| out += [r"\midrule"] | |
| out += body | |
| out += [r"\bottomrule", r"\end{tabular}"] | |
| if k < len(blocks) - 1: | |
| out.append(r"\par\medskip") | |
| out.append(f"\\end{{{env}}}") | |
| p = OUT / f"{name}.tex" | |
| p.write_text("\n".join(out) + "\n", encoding="utf-8") | |
| return p | |
| # ---------------------------------------------------------------------------------------------- | |
| # ICLR emitter: cwtable / cwtable* (cwm_macros.tex), caption ABOVE, \headrow header rows, \oursrow CockpitWM rows, | |
| # per-column \best{} among model rows, AAAI +- style, short caption (<= 60 words), provenance in the % header | |
| # ---------------------------------------------------------------------------------------------- | |
| def _short_label(name: str) -> str: | |
| return name[4:] if name.startswith("tab_") else name | |
| def _default_cand(cells: list[str], grp: str) -> bool: | |
| """Rows eligible for the per-column \\best{} mark: model rows only — never published-baseline rows (group title or | |
| label says 'published' / 'paper'), margin rows, or ensembles (not single models).""" | |
| lab = cells[0].lower() | |
| g = (grp or "").lower() | |
| if "published" in g or "margin" in g or "paper" in lab or "published" in lab or "margin" in lab or "ensemble" in lab: | |
| return False | |
| return not lab.startswith("best published") | |
| def _default_ours(cells: list[str], grp: str) -> bool: | |
| return any("CockpitWM" in c for c in cells) and "margin" not in cells[0].lower() | |
| _GROUP_RE = re.compile(r"^\\multicolumn\{\d+\}\{[^{}]*\}\{\\emph\{(.*)\}\}\s*\\\\$") | |
| def _split_row(line: str): | |
| s = line.rstrip() | |
| if not s.endswith("\\\\"): | |
| return None | |
| if s.lstrip().startswith(("\\multicolumn", "\\midrule", "\\addlinespace", "\\cmidrule", "\\rowcolor", "\\headrow", "\\oursrow")): | |
| return None | |
| return [c.strip() for c in s[:-2].split(" & ")] | |
| def _iclr_header(name: str, caption: str, sources: list[str]) -> list[str]: | |
| out = [f"% {name}.tex --- GENERATED by paper/tables/gen_tables.py --style iclr on {TODAY}; do not edit by hand.", | |
| "% Every number is copied verbatim from these sources (path relative to the repository root : section / line):"] | |
| for s in sources: | |
| path, sep, rest = s.partition(" : ") | |
| if path.startswith("/"): | |
| try: | |
| path = str(pathlib.Path(path).relative_to(ROOT)) | |
| except ValueError: | |
| pass | |
| rest = _scrub_mbkp_comment(rest) # owner decision 2026-09-18: no small-architecture MotionBERT pointer in the ICLR header | |
| out.append(f"% - {nm(path + sep + rest)}") | |
| out.append("% Full caption of the IEEE draft (provenance, verdict legend, line pointers; kept as a comment):") | |
| out += ["% | " + w for w in textwrap.wrap(nm(_scrub_mbkp_comment(caption)), width=150)] | |
| return out | |
| def _render_block(name: str, k: int, title, colspec: str, header, body: list[str], env: str, placement: str, short: str) -> list[str]: | |
| out = [] | |
| colspec = ICLR_COLSPEC.get(name, {}).get(k, colspec) | |
| ncols = count_cols(colspec) | |
| if k == 0: | |
| out.append(f"\\begin{{{env}}}{placement}{{tab:{_short_label(name)}}}{{{short}\\label{{tab:{name}}}}}{{{colspec}}}") | |
| elif k in ICLR_NEWFLOAT.get(name, ()): # this block opens a continuation float (a four-block table taller than the page) | |
| out += [f"\\end{{{env}}}", "", | |
| f"\\begin{{{env}}}{placement}{{tab:{_short_label(name)}_cont{k}}}{{{short} (continued).\\label{{tab:{name}_cont{k}}}}}{{{colspec}}}"] | |
| else: | |
| out.append(r"\end{tabular*}\par\smallskip") | |
| if name in ICLR_COLSEP: # per-block \tabcolsep for later blocks of a wide table (local to the float; block 0 keeps the cwtable default) | |
| out.append(f"\\setlength{{\\tabcolsep}}{{{ICLR_COLSEP[name].get(k, '3pt')}}}") | |
| out.append(f"\\begin{{tabular*}}{{\\textwidth}}{{@{{\\extracolsep{{\\fill}}}}{colspec}@{{}}}}") | |
| if title: | |
| out.append(f"\\multicolumn{{{ncols}}}{{@{{}}p{{0.98\\textwidth}}@{{}}}}{{\\textbf{{{nm(title)}}}}} \\\\") | |
| out.append(r"\toprule") | |
| header = ICLR_HEADER.get(name, {}).get(k, header) # ICLR-only abbreviated / two-row headers (IEEE output untouched) | |
| cellfn = ICLR_CELL.get(name) # ICLR-only cell transform (text only; never touches a number) | |
| # a header is multi-row when it contains a list (cell row) or a raw LaTeX row string (starts with '\') | |
| multi = any(isinstance(h, list) for h in header) or (bool(header) and isinstance(header[0], str) and header[0].startswith("\\")) | |
| hdr_rows = header if multi else [header] | |
| hdr_lines = [nm(h) if isinstance(h, str) else r"\headrow " + " & ".join(nm(c) for c in h) + r" \\" for h in hdr_rows] | |
| out += hdr_lines + [r"\midrule"] | |
| split = ICLR_SPLIT.get(name, {}).get(k) # predicate(cells, line, group) -> close the float and start a continuation before this row | |
| part = 1 | |
| # parse body rows; remember the group row (\multicolumn{..}{l}{\emph{...}}) each row belongs to | |
| parsed = [] | |
| grp = None | |
| for l_ in body: | |
| m = _GROUP_RE.match(l_.strip()) | |
| if m: | |
| grp = m.group(1) | |
| parsed.append((_split_row(l_), l_, grp)) | |
| best_cols = BEST.get(name, {}).get(k, {}) | |
| cand = CAND.get(name, _default_cand) | |
| ours = OURS.get(name, _default_ours) | |
| winners: dict[int, int] = {} | |
| for c, direction in best_cols.items(): | |
| vals = [] | |
| for i, (cells, _, g) in enumerate(parsed): | |
| if cells and len(cells) > c and cand(cells, g): | |
| v = lead_num(nm(cells[c])) | |
| if v is not None: | |
| vals.append((v, i)) | |
| if not vals: | |
| continue | |
| target = (min if direction == "min" else max)(v for v, _ in vals) | |
| w = [i for v, i in vals if v == target] | |
| if len(w) == 1: # ties: no \best | |
| winners[c] = w[0] | |
| for i, (cells, line, g) in enumerate(parsed): | |
| if split is not None and i > 0 and split(cells, line, g): | |
| # a float taller than the page is split into numbered parts (same columns, header repeated, caption marked as continued) | |
| part += 1 | |
| # block 0 keeps the historical label "<name>_part<n>"; later blocks carry their block index so that two split blocks of one table | |
| # (mirror table (B) and (C), 2026-09-15) do not define the same label twice | |
| psfx = f"part{part}" if k == 0 else f"b{k}part{part}" | |
| out += [r"\bottomrule", f"\\end{{{env}}}", "", | |
| f"\\begin{{{env}}}{placement}{{tab:{_short_label(name)}_{psfx}}}{{{short} (continued, part {part}).\\label{{tab:{name}_{psfx}}}}}{{{colspec}}}", | |
| r"\toprule"] + hdr_lines + [r"\midrule"] | |
| if cells is None: | |
| m = _GROUP_RE.match(line.strip()) | |
| if m: # group rows span the full text width and wrap instead of overflowing the narrower ICLR column | |
| n = re.match(r"^\\multicolumn\{(\d+)\}", line.strip()).group(1) | |
| out.append(f"\\multicolumn{{{n}}}{{@{{}}p{{\\textwidth}}@{{}}}}{{\\emph{{{nm(m.group(1))}}}}} \\\\") | |
| else: | |
| out.append(nm(line)) | |
| continue | |
| cells = [pm_style(nm(cellfn(c) if cellfn else c)) for c in cells] | |
| for c, wi in winners.items(): | |
| if wi == i: | |
| cells[c] = "\\best{" + cells[c] + "}" | |
| prefix = r"\oursrow " if (ours and ours(cells, g)) else "" | |
| out.append(prefix + " & ".join(cells) + r" \\") | |
| out.append(r"\bottomrule") | |
| return out | |
| def emit_iclr(name: str, caption: str, sources: list[str], blocks) -> pathlib.Path: | |
| short = SHORT[name] | |
| nw = caption_words(short) | |
| if nw > 60: | |
| raise ValueError(f"{name}: short caption has {nw} words (> 60)") | |
| if re.search(r"cwm3", short, re.I): | |
| raise ValueError(f"{name}: short caption contains CWM3") | |
| main = name in MAIN_TABLES | |
| env = "cwtable" if main else "cwtable*" | |
| placement = "[t]" if main else "" | |
| out = _iclr_header(name, caption, sources) | |
| for k, (title, colspec, header, body) in enumerate(blocks): | |
| out += _render_block(name, k, title, colspec, header, body, env, placement, short) | |
| out.append(f"\\end{{{env}}}") | |
| txt = "\n".join(out) + "\n" | |
| if re.search(r"cwm3", txt, re.I): | |
| raise ValueError(f"{name}: CWM3 survived the name mapping") | |
| body_txt = "\n".join(l_ for l_ in out if not l_.startswith("%")) | |
| for bad in _FORBIDDEN_NAMES: | |
| if bad in body_txt: | |
| raise ValueError(f"{name}: forbidden model name {bad!r} survived the name mapping (owner rule 2026-09-15: one name, CockpitWM)") | |
| for l_ in out: # owner presentation decision 2026-09-15: no row of the matched-baseline-pretraining experiment in any ICLR table | |
| if not l_.startswith("%") and omitted_row(l_): | |
| raise ValueError(f"{name}: a row of the omitted matched-baseline-pretraining experiment survived (OMIT_ROWS_OWNER_20260915): {l_[:100]!r}") | |
| for l_ in out: # owner decisions 2026-09-17 (items 3 and 5) + 2026-09-18: no engaged hand cell, no small-architecture MotionBERT | |
| # control in any ICLR table -- data rows, block titles AND the % header comments (the engaged-hand regex still skips comments) | |
| if omitted_mbkp_text(l_): | |
| raise ValueError(f"{name}: a small-architecture MotionBERT control token survived (owner decisions 2026-09-17 item 5 / 2026-09-18): {l_[:100]!r}") | |
| if l_.startswith(("%", "\\begin{")): | |
| continue | |
| if name != "tab_label_check" and (_ENGAGED_HAND_ROW_RE.match(l_.strip()) or _ENGAGED_HAND_ANY_RE.search(l_)): | |
| raise ValueError(f"{name}: an engaged hand_leave / hand_return cell survived (owner decision 2026-09-17 item 3): {l_[:100]!r}") | |
| p = OUT / f"{name}.tex" | |
| p.write_text(txt, encoding="utf-8") | |
| return p | |
| def row(*cells: str) -> str: | |
| return " & ".join(cells) + r" \\" | |
| def group(n: int, text: str) -> str: | |
| return f"\\multicolumn{{{n}}}{{l}}{{\\emph{{{text}}}}} \\\\" | |
| LEGEND = (r"Verdicts follow \texttt{kill\_checks.beats} ($\geq 2/3$ seeds CI excl.\ 0, same sign, $|$mean $\Delta| >$ seed sd): " | |
| r"better / worse = significantly better / worse; n.s.\ (INCONCLUSIVE) and not worse (NOT\_WORSE) = no significant difference. ") | |
| # ---------------------------------------------------------------------------------------------- | |
| # sources | |
| # ---------------------------------------------------------------------------------------------- | |
| SRC = { | |
| "stage_a": AT / "stage_a.md", "stage_bc": AT / "stage_bc.md", "stage_a_5seed": AT / "stage_a_5seed.md", | |
| "stage_bc_5seed": AT / "stage_bc_5seed.md", "paper_rows": ROOT / "aide" / "eval" / "paper_rows.py", | |
| "baton_pretrain": AT / "baton_pretrain.md", "arch_attribution": AT / "arch_attribution.md", | |
| "stage_final": BT / "stage_final.md", "stage_final_ablations": BT / "stage_final_ablations.md", | |
| "k4": BT / "k4_v2_summary.md", "wh": BT / "warning_head_final.md", "wh_oof": BT / "warning_head_final_oof.md", | |
| "wh_gaze": BT / "warning_head_final_gaze.md", "wh_ext": BT / "warning_head_final_ext.md", | |
| "op": BT / "operating_points.md", "rob": BT / "robustness_final.md", | |
| "arch": BT / "branch_arch_ablation.md", "stage_F": BT / "stage_F.md", "rssm": BT / "stage_F_rssm.md", | |
| "gzfc": BT / "stage_final_gzfc.md", "ncroi": BT / "stage_final_ncroi.md", "kill": BT / "kill_report_final.md", | |
| "exp3_P": BT / "exp3_P.md", "dms_pre": BT / "dms_teacher_pretrain.md", "c1": BT / "c1_transfer.md", | |
| "power": BT / "power_gold.md", "identity": BT / "identity_invariance.md", "analytic": AT / "analytic_baselines.md", | |
| "decisions": DOCS / "decisions.md", "progress": DOCS / "progress_2026-09-11.md", | |
| } | |
| # K-v2 programme report (protocol C23; append-only, the LAST block is authoritative): registered lazily so that a checkout without the | |
| # programme still generates every other table; tab_supp_kv2 is added to ICLR_GENERATORS only when the file exists. | |
| _KV2_PATH = AT / "kv2_program.md" | |
| if _KV2_PATH.exists(): | |
| SRC["kv2"] = _KV2_PATH | |
| # Driver-WM arXiv v2 audit (Table 8 three-seed means, Table 10 / 12 mirrors) and the Table 2 / 3 head-to-head mirror (append-only; the LAST | |
| # '## Update' block is authoritative). tab_main_aide needs the audit for its Table-8 rows (owner item 2, 2026-09-15); both are the sources of the | |
| # supplement mirrors tab_supp_driverwm_mirror / tab_supp_risk_ranking (registered lazily at the end of this file). | |
| _V2_PATH = AT / "driverwm_v2_audit.md" | |
| _HH_PATH = AT / "driverwm_tables_headtohead.md" | |
| if _V2_PATH.exists(): | |
| SRC["v2_audit"] = _V2_PATH | |
| if _HH_PATH.exists(): | |
| SRC["headtohead"] = _HH_PATH | |
| def rel(p: pathlib.Path) -> str: | |
| return tx(str(p.relative_to(ROOT))) | |
| # ---------------------------------------------------------------------------------------------- | |
| # Table 1 — AIDE geometry | |
| # ---------------------------------------------------------------------------------------------- | |
| def tab_aide_geometry() -> pathlib.Path: | |
| bc = SRC["stage_bc"] | |
| h1b, pub, l1b = first_table(bc, "1b.") | |
| h1, ours, l1 = first_table(bc, "1. Test headline") | |
| h1c, marg, l1c = first_table(bc, "1c.") | |
| hdr = ["Model", "Params", "All-MPJPE", "d-n", "HM-MPJPE", "HM d-n", "PCK@0.05", "HM $h{=}5$"] | |
| body: list[str] = [] | |
| # published rows (18), grouped | |
| gmap = {"motion baseline": "Published motion baselines (Driver-WM paper, Table 1: single runs)", | |
| "controlled context baseline": "Published controlled-context baselines", | |
| "main": "Published Driver-WM main model and variants", "variant": "Published Driver-WM main model and variants", | |
| "variant (reads future frames)": "Published Driver-WM main model and variants", | |
| "ablation": "Published Driver-WM ablations"} | |
| cur = None | |
| ci = {k: col(h1b, k) for k in ["row", "group", "All", "d-n", "HM", "HM d-n", "PCK@0.05", "HM h=5"]} | |
| for r in pub: | |
| g = gmap[r[ci["group"]]] | |
| if g != cur: | |
| body.append(group(8, g)) | |
| cur = g | |
| name = tx(r[ci["row"]]) + (r"$^{\dagger}$" if "future" in r[ci["group"]] else "") | |
| body.append(row(name, "--", *[tx(r[ci[k]]) for k in ["All", "d-n", "HM", "HM d-n", "PCK@0.05", "HM h=5"]])) | |
| body.append(r"\midrule") | |
| oi = {"model": col(h1, "model"), "All": col(h1, "All-MPJPE"), "d-n": col(h1, "d-n"), "HM": col(h1, "HM-MPJPE"), | |
| "HM d-n": col(h1, "HM d-n"), "PCK": col(h1, "PCK@0.05"), "h5": col(h1, "HM h=5"), "params": col(h1, "params")} | |
| def ours_row(prefix: str, label: str) -> str: | |
| r = find_row(ours, oi["model"], prefix) | |
| return row(label, tx(r[oi["params"]]), *[tx(r[oi[k]]) for k in ["All", "d-n", "HM", "HM d-n", "PCK", "h5"]]) | |
| body.append(group(8, "Ours, shared keypoint recipe (test, mean $\\pm$ sd over 3 seeds; not CWM3)")) | |
| body.append(ours_row("SiMLPe-kp", "SiMLPe-kp")) | |
| body.append(ours_row("MotionBERT-kp", "MotionBERT-kp")) | |
| body.append(ours_row("ST-GCN-kp", "ST-GCN-kp")) | |
| body.append(group(8, "Ours, CWM3 (test, mean $\\pm$ sd over 3 seeds; two separate models)")) | |
| body.append(ours_row("CWM3-D-kp (Stage A)", r"\textbf{CWM3-D-kp} (geometry only)")) | |
| body.append(ours_row("CWM3-D vis+sem (B2 main)", r"\textbf{CWM3-D vis+sem} (B2 main)")) | |
| body.append(r"\midrule") | |
| body.append(group(8, "Margin over the best published value (ours $-$ best; error columns: negative = better; PCK: positive = better)")) | |
| mi = {"column": col(h1c, "column"), "best": col(h1c, "best published"), "kp": col(h1c, "CWM3-D-kp"), "vs": col(h1c, "CWM3-D vis+sem")} | |
| cols = ["All", "d-n", "HM", "HM d-n", "PCK@0.05"] | |
| best = [tx(find_row(marg, mi["column"], c)[mi["best"]]) for c in cols] | |
| def margin_of(cell: str) -> str: # '48.63 / -4.26 (**SOTA**)' -> '-4.26' | |
| return tx(cell.split("/")[1].split("(")[0].strip()) | |
| body.append(row("best published (row)", "--", *best, "--")) | |
| body.append(row("CWM3-D-kp margin", "--", *[margin_of(find_row(marg, mi["column"], c)[mi["kp"]]) for c in cols], "--")) | |
| body.append(row("CWM3-D vis+sem margin", "--", *[margin_of(find_row(marg, mi["column"], c)[mi["vs"]]) for c in cols], "--")) | |
| cap = (r"AIDE geometry (official test split, $n{=}609$; locked protocol: driver \texttt{first}, grid \texttt{floor}, HM top~60, PCK @ 96\,px). " | |
| r"Published rows are typed verbatim from the Driver-WM paper (arXiv 2605.05092v2, Table~1 single seed; " | |
| r"\texttt{aide/eval/paper\_rows.py}); $^{\dagger}$ reads future frames. Our rows are seed means $\pm$ sd (3 seeds). " | |
| r"The two CWM3 rows are two different models (5.8\,M geometry-only; 6.3\,M vis+sem) and are never merged. " | |
| f"Source: \\texttt{{{rel(bc)}}} \\S{{}}1 (line {l1}), \\S{{}}1b (line {l1b}), \\S{{}}1c (line {l1c}).") | |
| return emit("tab_aide_geometry", cap, | |
| [f"{bc} : §1 test headline (table at line {l1})", f"{bc} : §1b published table (line {l1b})", | |
| f"{bc} : §1c margins (line {l1c})", f"{SRC['paper_rows']} : published rows typed verbatim"], | |
| [(None, "l r r r r r r r", hdr, body)]) | |
| # ---------------------------------------------------------------------------------------------- | |
| # Table 2 — AIDE semantic heads, Gate B (a)/(b) | |
| # ---------------------------------------------------------------------------------------------- | |
| def gate_b_verdicts(bc: pathlib.Path) -> dict[str, str]: | |
| sec, _ = section(lines_of(bc), "6. Gate verdicts") | |
| out: dict[str, str] = {} | |
| label = None | |
| for ln in sec: | |
| if ln.startswith("### Gate B"): | |
| label = ln.split("—", 2)[2].split("; threshold")[0].strip() | |
| elif ln.startswith("**Gate B (") and label is not None: | |
| v = ln.split("):", 1)[1].replace("**", "").strip() | |
| out[label] = v | |
| label = None | |
| return out | |
| def tab_aide_semantic() -> pathlib.Path: | |
| bc = SRC["stage_bc"] | |
| h1, ours, l1 = first_table(bc, "1. Test headline") | |
| gb = gate_b_verdicts(bc) | |
| _, l6 = section(lines_of(bc), "6. Gate verdicts") | |
| oi = {k: col(h1, k) for k in ["model", "n", "All-MPJPE", "HM-MPJPE", "HM h=5", "F1 DBR", "F1 DER", "F1 TCR", "F1 VCR", "params"]} | |
| spec = [ # (row prefix in §1, display label, selection) | |
| ("paper Driver-WM main (seed 42)", "Driver-WM main (paper, seed 42)", "--"), | |
| ("paper Driver-WM main (3 seeds, Table 8)", "Driver-WM main (paper, 3 seeds, Table 8)", "--"), | |
| ("paper static pooling", "Static pooling (paper)", "--"), | |
| ("CWM3-D vis+sem (B2 main)", "CWM3-D vis+sem (B2 main), trunk-state heads", "(a)"), | |
| ("SEMANTIC-ONLY reference", "Semantic-only reference: frozen features, no trunk (geometry = ZV)", "F1"), | |
| ("CWM3-D vis + attn heads, plain CE (vii) — geometry-selected ckpt (a)", "CWM3-D vis + attention heads, plain CE (vii)", "(a)"), | |
| ("CWM3-D vis + attn heads, plain CE (vii) — DUAL SELECTION", "CWM3-D vis + attention heads, plain CE (vii)", "(b)"), | |
| ("DER (i) attn heads + learned view gate — (a)", "CWM3-D vis + attention heads + view gate (DER i)", "(a)"), | |
| ("DER (i) attn heads + learned view gate — (b)", "CWM3-D vis + attention heads + view gate (DER i)", "(b)"), | |
| ("Hardening A2: view-gate heads + ego-motion token — (a)", "view-gate heads + ego-motion token (A2)", "(a)"), | |
| ("Hardening A2: view-gate heads + ego-motion token — (b)", "view-gate heads + ego-motion token (A2)", "(b)"), | |
| ("Hardening A3: logit ENSEMBLE", "Logit ensemble of the 3 view-gate (b) seeds (A3; not one model)", "(b)"), | |
| ("Stage C (iv) 3-seed ENSEMBLE", "3-seed ensemble of B2 main (not one model)", "(a)"), | |
| ] | |
| hdr = ["Variant", "Sel.", "$n$", "Params", "All", "HM", "HM $h{=}5$", "F1 DBR", "F1 DER", "F1 TCR", "F1 VCR", "Gate B"] | |
| body = [] | |
| for prefix, label, sel in spec: | |
| r = find_row(ours, oi["model"], prefix) | |
| full = r[oi["model"]].replace("**", "") | |
| verdict = "--" | |
| for k, v in gb.items(): | |
| if full.startswith(k) or k.startswith(full): | |
| verdict = v | |
| break | |
| if prefix.startswith("paper"): | |
| verdict = "threshold" if "seed 42" in prefix else "--" | |
| body.append(row(label, sel, tx(r[oi["n"]]), tx(r[oi["params"]]), tx(r[oi["All-MPJPE"]]), tx(r[oi["HM-MPJPE"]]), | |
| tx(r[oi["HM h=5"]]), tx(r[oi["F1 DBR"]]), tx(r[oi["F1 DER"]]), tx(r[oi["F1 TCR"]]), tx(r[oi["F1 VCR"]]), | |
| tx(verdict.rstrip(".")).replace("--- short on", "(short:") + (")" if "short on" in verdict else ""))) | |
| cap = (r"AIDE semantic heads (Macro-F1, test, $n{=}609$) and their geometry, with the pre-registered Gate~B verdict " | |
| r"(all four heads $\geq$ the paper's Driver-WM main: 68.07 / 72.61 / 90.15 / 68.34; `short:' lists the heads below threshold). " | |
| r"Sel.\ = checkpoint selection: (a) single checkpoint selected on validation geometry; " | |
| r"(b) dual selection, checkpoint selected on validation mean macro-F1 (costs 1--2\,px All); F1 = selected on validation F1 (no trunk). Ensembles are not single models. " | |
| r"Mean $\pm$ sd over seeds. " | |
| f"Source: \\texttt{{{rel(bc)}}} \\S{{}}1 (line {l1}) and \\S{{}}6 Gate~B blocks (from line {l6 + 1}).") | |
| return emit("tab_aide_semantic", cap, | |
| [f"{bc} : §1 test headline (line {l1})", f"{bc} : §6 Gate B verdict blocks (from line {l6 + 1})"], | |
| [(None, "p{0.18\\linewidth} l r r r r r r r r r p{0.085\\linewidth}", hdr, body)], colsep="2pt") | |
| # ---------------------------------------------------------------------------------------------- | |
| # Table 3 — AIDE 5-seed appendix | |
| # ---------------------------------------------------------------------------------------------- | |
| def tab_aide_5seed() -> pathlib.Path: | |
| a = SRC["stage_a_5seed"] | |
| b = SRC["stage_bc_5seed"] | |
| ha, ra, la = first_table(a, "2. Seed means") | |
| hb, rb, lb = first_table(b, "2. Seed means") | |
| cols = ["All", "d-n", "HM", "HM d-n", "PCK@0.05", "PCK@0.10", "HM h=5"] | |
| f1 = ["F1 DBR", "F1 DER", "F1 TCR", "F1 VCR"] | |
| hdrG = ["Seeds", "$n$"] + [tx(c).replace("HM h=5", "HM $h{=}5$") for c in cols] | |
| hdrF = ["Seeds", "$n$"] + f1 | |
| short = {"locked 3 seeds (HEADLINE, unchanged)": "locked 3 seeds (headline, unchanged)", "all 5 seeds (appendix)": "all 5 seeds", | |
| "worst seed of 5 (per column)": "worst of 5 (per column)"} | |
| ia = {c: col(ha, c) for c in ["rows", "n"] + cols} | |
| ib = {c: col(hb, c) for c in ["rows", "n"] + cols + f1} | |
| bodyG = [group(9, "CWM3-D-kp (5.8\\,M, geometry only)")] | |
| for r in ra: | |
| bodyG.append(row(tx(short.get(r[ia["rows"]], r[ia["rows"]])), tx(r[ia["n"]]), *[tx(r[ia[c]]) for c in cols])) | |
| bodyG.append(r"\midrule") | |
| bodyG.append(group(9, "CWM3-D vis+sem (B2 main, 6.3\\,M)")) | |
| for r in rb: | |
| bodyG.append(row(tx(short.get(r[ib["rows"]], r[ib["rows"]])), tx(r[ib["n"]]), *[tx(r[ib[c]]) for c in cols])) | |
| bodyF = [group(6, "CWM3-D vis+sem (B2 main, 6.3\\,M); the geometry-only model has no semantic heads")] | |
| for r in rb: | |
| bodyF.append(row(tx(short.get(r[ib["rows"]], r[ib["rows"]])), tx(r[ib["n"]]), *[tx(r[ib[c]]) for c in f1])) | |
| cap = (r"Appendix: 5-seed extension of the two AIDE models (test, $n{=}609$; sd = seed sd, ddof~1). The locked seeds 42/123/456 remain the headline rows of " | |
| r"Tables~\ref{tab:aide_geometry}--\ref{tab:aide_semantic}; seeds 789/1011 were trained with the locked recipe verbatim and are reported whatever their value. " | |
| f"Sources: \\texttt{{{rel(a)}}} \\S{{}}2 (line {la}); \\texttt{{{rel(b)}}} \\S{{}}2 (line {lb}).") | |
| return emit("tab_aide_5seed", cap, [f"{a} : §2 seed means (line {la})", f"{b} : §2 seed means (line {lb})"], | |
| [("Geometry (MPJPE in px; PCK in \\%)", "l r r r r r r r r", hdrG, bodyG), ("Semantic macro-F1", "l r r r r r", hdrF, bodyF)]) | |
| # ---------------------------------------------------------------------------------------------- | |
| # Table 6 — BATON main model vs independent branches (+ noP ablation, naive fusion) | |
| # ---------------------------------------------------------------------------------------------- | |
| ONSET_CELLS = ["veh_onset/brake_on/3s", "veh_onset/gas_on/3s", "veh_onset/steer_phase_on/3s", | |
| "drv_onset/hand_leave/3s", "drv_onset/hand_return/3s", "drv_onset/head_turn_onset/3s", | |
| "d_onset/badas/3s", "d_onset/decel/3s", "d_onset/lane/3s", "d_onset/steer_rate/3s", "d_onset/ttc_drop/3s", "d_onset/ttc/3s"] | |
| def paired_index(path: pathlib.Path, heading: str) -> tuple[dict, int]: | |
| h, rows, ln = first_table(path, heading) | |
| ci = {k: col(h, k) for k in ["regime", "cell", "metric", "A s0", "A s1", "A s2", "mean Δ ± sd", "verdict"]} | |
| for k in ["Δ s0 [CI]", "Δ s1 [CI]", "Δ s2 [CI]"]: # per-seed paired Δ (used for the level-consistency guard) | |
| try: | |
| ci[k] = col(h, k) | |
| except KeyError: | |
| pass | |
| idx = {} | |
| for r in rows: | |
| idx[(r[ci["regime"]], r[ci["cell"]], r[ci["metric"]].split(" ")[0])] = r | |
| return {"idx": idx, "ci": ci}, ln | |
| def tab_baton_main() -> pathlib.Path: | |
| sf, ab = SRC["stage_final"], SRC["stage_final_ablations"] | |
| main, l_main = paired_index(sf, "B2 main comparison (v2 causal kin targets): A = allminus, B = indep") | |
| nop, l_nop = paired_index(ab, "Main comparison: A = allminusnoP, B = indepnoP") | |
| naive, l_naive = paired_index(ab, "Secondary comparison: A = naivefresh, B = indep") | |
| v_main, lv_main = find_line(sf, "### B2 verdict (all_minus_road2drv vs indep)") | |
| v_nop, lv_nop = find_line(ab, "## Claim B2 verdict") | |
| v_naive, lv_naive = find_line(ab, "Secondary B2-style verdict (naivefresh vs indep)") | |
| hdr = ["Endpoint", "Main s0 / s1 / s2", | |
| "$\\Delta$ main $-$ indep", "verdict", "$\\Delta$ no-P", "verdict", | |
| "$\\Delta$ naive fusion", "verdict"] | |
| body = [] | |
| def cells(d, key): | |
| r = d["idx"].get(key) | |
| if r is None: | |
| return "--", "--" | |
| ci = d["ci"] | |
| return tx(strip_n(r[ci["mean Δ ± sd"]])), vd(r[ci["verdict"]]) | |
| for regime in ["manual", "engaged"]: | |
| body.append(group(8, f"{regime} regime")) | |
| keys = [(regime, c, "pr_auc") for c in ONSET_CELLS] + [(regime, "C1_given_k", "auroc"), (regime, "C1_given_k", "pr_auc")] | |
| for key in keys: | |
| if omitted_cell(key[0], key[1]): # owner decision 2026-09-17 item 3 (ICLR): engaged hand_leave / hand_return leave the table | |
| continue | |
| r = main["idx"][key] | |
| ci = main["ci"] | |
| label = cell_name(key[1]) + (f" ({key[2].replace('_', '-').upper()}, cross-leg)" if key[1].startswith("C1") else "") | |
| a = " / ".join(tx(r[ci[k]]) for k in ["A s0", "A s1", "A s2"]) | |
| body.append(row(label, a, tx(strip_n(r[ci["mean Δ ± sd"]])), vd(r[ci["verdict"]]), *cells(nop, key), *cells(naive, key))) | |
| cap = (r"BATON: the frozen main model \texttt{all\_minus\_road2drv} (V $\cdot$ U $\cdot$ E branches + zero-initialised env$\rightarrow$vehicle and " | |
| r"driver$\rightarrow$vehicle interactions) vs the independent branches (\texttt{indep}) on identical rows (test split, 3 seeds, paired device-cluster " | |
| r"bootstrap, $n_{\mathrm{boot}}{=}1000$; driver populations from the v2 causal targets). Endpoints are onset PR-AUC@3\,s unless noted (C1 given k: cross-leg AUROC and PR-AUC); " | |
| r"column 2: the main model per seed; column 3: paired $\Delta$ main $-$ indep (mean $\pm$ seed sd). Columns 5--8: the same comparison without the detached road-pressure head~P " | |
| r"($\Delta$ no-P = \texttt{allminusnoP} $-$ \texttt{indepnoP}) and the naive-fusion control ($\Delta$ naive fusion = \texttt{naivefresh} $-$ \texttt{indep}). " | |
| + LEGEND + | |
| r"Pre-registered B2 verdicts: main vs indep \textbf{PASS} (own WORSE none; cross-leg better only on manual C1 given k PR-AUC); no-P \textbf{PASS}; " | |
| r"naive fusion \textbf{FAIL} (worse on 5 own endpoints). " | |
| f"Sources: \\texttt{{{rel(sf)}}} \\S{{}}1 (table at line {l_main}, verdict line {lv_main}); \\texttt{{{rel(ab)}}} (tables at lines {l_nop}, {l_naive}; verdicts lines {lv_nop}, {lv_naive}).") | |
| return emit("tab_baton_main", cap, | |
| [f"{sf} : §1 B2 main comparison allminus vs indep (table line {l_main}; verdict line {lv_main})", | |
| f"{ab} : main comparison allminusnoP vs indepnoP (table line {l_nop}; verdict line {lv_nop})", | |
| f"{ab} : secondary comparison naivefresh vs indep (table line {l_naive}; verdict line {lv_naive})"], | |
| [(None, "l l r l r l r l", hdr, body)], colsep="2.5pt") | |
| # ---------------------------------------------------------------------------------------------- | |
| # Table 4 — K4 causal ROI, dual protocol + statistics arm | |
| # ---------------------------------------------------------------------------------------------- | |
| def tab_baton_k4() -> pathlib.Path: | |
| k4 = SRC["k4"] | |
| hA, rA, lA = first_table(k4, "Protocol: all rows") | |
| hM, rM, lM = first_table(k4, "Protocol: suspect routes masked") | |
| hI, rI, lI = first_table(k4, "Input effect") | |
| hS, rS, lS = first_table(k4, "Stats-version arm") | |
| hV, rV, lV = first_table(k4, "Survivor recipe") | |
| vlines = [find_line(k4, "- **B1 (survivor recipe clip8+LN, suspect routes masked)**")[0], | |
| find_line(k4, "- **B1 (all rows)**")[0], find_line(k4, "- **B1 (suspect routes masked)**")[0], | |
| find_line(k4, "- **K4 input effect (all rows)**")[0]] | |
| _, lverd = find_line(k4, "## Verdicts") | |
| def key(r, h): | |
| return (r[col(h, "regime")], r[col(h, "event")]) | |
| # panel A | |
| hdrA = ["Regime", "Event", "Causal-ROI inputs", "Old route-median inputs", "k0 heuristic", "Persistence (base rate)", | |
| "Input effect $\\Delta$ (causal $-$ old)", "verdict", "Causal vs k0"] | |
| Iidx = {key(r, hI): r for r in rI} | |
| bodyA = [] | |
| for r in rA: | |
| i = Iidx[key(r, hA)] | |
| bodyA.append(row(tx(r[col(hA, "regime")]), cell_name(r[col(hA, "event")]), tx(r[col(hA, "causal inputs")]), tx(r[col(hA, "old inputs")]), | |
| tx(r[col(hA, "k0 heuristic")]), tx(r[col(hA, "persistence")]), tx(i[col(hI, "mean ± sd")]), vd(i[col(hI, "verdict")]), | |
| vd(r[col(hA, "causal vs k0")]))) | |
| # panel B | |
| hdrB = ["Regime", "Event", "Causal (clamp 5)", "k0 (masked pop.)", "Persistence", "vs k0", | |
| "Survivor recipe clip8+LN (final U)", "vs k0", "vs clamp-5 baseline"] | |
| Vidx = {key(r, hV): r for r in rV} | |
| bodyB = [] | |
| for r in rM: | |
| v = Vidx[key(r, hM)] | |
| bodyB.append(row(tx(r[col(hM, "regime")]), cell_name(r[col(hM, "event")]), tx(r[col(hM, "causal inputs")]), tx(r[col(hM, "k0 heuristic")]), | |
| tx(r[col(hM, "persistence")]), vd(r[col(hM, "causal vs k0")]), tx(v[col(hV, "clip8+LN masked")]), | |
| vd(v[col(hV, "verdict vs k0")]), vd(v[col(hV, "verdict vs baseline")]))) | |
| # panel C | |
| hdrC = ["Regime", "Event", "Stats v1 (float32)", "Stats v2 (float64)", "k0", "$\\Delta$ stats1 $-$ stats2 (mean $\\pm$ sd)", "verdict", "Stats v1 vs k0"] | |
| bodyC = [] | |
| for r in rS: | |
| bodyC.append(row(tx(r[col(hS, "regime")]), cell_name(r[col(hS, "event")]), tx(r[col(hS, "stats v1")]), tx(r[col(hS, "stats v2")]), | |
| tx(r[col(hS, "k0")]), tx(r[col(hS, "mean ± sd")]), vd(r[col(hS, "verdict")]), vd(r[col(hS, "stats v1 vs k0")]))) | |
| cap = (r"K4: driver-onset PR-AUC@3\,s of the driver branch~U on the v2 \emph{causal} targets (mean $\pm$ sd, seeds 0--2; paired on identical rows). " | |
| r"(A)~all rows: causal-ROI inputs vs the old route-median inputs (input-isolation control, same targets), the label-free k0 current-state heuristic and persistence. " | |
| r"(B)~the 64 driver-box-suspect routes censored from training and from every evaluated population; last three columns: the survivor recipe (clamp~8 + input LayerNorm) " | |
| r"that the final joint model uses. (C)~statistics arm: the same v2 packs with the pre-fix float32 standardisation statistics. " | |
| + LEGEND + | |
| r"Pre-registered B1 (report\_joint rule: hand\_leave AND head\_turn BEATS k0 in both regimes; strict rule: 6/6 cells): all rows \textbf{FAIL} (4/6 cells better than k0), " | |
| r"masked clamp-5 5/6 (report\_joint rule PASS, strict 6/6 rule FAIL), survivor recipe masked \textbf{FAIL} (4/6); K4 input effect \textbf{PASS} (6/6 cells better, none worse). " | |
| f"Source: \\texttt{{{rel(k4)}}} (tables at lines {lA}, {lM}, {lI}, {lS}, {lV}; verdicts from line {lverd}).") | |
| return emit("tab_baton_k4", cap, | |
| [f"{k4} : Protocol all rows (line {lA})", f"{k4} : Protocol suspect routes masked (line {lM})", f"{k4} : Input effect (line {lI})", | |
| f"{k4} : Stats-version arm (line {lS})", f"{k4} : Survivor recipe masked (line {lV})", f"{k4} : Verdicts (line {lverd}): " + " | ".join(vlines)], | |
| [("(A) all rows", "l l r r r r r l l", hdrA, bodyA), | |
| ("(B) suspect routes masked", "l l r r r l r l l", hdrB, bodyB), | |
| ("(C) statistics arm (all rows, v2 packs)", "l l r r r r l l", hdrC, bodyC)]) | |
| # ---------------------------------------------------------------------------------------------- | |
| # Table 7 — learned warning head vs the DMS attention chain | |
| # ---------------------------------------------------------------------------------------------- | |
| def tab_warning_head() -> pathlib.Path: | |
| wh, oof = SRC["wh"], SRC["wh_oof"] | |
| h1, r1, l1 = first_table(wh, "1. Clean-test AUROC (raw) per seed") | |
| h2, r2, l2 = first_table(oof, "1. Clean-test AUROC (raw) per seed") | |
| hR, rR, lR = first_table(oof, "1. Clean-test AUROC per stratum") | |
| hD, rD, lD = first_table(oof, "2. Paired Δ vs the DMS attention chain", merge_col=1) | |
| b4, lb4 = find_line(wh, "- **B4**") | |
| b5, lb5 = find_line(wh, "- **B5**") | |
| b4o, lb4o = find_line(oof, "- **B4**") | |
| b5o, lb5o = find_line(oof, "- **B5**") | |
| def auroc_row(src_rows, h, arm, column): | |
| for r in src_rows: | |
| if r[col(h, "arm")] == arm and r[col(h, "column")] == column: | |
| return r | |
| raise KeyError((arm, column)) | |
| Ridx = {r[col(hR, "arm::column")]: r for r in rR} | |
| Didx = {(r[col(hD, "arm::column")], r[col(hD, "stratum")]): r for r in rD} | |
| spec = [ # (file, arm, column, label) | |
| ("wh", "legacy_att", "att@3s", "openpilot DMS attention chain (att@3\\,s) --- reference"), | |
| ("wh", "legacy_cockpit_fixedD0", "cockpit@3s", "cwm2 composition (cockpit@3\\,s)"), | |
| ("wh", "legacy_risk", "risk@3s", "cwm2 risk score (risk@3\\,s)"), | |
| ("wh", "persist_joint", "persist@3s", "persistence"), | |
| ("wh", "reactive_nodms", "D0any&away", "reactive rule (D0 any \\& away), no DMS"), | |
| ("wh", "cwm3_I", "W_direct_t15_w10_RV_6fam", "CWM3 own label-free composition (W\\_direct, 6 demand families)"), | |
| ("wh", "cwm3_I", "driver_only_t15", "CWM3 driver chains only"), | |
| ("wh", "cwm3_I", "demand_only_t15_6fam", "CWM3 demand chains only"), | |
| ("wh", "cwm3_W", "W_learned_bothsel_t15_w10_n979", "Learned head, CV-selected, current + predicted future (pre-registered headline; in-sample)"), | |
| ("oof", "cwm3_W", "W_learned_bothsel_t15_w10_n979oof", "Learned head, CV-selected, current + predicted future (out-of-fold)"), | |
| ("wh", "cwm3_W", "W_learned_curhgb_t15_w10_n979", "HGB, current state only (post hoc; no model output, OOF identical)"), | |
| ("wh", "cwm3_W", "W_learned_futhgb_t15_w10_n979", "HGB, predicted future only (post hoc; in-sample)"), | |
| ("oof", "cwm3_W", "W_learned_futhgb_t15_w10_n979oof", "HGB, predicted future only (post hoc; out-of-fold)"), | |
| ("wh", "cwm3_W", "W_learned_bothhgb_t15_w10_n979", "HGB, current + predicted future (post hoc; in-sample)"), | |
| ("oof", "cwm3_W", "W_learned_bothhgb_t15_w10_n979oof", "HGB, current + predicted future (post hoc; out-of-fold)"), | |
| ("oof", "cwm3_W", "W_learned_curhgb_t15_w10_n979dwfc", "HGB, current + dwell + face landmarks (post hoc; no model output)"), | |
| ] | |
| hdr = ["Score (509 gold rows / 63 positives)", "AUROC s0 / s1 / s2", "mean $\\pm$ sd", "manual", "engaged", "$\\Delta$ vs DMS (pooled)", "verdict"] | |
| body = [] | |
| for f, arm, column, label in spec: | |
| r = auroc_row(r1 if f == "wh" else r2, h1 if f == "wh" else h2, arm, column) | |
| h = h1 if f == "wh" else h2 | |
| seeds = " / ".join(tx(r[col(h, k)].split(" ")[0]) for k in ["s0", "s1", "s2"]) | |
| key = f"{arm}::{column}" | |
| man = eng = "--" | |
| if key in Ridx: | |
| rr = Ridx[key] | |
| means = [i for i, c in enumerate(hR) if c.strip() == "mean"] | |
| man, eng = tx(rr[means[1]]), tx(rr[means[2]]) | |
| d = Didx.get((key, "clean_test")) | |
| dm, dv = ("--", "--") if d is None else (tx(d[col(hD, "mean Δ")]), vd(d[col(hD, "verdict")])) | |
| body.append(row(label, seeds, tx(r[col(h, "mean ± sd")]), man, eng, dm, dv)) | |
| cap = (r"Warning head on the clean human gold set (cwm2 \texttt{warning\_gold.py} unchanged: 509 clean-test rows / 63 warranted positives; AUROC, device-cluster bootstrap " | |
| r"$n_{\mathrm{boot}}{=}2000$; per-seed CIs in the source). Seeds index the frozen joint model whose outputs feed the head; current-state heads use no model output and are seed-invariant. " | |
| r"Labels: 979 train consensus anchors. ``Out-of-fold'' = head features from 5 device-fold retrained models. " | |
| r"Columns manual / engaged = per-stratum AUROC means (327 rows / 31 positives and 182 / 32) from the regime report; $\Delta$ vs DMS = paired AUROC difference to the openpilot attention chain on the pooled clean-test stratum. " | |
| + LEGEND + | |
| r"Pre-registered verdicts: \textbf{B4 FAIL} (learned head vs own W\_direct INCONCLUSIVE); \textbf{B5 INCONCLUSIVE} --- matches the DMS attention chain " | |
| r"(mean $\Delta$ +0.015 for the in-sample CV-selected head; +0.016 for the out-of-fold CV-selected head in the regime report \S{}2, while the out-of-fold \S{}5 verdict line quotes +0.032, " | |
| r"which is the HGB current+future out-of-fold column). " | |
| f"Sources: \\texttt{{{rel(wh)}}} \\S{{}}1 (line {l1}), \\S{{}}5 (lines {lb4}--{lb5}); \\texttt{{{rel(oof)}}} \\S{{}}1 (line {l2}), \\S{{}}5 (lines {lb4o}--{lb5o}), " | |
| f"regime report \\S{{}}1 (line {lR}) and \\S{{}}2 (line {lD}).") | |
| return emit("tab_warning_head", cap, | |
| [f"{wh} : §1 clean-test AUROC (line {l1}); §5 verdicts (lines {lb4}, {lb5}): {b4} | {b5}", | |
| f"{oof} : §1 clean-test AUROC (line {l2}); §5 verdicts (lines {lb4o}, {lb5o}): {b4o} | {b5o}", | |
| f"{oof} : regime report §1 per-stratum AUROC (line {lR}); §2 paired Δ vs DMS (line {lD})"], | |
| [(None, "p{0.40\\linewidth} l l r r r l", hdr, body)]) | |
| # ---------------------------------------------------------------------------------------------- | |
| # Table 7b — equal-alert-load operating points | |
| # ---------------------------------------------------------------------------------------------- | |
| def tab_operating_points() -> pathlib.Path: | |
| op = SRC["op"] | |
| ls = lines_of(op) | |
| hdr = ["Regime", "Score", "alerts/h manual / engaged", "$n$ gold / pos", "recall [CI, seed 0]", "precision [CI, seed 0]", "lead median s [IQR]", "detected"] | |
| blocks = [] | |
| srcs = [] | |
| plan = [("item `final_ext_dwfc`", "Load `dms_matched`", "(A) HGB current + dwell + face vs DMS att@3\\,s at the DMS chain's alert load"), | |
| ("item `final_ext_dwfc`", "Load `same_recall`", "(B) same head, thresholded to the DMS chain's gold recall (precision and load at equal recall)"), | |
| ("item `final_ext_dwfc`", "Load `low10`", "(C) same head thresholded to a low load of 10 alerts/h; the DMS row is at its achieved load (16.4 / 14.7 alerts/h)"), | |
| ("item `oof`", "Load `dms_matched`", "(D) HGB current state only, out-of-fold, at the DMS chain's alert load (item \\texttt{oof}, layouts W\\_I1\\_all\\_s0--2\\_oof; current-state features contain no model output)")] | |
| verdicts = [] | |
| for item, load, title in plan: | |
| item_lines, i0 = section(ls, item) | |
| sub, j0 = section(item_lines, load) | |
| h, rows, k = md_tables(sub)[0] | |
| body = [] | |
| for r in rows: | |
| body.append(row(tx(r[col(h, "regime")]), tx(r[col(h, "score")]), tx(r[col(h, "alerts/h")]), tx(r[col(h, "n gold")]), | |
| tx(r[col(h, "recall")]), tx(r[col(h, "precision")]), tx(r[col(h, "lead median s")]), tx(r[col(h, "detected")]))) | |
| blocks.append((title, "l l l l l l l r", hdr, body)) | |
| srcs.append(f"{op} : {item} / {load} (table line {i0 + j0 + k + 1})") | |
| for ln_ in item_lines: | |
| if ln_.startswith("**Verdict (pre-stated rule"): | |
| verdicts.append((item, ln_)) | |
| panel = {"item `final_ext_dwfc`": "(A)--(C)", "item `oof`": "(D)"} | |
| vtxt = "; ".join(f"{panel.get(it, tx(it))}: {tx(v.split(':', 1)[1].strip().rstrip('.')).replace('->', r'$\rightarrow$')}" for it, v in dict(verdicts).items()) | |
| cap = (r"Equal-alert-load operating points of the learned warning head vs the openpilot DMS attention chain (test split; alerts/h with a 60\,s per-route cooldown; " | |
| r"recall / precision on the clean-test gold rows at the fixed thresholds, device-cluster bootstrap; lead time = $t_0$ minus first alert in $[t_0-10\,\mathrm{s}, t_{\mathrm{anchor}}]$). " | |
| r"Precision is measured on the enriched gold set (the $n$ gold / pos column; 512 pooled rows / 63 positives in this table) and is \emph{not} a natural false-alarm rate. Means over seeds 0--2. " | |
| r"Pre-stated lead-time rule (DMS-matched load, pooled): paired $\Delta$ CI $\supset 0 \rightarrow$ EQUAL; " + vtxt + ". " | |
| f"Source: \\texttt{{{rel(op)}}}.") | |
| return emit("tab_operating_points", cap, srcs, blocks) | |
| # ---------------------------------------------------------------------------------------------- | |
| # Robustness summary | |
| # ---------------------------------------------------------------------------------------------- | |
| def _robustness_counts(rob: pathlib.Path) -> dict: | |
| """Verdict counts per perturbation over the 16 reported cells (owner decision 2026-09-17 item 3: engaged hand_leave / hand_return | |
| excluded), read from the per-cell tables of robustness_final.md (manual / engaged); guard: over all 18 cells the recount reproduces | |
| the NOT_WORSE / INCONCLUSIVE / BEATS counts of the §4 summary.""" | |
| h4, r4, _ = first_table(rob, "4. Summary") | |
| counts_all: dict = {} | |
| counts_kept: dict = {} | |
| for regime in ("manual", "engaged"): | |
| h, rows, _ = first_table(rob, regime) | |
| for r in rows: | |
| pert = r[0].strip() | |
| if pert.startswith("clean level"): | |
| continue | |
| for c in range(1, len(h)): | |
| verdict = r[c].split()[-1] | |
| counts_all.setdefault(pert, {})[verdict] = counts_all.setdefault(pert, {}).get(verdict, 0) + 1 | |
| if omitted_cell(regime, h[c].strip()): | |
| continue | |
| counts_kept.setdefault(pert, {})[verdict] = counts_kept.setdefault(pert, {}).get(verdict, 0) + 1 | |
| for r in r4: | |
| pert = r[0].strip() | |
| for k, v in (("NOT_WORSE", r[3]), ("INCONCLUSIVE", r[4]), ("BEATS", r[5])): | |
| want = "0" if v.strip() == "none" else v.strip() | |
| if str(counts_all[pert].get(k, 0)) != want: | |
| raise ValueError(f"robustness_final.md: recount of {k} for {pert!r} = {counts_all[pert].get(k, 0)} differs from the §4 summary {want}") | |
| return counts_kept | |
| def tab_robustness() -> pathlib.Path: | |
| rob = SRC["rob"] | |
| h, rows, l4 = first_table(rob, "4. Summary") | |
| hdr = ["Perturbation", "Description", "Significantly worse cells ($\\Delta$ PR-AUC@3\\,s)", "not worse", "n.s.", "better"] | |
| if _iclr(): # owner decision 2026-09-17 item 3: the two engaged hand cells leave the list and the counts are re-derived over 16 cells | |
| kept = _robustness_counts(rob) | |
| body = [row(tx(r[0]), tx(r[1]), tx(strip_engaged_hand(r[2])), str(kept[r[0].strip()].get("NOT_WORSE", 0)), | |
| str(kept[r[0].strip()].get("INCONCLUSIVE", 0)), "none" if kept[r[0].strip()].get("BEATS", 0) == 0 else str(kept[r[0].strip()]["BEATS"])) | |
| for r in rows] | |
| else: | |
| body = [row(tx(r[0]), tx(r[1]), tx(r[2]), tx(r[3]), tx(r[4]), tx(r[5])) for r in rows] | |
| cap = (r"Test-time input perturbations of the frozen main model (no retraining; seeds 0--2; both regimes; 18 main endpoints = 9 per regime: " | |
| r"steer phase, gas, brake, any vehicle event, hand leave, hand return, head turn, P ttc-drop, P cut-in). " | |
| r"Cells list the endpoints whose perturbed $-$ clean $\Delta$ is significantly worse (mean $\Delta$ in parentheses); the counts give the remaining verdicts. " | |
| + LEGEND + r"In this file NOT\_WORSE additionally requires $|\Delta| < 0.01$ on every seed with no CI excluding 0. " + f"Source: \\texttt{{{rel(rob)}}} \\S{{}}4 (line {l4}); per-cell $\\Delta$ in \\S{{}}1--2 of the same file.") | |
| return emit("tab_robustness", cap, [f"{rob} : §4 summary (line {l4})"], | |
| [(None, "l p{0.22\\linewidth} p{0.42\\linewidth} r r r", hdr, body)]) | |
| # ---------------------------------------------------------------------------------------------- | |
| # Branch-architecture ablation | |
| # ---------------------------------------------------------------------------------------------- | |
| def tab_branch_arch() -> pathlib.Path: | |
| arch = SRC["arch"] | |
| ls = lines_of(arch) | |
| hdr = ["Branch", "Alternative vs survivor", "Params A (total / enc.)", "Params B (total / enc.)", | |
| "Own cells better (mean $\\Delta$)", "Own cells worse (mean $\\Delta$)", "Other cells worse / better", "Verdict"] | |
| body = [] | |
| srcs = [] | |
| for i, ln in enumerate(ls): | |
| if ln.startswith("## ") and not ln.startswith("## Reading"): | |
| sec, _ = section(ls, ln.lstrip("#").strip(), start=i) | |
| tabs = md_tables(sec, merge_col=1) | |
| hp, rp, kp = tabs[0] | |
| hc, rc, kc = tabs[1] | |
| verdict = next(l_ for l_ in sec if l_.startswith("verdict:")).split(":", 1)[1].replace("**", "").strip() | |
| title = ln.lstrip("#").strip() | |
| branch, rest = title.split(":", 1) | |
| alt = rest.strip() | |
| pa = rp[0][col(hp, "A params")] | |
| pb = rp[0][col(hp, "B params")] | |
| better, worse, other_w, other_b = [], [], [], [] | |
| for r in rc: | |
| v = r[col(hc, "verdict")] | |
| lab = f"{r[col(hc, 'regime')]} {cell_name(r[col(hc, 'cell')])} ({tx(r[col(hc, 'mean Δ ± sd')].split(' ± ')[0])})" | |
| own = r[col(hc, "own")] == "own" | |
| if v.startswith("BEATS"): | |
| (better if own else other_b).append(lab) | |
| elif v.startswith("WORSE"): | |
| (worse if own else other_w).append(lab) | |
| other = "worse: " + ("; ".join(other_w) if other_w else "none") + "; better: " + ("; ".join(other_b) if other_b else "none") | |
| verdict_w = verdict.replace("cell(s)", "cells").replace("NOT_WORSE", "not worse").replace("BEATS", "better").replace("WORSE", "worse").replace("INCONCLUSIVE", "n.s.") | |
| body.append(row(tx(branch.split(" ")[0]), tx(alt), tx(pa), tx(pb), "; ".join(better) if better else "none", "; ".join(worse) if worse else "none", other, tx(verdict_w))) | |
| srcs.append(f"{arch} : '{title}' (params table line {i + 1 + kp + 1}; cell table line {i + 1 + kc + 1})") | |
| cap = (r"Branch-architecture ablation: parameter-matched trunk swaps on the survivor recipes (3 seeds, test, both regimes; paired on identical rows). " | |
| r"$\Delta$ = alternative $-$ survivor; lower-is-better cells are sign-flipped for the verdict. `Own' cells are the cells tagged \texttt{own} in the source (the branch's onset endpoints and, for V, its CAN emission CRPS / MAE cells: 6 / 18 / 24 own cells for U / V / E); `other' cells are the remaining hazard NLL / Brier / F-cosine cells. " | |
| r"Pre-registered reading: architecture-insensitive iff no own cell is significantly better or worse. " + LEGEND + | |
| f"Source: \\texttt{{{rel(arch)}}} (one section per comparison).") | |
| return emit("tab_branch_arch", cap, srcs, | |
| [(None, "l p{0.14\\linewidth} p{0.085\\linewidth} p{0.085\\linewidth} p{0.12\\linewidth} p{0.15\\linewidth} p{0.15\\linewidth} p{0.11\\linewidth}", hdr, body)]) | |
| # ---------------------------------------------------------------------------------------------- | |
| # Decoder baselines: chunked (B3) and RSSM rollout | |
| # ---------------------------------------------------------------------------------------------- | |
| def _lists(s: str) -> dict[str, str]: | |
| """Extract WORSE / BEATS cross / BEATS own lists from a verdict line.""" | |
| out = {} | |
| for key, pat in [("worse", r"WORSE(?: own)?:? (\[[^\]]*\]|none)"), ("cross", r"BEATS cross:? (\[[^\]]*\]|none)"), ("own", r"BEATS own:? (\[[^\]]*\]|none)")]: | |
| m = re.search(pat, s) | |
| out[key] = m.group(1) if m else "--" | |
| return out | |
| def _fmt_list(s: str) -> str: | |
| if s in ("none", "--"): | |
| return s | |
| items = re.findall(r"'([^']*)'", s) | |
| return "; ".join(tx(i.replace("|", " / ").replace("_", " ")) for i in items) + f" ({len(items)} cell{'s' if len(items) != 1 else ''})" if items else tx(s) | |
| def tab_rssm() -> pathlib.Path: | |
| sF, sR = SRC["stage_F"], SRC["rssm"] | |
| # panel 1: verdict rows | |
| secF, iF = section(lines_of(sF), "Claim B3 verdict") | |
| fw = next(l_ for l_ in secF if l_.startswith("- own endpoints WORSE")).split(":", 1)[1].strip() | |
| fc = next(l_ for l_ in secF if l_.startswith("- cross-leg endpoints BEATS")).split(":", 1)[1].strip() | |
| fo = next(l_ for l_ in secF if l_.startswith("- own endpoints BEATS")).split(":", 1)[1].strip() | |
| p_line, lp = find_line(sR, "### Primary verdict") | |
| k_line, lk = find_line(sR, "### Kill rule") | |
| s_line, lsec = find_line(sR, "### Secondary verdict") | |
| P, S = _lists(p_line), _lists(s_line) | |
| hdr1 = ["Comparison (A $-$ B, 3 seeds)", "Pre-registered rule", "Own / any endpoints significantly worse", "Own endpoints significantly better", "Cross-leg better", "Verdict"] | |
| body1 = [ | |
| row("B3: chunked decoder $-$ parameter-matched fresh direct decoder", "no endpoint worse and $\\geq 1$ better", _fmt_list(fw), _fmt_list(fo), _fmt_list(fc), "FAIL"), | |
| row("RSSM stochastic rollout $-$ fresh direct heads (same interaction set)", "B3-style; killed if manual brake / gas / steer-phase onset worse", | |
| _fmt_list(P["worse"]), _fmt_list(P["own"]), _fmt_list(P["cross"]), "FAIL (not killed by the CAN cells: " + "; ".join(f"{cell_name(c.split('|', 1)[1].rsplit('|', 1)[0].replace('|', '/') + '/3s')} {vd(v)}" for c, v in re.findall(r"'([^']+)': '([A-Z_]+)'", k_line)) + ")"), | |
| row("RSSM stochastic rollout $-$ frozen main model (pretrained direct heads)", "B3-style", _fmt_list(S["worse"]), _fmt_list(S["own"]), _fmt_list(S["cross"]), "FAIL"), | |
| ] | |
| # panel 2: the CAN kill-rule cells + head turn | |
| pairs = [("chunked $-$ direct\\_fresh", paired_index(sF, "Main comparison: A = chunked, B = direct_fresh")), | |
| ("RSSM $-$ direct\\_fresh", paired_index(sR, "1. PRIMARY")), | |
| ("RSSM $-$ frozen main", paired_index(sR, "2. SECONDARY"))] | |
| cells = [("manual", "veh_onset/brake_on/3s"), ("manual", "veh_onset/gas_on/3s"), ("manual", "veh_onset/steer_phase_on/3s"), | |
| ("manual", "drv_onset/head_turn_onset/3s"), ("engaged", "drv_onset/head_turn_onset/3s")] | |
| hdr2 = ["Pair", "Regime", "Endpoint (PR-AUC@3\\,s)", "A s0 / s1 / s2", "mean $\\Delta$ $\\pm$ sd", "verdict"] | |
| body2 = [] | |
| lines2 = [] | |
| for name, (d, ln) in pairs: | |
| lines2.append(ln) | |
| ci = d["ci"] | |
| for regime, cell in cells: | |
| r = d["idx"][(regime, cell, "pr_auc")] | |
| body2.append(row(name, regime, cell_name(cell), " / ".join(tx(r[ci[k]]) for k in ["A s0", "A s1", "A s2"]), tx(strip_n(r[ci["mean Δ ± sd"]])), vd(r[ci["verdict"]]))) | |
| cap = (r"Decoder baselines (negative results): the chunked 1\,s-step decoder (claim B3) and the cwm3-native stochastic latent rollout decoder (RSSM: per-chunk Gaussian latent, " | |
| r"GRU transition on the model's own expected emissions, 32 prior samples at prediction) against parameter-matched direct 25-step heads and against the frozen main model. " | |
| r"Top: pre-registered verdicts with the cell lists of the source. Bottom: the pre-stated CAN kill-rule cells and head turn. " | |
| r"B3 (\texttt{stage\_F.md}) was run on the pre-final bases (v1 packs; driver cells on the route-median ROI inputs); the two RSSM pairs are on the final bases with the v2 causal driver targets. " + LEGEND + | |
| f"Sources: \\texttt{{{rel(sF)}}} (B3 verdict from line {iF + 1}; table line {lines2[0]}); \\texttt{{{rel(sR)}}} (verdict lines {lp}, {lk}, {lsec}; tables at lines {lines2[1]}, {lines2[2]}).") | |
| return emit("tab_rssm", cap, | |
| [f"{sF} : Claim B3 verdict (line {iF + 1}); main comparison chunked vs direct_fresh (table line {lines2[0]})", | |
| f"{sR} : primary verdict (line {lp}), kill rule (line {lk}), secondary verdict (line {lsec}); tables at lines {lines2[1]}, {lines2[2]}"], | |
| [("Verdicts", "p{0.22\\linewidth} p{0.13\\linewidth} p{0.22\\linewidth} p{0.16\\linewidth} p{0.08\\linewidth} p{0.11\\linewidth}", hdr1, body1), | |
| ("Kill-rule cells", "l l l l r l", hdr2, body2)]) | |
| # ---------------------------------------------------------------------------------------------- | |
| # Appendix: gaze-chain joint variant (driver cells) | |
| # ---------------------------------------------------------------------------------------------- | |
| def tab_gzfc() -> pathlib.Path: | |
| g = SRC["gzfc"] | |
| hO, rO, lO = first_table(g, "Own endpoints of (a)") | |
| hA, rA, lA = first_table(g, "B1 on the variant — driver onset PR-AUC@3s (v2 causal targets) vs the k0 heuristic / persistence, protocol: all rows") | |
| hM, rM, lM = first_table(g, "B1 on the variant — driver onset PR-AUC@3s (v2 causal targets) vs the k0 heuristic / persistence, protocol: suspect routes masked") | |
| v_line, lv = find_line(g, "## VERDICT") | |
| Oidx = {(r[col(hO, "regime")], r[col(hO, "own endpoint")]): r for r in rO} | |
| def b1(rows, h, regime, event): | |
| for r in rows: | |
| if r[col(h, "variant")] == "allminusgzfc" and r[col(h, "regime")] == regime and r[col(h, "event")] == event: | |
| return r | |
| raise KeyError((regime, event)) | |
| hdr = ["Regime", "Event", "$\\Delta$ variant $-$ frozen main (a)", "verdict", "Variant (all rows)", "k0", "Persistence", "vs k0", "Variant (masked)", "k0 (masked)", "vs k0"] | |
| body = [] | |
| for regime in ["manual", "engaged"]: | |
| for ev in ["hand_leave", "hand_return", "head_turn_onset"]: | |
| o = Oidx[(regime, f"drv_onset/{ev}/3s")] | |
| a = b1(rA, hA, regime, ev) | |
| m = b1(rM, hM, regime, ev) | |
| body.append(row(regime, cell_name(ev), tx(o[col(hO, "mean Δ")]), vd(o[col(hO, "verdict")]), tx(a[col(hA, "model")]), tx(a[col(hA, "k0")]), | |
| tx(a[col(hA, "persistence")]), vd(a[col(hA, "verdict")]), tx(m[col(hM, "model")]), tx(m[col(hM, "k0")]), vd(m[col(hM, "verdict")]))) | |
| b1a = next(r for r in rA if r[col(hA, "variant")] == "allminusgzfc" and "B1" in r[col(hA, "regime")]) | |
| b1m = next(r for r in rM if r[col(hM, "variant")] == "allminusgzfc" and "B1" in r[col(hM, "regime")]) | |
| cap = (r"Appendix variant (never replaces the headline model): the frozen joint recipe on the gaze U base (\texttt{gaze\_off} chain + causal face inputs), driver-onset PR-AUC@3\,s on the v2 causal targets " | |
| r"(3 seeds, test, paired on identical rows). Column~3: paired $\Delta$ of the variant vs the frozen main model (pre-registered comparison (a)); columns 5--8: B1 on the variant (all rows); " | |
| r"columns 9--11: suspect routes masked. Pre-registered verdict: " + tx(v_line.lstrip("#").strip().split(":", 1)[1].strip()) + | |
| f" (no own endpoint worse; head turn better in both regimes). B1 on the variant: {tx(b1a[-2])} $\\rightarrow$ {tx(b1a[-1])} (all rows); {tx(b1m[-2])} $\\rightarrow$ {tx(b1m[-1])} (masked). " | |
| r"Human gaze validation is pending (\texttt{docs/progress\_2026-09-11.md} \S{}12.7). " + LEGEND + | |
| f"Source: \\texttt{{{rel(g)}}} (verdict line {lv}; tables at lines {lO}, {lA}, {lM}).") | |
| return emit("tab_gzfc", cap, [f"{g} : VERDICT (line {lv})", f"{g} : Own endpoints of (a) (line {lO})", f"{g} : B1 on the variant, all rows (line {lA})", f"{g} : B1 on the variant, masked (line {lM})"], | |
| [(None, "l l r l r r r l r r l", hdr, body)]) | |
| # ---------------------------------------------------------------------------------------------- | |
| # Appendix: E4 non-causal ROI sensitivity | |
| # ---------------------------------------------------------------------------------------------- | |
| def tab_e4() -> pathlib.Path: | |
| n = SRC["ncroi"] | |
| hC, rC, lC = first_table(n, "Driver own endpoints of (a)") | |
| hR, rR, lR = first_table(n, "Driver cells of ncroi vs frozen main on the ROUTE-MEDIAN targets") | |
| hS, rS, lS = first_table(n, "Driver cells: indep_ncroi vs indep") | |
| hM, rM, lM = first_table(n, "Driver cells: ncroi vs frozen main, masked") | |
| r_line, lr = find_line(n, "## READING") | |
| def idx(rows, h): | |
| return {(r[col(h, "regime")], r[col(h, "driver cell")]): r for r in rows} | |
| C, R, S, M = idx(rC, hC), idx(rR, hR), idx(rS, hS), idx(rM, hM) | |
| hdr = ["Regime", "Event", "$\\Delta$ causal", "verdict", "$\\Delta$ causal, masked", "verdict", "$\\Delta$ U-swap only", "verdict", | |
| "$\\Delta$ route-median", "verdict"] | |
| body = [] | |
| for regime in ["manual", "engaged"]: | |
| for ev in ["hand_leave", "hand_return", "head_turn_onset"]: | |
| k = (regime, f"drv_onset/{ev}/3s") | |
| body.append(row(regime, cell_name(ev), tx(C[k][2]), vd(C[k][3]), tx(M[k][2]), vd(M[k][3]), tx(S[k][2]), vd(S[k][3]), tx(R[k][2]), vd(R[k][3]))) | |
| cap = (r"E4 sensitivity row: the frozen joint recipe on a \emph{non-causal} ROI driver base (cwm2 route-median kinematics) minus the frozen main model (causal ROI), driver-onset PR-AUC@3\,s, " | |
| r"3 seeds, test, paired on identical rows (mean $\Delta$ = ncroi $-$ causal). Columns: $\Delta$ causal = on the v2 causal targets, all rows; masked = the 64 suspect routes removed from every population; " | |
| r"U-swap only = \texttt{indep\_ncroi} $-$ \texttt{indep} (assembled bases, no interaction training); route-median = on the route-median targets (descriptive). On the v2 causal targets the non-causal ROI is significantly worse on every driver cell (also after masking the 64 suspect routes, " | |
| r"and for the U-base swap alone without joint training); the apparent non-causal ``gain'' appears only on the route-median targets, which carry the same non-causal ROI as the inputs (the leak the K4 protocol removed). " | |
| r"Pre-registered expected reading: " + tx(r_line.lstrip("#").split(":", 1)[1].strip()) + ". The frozen main stays the headline. " + LEGEND + | |
| f"Source: \\texttt{{{rel(n)}}} (reading line {lr}; tables at lines {lC}, {lM}, {lS}, {lR}).") | |
| return emit("tab_e4", cap, [f"{n} : READING (line {lr})", f"{n} : Driver own endpoints of (a), causal targets (line {lC})", f"{n} : masked (line {lM})", | |
| f"{n} : U-base swap alone (line {lS})", f"{n} : route-median targets, descriptive (line {lR})"], | |
| [(None, "l l r l r l r l r l", hdr, body)]) | |
| # ---------------------------------------------------------------------------------------------- | |
| # Table 5 — Exp3-P: the E-branch road-pressure head P vs the current-margin rule (main text) | |
| # ---------------------------------------------------------------------------------------------- | |
| def _seed_deltas(cell: str) -> str: | |
| """'-0.208 [-0.254,-0.151] / -0.198 [...] / -0.212 [...]' -> '-0.208 / -0.198 / -0.212' (the CIs stay in the source).""" | |
| return " / ".join(tx(p.strip().split(" ")[0]) for p in cell.split("/")) | |
| def _hcol(header: list[str], *needles: str) -> int: | |
| for i, h in enumerate(header): | |
| hh = h.replace("**", "") | |
| if all(n in hh for n in needles): | |
| return i | |
| raise KeyError((needles, header)) | |
| def tab_baton_exp3P() -> pathlib.Path: | |
| p3 = SRC["exp3_P"] | |
| hA, rA, lA = first_table(p3, "(a) P-onset") | |
| hC, rC, lC = first_table(p3, "(c) regionpca256_P") | |
| _, lva = find_line(p3, "- **(a) pooled_P vs the current-margin rule**") | |
| _, lvb = find_line(p3, "- **(b) adding the P head") | |
| _, lvc = find_line(p3, "- **(c) spatial road stream") | |
| c_reg, c_chain = col(hA, "regime"), col(hA, "chain") | |
| c_pool, c_rp = col(hA, "pooled_P"), col(hA, "regionpca256_P") | |
| c_rule, c_pers = col(hA, "margin rule"), col(hA, "persistence") | |
| c_d1 = _hcol(hA, "pooled_P", "margin") | |
| c_d2 = _hcol(hA, "rp256_P", "margin") | |
| Cidx = {(r[col(hC, "regime")], r[col(hC, "chain")]): r for r in rC} | |
| hdr = ["Chain", "P pooled", "P spatial", "Rule $S_0$", "Persist.", | |
| "$\\Delta$ pooled $-$ rule (per seed)", "verdict", "spatial vs rule", "$\\Delta$ spat.\\ $-$ pooled", "verdict"] | |
| body = [] | |
| for regime in ["manual", "engaged"]: | |
| body.append(group(10, f"{regime} regime")) | |
| for r in rA: | |
| if r[c_reg] != regime: | |
| continue | |
| c = Cidx[(regime, r[c_chain])] | |
| body.append(row(r"\texttt{" + tx(r[c_chain]) + "}", tx(r[c_pool]), tx(r[c_rp]), tx(r[c_rule]), tx(r[c_pers]), | |
| _seed_deltas(r[c_d1]), vd(r[c_d1 + 1]), vd(r[c_d2 + 1]), tx(c[col(hC, "mean ± sd")]), vd(c[col(hC, "verdict")]))) | |
| cap = (r"Exp3-P: the road-pressure head~P emitted by the environment branch~E (six chains, test split, 3 seeds, mean $\pm$ sd; rows inactive and valid at $t$) " | |
| r"against the current-margin rule $S_0$ (threshold-normalised margin at $t$; a label-free current-state rule) and persistence (= base rate), P-onset PR-AUC@3\,s. " | |
| r"P pooled / P spatial = the P head on the pooled road latent used by the main model / on the spatial region-PCA-256 road stream; Rule $S_0$ = the current-margin rule; Persist.\ = persistence. " | |
| r"Column 6: paired device-cluster bootstrap on identical rows ($n_{\mathrm{boot}}{=}1000$), $\Delta$ per seed s0 / s1 / s2 (CIs in the source); column 8: verdict of the spatial head against the rule; " | |
| r"columns 9--10: spatial $-$ pooled on the same P cells (mean $\pm$ sd). " | |
| + LEGEND + | |
| r"Source verdict lines: (a) pooled P vs the rule --- significantly better on manual \texttt{ttc\_drop}, \texttt{cut\_in}, \texttt{badas} and engaged \texttt{cut\_in}; significantly worse on \texttt{ttc} and \texttt{lane\_excursion} in both regimes; no significant difference on engaged \texttt{ttc\_drop}, \texttt{lead\_braking}, \texttt{badas}; " | |
| r"(b) adding the P head costs the demand chains nothing (D cells worse: none; PASS); (c) spatial $-$ pooled: P cells better none, worse none, while its D / F cells are significantly worse on manual D steer rate and on the F cosine at every horizon in both regimes. " | |
| f"Source: \\texttt{{{rel(p3)}}} \\S{{}}(a) (table line {lA}), \\S{{}}(c) (line {lC}), Verdicts (lines {lva}--{lvc}).") | |
| return emit("tab_baton_exp3P", cap, | |
| [f"{p3} : (a) P-onset PR-AUC@3s levels and paired Δ vs the current-margin rule (table line {lA})", | |
| f"{p3} : (c) regionpca256_P − pooled_P on the P cells (table line {lC})", | |
| f"{p3} : Verdicts (a) line {lva}, (b) line {lvb}, (c) line {lvc}"], | |
| [(None, "l r r r r l l l r l", hdr, body)], colsep="2pt") | |
| # ---------------------------------------------------------------------------------------------- | |
| # AIDE — Driver-WM Table-3 intervention mirror (§4b of stage_bc.md) | |
| # ---------------------------------------------------------------------------------------------- | |
| _INT_RE = re.compile(r"^([-+]?\d+\.\d+)\s*\(([-+]?\d+\.\d+)\s*%\)(?:\s*\(max view ([-+]?\d+\.\d+)\))?\s*$") | |
| def _parse_intervention(cell: str): | |
| """'3.44 (7.1 %) (max view 3.76) · 6.57 · 4.13 · 2.13 · 4.91 [n=3]' -> (ΔAll, Δ/All, max-view, HM, h5, Head, Hands, footnote).""" | |
| s = cell.strip() | |
| if s in ("n/a", "–", "-", ""): | |
| return None | |
| foot = "ᵃ" in s | |
| s = s.replace("ᵃ", "").replace("[n=3]", "") | |
| parts = [p.strip() for p in s.split("·")] | |
| m = _INT_RE.match(parts[0]) | |
| if not m or len(parts) != 5: | |
| raise ValueError(f"unexpected intervention cell: {cell!r}") | |
| return m.group(1), m.group(2), m.group(3), parts[1], parts[2], parts[3], parts[4], foot | |
| def tab_aide_interventions() -> pathlib.Path: | |
| bc = SRC["stage_bc"] | |
| h, rows, l4b = first_table(bc, "4b.") | |
| _, lnote = find_line(bc, "Reading (roadmap B §B2 wording)") | |
| _, ldef = find_line(bc, "do(zero_ext) = exterior features zeroed") | |
| c_paper_d = _hcol(h, "paper Δ All") | |
| c_paper_p = _hcol(h, "paper Δ/All") | |
| c_nogate = _hcol(h, "B2 main, no gate") | |
| c_gate = _hcol(h, "traffic gate (iii)") | |
| c_repro = _hcol(h, "Driver-WM reproduction (C1)") | |
| models = [("Driver-WM main (paper, 1 run)", "paper", c_paper_d, None), | |
| ("CWM3-D vis+sem (B2 main, no gate)", "ours", c_nogate, c_nogate + 1), | |
| ("CWM3-D vis+sem + traffic gate (iii)", "ours", c_gate, c_gate + 1), | |
| ("Driver-WM reproduction (C1)", "ours", c_repro, c_repro + 1)] | |
| hdr = ["Intervention", "Model", "$\\Delta$ All", "$\\Delta$/All (\\%)", "$\\Delta$ HM", "$\\Delta$ $h{=}5$", "$\\Delta$ Head", "$\\Delta$ Hands", "GT All ($-$ factual)"] | |
| body = [] | |
| for k, r in enumerate(rows): | |
| first = True | |
| for label, kind, cd, cgt in models: | |
| if kind == "paper": | |
| if r[cd].strip() in ("–", "-", ""): | |
| cells, gt = ["--"] * 6, "--" | |
| else: | |
| parts = [tx(p.strip()) for p in r[cd].split("/")] | |
| cells = [parts[0], tx(r[c_paper_p].replace("%", "").strip()), parts[1], parts[2], parts[3], parts[4]] | |
| gt = "--" | |
| else: | |
| parsed = _parse_intervention(r[cd]) | |
| if parsed is None: | |
| cells, gt = ["n/a"] + ["--"] * 5, "--" | |
| else: | |
| d_all, pct, mx, hm, h5, hd, hands, foot = parsed | |
| d_all_s = tx(d_all) + (f" (max view {tx(mx)})" if mx else "") + ("$^{a}$" if foot else "") | |
| cells, gt = [d_all_s, tx(pct), tx(hm), tx(h5), tx(hd), tx(hands)], tx(r[cgt]) | |
| body.append(row(tx(r[0]) if first else "", label, *cells, gt)) | |
| first = False | |
| if k < len(rows) - 1: | |
| body.append(r"\addlinespace") | |
| cap = (r"Test-time interventions on AIDE (mirror of the Driver-WM paper's Table~3; test, $n{=}609$). $\Delta$ = deviation of the intervened rollout from the factual rollout in px " | |
| r"(All, High-Motion subset, horizon $h{=}5$, head joints, both hands); $\Delta$/All = $\Delta$~All $\div$ the model's factual GT All-MPJPE (paper: $\div$ 71.47), the only column comparable across models " | |
| r"whose factual error differs. Paper rows: single seed, no CI, typed verbatim; ours: means over 3 seeds. Last column: direct GT All-MPJPE of the intervened rollout (paired difference to the factual rollout in parentheses). " | |
| r"Operators: swap = exterior features of another test clip (fixed derangement); remove ext = exterior features zeroed on the observed window; shift large / small = exterior features delayed 2 / 1 protocol steps; " | |
| r"drop view = one exterior view zeroed (mean over the three views, max in the cell); disable pathway / force / over-injection = traffic gate $\lambda_{\mathrm{CA}}$ clamped to 0 / 1 / 2. " | |
| r"$^{a}$~The B2 main model has no traffic gate: disable pathway / over-injection are mirrored by scaling its exterior visual tokens by 0 / 2 before the trunk (an analogue, not the same operator); force is undefined for it (n/a). " | |
| f"Source: \\texttt{{{rel(bc)}}} \\S{{}}4b (table line {l4b}; operator definitions line {ldef}; reading line {lnote}).") | |
| return emit("tab_aide_interventions", cap, | |
| [f"{bc} : §4b Full Table-3 mirror (table line {l4b}); operator definitions (line {ldef}); reading (line {lnote})"], | |
| [(None, "l l r r r r r r r", hdr, body)]) | |
| # ---------------------------------------------------------------------------------------------- | |
| # Appendix — cross-dataset transfer in both directions (C1 AIDE->BATON; BATON->AIDE pose pretraining) | |
| # ---------------------------------------------------------------------------------------------- | |
| def tab_app_transfer() -> pathlib.Path: | |
| c1, bp = SRC["c1"], SRC["baton_pretrain"] | |
| h2, r2, l2 = first_table(c1, "2. Fine-tuned U0 (AIDE trunk) vs scratch") | |
| h3, r3, l3 = first_table(c1, "3. Fine-tuned U0 (AIDE trunk) vs the k0") | |
| v4, lv4 = find_line(c1, "**Verdict: FAIL") | |
| k0 = {(r[col(h3, "regime")], r[col(h3, "event")]): r for r in r3} | |
| hdrA = ["Regime", "Event", "AIDE-init s0 / s1 / s2", "Scratch s0 / s1 / s2", "mean $\\Delta$ $\\pm$ sd", "seeds $\\Delta \\geq +0.02$", "verdict", | |
| "k0 heuristic", "AIDE-init $-$ k0", "verdict"] | |
| bodyA = [] | |
| for regime in ["manual", "engaged"]: | |
| for r in r2: | |
| if r[col(h2, "regime")] != regime: | |
| continue | |
| k = k0[(regime, r[col(h2, "event")])] | |
| bodyA.append(row(tx(regime), cell_name(r[col(h2, "event")]), tx(r[col(h2, "A s0/s1/s2")]), tx(r[col(h2, "B s0/s1/s2")]), | |
| tx(r[col(h2, "mean Δ ± sd")]), tx(r[col(h2, "seeds Δ ≥ +0.02")]), vd(r[col(h2, "verdict")]), | |
| tx(k[col(h3, "k0")]), tx(k[col(h3, "mean Δ ± sd")]), vd(k[col(h3, "verdict")]))) | |
| arms = [("3. keypoint-only CWM3-D-kp: fine-tuned", "CWM3-D-kp, all weights", "pre-registered", "not adopted (rule not met)"), | |
| ("4. vis+sem CWM3-D (B2 main): fine-tuned", "CWM3-D vis+sem (B2 main), all weights", "pre-registered", "not adopted (rule not met)"), | |
| ("5. keypoint-only CWM3-D-kp, TRUNK-only init — POST HOC", "CWM3-D-kp, trunk only (pretraining seed 42)", "post hoc", "exploratory; not adopted on its own"), | |
| ("6. keypoint-only CWM3-D-kp, TRUNK-only init — PRE-REGISTERED REPLICATION", "CWM3-D-kp, trunk only (independent pretraining seed 123)", "pre-registered replication", "replicated; adopted"), | |
| ("7. vis+sem CWM3-D (B2 main), TRUNK-only init — PRE-REGISTERED", "CWM3-D vis+sem (B2 main), trunk only", "pre-registered", "not adopted (rule not met)"), | |
| ("8. vis + attention heads + learned view gate", "vis + attention heads + view gate, (a) checkpoint, trunk only", "pre-registered", "adopted (reported row)")] | |
| hdrB = ["Arm [registration] (A = fine-tuned from the BATON-pretrained checkpoint; B = seed init)", "$\\Delta$ All-MPJPE", "verdict", "$\\Delta$ HM-MPJPE", "verdict", | |
| "$\\Delta$ PCK@0.05", "verdict", "$\\Delta$ HM $h{=}5$", "verdict", "Outcome (kill rule)"] | |
| bodyB, srcB = [], [] | |
| ls = lines_of(bp) | |
| for prefix, label, reg, outcome in arms: | |
| sec, i0 = section(ls, prefix) | |
| tabs = md_tables(sec) | |
| hc, rc, kc = next(t for t in tabs if t[0][0].strip() == "cell") | |
| kill = next((j for j, l_ in enumerate(sec) if l_.startswith("**Kill rule")), None) | |
| vals = [] | |
| for cell in ["All-MPJPE", "HM-MPJPE", "PCK@0.05", "HM h=5"]: | |
| rr = find_row(rc, col(hc, "cell"), cell) | |
| vals += [tx(rr[col(hc, "mean Δ ± sd")]), vd(rr[col(hc, "verdict")])] | |
| bodyB.append(row(f"{label} [{reg}]", *vals, outcome)) | |
| srcB.append(f"{bp} : §{prefix.split('.')[0]} cell table (line {i0 + kc + 1}); kill-rule line {i0 + kill + 1 if kill is not None else '?'}") | |
| cap = (r"Appendix: cross-dataset transfer in both directions. (A)~AIDE $\rightarrow$ BATON (C1): the survivor driver trunk (input LayerNorm + GRU + mode token) pretrained self-supervised on " | |
| r"11 BATON-style kinematic channels built from the AIDE in-cabin keypoints (2\,s $\rightarrow$ next 1\,s, Laplace NLL), then trained with the unchanged BATON recipe, vs the scratch survivor; " | |
| r"test driver-onset PR-AUC@3\,s, paired device-cluster bootstrap on identical causal-v2 rows; last three columns: the same AIDE-initialised model against the label-free k0 current-state heuristic. " | |
| r"Pre-registered acceptance (engaged \texttt{hand\_leave} AND \texttt{head\_turn\_onset}: $\Delta \geq +0.02$ on $\geq 2/3$ seeds and BEATS; no manual driver cell WORSE): " | |
| r"\textbf{FAIL --- no transfer}. (B)~BATON $\rightarrow$ AIDE: CWM3-D fine-tuned from a checkpoint pretrained on 642,179 BATON in-cabin pose windows (train-split, train-only devices), " | |
| r"vs the same recipe from the seed init (AIDE test, $n{=}609$, paired per-clip bootstrap 10k; $\Delta$ = A $-$ B, mean $\pm$ sd over seeds 42/123/456; negative = better for errors, positive = better for PCK). " | |
| r"Verdicts in (B) follow the source: BEATS / WORSE = CI excl.\ 0 on $\geq 2/3$ seeds, same sign; NOT\_WORSE = all CIs cover 0 and $|\Delta| < 0.25$; else INCONCLUSIVE; " | |
| r"pre-registered kill rule: adopt only if $\Delta$~All-MPJPE is BEATS (HM $h{=}5$ reported regardless). " + LEGEND + | |
| f"Sources: \\texttt{{{rel(c1)}}} \\S{{}}2 (line {l2}), \\S{{}}3 (line {l3}), \\S{{}}4 verdict (line {lv4}); \\texttt{{{rel(bp)}}} \\S{{}}3--8 cell tables and kill-rule lines.") | |
| return emit("tab_app_transfer", cap, | |
| [f"{c1} : §2 AIDE-init vs scratch (table line {l2}); §3 vs k0 (table line {l3}); §4 verdict (line {lv4}): {v4}"] + srcB, | |
| [("(A) AIDE $\\rightarrow$ BATON: driver trunk pretrained on AIDE, fine-tuned on BATON (C1)", "l l l l r l l r r l", hdrA, bodyA), | |
| ("(B) BATON $\\rightarrow$ AIDE: CWM3-D fine-tuned from BATON in-cabin pose pretraining", "p{0.27\\linewidth} r l r l r l r l p{0.14\\linewidth}", hdrB, bodyB)], | |
| colsep="2.5pt") | |
| # ---------------------------------------------------------------------------------------------- | |
| # Appendix — power of the clean-test gold for the head-vs-DMS paired AUROC claim | |
| # ---------------------------------------------------------------------------------------------- | |
| def tab_app_power() -> pathlib.Path: | |
| pg = SRC["power"] | |
| h, rows, l = first_table(pg, "Power of the clean-test gold") | |
| _, la = find_line(pg, "Anchor:") | |
| _, lr = find_line(pg, "Reading:") | |
| hdr = [["", r"\multicolumn{2}{c}{paired-$\Delta$ CI half-width}", "", "", r"\multicolumn{4}{c}{declarable $\Delta$?}", r"\multicolumn{2}{c}{new clips}", ""], | |
| r"\cmidrule(lr){2-3}\cmidrule(lr){6-9}\cmidrule(lr){10-11}", | |
| ["$n_{\\mathrm{pos}}$", "calibrated", "Hanley--McNeil", "manual / engaged", "smallest $\\Delta$", "0.1", "0.075", "0.05", "0.03", "@12.4\\%", "@25\\%", "note"]] | |
| def note_tx(c: str) -> str: | |
| m = re.match(r"n_pos needed to declare Δ = ([\d.]+)$", c.strip()) | |
| return f"$n_{{\\mathrm{{pos}}}}$ needed for $\\Delta{{=}}{m.group(1)}$" if m else (tx(c) if c.strip() else "--") | |
| body = [] | |
| for i, r in enumerate(rows): | |
| if r[-1].strip(): | |
| if not any(x.startswith(r"\midrule") for x in body): | |
| body.append(r"\midrule") | |
| body.append(row(*[tx(c) if c.strip() else "--" for c in r[:-1]], note_tx(r[-1]))) | |
| cap = (r"Appendix: power of the clean-test warning gold (509 rows / 63 positives) for the paired head-vs-DMS AUROC claim. Anchor: the observed device-cluster paired-$\Delta$ CI half-width is " | |
| r"0.088 pooled (0.142 manual on 31 positives, 0.115 engaged on 32); Hanley--McNeil positive-limited scaling half-width$(n_{\mathrm{pos}}) = 0.088\cdot\sqrt{63/n_{\mathrm{pos}}}$, " | |
| r"calibrated to the anchor (the uncalibrated formula with $A_{\mathrm{head}}$ 0.712, $A_{\mathrm{DMS}}$ 0.637 and between-score $r$ fitted to the anchor, $+0.335$, gives the same values). " | |
| r"A paired $\Delta$ is declarable when $|\Delta|$ exceeds the half-width (yes / no columns). New clips = labelled clips needed for the extra positives at a warranted share of 12.4\,\% (gold rate) or 25\,\% (active-strata expectation). " | |
| r"Upper block: the pre-planned $n_{\mathrm{pos}}$ grid; lower block: the smallest $n_{\mathrm{pos}}$ that declares each $\Delta$. Reading of the source: today's pooled $+0.075$ (HGB current-state head vs DMS att@3\,s) " | |
| r"needs $n_{\mathrm{pos}} \geq 87$; $+0.05$ needs $\geq 196$; the engaged stratum alone (32 positives, half-width 0.115) cannot declare anything below $\approx 0.11$ without new engaged positives. " | |
| + (r"The primary claim stays on the 509-row gold; the pre-registered human-evaluation programme was not executed by submission and has no result (round 7a, 2026-09-18). " | |
| if _iclr() else r"The primary claim stays on the 509-row gold; the human-evaluation round is in progress and has no result yet. ") | |
| + | |
| f"Source: \\texttt{{{rel(pg)}}} (anchor line {la}; table line {l}; reading line {lr}).") | |
| return emit("tab_app_power", cap, [f"{pg} : power table (line {l}); anchor (line {la}); reading (line {lr})"], | |
| [(None, "r r r c r c c c c r r l", hdr, body)]) | |
| # ---------------------------------------------------------------------------------------------- | |
| # Appendix — identity-invariant driver trunks (killed arms) | |
| # ---------------------------------------------------------------------------------------------- | |
| def tab_app_identity() -> pathlib.Path: | |
| idn = SRC["identity"] | |
| h0, r0, l0 = first_table(idn, "0. Validation chain NLL") | |
| h1, r1, l1 = first_table(idn, "1. Same-route twin") | |
| h2, r2, l2 = first_table(idn, "2. Identity probe") | |
| h3, r3, l3 = first_table(idn, "3. K4 driver cells") | |
| _, lsel = find_line(idn, "lambda-adv selected") | |
| _, lv1 = find_line(idn, "- **adv01**") | |
| _, lv3 = find_line(idn, "- **devnorm**") | |
| arm_label = {"adv01": "u\\_adv: gradient-reversal device head, $\\lambda{=}0.1$", "adv03": "u\\_adv: gradient-reversal device head, $\\lambda{=}0.3$", | |
| "devnorm": "u\\_devnorm: causal per-route normalisation", "baseline (ln)": "survivor baseline (clip~8 + input LN)"} | |
| # block 0: validation NLL (selection) | |
| hdr0 = ["Arm", "val chain NLL s0", "s1", "s2", "mean"] | |
| body0 = [row(arm_label.get(r[0], tx(r[0])), *[tx(c) for c in r[1:5]]) for r in r0] | |
| # block 1: identity probe | |
| hdr2 = ["Arm", "Regime", "Device top-1 (arm)", "top-1 (baseline)", "Majority rate", "arm $-$ majority", "verdict ($\\leq 0.05$)"] | |
| body2 = [row(tx(r[0]), tx(r[1]), tx(r[2]), tx(r[3]), tx(r[4]), tx(r[5]), vd(r[6])) for r in r2] | |
| # block 2: twin gap + K4 cells | |
| K = {(r[0], r[1], r[2], r[3]): r for r in r3} | |
| hdr1 = ["Regime", "Event", "Twin gap (arm)", "Twin gap (baseline)", "$\\Delta$ twin AUROC (arm $-$ base)", "K4 all rows: arm", "baseline", "verdict", "vs k0", | |
| "K4 masked: verdict", "vs k0"] | |
| body1 = [] | |
| for arm in ["adv01", "adv03", "devnorm"]: | |
| body1.append(group(11, arm_label[arm])) | |
| for r in r1: | |
| if r[0] != arm: | |
| continue | |
| regime, ev = r[1], r[2] | |
| a, m = K[(arm, "all rows", regime, ev)], K[(arm, "masked", regime, ev)] | |
| body1.append(row(tx(regime), cell_name(ev), tx(r[col(h1, "gap A")]), tx(r[col(h1, "gap B")]), vd(r[col(h1, "verdict")]), | |
| tx(a[4]), tx(a[5]), vd(a[7]), vd(a[9]), vd(m[7]), vd(m[9]))) | |
| cap = (r"Appendix (negative result): identity-invariant driver trunks vs the survivor baseline \texttt{U0\_kin\_can\_noK} (causal v2 inputs, stats v2, clip~8, input LN; 3 seeds). " | |
| r"Pre-stated kill rule: adopt an arm only if the twin gap (random-negative minus same-route-twin pair-AUROC@3\,s) is $\leq 0.10$ AND the device top-1 of a linear probe on the frozen 128-d GRU state is within 0.05 of the majority rate AND no K4 cell is WORSE vs the baseline. " | |
| r"Top: validation chain NLL (selection objective; $\lambda_{\mathrm{adv}}$ chosen here, never on test: adv03, mean 0.1572 vs adv01 0.1578). Middle: identity probe (train rows, GroupKFold by route). " | |
| r"Bottom: twin gap per arm (bold columns of the source) with the verdict of the paired twin-AUROC difference, and the K4 driver-onset PR-AUC@3\,s cells on the causal v2 targets (all rows and the 64 suspect routes masked) against the baseline and the k0 heuristic. " | |
| + LEGEND + | |
| r"Source verdicts: all three arms \textbf{KILL (not adopted)} --- maximal twin gaps 0.141 / 0.138 / 0.126 (baseline 0.161, rule $\leq 0.10$); identity top-1 $-$ majority $+0.354$ / $+0.593$ (adv01), $+0.359$ / $+0.607$ (adv03), $+0.048$ / $+0.092$ (devnorm) vs baseline $+0.355$ / $+0.592$; every arm is significantly worse on all twelve K4 cells. " | |
| f"Source: \\texttt{{{rel(idn)}}} \\S{{}}0 (line {l0}; selection line {lsel}), \\S{{}}1 (line {l1}), \\S{{}}2 (line {l2}), \\S{{}}3 (line {l3}), \\S{{}}4 verdicts (lines {lv1}--{lv3}).") | |
| return emit("tab_app_identity", cap, | |
| [f"{idn} : §0 validation chain NLL (line {l0}); selection line {lsel}", f"{idn} : §1 twin gaps (line {l1})", f"{idn} : §2 identity probe (line {l2})", | |
| f"{idn} : §3 K4 driver cells (line {l3})", f"{idn} : §4 verdicts (lines {lv1}–{lv3})"], | |
| [("Validation chain NLL (selection)", "l r r r r", hdr0, body0), | |
| ("Identity probe: device top-1 from the frozen GRU state", "l l r r r r l", hdr2, body2), | |
| ("Twin gap and K4 driver cells (arm vs baseline)", "l l r r l r r l l l l", hdr1, body1)], colsep="2.5pt") | |
| # ---------------------------------------------------------------------------------------------- | |
| # AIDE — zero-parameter analytic baselines (companion of the All-vs-HM Pareto figure) | |
| # ---------------------------------------------------------------------------------------------- | |
| def tab_aide_analytic() -> pathlib.Path: | |
| an = SRC["analytic"] | |
| ls = lines_of(an) | |
| tabs = md_tables(ls) | |
| h, rows, k = tabs[0] | |
| hp, pub, kp = tabs[1] | |
| labels = {"zero_velocity": "zero velocity (ZV): copy the last observed pose", | |
| "const_vel_a1.0": "constant velocity, $a{=}1.0$", "const_vel_a0.5": "constant velocity, $a{=}0.5$", "const_vel_a0.25": "constant velocity, $a{=}0.25$", | |
| "anti_velocity_0.1": "anti-velocity, 0.1", "mean_obs": "mean of the observed poses", "per_part_copy": "per-part copy", | |
| "zv_shrink_val": "ZV shrunk towards the observed mean ($a$ fitted on val)", | |
| "mean_pose_shrink_a0.1": "last pose shrunk towards the train mean pose, $a{=}0.1$", | |
| "mean_pose_shrink_a0.2": "last pose shrunk towards the train mean pose, $a{=}0.2$", | |
| "mean_pose_shrink_a0.3": "last pose shrunk towards the train mean pose, $a{=}0.3$", | |
| "zv_shrink_h_val": "ZV shrunk, horizon-scaled $\\alpha_h{=}a\\cdot h/5$ ($a$ fitted on val All)"} | |
| hdr1 = ["Analytic rule (zero parameters)", "All-MPJPE [95\\% CI]", "d-n", "HM-MPJPE [95\\% CI]", "HM d-n", "PCK@0.05", "PCK@0.10", "$h{=}1$", "$h{=}5$", "HM $h{=}5$"] | |
| body1 = [row(labels.get(r[0], tx(r[0])), *[tx(c) for c in r[1:10]]) for r in rows] | |
| body1.append(r"\midrule") | |
| body1.append(group(10, "Published (Driver-WM Table~1, typed from the paper)")) | |
| for r in pub: | |
| body1.append(row(tx(r[0]), tx(r[1]), tx(r[2]), tx(r[3]), tx(r[4]), tx(r[5]), "--", "--", "--", tx(r[6]))) | |
| hdr2 = ["Analytic rule", "$\\Delta$ vs ZV, All [95\\% CI]", "$\\Delta$ vs ZV, HM [95\\% CI]"] | |
| body2 = [row(labels.get(r[0], tx(r[0])), tx(r[10]), tx(r[11])) for r in rows] | |
| cap = (r"AIDE zero-parameter analytic baselines on the official test split ($n{=}609$; locked protocol: driver \texttt{first}, grid \texttt{floor}, HM = top~60 clips by mean displacement over 4 future transitions, threshold 72.05\,px; PCK threshold $t\cdot\max(W,H)$ = 96\,px @0.05). " | |
| r"95\,\% CIs = clip-level bootstrap (10000 resamples); $\Delta$ vs ZV = paired per-clip difference to zero velocity (negative = better). " | |
| r"The shrinkage rows move the last observed pose towards the TRAIN-split mean pose (fixed $a$, a priori) or towards the observed mean; \texttt{zv\_shrink\_h\_val} scales the shrinkage with the horizon and fits $a$ on validation All only. " | |
| r"These rows bound what a learned model must beat and trace the All-vs-HM trade-off of Fig.~\ref{fig:pareto_all_vs_hm}; none is a learned model. " | |
| f"Source: \\texttt{{{rel(an)}}} (table line {k + 1}; published rows line {kp + 1}).") | |
| return emit("tab_aide_analytic", cap, [f"{an} : analytic rows (table line {k + 1}); published rows (line {kp + 1})"], | |
| [("Levels", "p{0.28\\linewidth} l r l r r r r r r", hdr1, body1), | |
| ("Paired difference to zero velocity", "p{0.28\\linewidth} l l", hdr2, body2)]) | |
| # ---------------------------------------------------------------------------------------------- | |
| # Curated negative-results summary (one line per negative result; every number verbatim from the named table) | |
| # ---------------------------------------------------------------------------------------------- | |
| NEGATIVES: list[tuple[str, str, str]] = [ | |
| # (result, source table + section, verdict) | |
| ("Road→driver cross-attention: dropping it (all_minus_road2drv − all) is worse nowhere and better on engaged hand_leave (+0.0250 ± 0.0035); the road→driver path is not in the main model", | |
| "results/tables/stage_final.md §1 all_minus_road2drv vs all (verdict line 518)", "no gain from road→driver (PASS for dropping it)"), | |
| ("B2 cross-leg effect of the directed interactions: better on 1 of 8 cross-leg cells (manual C1 given k PR-AUC +0.0090 ± 0.0014); every engaged cross-leg cell INCONCLUSIVE", | |
| "results/tables/stage_final.md §1 B2 main comparison (verdict line 191)", "B2 PASS on own endpoints; cross-leg effect marginal"), | |
| ("Predicted-future features for warning: both − current −0.023 (0/3 CIs excl. 0) and future − current −0.006 (0/3) under out-of-fold features; in-sample engaged both − current −0.078 (2/3, negative)", | |
| "results/tables/warning_head_final_oof.md regime report §3 (both_minus_cur_OOF, fut_minus_cur_OOF, both_minus_cur_insample)", "no effect by the pre-registered rule; no positive effect in any stratum"), | |
| ("B3 chunked 1 s-step decoder vs parameter-matched fresh direct decoder: worse on manual hazard NLL gas_on (+0.0127 ± 0.0072) and steer_phase_on (+0.0042 ± 0.0011), manual aEgo CRPS (+0.0018 ± 0.0009) and MAE (+0.0024 ± 0.0005); better only on manual D badas", | |
| "results/tables/stage_F.md Claim B3 verdict (line 164) and main comparison", "FAIL → direct 25-step decoder kept"), | |
| ("RSSM stochastic latent rollout vs fresh direct heads: worse on manual hazard NLL D_ttc and steer_phase_on; vs the frozen main model: worse on 21 cells incl. manual brake (−0.0359 ± 0.0019), gas (−0.0704 ± 0.0065), steer phase (−0.0066 ± 0.0053) onset", | |
| "results/tables/stage_F_rssm.md primary verdict (line 178), secondary verdict (line 342)", "FAIL (both pairs); no world-model claim (kill_report_final.md K1 NOT_CLAIMED)"), | |
| ("B4 learned warning head vs the model's own label-free composition W_direct (0.550 ± 0.008) and the cwm2 composition (0.545 ± 0.011): pre-registered CV-selected head 0.652 ± 0.009 in-sample / 0.652 ± 0.034 out-of-fold; own W_direct INCONCLUSIVE", | |
| "results/tables/warning_head_final.md §5 (line 1031); warning_head_final_oof.md §5 (line 1008)", "FAIL"), | |
| ("B5 learned warning head vs the openpilot DMS attention chain (0.637 ± 0.007): mean Δ +0.015 (in-sample CV-selected head), +0.016 (out-of-fold CV-selected head, regime report §2; the OOF §5 verdict line quotes +0.032 = the HGB current+future OOF column); post-hoc HGB current-state +0.054 with 0/3 CIs excl. 0", | |
| "results/tables/warning_head_final.md §5 (line 1032); warning_head_final_oof.md §5 (line 1009) and regime report §2 (line 1046); kill_report_final.md K10", "INCONCLUSIVE — matches, does not exceed"), | |
| ("Engaged regime: every learned head is below the DMS attention chain in the engaged stratum (0.746): HGB current-state −0.083 (0/3), in-sample HGB current+future −0.162 (3/3 CIs excl. 0)", | |
| "results/tables/warning_head_final_oof.md regime report §1–§2", "worse (in-sample both) / INCONCLUSIVE (current-state)"), | |
| ("B1 driver cells vs the k0 current-state heuristic (final model, all rows): 4/6 cells better; engaged hand_return (0.682 ± 0.010 vs 0.621) and head_turn (0.258 ± 0.005 vs 0.238) INCONCLUSIVE; masked protocol identical (4/6)", | |
| "results/tables/stage_final.md §3 B1 (lines 530–580); k4_v2_summary.md Verdicts (line 148)", "FAIL (strict 6/6 and report_joint rule)"), | |
| ("K7 demand chains vs the cwm2 current-signal rule S0: below on decel (0.142 vs 0.314), ttc (0.188 vs 0.374) and lane (0.125 vs 0.286) in manual and on the same three families in engaged", | |
| "results/tables/kill_report_final.md K7 detail (lines 53–66)", "FLAG — learned D heads lose on state-threshold families"), | |
| ("Road-pressure head P vs the current-margin rule: worse on ttc (manual 0.181 vs 0.387; engaged 0.111 vs 0.232) and lane_excursion (manual 0.060 vs 0.203; engaged 0.038 vs 0.140); better on ttc_drop, cut_in, badas (manual) and cut_in (engaged)", | |
| "results/tables/exp3_P.md (a) and Verdicts (line 95)", "mixed: WORSE on the two state-threshold families"), | |
| ("Spatial road stream (regionpca256_P − pooled_P): P cells better none / worse none; its D / F cells worse on manual D steer_rate and on F cosine at every horizon in both regimes", | |
| "results/tables/exp3_P.md (c) and Verdicts (line 98)", "pooled road latent kept"), | |
| ("Full-frame cabin latent added to the driver branch (kin_can_vc, seed 0, descriptive; seed 1 same direction, head_turn −0.02 / −0.01 vs kin_can): head_turn 0.410 vs 0.453 (manual) and 0.237 vs 0.304 (engaged); training loss collapsed to 0.0076 while validation loss rose to 0.444 (memorisation)", | |
| "docs/decisions.md 2026-09-10 rows `U0_kin_can_vc_s0` / `_s1` (hand-written summaries; no paired verdict)", "not adopted"), | |
| ("DMS weak-teacher pretraining of the driver trunk: engaged hand_leave Δ −0.0284 / −0.0296 / −0.0124 (0/3 seeds ≥ +0.02), head_turn −0.0009 / +0.0001 / −0.0001", | |
| "results/tables/dms_teacher_pretrain.md §3 acceptance gate (lines 63–69)", "FAIL / not met"), | |
| ("AIDE → BATON transfer of the driver trunk (C1): engaged hand_leave Δ +0.018 / +0.002 / +0.000, head_turn −0.008 / −0.013 / −0.001 (0/3 seeds ≥ +0.02; INCONCLUSIVE)", | |
| "results/tables/c1_transfer.md §4 (lines 39–45)", "FAIL — no transfer"), | |
| ("BATON → AIDE in-cabin pose pretraining, full initialisation (trunk + head): Δ All −0.31 ± 0.02 px with every seed CI covering 0 (CWM3-D-kp); vis+sem −0.10 ± 0.25 — pre-registered rule not met. (The trunk-only, zero-init-head replication with an independent pretraining seed did pass: Δ All −0.62 ± 0.17 BEATS, reported as a separate AIDE row; for vis+sem the trunk-only arm is INCONCLUSIVE)", | |
| "aide/results/tables/baton_pretrain.md §3 (line 39, kill rule line 53), §4 (line 73, line 87), §6 (line 125, line 139), §7 (line 173)", "full init INCONCLUSIVE → not adopted; trunk-only replication BEATS (positive, separate row)"), | |
| ("Gaze-chain features added to the warning head (cur+dwell+face+gaze − cur+dwell+face): pooled Δ −0.003 / −0.000 / −0.004 (0/3 CIs excl. 0); manual −0.010, engaged +0.012", | |
| "results/tables/warning_head_final_gaze.md regime report §3 (line 300)", "no effect by the pre-registered rule (gaze validation pending)"), | |
| ("AIDE Gate B(a), single geometry-selected checkpoint: best variant F1 67.6 / 73.1 / 91.4 / 69.9 vs thresholds 68.07 / 72.61 / 90.15 / 68.34 (DBR short)", | |
| "aide/results/tables/stage_bc.md Final AIDE verdict table (line 839)", "FAIL (3/4 heads); Gate B(b) dual selection PASS (4/4) at +1–2 px All"), | |
| ("AIDE Stage C long-horizon High-Motion: B2 main HM h=5 162.8 [119.4, 221.7] vs the paper's 155.82 (single run, no CI; n=60 clips, CI half-width ≈ ±51 px)", | |
| "aide/results/tables/stage_bc.md Final AIDE verdict table (line 841) and note", "FAIL vs paper; PASS vs our reproduction (194.3); not statistically resolvable"), | |
| ("Driver-WM reproduction gap: our port of the published architecture reaches All 130.86 ± 3.11 / HM 176.33 ± 3.29 vs the published 71.47 / 138.03 (semantics reproduce: F1 71.65 / 68.71 / 89.57 / 68.39)", | |
| "aide/results/tables/stage_bc.md §1 (line 50 vs line 56)", "geometry not reproduced; reported as a limitation"), | |
| ("AIDE hybrid (spatial attention before the tokenizer, 6.7 M): ΔHM vs same-seed CWM3-D-kp −2.79 [−5.09, −0.62] / −1.45 [−3.21, +0.16] / −1.49 [−3.09, +0.08] (CI excl. 0 on 1/3 seeds)", | |
| "aide/results/tables/stage_bc.md Final AIDE verdict table (last row)", "NOT adopted"), | |
| ("AIDE hardening arms killed on validation: motion weight 5 + horizon weights (val HM h=5 143.5 / 145.2 / 144.9 ≥ 144.5 on 2/3), motion oversampling k=2 (145.8 / 144.9 / 146.3), view-gate + ego-motion token A2 (val F1 76.57 / 77.97 / 76.62 < 78.2)", | |
| "aide/results/tables/stage_bc.md §8 (lines 862–869)", "KILLED (pre-registered rules)"), | |
| ("Equal-alert-load lead time: at the DMS chain's load the paired lead-time Δ is +0.23 [−1.28, +1.58] / +0.36 [−0.87, +1.59] / +0.35 [−1.23, +1.78] s (cur+dwell+face); at 10 alerts/h (DMS row at its achieved 16.4 / 14.7 alerts/h) pooled recall 0.016 vs DMS 0.021 and DMS earlier in engaged (3/3 seeds)", | |
| "results/tables/operating_points.md item final_ext_dwfc (verdict line 178; low10 rows lines 146–151, 158–160)", "EQUAL — no lead-time claim"), | |
| ("Device shortcut: same-route shifted-twin AUROC is 0.12 below random-pair AUROC in both the main and the independent arm (gains do not ride on identity, but the shortcut is present)", | |
| "results/tables/kill_report_final.md K5 (line 11) and K5 detail", "PASS for the claim; shortcut reported as a limitation"), | |
| ("A validation-screened variant of CWM3-D-kp (3-layer part trunk, joint-token stream without spatial mixing, lean shared read-out, onset-hazard gated anchor mixture; 2,666,906 params; every choice fixed on validation, MotionBERT-kp given the same validation budget → dropout 0.1): over 5 seeds Δ All vs CWM3-D-kp −0.19 ± 0.21 (1/5 CIs excl. 0), vs the val-tuned MotionBERT-kp −0.05 ± 0.36 (1/5, mixed sign); with BATON trunk pretraining on both sides −0.08 ± 0.14 (0/5) and +0.28 ± 0.16 (0/5); HM vs CWM3-D-kp −1.62 ± 1.36 (2/5)", | |
| "aide/results/tables/kv2_program.md §4 primary endpoints and adoption (last block, lines 1085–1103); §1 val screen; §3 MotionBERT-kp grid", "INCONCLUSIVE on all four pre-registered endpoints → NOT ADOPTED (no significant difference to CWM3-D-kp or to the val-tuned MotionBERT-kp); ablation family"), | |
| ] | |
| # owner presentation decision 2026-09-15 (see OMIT_ROWS_OWNER_20260915): in the ICLR output the K-v2 row carries no P2 clause (variant + | |
| # BATON trunk against the val-tuned MotionBERT-kp + BATON trunk) and its verdict counts only the reported endpoints; every number that | |
| # stays is unchanged. The IEEE draft row is untouched. Each anchor must be found (a stale anchor raises). | |
| _NEG_ICLR_EDITS = [("with BATON trunk pretraining on both sides −0.08 ± 0.14 (0/5) and +0.28 ± 0.16 (0/5)", | |
| "with BATON trunk pretraining on both sides (vs CWM3-D-kp) −0.08 ± 0.14 (0/5)"), | |
| ("INCONCLUSIVE on all four pre-registered endpoints", "INCONCLUSIVE on every reported pre-registered endpoint"), | |
| # owner decisions 2026-09-17 (docs/decisions.md row 443): item (3) -- the engaged hand_leave / hand_return cells leave the | |
| # paper (four driver cells: manual hand_leave / hand_return / head_turn, engaged head_turn); item (5) -- the paper's | |
| # MotionBERT is the released-weights baseline only, the architecture-family control (MotionBERT-kp) is archived. | |
| ("is worse nowhere and better on engaged hand_leave (+0.0250 ± 0.0035); the road→driver path", | |
| "is worse nowhere and better on none of the reported cells; the road→driver path"), | |
| ("4/6 cells better; engaged hand_return (0.682 ± 0.010 vs 0.621) and head_turn (0.258 ± 0.005 vs 0.238) INCONCLUSIVE; masked protocol identical (4/6)", | |
| "3/4 reported cells better; engaged head_turn (0.258 ± 0.005 vs 0.238) INCONCLUSIVE; masked protocol identical (3/4)"), | |
| ("engaged hand_leave Δ −0.0284 / −0.0296 / −0.0124 (0/3 seeds ≥ +0.02), head_turn −0.0009 / +0.0001 / −0.0001", | |
| "engaged head_turn Δ −0.0009 / +0.0001 / −0.0001 (0/3 seeds ≥ +0.02)"), | |
| ("engaged hand_leave Δ +0.018 / +0.002 / +0.000, head_turn −0.008 / −0.013 / −0.001 (0/3 seeds ≥ +0.02; INCONCLUSIVE)", | |
| "engaged head_turn Δ −0.008 / −0.013 / −0.001 (0/3 seeds ≥ +0.02; INCONCLUSIVE)"), | |
| ("every choice fixed on validation, MotionBERT-kp given the same validation budget → dropout 0.1): over 5 seeds", | |
| "every choice fixed on validation): over 5 seeds"), | |
| (", vs the val-tuned MotionBERT-kp −0.05 ± 0.36 (1/5, mixed sign); with BATON", "; with BATON"), | |
| ("; §1 val screen; §3 MotionBERT-kp grid", "; §1 val screen"), | |
| ("(no significant difference to CWM3-D-kp or to the val-tuned MotionBERT-kp)", "(no significant difference to CWM3-D-kp)")] | |
| def _negatives() -> list: | |
| if STYLE != "iclr": | |
| return NEGATIVES | |
| blob = "\n".join(c for r in NEGATIVES for c in r) | |
| for a, _ in _NEG_ICLR_EDITS: | |
| if a not in blob: | |
| raise ValueError(f"NEGATIVES: anchor of the owner-decision edit not found (stale row text): {a[:60]!r}") | |
| out = [] | |
| for r in NEGATIVES: | |
| cells = [] | |
| for c in r: | |
| for a, b in _NEG_ICLR_EDITS: | |
| c = c.replace(a, b) | |
| cells.append(c) | |
| out.append(tuple(cells)) | |
| return out | |
| def tab_negative_summary() -> pathlib.Path: | |
| hdr = ["Result (numbers verbatim from the source)", "Source table / section", "Verdict"] | |
| negs = _negatives() | |
| if _iclr(): # round 6 (owner decision 2026-09-18, row 509 (3b)): the AIDE -> BATON transfer (C1) leaves the paper and the supplement | |
| negs = [r for r in negs if not r[0].startswith("AIDE → BATON transfer of the driver trunk (C1)")] | |
| assert len(negs) == len(_negatives()) - 1, "NEGATIVES: the C1 row was not found for omission" | |
| body = [row(tx(a), r"\texttt{" + tx(b) + "}", tx(c)) for a, b, c in negs] | |
| cap = (r"Negative and null results, one line each (numbers copied verbatim from the named table; INCONCLUSIVE / NOT\_WORSE are reported as ``no significant difference'', never as a win; " | |
| r"pre-registered FAILs stay FAIL). Source files are relative to the \texttt{cwm3/} repository root.") | |
| return emit("tab_negative_summary", cap, ["curated list NEGATIVES in gen_tables.py; each row names its source table + section"], | |
| [(None, "p{0.56\\linewidth} p{0.27\\linewidth} p{0.13\\linewidth}", hdr, body)], size=r"\tiny") | |
| # ============================================================================================== | |
| # ICLR-only tables (compact main-text tables with significance marks, the user-study scaffold, the identifier map). | |
| # Emitted only with --style iclr; every number is read from the declared source table (verbatim strings). | |
| # ============================================================================================== | |
| def dmark(delta: str, verdict: str) -> str: | |
| """'+0.0300 ± 0.0019 (n=3, pos=…)' + 'BEATS' -> '+0.0300 $\\pm$ 0.0019\\,\\cmark'; WORSE -> \\xmark; INCONCLUSIVE / | |
| NOT_WORSE -> no mark (compact tables carry the verdict as a mark instead of a column).""" | |
| v = verdict.replace("**", "").strip().split(" ")[0] | |
| return tx(strip_n(delta)) + {"BEATS": r"\,\cmark", "WORSE": r"\,\xmark"}.get(v, "") | |
| def _status(verdict: str) -> str: | |
| v = verdict.replace("**", "").strip().split(" ")[0] | |
| return {"BEATS": "significant", "WORSE": "significant (worse)", "NOT_WORSE": "no difference"}.get(v, "inconclusive") | |
| _CI_RE = re.compile(r"\[\s*([-+]?\d+\.\d+)\s*,\s*([-+]?\d+\.\d+)\s*\]") | |
| def ci_excl(cells: list[str]) -> str: | |
| """Count of per-seed CIs '[lo,hi]' that exclude 0 (read from the source's CI brackets) -> 'k/n'.""" | |
| n = 0 | |
| for c in cells: | |
| m = _CI_RE.search(c) | |
| if not m: | |
| raise ValueError(f"no CI in {c!r}") | |
| lo, hi = float(m.group(1)), float(m.group(2)) | |
| n += int(lo > 0 or hi < 0) | |
| return f"{n}/{len(cells)}" | |
| def _f(s: str) -> float: | |
| return float(s.replace("**", "").strip().split(" ")[0]) | |
| # ---------------------------------------------------------------------------------------------- | |
| # Main table A — BATON interaction: CAN-only reference, independent branches, CockpitWM and the three paired deltas | |
| # ---------------------------------------------------------------------------------------------- | |
| _MAIN_ENDPOINTS = { | |
| "manual": [("veh_onset/steer_phase_on/3s", "steer phase"), ("veh_onset/gas_on/3s", "gas"), ("veh_onset/brake_on/3s", "brake"), | |
| ("d_onset/decel/3s", "decel (demand)"), ("drv_onset/hand_leave/3s", "hand leave"), | |
| ("drv_onset/hand_return/3s", "hand return"), ("drv_onset/head_turn_onset/3s", "head turn")], | |
| "engaged": [("veh_onset/steer_phase_on/3s", "steer phase"), ("veh_onset/gas_on/3s", "gas"), ("veh_onset/brake_on/3s", "brake"), | |
| ("drv_onset/hand_leave/3s", "hand leave"), ("drv_onset/hand_return/3s", "hand return"), | |
| ("drv_onset/head_turn_onset/3s", "head turn")], | |
| } | |
| _K3_EVENT = {"veh_onset/brake_on/3s": "brake_on", "veh_onset/gas_on/3s": "gas_on", "veh_onset/steer_phase_on/3s": "steer_phase_on"} | |
| # Owner experiment C (docs/decisions.md 2026-09-17T07:00:22Z part (C); outcome 11:39:46Z; verification 12:08:31Z): CockpitWM with a | |
| # Driver-WM-style Transformer U -- an adapted Driver-WM-style temporal encoder at its published width replacing ONLY the GRU driver trunk | |
| # (21,185,664 vs 56,832 U-trunk parameters; whole joint model 24,778,745 vs 3,649,913; same inputs; NOT parameter-matched), pretrained and | |
| # fine-tuned under the frozen recipe. Pre-registered placement: the four reported driver cells and the vehicle cells enter the main-text | |
| # interaction table REGARDLESS of direction as one paired Δ column (variant − CockpitWM); the road-demand row is not part of the registered | |
| # cell set and reads '--'. Lazy (ICLR style only; the IEEE draft never had the column): emitted only when the report exists. | |
| _UDW_PATH = BT / "stage_final_udwm.md" | |
| def _udwm_index(heading_prefix: str) -> tuple[dict, int]: | |
| """(regime, cell, metric) -> row of a compact stage_final_udwm.md table, its column map and the 1-based line of the table header.""" | |
| h, rows, ln = first_table(_UDW_PATH, heading_prefix) | |
| ci = {"regime": col(h, "regime"), "cell": col(h, "cell"), "metric": col(h, "metric"), "B": col(h, "B per seed"), | |
| "delta": col(h, "Δ mean ± sd"), "verdict": col(h, "verdict")} | |
| idx = {(r[ci["regime"]], r[ci["cell"]], r[ci["metric"]].split(" ")[0]): r for r in rows} | |
| return {"idx": idx, "ci": ci}, ln | |
| def _baton_interaction_visual(name: str) -> pathlib.Path: | |
| """Rows of the interaction table on the visual-only environment-input configuration (the frozen original main model). Round 4 | |
| (owner decision 2026-09-17T16:24:02Z): emitted twice -- as tab_main_baton_interaction (byte-identical to the round-3 output; no | |
| longer \\input by the manuscript) and as tab_supp_baton_interaction_visual (same rows, supplement caption naming the configuration).""" | |
| sf, ab, kill = SRC["stage_final"], SRC["stage_final_ablations"], SRC["kill"] | |
| main, l_main = paired_index(sf, "B2 main comparison (v2 causal kin targets): A = allminus, B = indep") | |
| road, l_road = paired_index(sf, "B2 secondary comparison (v2 causal kin targets): A = all, B = indep") | |
| naive, l_naive = paired_index(ab, "Secondary comparison: A = naivefresh, B = indep") | |
| indep, l_indep = paired_index(ab, "Secondary comparison: A = indep, B = indepnoP") | |
| hK, rK, lK = first_table(kill, "K3 detail") | |
| can = {(r[col(hK, "regime")], r[col(hK, "event")]): r[col(hK, "can_only mean")] for r in rK} | |
| hdr = [["Endpoint", "CAN-only", "Indep.", r"\cwname", r"$\Delta$ \cwname", r"$\Delta$ all three paths", r"$\Delta$ scratch fusion"], | |
| ["", "(earlier system)", "(seed 0)", "(seed 0)", r"$-$ indep.", r"$-$ indep.", r"$-$ indep."]] | |
| udw = _iclr() and _UDW_PATH.exists() # owner experiment C column (pre-registered placement regardless of direction) | |
| if udw: | |
| udrv, l_udrv = _udwm_index("Driver cells — TEST (a)") | |
| uveh, l_uveh = _udwm_index("Vehicle cells — TEST (a)") | |
| uidx, uci = {**udrv["idx"], **uveh["idx"]}, udrv["ci"] | |
| hdr[0].append(r"$\Delta$ Transformer U") | |
| hdr[1].append(r"$-$ \cwname") | |
| ncol = 8 if udw else 7 | |
| body: list[str] = [] | |
| def d(tab, key): | |
| r, ci = tab["idx"][key], tab["ci"] | |
| return dmark(r[ci["mean Δ ± sd"]], r[ci["verdict"]]) | |
| for regime, title in [("manual", "Manual driving"), ("engaged", "Assistance engaged")]: | |
| body.append(group(ncol, title)) | |
| for cell, label in _MAIN_ENDPOINTS[regime]: | |
| if omitted_cell(regime, cell): # owner decision 2026-09-17 item 3 (ICLR): engaged hand_leave / hand_return leave the table | |
| continue | |
| key = (regime, cell, "pr_auc") | |
| rm, cm = main["idx"][key], main["ci"] | |
| ri, ci_ = indep["idx"][key], indep["ci"] | |
| # guard: the indep level (A side of the indep-vs-indepnoP table) must reproduce Δ s0 of the main comparison | |
| if abs((_f(rm[cm["A s0"]]) - _f(ri[ci_["A s0"]])) - _f(rm[cm["Δ s0 [CI]"]])) > 1.5e-4: | |
| raise ValueError(f"indep level inconsistent with the paired Δ for {key}") | |
| c = can.get((regime, _K3_EVENT.get(cell, "")), "--") | |
| cells_ = [label, tx(c), tx(ri[ci_["A s0"]]), tx(rm[cm["A s0"]]), d(main, key), d(road, key), d(naive, key)] | |
| if udw: | |
| ru = uidx.get(key) | |
| if ru is None: # the road-demand row is not part of the pre-registered cell set (driver + vehicle cells) | |
| cells_.append("--") | |
| else: | |
| # guard: the frozen-main side (B) of the udwm comparison must reproduce the per-seed CockpitWM levels of the main comparison | |
| if [t.strip() for t in ru[uci["B"]].split("/")] != [rm[cm[k]].strip() for k in ["A s0", "A s1", "A s2"]]: | |
| raise ValueError(f"udwm B levels inconsistent with the CockpitWM levels for {key}") | |
| cells_.append(dmark(ru[uci["delta"]], ru[uci["verdict"]])) | |
| body.append(row(*cells_)) | |
| cap = (r"BATON test split, PR-AUC of onset within 3\,s, 3 seeds. Levels: seed 0 (per-seed levels in the sources); $\Delta$ columns: mean $\pm$ sd over seeds of the paired " | |
| r"device-cluster bootstrap difference to the independent branches for the main model (all\_minus\_road2drv), for adding the road$\rightarrow$driver path (all) and for the from-scratch fusion (naivefresh). " | |
| r"\cmark\ / \xmark\ = BEATS / WORSE by kill\_checks.beats. CAN-only = cwm2 can\_only\_direct (mean $\pm$ sd, 3 seeds, K3 block). Hazard-NLL rows are left to the text. " | |
| f"Sources: stage\\_final.md tables at lines {l_main}, {l_road}; stage\\_final\\_ablations.md tables at lines {l_indep}, {l_naive}; kill\\_report\\_final.md K3 detail line {lK}.") | |
| srcs = [f"{sf} : §1 B2 main comparison allminus vs indep (table line {l_main}; A s0 = CockpitWM level, mean Δ ± sd, verdict)", | |
| f"{sf} : §1 B2 secondary comparison all vs indep (table line {l_road})", | |
| f"{ab} : secondary comparison indep vs indepnoP (table line {l_indep}; A s0 = independent-branches level)", | |
| f"{ab} : secondary comparison naivefresh vs indep (table line {l_naive})", | |
| f"{kill} : K3 detail, can_only mean ± sd (table line {lK})"] | |
| if udw: | |
| cap += (r" Last column (owner experiment C, pre-registered placement regardless of direction): \cwname\ with a Driver-WM-style Transformer U, an adapted " | |
| r"Driver-WM-style temporal encoder at its published width replacing only the GRU driver trunk (21,185,664 vs 56,832 U-trunk parameters; whole joint model " | |
| r"24,778,745 vs 3,649,913; same inputs; not parameter-matched), pretrained and fine-tuned under the frozen recipe, minus \cwname\ (mean $\pm$ sd over seeds, " | |
| f"same marks); the road-demand row is not part of the registered cell set. Source: stage\\_final\\_udwm.md tables at lines {l_udrv}, {l_uveh}.") | |
| srcs.append(f"{_UDW_PATH} : §1 (a) udwm main vs frozen main, TEST: driver cells (table line {l_udrv}) and vehicle cells (table line {l_uveh}); Δ mean ± sd, verdict") | |
| return emit(name, cap, srcs, [(None, "l r r r r r r" + (" r" if udw else ""), hdr, body)]) | |
| def tab_main_baton_interaction() -> pathlib.Path: | |
| return _baton_interaction_visual("tab_main_baton_interaction") | |
| def tab_supp_baton_interaction_visual() -> pathlib.Path: | |
| """Round 4: the visual-only environment-input configuration table for Supp. D (input ablation); rows identical to tab_main_baton_interaction.""" | |
| return _baton_interaction_visual("tab_supp_baton_interaction_visual") | |
| # ---------------------------------------------------------------------------------------------- | |
| # Main table B — AIDE geometry and semantics against the published Driver-WM numbers | |
| # ---------------------------------------------------------------------------------------------- | |
| def tab_main_aide() -> pathlib.Path: | |
| bc, aa = SRC["stage_bc"], SRC["arch_attribution"] | |
| h1, ours, l1 = first_table(bc, "1. Test headline") | |
| h1b, pub, l1b = first_table(bc, "1b.") | |
| # architecture attribution (arch_attribution.md, owner-approved 2026-09-14): Driver-WM-kp as a paired-Δ row (§2.1 mean Δ ± sd to K; | |
| # the file holds no 3-seed level means for it) and the 5-seed mean of K (§3.1) as a separately labelled row. | |
| # Owner decision 2026-09-15: the re-instantiated generic encoders (MotionBERT-kp, ST-GCN-kp, SiMLPe-kp, incl. their 5-seed / pretrained / | |
| # val-tuned variants) do NOT appear in this main table; they are reported in full in tab_supp_arch_attribution, tab_supp_kv2 and | |
| # tab_supp_master_aide (supplement, Section D). | |
| h21, r21, l21 = first_table(aa, "2.1 Paired") | |
| a21 = {k: col(h21, k) for k in ["cell", "mean Δ ± sd"]} | |
| hrun, rrun, lrun = first_table(aa, "2. Driver-WM-kp") | |
| dwm_params = find_row(rrun, col(hrun, "run"), "driverwm_kp_s42")[col(hrun, "params")] | |
| h31, r31, l31 = first_table(aa, "3.1 Seed means") | |
| a31 = {k: col(h31, k) for k in ["model", "n", "All", "d-n", "HM", "PCK@0.05", "HM h=5"]} | |
| h14, r14, l14 = first_table(aa, "1.4 Gain") | |
| p14 = {"K": find_row(r14, col(h14, "model"), "K = CWM3-D-kp")[col(h14, "params")]} | |
| # Owner decision 2026-09-17T06:33:12Z (docs/decisions.md): the main-text MotionBERT comparison uses OUR faithful rerun — the released | |
| # MB_release weights fine-tuned on AIDE under both read-outs (aide/results/tables/motionbert_faithful.md §1 seed means, locked seeds | |
| # 42 / 123 / 456; Params = the §1 params column of the seed-42 run) — and the published single-run MotionBERT row (73.51) leaves this | |
| # table (it stays in tab_aide_geometry (Supp. A) and tab_supp_master_aide (Supp. D)). _mbf_rows / _xcol are the R2 helpers below. | |
| mbf = SRC.get("mb_faithful") | |
| if mbf is None or not mbf.exists(): | |
| raise FileNotFoundError("tab_main_aide: aide/results/tables/motionbert_faithful.md is required (owner decision 2026-09-17: faithful MotionBERT rows)") | |
| hmb, rmb, lmb = first_table(mbf, "1. Test levels per run") | |
| def mbrow(prefix: str, label: str) -> str: | |
| mean, seed = _mbf_rows(rmb, prefix, " — mean ± sd") | |
| return row(label, tx(seed[_xcol(hmb, "params")]), "released weights, 3 seeds", *[tx(mean[_xcol(hmb, k)]) for k in ["All", "d-n", "HM", "PCK@0.05", "HM h=5"]]) | |
| ci = {k: col(h1, k) for k in ["model", "All-MPJPE", "d-n", "HM-MPJPE", "PCK@0.05", "HM h=5", "F1 DBR", "F1 DER", "F1 TCR", "F1 VCR", "params"]} | |
| pi = {k: col(h1b, k) for k in ["row", "All", "d-n", "HM", "PCK@0.05", "HM h=5"]} | |
| geo = ["All-MPJPE", "d-n", "HM-MPJPE", "PCK@0.05", "HM h=5"] | |
| hdrG = ["Model", "Params", "Provenance", r"All$\downarrow$", r"d-n$\downarrow$", r"HM$\downarrow$", r"PCK@0.05$\uparrow$", r"HM $h{=}5\downarrow$"] | |
| # Owner item 2 (2026-09-15): the three-seed means of the published main model (Driver-WM v2 Table 8, seeds 42/123/456) next to the | |
| # single-run Table-1 row. Cells are the verbatim strings of driverwm_v2_audit.md §1.1 (second table = Table 8); HM h=5 is not in Table 8. | |
| v2 = SRC["v2_audit"] | |
| h8, r8, l8 = first_table(v2, "1.1 v2 tables typed verbatim", table_idx=1) | |
| c8 = {k: col(h8, k) for k in ["model", "All px", "All %", "HM px", "PCK@0.05", "DBR Acc / F1", "DER Acc / F1", "TCR Acc / F1", "VCR Acc / F1"]} | |
| t8 = find_row(r8, c8["model"], "Driver-WM main") | |
| if any(k not in h8 for k in ["PCK@0.10"]): | |
| raise ValueError("driverwm_v2_audit.md §1.1: Table 8 header changed") | |
| def t8_f1(cell: str) -> str: # '73.34±1.3 / 69.09±1.8' (Acc / F1) -> the F1 half | |
| parts = [p.strip() for p in cell.split(" / ")] | |
| if len(parts) != 2: | |
| raise ValueError(f"Table 8 Acc / F1 cell not parseable: {cell!r}") | |
| return tx(parts[1]) | |
| t8_label = "Driver-WM (main), three seeds, v2 Table 8" | |
| t8_geo = row(t8_label, "--", "paper, 3 seeds", tx(t8[c8["All px"]]), tx(t8[c8["All %"]]), tx(t8[c8["HM px"]]), tx(t8[c8["PCK@0.05"]]), "--") | |
| t8_sem = row(t8_label, "--", "--", *[t8_f1(t8[c8[k]]) for k in ["DBR Acc / F1", "DER Acc / F1", "TCR Acc / F1", "VCR Acc / F1"]], tx(t8[c8["All px"]])) | |
| def pubrow(prefix: str, label: str) -> str: | |
| r = find_row(pub, pi["row"], prefix) | |
| return row(label, "--", "paper, 1 run", *[tx(r[pi[k]]) for k in ["All", "d-n", "HM", "PCK@0.05", "HM h=5"]]) | |
| def ourrow(prefix: str, label: str, prov: str) -> str: | |
| r = find_row(ours, ci["model"], prefix) | |
| return row(label, tx(r[ci["params"]]), prov, *[tx(r[ci[k]]) for k in geo]) | |
| def seedrow(prefix: str, label: str, prov: str, params: str, n_expect: str) -> str: | |
| """§3.1 seed-mean row of arch_attribution.md (5 seeds 42/123/456/789/1011); fails if the n column is not the expected one.""" | |
| r = find_row(r31, a31["model"], prefix) | |
| if r[a31["n"]].strip() != n_expect: | |
| raise ValueError(f"arch_attribution.md §3.1 row {prefix!r}: n = {r[a31['n']]!r}, expected {n_expect}") | |
| return row(label, tx(params), prov, *[tx(r[a31[k]]) for k in ["All", "d-n", "HM", "PCK@0.05", "HM h=5"]]) | |
| def dwm_delta_row() -> str: | |
| """Driver-WM-kp: the §2.1 paired mean Δ ± sd (Driver-WM-kp − K) per geometry column (no level means exist in the source).""" | |
| cells = [tx(find_row(r21, a21["cell"], k)[a21["mean Δ ± sd"]]) for k in ["All-MPJPE", "d-n", "HM-MPJPE", "PCK@0.05", "HM h=5"]] | |
| return row(r"Driver-WM arch.\ on CWM3-D-kp tokens, $\Delta$ to CWM3-D-kp, 3 seeds", tx(dwm_params), "same tokens, paired", *cells) | |
| # Owner instruction 2026-09-17 (round 3): the architecture port also as a LEVEL row (seed mean ± sd, 3 seeds) next to its paired Δ rows. | |
| # All / d-n / HM / PCK@0.05 = master_aide.md §1 row "Driver-WM-kp (... n=3)" (verbatim strings); HM h=5 = driverwm_quantile_sweep.md §2 | |
| # (h=5 MPJPE per quantile, top-10 % column = the official HM subset). Lazy: emitted only when both reports exist. | |
| dwm_level, dwm_level_src = [], [] | |
| if _MA_PATH.exists() and _DQ_PATH.exists(): | |
| hma, rma, lma = first_table(_MA_PATH, "1. Master table") | |
| cma = {k: col(hma, k) for k in ["Model", "All MPJPE", "All d-nMPJPE", "HM MPJPE", "PCK@0.05"]} | |
| rl = find_row(rma, cma["Model"], "Driver-WM-kp (Driver-WM architecture on the keypoint part tokens, n=3)") | |
| hq5, rq5, lq5 = first_table(_DQ_PATH, "2. h=5 MPJPE") | |
| rq = _dq_row(rq5, hq5, "Driver-WM architecture on CockpitWM tokens") | |
| if rq[col(hq5, "seeds")].strip() != "3": | |
| raise ValueError("driverwm_quantile_sweep.md §2: the architecture-port row is not a 3-seed row") | |
| dwm_level = [row("Driver-WM architecture on CockpitWM tokens", tx(dwm_params), "same tokens, 3 seeds", | |
| *[tx(rl[cma[k]]) for k in ["All MPJPE", "All d-nMPJPE", "HM MPJPE", "PCK@0.05"]], tx(rq[col(hq5, "top 10 %")]))] | |
| dwm_level_src = [f"{_MA_PATH} : §1 master table, row Driver-WM-kp (n=3): All / d-n / HM / PCK@0.05 seed means ± sd (table line {lma})", | |
| f"{_DQ_PATH} : §2 h=5 MPJPE per quantile, architecture-port row, top-10 % column = HM h=5 (table line {lq5})"] | |
| # Owner decision 2026-09-15 (after the pretraining programme): the same architecture with the same BATON trunk pretraining on both sides, | |
| # pretrain_variants.md §3.3 (last block) paired mean Δ ± sd (Driver-WM architecture pretrained − CockpitWM pretrained, 3 seeds). | |
| pv_rows, pv_src, l33 = [], [], None | |
| if "pretrain_variants" in SRC: | |
| h33, r33, l33 = _pv_table(SRC["pretrain_variants"], "3. P2", "3.3 (ii)") | |
| pv_cells = [tx(_pv_cell(r33, h33, k, "mean Δ ± sd")) for k in ["All-MPJPE", "d-n", "HM-MPJPE", "PCK@0.05", "HM h=5"]] | |
| pv_rows = [row(r"Driver-WM arch.\ on CockpitWM tokens + BATON pretraining, $\Delta$ to CockpitWM + BATON pretraining, 3 seeds", tx(dwm_params), "pretrained, paired", *pv_cells)] | |
| pv_src = [f"{SRC['pretrain_variants']} : last block, §3.3 paired Δ Driver-WM architecture pretrained − CockpitWM pretrained (line {l33})"] | |
| # Owner item 3 (2026-09-15): the published rows are single RUNS (Tables 1--3); Table 8 of the same paper gives three seeds for the main model. | |
| # Owner item 9: every configuration row names its checkpoint ((a) geometry / (b) semantic), pretraining / heads and its seed set in words. | |
| bodyG = [group(8, "Published in the Driver-WM paper (Tables 1--3: single runs; Table 8: three seeds of the main model)"), | |
| pubrow("Zero-Velocity", "Zero velocity"), pubrow("Static pooling", "Static pooling"), | |
| # owner decision 2026-09-17: the published single-run MotionBERT row is not in the main table (tab_aide_geometry / tab_supp_master_aide keep it) | |
| pubrow("ST-GCN", "ST-GCN"), pubrow("Driver-WM main", "Driver-WM (main)"), t8_geo, | |
| r"\midrule", group(8, "Our harness, locked protocol (analytic rules; learned rows: 3 seeds, mean $\\pm$ sd)"), | |
| ourrow("zero-velocity", "Zero velocity", "analytic rule"), ourrow("ZV-shrink", r"ZV-shrink ($\alpha{=}0.44$)", "analytic, val-fit"), | |
| # owner decision 2026-09-17 (round 3, verbatim labels): the two Driver-WM ports as adjacent LEVEL rows; seeds in the provenance column | |
| ourrow("Driver-WM reproduction (C1)", "Driver-WM, our reimplementation (their formulation; does not reproduce the published numbers)", "published arch., 3 seeds"), | |
| *dwm_level, | |
| mbrow("(a) MotionBERT released weights, anchored residual read-out", "MotionBERT (released weights, fine-tuned), anchored read-out, 3 seeds"), | |
| mbrow("(b) MotionBERT released weights, absolute read-out (their formulation)", "MotionBERT (released weights, fine-tuned), absolute read-out (their formulation), 3 seeds"), | |
| dwm_delta_row(), *pv_rows, | |
| r"\midrule", group(8, "Ours"), | |
| ourrow("CWM3-D-kp (Stage A)", "CWM3-D-kp, 3 seeds (42 / 123 / 456)", "keypoints only"), | |
| seedrow("CWM3-D-kp (K)", "CWM3-D-kp, 5~seeds (42 / 123 / 456 / 789 / 1011)", "keypoints only", p14["K"], "5"), | |
| ourrow("CWM3-D vis+sem (B2 main)", "CWM3-D vis+sem, geometry checkpoint (a), 3 seeds", "kp + vision")] | |
| hdrF = ["Model", "Selection", "Params", r"DBR$\uparrow$", r"DER$\uparrow$", r"TCR$\uparrow$", r"VCR$\uparrow$", r"All$\downarrow$"] | |
| _NOPARAM = ("", "–", "-", "--", "—", "n/a", "N/A") | |
| def semrow(prefix: str, label: str, sel: str, params_row: str | None = None) -> str: | |
| """Params = the §1 params column verbatim; a (b)-checkpoint row of a dual selection carries no params cell in the source | |
| and inherits the count of its (a) row (same model, other checkpoint); '--' where the source has none (paper rows, ensemble).""" | |
| r = find_row(ours, ci["model"], prefix) | |
| p_ = r[ci["params"]].strip() | |
| if p_ in _NOPARAM and params_row: | |
| p_ = find_row(ours, ci["model"], params_row)[ci["params"]].strip() | |
| params = tx(p_) if p_ not in _NOPARAM else "--" | |
| return row(label, sel, params, *[tx(r[ci[k]]) for k in ["F1 DBR", "F1 DER", "F1 TCR", "F1 VCR", "All-MPJPE"]]) | |
| bodyF = [semrow("paper Driver-WM main (seed 42)", "Driver-WM (main), paper, 1 run (Table 1, seed 42)", "--"), t8_sem, | |
| semrow("DER (i) attn heads + learned view gate — (a)", "CWM3-D vis+sem, view-gate heads, geometry checkpoint (a), 3 seeds", "geometry"), | |
| semrow("DER (i) attn heads + learned view gate — (b)", "CWM3-D vis+sem, view-gate heads, semantic checkpoint (b), 3 seeds", "macro-F1", | |
| params_row="DER (i) attn heads + learned view gate — (a)"), | |
| semrow("SEMANTIC-ONLY reference", "Frozen-feature semantic-only reference (no trunk), semantic checkpoint (b), 3 seeds", "macro-F1"), | |
| semrow("Hardening A3: logit ENSEMBLE", "Logit ensemble of the three semantic-checkpoint (b) seeds (not a single model)", "macro-F1")] | |
| cap = (r"AIDE test ($n{=}609$). Block 1: geometry (px; PCK in \%); published rows typed from the Driver-WM paper (1b table; Tables 1--3 are single runs, the Table 8 row is the three-seed mean $\pm$ sd of the main model), our rows = §1 seed means $\pm$ sd (3 seeds); " | |
| r"Params = the §1 params column verbatim. Block 2: semantic macro-F1 (observed window) with the All-MPJPE of the same checkpoint; selection (a) = validation geometry, (b) = validation F1; " | |
| r"Params (block 2) = §1 params column of the row (a (b) checkpoint row inherits the count of its (a) row, the same model; '--' where the source has none). " | |
| r"Architecture attribution rows (arch\_attribution.md): Driver-WM-kp = §2.1 paired mean $\Delta$ $\pm$ sd (Driver-WM-kp $-$ K, 3 seeds; positive = worse for errors); " | |
| r"'5 seeds' rows = §3.1 seed means over 42/123/456/789/1011; params from §1.4 / §2; " | |
| r"the '+ BATON pretraining' $\Delta$ row = pretrain\_variants.md §3.3 paired mean $\Delta$ $\pm$ sd (Driver-WM architecture pretrained $-$ CockpitWM pretrained, 3 seeds). " | |
| r"Faithful MotionBERT rows (owner decision 2026-09-17): the released MB\_release DSTformer weights fine-tuned on AIDE under our anchored (residual) read-out and under their absolute read-out, " | |
| r"locked seeds 42 / 123 / 456, motionbert\_faithful.md §1 seed means $\pm$ sd; Params = the §1 params column of the seed-42 run; the paper's single-run MotionBERT row (73.51) stays in the supplement (tab\_aide\_geometry, tab\_supp\_master\_aide). " | |
| r"'Driver-WM, our reimplementation (their formulation)' = our reimplementation of the published model under the locked protocol; it does not reproduce the published numbers (All 130.86 vs 71.47), so margins against it say nothing about Driver-WM as published. " | |
| r"'Driver-WM architecture on CockpitWM tokens' (levels, 3 seeds; owner decision 2026-09-17: both ports as adjacent level rows) = master\_aide.md §1 seed means $\pm$ sd (All, d-n, HM, PCK) and driverwm\_quantile\_sweep.md §2 top-10\,\% h=5 column (owner instruction 2026-09-17). " | |
| f"Sources: stage\\_bc.md §1 (line {l1}), §1b (line {l1b}); paper\\_rows.py; arch\\_attribution.md §2 (line {lrun}), §2.1 (line {l21}), §3.1 (line {l31}), §1.4 (line {l14}); driverwm\\_v2\\_audit.md §1.1 Table 8 (line {l8}); motionbert\\_faithful.md §1 (line {lmb})" | |
| + (f"; pretrain\\_variants.md §3.3 (line {l33})." if l33 else ".")) | |
| return emit("tab_main_aide", cap, | |
| [f"{bc} : §1 test headline (table line {l1})", f"{bc} : §1b published Driver-WM table (line {l1b})", | |
| f"{SRC['paper_rows']} : published rows typed verbatim", | |
| f"{aa} : §2 run table (line {lrun}); §2.1 paired Δ Driver-WM-kp − K (line {l21}); §3.1 seed means (line {l31}); §1.4 params (line {l14})", | |
| f"{v2} : §1.1 v2 Table 8, three-seed means of the published main model (table line {l8})", | |
| f"{mbf} : §1 seed means ± sd of the faithful MotionBERT arms (a) anchored / (b) absolute read-out, params of the seed-42 rows (table line {lmb})", *pv_src, *dwm_level_src], | |
| [("Geometry (AIDE test, $n{=}609$)", "l r l r r r r r", hdrG, bodyG), | |
| ("Semantic macro-F1 (observed window)", "l l r r r r r", hdrF, bodyF)]) | |
| # ---------------------------------------------------------------------------------------------- | |
| # Supplement table — AIDE architecture attribution (arch_attribution.md; owner-approved fair experiments, rules fixed before the runs): | |
| # (A) matched BATON pretraining gains side by side (§1.4 + §1.1–1.3 cell tables), (B) Driver-WM-kp per-seed levels (§2 run table), | |
| # (C) paired Δ Driver-WM-kp − K (§2.1) and − MotionBERT-kp (§2.2), (D) 5-seed means (§3.1), (E) paired Δ K − MotionBERT-kp over 5 seeds (§3.2) | |
| # ---------------------------------------------------------------------------------------------- | |
| _AA_CELLS = ["All-MPJPE", "d-n", "HM-MPJPE", "PCK@0.05", "HM h=5"] | |
| def _aa_cell(rows: list[list[str]], header: list[str], cell: str, column: str) -> str: | |
| """One cell of an arch_attribution.md cell table (rows = metrics); raises KeyError when the row or column is missing.""" | |
| r = find_row(rows, col(header, "cell"), cell) | |
| v = r[col(header, column)].strip() | |
| if not v: | |
| raise ValueError(f"arch_attribution.md: empty cell {cell!r} / {column!r}") | |
| return v | |
| def tab_supp_arch_attribution() -> pathlib.Path: | |
| aa = SRC["arch_attribution"] | |
| # The former block "(A) Gain from matched BATON in-cabin pose pretraining" (arch_attribution.md §1.1-§1.4: MotionBERT-kp and ST-GCN-kp | |
| # + BATON trunk next to CWM3-D-kp) is NOT built: owner presentation decision 2026-09-15 (OMIT_ROWS_OWNER_20260915). The CockpitWM | |
| # pretraining gain stays in tab_main_transfer / tab_app_transfer. The remaining blocks are relabelled (A)-(D); cells unchanged. | |
| # (A) Driver-WM-kp per seed (§2 run table, driverwm_kp rows only) | |
| hrun, rrun, lrun = first_table(aa, "2. Driver-WM-kp") | |
| crun = {k: col(hrun, k) for k in ["seed", "run", "params", "GPU min", "All [CI]", "d-n [CI]", "HM [CI]", "PCK@0.05 [CI]", "HM h=5 [CI]"]} | |
| hdrB = ["Seed", "Params", "GPU min", "All [CI]", "d-n [CI]", "HM [CI]", "PCK@0.05 [CI]", r"HM $h{=}5$ [CI]"] | |
| bodyB = [] | |
| for seed in ["42", "123", "456"]: | |
| r = find_row(rrun, crun["run"], f"driverwm_kp_s{seed}_v2") | |
| if r[crun["seed"]].strip() != seed: | |
| raise ValueError(f"arch_attribution.md §2: seed column mismatch for driverwm_kp_s{seed}_v2") | |
| bodyB.append(row(seed, tx(r[crun["params"]]), tx(r[crun["GPU min"]]), | |
| *[tx(r[crun[k]]) for k in ["All [CI]", "d-n [CI]", "HM [CI]", "PCK@0.05 [CI]", "HM h=5 [CI]"]])) | |
| # (B) paired Δ per seed: §2.1 (− K) and §2.2 (− MotionBERT-kp) | |
| h21, r21, l21 = first_table(aa, "2.1 Paired") | |
| h22, r22, l22 = first_table(aa, "2.2 Paired") | |
| hdrC = ["Cell", r"$\Delta$ s42 [CI]", r"$\Delta$ s123 [CI]", r"$\Delta$ s456 [CI]", r"mean $\Delta$ $\pm$ sd", "verdict"] | |
| def rowsC(hdr, rows) -> list[str]: | |
| return [row(tx(cell), *[tx(_aa_cell(rows, hdr, cell, f"Δ s{s} [CI]")) for s in ["42", "123", "456"]], | |
| tx(_aa_cell(rows, hdr, cell, "mean Δ ± sd")), vd(_aa_cell(rows, hdr, cell, "verdict"))) for cell in _AA_CELLS] | |
| bodyC = [group(6, "Driver-WM-kp $-$ CWM3-D-kp (seed-matched)")] + rowsC(h21, r21) + \ | |
| [r"\midrule", group(6, "Driver-WM-kp $-$ MotionBERT-kp (seed-matched)")] + rowsC(h22, r22) | |
| # (C) 5-seed means (§3.1) | |
| h31, r31, l31 = first_table(aa, "3.1 Seed means") | |
| c31 = {k: col(h31, k) for k in ["model", "n", "All", "d-n", "HM", "PCK@0.05", "HM h=5"]} | |
| hdrD = ["Model", "Seeds", r"All$\downarrow$", r"d-n$\downarrow$", r"HM$\downarrow$", r"PCK@0.05$\uparrow$", r"HM $h{=}5\downarrow$"] | |
| def rowD(prefix: str, label: str, n_expect: str) -> str: | |
| r = find_row(r31, c31["model"], prefix) | |
| if r[c31["n"]].strip() != n_expect: | |
| raise ValueError(f"arch_attribution.md §3.1 row {prefix!r}: n = {r[c31['n']]!r}, expected {n_expect}") | |
| return row(label, tx(r[c31["n"]]), *[tx(r[c31[k]]) for k in ["All", "d-n", "HM", "PCK@0.05", "HM h=5"]]) | |
| bodyD = [rowD("CWM3-D-kp (K), locked", "CWM3-D-kp, locked seeds 42 / 123 / 456", "3"), rowD("CWM3-D-kp (K)", "CWM3-D-kp, five seeds", "5"), | |
| rowD("MotionBERT-kp, locked", "MotionBERT-kp, locked seeds 42 / 123 / 456", "3"), rowD("MotionBERT-kp", "MotionBERT-kp, five seeds", "5")] | |
| # (D) paired Δ K − MotionBERT-kp over 5 seeds (§3.2) | |
| h32, r32, l32 = first_table(aa, "3.2 Paired") | |
| seeds5 = ["42", "123", "456", "789", "1011"] | |
| hdrE = ["Cell"] + [rf"$\Delta$ s{s} [CI]" for s in seeds5] + [r"mean $\Delta$ $\pm$ sd", "verdict"] | |
| bodyE = [row(tx(cell), *[tx(_aa_cell(r32, h32, cell, f"Δ s{s} [CI]")) for s in seeds5], | |
| tx(_aa_cell(r32, h32, cell, "mean Δ ± sd")), vd(_aa_cell(r32, h32, cell, "verdict"))) for cell in _AA_CELLS] | |
| cap = (r"Appendix: AIDE architecture attribution (test, $n{=}609$; paired per-clip bootstrap, 10k; $\Delta$ negative = better for errors, positive = better for PCK; " | |
| r"verdicts as baton\_pretrain.md: BEATS / WORSE = CI excl.\ 0 on $\geq 2/3$ seeds ($\geq 4/5$ for five seeds) with the same sign; NOT\_WORSE = all CIs cover 0 and $|\Delta| < 0.25$; else INCONCLUSIVE). " | |
| r"(A) Driver-WM-kp (Driver-WM architecture on K's keypoint part tokens, shared recipe) per seed. (B) Paired $\Delta$ Driver-WM-kp $-$ K and $-$ MotionBERT-kp. " | |
| r"(C) Seed means. (D) Paired $\Delta$ K $-$ MotionBERT-kp over five seeds. The matched-pretraining block of arch\_attribution.md §1 is not reported (owner decision 2026-09-15). " + LEGEND + | |
| (f"Sources: arch\\_attribution.md §2 (line {lrun}), §2.1 (line {l21}), §3.1 (line {l31})." if _iclr() else # owner decision 2026-09-18: no pointer to the removed §2.2 / §3.2 blocks in the ICLR header | |
| f"Sources: arch\\_attribution.md §2 (line {lrun}), §2.1 (line {l21}), §2.2 (line {l22}), §3.1 (line {l31}), §3.2 (line {l32}).")) | |
| return emit("tab_supp_arch_attribution", cap, | |
| [f"{aa} : §2 per-seed run table (line {lrun}); §2.1 paired Δ − K (line {l21})" + ("" if _iclr() else f"; §2.2 paired Δ − MotionBERT-kp (line {l22})"), | |
| f"{aa} : §3.1 seed means (line {l31})" + ("" if _iclr() else f"; §3.2 paired Δ K − MotionBERT-kp, five seeds (line {l32})")], | |
| [("(A) Driver-WM architecture on CWM3-D-kp tokens, per seed (AIDE test, px; PCK in \\%)", "l r r l l l l l", hdrB, bodyB), | |
| ("(B) Paired per-seed differences of Driver-WM-kp (px; PCK in \\%)", "l l l l r l", hdrC, bodyC), | |
| ("(C) Seed means, locked three seeds and five seeds (mean $\\pm$ sd)", "l c r r r r r", hdrD, bodyD), | |
| ("(D) Paired per-seed differences CockpitWM-K $-$ MotionBERT-kp over five seeds", "l l l l l l r l", hdrE, bodyE)]) | |
| # ---------------------------------------------------------------------------------------------- | |
| # Supplement table — K-v2 programme (protocol C23): validation screen, five-seed test levels and paired Δ, secondary cells, | |
| # MotionBERT-kp validation grid. Every cell is parsed from the LAST block of aide/results/tables/kv2_program.md (append-only | |
| # report; each block starts with a '## 0. Pre-registration' heading and earlier blocks are never edited). | |
| # ---------------------------------------------------------------------------------------------- | |
| _KV2_STATUS = {"SURVIVE": "continued", "KILL": "stopped", "CONTINUE": "continued to five seeds", "KILLED": "stopped"} | |
| _KV2_COMPONENTS = {"full": "5", "q060": "5", "q090": "5", "lam03": "5", "nospatial": "4", "khead": "4", "hazaux": "4", "plain": "4", "nohaz": "3"} | |
| _KV2_SEEDS = ["42", "123", "456", "789", "1011"] | |
| def _kv2_last_block(ls: list[str]) -> int: | |
| starts = [i for i, l_ in enumerate(ls) if l_.startswith("## 0. Pre-registration")] | |
| if not starts: | |
| raise KeyError("kv2_program.md: no '## 0. Pre-registration' heading") | |
| return starts[-1] | |
| def _kv2_table(path: pathlib.Path, heading_prefix: str, *sub_prefixes: str, table_idx: int = 0): | |
| """(header, rows, absolute 1-based header line) of table `table_idx` in the section of the LAST block whose heading starts with | |
| `heading_prefix`, narrowed successively to the sub-sections `sub_prefixes` (so that the same '#### Δ = …' heading of a later | |
| configuration section is never picked up).""" | |
| ls = lines_of(path) | |
| sec, i0 = section(ls, heading_prefix, _kv2_last_block(ls)) | |
| for sp in sub_prefixes: | |
| sec, k = section(sec, sp) | |
| i0 += k | |
| header, rows, k = md_tables(sec)[table_idx] | |
| return header, rows, i0 + k + 1 | |
| def _kv2_levels(rows, header, side: str) -> list[str]: | |
| return [_aa_cell(rows, header, "All-MPJPE", f"{side} s{s}") for s in _KV2_SEEDS] | |
| def tab_supp_kv2() -> pathlib.Path: | |
| kv = SRC["kv2"] | |
| ls = lines_of(kv) | |
| # ---- (A) S1 validation screen (seed 42) and S1b (seed 123) | |
| h1, r1, l1 = _kv2_table(kv, "1. S1 val screen") | |
| c1 = {k: col(h1, k) for k in ["cfg", "flags", "params", "val All", "Δ val All", "guard", "S1 status"]} | |
| sec1, _ = section(ls, "1. S1 val screen", _kv2_last_block(ls)) | |
| rule = [l_ for l_ in sec1 if "full/q060/q090/lam03 = 5" in l_ and "nospatial/khead/hazaux/plain = 4" in l_ and "nohaz = 3" in l_] | |
| if not rule: | |
| raise ValueError("kv2_program.md §1: component-count rule line not found (the hard-coded _KV2_COMPONENTS could be stale)") | |
| hdrA = ["Config", "Flags", "Comp.", "Params", "val All", r"$\Delta$ val All [CI]", "Two-seed mean", "Decision"] | |
| def flags(f: str) -> str: | |
| f = f.strip() | |
| if f == "(full)": | |
| return "(full design)" | |
| if f == "(default)": | |
| return "(default)" | |
| return "--" if f in ("—", "-", "") else r"\texttt{" + tx(f) + "}" | |
| bodyA = [group(8, "S1: nine configurations at seed 42 against CockpitWM-K seed 42 ($n{=}405$ validation clips); continued iff mean $\\Delta \\leq -0.30$ px, at most two")] | |
| params_of = {} | |
| for r in r1: | |
| cfg = r[c1["cfg"]].strip() | |
| params_of[cfg] = r[c1["params"]].strip() | |
| if cfg.startswith("K"): | |
| bodyA.append(row("CockpitWM-K (reference)", "--", "--", tx(r[c1["params"]]), tx(r[c1["val All"]]), "--", "--", "--")) | |
| continue | |
| dec = _KV2_STATUS[r[c1["S1 status"]].replace("**", "").strip()] | |
| if r[c1["guard"]].replace("**", "").strip() == "KILL": | |
| dec += " (also by the high-motion guard)" | |
| bodyA.append(row(tx(cfg), flags(r[c1["flags"]]), _KV2_COMPONENTS[cfg], tx(r[c1["params"]]), tx(r[c1["val All"]]), tx(r[c1["Δ val All"]]), "--", dec)) | |
| hb, rb, lb = _kv2_table(kv, "1. S1 val screen", "1.1 S1b") | |
| cb = {k: col(hb, k) for k in ["cfg", "val All", "Δ val All s123", "2-seed mean", "decision"]} | |
| bodyA += [r"\midrule", group(8, "S1b: survivors at seed 123 against CockpitWM-K seed 123; continued iff $\\Delta < 0$ and the two-seed mean $\\leq -0.25$ px")] | |
| for r in rb: | |
| cfg = r[cb["cfg"]].strip() | |
| bodyA.append(row(tx(cfg) + " (seed 123)", "--", _KV2_COMPONENTS[cfg], tx(params_of[cfg]), tx(r[cb["val All"]]), tx(r[cb["Δ val All s123"]]), | |
| tx(r[cb["2-seed mean"]]), _KV2_STATUS[r[cb["decision"]].replace("**", "").strip()])) | |
| # ---- (B) five-seed test levels and the four pre-registered paired differences (All-MPJPE) | |
| hA1, rA1, lA1 = _kv2_table(kv, "2. S2", "2.1 `nospatial`", "Δ = K-v2 − K") | |
| hA2, rA2, lA2 = _kv2_table(kv, "2. S2", "2.1 `nospatial`", "Δ = K-v2+pre − K+pre") | |
| hP1, rP1, lP1 = _kv2_table(kv, "2. S2", "2.1 `nospatial`", "Δ = K-v2 − MB-best") | |
| hP2, rP2, lP2 = _kv2_table(kv, "2. S2", "2.1 `nospatial`", "Δ = K-v2+pre − MB-best") | |
| lv_v2, lv_k = _kv2_levels(rA1, hA1, "A"), _kv2_levels(rA1, hA1, "B") | |
| lv_v2p, lv_kp = _kv2_levels(rA2, hA2, "A"), _kv2_levels(rA2, hA2, "B") | |
| lv_mb, lv_mbp = _kv2_levels(rP1, hP1, "B"), _kv2_levels(rP2, hP2, "B") | |
| if _kv2_levels(rP1, hP1, "A") != lv_v2 or _kv2_levels(rP2, hP2, "A") != lv_v2p: | |
| raise ValueError("kv2_program.md §2.1: K-v2 test levels differ between the − K and the − MB-best tables") | |
| hdrB = ["Model or difference"] + [f"s{s}" for s in _KV2_SEEDS] + [r"mean $\pm$ sd", "verdict"] | |
| def lrow(label: str, levels: list[str]) -> str: | |
| return row(label, *[tx(v) for v in levels], "--", "--") | |
| def drow(label: str, hdr, rows) -> str: | |
| return row(label, *[tx(_aa_cell(rows, hdr, "All-MPJPE", f"Δ s{s} [CI]")) for s in _KV2_SEEDS], | |
| tx(_aa_cell(rows, hdr, "All-MPJPE", "mean Δ ± sd")), vd(_aa_cell(rows, hdr, "All-MPJPE", "verdict"))) | |
| bodyB = [group(8, "Test All-MPJPE per seed (px; one evaluation per run); variant = the validation-screened CockpitWM variant"), | |
| lrow("Variant", lv_v2), lrow("CockpitWM", lv_k), lrow("MotionBERT-kp, validation-tuned (dropout 0.1)", lv_mb), | |
| lrow("Variant + BATON pretraining", lv_v2p), lrow("CockpitWM + BATON pretraining", lv_kp), lrow("MotionBERT-kp, validation-tuned + BATON pretraining", lv_mbp), | |
| r"\midrule", group(8, "Pre-registered paired per-clip differences of All-MPJPE, $\\Delta$ [CI] per seed (px)"), | |
| drow("Variant $-$ CockpitWM", hA1, rA1), drow("Variant $-$ MotionBERT-kp (tuned)", hP1, rP1), | |
| drow("Variant $-$ CockpitWM, both + BATON pretraining", hA2, rA2), drow("Variant $-$ MotionBERT-kp (tuned), both + BATON pretraining", hP2, rP2)] | |
| # owner presentation decision 2026-09-15 (OMIT_ROWS_OWNER_20260915): the MB-best + BATON trunk level row and the P2 endpoint are | |
| # built as before and dropped here; A1, P1 and A2 and every remaining cell are unchanged. | |
| bodyB = [r for r in bodyB if not omitted_row(r)] | |
| # ---- (C) secondary cells of the four pairs and the descriptive pairs of §3.1 (mean ± sd with verdict) | |
| hD1, rD1, lD1 = _kv2_table(kv, "3. S3", "3.1 MB-best", "Δ = K+pre − K") | |
| hD2, rD2, lD2 = _kv2_table(kv, "3. S3", "3.1 MB-best", "Δ = MB-best[do0.1]+pre − MB-best[do0.1]") | |
| hD3, rD3, lD3 = _kv2_table(kv, "3. S3", "3.1 MB-best", "Δ = K − MB-best[do0.1]") | |
| hD4, rD4, lD4 = _kv2_table(kv, "3. S3", "3.1 MB-best", "Δ = K+pre − MB-best[do0.1]+pre") | |
| hdrC = ["Difference (five seeds)", r"All$\downarrow$", r"d-n$\downarrow$", r"HM$\downarrow$", r"PCK@0.05$\uparrow$", r"HM $h{=}5\downarrow$"] | |
| def crow(label: str, hdr, rows) -> str: | |
| return row(label, *[tx(_aa_cell(rows, hdr, cell, "mean Δ ± sd")) + " (" + vd(_aa_cell(rows, hdr, cell, "verdict")) + ")" for cell in _AA_CELLS]) | |
| bodyC = [group(6, "Pre-registered pairs (secondary cells are descriptive, never an adoption basis); variant = the validation-screened CockpitWM variant"), | |
| crow("Variant $-$ CockpitWM", hA1, rA1), crow("Variant $-$ MotionBERT-kp (tuned)", hP1, rP1), | |
| crow("Variant $-$ CockpitWM, both + BATON pretraining", hA2, rA2), crow("Variant $-$ MotionBERT-kp (tuned), both + BATON pretraining", hP2, rP2), | |
| r"\midrule", group(6, "Descriptive pairs"), | |
| crow("CockpitWM + BATON pretraining $-$ CockpitWM", hD1, rD1), crow("MotionBERT-kp (tuned) + BATON pretraining $-$ MotionBERT-kp (tuned)", hD2, rD2), | |
| crow("CockpitWM $-$ MotionBERT-kp (tuned)", hD3, rD3), crow("CockpitWM $-$ MotionBERT-kp (tuned), both + BATON pretraining", hD4, rD4)] | |
| # owner presentation decision 2026-09-15 (OMIT_ROWS_OWNER_20260915): the P2 secondary cells and the two descriptive pairs that involve | |
| # MB-best + BATON trunk (§3.1 D2, D4) are dropped; the remaining rows are unchanged. | |
| bodyC = [r for r in bodyC if not omitted_row(r)] | |
| # ---- (D) MotionBERT-kp validation grid (S3) | |
| h3, r3, l3 = _kv2_table(kv, "3. S3") | |
| c3 = {k: col(h3, k) for k in ["cfg", "model", "flags", "params", "val All", "Δ val All vs default", "S3"]} | |
| hdrD = ["Config", "Model", "Flags", "Params", "val All", r"$\Delta$ val All vs default [CI]", "Selection"] | |
| bodyD = [group(7, "Ten validation points at seed 42 (nine new + the default); selected = lowest validation All-MPJPE, ties within 0.10 px to fewer parameters")] | |
| for r in r3: | |
| sel = "selected" if "MB-best" in r[c3["S3"]] else "--" | |
| bodyD.append(row(tx(r[c3["cfg"]]), r"\texttt{" + tx(r[c3["model"]]) + "}", flags(r[c3["flags"]]), tx(r[c3["params"]]), tx(r[c3["val All"]]), | |
| tx(r[c3["Δ val All vs default"]]), sel)) | |
| cap = (r"Appendix: K-v2 programme (protocol C23) on AIDE (validation $n{=}405$ for every selection; test $n{=}609$, one evaluation per run; paired per-clip bootstrap, 10k; " | |
| r"$\Delta$ negative = better for errors, positive for PCK; verdicts as arch\_attribution.md: BEATS / WORSE = CI excl.\ 0 on $\geq 4/5$ seeds with the same sign; " | |
| r"NOT\_WORSE = all CIs cover 0 and $|\Delta| < 0.25$; else INCONCLUSIVE). (A) S1 validation screen at seed 42 and S1b at seed 123. (B) Five-seed test levels and the " | |
| r"pre-registered paired differences A1 / P1 (without pretraining) and A2 (BATON trunk-only pretraining on both sides)" + | |
| ((r". (C) Secondary cells and the descriptive pairs of \S{}3.1. " + LEGEND + # owner decision 2026-09-18: ICLR header without the removed control pointers | |
| f"Sources (last block): kv2\\_program.md \\S{{}}1 (line {l1}), \\S{{}}1.1 (line {lb}), \\S{{}}2.1 (lines {lA1}, {lA2}), \\S{{}}3.1 (line {lD1}).") if _iclr() else | |
| (r"; the P2 pair and the MB-best + BATON trunk rows are not reported (owner decision 2026-09-15). " | |
| r"(C) Secondary cells and the descriptive pairs of \S{}3.1 that do not involve MB-best + BATON trunk. " | |
| r"(D) MotionBERT-kp validation grid with the same budget of ten validation points. " + LEGEND + | |
| f"Sources (last block): kv2\\_program.md \\S{{}}1 (line {l1}), \\S{{}}1.1 (line {lb}), \\S{{}}2.1 (lines {lA1}, {lA2}, {lP1}), \\S{{}}3 (line {l3}), \\S{{}}3.1 (lines {lD1}, {lD3})."))) | |
| return emit("tab_supp_kv2", cap, | |
| [f"{kv} : last block; §1 S1 val screen (table line {l1}); §1.1 S1b (line {lb})", | |
| f"{kv} : §2.1 nospatial paired Δ tables − K (line {lA1}), +pre − K+pre (line {lA2})" + ("" if _iclr() else f", − MB-best (line {lP1})") + "; test levels = their A / B columns", | |
| (f"{kv} : §3.1 descriptive Δ table (line {lD1})" if _iclr() else f"{kv} : §3 MotionBERT-kp grid (line {l3}); §3.1 descriptive Δ tables (lines {lD1}, {lD3})")], | |
| [("(A) Validation screen of the variant configurations (validation All-MPJPE, px)", "l l c r r l r l", hdrA, bodyA), | |
| ("(B) Five-seed test levels and pre-registered paired differences (All-MPJPE, px)", "l l l l l l r l", hdrB, bodyB), | |
| ("(C) Mean $\\pm$ sd over five seeds with verdict (px; PCK in \\%)", "l l l l l l", hdrC, bodyC), | |
| ("(D) MotionBERT-kp validation grid at seed 42 (same budget as S1; validation All-MPJPE, px)", "l l l r r l l", hdrD, bodyD)]) | |
| # ---------------------------------------------------------------------------------------------- | |
| # Main table C — transfer in both directions | |
| # ---------------------------------------------------------------------------------------------- | |
| def tab_supp_transfer() -> pathlib.Path: | |
| """Round 6 (owner decision docs/decisions.md row 509 (3b), 2026-09-18): the former main Table 6 moves to the supplement and keeps ONLY its | |
| BATON -> AIDE block; the AIDE -> BATON block (C1) leaves the paper and the supplement (single-driver dataset, design judged invalid).""" | |
| bp, c1 = SRC["baton_pretrain"], SRC["c1"] | |
| ls = lines_of(bp) | |
| arms = [ # (section prefix, model label incl. arm registration, initialised from pretraining) | |
| ("3. keypoint-only CWM3-D-kp: fine-tuned", "CWM3-D-kp, pre-registered", "all weights"), | |
| ("4. vis+sem CWM3-D (B2 main): fine-tuned", "CWM3-D vis+sem, pre-registered", "all weights"), | |
| ("5. keypoint-only CWM3-D-kp, TRUNK-only init — POST HOC", "CWM3-D-kp, exploratory arm", "trunk only"), | |
| ("6. keypoint-only CWM3-D-kp, TRUNK-only init — PRE-REGISTERED REPLICATION", "CWM3-D-kp, pre-registered replication (independent pretraining seed)", "trunk only"), | |
| ("7. vis+sem CWM3-D (B2 main), TRUNK-only init — PRE-REGISTERED", "CWM3-D vis+sem, pre-registered", "trunk only"), | |
| ("8. vis + attention heads + learned view gate", "CWM3-D vis+sem, view-gate heads (a), pre-registered", "trunk only"), | |
| ] | |
| hdrA = [["Model", "Initialised from", r"$\Delta$ All-MPJPE", r"$\Delta$ HM", "Seeds CI", "Status"], | |
| ["", "pretraining", "(px)", "(px)", "excl.\\ 0", ""]] | |
| bodyA, srcs = [], [] | |
| for prefix, label, init in arms: | |
| sec, i0 = section(ls, prefix) | |
| hc, rc, kc = next(t for t in md_tables(sec) if t[0][0].strip() == "cell") | |
| ra = find_row(rc, col(hc, "cell"), "All-MPJPE") | |
| rh = find_row(rc, col(hc, "cell"), "HM-MPJPE") | |
| cis = [ra[col(hc, k)] for k in ["Δ s42 [CI]", "Δ s123 [CI]", "Δ s456 [CI]"]] | |
| bodyA.append(row(label, init, tx(ra[col(hc, "mean Δ ± sd")]), tx(rh[col(hc, "mean Δ ± sd")]), ci_excl(cis), _status(ra[col(hc, "verdict")]))) | |
| srcs.append(f"{bp} : §{prefix.split('.')[0]} cell table (line {i0 + kc + 1}): All-MPJPE / HM-MPJPE rows (mean Δ ± sd, per-seed CIs, verdict)") | |
| h2, r2, l2 = first_table(c1, "2. Fine-tuned U0 (AIDE trunk) vs scratch") | |
| hdrB = [["Regime", "Endpoint", r"$\Delta$ PR-AUC@3\,s", "Seeds CI", r"Seeds", "Status"], | |
| ["", "", "", "excl.\\ 0", r"$\Delta \geq +0.02$", ""]] | |
| bodyB = [] | |
| for regime in ["manual", "engaged"]: | |
| for r in r2: | |
| if r[col(h2, "regime")] != regime: | |
| continue | |
| cis = [r[col(h2, k)] for k in ["Δ s0 [CI]", "Δ s1 [CI]", "Δ s2 [CI]"]] | |
| bodyB.append(row(tx(regime), cell_name(r[col(h2, "event")]), dmark(r[col(h2, "mean Δ ± sd")], r[col(h2, "verdict")]), ci_excl(cis), | |
| tx(r[col(h2, "seeds Δ ≥ +0.02")]), _status(r[col(h2, "verdict")]))) | |
| cap = (r"Transfer BATON$\rightarrow$AIDE: fine-tuned from the BATON in-cabin pose pretraining (A) vs the seed init (B), Δ = A − B, mean ± sd over seeds 42/123/456, " | |
| r"paired per-clip bootstrap; 'Seeds CI excl. 0' counts the per-seed CIs of the source that exclude 0; status = BEATS -> significant, else inconclusive. " | |
| r"The AIDE$\rightarrow$BATON block (C1) of the former main-text table leaves the paper and the supplement by owner decision 2026-09-18 (single-driver dataset). " | |
| f"Sources: baton\\_pretrain.md §3–§8 cell tables.") | |
| del hdrB, bodyB, l2 # the AIDE -> BATON block is read (guard: the source still parses) and not emitted | |
| return emit("tab_supp_transfer", cap, srcs, | |
| [(r"BATON $\rightarrow$ AIDE (pose pretraining on BATON in-cabin windows; AIDE test, $n{=}609$; $\Delta$ = pretrained $-$ seed init, negative = better)", | |
| "p{0.30\\linewidth} l r r c l", hdrA, bodyA)]) | |
| # ---------------------------------------------------------------------------------------------- | |
| # Main table D — warning head vs the openpilot attention chain | |
| # ---------------------------------------------------------------------------------------------- | |
| def tab_main_warning() -> pathlib.Path: | |
| wh, ext, op = SRC["wh"], SRC["wh_ext"], SRC["op"] | |
| h1, r1, l1 = first_table(wh, "1. Clean-test AUROC (raw) per seed") | |
| hR, rR, lR = first_table(ext, "1. Clean-test AUROC per stratum") | |
| hD, rD, lD = first_table(ext, "2. Paired Δ vs the DMS attention chain", merge_col=1) | |
| means = [i for i, c in enumerate(hR) if c.strip() == "mean"] # pooled, manual, engaged | |
| Ridx = {r[col(hR, "arm::column")]: r for r in rR} | |
| Didx = {(r[col(hD, "arm::column")], r[col(hD, "stratum")]): r for r in rD} | |
| ls = lines_of(op) | |
| def pooled_sd(arm: str, column: str) -> str: | |
| for r in r1: | |
| if r[col(h1, "arm")] == arm and r[col(h1, "column")] == column: | |
| return tx(r[col(h1, "mean ± sd")]) | |
| raise KeyError((arm, column)) | |
| def strat(key: str) -> list[str]: | |
| return [tx(Ridx[key][m]) for m in means] | |
| def delta(key: str, stratum: str) -> str: | |
| r = Didx[(key, stratum)] | |
| return dmark(r[col(hD, "mean Δ")], r[col(hD, "verdict")]) | |
| def op_item(item: str): | |
| item_lines, i0 = section(ls, f"item `{item}`") | |
| sub, j0 = section(item_lines, "Load `dms_matched`") | |
| h, rows, k = md_tables(sub)[0] | |
| rel_, jr = section(item_lines, "Reliability") | |
| hr, rr, kr = md_tables(rel_)[0] | |
| return (h, rows, i0 + j0 + k + 1), (hr, rr, i0 + jr + kr + 1) | |
| def recall(load, score: str) -> str: | |
| h, rows, _ = load | |
| vals = [] | |
| for regime in ["pooled", "manual", "engaged"]: | |
| r = next(r for r in rows if r[col(h, "regime")] == regime and r[col(h, "score")] == score) | |
| vals.append(tx(r[col(h, "recall")].split(" ")[0])) | |
| return " / ".join(vals) | |
| def ece(rel_, score: str) -> str: | |
| hr, rr, _ = rel_ | |
| r = next(r for r in rr if r[col(hr, "score")] == score and r[col(hr, "seed")] == "0") | |
| return tx(r[col(hr, "ECE calibrated")].split(" ")[0]) | |
| ext_load, ext_rel = op_item("final_ext_dwfc") | |
| oof_load, oof_rel = op_item("oof") | |
| dms, cur, dwfc = "legacy_att::att@3s", "cwm3_W::W_learned_curhgb_t15_w10_n979", "abl_W_dwfc::W_learned_curhgb_t15_w10_n979dwfc" | |
| # round 6 (owner decision 2026-09-18, docs/decisions.md row 509): the pooled paired Δ vs the surrogate is a column of its own (the BATON warning | |
| # summary): +0.080 pooled is INCONCLUSIVE (1/3 seeds), only the manual stratum is significant (3/3) | |
| hdr = [r"\headrow Score & \multicolumn{3}{c}{AUROC} & \multicolumn{3}{c}{$\Delta$ vs DMS chain} & Recall at equal alert load & ECE \\", | |
| r"\cmidrule(lr){2-4}\cmidrule(lr){5-7}", | |
| ["", "pooled", "manual", "engaged", "pooled", "manual", "engaged", "pooled / manual / engaged", "(calibrated)"]] | |
| body = [row(r"openpilot DMS attention chain (att@3\,s)", pooled_sd("legacy_att", "att@3s"), *strat(dms)[1:], "--", "--", "--", | |
| recall(ext_load, "DMS att@3s"), ece(ext_rel, "DMS att@3s")), | |
| row(r"\cwname\ head, pre-specified (CV-selected learner, base features)", pooled_sd("cwm3_W", "W_learned_bothsel_t15_w10_n979"), "--", "--", "--", "--", "--", "--", "--"), | |
| row(r"\cwname\ head, current state (fixed HGB, exploratory)", *strat(cur), delta(cur, "clean_test"), delta(cur, "clean_test|manual"), delta(cur, "clean_test|engaged"), | |
| "--", "--"), | |
| row(r"\cwname\ head, current state + dwell + face (fixed HGB, exploratory)", *strat(dwfc), delta(dwfc, "clean_test"), delta(dwfc, "clean_test|manual"), delta(dwfc, "clean_test|engaged"), | |
| recall(ext_load, "HGB(current+dwell+face)"), ece(ext_rel, "HGB(current+dwell+face)")), | |
| r"\midrule", | |
| r"Human evaluation, 299 new test clips (in progress) & \multicolumn{8}{l}{\pendingresult{AUROC, $\Delta$ vs DMS, recall at equal alert load, ECE}} \\", | |
| r"Public driver-monitoring baselines, same protocol (under evaluation) & \multicolumn{8}{p{0.66\textwidth}}{\pendingresult{Intel OMZ gaze pipeline, MediaPipe Face Landmarker, OpenFace 3.0, L2CS-Net, VideoMAEv2 features; layers 1--3 of the BATON protocol}} \\"] | |
| if _iclr(): | |
| # round 7a (2026-09-18, decisions.md row 516): the pre-registered human evaluation was not executed by submission (no result; scoping | |
| # in Supp. G) and the public-DMS comparison is stated in Supp. C.9 under the owner's review gate -> both pending rows and the | |
| # \midrule leave the ICLR table; the short caption points to the two supplement sections instead. IEEE output unchanged. | |
| body = body[:-3] | |
| cap = (r"Warning head vs the openpilot DMS attention chain on the clean human gold (509 clean-test rows / 63 warranted positives; 327 / 31 manual, 182 / 32 engaged). " | |
| r"AUROC: pooled mean ± sd (warning_head_final.md §1) and per-stratum means (warning_head_final_ext.md regime report §1); Δ vs DMS = paired AUROC difference pooled and per stratum (§2), " | |
| r"\cmark = BEATS (≥ 2/3 seeds CI excl. 0); the pooled Δ of the dwell + face head (+0.080) excludes zero on one seed of three and is not significant. Recall at the DMS chain's own alert load (operating_points.md, Load dms_matched, mean over seeds; current-state head from item oof, " | |
| r"cur+dwell+face from item final_ext_dwfc); ECE calibrated = seed 0 of the Reliability tables (temperature fitted on clean-val). The exploratory heads were chosen after the pre-specified head. " | |
| f"Sources: warning\\_head\\_final.md §1 (line {l1}); warning\\_head\\_final\\_ext.md regime report §1 (line {lR}), §2 (line {lD}); operating\\_points.md dms\\_matched tables (lines {ext_load[2]}, {oof_load[2]}), reliability tables (lines {ext_rel[2]}, {oof_rel[2]}).") | |
| return emit("tab_main_warning", cap, | |
| [f"{wh} : §1 clean-test AUROC per seed, mean ± sd (table line {l1})", | |
| f"{ext} : regime report §1 per-stratum AUROC (table line {lR}); §2 paired Δ vs DMS per stratum (table line {lD})", | |
| f"{op} : item final_ext_dwfc, Load dms_matched (table line {ext_load[2]}); Reliability / ECE (table line {ext_rel[2]})", | |
| f"{op} : item oof, Load dms_matched (table line {oof_load[2]}); Reliability / ECE (table line {oof_rel[2]})"], | |
| [(None, "p{0.25\\textwidth} r r r r r r c r", hdr, body)]) | |
| # ---------------------------------------------------------------------------------------------- | |
| # User-study scaffold (no numbers; every cell is a \pendingresult placeholder) | |
| # ---------------------------------------------------------------------------------------------- | |
| def tab_user_study() -> pathlib.Path: | |
| def P(s: str) -> str: | |
| return r"\pendingresult{" + s + "}" | |
| hdr = ["Measure", "openpilot stock driver monitoring", r"\cwname\ readout"] | |
| measures = [("Participants (completed)", "n"), ("Drive hours", "h"), ("Alerts per hour", "rate"), | |
| ("Appropriateness (1--5)", "mean [CI]"), ("Acceptance (1--5)", "mean [CI]")] | |
| body = [row(m, P(a), r"\ourscol{" + P(a) + "}") for m, a in measures] | |
| body.append(row("Primary endpoint", r"\multicolumn{2}{l}{" + P("pre-registered primary endpoint, paired difference [CI]") + "}")) | |
| cap = (r"User-study scaffold: planned 30-participant blinded in-car study; every value is a \pendingresult placeholder to be filled from the study artefacts. " | |
| r"Conditions are the columns (the CockpitWM column is shaded with \ourscol); the recruitment target is 30 and the completed sample is reported separately. No source file yet.") | |
| return emit("tab_user_study", cap, ["study design only — no result file exists yet; every cell is a \\pendingresult placeholder"], | |
| [(None, "l l l", hdr, body)]) | |
| # ---------------------------------------------------------------------------------------------- | |
| # Identifier map (supplement): internal run / claim identifiers -> meaning in the paper -> where reported | |
| # ---------------------------------------------------------------------------------------------- | |
| ID_MAP: list[tuple[str, str, str]] = [ | |
| ("all_minus_road2drv", r"\cwname\ (final joint model; road$\rightarrow$vehicle and driver$\rightarrow$vehicle paths)", "main paper Sec.~5; Appendix B"), | |
| ("indep", "independent branches (no interaction paths)", "main paper Sec.~5"), | |
| ("all", r"\cwname\ plus the road$\rightarrow$driver path", "main paper Sec.~5; Appendix B"), | |
| ("naive", "default-initialised fusion of the pretrained trunks (earlier data generation)", "Appendix D"), | |
| ("naive_fresh", "fusion trained from scratch (from-scratch fusion)", "main paper Sec.~5; Appendix D"), | |
| ("none", "joint fine-tuning without interaction modules", "Appendix D"), | |
| ("U / V / E", "driver / vehicle / road branch", "main paper Sec.~3"), | |
| ("K / P / R", "detached kinematics / road-pressure / response heads", "main paper Sec.~3; Appendix F"), | |
| ("W_learned_curhgb_t15_w10_n979dwfc", "current-state + dwell + face warning head", "main paper Sec.~5; Appendix C"), | |
| ("att@3s", r"openpilot-derived surrogate: hazard chain trained per model seed to reproduce the logged openpilot attention alerts, composed to 3\,s (comparator only)", "main paper Sec.~5; Appendix C"), | |
| ("B1", "driver branch beats the label-free current-state heuristic k0", "Appendix B, E"), | |
| ("B2", "joint model with interactions not below the independent branches", "main paper Sec.~5; Appendix E"), | |
| ("B3", "chunked 1\\,s-step decoder vs parameter-matched direct decoder", "Appendix D, E"), | |
| ("B4", "learned warning head vs the model's own label-free composition", "Appendix C, E"), | |
| ("B5", "learned warning head vs the openpilot attention chain", "main paper Sec.~5; Appendix C, E"), | |
| ("K3", "vehicle onset chains not below the earlier CAN-only system", "main paper Sec.~5; Appendix E"), | |
| ("K4", "causal-ROI driver inputs beat the old route-median inputs", "Appendix B, E"), | |
| ("K5", "gains survive same-route shifted twins (identity check)", "Appendix E"), | |
| ("K7", "demand / pressure heads vs current-signal threshold rules", "Appendix B, E"), | |
| ("K10", "warning head vs the openpilot attention chain, paired AUROC", "main paper Sec.~5; Appendix E"), | |
| ("E4", "non-causal driver-ROI sensitivity row (appendix only)", "Appendix D"), | |
| ("Gate 0", "published zero-velocity numbers reproduced under the locked protocol", "Appendix A"), | |
| ("Gate A", "keypoint model below the published All / HM and beats ZV-shrink", "Appendix A"), | |
| ("Gate B", "semantic heads reach the published Driver-WM macro-F1", "main paper Sec.~5; Appendix A"), | |
| ("Gate C", "High-Motion error at $h{=}5$ vs the published value", "Appendix A"), | |
| ("C1 (AIDE)", "Driver-WM reproduction under the published architecture", "main paper Sec.~5; Appendix A"), | |
| ("C1 (BATON)", "AIDE-pretrained driver trunk fine-tuned on BATON", "main paper Sec.~5; Appendix B"), | |
| ("C21", "BATON in-cabin pose pretraining transferred to AIDE", "main paper Sec.~5; Appendix A"), | |
| ("C22", "five-seed extension of the two locked AIDE models", "Appendix A"), | |
| ] | |
| def tab_id_map() -> pathlib.Path: | |
| hdr = ["Internal identifier", "Meaning in the paper", "Where reported"] | |
| body = [] | |
| for i, (ident, meaning, where) in enumerate(ID_MAP): | |
| if i == 10: | |
| body.append(r"\midrule") | |
| body.append(group(3, "Pre-registered claim / check identifiers")) | |
| body.append(row(r"\texttt{" + tx(ident) + "}", meaning, where)) | |
| cap = (r"Identifier map: internal run and claim identifiers of the result files, their meaning in the manuscript and where they are reported. " | |
| r"Meanings of the K identifiers follow kill\_report\_final.md; the AIDE gates and C identifiers follow aide/docs/protocol.md. No numbers.") | |
| return emit("tab_id_map", cap, [f"{SRC['kill']} : claim table (K identifiers)", f"{ROOT / 'aide' / 'docs' / 'protocol.md'} : gates, C identifiers"], | |
| [(None, "p{0.26\\textwidth} p{0.46\\textwidth} p{0.22\\textwidth}", hdr, body)]) | |
| # ---------------------------------------------------------------------------------------------- | |
| # legacy stub names -> redirect comments (avoid duplicate labels if a section still \input's the old name) | |
| # ---------------------------------------------------------------------------------------------- | |
| LEGACY = {"tab_aide_semantic_gateb": "tab_aide_semantic", "tab_app_5seed": "tab_aide_5seed", "tab_app_branch_arch": "tab_branch_arch", | |
| "tab_app_rssm": "tab_rssm", "tab_app_gaze": "tab_gzfc", "tab_app_ncroi": "tab_e4"} | |
| GENERATORS = [tab_aide_geometry, tab_aide_semantic, tab_aide_5seed, tab_aide_interventions, tab_aide_analytic, | |
| tab_baton_main, tab_baton_k4, tab_baton_exp3P, tab_warning_head, tab_operating_points, tab_robustness, | |
| tab_branch_arch, tab_rssm, tab_gzfc, tab_e4, tab_app_transfer, tab_app_power, tab_app_identity, tab_negative_summary] | |
| # emitted only with --style iclr (they use the cwm_macros.tex macros \cmark / \xmark / \cwname / \pendingresult / \ourscol) | |
| ICLR_GENERATORS = [tab_main_baton_interaction, tab_supp_baton_interaction_visual, tab_main_aide, tab_supp_transfer, tab_main_warning, tab_user_study, tab_id_map, tab_supp_arch_attribution] | |
| if "kv2" in SRC: # K-v2 programme table only when its report exists (lazy source, see SRC) | |
| ICLR_GENERATORS.append(tab_supp_kv2) | |
| # round 6 (owner decision 2026-09-18, docs/decisions.md row 509 (3b)): the AIDE -> BATON transfer block leaves the paper and the supplement; | |
| # in ICLR style the IEEE-era two-direction table tab_app_transfer is not emitted (tab_supp_transfer, BATON -> AIDE only, replaces it in Supp. A) | |
| ICLR_DROPPED = {"tab_app_transfer"} | |
| def generators() -> list: | |
| if STYLE == "iclr": | |
| return [g for g in GENERATORS if g.__name__ not in ICLR_DROPPED] + ICLR_GENERATORS | |
| return GENERATORS | |
| # ============================================================================================== | |
| # ICLR configuration | |
| # ============================================================================================== | |
| # main-text tables: cwtable (\small, placement [t]); everything else: cwtable* (\scriptsize, supplement) | |
| MAIN_TABLES = {"tab_main_baton_interaction", "tab_main_aide", "tab_main_warning", "tab_user_study", | |
| "tab_road_dynamics"} # owner decision 2026-09-17 item 7: F5c road-demand forecasting is a main-text contribution (both floats) | |
| # short captions (<= 60 words; inputs / outputs / horizon / comparison / statistical meaning; no file paths, no CWM3) | |
| SHORT = { | |
| "tab_aide_geometry": (r"AIDE geometry, official test split ($n{=}609$): 5 observed poses in, 5 future out (10 frames sampled over the 3\,s clip); MPJPE in px (lower is better), " | |
| r"PCK@0.05 in \% (higher). Published rows: single runs (Driver-WM paper, Table 1); ours: mean $\pm$ sd, 3 seeds. " | |
| r"Margins: ours minus best published (zero velocity for All, d-n, PCK; static pooling for HM)."), | |
| "tab_aide_semantic": (r"AIDE semantic heads: macro-F1 on the observed window (test, $n{=}609$; higher is better) with the geometry of the same checkpoint, mean $\pm$ sd over seeds. " | |
| r"Sel.: (a) checkpoint chosen on validation geometry, (b) on validation F1, F1 = frozen features without trunk. " | |
| r"Gate B passes when all four heads reach the published Driver-WM main model. Ensembles are not single models."), | |
| "tab_aide_5seed": (r"Five-seed extension of the two AIDE models (test, $n{=}609$). The locked seeds 42/123/456 remain the headline; seeds 789/1011 were trained " | |
| r"with the locked recipe and are reported regardless of their value. Mean $\pm$ sd over seeds; MPJPE in px (lower is better), PCK and macro-F1 in \% (higher)."), | |
| "tab_aide_interventions": (r"Test-time interventions on the exterior context (AIDE test, $n{=}609$): deviation of the intervened five-step rollout from the factual rollout in px. " | |
| r"$\Delta$/All divides by the model's factual error and is the only column comparable across models. Paper rows: single runs; ours: mean over 3 seeds. " | |
| r"Last column: ground-truth error of the intervened rollout."), | |
| "tab_aide_analytic": (r"Zero-parameter analytic baselines on AIDE test ($n{=}609$): copy or shrink the last observed pose over the 5 future steps. MPJPE in px with 95\% " | |
| r"clip-bootstrap CIs; $\Delta$ vs zero velocity is a paired per-clip difference (negative = better). These rows bound what a learned model must beat."), | |
| "tab_baton_main": (r"BATON onset PR-AUC within 3\,s (test split, both regimes, 3 seeds): the joint model per seed and its paired difference to the independent branches, " | |
| r"without the road-pressure head, and for the from-scratch fusion control. Paired device-cluster bootstrap; better / worse = CI excludes 0 on $\geq 2/3$ seeds " | |
| r"with the same sign; n.s. = no significant difference."), | |
| "tab_baton_k4": (r"Driver-onset PR-AUC within 3\,s of the driver branch on causal targets (3 seeds, mean $\pm$ sd): causal-ROI vs route-median inputs, the label-free " | |
| r"current-state heuristic k0 and persistence; (B) with 64 suspect routes censored; (C) pre-fix float32 statistics. Verdicts: paired bootstrap, CI excludes 0 on $\geq 2/3$ seeds."), | |
| "tab_baton_exp3P": (r"Road-pressure onset PR-AUC within 3\,s (six chains, test, 3 seeds): the P head on the pooled road latent and on a spatial road stream against the " | |
| r"label-free current-margin rule and persistence. Paired device-cluster bootstrap; $\Delta$ per seed; better / worse = CI excludes 0 on $\geq 2/3$ seeds."), | |
| "tab_warning_head": (r"Warning scores on the human gold set (509 test anchors, 63 warranted warnings): AUROC per seed and per regime, and the paired difference " | |
| r"to the openpilot-derived surrogate (att@3s), a chain trained per model seed to reproduce the logged openpilot attention alerts (hence its seed " | |
| r"variation; device-cluster bootstrap). Learned heads read the causal current state; out-of-fold = device-fold retrained models."), | |
| "tab_operating_points": (r"Equal-alert-load operating points, test split, 60\,s cooldown: recall and precision on the gold anchors at fixed thresholds (device-cluster CIs), lead time. " | |
| r"(A) at the openpilot-derived surrogate's own load, (B) at its recall, (C) at 10 alerts per hour, a pre-registered low-load point kept only here " | |
| r"(63 positives: its recall rests on one to twelve events), (D) the current-state head out-of-fold."), | |
| "tab_robustness": (r"Test-time input perturbations of the frozen joint model (no retraining; 3 seeds; 16 onset endpoints, PR-AUC within 3\,s): endpoints whose perturbed minus " | |
| r"clean difference is significantly worse (mean $\Delta$ in parentheses) and the counts of the remaining verdicts."), | |
| "tab_branch_arch": (r"Parameter-matched trunk swaps on each branch (3 seeds, test, both regimes; paired on identical rows). $\Delta$ = alternative minus survivor recipe; own cells are " | |
| r"the branch's onset endpoints (and CAN emissions for V). A branch is architecture-insensitive when no own cell is significantly better or worse."), | |
| "tab_rssm": (r"Decoder baselines (negative results): a chunked 1\,s-step decoder and a stochastic latent-rollout decoder against direct 25-step heads and the frozen joint model, " | |
| r"3 seeds. Top: pre-registered verdicts with the cells that decide them; bottom: the pre-stated CAN kill-rule cells (onset PR-AUC within 3\,s, paired bootstrap)."), | |
| "tab_gzfc": (r"Appendix variant with a gaze-off chain and causal face inputs in the driver branch: driver-onset PR-AUC within 3\,s on causal targets (3 seeds, test). Paired " | |
| r"difference to \cwname\ (visual-only environment input), and the variant against the k0 heuristic and persistence with and without the 64 suspect routes. Never replaces the headline model."), | |
| "tab_e4": (r"Sensitivity to a non-causal driver ROI: the joint recipe on route-median (non-causal) driver inputs minus \cwname\ (visual-only environment input) on causal inputs, driver-onset PR-AUC within 3\,s, " | |
| r"3 seeds. Columns: causal targets (all rows / masked), the base swap alone, and the route-median targets that share the leak. Negative = the causal ROI is better."), | |
| "tab_app_transfer": (r"Cross-dataset transfer in both directions. (A) AIDE$\rightarrow$BATON: driver trunk pretrained on AIDE keypoints, fine-tuned on BATON, vs scratch " | |
| r"(driver-onset PR-AUC within 3\,s). (B) BATON$\rightarrow$AIDE: models fine-tuned from BATON pose pretraining vs the seed init (AIDE test, px). " | |
| r"Paired bootstrap; mean $\pm$ sd over 3 seeds."), | |
| "tab_app_power": (r"Power of the 509-anchor gold set for the paired head-vs-surrogate AUROC difference: CI half-width as a function of positives (Hanley--McNeil scaling " | |
| r"calibrated to the observed 0.088), which differences are declarable, and how many new clips each requires."), | |
| "tab_app_identity": (r"Identity-invariant driver trunks (negative result, 3 seeds): adversarial device head or per-route normalisation vs the survivor baseline. Top: validation " | |
| r"selection; middle: device identity probe on the frozen state; bottom: same-route twin gap and driver-onset PR-AUC within 3\,s against baseline and k0. " | |
| r"All arms killed by the pre-stated rule."), | |
| "tab_negative_summary": (r"Negative and null results, one line each, with the source table and verdict. Inconclusive and not-worse outcomes are reported as no significant " | |
| r"difference, never as wins; pre-registered failures stay failures."), | |
| "tab_main_baton_interaction": (r"BATON test split: PR-AUC of onset within 3\,s, 3 seeds. Levels are seed~0; $\Delta$ columns are mean $\pm$ sd over seeds of the paired " | |
| r"device-cluster bootstrap difference to the independent branches, for \cwname, for adding the road$\rightarrow$driver path, and for fusion trained " | |
| r"from scratch. \cmark/\xmark: significantly better/worse by the pre-specified rule. CAN-only: an earlier CAN-only system."), | |
| # round 4: the same rows under a supplement caption that names the configuration (owner decision 2026-09-17T16:24:02Z) | |
| "tab_supp_baton_interaction_visual": (r"\cwname\ (visual-only environment input), the input ablation: BATON test, onset PR-AUC within 3\,s, 3 seeds, levels at seed~0. " | |
| r"$\Delta$: mean $\pm$ sd over seeds of the paired difference to the independent branches for this configuration, for adding the " | |
| r"road$\rightarrow$driver path and for fusion trained from scratch. \cmark/\xmark: significantly better/worse by the pre-specified rule. CAN-only: earlier system."), | |
| "tab_main_aide": (r"AIDE test ($n{=}609$): 5 observed poses in, 5 future out. Top: geometry, MPJPE in px (lower better), " | |
| r"PCK@0.05 in \% (higher); Driver-WM architecture on our tokens: paired $\Delta$ to \cwname{}. " | |
| r"MotionBERT rows: released MB\_release weights fine-tuned on AIDE under both read-outs (Supp.\ D). " | |
| r"Bottom: semantic macro-F1 (higher) with that checkpoint's geometry. Ours: mean $\pm$ sd; published rows: single runs."), | |
| "tab_supp_arch_attribution": (r"Architecture attribution on AIDE test ($n{=}609$; paired per-clip bootstrap; $\Delta$ in px, negative = better for errors, positive for PCK). " | |
| r"(A) The Driver-WM architecture on \cwname{} tokens, per seed. " | |
| r"(B) Its paired difference to \cwname{}. (C) Seed means over the locked three seeds and over five seeds."), | |
| "tab_supp_kv2": (r"A validation-screened \cwname{} variant on AIDE test ($n{=}609$; paired per-clip bootstrap; $\Delta$ in px, negative = better). " | |
| r"(A) Validation screen at seed 42 and the seed-123 check. (B) Five-seed test levels and paired differences to \cwname{}, without and with BATON trunk pretraining " | |
| r"on both sides. (C) Secondary cells and descriptive pairs."), | |
| "tab_supp_transfer": (r"Transfer BATON$\rightarrow$AIDE, 3 seeds, paired per-clip bootstrap; significant = CI excludes 0 on $\geq 2/3$ seeds with the same sign: " | |
| r"fine-tuned from BATON in-cabin pose pretraining vs the seed init (AIDE test, $n{=}609$; $\Delta$ in px, negative = better)."), # round-6 fix: the removed AIDE->BATON block is recorded once, in Supp. E (deviations); the header comment keeps the note | |
| "tab_main_warning": (r"Human gold set: 509 test anchors, 63 warranted warnings (31 manual / 32 engaged). AUROC (device-cluster bootstrap); paired $\Delta$ vs the openpilot-derived surrogate (att@3s), " | |
| r"\cmark = significant on $\geq 2/3$ seeds (pooled $+0.080$: one seed). Recall at the surrogate's load; ECE after validation-fitted temperature, seed 0. " | |
| r"Exploratory heads chosen after the pre-specified head; human evaluation (not executed): supplementary material, Section G; public pipelines: Section C."), # round 7a (DEC:516): the two pending rows leave the ICLR table; pointers to Supp. G / C instead; round-7a fixes: bootstrap + seed 0 restored, 60 words by caption_words() | |
| "tab_user_study": (r"Planned blinded in-car user study (recruitment target 30 participants; the completed sample is reported separately): each participant drives with the stock " | |
| r"openpilot driver monitoring and with the \cwname\ readout. Values will be filled from the study artefacts once the study has run; nothing here is a result."), | |
| "tab_id_map": (r"Internal identifiers used in the result files and their meaning in the paper. Pre-registered claim and check identifiers (B, K, E, Gate, C) are listed with a " | |
| r"one-line meaning and the place where each is reported."), | |
| } | |
| # per-column \best{} among model rows: {table: {block index: {column index: 'min' | 'max'}}} | |
| BEST = { | |
| "tab_aide_geometry": {0: {2: "min", 3: "min", 4: "min", 5: "min", 6: "max", 7: "min"}}, | |
| "tab_aide_semantic": {0: {4: "min", 5: "min", 6: "min", 7: "max", 8: "max", 9: "max", 10: "max"}}, | |
| "tab_aide_analytic": {0: {1: "min", 2: "min", 3: "min", 4: "min", 5: "max", 6: "max", 7: "min", 8: "min", 9: "min"}}, | |
| "tab_warning_head": {0: {2: "max", 3: "max", 4: "max"}}, | |
| "tab_main_aide": {0: {3: "min", 4: "min", 5: "min", 6: "max", 7: "min"}, 1: {3: "max", 4: "max", 5: "max", 6: "max", 7: "min"}}, # block 1: Params column inserted 2026-09-16 | |
| "tab_main_warning": {0: {1: "max", 2: "max", 3: "max", 8: "min"}}, # round 6: pooled Δ column inserted (col 4) | |
| } | |
| # candidate-row hooks (cells, group title) -> bool; default _default_cand | |
| CAND: dict = { | |
| # the Driver-WM-kp row is a paired Δ, the '5~seeds' row a different seed set and the Table-8 row a published three-seed mean: none competes | |
| # for \best{} with the 3-seed levels (row labels now name their seed set in words, owner item 9, so the exclusion is by these three markers) | |
| "tab_main_aide": lambda cells, grp: _default_cand(cells, grp) and "\\Delta" not in cells[0] and "5~seeds" not in cells[0] and "three seeds" not in cells[0], | |
| } | |
| # \oursrow hooks (cells, group title) -> bool; default _default_ours (any cell names CockpitWM) | |
| _NEVER = lambda cells, grp: False # noqa: E731 | |
| OURS = { | |
| "tab_baton_main": _NEVER, "tab_baton_k4": _NEVER, "tab_baton_exp3P": _NEVER, "tab_robustness": _NEVER, "tab_branch_arch": _NEVER, | |
| "tab_rssm": _NEVER, "tab_gzfc": _NEVER, "tab_e4": _NEVER, "tab_app_power": _NEVER, "tab_app_identity": _NEVER, "tab_negative_summary": _NEVER, | |
| "tab_main_baton_interaction": _NEVER, "tab_supp_baton_interaction_visual": _NEVER, "tab_main_baton_interaction_ecan": _NEVER, "tab_input_ablation": _NEVER, "tab_supp_transfer": _NEVER, "tab_main_kpf_gain": _NEVER, "tab_user_study": _NEVER, "tab_id_map": _NEVER, "tab_supp_kv2": _NEVER, | |
| "tab_warning_head": lambda cells, grp: cells[0].startswith(("Learned head", "HGB")) or "CockpitWM" in cells[0], | |
| "tab_operating_points": lambda cells, grp: len(cells) > 1 and cells[1].startswith("HGB"), | |
| "tab_main_warning": lambda cells, grp: "dwell" in cells[0], | |
| "tab_main_aide": lambda cells, grp: cells[0].startswith("CockpitWM"), # not the 'Driver-WM-kp, Δ to CockpitWM-K' row | |
| } | |
| # ICLR column specs (\textwidth = 5.5 in): {table: {block index: colspec}}; unspecified blocks keep the IEEE colspec. | |
| # Main tables are \small (= 9pt in the ICLR style; \footnotesize is also 9pt, \scriptsize 7pt, \tiny 6pt); a per-column size prefix | |
| # keeps a wide main table on one line without dropping a column. | |
| def sized(size: str, spec: str) -> str: | |
| return " ".join(">{\\" + size + "}" + c for c in spec.split()) | |
| ICLR_COLSPEC = { | |
| # main-text tables (\small = 9pt); the three widest are set in \scriptsize per column | |
| "tab_main_baton_interaction": {0: sized("scriptsize", "l r r r r r r")}, | |
| "tab_main_aide": {0: sized("scriptsize", "p{0.155\\textwidth} r l r r r r r"), 1: sized("scriptsize", "p{0.29\\textwidth} l r r r r r r")}, # block 1: 0.33 -> 0.29 (own float since round 3, default 3pt colsep) # block 1 gained a Params column (2026-09-16); block 0 label 0.17 -> 0.155 (2026-09-17: the "released weights, 3 seeds" provenance cell made the geometry block 5.3 pt overfull) | |
| "tab_supp_transfer": {0: tiny("p{0.30\\linewidth} l r r c l")}, | |
| "tab_main_warning": {0: sized("scriptsize", "p{0.22\\textwidth} r r r r r r c r")}, # round 6: + pooled Δ column (0.26 gave a 7.2 pt overfull) | |
| "tab_id_map": {0: "p{0.32\\textwidth} p{0.42\\textwidth} p{0.20\\textwidth}"}, | |
| # supplement tables (\scriptsize = 7pt) that were laid out for the 7.2-in IEEE page: \tiny columns and narrower p{} widths | |
| "tab_aide_geometry": {0: tiny("l r r r r r r r")}, | |
| "tab_aide_semantic": {0: tiny("p{0.12\\linewidth} l r r r r r r r r r p{0.07\\linewidth}")}, | |
| "tab_aide_interventions": {0: tiny("l p{0.22\\linewidth} r r r r r r r")}, # model labels wrap ("CockpitWM (+ semantic heads), ...") | |
| "tab_aide_analytic": {0: tiny("p{0.19\\linewidth} l r l r r r r r r")}, | |
| "tab_baton_main": {0: tiny("l l r l r l r l")}, | |
| "tab_baton_k4": {0: tiny("l l r r r r r l l"), 1: tiny("l l r r r l r l l"), 2: tiny("l l r r r r l l")}, | |
| "tab_baton_exp3P": {0: tiny("l r r r r l l l r l")}, | |
| "tab_warning_head": {0: tiny("p{0.34\\linewidth} l l r r r l")}, | |
| "tab_operating_points": {k: tiny("l l l l l l l r") for k in range(4)}, | |
| "tab_branch_arch": {0: "l p{0.17\\linewidth} p{0.08\\linewidth} p{0.08\\linewidth} p{0.12\\linewidth} p{0.14\\linewidth} p{0.14\\linewidth} p{0.11\\linewidth}"}, | |
| "tab_gzfc": {0: tiny("l l r l r r r l r r l")}, | |
| "tab_app_transfer": {0: tiny("l l l l r l l r r l"), 1: tiny("p{0.20\\linewidth} r l r l r l r l p{0.10\\linewidth}")}, | |
| "tab_app_power": {0: tiny("r r r c r c c c c r r l")}, | |
| "tab_app_identity": {2: tiny("l l r r l r r l l l l")}, | |
| "tab_negative_summary": {0: "p{0.50\\linewidth} p{0.32\\linewidth} p{0.13\\linewidth}"}, | |
| # blocks (A)-(D) since 2026-09-15 (the former matched-pretraining block (A) is not emitted, OMIT_ROWS_OWNER_20260915) | |
| "tab_supp_arch_attribution": {0: tiny("l r r l l l l l"), 1: tiny("l l l l r l"), 2: tiny("l c r r r r r"), 3: tiny("l l l l l l r l")}, | |
| "tab_supp_kv2": {0: tiny("p{0.13\\linewidth} l c r r l r p{0.16\\linewidth}"), 1: tiny("p{0.19\\linewidth} l l l l l r l"), | |
| 2: tiny("p{0.26\\linewidth} l l l l l"), 3: tiny("l l l r r l l")}, | |
| } | |
| # ICLR-only \tabcolsep per block (k >= 1) of a wide table: {table: {block: length}}; blocks not listed get the cwtable default 3pt | |
| ICLR_COLSEP = { | |
| "tab_main_aide": {1: "2pt"}, # block 2 (semantic) carries the Params column since 2026-09-16 | |
| "tab_supp_arch_attribution": {3: "2pt"}, # block (D) (former (E)): five CI columns; 3pt gave a 10.8pt overfull on the 5.5in text width | |
| "tab_supp_kv2": {1: "2pt", 2: "2pt"}, # blocks (B) five CI columns and (C) five mean ± sd (verdict) columns | |
| } | |
| # ICLR-only float splits: {table: {block: predicate(cells, line, group) -> bool}}; a float taller than the 9-in page is closed before the | |
| # first row for which the predicate holds and continued in a new float with the same columns and header (caption "... (continued, part n)"). | |
| ICLR_SPLIT = { | |
| # the negative-results summary (25 long rows) was too large for the page by 293 pt (found 2026-09-15): two parts of 12 / 13 rows | |
| "tab_negative_summary": {0: lambda cells, line, grp: bool(cells) and cells[0].startswith("Full-frame cabin latent")}, | |
| } | |
| # ICLR-only continuation floats: {table: {block indices that open a new float}} (block 0 always opens the first float) | |
| ICLR_NEWFLOAT = { | |
| "tab_supp_kv2": {3}, # blocks (A)-(C) were 12 pt too tall for the page with (D) in the same float (2026-09-15); (D) needs no tight \tabcolsep | |
| # tab_main_aide (round 3, 2026-09-17): with the two adjacent Driver-WM port level rows (owner decision) the geometry block alone fills most of a | |
| # page and the two-block [t] float exceeded the page -- LaTeX deferred it, and every later float, past the references (first round-3 build: | |
| # Tables 2--7 on pp. 21--25). Geometry and semantic blocks are therefore two floats (like tab_road_dynamics); the semantic float is | |
| # Table~\ref{tab:main_aide_cont1} in the text. The 2pt \tabcolsep of block 1 cannot be set inside a fresh cwtable, so its label column is 0.29. | |
| "tab_main_aide": {1}, | |
| } | |
| # ICLR-only header rows (abbreviated two-row headers for the narrow page; {table: {block: header}}); the IEEE headers are unchanged | |
| _OP_HDR = [["Regime", "Score", "Alerts/h", "$n$ gold", "Recall", "Precision", "Lead median", "Detected"], | |
| ["", "", "manual / engaged", "/ pos", "[CI, seed 0]", "[CI, seed 0]", "s [IQR]", ""]] | |
| ICLR_HEADER = { | |
| "tab_operating_points": {k: _OP_HDR for k in range(4)}, | |
| "tab_app_identity": {2: [["Regime", "Event", "Twin gap", "", r"$\Delta$ twin AUROC", "K4, all rows", "", "", "", "K4, masked", ""], | |
| ["", "", "arm", "baseline", "(arm $-$ base)", "arm", "baseline", "verdict", "vs k0", "verdict", "vs k0"]]}, | |
| "tab_baton_k4": {0: [["Regime", "Event", "Causal-ROI", "Route-median", "k0", "Persistence", r"Input effect $\Delta$", "verdict", "Causal"], | |
| ["", "", "inputs", "inputs", "heuristic", "(base rate)", "(causal $-$ old)", "", "vs k0"]], | |
| 1: [["Regime", "Event", "Causal", "k0", "Persistence", "vs k0", "Survivor recipe", "vs k0", "vs clamp-5"], | |
| ["", "", "(clamp 5)", "(masked pop.)", "", "", "clip8+LN (final U)", "", "baseline"]], | |
| 2: [["Regime", "Event", "Stats v1", "Stats v2", "k0", r"$\Delta$ stats1 $-$ stats2", "verdict", "Stats v1"], | |
| ["", "", "(float32)", "(float64)", "", r"(mean $\pm$ sd)", "", "vs k0"]]}, | |
| "tab_baton_exp3P": {0: [["Chain", "P pooled", "P spatial", "Rule $S_0$", "Persist.", r"$\Delta$ pooled $-$ rule", "verdict", "spatial", r"$\Delta$ spatial", "verdict"], | |
| ["", "", "", "", "", "(s0 / s1 / s2)", "", "vs rule", "$-$ pooled", ""]]}, | |
| "tab_gzfc": {0: [["Regime", "Event", r"$\Delta$ variant $-$", "verdict", "Variant", "k0", "Persistence", "vs k0", "Variant", "k0", "vs k0"], | |
| ["", "", "frozen main (a)", "", "(all rows)", "", "", "", "(masked)", "(masked)", ""]]}, | |
| } | |
| # ICLR-only cell transforms (text only, never a number): {table: fn(cell) -> cell} | |
| ICLR_CELL = { | |
| # '134.56 (Static pooling)' -> '134.56' on the best-published row (the row names are given in the short caption) | |
| "tab_aide_geometry": lambda c: re.sub(r"^(\d+\.\d+) \([^()]*\)$", r"\1", c), | |
| # let the \texttt{source path} column break after '/' and '_' | |
| "tab_negative_summary": lambda c: c.replace("/", "/\\allowbreak ").replace("\\_", "\\_\\allowbreak ") if c.startswith("\\texttt{") else c, | |
| } | |
| # ---------------------------------------------------------------------------------------------- | |
| # Supplement table — AIDE MASTER table in the Driver-WM column format (aide/results/tables/master_aide.md, written by | |
| # aide/eval/report_master_aide.py: every OUR cell recomputed from the run's pred_test.npz and checked against its metrics_test.json; | |
| # the 18 published rows are the stage_bc.md §1b strings). Emitted only with --style iclr and only when the source exists; it is NOT | |
| # \input anywhere in the manuscript (owner decision pending) and no existing generator is touched by this block. | |
| # ---------------------------------------------------------------------------------------------- | |
| _MASTER_PATH = AT / "master_aide.md" | |
| _MASTER_COLS = ["Model", "All MPJPE↓", "All d-nMPJPE↓", "HM MPJPE↓", "HM d-nMPJPE↓", "PCK@0.05↑", "DBR F1↑", "DER F1↑", "TCR F1↑", "VCR F1↑"] | |
| _MASTER_HDR = ["Model", r"All$\downarrow$", r"d-n$\downarrow$", r"HM$\downarrow$", r"HM d-n$\downarrow$", r"PCK@0.05$\uparrow$", | |
| r"DBR$\uparrow$", r"DER$\uparrow$", r"TCR$\uparrow$", r"VCR$\uparrow$"] | |
| def _master_block(heading_prefix: str) -> tuple[list[str], int]: | |
| """Body rows of one master_aide.md table: group rows (first cell in *italics*, all other cells empty) become \\multicolumn | |
| group lines, every other row is copied cell by cell (tx(); bold marks of the markdown are dropped — \\best{} is re-derived by BEST).""" | |
| h, rows, line = first_table(_MASTER_PATH, heading_prefix) | |
| if [c.strip() for c in h] != _MASTER_COLS: | |
| raise ValueError(f"master_aide.md: unexpected header {h!r} under {heading_prefix!r}") | |
| body = [] | |
| for r in rows: | |
| if len(r) != len(_MASTER_COLS): | |
| raise ValueError(f"master_aide.md: row with {len(r)} cells under {heading_prefix!r}: {r!r}") | |
| if omitted_row(r[0]): # owner presentation decision 2026-09-15 (OMIT_ROWS_OWNER_20260915): MotionBERT-kp / ST-GCN-kp + BATON trunk rows | |
| continue # are not emitted; \best{} is re-derived among the remaining rows by BEST / CAND (descriptive bold) | |
| if r[0].strip().startswith("*") and all(not c.strip() for c in r[1:]): | |
| body.append(group(len(_MASTER_COLS), tx(r[0].strip().strip("*").strip()))) | |
| else: | |
| body.append(row(*[tx(c) for c in r])) | |
| return body, line | |
| def tab_supp_master_aide() -> pathlib.Path: | |
| bodyA, lA = _master_block("1. Master table") | |
| bodyB, lB = _master_block("2. Same columns") | |
| chk, lchk = find_line(_MASTER_PATH, "Generated ") | |
| m = re.search(r"Recompute-vs-harness check: (\d+) runs, max \|Δ\| = ([0-9.e+-]+); (\d+) mismatch", chk) | |
| if not m: | |
| raise ValueError("master_aide.md: recompute-vs-harness summary line not found") | |
| cap = (r"Appendix: AIDE master table in the Driver-WM column format (official test split, $n{=}609$; px for MPJPE, \% for PCK and macro-F1). " | |
| r"Published rows are single-seed values typed from the Driver-WM paper (stage\_bc.md §1b) and cannot be paired with our clips; our rows are seed means $\pm$ sd (ddof 1) " | |
| r"recomputed from the saved test predictions of every run and checked against the harness records " | |
| f"({m.group(1)} runs, max abs.\\ difference {m.group(2)}, {m.group(3)} mismatches). " | |
| r"HM = the 60 highest-motion test clips (threshold 72.05 px); d-n = 100 $\cdot$ MPJPE / image diagonal; PCK@0.05 at 96 px. " | |
| r"(A) semantic F1 under reading (b) = checkpoint selected on validation macro-F1 (dual selection); (B) reading (a) = the checkpoint selected on validation All-MPJPE. " | |
| r"Ensembles average saved predictions and are not single models; analytic rules have no parameters. Bold = best per column among the single-model rows (descriptive; " | |
| r"significance only in the paired tests of arch\_attribution.md / baton\_pretrain.md / kv2\_program.md). " | |
| f"Sources: master\\_aide.md §1 (line {lA}), §2 (line {lB}), check line {lchk}.") | |
| return emit("tab_supp_master_aide", cap, | |
| [f"{_MASTER_PATH} : §1 master table, F1 under reading (b) (table line {lA})", | |
| f"{_MASTER_PATH} : §2 same columns, F1 under reading (a) (table line {lB})", | |
| f"{_MASTER_PATH} : recompute-vs-harness summary (line {lchk})"], | |
| [("(A) Master table; semantic macro-F1 under reading (b): checkpoint selected on validation F1", "p{0.30\\linewidth} r r r r r r r r r", _MASTER_HDR, bodyA), | |
| ("(B) Same columns; semantic macro-F1 under reading (a): checkpoint selected on validation geometry (semantic models only)", "p{0.30\\linewidth} r r r r r r r r r", _MASTER_HDR, bodyB)]) | |
| if _MASTER_PATH.exists(): # lazy, as the K-v2 table: a checkout without the master table still generates everything else | |
| SRC["master_aide"] = _MASTER_PATH | |
| ICLR_GENERATORS.append(tab_supp_master_aide) | |
| SHORT["tab_supp_master_aide"] = (r"AIDE master table in the Driver-WM column format (test, $n{=}609$). MPJPE in px (lower is better); d-n = MPJPE over the image diagonal; " | |
| r"HM = 60 highest-motion clips; PCK@0.05 and macro-F1 in \% (higher). Published rows: single runs (paper Tables 1--3). Ours: mean $\pm$ sd over seeds, " | |
| r"recomputed from saved predictions. (A) F1 at the validation-F1 checkpoint, (B) at the validation-geometry checkpoint.") | |
| BEST["tab_supp_master_aide"] = {0: {1: "min", 2: "min", 3: "min", 4: "min", 5: "max", 6: "max", 7: "max", 8: "max", 9: "max"}, | |
| 1: {6: "max", 7: "max", 8: "max", 9: "max"}} # block (B): F1 columns only, as in master_aide.md §2 | |
| # best marks among SINGLE models only: not the published rows (default), not the analytic rules, not the ensembles (default) | |
| CAND["tab_supp_master_aide"] = lambda cells, grp: _default_cand(cells, grp) and "analytic" not in (grp or "").lower() | |
| ICLR_COLSPEC["tab_supp_master_aide"] = {k: tiny("p{0.30\\linewidth} r r r r r r r r r") for k in (0, 1)} | |
| # ---------------------------------------------------------------------------------------------- | |
| # Owner naming rule (2026-09-15): the model has ONE name, CockpitWM. _NM rewrites every internal / earlier display name into words | |
| # (keypoint forecaster = CockpitWM; semantic variant = CockpitWM (+ semantic heads); K-v2 = validation-screened CockpitWM variant; | |
| # Driver-WM-kp = Driver-WM architecture on CockpitWM tokens); emit_iclr() refuses these survivors outside comment lines. | |
| # The linter (ICLR/tools/lint_sections.py, rule F5) applies the same ban to sections/ and tables/. | |
| # ---------------------------------------------------------------------------------------------- | |
| _FORBIDDEN_NAMES = ("CockpitWM-KS", "CockpitWM-K", "K-v2", "\\cwname-KS", "\\cwname-K") | |
| # master table: the Driver-WM-architecture row now names CockpitWM (its tokens) but is a comparator, not one of our rows | |
| OURS["tab_supp_master_aide"] = lambda cells, grp: "CockpitWM" in cells[0] and not cells[0].startswith("Driver-WM") | |
| # master table layout on the 5.5-in page (first compile 2026-09-15: 45 / 52 pt overfull and 176 pt too tall): 9 numeric \tiny columns with | |
| # 2.5 pt inter-column space, a 0.23-linewidth label column, and the single-model / ensemble rows + block (B) in a second float | |
| _MASTER_SPEC = ">{\\tiny}p{0.23\\linewidth}" + "".join("@{\\hskip 2.5pt}>{\\tiny}r" for _ in range(9)) | |
| ICLR_COLSPEC["tab_supp_master_aide"] = {0: _MASTER_SPEC, 1: _MASTER_SPEC} | |
| ICLR_SPLIT["tab_supp_master_aide"] = {0: lambda cells, line, grp: cells is None and "Single models" in line} | |
| # ---------------------------------------------------------------------------------------------- | |
| # Supplement table — absolute-coordinate formulation ablation (aide/results/tables/formulation_abs.md, explanatory, pre-registered | |
| # docs/decisions.md 2026-09-15; written by aide/eval/report_formulation_abs.py from metrics_test.json / run json / pred_test.npz). | |
| # (A) test levels of the published rows, our zero velocity, the anchored (residual) references and the two absolute-read-out arms; | |
| # (B) paired per-clip Δ = absolute − anchored per seed. Lazy, like the master table: emitted only when the report exists. | |
| # ---------------------------------------------------------------------------------------------- | |
| _FA_PATH = AT / "formulation_abs.md" | |
| _FA_CELLS = ["All-MPJPE", "d-n", "HM-MPJPE", "HM d-n", "PCK@0.05", "All h=1", "All h=2", "All h=3", "All h=4", "All h=5"] | |
| def _fa_label(raw: str, seed: str) -> str: | |
| """Short row label for a §1 row of formulation_abs.md (the source labels carry run names and formulation prose).""" | |
| r = raw.replace("**", "").strip() | |
| arch = "MotionBERT-kp" if "MotionBERT" in r else "CockpitWM" | |
| if "published" in r.lower(): | |
| return {"MotionBERT": "MotionBERT (published, single run)", "Driver-WM main": "Driver-WM main (published, single run)", | |
| "Zero-Velocity": "Zero velocity (published, single run)"}[r.split(" (")[0]] | |
| if r.lower().startswith("zero-velocity (ours"): | |
| return "Zero velocity (our protocol, analytic)" | |
| if "ABSOLUTE" in r: | |
| return f"{arch}, absolute read-out" + (" (3 seeds)" if "mean" in r else f", seed {seed.strip()}") | |
| if "5-seed mean" in r: | |
| return f"{arch}, anchored (5 seeds)" | |
| return f"{arch}, anchored, seed {seed.strip()}" | |
| def tab_supp_formulation_abs() -> pathlib.Path: | |
| fa = SRC["formulation_abs"] | |
| h1, r1, l1 = first_table(fa, "1. Test levels") | |
| c1 = {k: col(h1, k) for k in ["row", "seed / n", "All", "d-n", "HM", "HM d-n", "PCK@0.05"]} | |
| hdrA = ["Model", "Seed / n", r"All$\downarrow$", r"d-n$\downarrow$", r"HM$\downarrow$", r"HM d-n$\downarrow$", r"PCK@0.05$\uparrow$"] | |
| bodyA = [] | |
| for r in r1: | |
| lab = _fa_label(r[c1["row"]], r[c1["seed / n"]]) | |
| seed = tx(r[c1["seed / n"]]).replace("paper (single seed)", "--").replace("analytic", "--") | |
| bodyA.append(row(lab, seed, *[tx(r[c1[k]]) for k in ["All", "d-n", "HM", "HM d-n", "PCK@0.05"]])) | |
| # (B) paired Δ per arm (two "###" tables under §2; the first is the MotionBERT architecture, the second CockpitWM) | |
| h2, rmb, l2 = first_table(fa, "2. Paired per-clip", table_idx=0) | |
| _, rk, l3 = first_table(fa, "2. Paired per-clip", table_idx=1) | |
| c2 = {k: col(h2, k) for k in ["cell", "Δ s42 [CI]", "Δ s123 [CI]", "Δ s456 [CI]", "mean Δ ± sd"]} | |
| hdrB = ["Cell", r"$\Delta$ s42 [CI]", r"$\Delta$ s123 [CI]", r"$\Delta$ s456 [CI]", r"mean $\Delta$ $\pm$ sd"] | |
| def rowsB(rows) -> list[str]: | |
| return [row(tx(cell), *[tx(find_row(rows, c2["cell"], cell)[c2[k]]) for k in ["Δ s42 [CI]", "Δ s123 [CI]", "Δ s456 [CI]", "mean Δ ± sd"]]) for cell in _FA_CELLS] | |
| bodyB = [group(5, "MotionBERT-kp: absolute read-out $-$ anchored (seed-matched)")] + rowsB(rmb) + \ | |
| [r"\midrule", group(5, "CockpitWM: absolute read-out $-$ anchored (seed-matched)")] + rowsB(rk) | |
| out_line, lo = find_line(fa, "**Outcome sentence.**") | |
| cap = (r"Appendix: absolute-coordinate formulation ablation on AIDE (test, $n{=}609$; explanatory, pre-registered before any run, nothing adopted). " | |
| r"(A) Test levels (px; PCK in \%; [CI] = 10k clip bootstrap) of the published rows, our zero velocity, the anchored references (residual over the last pose, zero init, + anchor mixture for CockpitWM) " | |
| r"and the two arms with an absolute-coordinate read-out (default init, no residual, no anchor; recipe otherwise identical). " | |
| r"(B) Paired per-clip $\Delta$ = absolute $-$ anchored per seed (positive = the absolute read-out is worse; PCK negative = worse). " | |
| f"Sources: formulation\\_abs.md \\S{{}}1 (line {l1}), \\S{{}}2 (lines {l2}, {l3}), outcome (line {lo}).") | |
| return emit("tab_supp_formulation_abs", cap, | |
| [f"{fa} : §1 test levels (table line {l1})", f"{fa} : §2 paired Δ, CockpitWM architecture (line {l3})" if _iclr() else f"{fa} : §2 paired Δ, MotionBERT architecture (line {l2}); CockpitWM architecture (line {l3})", | |
| f"{fa} : §3 outcome sentence (line {lo})"], | |
| [("(A) Test levels: published rows, zero velocity, anchored references and absolute-read-out arms (px; PCK in \\%)", "l l l l l l l", hdrA, bodyA), | |
| ("(B) Paired per-clip differences, absolute $-$ anchored (px; PCK in \\%)", "l l l l r", hdrB, bodyB)]) | |
| if _FA_PATH.exists(): | |
| SRC["formulation_abs"] = _FA_PATH | |
| ICLR_GENERATORS.append(tab_supp_formulation_abs) | |
| SHORT["tab_supp_formulation_abs"] = (r"Absolute-coordinate ablation on AIDE test ($n{=}609$; explanatory, nothing adopted). (A) Test levels of the published rows, zero velocity, " | |
| r"the anchored \cwname{} (residual over the last observed pose) and \cwname{} trained with an absolute-coordinate read-out; " | |
| r"[CI] = clip bootstrap. (B) Paired per-clip difference absolute minus anchored per seed (positive = worse; PCK negative = worse).") | |
| OURS["tab_supp_formulation_abs"] = lambda cells, grp: cells[0].startswith("CockpitWM") | |
| # block (A): five CI-bearing columns were 31 pt too wide with the 3 pt default gaps and a 0.30-linewidth label (first compile 2026-09-15) | |
| ICLR_COLSPEC["tab_supp_formulation_abs"] = {0: ">{\\tiny}p{0.20\\linewidth}" + "".join("@{\\hskip 2pt}>{\\tiny}l" for _ in range(6)), 1: tiny("l l l l r")} | |
| # ---------------------------------------------------------------------------------------------- | |
| # Supplement table — rule-based alternatives to Driver-WM's official High-Motion subset (aide/results/tables/hm_subsets.md, written by | |
| # aide/eval/report_hm_subsets.py from saved predictions only; pre-registered docs/decisions.md 2026-09-15T03:01:43Z; descriptive — every subset | |
| # reported, none selected or adopted). (A) motion-quantile sweep (top 5…100 % of the test clips by the official GT motion score), (B) part-specific | |
| # top-10 % subsets (hands / face / body score), (C) the pre-specified "reactive manoeuvre" label union and every AIDE class as its own subset. | |
| # Every cell is the verbatim string of the owner-summary tables §1.1 / §2.1 / §3.1 / §3.2 (verdict tokens rendered by vd()). Lazy, like the master | |
| # table: emitted only with --style iclr and only when the report exists; \input in Supp. A "Rule-based high-motion subsets" since 2026-09-15 (owner item 13). | |
| # ---------------------------------------------------------------------------------------------- | |
| _HMS_PATH = AT / "hm_subsets.md" | |
| _HMS_HDR_A = ["top q", "n clips", "comparator", "CockpitWM (px)", "comparator (px)", "Δ mean ± sd over seeds", "CI excl. 0", "verdict"] | |
| _HMS_HDR_B = ["subset", "n", "comparator", "Δ all joints mean ± sd", "CI excl. 0", "verdict (all)", "Δ part joints mean ± sd", "CI excl. 0", "verdict (part)"] | |
| _HMS_HDR_C1 = ["subset", "n clips", "comparator", "CockpitWM (px)", "comparator (px)", "Δ mean ± sd over seeds", "CI excl. 0", "verdict"] | |
| _HMS_HDR_C2 = ["task", "class", "n", "in official HM", "mean motion score (px)", "zero-velocity", "CockpitWM", "Δ vs ZV", | |
| "Δ vs Driver-WM arch. on CockpitWM tokens", "Δ vs Driver-WM reproduction (ours)"] | |
| _HMS_PART = {"hand motion (42 hand joints, both hands)": "hands (42 joints)", "head/face motion (68 face joints)": "face (68 joints)", | |
| "body motion (26 body joints)": "body (26 joints)"} | |
| _HMS_VERD_RE = re.compile(r"\b(BEATS|WORSE|INCONCLUSIVE|NOT_WORSE|SINGLE_RULE|INSUFFICIENT)\b") | |
| def _hms_table(heading_prefix: str, expected_header: list[str]): | |
| h, rows, line = first_table(_HMS_PATH, heading_prefix) | |
| if [c.strip() for c in h] != expected_header: | |
| raise ValueError(f"hm_subsets.md: unexpected header under {heading_prefix!r}: {h!r}") | |
| for r in rows: | |
| if len(r) != len(expected_header): | |
| raise ValueError(f"hm_subsets.md: row with {len(r)} cells under {heading_prefix!r}: {r!r}") | |
| return rows, line | |
| def _hms_comp(cell: str) -> str: | |
| """Comparator label: the two ZV-shrink rules in math (the md carries 'α' / 'α_h'); everything else through tx().""" | |
| return {"ZV-shrink α": r"ZV-shrink $\alpha$", "ZV-shrink α_h": r"ZV-shrink $\alpha_h$"}.get(cell.strip(), tx(cell)) | |
| def _hms_verd_inline(cell: str) -> str: | |
| """'-4.13 ± 0.14 (5/5; BEATS)' -> the verdict word of vd(); numbers untouched.""" | |
| return tx(_HMS_VERD_RE.sub(lambda m: _VERD.get(m.group(1), m.group(1)), cell)) | |
| def tab_supp_hm_subsets() -> pathlib.Path: | |
| rA, lA = _hms_table("1.1 Owner summary", _HMS_HDR_A) | |
| rB, lB = _hms_table("2.1 Owner summary", _HMS_HDR_B) | |
| rC1, lC1 = _hms_table("3.1 Owner summary", _HMS_HDR_C1) | |
| rC2, lC2 = _hms_table("3.2 Every class", _HMS_HDR_C2) | |
| chk, lchk = find_line(_HMS_PATH, "Generated ") | |
| m = re.search(r"Integrity check: (\d+) runs, (\d+) cells .*?max abs diff ([0-9.e+-]+); (\d+) mismatch", chk) | |
| if not m: | |
| raise ValueError("hm_subsets.md: integrity summary line not found") | |
| hdrA = ["Top $q$", "$n$", "Comparator", "CockpitWM (px)", "Comparator (px)", r"$\Delta$ mean $\pm$ sd (px)", r"CI excl.\ 0", "Verdict"] | |
| bodyA = [row(tx(r[0]), tx(r[1]), _hms_comp(r[2]), tx(r[3]), tx(r[4]), tx(r[5]), tx(r[6]), vd(r[7])) for r in rA] | |
| hdrB = [r"Subset (top 10\,\%)", "$n$", "Comparator", r"$\Delta$ all joints", r"CI excl.\ 0", "Verdict", r"$\Delta$ part joints", r"CI excl.\ 0", "Verdict"] | |
| bodyB = [row(tx(_HMS_PART.get(r[0], r[0])), tx(r[1]), _hms_comp(r[2]), tx(r[3]), tx(r[4]), vd(r[5]), tx(r[6]), tx(r[7]), vd(r[8])) for r in rB] | |
| hdrC1 = ["Subset", "$n$", "Comparator", "CockpitWM (px)", "Comparator (px)", r"$\Delta$ mean $\pm$ sd (px)", r"CI excl.\ 0", "Verdict"] | |
| bodyC1 = [row(tx(r[0]), tx(r[1]), _hms_comp(r[2]), tx(r[3]), tx(r[4]), tx(r[5]), tx(r[6]), vd(r[7])) for r in rC1] | |
| hdrC2 = ["Task", "Class", "$n$", "in HM", "GT motion (px)", "Zero-velocity", "CockpitWM", r"$\Delta$ vs zero-velocity", r"$\Delta$ vs Driver-WM arch.", r"$\Delta$ vs reproduction"] | |
| bodyC2 = [row(tx(r[0]), tx(r[1]), tx(r[2]), tx(r[3]), tx(r[4]), tx(r[5]), tx(r[6]), _hms_verd_inline(r[7]), _hms_verd_inline(r[8]), _hms_verd_inline(r[9])) for r in rC2] | |
| cap = (r"Appendix: rule-based alternatives to Driver-WM's official High-Motion (HM) subset on the AIDE test split ($n{=}609$; px), pre-registered before any " | |
| r"metric was computed; every subset is reported and none was used for selection or adoption. The official top-10\,\% HM subset ($n{=}60$, threshold 72.05 px) is the " | |
| r"only subset on which the published Driver-WM HM $h{=}5$ = 155.82 applies. Levels are seed means $\pm$ sd; $\Delta$ = paired per-clip difference CockpitWM $-$ comparator " | |
| r"on the subset (10k clip bootstrap per seed, seed 0; negative = CockpitWM better), mean $\pm$ sd over seeds with the number of seeds whose CI excludes 0 (k/n) and the " | |
| r"verdict of the standing rule (better / worse = CI excl.\ 0 on $\geq \lceil 2n/3 \rceil$ seeds, same sign on all; not worse = all CIs cover 0 and $|\Delta| < 0.25$ px; else n.s.). " | |
| r"Comparators: zero-velocity; the val-fitted ZV-shrink rules ($\alpha{=}0.44$; $\alpha_h{=}0.76\,h/5$); Driver-WM architecture on CockpitWM tokens (seed-matched, the " | |
| r"meaningful architecture comparator); our Driver-WM reproduction (seed-matched; All-MPJPE 130.86, it does not reproduce the published geometry, so these margins reflect " | |
| r"the reproduction, not Driver-WM as published). (A) top $q$ of the test clips by the official GT motion score (Eq.\ 16; $n = \lfloor q N \rfloor$). " | |
| r"(B) top 10\,\% by the motion score of one joint group (hands 94--135, face 26--93, body 0--25), $\Delta$ on all joints and on the defining part. " | |
| r"(C) label-defined subsets: the pre-specified reactive-manoeuvre union (VCR Turning / Backward Moving / Changing Lane or DBR Looking Around / Body Movement) and every class " | |
| r"of every AIDE task with its size, GT motion, zero-velocity and CockpitWM levels and the three paired $\Delta$s (k/n; verdict). " | |
| f"Integrity: the top-10\\,\\% and 100\\,\\% subsets reproduce the harness and master-table cells of all {m.group(1)} runs ({m.group(2)} cells, max abs.\\ difference {m.group(3)}, {m.group(4)} mismatches). " | |
| f"Sources: hm\\_subsets.md \\S{{}}1.1 (line {lA}), \\S{{}}2.1 (line {lB}), \\S{{}}3.1 (line {lC1}), \\S{{}}3.2 (line {lC2}), integrity line {lchk}.") | |
| return emit("tab_supp_hm_subsets", cap, | |
| [f"{_HMS_PATH} : §1.1 owner summary, motion-quantile sweep (table line {lA})", | |
| f"{_HMS_PATH} : §2.1 owner summary, part-specific subsets (table line {lB})", | |
| f"{_HMS_PATH} : §3.1 owner summary, reactive-manoeuvre union (table line {lC1})", | |
| f"{_HMS_PATH} : §3.2 every class as its own subset (table line {lC2})", | |
| f"{_HMS_PATH} : integrity summary (line {lchk})"], | |
| [("(A) Motion-quantile sweep: top q of the test clips by the official GT motion score; CockpitWM vs each comparator (horizon-averaged MPJPE, px)", | |
| "l r p{0.24\\linewidth} l l l l l", hdrA, bodyA), | |
| (r"(B) Part-specific top 10\,\% ($n{=}60$ by the hand / face / body motion score): paired $\Delta$ on all joints and on the defining part (px)", | |
| "l r p{0.22\\linewidth} l l l l l l", hdrB, bodyB), | |
| ("(C1) Reactive-manoeuvre union (VCR Turning / Backward Moving / Changing Lane or DBR Looking Around / Body Movement)", | |
| "p{0.16\\linewidth} r p{0.22\\linewidth} l l l l l", hdrC1, bodyC1), | |
| (r"(C2) Every AIDE class as its own subset: $n$, clips in the official HM, mean GT motion score, zero-velocity and CockpitWM levels, CockpitWM paired $\Delta$ (k/n; verdict)", | |
| "l p{0.12\\linewidth} r r r r l l l l", hdrC2, bodyC2)]) | |
| if _HMS_PATH.exists(): # lazy, as the K-v2 / master / formulation tables: a checkout without the report still generates everything else | |
| SRC["hm_subsets"] = _HMS_PATH | |
| ICLR_GENERATORS.append(tab_supp_hm_subsets) | |
| SHORT["tab_supp_hm_subsets"] = (r"Rule-based alternatives to the official High-Motion subset on AIDE test ($n{=}609$; descriptive, pre-registered, nothing selected). " | |
| r"Paired per-clip $\Delta$ = CockpitWM minus comparator in px (negative = better), mean $\pm$ sd over seeds, seeds with CI excluding 0, verdict. " | |
| r"(A) top $q$ by GT motion; (B) top 10\,\% by hand / face / body motion; (C) reactive-manoeuvre label union and every class.") | |
| OURS["tab_supp_hm_subsets"] = _NEVER # every row is a CockpitWM-vs-comparator Δ row; shading them all would carry no information | |
| ICLR_COLSPEC["tab_supp_hm_subsets"] = {0: tiny("l r p{0.24\\linewidth} l l l l l"), 1: tiny("l r p{0.22\\linewidth} l l l l l l"), | |
| 2: tiny("p{0.16\\linewidth} r p{0.22\\linewidth} l l l l l"), 3: tiny("l p{0.12\\linewidth} r r r r l l l l")} | |
| ICLR_COLSEP["tab_supp_hm_subsets"] = {1: "2pt", 3: "2pt"} # blocks (B) and (C2) carry nine / ten columns | |
| ICLR_NEWFLOAT["tab_supp_hm_subsets"] = {2} # (A)+(B) in the first float, (C1)+(C2) in a continuation float (four blocks exceed one page) | |
| # ---------------------------------------------------------------------------------------------- | |
| # Supplement table — calibration report: Brier scores and reliability complementing the ECE comparison of the warning read-out vs the openpilot | |
| # attention chain (results/tables/operating_points.md, section "Calibration report — Brier and reliability (both scores temperature-calibrated | |
| # on clean-val)", written by eval/calibration_report.py; append-only, the LAST such section is authoritative). Lazy: registered only when the | |
| # section exists. (A) per-seed ECE / Brier raw and after the clean-val temperature + score quantiles; (B) paired Δ Brier on identical rows; | |
| # (C) secondary Platt scaling; (D) the DMS layer-2 selected read-outs (withheld, see _CAL_INCLUDE_D). \input in Supp. C "Calibration: Brier scores and reliability" since 2026-09-15 (owner item 7). | |
| # ---------------------------------------------------------------------------------------------- | |
| _CAL_HEAD = "Calibration report — Brier and reliability (both scores temperature-calibrated on clean-val)" | |
| # Block (D) lists the five public driver-monitoring read-outs (Intel OMZ, MediaPipe / face rule, L2CS-Net, VideoMAEv2, ...) under the same | |
| # protocol. Placeholder P5 (PLACEHOLDERS.md) keeps every number and every word about these baselines out of the manuscript until the owner's | |
| # review gate, so the ICLR table is emitted with blocks (A)-(C) only; flip this flag after the owner review to append (D) as a continuation float. | |
| _CAL_INCLUDE_D = False | |
| # Round 5 (2026-09-18): the ICLR table is pinned to the ORIGINAL calibration run, the section whose heading carries this run stamp -- the one | |
| # the Supp. C / \S5.5 prose cites (\src{OP:513-553}); later appended sections (e.g. the ECAN re-fit, calibration_report_ecan_*) do not move the | |
| # pointers any more. Fallback (stamp absent): the LAST section, with a WARNING on stderr. Guard: blocks (A)-(C) of the pinned and of the LAST | |
| # section must carry identical numbers (true today: the ECAN read-out is bit-identical to the original), otherwise generation stops. | |
| _CAL_PIN_STAMP = "calibration_report_20260915T035901Z" | |
| def _cal_sections(): | |
| """Every calibration-report section of operating_points.md as (lines, 0-based heading index), in file order.""" | |
| ls = lines_of(SRC["op"]) | |
| found, start = [], 0 | |
| while True: | |
| try: | |
| sec, i0 = section(ls, _CAL_HEAD, start) | |
| except KeyError: | |
| break | |
| found.append((sec, i0)) | |
| start = i0 + 1 | |
| if not found: | |
| raise KeyError(_CAL_HEAD) | |
| return found | |
| def _cal_last_section(): | |
| """(lines, 0-based heading index) of the calibration-report section PINNED by _CAL_PIN_STAMP (fallback: the LAST section + WARNING).""" | |
| secs = _cal_sections() | |
| pinned = [s for s in secs if _CAL_PIN_STAMP in s[0][0]] | |
| if pinned: | |
| return pinned[0] | |
| print(f"WARNING: tab_supp_calibration: no calibration section carries the pinned run stamp {_CAL_PIN_STAMP}; using the LAST section " | |
| f"(heading line {secs[-1][1] + 1})", file=sys.stderr) | |
| return secs[-1] | |
| def _cal_blocks_abc(sec: list[str]) -> list[list[list[str]]]: | |
| """The table rows of blocks A (two tables) and C of one calibration section, for the identity guard.""" | |
| subA, _ = section(sec, "A. ") | |
| subC, _ = section(sec, "C. ") | |
| (hA, rA, _), (hP, rP, _) = md_tables(subA)[:2] | |
| hC, rC, _ = md_tables(subC)[0] | |
| return [rA, rP, rC] | |
| def _cal_has_section() -> bool: | |
| try: | |
| _cal_last_section() | |
| return True | |
| except (KeyError, FileNotFoundError): | |
| return False | |
| def _cal_tx(c: str) -> str: | |
| """tx() plus the two symbols of the calibration section that tx does not map (kept out of _UNI so no other table changes).""" | |
| return tx(c).replace("→", r"$\rightarrow$").replace("⊃", r"$\supset$") | |
| _CAL_N_RE = re.compile(r"\s*\(n \d+\)$") | |
| def tab_supp_calibration() -> pathlib.Path: | |
| op = SRC["op"] | |
| sec, i0 = _cal_last_section() | |
| last, i_last = _cal_sections()[-1] | |
| if i_last != i0 and _cal_blocks_abc(sec) != _cal_blocks_abc(last): # identity guard between the pinned and the LAST section | |
| raise ValueError(f"tab_supp_calibration: blocks (A)-(C) of the pinned calibration section (heading line {i0 + 1}) differ from the LAST " | |
| f"section (heading line {i_last + 1}); decide which run the table reports before regenerating") | |
| subA, jA = section(sec, "A. ") | |
| subB, jB = section(sec, "B. ") | |
| subC, jC = section(sec, "C. ") | |
| (hA, rA, kA), (hP, rP, kP) = md_tables(subA)[:2] | |
| hC, rC, kC = md_tables(subC)[0] | |
| cA = {k: col(hA, k) for k in ["score", "seed", "T (clean-val)", "ECE raw", "ECE cal", "Brier raw", "Brier cal", "paired Δ Brier cal", "p05 / p50 / p95"]} | |
| hdrA = ["Score", "Seed", "$T$ (clean-val)", "ECE raw", r"ECE cal.\ [CI]", "Brier raw", r"Brier cal.\ [CI]", r"p05 / p50 / p95 raw $\rightarrow$ cal."] | |
| bodyA = [row(*[_cal_tx(r[cA[k]]) for k in ["score", "seed", "T (clean-val)", "ECE raw", "ECE cal", "Brier raw", "Brier cal", "p05 / p50 / p95"]]) for r in rA] | |
| cP = {k: col(hP, k) for k in ["seed", "n rows / pos", "Δ Brier raw", "Δ Brier calibrated", "share of rows", "verdict"]} | |
| hdrP = ["Seed", "$n$ rows / pos", r"$\Delta$ Brier raw [CI]", r"$\Delta$ Brier cal.\ [CI]", "Share of rows where the read-out is closer", "Verdict (cal.)"] | |
| bodyP = [row(*[_cal_tx(r[cP[k]]) for k in ["seed", "n rows / pos", "Δ Brier raw", "Δ Brier calibrated", "share of rows", "verdict"]]) for r in rP] | |
| cC = {k: col(hC, k) for k in ["score", "seed", "a / b", "ECE Platt", "Brier Platt", "paired Δ Brier Platt", "p05 / p50 / p95 Platt"]} | |
| hdrC = ["Score", "Seed", "$a$ / $b$", "ECE Platt [CI]", "Brier Platt [CI]", r"Paired $\Delta$ Brier Platt vs att@3s [CI]", "p05 / p50 / p95 Platt"] | |
| bodyC = [row(*[_cal_tx(_CAL_N_RE.sub("", r[cC[k]])) for k in ["score", "seed", "a / b", "ECE Platt", "Brier Platt", "paired Δ Brier Platt", "p05 / p50 / p95 Platt"]]) for r in rC] | |
| blocks = [("(A) CockpitWM read-out vs the openpilot attention chain (att@3s): ECE and Brier on the clean-test gold, raw and after the clean-val temperature (both scores), per seed", | |
| "p{0.17\\linewidth} c l l l l l l", hdrA, bodyA), | |
| (r"(B) Paired $\Delta$ Brier (read-out $-$ chain) on the identical clean-test rows; negative = the read-out is closer to the outcome", | |
| "c l l l l l", hdrP, bodyP), | |
| ("(C) Secondary: Platt scaling (slope $a$ and bias $b$ on the logit, fitted on the same clean-val rows); the primary protocol is temperature-only", | |
| "p{0.17\\linewidth} c l l l l l", hdrC, bodyC)] | |
| srcs = [f"{op} : {_CAL_HEAD} / A (table line {i0 + jA + kA + 1}; paired table line {i0 + jA + kP + 1})", | |
| f"{op} : {_CAL_HEAD} / C Platt (table line {i0 + jC + kC + 1})"] | |
| try: | |
| if not _CAL_INCLUDE_D: | |
| raise KeyError("block (D) withheld") | |
| subD, jD = section(sec, "D. ") | |
| hD, rD, kD = md_tables(subD)[0] | |
| cD = {k: col(hD, k) for k in ["score", "seed", "T (clean-val)", "ECE raw", "ECE cal", "Brier raw", "Brier cal", "paired Δ Brier cal"]} | |
| hdrD = ["Read-out", "Seed", "$T$ (clean-val)", "ECE raw", r"ECE cal.\ [CI]", "Brier raw", r"Brier cal.\ [CI]", r"Paired $\Delta$ Brier cal.\ vs att@3s [CI]"] | |
| bodyD = [row(*[_cal_tx(_CAL_N_RE.sub("", r[cD[k]])) for k in ["score", "seed", "T (clean-val)", "ECE raw", "ECE cal", "Brier raw", "Brier cal", "paired Δ Brier cal"]]) for r in rD] | |
| blocks.append(("(D) DMS layer-2 selected read-outs on the same gold under the same temperature protocol; paired $\\Delta$ vs att@3s of the same seed", | |
| "p{0.30\\linewidth} c l l l l l l", hdrD, bodyD)) | |
| srcs.append(f"{op} : {_CAL_HEAD} / D layer-2 (table line {i0 + jD + kD + 1})") | |
| except KeyError: | |
| pass | |
| cap = (r"Calibration of the CockpitWM warning read-out and the openpilot attention chain (att@3s) on the clean-test gold (512 rows, 63 positives, 47 devices; the chain has 511 finite rows). " | |
| r"BOTH scores are temperature-calibrated on the clean-val gold (NLL on a log-spaced grid $[0.1, 20]$; `pinned' = fit at a grid edge) and evaluated on clean-test: ECE (15 equal-width bins) " | |
| r"and Brier (mean squared error) before / after calibration with device-cluster bootstrap CIs (2000 resamples); p05 / p50 / p95 of the raw and calibrated scores; " | |
| r"(B) paired $\Delta$ Brier on the identical rows (bootstrap over devices); (C) Platt scaling (slope + bias) as a secondary check because a temperature cannot move a score that lies above 0.5 below 0.5; " | |
| r"(D) the DMS layer-2 read-outs under the same protocol (withheld from the ICLR output until the owner review gate of placeholder P5). The constant clean-test prevalence (0.123) scores Brier 0.108. " | |
| f"Source: \\texttt{{{rel(op)}}}, section `{_CAL_HEAD}'.") | |
| return emit("tab_supp_calibration", cap, srcs, blocks) | |
| if _cal_has_section(): # lazy, as the K-v2 / master / formulation / HM-subset tables: registered only when the calibration section exists | |
| ICLR_GENERATORS.append(tab_supp_calibration) | |
| SHORT["tab_supp_calibration"] = (r"Calibration of the CockpitWM warning read-out and the openpilot-derived surrogate (att@3s) on the clean-test gold (512 rows, 63 positives). " | |
| r"ECE and Brier before and after a temperature fitted on clean validation for both scores, device-cluster bootstrap CIs; (B) paired Brier difference on identical rows; " | |
| r"(C) Platt scaling as a secondary check.") | |
| OURS["tab_supp_calibration"] = lambda cells, grp: bool(cells) and cells[0].startswith("CockpitWM read-out") # not the '+ CockpitWM current-state context' comparators of (D) | |
| ICLR_COLSPEC["tab_supp_calibration"] = {0: tiny("p{0.17\\linewidth} c l l l l l l"), 1: tiny("c l l l l l"), 2: tiny("p{0.17\\linewidth} c l l l l l"), | |
| 3: tiny("p{0.30\\linewidth} c l l l l l l")} | |
| ICLR_NEWFLOAT["tab_supp_calibration"] = {3} # (A)-(C) in the first float, the 37-row layer-2 block (D) in a continuation float | |
| # ---------------------------------------------------------------------------------------------- | |
| # Supplement table — Driver-WM Tables 2, 3 and 10 mirrored (owner item 5, 2026-09-15). Sources: the LAST '## Update' block of | |
| # aide/results/tables/driverwm_tables_headtohead.md (§2.2 axis-by-axis mirror of their Table 2; §3.2 their Table 3 with DEVIATION and the | |
| # ERROR CHANGE under each intervention in separate columns) and driverwm_v2_audit.md §6 (their Table 10: HM h=5 and HM hands h=5 under the | |
| # factual and intervened rollouts). Every number is the verbatim source string; row labels of ours are written in words (config + seed set). | |
| # Descriptive: nothing is adopted or selected from these tables. Lazy: emitted only with --style iclr when both sources exist. | |
| # ---------------------------------------------------------------------------------------------- | |
| _MIR_VERD_RE = re.compile(r"^(.*?)\s*\((BEATS|WORSE|INCONCLUSIVE|NOT_WORSE)(?:;.*)?\)\s*$", re.S) | |
| def _hh_last_update(path: pathlib.Path) -> tuple[list[str], int]: | |
| """Lines from the LAST '## Update' heading to the end of the head-to-head report (append-only file) and its 0-based index.""" | |
| ls = lines_of(path) | |
| starts = [i for i, l_ in enumerate(ls) if l_.startswith("## Update")] | |
| if not starts: | |
| raise KeyError("driverwm_tables_headtohead.md: no '## Update' block") | |
| return ls[starts[-1]:], starts[-1] | |
| def _mir_tx(c: str) -> str: | |
| """tx() plus the symbols of the two mirror reports that tx does not map; the seed-count suffix ' [n=3]' is dropped (the group row names the seeds).""" | |
| c = re.sub(r"\s*\[n=\d\]", "", c).replace("∅", "EMPTYSET").replace(" ᵃ", "ANALOGUE").replace("ᵃ", "ANALOGUE") | |
| s = tx(c) | |
| s = s.replace("EMPTYSET", r"$\emptyset$").replace("ANALOGUE", r"\textsuperscript{a}") | |
| s = s.replace(r"$\lambda$\_CA", r"$\lambda_{\mathrm{CA}}$").replace(r"$\lambda$CA", r"$\lambda_{\mathrm{CA}}$") | |
| return s | |
| def _mir_delta(cell: str) -> str: | |
| """'+0.27 ± 0.20 (INCONCLUSIVE; per seed +0.49 [...]; ...)' -> '+0.27 ± 0.20 (n.s.)' (numbers untouched; per-seed CIs stay in the source).""" | |
| c = cell.strip() | |
| if c in ("—", "–", "-", ""): | |
| return "--" | |
| m = _MIR_VERD_RE.match(c) | |
| if not m: | |
| return tx(c) | |
| return tx(m.group(1).strip()) + " (" + _VERD[m.group(2)] + ")" | |
| _MIR_SUB = {"CockpitWM_5seeds": "CockpitWM, 5 seeds", "B2_main_3seeds": "CockpitWM (+ semantic heads), geometry checkpoint (a), 3 seeds", | |
| "viewgate_a_3seeds": "CockpitWM (+ semantic heads), view-gate heads, geometry checkpoint (a), 3 seeds", | |
| "viewgate_reading_a": "(a)", "viewgate_reading_b": "(b)"} | |
| # our analogue of each published axis, in words (the source cell is a paragraph of run names); numbers never appear here | |
| _MIR_ANALOGUE = { | |
| "w/o ext context": "keypoint-only CockpitWM minus CockpitWM (+ semantic heads), geometry checkpoint (a), same seed; the heads and the loss change with the exterior input, so this is not a clean single-axis pair; F1: trunk-state heads without vision minus geometry checkpoint (a)", | |
| "RSSM/GRU dyn.": "recursive one-step decoding minus CockpitWM, same seed (no recurrent latent-dynamics variant of CockpitWM exists)", | |
| "+Skeleton-Pre": "+ BATON in-cabin pose pretraining of the trunk minus seed initialisation, same seed (three model families, one row each)", | |
| "KL bottleneck": "none: CockpitWM has no stochastic latent on AIDE", | |
| "no-prompt feat.": "vision tokens pooled without the text prompt minus CockpitWM (+ semantic heads), same seed; F1 from the trunk-state heads", | |
| "no pose head": "frozen-feature semantic-only reference (no trunk) minus view-gate heads, semantic checkpoint (b); F1 only", | |
| "Non-causal": "none by design: the encoder is causal", | |
| } | |
| _MIR_T3_MODELS = [("CockpitWM (+ semantic heads), B2 main — no traffic gate", "CockpitWM (+ semantic heads), geometry checkpoint (a), 3 seeds (no traffic gate; the g = 0 / $\\lambda_{\\mathrm{CA}}$ = 2 rows are exterior-token scaling analogues\\textsuperscript{a})"), | |
| ("CockpitWM (+ semantic heads), view-gate heads — reading-(a) checkpoint", "CockpitWM (+ semantic heads), view-gate heads, geometry checkpoint (a), 3 seeds"), | |
| ("CockpitWM (+ semantic heads) + traffic gate (iii)", "CockpitWM (+ semantic heads) + traffic gate, geometry checkpoint (a), 3 seeds"), | |
| ("Driver-WM reproduction (our port)", "Driver-WM reproduction (our port), 3 seeds")] | |
| # column specs of the three mirror blocks on the 5.5-in page (first compile 2026-09-15: (A) 95.8 pt and (C) 16.1 pt too wide with 'l' Δ columns | |
| # and a 0.07-linewidth All column): every column is a fixed-width p{} so that the sum plus \tabcolsep stays below the text width | |
| _MIR_SPEC_A = "p{0.085\\linewidth} p{0.14\\linewidth} p{0.24\\linewidth} p{0.085\\linewidth} p{0.085\\linewidth} p{0.085\\linewidth} p{0.16\\linewidth}" | |
| _MIR_SPEC_B = "p{0.13\\linewidth} p{0.19\\linewidth} r p{0.27\\linewidth} p{0.27\\linewidth}" | |
| _MIR_SPEC_C = "p{0.12\\linewidth} p{0.08\\linewidth} p{0.11\\linewidth} p{0.19\\linewidth} p{0.11\\linewidth} p{0.19\\linewidth} p{0.09\\linewidth}" | |
| _MIR_T10_GROUPS = ["Zero velocity (parameter-free; no exterior input, no interventions)", "CockpitWM, 3 seeds (keypoints only; no exterior input)", | |
| "CockpitWM (+ semantic heads), geometry checkpoint (a), 3 seeds (no traffic gate)", "CockpitWM (+ semantic heads) + traffic gate, geometry checkpoint (a), 3 seeds", | |
| "Driver-WM reproduction (our port), 3 seeds"] | |
| def tab_supp_driverwm_mirror() -> pathlib.Path: | |
| hh, v2 = SRC["headtohead"], SRC["v2_audit"] | |
| blk, i0 = _hh_last_update(hh) | |
| # (A) their Table 2 axes (§2.2 of the last block) | |
| secA, jA = section(blk, "2.2 Axis-by-axis") | |
| hA, rA, kA = md_tables(secA)[0] | |
| cA = {k: col(hA, k) for k in ["their ablation", "their Δ vs Driver-WM main", "our Δ All", "our Δ HM", "our Δ PCK@0.05", "our Δ F1", "status"]} | |
| hdrA = ["Their ablation", r"Their $\Delta$ (All / HM / PCK / DBR / DER / TCR / VCR)", "Our analogue (paired per clip, same seed)", r"Our $\Delta$ All", r"Our $\Delta$ HM", | |
| r"Our $\Delta$ PCK@0.05", r"Our $\Delta$ F1 DBR / DER / TCR / VCR"] | |
| bodyA = [] | |
| for r in rA: | |
| name = r[cA["their ablation"]].strip() | |
| theirs = [p.strip() for p in r[cA["their Δ vs Driver-WM main"]].split("/")] | |
| if len(theirs) != 9: | |
| raise ValueError(f"head-to-head §2.2: unexpected 'their Δ' cell for {name!r}: {r[cA['their Δ vs Driver-WM main']]!r}") | |
| their = tx(" / ".join(theirs[i] for i in (0, 2, 4, 5, 6, 7, 8))) | |
| ana = _MIR_ANALOGUE[name] | |
| f1 = r[cA["our Δ F1"]].strip() | |
| subs = r[cA["our Δ All"]].split("<br>") | |
| if len(subs) > 1: # several model families on one axis (+Skeleton-Pre): one row per family, the axis named on the first | |
| hm_s, pck_s = r[cA["our Δ HM"]].split("<br>"), r[cA["our Δ PCK@0.05"]].split("<br>") | |
| if not (len(hm_s) == len(pck_s) == len(subs)): | |
| raise ValueError(f"head-to-head §2.2: sub-result counts differ for {name!r}") | |
| f1_s = dict(p.split(":", 1) for p in f1.split("<br>")) if ":" in f1 else {} | |
| for j, s in enumerate(subs): | |
| key, val = s.split(":", 1) | |
| key = key.strip() | |
| lab = _MIR_SUB[key] | |
| f1cell = "--" | |
| if key == "viewgate_a_3seeds" and f1_s: # the F1 sub-results belong to the view-gate model (readings (a) and (b)) | |
| f1cell = tx("; ".join(f"{_MIR_SUB[k.strip()]}: {v.strip()}" for k, v in f1_s.items())) | |
| bodyA.append(row(tx(name) if j == 0 else "", their if j == 0 else "", (ana + "; " if j == 0 else "") + lab, | |
| _mir_delta(val), _mir_delta(hm_s[j].split(":", 1)[1]), _mir_delta(pck_s[j].split(":", 1)[1]), f1cell)) | |
| else: | |
| f1cell = "--" if f1 in ("—", "–", "") else tx(f1) | |
| bodyA.append(row(tx(name), their, ana, _mir_delta(r[cA["our Δ All"]]), _mir_delta(r[cA["our Δ HM"]]), _mir_delta(r[cA["our Δ PCK@0.05"]]), f1cell)) | |
| # (B) their Table 3 interventions with deviation and error change in separate columns (§3.2 of the last block) | |
| secB, jB = section(blk, "3.2 Ours in the same layout") | |
| hB, rB, kB = md_tables(secB)[0] | |
| c_int, c_pd, c_pp = col(hB, "paper intervention"), col(hB, "paper Δ All"), col(hB, "paper Δ/All") | |
| hdrB = ["Intervention", r"Paper deviation All / HM / $h{=}5$ / Head / Hands (px)", r"Paper $\Delta$/All", r"Our deviation All ($\Delta$/All) $\cdot$ HM $\cdot$ $h{=}5$ $\cdot$ Head $\cdot$ Hands (px)", | |
| r"Our error change: All-MPJPE under do($\cdot$) vs factual [paired $\Delta$; seeds with CI excl.\ 0]"] | |
| bodyB = [] | |
| for key, glabel in _MIR_T3_MODELS: | |
| hits = [i for i, h in enumerate(hB) if h.startswith(key + ":") and "Δ All" in h] | |
| if len(hits) != 1: | |
| raise ValueError(f"head-to-head §3.2: deviation column for {key!r} not found exactly once in {hB!r}") | |
| cd = hits[0] | |
| if "All-MPJPE under do" not in hB[cd + 1] or not hB[cd + 1].startswith(key + ":"): | |
| raise ValueError(f"head-to-head §3.2: deviation / error columns not adjacent for {key!r}") | |
| bodyB.append(group(5, glabel)) | |
| for r in rB: | |
| bodyB.append(row(_mir_tx(r[c_int]), tx(r[c_pd]), tx(r[c_pp]), _mir_tx(r[cd]), _mir_tx(r[cd + 1]))) | |
| bodyB.append(r"\midrule") | |
| bodyB.pop() | |
| # (C) their Table 10 (audit §6): HM h=5 and HM hands h=5, factual and intervened | |
| secC, jC = section(lines_of(v2), "§6 Mirror of Table 10") | |
| tabsC = md_tables(secC) | |
| if len(tabsC) != len(_MIR_T10_GROUPS): | |
| raise ValueError(f"driverwm_v2_audit.md §6: expected {len(_MIR_T10_GROUPS)} tables, found {len(tabsC)}") | |
| hdrC = ["Setting", r"Paper HM $h{=}5$ / hands", r"Our HM $h{=}5$ [CI]", r"Paired $\Delta$ vs factual per seed [CI]", r"Our HM hands $h{=}5$ [CI]", r"Paired $\Delta$ hands per seed [CI]", "Our All-MPJPE"] | |
| bodyC = [] | |
| for glabel, (hC, rC, kC) in zip(_MIR_T10_GROUPS, tabsC): | |
| if len(hC) != 7: | |
| raise ValueError(f"driverwm_v2_audit.md §6: unexpected header {hC!r}") | |
| bodyC.append(group(7, glabel)) | |
| for r in rC: | |
| bodyC.append(row(*[_mir_tx(c) for c in r])) | |
| bodyC.append(r"\midrule") | |
| bodyC.pop() | |
| lA, lB, lC = i0 + jA + kA + 1, i0 + jB + kB + 1, jC + 1 | |
| cap = (r"Appendix: Driver-WM Tables 2, 3 and 10 mirrored on our runs (AIDE test, $n{=}609$; HM = 60 clips). (A) their Table 2 ablation axes with our closest paired analogue " | |
| r"(same seed, per-clip 10k clip bootstrap; verdict rule as baton\_pretrain.md); (B) their Table 3 interventions with the deviation of the intervened rollout and the change of " | |
| r"its ground-truth error reported in separate columns; (C) their Table 10 HM $h{=}5$ and HM hands $h{=}5$ under the factual and intervened rollouts. Published cells are single runs without CIs. " | |
| f"Sources: driverwm\\_tables\\_headtohead.md last update block §2.2 (line {lA}), §3.2 (line {lB}); driverwm\\_v2\\_audit.md §6 (from line {lC}).") | |
| return emit("tab_supp_driverwm_mirror", cap, | |
| [f"{hh} : last '## Update' block, §2.2 axis-by-axis mirror of their Table 2 (table line {lA})", | |
| f"{hh} : last '## Update' block, §3.2 their Table 3 with deviation and accuracy (table line {lB})", | |
| f"{v2} : §6 mirror of their Table 10, HM h=5 and HM hands h=5 (section from line {lC})"], | |
| [("(A) Their Table 2 ablation axes and our closest paired analogue (px; F1 in \\%; their values are single runs; every mirrored axis is descriptive)", _MIR_SPEC_A, hdrA, bodyA), | |
| ("(B) Their Table 3 interventions: deviation of the intervened rollout and change of its ground-truth error, in separate columns (px)", _MIR_SPEC_B, hdrB, bodyB), | |
| ("(C) Their Table 10: HM $h{=}5$ and HM hands $h{=}5$ (px) under the factual and intervened rollouts", _MIR_SPEC_C, hdrC, bodyC)]) | |
| # ---------------------------------------------------------------------------------------------- | |
| # Supplement table — risk-ranking proxy of the Driver-WM paper (their Table 12) mirrored (owner item 12, 2026-09-15): positives = the 60 | |
| # official high-motion test clips; scores ranked by AUROC / AUPRC / recall at 10 % FPR. Source: driverwm_v2_audit.md §5 (ours; every cell | |
| # verbatim) and the §1.1 'Table 12' line (their four rows). The paper does not state its combination rule; ours is an equal-weight sum of | |
| # validation-z-scored components, so the composite rows are our reading of their description (caption). Lazy, ICLR only. | |
| # ---------------------------------------------------------------------------------------------- | |
| _RR_MODEL = [("CockpitWM-K-v2 no-spatial (`cwm3d_v2_nospatial_s*_v2`, 5 seeds)", "validation-screened CockpitWM variant (nospatial), 5 seeds"), | |
| ("CockpitWM-K-v2 no-spatial + BATON trunk (5 seeds)", "validation-screened CockpitWM variant (nospatial) + BATON pretraining, 5 seeds"), | |
| ("observed-window motion (GT displacement of the last observed transition; parameter-free)", "Observed-window motion: ground-truth displacement of the last observed transition (no model)"), | |
| ("CockpitWM (+ semantic heads), B2 main (3 seeds)", "CockpitWM (+ semantic heads), geometry checkpoint (a), 3 seeds"), | |
| ("CockpitWM (+ semantic heads), view-gate heads (a) (3 seeds)", "CockpitWM (+ semantic heads), view-gate heads, geometry checkpoint (a), 3 seeds"), | |
| ("CockpitWM (+ semantic heads), view-gate heads (b) (3 seeds)", "CockpitWM (+ semantic heads), view-gate heads, semantic checkpoint (b), 3 seeds"), | |
| ("CockpitWM (+ semantic heads) + BATON trunk, view-gate (a) (3 seeds)", "CockpitWM (+ semantic heads) + BATON pretraining, view-gate heads, geometry checkpoint (a), 3 seeds"), | |
| ("CockpitWM + BATON trunk (5 seeds)", "CockpitWM + BATON pretraining, 5 seeds"), | |
| ("CockpitWM (3 locked seeds)", "CockpitWM, 3 seeds (42 / 123 / 456)"), ("CockpitWM (5 seeds)", "CockpitWM, 5 seeds"), | |
| ("Driver-WM reproduction (3 seeds)", "Driver-WM reproduction (our port), 3 seeds")] | |
| _RR_SCORE = [("+ driver semantics + uncertainty", "predicted motion + driver semantics + uncertainty (our reading)"), | |
| ("+ driver semantics", "predicted motion + driver semantics (our reading)"), ("+ uncertainty", "predicted motion + seed-variance uncertainty"), | |
| ("motion only", "predicted motion (their Eq.\\ 16 on the five predicted frames)"), | |
| ("onset-hazard probability haz_P (max", "onset-hazard probability, max over parts and horizons"), | |
| ("onset-hazard probability haz_P (mean", "onset-hazard probability, mean over parts and horizons")] | |
| _RR_P_RE = re.compile(r"\s*\(P\(Δ ≤ 0\) = [0-9.]+\)\s*$") | |
| _RR_SPEC = "p{0.34\\linewidth} p{0.145\\linewidth} p{0.145\\linewidth} p{0.145\\linewidth} p{0.14\\linewidth}" | |
| def _rr_label(raw: str) -> str: | |
| raw = raw.replace("**", "").strip() | |
| model, _, score = raw.partition(" — ") | |
| for a, b in _RR_MODEL: | |
| if model.strip() == a: | |
| model = b | |
| break | |
| else: | |
| raise ValueError(f"driverwm_v2_audit.md §5: unmapped model label {model!r}") | |
| if not score: | |
| return model | |
| for a, b in _RR_SCORE: | |
| if score.startswith(a): | |
| return f"{model}; {b}" | |
| raise ValueError(f"driverwm_v2_audit.md §5: unmapped score label {score!r}") | |
| def tab_supp_risk_ranking() -> pathlib.Path: | |
| v2 = SRC["v2_audit"] | |
| sec5, j5 = section(lines_of(v2), "§5 Mirror of Table 12") | |
| h5, r5, k5 = md_tables(sec5)[0] | |
| c5 = {k: col(h5, k) for k in ["score", "seeds", "AUROC", "AUPRC", "R@10%FPR", "paired ΔAUPRC"]} | |
| t12, l12 = find_line(v2, "**Table 12 (dump") | |
| m = re.search(r"Motion only: (\d+\.\d+) / (\d+\.\d+) / (\d+\.\d+); \+ driver semantics: (\d+\.\d+) / (\d+\.\d+) / (\d+\.\d+); \+ uncertainty: (\d+\.\d+) / (\d+\.\d+) / (\d+\.\d+); " | |
| r"\+ driver semantics \+ uncertainty: (\d+\.\d+) / (\d+\.\d+) / (\d+\.\d+)", t12) | |
| if not m: | |
| raise ValueError("driverwm_v2_audit.md §1.1: Table 12 line not parseable") | |
| g = m.groups() | |
| hdr = ["Score (model; seed set in the label)", "AUROC [CI]", "AUPRC [CI]", r"Recall at 10\,\% FPR [CI]", r"Paired $\Delta$AUPRC vs the same model's predicted motion [CI]"] | |
| body = [group(5, "Published (Driver-WM paper, Table 12; single run; combination rule and the probabilities used are not stated)")] | |
| for lab, i in [("Driver-WM main, single run: motion only", 0), ("Driver-WM main, single run: + driver semantics", 3), ("Driver-WM main, single run: + uncertainty", 6), | |
| ("Driver-WM main, single run: + driver semantics + uncertainty", 9)]: | |
| body.append(row(lab, g[i], g[i + 1], g[i + 2], "--")) | |
| body += [r"\midrule", group(5, "Ours (positives = the 60 official high-motion test clips; 10k clip bootstrap, one shared resample matrix; seed-mean score)")] | |
| for r in r5: | |
| d = _RR_P_RE.sub("", r[c5["paired ΔAUPRC"]].strip()) | |
| body.append(row(_rr_label(r[c5["score"]]), tx(r[c5["AUROC"]]), tx(r[c5["AUPRC"]]), tx(r[c5["R@10%FPR"]]), "--" if d in ("–", "—", "-") else tx(d))) | |
| cap = (r"Appendix: the risk-ranking proxy of the Driver-WM paper (its Table 12) on our runs: positives = the 60 official high-motion AIDE test clips (top 10\,\% by the paper's Eq.\ 16), " | |
| r"random AUPRC = 60/609; AUROC, AUPRC and recall at 10\,\% FPR with 10k clip-bootstrap CIs; paired $\Delta$AUPRC of each composite against the same model's predicted-motion score. " | |
| r"The paper does not state its combination rule or which DBR / DER probabilities enter; ours = equal-weight sum of validation-z-scored components. Descriptive, nothing adopted. " | |
| f"Sources: driverwm\\_v2\\_audit.md §5 (table line {j5 + k5 + 1}), §1.1 Table 12 line {l12}.") | |
| return emit("tab_supp_risk_ranking", cap, | |
| [f"{v2} : §5 mirror of Table 12 (table line {j5 + k5 + 1})", f"{v2} : §1.1 Table 12 published values (line {l12})"], | |
| [(None, _RR_SPEC, hdr, body)]) | |
| if _V2_PATH.exists() and _HH_PATH.exists(): | |
| ICLR_GENERATORS.append(tab_supp_driverwm_mirror) | |
| if _V2_PATH.exists(): | |
| ICLR_GENERATORS.append(tab_supp_risk_ranking) | |
| SHORT["tab_supp_driverwm_mirror"] = (r"Driver-WM Tables 2, 3 and 10 mirrored on our AIDE runs (test, $n{=}609$; published cells are single runs). (A) Their ablation axes and our closest " | |
| r"paired analogue (same seed; $\Delta$ in px, negative = better). (B) Their interventions: rollout deviation and error change in separate " | |
| r"columns. (C) High-motion error at $h{=}5$, all joints and hands, factual and intervened.") | |
| SHORT["tab_supp_risk_ranking"] = (r"Risk-ranking proxy of the Driver-WM paper on AIDE test: positives are the 60 highest-motion clips; AUROC, AUPRC and recall at 10\,\% FPR " | |
| r"(higher is better) with clip-bootstrap CIs. Published rows are single runs with an unstated combination rule; our composites are an " | |
| r"equal-weight sum of validation-standardised components. Descriptive only.") | |
| OURS["tab_supp_driverwm_mirror"] = _NEVER # every row pairs ours with theirs; shading carries no information | |
| OURS["tab_supp_risk_ranking"] = lambda cells, grp: cells[0].startswith(("CockpitWM", "validation-screened CockpitWM")) | |
| CAND["tab_supp_risk_ranking"] = _NEVER # levels are descriptive (CIs overlap); no per-column bold | |
| ICLR_COLSPEC["tab_supp_driverwm_mirror"] = {0: tiny(_MIR_SPEC_A), 1: tiny(_MIR_SPEC_B), 2: tiny(_MIR_SPEC_C)} | |
| ICLR_COLSEP["tab_supp_driverwm_mirror"] = {1: "2pt", 2: "2pt"} | |
| # ---------------------------------------------------------------------------------------------- | |
| # Supplement table — pre-registered pretraining programme P1 / P1-ext / P2 / P3 (aide/results/tables/pretrain_variants.md, written by | |
| # aide/eval/report_pretrain_variants.py from run outputs only; append-only, the LAST block — introduced by the heading | |
| # '# Pre-registered pretraining experiments' — is authoritative). Owner decisions 2026-09-15 (docs/decisions.md 13:33:33Z and the | |
| # placement row of this round): the matched CONVERGED-recipe comparison (P3) enters Supp. D regardless of direction; the main text names | |
| # the Driver-WM architecture (P2, with and without pretraining) and the ST-GCN architecture; the MotionBERT-architecture control stays in | |
| # Supp. D with factual framing. The earlier six-epoch matched runs (*_batonpre_trunkp123_*, *_batonpre_pretrain_s123 of the MotionBERT / | |
| # ST-GCN families, do0.1) remain omitted (OMIT_ROWS_OWNER_20260915, superseded by P3). | |
| # ---------------------------------------------------------------------------------------------- | |
| _PV_PATH = AT / "pretrain_variants.md" | |
| _PV_CELLS = ["All-MPJPE", "d-n", "HM-MPJPE", "PCK@0.05", "HM h=5"] | |
| _PV_SEEDS3 = ["42", "123", "456"] | |
| _PV_SEEDS5 = ["42", "123", "456", "789", "1011"] | |
| _PV_VARIANT_WORDS = { # §0 definitions in words (the source carries the command-line flags) | |
| "reference (adopted)": "six epochs, four loss terms (the paper's pretraining row)", | |
| "euc": "six epochs, Euclidean loss only", | |
| "scale": "six epochs, four loss terms, motion-scale aug.\\ to 2.5", | |
| "conv": "convergence schedule (cap 36, patience 4), four loss terms", | |
| "conveuc": "convergence schedule, Euclidean loss only (selected on validation)", | |
| "convscale": "convergence schedule, four loss terms, motion-scale aug.\\ to 2.5", | |
| } | |
| _PV_PRETRAIN_RUNS = [ # (label, run name of the pretraining, schedule note) | |
| ("CockpitWM (selected recipe)", "cwm3d_kp_batonpre_pretrain_conveuc_s123", "converged, Euclidean"), | |
| ("MotionBERT arch.\\ on CockpitWM tokens", "motionbert_kp_batonpre_pretrain_conv_s123", "converged, Euclidean"), | |
| ("ST-GCN arch.\\ on CockpitWM tokens", "stgcn_kp_batonpre_pretrain_conv_s123", "converged, Euclidean"), | |
| ("Driver-WM arch.\\ on CockpitWM tokens", "driverwm_kp_batonpre_pretrain_s123", "six epochs, Euclidean"), | |
| ] | |
| _PV_RUN_RE = re.compile(r"\*\*(\d+) epochs run, best epoch (\d+) \(held-out-route All-MPJPE ([\d.]+) px\), stop = ([^;]+); ([\d.]+) ms/step, ([\d.]+) GPU-min\*\*") | |
| def _pv_last_block(ls: list[str]) -> int: | |
| starts = [i for i, l_ in enumerate(ls) if l_.startswith("# Pre-registered pretraining experiments")] | |
| if not starts: | |
| raise KeyError("pretrain_variants.md: no '# Pre-registered pretraining experiments' heading") | |
| return starts[-1] | |
| def _pv_table(path: pathlib.Path, heading_prefix: str, *sub_prefixes: str, table_idx: int = 0): | |
| """(header, rows, absolute 1-based header line) of table `table_idx` in the section of the LAST block whose heading starts with | |
| `heading_prefix`, narrowed successively to the sub-sections `sub_prefixes`.""" | |
| ls = lines_of(path) | |
| sec, i0 = section(ls, heading_prefix, _pv_last_block(ls)) | |
| for sp in sub_prefixes: | |
| sec, k = section(sec, sp) | |
| i0 += k | |
| header, rows, k = md_tables(sec)[table_idx] | |
| return header, rows, i0 + k + 1 | |
| def _pv_cell(rows, header, cell: str, column: str) -> str: | |
| r = find_row(rows, col(header, "cell"), cell) | |
| v = r[col(header, column)].strip() | |
| if not v: | |
| raise ValueError(f"pretrain_variants.md: empty cell {cell!r} / {column!r}") | |
| return v | |
| def _pv_pretrain_run(pv: pathlib.Path, run: str) -> tuple[str, str, str, str, str, str, int]: | |
| """(params, epochs run, best epoch, held-out All px, stop rule in words, GPU-min, 1-based line) of a pretraining bullet of the last block.""" | |
| ln, k = find_line(pv, f"- `{run}`", _pv_last_block(lines_of(pv))) | |
| m_par = re.search(r"\): ([\d,]+) params", ln) | |
| m_run = _PV_RUN_RE.search(ln) | |
| if not (m_par and m_run): | |
| raise ValueError(f"pretrain_variants.md: pretraining bullet of {run} not parseable (line {k})") | |
| stop = m_run.group(4).strip() | |
| stop_w = "early stop, patience 4" if stop.startswith("early_stop(patience=4)") else ("epoch cap" if stop == "epochs" else tx(stop)) | |
| return m_par.group(1), m_run.group(1), m_run.group(2), m_run.group(3), stop_w, m_run.group(6), k | |
| def tab_supp_pretrain_variants() -> pathlib.Path: | |
| pv = SRC["pretrain_variants"] | |
| # ---- (A) P1: CockpitWM pretraining variants — §0 recipe-selection table + §2.6 overview (test Δ vs the adopted arm and vs seed init) | |
| h0, r0, l0 = _pv_table(pv, "0. Recipe-selection") | |
| c0 = {k: col(h0, k) for k in ["variant", "n fine-tunes finished", "mean val All", "mean test All", "pretraining GPU-min"]} | |
| h26, r26, l26 = _pv_table(pv, "2. P1 fine-tunes", "2.6 Overview") | |
| c26 = {k: col(h26, k) for k in ["variant", "test All mean", "Δ All vs adopted", "verdict vs adopted", "Δ All vs seed init", "verdict vs seed init", "HM vs adopted", "PCK@0.05 vs adopted"]} | |
| sec26, i26 = section(lines_of(pv), "2. P1 fine-tunes", _pv_last_block(lines_of(pv))) | |
| sec26, k26 = section(sec26, "2.6 Overview") | |
| m_ref = re.search(r"adopted arm = ([\d.]+ ± [\d.]+), seed init = ([\d.]+ ± [\d.]+)", sec26[0]) | |
| if not m_ref: | |
| raise ValueError("pretrain_variants.md §2.6: heading without the adopted-arm / seed-init means") | |
| ref_test, seed_test = m_ref.group(1), m_ref.group(2) | |
| hdrA = ["Variant", "Pretraining schedule (five fine-tuned seeds each)", "val All", "test All", r"$\Delta$ vs adopted", "verdict", r"$\Delta$ vs seed init", "verdict", "GPU-min"] | |
| bodyA = [] | |
| for r in r0: | |
| v = r[c0["variant"]].strip() | |
| if v not in _PV_VARIANT_WORDS: | |
| raise ValueError(f"pretrain_variants.md §0: unknown variant {v!r} (add it to _PV_VARIANT_WORDS)") | |
| if v.startswith("reference"): | |
| if r[c0["n fine-tunes finished"]].strip() != "5": | |
| raise ValueError("pretrain_variants.md §0: the reference arm does not list five fine-tunes") | |
| bodyA.append(row("adopted arm (reference)", _PV_VARIANT_WORDS[v], tx(r[c0["mean val All"]]), tx(ref_test), "--", "--", "--", "--", tx(r[c0["pretraining GPU-min"]]))) | |
| continue | |
| o = find_row(r26, c26["variant"], v) | |
| if o[c26["variant"]].strip() != v: | |
| raise ValueError(f"pretrain_variants.md §2.6: row {v!r} not found verbatim") | |
| if r[c0["n fine-tunes finished"]].strip() != "5": | |
| raise ValueError(f"pretrain_variants.md §0: variant {v!r} does not list five fine-tunes") | |
| bodyA.append(row(r"\texttt{" + tx(v) + "}", _PV_VARIANT_WORDS[v], tx(r[c0["mean val All"]]), tx(o[c26["test All mean"]]), | |
| tx(o[c26["Δ All vs adopted"]]), vd(o[c26["verdict vs adopted"]]), tx(o[c26["Δ All vs seed init"]]), vd(o[c26["verdict vs seed init"]]), | |
| tx(r[c0["pretraining GPU-min"]]))) | |
| bodyA.append(row("seed initialisation (no pretraining)", "--", "--", tx(seed_test), "--", "--", "--", "--", "--")) | |
| # ---- (B) P2: Driver-WM architecture on CockpitWM tokens + BATON pretraining — per-seed levels (§3.1) and paired Δ (§3.2, §3.3) | |
| h31, r31, l31 = _pv_table(pv, "3. P2", "3.1 Fine-tunes") | |
| c31 = {k: col(h31, k) for k in ["seed", "run", "val All", "All [CI]", "d-n [CI]", "HM [CI]", "PCK@0.05 [CI]", "HM h=5 [CI]"]} | |
| hdrB1 = ["Seed", "val All", "All [CI]", "d-n [CI]", "HM [CI]", "PCK@0.05 [CI]", r"HM $h{=}5$ [CI]"] | |
| bodyB1 = [] | |
| for s in _PV_SEEDS3: | |
| r = find_row(r31, c31["run"], f"driverwm_kp_batonpre_trunkp123_s{s}_v2") | |
| if r[c31["seed"]].strip() != s: | |
| raise ValueError(f"pretrain_variants.md §3.1: seed column mismatch for seed {s}") | |
| bodyB1.append(row(s, *[tx(r[c31[k]]) for k in ["val All", "All [CI]", "d-n [CI]", "HM [CI]", "PCK@0.05 [CI]", "HM h=5 [CI]"]])) | |
| h32, r32, l32 = _pv_table(pv, "3. P2", "3.2 (i)") | |
| h33, r33, l33 = _pv_table(pv, "3. P2", "3.3 (ii)") | |
| hdrB2 = ["Cell"] + [rf"$\Delta$ s{s} [CI]" for s in _PV_SEEDS3] + [r"mean $\Delta$ $\pm$ sd", "verdict"] | |
| def rows3(hdr, rows) -> list[str]: | |
| return [row(tx(cell), *[tx(_pv_cell(rows, hdr, cell, f"Δ s{s} [CI]")) for s in _PV_SEEDS3], | |
| tx(_pv_cell(rows, hdr, cell, "mean Δ ± sd")), vd(_pv_cell(rows, hdr, cell, "verdict"))) for cell in _PV_CELLS] | |
| bodyB2 = [group(6, "pretrained $-$ from seed initialisation, Driver-WM architecture (does the pretraining help this architecture?)")] + rows3(h32, r32) + \ | |
| [r"\midrule", group(6, "pretrained Driver-WM architecture $-$ pretrained CockpitWM (both trunks pretrained on the same corpus)")] + rows3(h33, r33) | |
| # ---- (C) pretraining runs under the converged recipe (bullets of §1.5, §4.1, §4.2; P2 six-epoch run for reference) | |
| hdrC = ["Architecture (pretraining run)", "Schedule", "Params", "Epochs run / best", "Held-out All (px)", "Stop", "GPU-min"] | |
| bodyC, lC = [], [] | |
| for label, run, sched in _PV_PRETRAIN_RUNS: | |
| params, ep, best, ho, stop_w, gmin, k = _pv_pretrain_run(pv, run) | |
| lC.append(k) | |
| bodyC.append(row(label, sched, tx(params), f"{ep} / {best}", ho, stop_w, gmin)) | |
| # ---- (D) P3 per-seed test levels of the three matched architectures (level columns of the §4.1 / §4.2 Δ tables; CockpitWM = conveuc fine-tunes) | |
| hMB, rMB, lMB = _pv_table(pv, "4. P3", "4.1 MotionBERT", "Δ = CockpitWM") | |
| hST, rST, lST = _pv_table(pv, "4. P3", "4.2 ST-GCN", "Δ = CockpitWM") | |
| hdrD = ["Architecture, cell"] + [f"seed {s}" for s in _PV_SEEDS5] | |
| def levels(hdr, rows, side: str, cell: str) -> list[str]: | |
| return [tx(_pv_cell(rows, hdr, cell, f"{side} s{s}")) for s in _PV_SEEDS5] | |
| bodyD = [] | |
| for cell, word in [("All-MPJPE", "All-MPJPE"), ("HM-MPJPE", "HM-MPJPE"), ("PCK@0.05", "PCK@0.05")]: | |
| k_mb, k_st = levels(hMB, rMB, "K-conveuc", cell), levels(hST, rST, "K-conveuc", cell) | |
| if k_mb != k_st: | |
| raise ValueError(f"pretrain_variants.md §4: CockpitWM level columns differ between the MotionBERT and ST-GCN tables ({cell})") | |
| bodyD += [row(f"CockpitWM, {word}", *k_mb), row(f"MotionBERT arch., {word}", *levels(hMB, rMB, "motionbert_kp-conv", cell)), | |
| row(f"ST-GCN arch., {word}", *levels(hST, rST, "stgcn_kp-conv", cell))] | |
| if cell != "PCK@0.05": | |
| bodyD.append(r"\midrule") | |
| # ---- (E) P3 paired Δ CockpitWM − architecture (five seeds) and the pretraining gain of each architecture against its own seed initialisation | |
| hdrE = ["Cell"] + [rf"$\Delta$ s{s} [CI]" for s in _PV_SEEDS5] + [r"mean $\Delta$ $\pm$ sd", "verdict"] | |
| def rows5(hdr, rows, cells=_PV_CELLS) -> list[str]: | |
| return [row(tx(cell), *[tx(_pv_cell(rows, hdr, cell, f"Δ s{s} [CI]")) for s in _PV_SEEDS5], | |
| tx(_pv_cell(rows, hdr, cell, "mean Δ ± sd")), vd(_pv_cell(rows, hdr, cell, "verdict"))) for cell in cells] | |
| hMBi, rMBi, lMBi = _pv_table(pv, "4. P3", "4.1 MotionBERT", "Δ = `motionbert_kp_batonpre_conv") | |
| hSTi, rSTi, lSTi = _pv_table(pv, "4. P3", "4.2 ST-GCN", "Δ = `stgcn_kp_batonpre_conv") | |
| st_seeds = [s for s in _PV_SEEDS5 if f"Δ s{s} [CI]" in [h.strip() for h in hSTi]] | |
| if st_seeds != _PV_SEEDS3: | |
| raise ValueError(f"pretrain_variants.md §4.2: seed-init Δ table has seeds {st_seeds}, expected the three from-scratch seeds") | |
| rowsSTi = [row(tx(cell), *[tx(_pv_cell(rSTi, hSTi, cell, f"Δ s{s} [CI]")) for s in _PV_SEEDS3], "--", "--", | |
| tx(_pv_cell(rSTi, hSTi, cell, "mean Δ ± sd")), vd(_pv_cell(rSTi, hSTi, cell, "verdict"))) for cell in ["All-MPJPE", "HM-MPJPE", "PCK@0.05"]] | |
| bodyE = [group(8, "CockpitWM $-$ MotionBERT architecture, both pretrained with the identical converged recipe")] + rows5(hMB, rMB) + \ | |
| [r"\midrule", group(8, "CockpitWM $-$ ST-GCN architecture, both pretrained with the identical converged recipe")] + rows5(hST, rST) + \ | |
| [r"\midrule", group(8, "MotionBERT architecture: pretrained $-$ from seed initialisation")] + rows5(hMBi, rMBi, ["All-MPJPE", "HM-MPJPE", "PCK@0.05"]) + \ | |
| [r"\midrule", group(8, "ST-GCN architecture: pretrained $-$ from seed initialisation (the three seeds with a from-scratch run; verdict under the five-seed rule)")] + rowsSTi | |
| sel_line, lsel = find_line(pv, "**Selection (", _pv_last_block(lines_of(pv))) | |
| tot_line, ltot = find_line(pv, "| **total (new runs)**", _pv_last_block(lines_of(pv))) | |
| cap = (r"Appendix: pre-registered pretraining programme on AIDE (test, $n{=}609$; paired per-clip bootstrap, 10k; $\Delta$ negative = better for errors, positive = better for PCK; " | |
| r"verdicts: BEATS / WORSE = CI excl.\ 0 on $\geq 4/5$ seeds ($\geq 2/3$ for three-seed designs) with the same sign; NOT\_WORSE = all CIs cover 0 and $|\Delta| < 0.25$; else INCONCLUSIVE). " | |
| r"(A) P1: five pretraining schedules of CockpitWM, selected on validation only; none replaces the adopted arm. " | |
| r"(B) P2: the Driver-WM architecture on CockpitWM tokens with the same trunk pretraining, per seed and paired. " | |
| r"(C) The pretraining runs (BATON corpus, held-out routes). (D) P3 per-seed test levels under the identical converged recipe. " | |
| r"(E) P3 paired differences and each architecture's own pretraining gain. " + LEGEND + | |
| f"Sources (last block of pretrain\\_variants.md): \\S{{}}0 (line {l0}; selection line {lsel}), \\S{{}}2.6 (line {l26}), \\S{{}}3.1 (line {l31}), \\S{{}}3.2 (line {l32}), \\S{{}}3.3 (line {l33}), " | |
| f"pretraining bullets (lines {', '.join(str(k) for k in lC)}), \\S{{}}4.1 (lines {lMB}, {lMBi}), \\S{{}}4.2 (lines {lST}, {lSTi}), \\S{{}}6 total (line {ltot}).") | |
| return emit("tab_supp_pretrain_variants", cap, | |
| [f"{pv} : last block; §0 recipe-selection table (line {l0}), selection (line {lsel}); §2.6 overview (line {l26}, heading with the adopted-arm / seed-init means)", | |
| f"{pv} : §3.1 Driver-WM architecture + pretraining per seed (line {l31}); §3.2 Δ vs own seed init (line {l32}); §3.3 Δ vs pretrained CockpitWM (line {l33})", | |
| f"{pv} : pretraining bullets (lines {', '.join(str(k) for k in lC)}); " + ("" if _iclr() else f"§4.1 MotionBERT architecture Δ tables (lines {lMB}, {lMBi}); ") + f"§4.2 ST-GCN architecture Δ tables (lines {lST}, {lSTi}); §6 GPU minutes (line {ltot})"], | |
| [("(A) P1: CockpitWM pretraining schedules (trunk-only fine-tunes; px; selection on validation All-MPJPE only)", "l l r r l l l l r", hdrA, bodyA), | |
| ("(B1) P2: Driver-WM architecture on CockpitWM tokens + BATON pretraining, per seed (px; PCK in \\%)", "l r l l l l l", hdrB1, bodyB1), | |
| ("(B2) P2: paired per-seed differences (px; PCK in \\%)", "l l l l r l", hdrB2, bodyB2), | |
| ("(C) Pretraining runs on the BATON pose corpus (seed 123; held-out-route All-MPJPE selects the checkpoint)", "l l r c r l r", hdrC, bodyC), | |
| ("(D) P3: per-seed test levels under the identical converged recipe (px; PCK in \\%)", "l r r r r r", hdrD, bodyD), | |
| ("(E) P3: paired per-seed differences over five seeds (px; PCK in \\%)", "l l l l l l r l", hdrE, bodyE)]) | |
| if _PV_PATH.exists(): | |
| SRC["pretrain_variants"] = _PV_PATH | |
| ICLR_GENERATORS.append(tab_supp_pretrain_variants) | |
| SHORT["tab_supp_pretrain_variants"] = (r"Pre-registered pretraining programme on AIDE test ($n{=}609$; paired per-clip bootstrap; $\Delta$ in px, negative = better for errors, positive for PCK). " | |
| r"(A) Five pretraining schedules of \cwname{}, selected on validation. (B) The Driver-WM architecture on \cwname{} tokens with the same pretraining. " | |
| r"(C) The pretraining runs. (D, E) \cwname{} and the ST-GCN architecture under the identical converged recipe: levels and paired differences.") | |
| OURS["tab_supp_pretrain_variants"] = lambda cells, grp: cells[0].startswith("CockpitWM") | |
| CAND["tab_supp_pretrain_variants"] = _NEVER # levels are per seed and Δ rows carry their own verdict; no per-column bold | |
| ICLR_COLSEP["tab_supp_pretrain_variants"] = {2: "2pt", 4: "2pt", 5: "2pt"} # blocks (B2), (D) and (E) carry six to eight columns of CI strings | |
| ICLR_COLSPEC["tab_supp_pretrain_variants"] = {0: tiny("l p{0.19\\linewidth} r r l l l l r"), 1: tiny("l r l l l l l"), 2: tiny("l l l l r l"), | |
| 3: tiny("p{0.24\\linewidth} l r c r l r"), 4: tiny("l r r r r r"), 5: tiny("l l l l l l r l")} | |
| ICLR_NEWFLOAT["tab_supp_pretrain_variants"] = (3,) # (A)-(B2) and (C)-(E) as two floats: one float was 57 pt taller than the page | |
| ICLR_NEWFLOAT["tab_supp_driverwm_mirror"] = {1, 2} # (A), (B) and (C) each in its own float (32 + 25 rows would exceed the page) | |
| # risk-ranking table: five fixed-width columns (first compile 2026-09-15: 39 pt too wide with 'l' CI columns and 44 pt too tall); the second | |
| # float starts at the Driver-WM reproduction rows | |
| ICLR_COLSPEC["tab_supp_risk_ranking"] = {0: tiny(_RR_SPEC)} | |
| ICLR_SPLIT["tab_supp_risk_ranking"] = {0: lambda cells, line, grp: bool(cells) and cells[0].startswith("Driver-WM reproduction") and "predicted motion (their" in cells[0]} | |
| # mirror block (B): four model groups of eight interventions were 7.9 pt too tall for one page (2026-09-15); the float is split before the traffic-gate group | |
| ICLR_SPLIT["tab_supp_driverwm_mirror"] = {k: (lambda cells, line, grp: cells is None and "+ traffic gate, geometry checkpoint" in line) for k in (1, 2)} # (C) was 7.9 pt too tall as one float | |
| # ============================================================================================== | |
| # R2 result tables (2026-09-17) — eight supplement generators for the R2 programme: modality / control ablation of the vehicle-onset | |
| # cells, E-CAN road base, road-dynamics forecasting, the faithful MotionBERT baseline, the label-validation chain, the verified-mask | |
| # sensitivity, the future-state head + the face-channel variant, and the row-masked warning heads. ICLR style only (cwm_macros | |
| # \cmark / \xmark / \cwname); every generator is registered lazily (only when each source it reads exists), so the IEEE run keeps its | |
| # 19 tables and no generator above this block changes. None of these files is \input anywhere yet (the owner decides placement). | |
| # Every number is copied verbatim from the result tables named in the provenance header of each file; cross-table guards raise when | |
| # two renderings of one cell disagree (modality_ablation.md vs the paired tables; stage_final_verified.md §1 vs §1b; kin_v4b vs kin_v3 / v4). | |
| # ============================================================================================== | |
| _R2 = {"modality": BT / "modality_ablation.md", "ecan": BT / "stage_final_ecan.md", "road_dyn": BT / "road_dynamics.md", | |
| "mb_faithful": AT / "motionbert_faithful.md", "review": BT / "review_tool_summary.md", "kin_v3": BT / "kin_v3_build_stats.md", | |
| "kin_v4": BT / "kin_v4_build_stats.md", "kin_v4b": BT / "kin_v4b_build_stats.md", "vlm": BT / "vlm_handson_validation.md", | |
| "verified": BT / "stage_final_verified.md", "future_state": BT / "future_state_eval.md", "face": BT / "stage_final_face.md", | |
| "wh_rmv": BT / "warning_head_final_ext_rmv.md", "oracle": BT / "warning_oracle_diagnostic.md"} | |
| def _r2_register(fn, *keys: str) -> None: | |
| """Register an R2 generator when every source it reads exists (SRC entry + ICLR_GENERATORS; the IEEE GENERATORS list is untouched).""" | |
| if all(_R2[k].exists() for k in keys): | |
| for k in keys: | |
| SRC[k] = _R2[k] | |
| ICLR_GENERATORS.append(fn) | |
| def _unique_heading(path: pathlib.Path, prefix: str) -> None: | |
| """Guard: exactly one heading of `path` starts with `prefix` (the append-only result files must not carry two blocks of one comparison).""" | |
| n = sum(1 for ln in lines_of(path) if ln.startswith("#") and ln.lstrip("#").strip().startswith(prefix)) | |
| if n != 1: | |
| raise ValueError(f"{path.name}: heading {prefix!r} found {n} times (expected exactly 1)") | |
| def _xcol(header: list[str], name: str) -> int: | |
| """Exact-name column lookup ('per hour v4' must not resolve to 'per hour v4b').""" | |
| for i, h in enumerate(header): | |
| if h.replace("**", "").strip() == name: | |
| return i | |
| raise KeyError(f"column not found (exact): {name!r} in {header}") | |
| def _pmsd(cell: str) -> str: | |
| """'+0.0205 ± 0.0024 (n=3, pos=33712)' -> '+0.0205 $\\pm$ 0.0024' (the ICLR renderer applies the AAAI +- style afterwards).""" | |
| return tx(strip_n(cell)) | |
| _R2_NAME = {"ttc": "ttc", "ttc_drop": "ttc drop", "lane": "lane", "badas": "badas", "decel": "decel", "steer_rate": "steer rate", | |
| "lane_excursion": "lane excursion", "cut_in": "cut-in", "lead_braking": "lead braking", "brake_on": "brake", "gas_on": "gas", | |
| "steer_phase_on": "steer phase", "veh_any_on": "any vehicle onset", "hand_leave": "hand leave", "hand_return": "hand return", | |
| "head_turn_onset": "head turn"} | |
| def _r2_cell(c: str) -> str: | |
| """'d_onset/ttc_drop/3s' -> 'ttc drop' (the family / branch is given by the group row).""" | |
| return _R2_NAME.get(c.split("/")[1], tx(c)) | |
| _R2_REGIMES = [("manual", "Manual driving"), ("engaged", "Assistance engaged")] | |
| _R2_DRV = ["drv_onset/hand_leave/3s", "drv_onset/hand_return/3s", "drv_onset/head_turn_onset/3s"] | |
| _R2_VEH3 = ["veh_onset/brake_on/3s", "veh_onset/gas_on/3s", "veh_onset/steer_phase_on/3s"] | |
| _R2_VEH4 = _R2_VEH3 + ["veh_onset/veh_any_on/3s"] | |
| # ---------------------------------------------------------------------------------------------- | |
| # R2 table 1 — modality / control ablation of the vehicle-onset cells (results/tables/modality_ablation.md Tables 1-2, written by | |
| # eval/report_modality_table.py from results/paired_compare.csv; the mean Δ ± sd and verdict of every Δ cell are read from the paired | |
| # tables of stage_final_ablations.md (blocks appended 2026-09-16T19:02:03Z and 22:52:04Z, plus the naivefresh blocks) / stage_final.md | |
| # (main model vs indep), and modality_ablation.md must repeat the same mean Δ and verdict — guard). | |
| # ---------------------------------------------------------------------------------------------- | |
| _MOD_SYSTEMS = [ # (row label, A tag of the paired tables, row prefix in modality_ablation.md Tables 1-2) | |
| (r"V+E (road$\rightarrow$vehicle path only)", "env2veh", "V+E (env2veh)"), | |
| (r"V+U (driver$\rightarrow$vehicle path only)", "drv2veh", "V+U (drv2veh)"), | |
| (r"all = V+E+U (\cwname, visual-only environment input)", "allminus", "all = V+E+U (allminus, main)"), | |
| ("none (same joint fine-tuning, no interaction module)", "none", "none (fine-tune, no interaction)"), | |
| ("naive (pretrained trunks, default-initialised fusion)", "naive", "naive (pretrained + default-init fusion)"), | |
| ("scratch fusion (all trunks random)", "naivefresh", "naive_fresh (scratch fusion)"), | |
| ("scratch fusion + UW (uncertainty weighting)", "naivefreshuw", "naive_fresh + UW"), | |
| ("scratch fusion + FAMO", "naivefreshfamo", "naive_fresh + FAMO"), | |
| ("scratch fusion + PCGrad", "naivefreshpcgrad", "naive_fresh + PCGrad"), | |
| ("all + PCGrad", "allminuspcgrad", "all + PCGrad"), | |
| ] | |
| _MOD_CELLS = [("veh_onset/brake_on/3s", "brake"), ("veh_onset/gas_on/3s", "gas"), ("veh_onset/steer_phase_on/3s", "steer_phase"), | |
| ("veh_onset/veh_any_on/3s", "veh_any")] # (paired-table cell, modality_ablation.md column) | |
| _MOD_CELL_RE = re.compile(r"=([\d.]+) ± ([\d.]+); \S+=([-+]\d+\.\d+) \(n=\d+\).*\*\*([A-Z_]+)\*\*\s*$") # 'A̅=… ± …; Δ̄=… (n=3) [CI]… **VERDICT**' | |
| def _mod_pair(A: str, B: str): | |
| """paired_index of the A-vs-B table: stage_final.md for the main model vs indep, stage_final_ablations.md otherwise -> (index, path, heading, line).""" | |
| if (A, B) == ("allminus", "indep"): | |
| p, h = SRC["stage_final"], "B2 main comparison (v2 causal kin targets): A = allminus, B = indep" | |
| elif (A, B) == ("none", "indep"): | |
| p, h = SRC["stage_final_ablations"], "Main comparison: A = none, B = indep" | |
| else: | |
| p, h = SRC["stage_final_ablations"], f"Secondary comparison: A = {A}, B = {B}" | |
| _unique_heading(p, h) | |
| d, ln = paired_index(p, h) | |
| return d, p, h, ln | |
| def tab_modality_ablation() -> pathlib.Path: | |
| mod = _R2["modality"] | |
| sources, seen = [], {} | |
| spec = [("indep", "V (indep) — reference (B values)", "Table 1 ", "V (independent branches, no training): PR-AUC level", | |
| r"(A) $\Delta$ = system $-$ V (assembled independent branches, no interaction training); the first row of each regime is the reference level"), | |
| ("allminus", "all = V+E+U (allminus, main) — reference (B values)", "Table 2 ", r"all (\cwname): PR-AUC level", | |
| r"(B) $\Delta$ = system $-$ all (\cwname, visual-only environment input); the first row of each regime is the reference level")] | |
| blocks = [] | |
| hdr = ["System", "brake", "gas", "steer phase", "any vehicle onset"] | |
| for B, ref_prefix, tab_heading, ref_label, title in spec: | |
| body = [] | |
| for regime, rtitle in _R2_REGIMES: | |
| h, rows, ln = first_table(mod, tab_heading, table_idx=0 if regime == "manual" else 1) | |
| sources.append(f"{mod} : {tab_heading.strip()} {regime} (table line {ln}; level A̅ ± sd of the reference row, mean Δ and verdict of every system)") | |
| ref = find_row(rows, 0, ref_prefix) | |
| body.append(group(5, rtitle)) | |
| body.append(row(ref_label, *[tx(ref[col(h, c)]) for _, c in _MOD_CELLS])) | |
| for label, A, prefix in _MOD_SYSTEMS: | |
| if A == B: | |
| continue | |
| r = find_row(rows, 0, prefix) | |
| d, p, hh, lp = _mod_pair(A, B) | |
| if (p, hh) not in seen: | |
| seen[(p, hh)] = lp | |
| sources.append(f"{p} : {hh} (table line {lp}; mean Δ ± sd, verdict of the vehicle cells)") | |
| cells = [] | |
| for cell, c in _MOD_CELLS: | |
| m = _MOD_CELL_RE.search(r[col(h, c)]) | |
| if not m: | |
| raise ValueError(f"modality_ablation.md: unparsed cell {r[col(h, c)]!r} ({regime}, {prefix}, {c})") | |
| pr = d["idx"][(regime, cell, "pr_auc")] | |
| mean_sd, verdict = strip_n(pr[d["ci"]["mean Δ ± sd"]]), pr[d["ci"]["verdict"]].replace("**", "").strip() | |
| if mean_sd.split(" ")[0] != m.group(3) or verdict != m.group(4): | |
| raise ValueError(f"modality_ablation.md disagrees with the paired table for {A} vs {B}, {regime} {cell}: " | |
| f"{m.group(3)} {m.group(4)} vs {mean_sd} {verdict}") | |
| cells.append(dmark(pr[d["ci"]["mean Δ ± sd"]], verdict)) | |
| body.append(row(label, *cells)) | |
| blocks.append((title, "p{0.36\\linewidth} r r r r", hdr, body)) | |
| r1, lr1 = find_line(mod, "**(1) `none` vs the connections") | |
| r3, lr3 = find_line(mod, "**(3) MTL vs plain summation") | |
| hm, rm, lm = first_table(mod, "Consequence-table reading", table_idx=1) # (3) MTL vs plain summation | |
| mtl = "; ".join(f"{tx(r[col(hm, 'MTL arm')])} vs {tx(r[col(hm, 'vs plain sum')])}: better {tx(r[col(hm, 'own cells BEATS')])}, worse {tx(r[col(hm, 'own cells WORSE')])}" for r in rm) | |
| cap = (r"Modality / control ablation of the vehicle-onset cells (WP3 R2 reviewer controls): onset PR-AUC@3\,s of brake, gas, steer-phase and any-vehicle onsets, BATON test split, both regimes, 3 seeds, " | |
| r"paired device-cluster bootstrap on identical rows ($n_{\mathrm{boot}}{=}1000$), mean $\Delta$ $\pm$ sd over seeds. Systems: V = indep (assembled independent branches, no training), V+E = env2veh, V+U = drv2veh, " | |
| r"all = all\_minus\_road2drv (the main model), none (same joint fine-tuning without the interaction module), naive (pretrained trunks + default-init fusion MLP), naive\_fresh (fusion trained from scratch, all trunks random) " | |
| r"and its multi-task arms (UW = Kendall 2018, FAMO = Liu 2023, PCGrad = Yu 2020 on the shared parameters), all + PCGrad. (A) $\Delta$ vs V, (B) $\Delta$ vs all; the reference rows give the levels (A̅ $\pm$ sd). " | |
| r"\cmark\ / \xmark\ = BEATS / WORSE by kill\_checks.beats ($\geq 2/3$ seeds CI excl.\ 0, same sign, $|$mean $\Delta| >$ seed sd); no mark = INCONCLUSIVE or NOT\_WORSE (no significant difference). " | |
| f"Pre-registered consequence reading (modality\\_ablation.md lines {lr1}--{lr3}): {mtl}. " | |
| f"Sources: modality\\_ablation.md Tables 1--2 (levels, mean $\\Delta$, verdicts); stage\\_final\\_ablations.md / stage\\_final.md paired tables (mean $\\Delta$ $\\pm$ sd, verdicts; lines in the header).") | |
| sources.append(f"{mod} : Consequence-table reading, (3) MTL vs plain summation (table line {lm}); reading lines {lr1}--{lr3}") | |
| return emit("tab_modality_ablation", cap, sources, blocks) | |
| # ---------------------------------------------------------------------------------------------- | |
| # R2 table 2 — E-CAN road base (results/tables/stage_final_ecan.md): (a) sensor + vision E base and (a2) sensor-only control vs the | |
| # FROZEN main model; D / P road cells, vehicle and driver own cells, both regimes. The 'Own + road-D endpoints of (a)' table of the | |
| # pre-registered rule repeats mean Δ and verdict of (a) — guard. | |
| # ---------------------------------------------------------------------------------------------- | |
| _ECAN_GROUPS = [("Road-demand (D) onset cells of the E branch (ttc, ttc drop, lane and badas are the road cells of the pre-registered rule)", | |
| ["d_onset/ttc/3s", "d_onset/ttc_drop/3s", "d_onset/lane/3s", "d_onset/badas/3s", "d_onset/decel/3s", "d_onset/steer_rate/3s"], "kin"), | |
| ("Road-pressure (P) onset cells", ["p_onset/ttc/3s", "p_onset/ttc_drop/3s", "p_onset/lane_excursion/3s", "p_onset/badas/3s", | |
| "p_onset/cut_in/3s", "p_onset/lead_braking/3s"], "P"), | |
| ("Vehicle own cells", _R2_VEH3, "kin"), ("Driver own cells", _R2_DRV, "kin")] | |
| def tab_ecan() -> pathlib.Path: | |
| ec = _R2["ecan"] | |
| hA = "(a) sensor + vision E base vs the FROZEN main model (v2 causal kin targets): A = allminusecan, B = allminus" | |
| hA2 = "(a2) sensor-only control (no vision tokens) vs the FROZEN main model: A = allminusecanonly, B = allminus" | |
| hPA = "P cells (road-pressure onset PR-AUC@3s, eval/pressure_eval.py): (a) vs FROZEN main: A = allminusecan, B = allminus" | |
| hPA2 = "P cells: (a2) sensor-only vs FROZEN main: A = allminusecanonly, B = allminus" | |
| for hh in (hA, hA2, hPA, hPA2): | |
| _unique_heading(ec, hh) | |
| A, lA = paired_index(ec, hA) | |
| A2, lA2 = paired_index(ec, hA2) | |
| PA, lPA = paired_index(ec, hPA) | |
| PA2, lPA2 = paired_index(ec, hPA2) | |
| hO, rO, lO = first_table(ec, "Own + road-D endpoints of (a)") | |
| own = {(r[col(hO, "regime")], r[col(hO, "endpoint")]): r for r in rO} | |
| vline, lv = find_line(ec, "## VERDICT") | |
| rule, lrule = find_line(ec, "**Pre-registered rule") | |
| hdr = [r"\headrow Cell & \multicolumn{4}{c}{Manual driving} & \multicolumn{4}{c}{Assistance engaged} \\", r"\cmidrule(lr){2-5}\cmidrule(lr){6-9}", | |
| ["", r"$\Delta$ (a) sensor + vision", "verdict", r"$\Delta$ (a2) sensor only", "verdict", r"$\Delta$ (a) sensor + vision", "verdict", r"$\Delta$ (a2) sensor only", "verdict"]] | |
| body = [] | |
| for title, cells, kind in _ECAN_GROUPS: | |
| body.append(group(9, title)) | |
| for cell in cells: | |
| out = [_r2_cell(cell)] | |
| for regime, _ in _R2_REGIMES: | |
| if omitted_cell(regime, cell): # owner decision 2026-09-17 item 3 (ICLR): the engaged hand cells are not reported | |
| out += ["--", "--", "--", "--"] | |
| continue | |
| for tab in ((PA, PA2) if kind == "P" else (A, A2)): | |
| r = tab["idx"][(regime, cell, "pr_auc")] | |
| out += [_pmsd(r[tab["ci"]["mean Δ ± sd"]]), vd(r[tab["ci"]["verdict"]])] | |
| if kind == "kin": # guard: the rule's own-endpoint table repeats mean Δ and verdict of (a) | |
| o, r = own[(regime, cell)], A["idx"][(regime, cell, "pr_auc")] | |
| if o[col(hO, "mean Δ")] != strip_n(r[A["ci"]["mean Δ ± sd"]]).split(" ")[0] or o[col(hO, "verdict")] != r[A["ci"]["verdict"]].strip(): | |
| raise ValueError(f"stage_final_ecan.md: own-endpoint table disagrees with (a) for {regime} {cell}") | |
| body.append(row(*out)) | |
| cap = (r"E-CAN variants (F5b): the frozen joint recipe with the road (E) base swapped to pooled\_P\_can (vf256 PCA 0..215 + 40 CAN road anchor features; (a) sensor + vision) and to the sensor-only control " | |
| r"pooled\_P\_canonly (no vision tokens; (a2)), each vs the FROZEN main model, onset PR-AUC@3\,s, BATON test split, both regimes, 3 seeds; paired device-cluster bootstrap on identical rows ($n_{\mathrm{boot}}{=}1000$), " | |
| r"mean $\Delta$ $\pm$ sd (A $-$ B, A = variant). D cells = the E branch's demand-onset chains (v2 causal kin targets), P cells = road-pressure chains (eval/pressure\_eval.py). " | |
| + LEGEND + | |
| f"Pre-registered rule (line {lrule}): candidate E base iff no own endpoint WORSE and $\\geq 1$ road cell BEATS. Source verdict (line {lv}): {tx(vline.lstrip('#').strip())}. " | |
| f"Sources: stage\\_final\\_ecan.md (a) line {lA}, (a2) line {lA2}, P cells (a) line {lPA}, (a2) line {lPA2}, own + road-D endpoints of (a) line {lO}.") | |
| return emit("tab_ecan", cap, | |
| [f"{ec} : VERDICT (line {lv}); pre-registered rule (line {lrule})", | |
| f"{ec} : §1 (a) sensor + vision E base vs FROZEN main (table line {lA}; mean Δ ± sd, verdict)", | |
| f"{ec} : §1 Own + road-D endpoints of (a) (table line {lO}; guard)", | |
| f"{ec} : §2 (a2) sensor-only control vs FROZEN main (table line {lA2})", | |
| f"{ec} : §7 P cells (a) vs FROZEN main (table line {lPA}); (a2) sensor-only vs FROZEN main (table line {lPA2})"], | |
| [(None, "l r l r l r l r l", hdr, body)]) | |
| # ---------------------------------------------------------------------------------------------- | |
| # R2 table 3 — road dynamics (results/tables/road_dynamics.md, F5c / K7): (A) MAE of the forecast at 1 / 3 / 5 s per channel for the | |
| # four arms; (B) derived demand-onset PR-AUC@3 s vs the current-margin rule S0 (ttc, lead braking, lane excursion). | |
| # ---------------------------------------------------------------------------------------------- | |
| _RD_CHANNELS = [("dRel", "lead distance"), ("vRel", "relative speed"), ("vLead", "lead speed"), ("lane_off", "lane-centre offset")] | |
| _RD_ARMS = ["persistence", "cv", "dyn", "dynvis"] | |
| _RD_HORIZONS = [("1.0 s", r"1\,s"), ("3.0 s", r"3\,s"), ("5.0 s", r"5\,s")] | |
| _RD_FAMILIES = [("ttc", "ttc onsets"), ("lead_braking", "lead-braking onsets"), ("lane_excursion", "lane-excursion onsets")] | |
| _RD_ONSET_ARMS = [("persistence", r"margin rule $S_0$ ($\equiv$ persistence; reference)"), ("cv", "constant velocity"), | |
| ("dyn", "dyn (GRU on the CAN road history)"), ("dynvis", "dynvis (+ frozen vision features)"), | |
| ("FINAL P chain", r"\cwname{} P head (frozen main model)")] | |
| def _rd_verdict(s: str) -> str: | |
| """Single-run arms carry 'CI>0' / 'CI incl. 0' / 'CI<0' instead of a seed verdict; '>' and '<' need math mode in text.""" | |
| s0 = s.replace("**", "").strip() | |
| return {"CI>0": r"CI $>$ 0", "CI<0": r"CI $<$ 0", "CI incl. 0": r"CI incl.\ 0"}.get(s0, vd(s0)) | |
| def _rd_seeds(cell: str) -> str: | |
| """'0.401 / 0.398 / 0.394' or '+0.013 [CI] / +0.011 [CI] / …' -> per-seed values without CIs; a single value is kept as is.""" | |
| return _seed_deltas(cell) if "/" in cell else tx(cell.split(" ")[0]) | |
| def tab_road_dynamics() -> pathlib.Path: | |
| rd = _R2["road_dyn"] | |
| ls = lines_of(rd) | |
| vline, lv = find_line(rd, "## VERDICT") | |
| rule, lrule = find_line(rd, "**Reading rule (pre-registered):**") | |
| srcs = [f"{rd} : VERDICT (line {lv}); pre-registered reading rule (line {lrule})"] | |
| bodyA, bodyB = [], [] | |
| for regime, rtitle in _R2_REGIMES: | |
| sec, i0 = section(ls, f"{regime} (N =") | |
| a_sec, ja = section(sec, "(a) MAE") | |
| ha, ra, ka = md_tables(a_sec)[0] | |
| c_sec, jc = section(sec, "(c) Derived") | |
| hc, rc, kc = md_tables(c_sec)[0] | |
| la, lc = i0 + ja + ka + 1, i0 + jc + kc + 1 | |
| srcs += [f"{rd} : {regime} (a) MAE of the forecast (table line {la})", f"{rd} : {regime} (c) derived demand-onset PR-AUC@3 s vs S0 (table line {lc})"] | |
| idxA = {(r[col(ha, "arm")], r[col(ha, "channel")]): r for r in ra} | |
| bodyA.append(group(6, rtitle)) | |
| for ch, chlab in _RD_CHANNELS: | |
| for hz, hzlab in _RD_HORIZONS: | |
| bodyA.append(row(chlab, hzlab, *[tx(idxA[(arm, ch)][col(ha, hz)]) for arm in _RD_ARMS])) | |
| idxC = {(r[col(hc, "family")], r[col(hc, "arm")]): r for r in rc} | |
| for fam, flab in _RD_FAMILIES: | |
| base = idxC[(fam, "*base rate*")] | |
| bodyB.append(group(4, f"{rtitle} --- {flab} (base rate {tx(base[col(hc, 'PR-AUC A')])}; rows / positives {tx(base[col(hc, 'n / pos')])})")) | |
| for arm, alab in _RD_ONSET_ARMS: | |
| r = idxC[(fam, arm)] | |
| bodyB.append(row(alab, _rd_seeds(r[col(hc, "PR-AUC A")]), _rd_seeds(r[col(hc, "vs S0")]), _rd_verdict(r[col(hc, "verdict vs S0")]))) | |
| cap = (r"Road dynamics (F5c, K7): can road demand be PREDICTED rather than only recognised? Test split, both regimes; targets = future lead dRel / vRel / vLead and lane-centre offset at $k = 1..25$ " | |
| r"(canspec whitelist CAN). Arms: persistence, constant velocity (CV), RD\_dyn (GRU-128 on the 8\,s CAN road history + 40 CAN anchor features, Gaussian residual over CV, 149\,k params) and RD\_dynvis (+ frozen vf256, 183\,k params), " | |
| r"3 seeds each, validation-NLL selection. (A) MAE of the forecast at 1 / 3 / 5\,s (rows valid at the anchor and at $k$; learned arms mean $\pm$ sd over seeds). " | |
| r"(B) Derived demand-onset PR-AUC@3\,s (population = pressure\_eval rows; primary score = max over $k \leq 15$ of the forecast mean's margin ratio) against the current-margin rule $S_0$ (recognition; $\equiv$ persistence), $\Delta$ per seed s0 / s1 / s2 (CIs in the source), " | |
| r"and the frozen main model's P head as a second comparator; paired device-cluster bootstrap with shared resamples ($n_{\mathrm{boot}}{=}500$). Single-run arms carry the CI position instead of a seed verdict. " | |
| + LEGEND + f"Pre-registered reading rule (line {lrule}): {tx(rule.split('**', 2)[2].strip())} Source verdict (line {lv}): {tx(vline.lstrip('#').strip())}") | |
| hdrA = ["Channel", "$h$", "persistence", "constant velocity", "dyn", "dynvis"] | |
| hdrB = ["Arm", r"PR-AUC@3\,s (s0 / s1 / s2)", r"$\Delta$ vs $S_0$ (s0 / s1 / s2)", r"verdict vs $S_0$"] | |
| return emit("tab_road_dynamics", cap, srcs, | |
| [(r"(A) MAE of the road-state forecast (learned arms: mean $\pm$ sd over 3 seeds)", "l l r r r r", hdrA, bodyA), | |
| (r"(B) Demand-onset PR-AUC@3\,s derived from the forecast vs the current-margin rule $S_0$", "p{0.40\\linewidth} l l l", hdrB, bodyB)]) | |
| # ---------------------------------------------------------------------------------------------- | |
| # R2 table 4 — faithful MotionBERT baseline (aide/results/tables/motionbert_faithful.md, written by aide/eval/report_motionbert_faithful.py): | |
| # (A) §1 seed means of the three pre-registered arms, the post-hoc EMA-off run and the references; (B) §2 paired per-clip Δ (All / HM / PCK) | |
| # of (a), (b), (c) vs CockpitWM and vs CockpitWM + BATON pretraining, the two attribution contrasts, and the §2b post-hoc rows. | |
| # ---------------------------------------------------------------------------------------------- | |
| _MBF_LEVELS = [ # (row label, §1 label prefix, §1 label suffix of the mean row or None for a single analytic row) | |
| (r"(a) released MotionBERT weights, fine-tuned, anchored (residual) read-out", "(a) MotionBERT released weights, anchored residual read-out", " — mean ± sd"), | |
| (r"(b) released MotionBERT weights, fine-tuned, absolute read-out (their formulation)", "(b) MotionBERT released weights, absolute read-out (their formulation)", " — mean ± sd"), | |
| (r"(c) same architecture from random init, anchored read-out (control)", "(c) same architecture, random init, residual read-out", " — mean ± sd"), | |
| (r"post hoc, not pre-registered: (b) with the EMA disabled", "POST-HOC (b) released weights, absolute read-out, EMA disabled", " — mean ± sd"), | |
| (r"\cwname{} (3 seeds)", "reference: CockpitWM (cwm3d_kp)", " — locked seeds 42 / 123 / 456 mean ± sd"), | |
| (r"\cwname{} + BATON pretraining (3 seeds)", "reference: CockpitWM + BATON pretraining (cwm3d_kp_batonpre_trunkp123)", " — locked seeds 42 / 123 / 456 mean ± sd"), | |
| (r"MotionBERT architecture-family control (small, no released weights; 3 seeds)", "reference: MotionBERT architecture-family control (motionbert_kp", " — locked seeds 42 / 123 / 456 mean ± sd"), | |
| (r"zero velocity (analytic)", "reference: zero-velocity (analytic", None), | |
| ] | |
| _MBF_COLS = ["All", "d-n", "HM", "PCK@0.05", "HM h=5"] # the standard cell set (_PV_CELLS); HM d-n = HM over the image diagonal stays in the source | |
| _MBF_PAIRS = [ # (row label, §2 heading prefix, group) | |
| (r"(a) $-$ \cwname{}", "2.1 (a) − CockpitWM", "pre"), | |
| (r"(a) $-$ \cwname{} + BATON pretraining", "2.2 (a) − CockpitWM + BATON pretraining", "pre"), | |
| (r"(b) $-$ \cwname{}", "2.3 (b) − CockpitWM", "pre"), | |
| (r"(b) $-$ \cwname{} + BATON pretraining", "2.4 (b) − CockpitWM + BATON pretraining", "pre"), | |
| (r"(c) $-$ \cwname{}", "2.5 (c) − CockpitWM", "pre"), | |
| (r"(a) $-$ (c): value of the released weights", "2.6 (a) − (c)", "pre"), | |
| (r"(a) $-$ (b): value of anchoring (residual vs absolute read-out)", "2.7 (a) − (b)", "pre"), | |
| (r"(b, EMA off) $-$ (b): effect of the EMA lag under the 60-epoch cap", "POST-HOC (b, EMA off) − (b, pre-registered)", "post"), | |
| (r"(a) $-$ (b, EMA off): anchoring with the EMA confound removed", "POST-HOC (a) − (b, EMA off)", "post"), | |
| (r"(b, EMA off) $-$ \cwname{}", "POST-HOC (b, EMA off) − CockpitWM", "post"), | |
| ] | |
| def _mbf_rows(rows: list[list[str]], prefix: str, suffix): | |
| """(mean row, first seed row) of one §1 arm; the mean row is the one whose label ends with `suffix` (the 5-seed and 3-seed means differ only there).""" | |
| labs = [(r[0].replace("**", "").strip(), r) for r in rows] | |
| if suffix is None: | |
| mean = next(r for lab, r in labs if lab.startswith(prefix)) | |
| return mean, mean | |
| mean = [r for lab, r in labs if lab.startswith(prefix) and lab.endswith(suffix)] | |
| seed = [r for lab, r in labs if lab.startswith(prefix) and "mean ± sd" not in lab] | |
| if len(mean) != 1 or not seed: | |
| raise ValueError(f"motionbert_faithful.md §1: arm {prefix!r} -> {len(mean)} mean rows, {len(seed)} seed rows") | |
| return mean[0], seed[0] | |
| def tab_supp_motionbert_faithful() -> pathlib.Path: | |
| mb = _R2["mb_faithful"] | |
| h1, r1, l1 = first_table(mb, "1. Test levels per run") | |
| bodyA = [] | |
| for label, prefix, suffix in _MBF_LEVELS: | |
| mean, seed = _mbf_rows(r1, prefix, suffix) | |
| bodyA.append(row(label, *[tx(re.sub(r"^([-+]?\d+\.\d+)\s*\[[^\]]*\]$", r"\1", mean[_xcol(h1, c)].strip())) for c in _MBF_COLS], tx(seed[_xcol(h1, "params")]))) | |
| hdrA = [r"Model (AIDE test, $n{=}609$)", r"All$\downarrow$", r"d-n$\downarrow$", r"HM$\downarrow$", r"PCK@0.05$\uparrow$", r"HM $h{=}5\downarrow$", "Params"] | |
| bodyB, srcs = [], [f"{mb} : §1 test levels per run and seed means ± sd (table line {l1}; mean rows, params of the seed-42 row)"] | |
| grp = None | |
| for label, heading, g in _MBF_PAIRS: | |
| _unique_heading(mb, heading) | |
| h, rows, ln = first_table(mb, heading) | |
| srcs.append(f"{mb} : §2 {heading} (table line {ln}; mean Δ ± sd, CI excl. 0 count, verdict)") | |
| if g != grp: | |
| grp = g | |
| bodyB.append(group(7, "Pre-registered comparisons" if g == "pre" else "Post-hoc sensitivity (not pre-registered; launched after the pre-registered set)")) | |
| cells = [label] | |
| for c in ["All-MPJPE", "HM-MPJPE", "PCK@0.05"]: | |
| r = find_row(rows, 0, c) | |
| cells += [tx(r[col(h, "mean Δ ± sd")]), vd(r[col(h, "verdict")]) + " (" + tx(r[col(h, "CI excl. 0")]) + ")"] | |
| bodyB.append(row(*cells)) | |
| hdrB = [r"Comparison (paired per-clip $\Delta$, 3 seeds)", r"$\Delta$ All-MPJPE", "verdict (CIs excl.\\ 0)", r"$\Delta$ HM-MPJPE", "verdict (CIs excl.\\ 0)", r"$\Delta$ PCK@0.05", "verdict (CIs excl.\\ 0)"] | |
| read, lr = find_line(mb, "- **(a) vs CockpitWM + BATON pretraining") | |
| dis, ld = find_line(mb, "- _The two rules disagree here") | |
| # Owner decision 2026-09-17 (coordinator item 3): verdicts follow the project-wide >= 2/3 rule; the strict 3/3 count named by the | |
| # pre-registration row is disclosed as a footnote row for the (a) − CockpitWM + BATON pretraining All-MPJPE cell (§3 of the source). | |
| h22, r22, l22 = first_table(mb, "2.2 (a) − CockpitWM + BATON pretraining") | |
| r22a = find_row(r22, 0, "All-MPJPE") | |
| ms = re.search(r"strict-count verdict ([A-Z_]+) \(standard ≥ 2/3 rule: ([A-Z_]+)\)", read) | |
| if not ms or ms.group(2) != r22a[col(h22, "verdict")].strip(): | |
| raise ValueError("motionbert_faithful.md §3: strict-count sentence not found or inconsistent with the §2.2 All-MPJPE verdict") | |
| bodyB.append(r"\multicolumn{7}{@{}p{\textwidth}@{}}{\emph{Footnote --- verdicts follow the project-wide rule (CI excl.\ 0 on $\geq 2/3$ seeds, same sign). " | |
| r"The pre-registration row of this experiment also named a strict count (3/3 seeds): under it the (a) $-$ \cwname{} + BATON pretraining All-MPJPE cell " | |
| "(" + tx(r22a[col(h22, "CI excl. 0")]) + " seeds) reads " + vd(ms.group(1)) + " instead of " + vd(ms.group(2)) + r"; both counts are recorded in the source, \S{}3.}} \\") | |
| cap = (r"Faithful MotionBERT baseline: the released MB\_release DSTformer weights (42.5\,M params) fine-tuned on AIDE with (a) our anchored residual read-out and (b) their absolute read-out, and (c) the same architecture from random init, " | |
| r"vs CockpitWM (5.77\,M) with and without BATON pretraining; AIDE test ($n{=}609$), locked seeds 42 / 123 / 456, every run selected on validation All-MPJPE of the EMA weights, test evaluated once. " | |
| r"(A) Seed means $\pm$ sd (MPJPE in px, lower better; PCK@0.05 in \%, higher). (B) Paired per-clip $\Delta$ (10k clip bootstrap; errors: negative = first arm better; PCK: positive = better), mean $\pm$ sd and the count of seeds whose CI excludes 0; " | |
| r"verdict rule as arch\_attribution.md (BEATS / WORSE = CI excl.\ 0 on $\geq 2/3$ seeds, same sign; NOT\_WORSE = all CIs cover 0 and $|\Delta| < 0.25$; else INCONCLUSIVE). " | |
| r"The post-hoc rows (EMA disabled) were launched after the pre-registered set and do not enter the pre-registered reading. " | |
| f"Pre-registered reading (line {lr}): {tx(read.lstrip('- ').replace('**', ''))} (line {ld}): {tx(dis.lstrip('- ').strip('_'))} " | |
| f"Sources: motionbert\\_faithful.md §1 (line {l1}), §2 / §2b tables (lines in the header).") | |
| srcs.append(f"{mb} : §3 pre-registered reading (lines {lr}, {ld})") | |
| return emit("tab_supp_motionbert_faithful", cap, srcs, | |
| [(r"(A) Test levels, seed means $\pm$ sd (the analytic row: point value; its clip-bootstrap CI stays in the source)", "p{0.34\\linewidth} r r r r r r", hdrA, bodyA), | |
| (r"(B) Paired per-clip differences, mean $\pm$ sd over seeds", "p{0.34\\linewidth} r l r l r l", hdrB, bodyB)]) | |
| # ---------------------------------------------------------------------------------------------- | |
| # R2 table 5 — label-validation chain (results/tables/review_tool_summary.md, kin_v3/v4/v4b_build_stats.md, vlm_handson_validation.md): | |
| # (A) Task A driver association; (B) Task B precision of the automatic switch labels + the blind re-labelling passes of hand_return; | |
| # (C) event rates and hands-on shares under the label definitions v2 / v3 / v4 / v4b (test split; kin_v4b carries all four, kin_v3 and | |
| # kin_v4 must agree — guard); (D) the three local VLM candidates on the driver-box crop against the owner's frame-level clicks. | |
| # ---------------------------------------------------------------------------------------------- | |
| _VLM_CANDS = ["Qwen/Qwen3-VL-2B-Instruct", "Qwen/Qwen2.5-VL-3B-Instruct", "Qwen/Qwen3-VL-4B-Instruct"] | |
| _LC_P4_RE = re.compile(r"\*\*(\d+ / \d+)\*\* labelled \(Wilson 95 % \[([\d.]+), ([\d.]+)\]\)") | |
| def tab_label_check() -> pathlib.Path: | |
| rv, k3, k4, k4b, vl = _R2["review"], _R2["kin_v3"], _R2["kin_v4"], _R2["kin_v4b"], _R2["vlm"] | |
| # (A) Task A | |
| hA1, rA1, lA1 = first_table(rv, "Task A", table_idx=0) | |
| hA2, rA2, lA2 = first_table(rv, "Task A", table_idx=1) | |
| routes = {r[0].strip(): r[1].strip() for r in rA1} | |
| vm, lvm = find_line(rv, "Verified mask (") | |
| nmask = re.search(r"Verified mask \((\d+) routes", vm).group(1) | |
| bodyA = [row(tx(r[col(hA2, "regime_split")]).replace("\\_", " / "), *[tx(r[i]) for i in range(1, 5)]) for r in rA2] | |
| hdrA = ["Regime / split", "flagged anchors", "verified wrong occupant", "unsure", "verified driver"] | |
| titleA = (f"(A) Task A --- human review of the causal driver box on the 64 suspect routes: driver {routes['driver']}, passenger {routes['passenger']}; " | |
| f"verified mask = {nmask} routes (passenger or none)") | |
| # (B) Task B + passes 2-4 | |
| hB, rB, lB = first_table(rv, "Task B") | |
| hP2, rP2, lP2 = first_table(rv, "Review-tool summary — pass 2") | |
| hP3, rP3, lP3 = first_table(rv, "Review-tool summary — pass 3") | |
| p4, lP4 = find_line(rv, "Real hand return within") | |
| m4 = _LC_P4_RE.search(p4) | |
| if not m4: | |
| raise ValueError("review_tool_summary.md: pass-4 count line not parsed") | |
| cB = [col(hB, k) for k in ["regime", "event", "n labelled", "correct", "wrong", "timing", "unsure", "precision"]] | |
| bodyB = [group(9, "Pass 1 --- 200 automatic switch labels, owner labelling (reported for hand leave and head turn)")] | |
| for r in rB: | |
| bodyB.append(row(tx(r[cB[0]]), _r2_cell("x/" + r[cB[1]] + "/"), "1", *[tx(r[i]) for i in cB[2:]])) | |
| bodyB.append(group(9, "Blind re-labelling of hand return (reported: manual = pass 2; engaged = pass 3 / pass 4)")) | |
| def pass_row(h, rows, regime, pass_prefix): | |
| r = next(r for r in rows if r[col(h, "regime")] == regime and r[col(h, "pass")].replace("**", "").startswith(pass_prefix)) | |
| return row(regime, "hand return", tx(r[col(h, "pass")]), *[tx(r[col(h, k)]) for k in ["n labelled", "correct", "wrong", "timing", "unsure", "precision"]]) | |
| bodyB += [pass_row(hP2, rP2, "manual", "2"), pass_row(hP2, rP2, "engaged", "2"), pass_row(hP3, rP3, "engaged", "3"), | |
| row("engaged", "hand return", r"4 (frame click, $\pm 1$\,s)", m4.group(1).split(" / ")[1], m4.group(1).split(" / ")[0], "--", "--", "--", | |
| f"{tx(m4.group(1))} real returns [{m4.group(2)}, {m4.group(3)}]")] | |
| hdrB = ["Regime", "Event", "Pass", r"$n$", "correct", "wrong", r"timing $>$0.5\,s", "unsure", r"precision [Wilson 95\% CI]"] | |
| # (C) label definitions v2 / v3 / v4 / v4b on the test split | |
| h1, r1, l1 = first_table(k4b, "1. Coverage and state shares") | |
| h2, r2, l2 = first_table(k4b, "2. Events per hour") | |
| h31, r31, l31 = first_table(k3, "Coverage and state shares") | |
| h32, r32, l32 = first_table(k3, "Events per hour") | |
| h41, r41, l41 = first_table(k4, "1. Coverage and state shares") | |
| h42, r42, l42 = first_table(k4, "2. Events per hour") | |
| vers = ["v2", "v3", "v4", "v4b"] | |
| bodyC = [] | |
| for regime, rtitle in _R2_REGIMES: | |
| for ev in ["hand_return", "hand_leave", "head_turn_onset"]: | |
| r = next(r for r in r2 if r[0] == regime and r[1] == "test" and r[2] == ev) | |
| vals = [r[_xcol(h2, f"per hour {v}")] for v in vers] | |
| g3 = next(r for r in r32 if r[0] == regime and r[1] == "test" and r[2] == ev) | |
| g4 = next(r for r in r42 if r[0] == regime and r[1] == "test" and r[2] == ev) | |
| if [g3[_xcol(h32, "per hour v2")], g3[_xcol(h32, "per hour v3")], g4[_xcol(h42, "per hour v4")]] != [v.replace("**", "") for v in vals[:3]]: | |
| raise ValueError(f"kin build stats disagree on events/h for {regime} {ev}") | |
| bodyC.append(row(regime, _r2_cell("x/" + ev + "/") + ", events per hour", *[tx(v) for v in vals])) | |
| r = next(r for r in r1 if r[0] == regime and r[1] == "test") | |
| shares = [r[_xcol(h1, f"hands_on share {v}")] for v in vers] | |
| g3 = next(r for r in r31 if r[0] == regime and r[1] == "test") | |
| g4 = next(r for r in r41 if r[0] == regime and r[1] == "test") | |
| if [g3[_xcol(h31, "hands_on share v2")], g3[_xcol(h31, "hands_on share v3")], g4[_xcol(h41, "hands_on share v4")]] != [v.replace("**", "") for v in shares[:3]]: | |
| raise ValueError(f"kin build stats disagree on the hands-on share for {regime}") | |
| bodyC.append(row(regime, "hands-on share (mean over the 25 future steps)", *[tx(v) for v in shares])) | |
| hdrC = ["Regime", "Quantity (test split)", "v2", "v3", "v4", "v4b"] | |
| # (D) VLM hands-on gold | |
| hV, rV, lV = first_table(vl, "Summary") | |
| acc, lacc = find_line(vl, "frame accuracy at P") | |
| accepted, lacd = find_line(vl, "**Accepted candidate:") | |
| bodyD = [] | |
| for cand in _VLM_CANDS: | |
| r = next(r for r in rV if r[col(hV, "candidate")] == cand and r[col(hV, "variant")] == "crop") | |
| bodyD.append(row(tx(cand.split("/")[1]), *[tx(r[col(hV, k)]) for k in ["acc@0.5", "AUROC", "recall on", "recall off", "items agree", "clicks"]], | |
| tx(r[col(hV, "verdict")]).upper())) | |
| hdrD = ["Local VLM (driver-box crop, 981 frames of 41 items)", "acc@0.5", "AUROC", "recall on", "recall off", "items agree", r"clicks $\pm$0.5\,s (hyst.\ / plain)", "verdict"] | |
| cap = (r"Label-validation chain of the automatic driver-state labels (owner review tool, 2026-09-16). (A) Task A: driver association on the 64 driver-box suspect routes and the anchors they carry per regime / split. " | |
| r"(B) Task B: precision of the automatic switch labels among the labelled items (Wilson 95\,\% CI); hand\_return was re-labelled blind in pass 2 (definition shown), pass 3 (21 frames at 0.1\,s) and pass 4 (frame click: first frame with a hand on the wheel) --- " | |
| r"the reported engaged hand\_return precision is pass 3 / pass 4, manual hand\_return pass 2, other events pass 1. (C) Label definitions on the test split: v2 = original hands\_on / hand-event labels; v3 = manual-only causal wheel point reference, hysteresis 0.08 / 0.12, " | |
| r"$\geq 1$\,s persistence; v4 = per-device RANSAC ellipse fit of the rim, signed-distance hysteresis 0.04 / 0.08 (filled-ellipse convention); v4b = v4 with the rim distance (no filled region); head\_turn\_onset is identical across versions. " | |
| r"(D) Local vision-language models asked per frame whether a hand touches the wheel, against the owner's frame-level clicks (981 frames; driver-box crop input); pre-registered acceptance: " | |
| f"{tx(acc.split('AND')[0].strip())} and AUROC $\\geq 0.95$ and $\\geq 3$ of the 4 clicked returns within $\\pm 0.5$\\,s; {tx(accepted.replace('**', ''))} " | |
| f"Sources: review\\_tool\\_summary.md Task A (lines {lA1}, {lA2}, {lvm}), Task B (line {lB}), pass 2 (line {lP2}), pass 3 (line {lP3}), pass 4 (line {lP4}); kin\\_v4b\\_build\\_stats.md §1 (line {l1}), §2 (line {l2}) " | |
| f"checked against kin\\_v3 (lines {l31}, {l32}) and kin\\_v4 (lines {l41}, {l42}); vlm\\_handson\\_validation.md Summary (line {lV}), acceptance (line {lacc}), result (line {lacd}).") | |
| return emit("tab_label_check", cap, | |
| [f"{rv} : Task A label / routes (table line {lA1}); anchors per regime_split (table line {lA2}); verified-mask line {lvm}", | |
| f"{rv} : Task B pass-1 precisions (table line {lB})", | |
| f"{rv} : pass 2 hand_return re-labelling (table line {lP2}); pass 3 engaged hand_return at 0.1 s frames (table line {lP3}); pass 4 frame-click count (line {lP4})", | |
| f"{k4b} : §1 coverage and state shares, hands_on share v2 / v3 / v4 / v4b (table line {l1}); §2 events per hour v2 / v3 / v4 / v4b (table line {l2})", | |
| f"{k3} : coverage and state shares (table line {l31}); events per hour (table line {l32}) — v2 / v3 guard", | |
| f"{k4} : §1 coverage and state shares (table line {l41}); §2 events per hour (table line {l42}) — v4 guard", | |
| f"{vl} : Summary (table line {lV}; crop rows of the three candidates); acceptance (line {lacc}); accepted candidate (line {lacd})"], | |
| [(titleA, "l r r r r", hdrA, bodyA), | |
| ("(B) Task B --- precision of the automatic switch labels (owner labelling; Wilson 95\\,\\% CI)", "l l l r r r r r l", hdrB, bodyB), | |
| ("(C) Label definitions v2 / v3 / v4 / v4b --- events per hour and hands-on share, test split", "l l r r r r", hdrC, bodyC), | |
| ("(D) Vision-language hands-on gold --- three local candidates against the owner's frame-level clicks (every candidate fails the pre-registered acceptance)", "l r r r r r l l", hdrD, bodyD)]) | |
| # ---------------------------------------------------------------------------------------------- | |
| # R2 table 6 — verified-mask sensitivity (results/tables/stage_final_verified.md §1b compact table; §1 detailed table is the guard): | |
| # the six driver + eight vehicle onset cells, main model vs indep, under all rows / the 64-route suspect mask / the 3-route verified mask. | |
| # ---------------------------------------------------------------------------------------------- | |
| _VM_RE = re.compile(r"^([-+]\d+\.\d+ ± \d+\.\d+) \(([A-Z_]+); (\d+) / (\d+)\)$") | |
| _VM_PROTOS = [("verified mask (3)", "verified mask (3 routes)"), ("suspect mask (64)", "suspect mask (64 routes)"), ("all rows", "all rows")] | |
| def tab_verified_mask() -> pathlib.Path: | |
| vf = _R2["verified"] | |
| h1, r1, l1 = first_table(vf, "1. Driver + vehicle onset cells") | |
| hb, rb, lb = first_table(vf, "1b. Compact") | |
| b1, lb1 = find_line(vf, "B1 rule (hand_leave AND head_turn_onset BEATS k0") | |
| add, ladd = find_line(vf, "## Addendum") | |
| full = {(r[col(h1, "regime")], r[col(h1, "cell")], r[col(h1, "protocol")]): r for r in r1} | |
| comp = {(r[col(hb, "regime")], r[col(hb, "cell")]): r for r in rb} | |
| body = [] | |
| for title, cells in [("Driver onset cells (v2 causal kin targets)", _R2_DRV), ("Vehicle onset cells", _R2_VEH4)]: | |
| body.append(group(8, title)) | |
| for regime, _ in _R2_REGIMES: | |
| for cell in cells: | |
| r = comp[(regime, cell)] | |
| out = [regime, _r2_cell(cell)] | |
| for cname, pname in _VM_PROTOS: | |
| m = _VM_RE.match(r[col(hb, cname)].strip()) | |
| if not m: | |
| raise ValueError(f"stage_final_verified.md §1b: unparsed cell {r[col(hb, cname)]!r}") | |
| f = full[(regime, cell, pname)] | |
| if m.group(1) != f[col(h1, "mean Δ ± sd")].strip() or m.group(2) != f[col(h1, "verdict")].strip() or f"{m.group(3)} / {m.group(4)}" != f[col(h1, "n / pos")].strip(): | |
| raise ValueError(f"stage_final_verified.md: §1b disagrees with §1 for {regime} {cell} {pname}") | |
| out += [tx(m.group(1)), vd(m.group(2))] | |
| body.append(row(*out)) | |
| hdr = [r"\headrow Regime & Cell & \multicolumn{2}{c}{verified mask (3 routes)} & \multicolumn{2}{c}{suspect mask (64 routes)} & \multicolumn{2}{c}{all rows} \\", | |
| r"\cmidrule(lr){3-4}\cmidrule(lr){5-6}\cmidrule(lr){7-8}", | |
| ["", "", r"$\Delta$ mean $\pm$ sd", "verdict", r"$\Delta$ mean $\pm$ sd", "verdict", r"$\Delta$ mean $\pm$ sd", "verdict"]] | |
| cap = (r"Verified-mask sensitivity: the owner's human review of the 64 driver-box suspect routes left 3 routes labelled passenger or none (verified mask) and 61 verified driver routes. " | |
| r"Driver + vehicle onset cells (PR-AUC@3\,s), A = all\_minus\_road2drv (main) vs B = indep, test split, both regimes, 3 seeds; paired device-cluster bootstrap on identical rows ($n_{\mathrm{boot}}{=}1000$), mean $\Delta$ $\pm$ sd; " | |
| r"rows per cell: finalcv (3 verified routes censored from every population), finalcm (64 suspect routes censored; stage\_final.md §4), finalc (all rows; stage\_final.md §1); n / pos per protocol in the source. " | |
| + LEGEND + f"B1 line {lb1}: {tx(b1)} Addendum (line {ladd}): engaged hand\\_return is measured against a target that is not a hand-return label (pass 3 / 4) and carries no directional claim; the v3 label programme replaces the targets. " | |
| f"Sources: stage\\_final\\_verified.md §1b compact table (line {lb}), checked against §1 (line {l1}).") | |
| return emit("tab_verified_mask", cap, | |
| [f"{vf} : §1b compact mean Δ ± sd (verdict; n / pos) per protocol (table line {lb})", | |
| f"{vf} : §1 driver + vehicle onset cells, three protocols (table line {l1}; guard)", | |
| f"{vf} : §2 B1 rule line {lb1}; addendum line {ladd}"], | |
| [(None, "l l r l r l r l", hdr, body)]) | |
| # ---------------------------------------------------------------------------------------------- | |
| # R2 table 7a — future-state head F2′ (results/tables/future_state_eval.md): (A) verdict counts over regime x state x horizon per metric and | |
| # baseline; (B) engaged head_turned at 3 s, Brier and AUROC vs the three baselines; (C) recovery-time / first-leave MAE (s) of every state. | |
| # ---------------------------------------------------------------------------------------------- | |
| _FS_BASE = {"dwell_table": "dwell table (label-free, train empirical)", "final_closed_form": r"\cwname{} closed form (own hazards)", "persistence": "persistence"} | |
| _FS_STATE = {"hands_on": "hands on wheel", "head_turned": "head turned", "gaze_off": "gaze off"} | |
| _FS_ROWS = {"first_leave_all": "first leave (all anchors)", "remaining_dwell_off": "remaining dwell (off-task anchors)"} | |
| def tab_future_state() -> pathlib.Path: | |
| fs = _R2["future_state"] | |
| hV, rV, lV = first_table(fs, "Verdict counts (cells") | |
| hB, rB, lB = first_table(fs, "Occupancy BRIER") | |
| hA, rA, lA = first_table(fs, "Occupancy AUROC") | |
| hR, rR, lR = first_table(fs, "Recovery time") | |
| bodyA = [row({"auroc": "AUROC", "brier": "Brier"}[r[col(hV, "metric")]], _FS_BASE[r[col(hV, "baseline")]], | |
| *[tx(r[col(hV, k)]) for k in ["BEATS", "NOT_WORSE", "INCONCLUSIVE", "WORSE", "INSUFFICIENT"]]) for r in rV] | |
| hdrA = ["Metric", "Baseline", "better", "not worse", "n.s.", "worse", "insufficient"] | |
| bodyB = [] | |
| for mlab, h, rows in [("Brier (lower better)", hB, rB), ("AUROC (higher better)", hA, rA)]: | |
| for base in ["persistence", "dwell_table", "final_closed_form"]: | |
| r = next(r for r in rows if r[col(h, "regime")] == "engaged" and r[col(h, "state")] == "head_turned" and r[col(h, "horizon")] == "3s" and r[col(h, "baseline")] == base) | |
| bodyB.append(row(mlab, _FS_BASE[base], tx(r[col(h, "FS per seed")]), tx(r[col(h, "baseline per seed")]), tx(r[col(h, "mean Δ ± sd")]), vd(r[col(h, "verdict")]))) | |
| hdrB = ["Metric", "Baseline", "future-state head (s0 / s1 / s2)", "baseline (s0 / s1 / s2)", r"mean $\Delta$ $\pm$ sd", "verdict"] | |
| bodyC = [] | |
| for r in rR: | |
| na = lambda s: "--" if s.strip() == "n/a" else tx(s) # noqa: E731 | |
| bodyC.append(row(r[col(hR, "regime")], _FS_STATE[r[col(hR, "state")]], _FS_ROWS[r[col(hR, "rows")]], tx(r[col(hR, "n")]), tx(r[col(hR, "MAE FS")]), | |
| tx(r[col(hR, "MAE dwell table")]), vd(r[_hcol(hR, "verdict")]), na(r[col(hR, "MAE FINAL closed form")]), na(vd(r[_hcol(hR, "verdict") + 3]) if r[_hcol(hR, "verdict") + 3].strip() != "n/a" else "n/a"))) | |
| hdrC = ["Regime", "State", "Anchors", r"$n$", "MAE head", "MAE dwell table", "verdict", "MAE closed form", "verdict"] | |
| cap = (r"F2$'$ future-state head: a detached horizon-conditioned head ($\approx$0.034\,M params) on the FROZEN joint model's driver state $z_U$ + label-free dwell features, trained on the train anchors of both regimes, " | |
| r"selected on validation occupancy BCE; test split, seeds 0 / 1 / 2, device-cluster bootstrap ($n_{\mathrm{boot}}{=}500$). States hands\_on / head\_turned (v2 causal kin targets) and gaze\_off (own landmark chain, validation pending). " | |
| r"Baselines: persistence $\pi_k = z_0$; dwell table = train empirical $P(s_{t+k} \mid z_0, \text{time-in-state bin})$; FINAL closed form = forward marginal of the frozen model's own hazards (hands / head only). " | |
| r"(A) Verdict counts over the cells regime $\times$ state $\times$ horizon (1 / 2 / 3 / 5\,s); (B) engaged head\_turned at 3\,s; (C) MAE in s of $E[\min(T, 5.2\,\mathrm{s})]$ for the first-leave time (all anchors) and the remaining dwell in the off-task state, " | |
| r"paired $\Delta$ per seed and CIs in the source. $\Delta$ = head $-$ baseline; Brier / MAE lower better, AUROC higher. " + LEGEND + | |
| f"Nothing here changes the headline model. Sources: future\\_state\\_eval.md verdict counts (line {lV}), Brier (line {lB}), AUROC (line {lA}), recovery time (line {lR}).") | |
| return emit("tab_future_state", cap, | |
| [f"{fs} : Verdict counts (table line {lV})", f"{fs} : Occupancy BRIER, engaged head_turned 3s rows (table line {lB})", | |
| f"{fs} : Occupancy AUROC, engaged head_turned 3s rows (table line {lA})", f"{fs} : Recovery time / first-leave MAE (table line {lR})"], | |
| [(r"(A) Verdict counts over the 24 occupancy cells per metric and baseline (16 for the closed form: hands / head only)", "l l r r r r r", hdrA, bodyA), | |
| (r"(B) Engaged head-turned occupancy at 3\,s", "l l l l r l", hdrB, bodyB), | |
| (r"(C) Recovery time and first-leave time, MAE in s (gaze off: own landmark chain, validation pending; no closed form)", "l l l r r r l r l", hdrC, bodyC)]) | |
| # ---------------------------------------------------------------------------------------------- | |
| # R2 table 7b — face channels into the driver GRU, F3 (results/tables/stage_final_face.md): validation (adoption decision) and test | |
| # (confirmation) Δ of the six driver cells vs the FROZEN main model with the acceptable-degradation margin flags. | |
| # ---------------------------------------------------------------------------------------------- | |
| def _face_margin(cell: str) -> str: | |
| s = cell.replace("**", "").strip() | |
| return "broken" if s.startswith("NO") else ("within" if s.startswith("yes") else tx(s)) | |
| def tab_face() -> pathlib.Path: | |
| fc = _R2["face"] | |
| hv, rv, lv = first_table(fc, "Driver cells with the acceptable-degradation margins — VALIDATION (a-val)") | |
| ht, rt, lt = first_table(fc, "Driver cells with the acceptable-degradation margins — TEST (a)") | |
| dec, ld = find_line(fc, "## DECISION") | |
| q, lq = find_line(fc, "## F3 QUESTION") | |
| ans, lans = find_line(fc, "- **NO —") | |
| idx = {} | |
| for tag, h, rows in [("val", hv, rv), ("test", ht, rt)]: | |
| for r in rows: | |
| if r[col(h, "metric")].strip().startswith("pr_auc"): | |
| idx[(tag, r[col(h, "regime")], r[col(h, "cell")])] = (h, r) | |
| body = [] | |
| for regime, rtitle in _R2_REGIMES: | |
| body.append(group(8, rtitle)) | |
| for cell in _R2_DRV: | |
| out = [regime, _r2_cell(cell)] | |
| for tag in ("val", "test"): | |
| h, r = idx[(tag, regime, cell)] | |
| out += [tx(r[col(h, "mean Δ ± sd")]), vd(r[col(h, "verdict")]), _face_margin(r[col(h, "within margin")])] | |
| body.append(row(*out)) | |
| hdr = [r"\headrow Regime & Cell & \multicolumn{3}{c}{Validation split (adoption decision)} & \multicolumn{3}{c}{Test split (confirmation)} \\", | |
| r"\cmidrule(lr){3-5}\cmidrule(lr){6-8}", | |
| ["", "", r"$\Delta$ mean $\pm$ sd", "verdict", "margin", r"$\Delta$ mean $\pm$ sd", "verdict", "margin"]] | |
| cap = (r"F3: face channels into the driver GRU (FINAL U recipe + the 9 causal face-landmark channels + the face valid bit; no gaze chain), 3 seeds, both regimes, vs the FROZEN main model; " | |
| r"driver-onset PR-AUC@3\,s (v2 causal kin targets), paired device-cluster bootstrap on identical rows ($n_{\mathrm{boot}}{=}1000$), mean $\Delta$ $\pm$ sd (variant $-$ main). " | |
| r"Pre-registered reading: acceptable degradation $-0.005$ PR-AUC (mean $\Delta$ within the margin and no seed CI entirely beyond it); adoption candidate iff on VALIDATION no own onset cell is WORSE or breaks its margin AND head\_turn\_onset BEATS in $\geq 1$ regime; test = confirmation. " | |
| r"Margin column: within / broken. " + LEGEND + | |
| f"Decision (line {ld}): {tx(dec.lstrip('#').strip().replace('**', ''))}. F3 question (line {lq}): {tx(q.lstrip('#').strip())} --- answer (line {lans}): {tx(ans.lstrip('- ').replace('**', ''))} " | |
| f"Sources: stage\\_final\\_face.md driver cells with margins, validation (line {lv}) and test (line {lt}).") | |
| return emit("tab_face", cap, | |
| [f"{fc} : DECISION (line {ld}); F3 question (line {lq}) and answer (line {lans})", | |
| f"{fc} : §1 driver cells with the acceptable-degradation margins — VALIDATION (a-val) (table line {lv}; pr_auc rows)", | |
| f"{fc} : §2 driver cells with the acceptable-degradation margins — TEST (a) (table line {lt}; pr_auc rows)"], | |
| [(None, "l l r l l r l l", hdr, body)]) | |
| # ---------------------------------------------------------------------------------------------- | |
| # R2 table 8 — row-masked warning heads (results/tables/warning_head_final_ext_rmv.md, block appended 2026-09-16T17:39:51Z): clean-test | |
| # AUROC per stratum of the current-state head, the current + dwell + face head and the openpilot-derived surrogate under unmasked / | |
| # suspect-mask (rm) / verified-mask (rmv) protocols, with the paired Δ vs the surrogate. | |
| # ---------------------------------------------------------------------------------------------- | |
| _WR_PROTOS = [("unmasked", "Unmasked"), ("suspect mask (64 routes), tag rm", "Suspect mask: 64 driver-box suspect routes censored"), | |
| ("verified mask (3 routes), tag rmv", "Verified mask: 3 human-verified wrong-occupant routes censored")] | |
| _WR_HEADS = [("current (HGB)", r"\cwname{} head, current state (fixed HGB)"), | |
| ("current + dwell + face (HGB)", r"\cwname{} head, current state + dwell + face (fixed HGB)"), | |
| ("DMS att@3s (legacy_att, comparator)", r"openpilot-derived surrogate (att@3\,s), per seed")] | |
| _WR_VERD_RE = re.compile(r"^([A-Z_]+) \((\d/\d) CI excl\. 0\)$") | |
| def _wr_auroc(cell: str) -> str: | |
| s = re.sub(r"\s*\(×3 seeds identical\)\s*$", "", cell.strip()) | |
| return _seed_deltas(s) if " / " in s else tx(s) | |
| def tab_warning_rmv() -> pathlib.Path: | |
| wr = _R2["wh_rmv"] | |
| hA, rA, lA = first_table(wr, "A. AUROC per stratum") | |
| hB, rB, lB = first_table(wr, "B. Paired Δ vs the DMS attention chain", merge_col=2) # stratum cells carry a literal "|" (clean_test|manual) | |
| intro, li = find_line(wr, "## Appended 2026-09-16T17:39:51Z") | |
| body = [] | |
| for pkey, ptitle in _WR_PROTOS: | |
| rowsA = {r[col(hA, "head")]: r for r in rA if r[col(hA, "mask protocol")].startswith(pkey)} | |
| npos = {r[col(hA, "n / pos")] for r in rowsA.values()} | |
| if len(rowsA) != 3 or len(npos) != 1: | |
| raise ValueError(f"warning_head_final_ext_rmv.md A: protocol {pkey!r} -> {len(rowsA)} heads, n/pos {npos}") | |
| body.append(group(7, f"{ptitle} --- gold rows / positives (pooled, manual, engaged): {tx(npos.pop())}")) | |
| for hkey, hlab in _WR_HEADS: | |
| r = rowsA[hkey] | |
| out = [hlab] + [_wr_auroc(r[col(hA, k)]) for k in ["pooled AUROC", "manual AUROC", "engaged AUROC"]] | |
| for stratum in ["clean_test", "clean_test|manual", "clean_test|engaged"]: | |
| d = [x for x in rB if x[col(hB, "head")] == hkey and x[col(hB, "mask protocol")] == pkey and x[col(hB, "stratum")] == stratum] | |
| if not d: | |
| out.append("--") | |
| continue | |
| m = _WR_VERD_RE.match(d[0][col(hB, "verdict")].strip()) | |
| if not m: | |
| raise ValueError(f"warning_head_final_ext_rmv.md B: unparsed verdict {d[0][col(hB, 'verdict')]!r}") | |
| out.append(tx(d[0][col(hB, "mean Δ")]) + f" ({m.group(2)})" + {"BEATS": r"\,\cmark", "WORSE": r"\,\xmark"}.get(m.group(1), "")) | |
| body.append(row(*out)) | |
| hdr = [r"\headrow Score & \multicolumn{3}{c}{AUROC [95\% CI]} & \multicolumn{3}{c}{$\Delta$ vs surrogate (seeds with CI excl.\ 0)} \\", | |
| r"\cmidrule(lr){2-4}\cmidrule(lr){5-7}", ["", "pooled", "manual", "engaged", "pooled", "manual", "engaged"]] | |
| cap = (r"Row-masked warning heads on the clean HUMAN gold (episode labels; unchanged cwm2 \texttt{warning\_gold.py}, AUROC, device-cluster bootstrap $n_{\mathrm{boot}}{=}2000$): clean-test AUROC per stratum of the current-state head (fixed HGB), the " | |
| r"current + dwell + face head and the openpilot DMS attention chain (att@3s) under three mask protocols --- unmasked (item cwm3\_final\_ext), the 64 driver-box suspect routes removed from train and evaluation (rm, item cwm3\_final\_ext\_rm) and the 3 human-verified " | |
| r"wrong-occupant routes removed (rmv, item cwm3\_final\_ext\_rmv). Current-state heads are seed-invariant by construction (the joint model's seed enters no current-state feature), so their three seeds coincide; the DMS comparator varies with the seed. " | |
| r"A mask only removes the gold rows on the masked routes (hence the different n / pos); the precision of the automatic switch labels does not enter these numbers. $\Delta$ vs DMS = paired AUROC difference on identical rows / resamples, mean over seeds, with the count of seeds whose CI excludes 0; " | |
| r"\cmark\ = BEATS by kill\_checks.beats. " + f"Sources: warning\\_head\\_final\\_ext\\_rmv.md appended block (line {li}): A. AUROC per stratum (line {lA}), B. paired Δ vs the DMS attention chain (line {lB}).") | |
| return emit("tab_warning_rmv", cap, | |
| [f"{wr} : appended block 2026-09-16T17:39:51Z (line {li})", | |
| f"{wr} : A. AUROC per stratum under unmasked / rm / rmv (table line {lA}; AUROC [CI] per stratum, n / pos)", | |
| f"{wr} : B. paired Δ vs the DMS attention chain per stratum (table line {lB}; mean Δ, verdict with CI-excl.-0 count)"], | |
| [(None, "p{0.30\\linewidth} l l l l l l", hdr, body)]) | |
| # ---------------------------------------------------------------------------------------------- | |
| # R2 table 9 -- oracle-feature diagnostic of the warning read-out (results/tables/warning_oracle_diagnostic.md, eval/warning_oracle_diagnostic.py, | |
| # run 20260916T070907Z; owner decision 2026-09-17 item 8: one sentence in the main paper, the full three-level table in Supp. C). | |
| # Rows = level x stratum: §1 clean-test AUROC (mean ± sd over the three final seeds; the true-future levels are seed-invariant) and §2 paired | |
| # Δ vs the current-state base on identical rows and resamples (mean ± sd, seeds whose CI excludes 0, the source's paired reading). | |
| # ---------------------------------------------------------------------------------------------- | |
| _WOD_LEVELS = [ # (level label of the source, rendered group title) | |
| ("base: cur+dwell+face", "base: causal current state + dwell + face (the read-out of the main paper)"), | |
| ("(a) true-future onset scores alone", "(a) true future onset scores alone, no current-state feature"), | |
| ("(b) cur+dwell+face + TRUE future occupancy/recovery", "(b) base + true future occupancy and recovery times"), | |
| ("(b+) (b) + true-future onset scores", "(b+) as (b) + true future onset scores"), | |
| ("(c) cur+dwell+face + PREDICTED future (in-sample packs)", "(c) base + the model's predicted future (in-sample feature packs)"), | |
| ("(c-oof) cur+dwell+face + PREDICTED future (OOF packs)", "(c-oof) base + the model's predicted future (out-of-fold feature packs)"), | |
| ] | |
| _WOD_VERD = {"no paired evidence (CIs ⊃ 0)": "n.s.", "LOSS (CI < 0 in some seed)": r"CI $<$ 0 on some seed"} | |
| def tab_supp_oracle_diag() -> pathlib.Path: | |
| wod = _R2["oracle"] | |
| h1, r1, l1 = first_table(wod, "1. Clean-test AUROC") | |
| h2, r2, l2 = first_table(wod, "2. Paired") | |
| read, lrd = find_line(wod, "### 4. Reading") | |
| lv = {(r[col(h1, "level")].strip(), r[col(h1, "stratum")].strip()): r for r in r1} | |
| dl = {(r[col(h2, "level")].strip(), r[col(h2, "stratum")].strip()): r for r in r2} | |
| body = [] | |
| for raw, label in _WOD_LEVELS: | |
| body.append(group(6, label)) | |
| for stratum in ("pooled", "manual", "engaged"): | |
| r = lv[(raw, stratum)] | |
| cells = [stratum, tx(r[col(h1, "mean ± sd")]), tx(r[col(h1, "n / pos")])] | |
| d = dl.get((raw, stratum)) | |
| if d is None: | |
| cells += ["--", "--", "--"] | |
| else: | |
| v = d[col(h2, "verdict")].strip() | |
| cells += [tx(d[col(h2, "mean Δ ± sd")]), tx(d[col(h2, "CI excl. 0")]), _WOD_VERD.get(v, tx(v))] | |
| body.append(row(*cells)) | |
| hdr = ["Stratum", r"AUROC, mean $\pm$ sd", "rows / positives", r"$\Delta$ vs base, mean $\pm$ sd", r"seeds CI excl.\ 0", "paired reading"] | |
| cap = (r"Oracle-feature diagnostic of the warning read-out (eval/warning\_oracle\_diagnostic.py, run 20260916T070907Z; the trainer's HGB grid + device-grouped 5-fold CV on the 979 clean TRAIN " | |
| r"consensus labels; gold = 512 clean-test rows / 63 positives / 47 devices; device-cluster bootstrap 2,000 shared by every level, so every $\Delta$ is paired on identical rows). " | |
| r"Levels: base = cur+dwell+face (77 current-state features); (a) TRUE-future onset scores alone; (b) base + TRUE future occupancy / recovery; (b+) = (b) + onset scores; " | |
| r"(c) base + the model's PREDICTED future (144 is\_future features, in-sample packs); (c-oof) the same with out-of-fold packs. Not an upper bound: one feature set, one read-out. " | |
| + f"Pre-registered reading (line {lrd}): {tx(read.lstrip('#').strip().replace('**', ''))} " | |
| + f"Sources: warning\\_oracle\\_diagnostic.md §1 (line {l1}), §2 (line {l2}).") | |
| return emit("tab_supp_oracle_diag", cap, | |
| [f"{wod} : §1 clean-test AUROC per level and stratum (table line {l1}; mean ± sd, n / pos)", | |
| f"{wod} : §2 paired Δ vs base, identical rows and resamples (table line {l2}; mean Δ ± sd, CI excl. 0 count, verdict)", | |
| f"{wod} : §4 pre-registered reading (line {lrd})"], | |
| [(None, "l r r r c l", hdr, body)]) | |
| # ---- registration (lazy: every source of a generator must exist), short captions, layout hooks ----------------------------------- | |
| _r2_register(tab_modality_ablation, "modality") | |
| _r2_register(tab_ecan, "ecan") | |
| _r2_register(tab_road_dynamics, "road_dyn") | |
| _r2_register(tab_supp_motionbert_faithful, "mb_faithful") | |
| _r2_register(tab_label_check, "review", "kin_v3", "kin_v4", "kin_v4b", "vlm") | |
| _r2_register(tab_verified_mask, "verified") | |
| _r2_register(tab_future_state, "future_state") | |
| _r2_register(tab_face, "face") | |
| _r2_register(tab_warning_rmv, "wh_rmv") | |
| _r2_register(tab_supp_oracle_diag, "oracle") | |
| SHORT["tab_modality_ablation"] = (r"Vehicle-onset PR-AUC within 3\,s, BATON test split, both regimes, 3 seeds (paired device-cluster bootstrap; mean $\pm$ sd over seeds). " | |
| r"(A) Each fusion variant minus the independent branches; (B) minus \cwname\ (visual-only environment input); reference rows give the level. " | |
| r"\cmark/\xmark: significantly better/worse; no mark: no significant difference. UW, FAMO, PCGrad: multi-task weighting of the scratch fusion.") | |
| SHORT["tab_ecan"] = (r"Environment branch with a CAN side stream --- (a) vision + 40 CAN road features = \cwname\ (ECAN, without forecaster distillation), (a2) CAN only, no vision tokens --- versus \cwname\ (visual-only environment input): " | |
| r"onset PR-AUC within 3\,s, BATON test, both regimes, 3 seeds. Paired $\Delta$ = variant $-$ main, mean $\pm$ sd; better/worse = significant, n.s./not worse = no significant difference.") | |
| SHORT["tab_road_dynamics"] = (r"Forecasting road demand from CAN history (BATON test, both regimes). (A) MAE at 1/3/5\,s of persistence, constant velocity and the learned arms dyn (GRU on the CAN history) " | |
| r"and dynvis (+ frozen vision), mean $\pm$ sd over 3 seeds. (B) Demand-onset PR-AUC within 3\,s derived from the forecast against the current-margin rule $S_0$; $\Delta$ per seed, verdicts by the pre-specified rule.") | |
| SHORT["tab_supp_motionbert_faithful"] = (r"Released MotionBERT weights fine-tuned on AIDE (test, $n{=}609$; 3 seeds). (A) Levels: (a) anchored read-out, (b) their absolute read-out, (c) same architecture from random init; " | |
| r"\cwname{} references. MPJPE in px (lower better), PCK in \% (higher). (B) Paired per-clip $\Delta$, mean $\pm$ sd; verdicts by the project-wide $\geq 2/3$-seed rule; " | |
| r"the strict 3/3 count is footnoted. Post-hoc rows: not pre-registered.") | |
| SHORT["tab_label_check"] = (r"Validation chain of the automatic driver-state labels. (A) Human review of the 64 suspect driver-box routes. (B) Precision of the automatic switch labels (owner labelling, Wilson 95\,\% CI) and the blind re-labelling passes of hand return. " | |
| r"(C) Event rates and hands-on shares under label definitions v2--v4b (test split). (D) Local vision-language models against frame-level clicks; all fail the pre-registered acceptance.") | |
| SHORT["tab_verified_mask"] = (r"Sensitivity of the driver and vehicle onset cells (PR-AUC within 3\,s, BATON test, 3 seeds) to the driver-box mask: all rows, the 64 suspect routes censored, and only the 3 human-verified wrong-occupant routes censored. " | |
| r"Paired $\Delta$ = \cwname{} $-$ independent branches, mean $\pm$ sd; verdicts by the pre-specified rule.") | |
| SHORT["tab_future_state"] = (r"Detached future-state head on the frozen \cwname{} driver state (BATON test, 3 seeds): occupancy of hands-on / head-turned / gaze-off at 1--5\,s against persistence, a label-free dwell table and the model's own closed form. " | |
| r"(A) Verdict counts over cells; (B) engaged head-turned at 3\,s; (C) recovery-time MAE in s. Better = significantly lower Brier or MAE, higher AUROC.") | |
| SHORT["tab_face"] = (r"Face-landmark channels added to the driver branch (F3) versus \cwname\ (visual-only environment input): driver-onset PR-AUC within 3\,s, 3 seeds, paired $\Delta$ = variant $-$ that configuration (mean $\pm$ sd). " | |
| r"Validation decided adoption (rejected: hand leave and hand return degrade beyond the $-0.005$ margin); test confirms. Margin: within or broken by the pre-specified acceptable-degradation rule.") | |
| SHORT["tab_warning_rmv"] = (r"Current-state warning heads and the openpilot-derived surrogate (att@3\,s) on the clean human gold under three row masks: unmasked, the 64 suspect driver-box routes censored, the 3 verified wrong-occupant routes censored. " | |
| r"AUROC with device-cluster CIs per stratum; paired $\Delta$ vs the surrogate with the number of seeds whose CI excludes 0; \cmark = significantly better.") | |
| SHORT["tab_supp_oracle_diag"] = (r"Oracle-feature diagnostic of the warning read-out on the 512-row human gold (63 positives; the read-out's learner, labels and folds): clean-test AUROC per level and stratum, " | |
| r"and the paired difference to the current-state base with the number of seeds whose interval excludes zero. True-future levels read the labels themselves; predicted levels read the model's forecasts.") | |
| OURS["tab_supp_oracle_diag"] = _NEVER # every row is a diagnostic level of the same read-out | |
| ICLR_COLSPEC["tab_supp_oracle_diag"] = {0: tiny("l r r r c l")} | |
| OURS["tab_modality_ablation"] = lambda cells, grp: cells[0].startswith(("all = V+E+U", "all (\\cwname")) | |
| OURS["tab_ecan"] = _NEVER # every row is a variant-vs-main Δ | |
| OURS["tab_road_dynamics"] = _NEVER # the learned arms are new heads, the P head is a comparator here | |
| OURS["tab_supp_motionbert_faithful"] = lambda cells, grp: cells[0].startswith("\\cwname") | |
| OURS["tab_label_check"] = _NEVER | |
| OURS["tab_verified_mask"] = _NEVER # every row pairs the main model with the independent branches | |
| OURS["tab_future_state"] = _NEVER | |
| OURS["tab_face"] = _NEVER | |
| OURS["tab_warning_rmv"] = lambda cells, grp: cells[0].startswith("\\cwname") | |
| # no per-column \best{} in any R2 table (Δ rows carry their own verdict; the MAE and level blocks are descriptive) — BEST has no entry | |
| ICLR_COLSPEC["tab_modality_ablation"] = {0: "p{0.36\\linewidth} r r r r", 1: "p{0.36\\linewidth} r r r r"} | |
| ICLR_COLSPEC["tab_ecan"] = {0: tiny("l r l r l r l r l")} | |
| ICLR_COLSPEC["tab_road_dynamics"] = {0: "l l r r r r", 1: sized("scriptsize", "p{0.36\\linewidth} l l l")} # (B) at \\small was 13.2 pt too wide in the ICLR column (2026-09-17 build) | |
| ICLR_COLSPEC["tab_supp_motionbert_faithful"] = {0: tiny("p{0.26\\linewidth} r r r r r r"), 1: tiny("p{0.27\\linewidth} r l r l r l")} # first compile: 102.7 / 24.6 pt overfull | |
| ICLR_COLSPEC["tab_label_check"] = {0: "l r r r r", 1: tiny("l l l r r r r r l"), 2: "l l r r r r", 3: tiny("l r r r r r l l")} | |
| ICLR_COLSPEC["tab_verified_mask"] = {0: tiny("l l r l r l r l")} | |
| ICLR_COLSPEC["tab_future_state"] = {0: "l l r r r r r", 1: tiny("l l l l r l"), 2: tiny("l l l r r r l r l")} | |
| ICLR_COLSPEC["tab_face"] = {0: tiny("l l r l l r l l")} | |
| ICLR_COLSPEC["tab_warning_rmv"] = {0: ">{\\tiny}p{0.24\\linewidth}" + "".join("@{\\hskip 2pt}>{\\tiny}l" for _ in range(6))} # six CI / Δ columns at 2 pt | |
| ICLR_NEWFLOAT["tab_road_dynamics"] = {1} # (A) 24 MAE rows and (B) 30 onset rows as two floats | |
| # ---------------------------------------------------------------------------------------------- | |
| # Supplement table — pre-registered HM h=5 arms (aide/results/tables/hm_h5_arms.md, written by aide/eval/report_hm_h5_arms.py from saved | |
| # predictions only; pre-registration docs/decisions.md 2026-09-17T07:00:22Z part (A), outcome 09:24:11Z, verification 12:08:31Z). Five arms | |
| # on the adopted recipe of CockpitWM + BATON pretraining (hand-joint loss weight 2 / 4, learned per-horizon residual gain, hand-specific gain, | |
| # weight 2 + learned gain), 3 seeds each, selected on validation; every arm reported regardless (reading rule: none reportable). (A) test | |
| # levels per arm, (B) paired per-clip Δ arm − adopted row with the seeds whose CI excludes 0 and the reading-rule outcome. Lazy, like the | |
| # hm_subsets table: emitted only with --style iclr and only when the report exists; \input in Supp. A after the HM h=5 defence sentences. | |
| # ---------------------------------------------------------------------------------------------- | |
| _HMA_PATH = AT / "hm_h5_arms.md" | |
| _HMA_ARMS = [("adopted row", r"adopted row: \cwname\ + BATON pretraining"), | |
| ("(a1) hw2", "(a1) hand-joint loss weight 2"), ("(a2) hw4", "(a2) hand-joint loss weight 4"), | |
| ("(b) hgain", "(b) learned per-horizon residual gain"), ("(c) hgainp", "(c) hand-specific per-horizon gain"), | |
| ("(d) hw2hgain", "(d) weight 2 + learned per-horizon gain")] | |
| _HMA_SEC = {"(a1) hw2": "3.1 (a1) hw2", "(a2) hw4": "3.2 (a2) hw4", "(b) hgain": "3.3 (b) hgain", "(c) hgainp": "3.4 (c) hgainp", | |
| "(d) hw2hgain": "3.5 (d) hw2hgain"} | |
| _HMA_LEVEL_COLS = ["All-MPJPE", "d-n", "HM-MPJPE", "HM h=5", "HM hands h=5", "PCK@0.05"] | |
| _HMA_DELTA_ROWS = ["HM h=5", "All-MPJPE", "HM hands h=5"] | |
| _HMA_CI_RE = re.compile(r"\s*\[[^\]]*\]\s*$") | |
| def _hma_level(cell: str) -> str: | |
| """'48.01 ± 0.03 [44.31, 52.08]' -> '48.01 ± 0.03' (the clip-bootstrap CI of the seed mean stays in the md).""" | |
| return tx(_HMA_CI_RE.sub("", cell.strip())) | |
| def tab_supp_hm_h5_arms() -> pathlib.Path: | |
| hL, rL, lL = first_table(_HMA_PATH, "2. Levels") | |
| cL = {k: col(hL, k) for k in ["arm"] + _HMA_LEVEL_COLS} | |
| hR, rR, lR = first_table(_HMA_PATH, "4. Pre-registered reading rule applied") | |
| cR = {"arm": col(hR, "arm"), "rep": col(hR, "reportable")} | |
| hdrA = ["Arm", "All-MPJPE", "d-n", "HM-MPJPE", "HM $h{=}5$", "HM hands $h{=}5$", "PCK@0.05"] | |
| hdrB = ["Arm", r"$\Delta$ HM $h{=}5$", r"CI excl.\ 0", r"$\Delta$ All-MPJPE", r"CI excl.\ 0", r"$\Delta$ HM hands $h{=}5$", r"CI excl.\ 0", "Reportable"] | |
| bodyA, bodyB, srcs, lines_d = [], [], [], [] | |
| for key, label in _HMA_ARMS: | |
| r = find_row(rL, cL["arm"], key) | |
| bodyA.append(row(label, *[_hma_level(r[cL[k]]) for k in _HMA_LEVEL_COLS])) | |
| if key == "adopted row": | |
| continue | |
| h, rows, ln = first_table(_HMA_PATH, _HMA_SEC[key]) | |
| c = {k: col(h, k) for k in ["cell", "Δ s42 [CI]", "Δ s123 [CI]", "Δ s456 [CI]", "mean Δ ± sd"]} | |
| cells = [] | |
| for q in _HMA_DELTA_ROWS: | |
| rq = find_row(rows, c["cell"], q) | |
| cells += [tx(rq[c["mean Δ ± sd"]]), ci_excl([rq[c[k]] for k in ["Δ s42 [CI]", "Δ s123 [CI]", "Δ s456 [CI]"]])] | |
| rep = find_row(rR, cR["arm"], key)[cR["rep"]].replace("**", "").strip() | |
| bodyB.append(row(label, *cells, {"NO": "no", "YES": "yes"}.get(rep, tx(rep)))) | |
| lines_d.append(str(ln)) | |
| rule, lrule = find_line(_HMA_PATH, "**Pre-registered reading rule (verbatim)") | |
| cap = (r"Appendix: pre-registered HM $h{=}5$ arms on the AIDE test split ($n{=}609$; px, PCK in \%): five variations of the adopted CockpitWM + BATON pretraining recipe " | |
| r"(hand-joint loss weight 2 / 4 on the 42 hand keypoints in the Euclidean term; a learned per-horizon residual gain; a hand-specific per-horizon gain; weight 2 + learned gain), " | |
| r"3 seeds each (42 / 123 / 456), every run selected on validation All-MPJPE only and the test split evaluated once. (A) Seed mean $\pm$ sd of the test levels. " | |
| r"(B) Paired per-clip $\Delta$ = arm $-$ adopted row (seed-matched, 10k clip bootstrap), mean $\pm$ sd over seeds and the number of seeds whose CI excludes 0 (k/n); " | |
| r"'reportable' = the pre-registered rule (HM $h{=}5$ improves by $\geq 3$ px with the CI excluding zero on $\geq 2/3$ seeds AND All-MPJPE degrades by $\leq 0.2$ px). " | |
| f"Outcome: no arm is reportable; the adopted row is unchanged. Sources: hm\\_h5\\_arms.md \\S{{}}2 (line {lL}), \\S{{}}3.1--3.5 (lines {', '.join(lines_d)}), " | |
| f"\\S{{}}4 (line {lR}), reading rule line {lrule}.") | |
| return emit("tab_supp_hm_h5_arms", cap, | |
| [f"{_HMA_PATH} : §2 levels, seed mean ± sd (table line {lL})"] | |
| + [f"{_HMA_PATH} : §{_HMA_SEC[k]} paired Δ arm − adopted row (table line {ln})" for (k, _), ln in zip(_HMA_ARMS[1:], lines_d)] | |
| + [f"{_HMA_PATH} : §4 reading rule applied (table line {lR}); rule text line {lrule}"], | |
| [("(A) Test levels per arm: seed mean $\\pm$ sd over the three seeds (px; PCK@0.05 in \\%)", "p{0.30\\linewidth} r r r r r r", hdrA, bodyA), | |
| ("(B) Paired per-clip $\\Delta$ = arm $-$ adopted row (seed-matched; mean $\\pm$ sd over seeds; seeds whose CI excludes 0) and the pre-registered reading rule", | |
| "p{0.30\\linewidth} r c r c r c c", hdrB, bodyB)]) | |
| if _HMA_PATH.exists(): # lazy, as the hm_subsets table: a checkout without the report still generates everything else | |
| SRC["hm_h5_arms"] = _HMA_PATH | |
| ICLR_GENERATORS.append(tab_supp_hm_h5_arms) | |
| SHORT["tab_supp_hm_h5_arms"] = (r"Pre-registered sensitivity arms for the last-horizon high-motion error on AIDE test ($n{=}609$; three seeds each, selected on validation; " | |
| r"every arm reported, none adopted). (A) Test levels per arm, seed mean $\pm$ sd, px (PCK in \%). (B) Paired per-clip $\Delta$ = arm minus the " | |
| r"adopted \cwname\ + BATON pretraining row, mean $\pm$ sd over seeds, seeds whose interval excludes zero, and the reading-rule outcome.") | |
| OURS["tab_supp_hm_h5_arms"] = lambda cells, grp: cells[0].startswith("adopted row") # the reference row of both blocks | |
| ICLR_COLSPEC["tab_supp_hm_h5_arms"] = {0: tiny("p{0.30\\linewidth} r r r r r r"), 1: tiny("p{0.30\\linewidth} r c r c r c c")} | |
| # Owner experiment C column of the main-text interaction table (see tab_main_baton_interaction): eight columns and a caption naming the arm | |
| # when the report exists; without it the table keeps its seven-column layout and caption byte-identically. | |
| if _UDW_PATH.exists(): | |
| ICLR_COLSPEC["tab_main_baton_interaction"] = {0: sized("scriptsize", "l r r r r r r r")} | |
| SHORT["tab_supp_baton_interaction_visual"] = (r"\cwname\ (visual-only environment input), the input ablation: BATON test, onset PR-AUC within 3\,s, 3 seeds, levels at seed~0. " | |
| r"$\Delta$: mean $\pm$ sd over seeds of the paired difference to the independent branches for this configuration, the all-paths variant and " | |
| r"the from-scratch fusion; last column: a Driver-WM-style Transformer U trunk (21.2\,M against 0.06\,M, not parameter-matched) minus this " | |
| r"configuration. \cmark/\xmark: significantly better/worse; CAN-only: earlier system.") | |
| SHORT["tab_main_baton_interaction"] = (r"BATON test, onset PR-AUC within 3\,s, 3 seeds, levels at seed~0. $\Delta$: mean $\pm$ sd over seeds of the paired device-cluster " | |
| r"difference to the independent branches for \cwname, the all-paths variant and the from-scratch fusion; last column: \cwname\ with a " | |
| r"Driver-WM-style Transformer U trunk (21.2\,M against 0.06\,M U-trunk parameters, same inputs, not parameter-matched) minus \cwname. " | |
| r"\cmark/\xmark: significantly better/worse by the pre-specified rule; CAN-only: earlier system.") | |
| # ---------------------------------------------------------------------------------------------- | |
| # Supplement table — Driver-WM quantile sweep (aide/results/tables/driverwm_quantile_sweep.md, written by aide/eval/report_driverwm_quantile_sweep.py | |
| # from the frozen hm_subsets.json; item (B) of the pre-registration docs/decisions.md 2026-09-17T07:00:22Z, outcome 07:13:28Z: 'compiled; release | |
| # check: NOT RELEASED'). Levels of zero velocity, the published Driver-WM (only the cells that exist: top-10 % 138.03 / 155.82 and the full-set | |
| # All-MPJPE 71.47; every other cell '--' = not published), our reimplementation of Driver-WM (their formulation; it does NOT reproduce the published | |
| # numbers), the Driver-WM architecture on CockpitWM tokens and the CockpitWM models, on the top 5 / 10 / 20 / 30 / 50 / 100 % motion subsets: | |
| # (A) horizon-averaged MPJPE, (B) h=5 MPJPE, (C) paired Δ CockpitWM − architecture port (h=5 and horizon-averaged, seeds with CI excl. 0, verdict). | |
| # Owner instruction 2026-09-17 (round 3). Lazy: emitted only with --style iclr and only when the report exists; \input in Supp. A next to the | |
| # HM h=5 paragraph. master_aide.md is also read by tab_main_aide for the architecture-port level row (same owner instruction). | |
| # ---------------------------------------------------------------------------------------------- | |
| _DQ_PATH = AT / "driverwm_quantile_sweep.md" | |
| _MA_PATH = AT / "master_aide.md" | |
| _DQ_ROWS = [("zero-velocity", "Zero velocity"), | |
| ("Driver-WM published, single run (v2 Table 1 / Table 7 seed 42; text / Tables 10–11 for h=5)", "Driver-WM published, single run"), | |
| ("Driver-WM published, 3-seed mean ± sd (v2 Table 8, seeds 42/123/456)", "Driver-WM published, three seeds (Table 8)"), | |
| ("Driver-WM reproduction (ours, their formulation)", "Driver-WM, our reimplementation (their formulation; does not reproduce the published numbers)"), | |
| ("Driver-WM architecture on CockpitWM tokens", "Driver-WM architecture on CockpitWM tokens"), | |
| ("CockpitWM", "CockpitWM"), ("CockpitWM + BATON pretraining", "CockpitWM + BATON pretraining"), | |
| ("CockpitWM (+ semantic heads)", "CockpitWM (+ semantic heads)")] | |
| _DQ_Q = ["top 5 %", "top 10 %", "top 20 %", "top 30 %", "top 50 %", "top 100 %"] | |
| def _dq_row(rows: list[list[str]], header: list[str], model: str) -> list[str]: | |
| """Exact-match row lookup on the 'model' column (the CockpitWM labels are prefixes of each other, so no startswith).""" | |
| c = col(header, "model") | |
| for r in rows: | |
| if r[c].replace("**", "").strip() == model: | |
| return r | |
| raise KeyError(f"driverwm_quantile_sweep.md: row not found: {model!r}") | |
| def _dq_cell(cell: str) -> str: | |
| return "--" if cell.strip() == "not published" else tx(cell) | |
| _DQ_MAIN_ORDER = ["zero-velocity", "CockpitWM", "CockpitWM + BATON pretraining", "CockpitWM (+ semantic heads)", | |
| "Driver-WM reproduction (ours, their formulation)", "Driver-WM architecture on CockpitWM tokens", | |
| "Driver-WM published, single run (v2 Table 1 / Table 7 seed 42; text / Tables 10–11 for h=5)"] # owner order (round 3) | |
| _DQ_LABEL = dict(_DQ_ROWS) | |
| def _dq_levels(heading_prefix: str, keys: list[str]): | |
| """(two-row header, body rows, 1-based header line) of a §1 / §2 level table of driverwm_quantile_sweep.md for the models `keys`.""" | |
| h, rows, ln = first_table(_DQ_PATH, heading_prefix) | |
| hA, _, _ = first_table(_DQ_PATH, "1. Horizon-averaged MPJPE") | |
| ns = [] | |
| for q in _DQ_Q: # the §1 header cells read 'top 5 % (n 30)': the n of every subset comes from there | |
| hcell = next(c for c in hA if c.startswith(q + " ")) | |
| m = re.match(r"top (\d+) % \(n (\d+)\)$", hcell.strip()) | |
| if not m: | |
| raise ValueError(f"driverwm_quantile_sweep.md §1: unexpected header cell {hcell!r}") | |
| ns.append(m.group(2)) | |
| hdr = [["Model", "Seeds"] + [f"top {q.split()[1]}\\,\\%" for q in _DQ_Q], ["", ""] + [f"$n{{=}}{n}$" for n in ns]] | |
| cq = {q: next(i for i, c in enumerate(h) if c.startswith(q)) for q in _DQ_Q} | |
| body = [] | |
| for key in keys: | |
| r = _dq_row(rows, h, key) | |
| body.append(row(_DQ_LABEL[key], tx(r[col(h, "seeds")]), *[_dq_cell(r[cq[q]]) for q in _DQ_Q])) | |
| return hdr, body, ln | |
| def _dq_guard(): | |
| """Owner instruction: the published single-run row holds exactly 138.03 (top 10 %, horizon-averaged) and 155.82 (top 10 %, h=5).""" | |
| hA, rA, _ = first_table(_DQ_PATH, "1. Horizon-averaged MPJPE") | |
| hB, rB, _ = first_table(_DQ_PATH, "2. h=5 MPJPE") | |
| pub = _DQ_MAIN_ORDER[-1] | |
| if _dq_row(rA, hA, pub)[col(hA, "top 10 %")].strip() != "138.03" or _dq_row(rB, hB, pub)[col(hB, "top 10 %")].strip() != "155.82": | |
| raise ValueError("driverwm_quantile_sweep.md: published top-10 % cells are not 138.03 / 155.82") | |
| def tab_driverwm_quantile() -> pathlib.Path: | |
| """MAIN TEXT (owner decision 2026-09-17: the quantile table goes into the main text first, possibly to the supplement later): h=5 MPJPE per | |
| motion quantile, seven rows in the owner's order; one \\input line in §5.2 so that the table can move.""" | |
| _dq_guard() | |
| hdr, body, lB = _dq_levels("2. h=5 MPJPE", _DQ_MAIN_ORDER[:-1]) # round 6 (owner decision 2026-09-18, row 508 (3)): the published row is a footnote row | |
| hA_, rA_, lA_ = first_table(_DQ_PATH, "1. Horizon-averaged MPJPE") | |
| hB_, rB_, _ = first_table(_DQ_PATH, "2. h=5 MPJPE") | |
| pub_h5 = _dq_row(rB_, hB_, _DQ_MAIN_ORDER[-1])[col(hB_, "top 10 %")].strip() | |
| pub_avg = _dq_row(rA_, hA_, _DQ_MAIN_ORDER[-1])[col(hA_, "top 10 %")].strip() | |
| rep_h5 = _dq_row(rB_, hB_, "Driver-WM reproduction (ours, their formulation)")[col(hB_, "top 10 %")].strip() | |
| body.append(r"\midrule") | |
| body.append(f"\\multicolumn{{8}}{{@{{}}p{{\\textwidth}}@{{}}}}{{\\footnotesize Footnote: the Driver-WM paper reports {tx(pub_h5)}\\,px on the official top-10\\,\\% subset at $h{{=}}5$ " | |
| f"({tx(pub_avg)} horizon-averaged) for its single run and no value at any other quantile; although the original paper reports these values, our reimplementation " | |
| f"under identical training and evaluation does not reproduce them ({tx(rep_h5)}) and is behind CockpitWM at every quantile.}} \\\\") | |
| cap = (r"MPJPE at the last horizon $h{=}5$ (px) on the top 5 / 10 / 20 / 30 / 50 / 100\,\% of the AIDE test clips by the paper's ground-truth motion score " | |
| r"(the top-10\,\% subset is the official High-Motion subset), seed mean $\pm$ sd: zero velocity, the CockpitWM models, our reimplementation of Driver-WM " | |
| r"under their formulation (it does not reproduce the published numbers: All 130.86 vs 71.47) and the Driver-WM architecture on CockpitWM tokens; the " | |
| r"published Driver-WM single run, whose only last-horizon value is the top-10\,\% 155.82, is a footnote row (owner decision 2026-09-18). Item (B) of the pre-registration of 2026-09-17; " | |
| f"descriptive. Source: driverwm\\_quantile\\_sweep.md \\S{{}}1 (line {lA_}), \\S{{}}2 (line {lB}).") | |
| return emit("tab_driverwm_quantile", cap, [f"{_DQ_PATH} : §2 h=5 MPJPE per quantile, seed mean ± sd (table line {lB}); §1 horizon-averaged top-10 % published cell (table line {lA_}); footnote row = published single run"], | |
| [(None, "p{0.30\\textwidth} c r r r r r r", hdr, body)]) | |
| def tab_supp_driverwm_quantile() -> pathlib.Path: | |
| """SUPPLEMENT: (A) horizon-averaged MPJPE per quantile (all rows incl. the published Table-8 three-seed row), (B) paired Δ CockpitWM − architecture port.""" | |
| _dq_guard() | |
| hdr, bodyA, lA = _dq_levels("1. Horizon-averaged MPJPE", _DQ_MAIN_ORDER + [_DQ_ROWS[2][0]]) | |
| hC, rC, lC = first_table(_DQ_PATH, "3. Paired Δ at h=5") | |
| cC = {k: col(hC, k) for k in ["top q", "n clips", "Δ h=5 mean ± sd", "k/n seeds CI excl. 0 (h=5)", "Δ horizon-avg mean ± sd", "k/n (avg)", "verdict (avg"]} | |
| hdrC = ["Top $q$", "$n$", r"$\Delta$ $h{=}5$ (px)", r"CI excl.\ 0", r"$\Delta$ horizon-averaged (px)", r"CI excl.\ 0", "Verdict (averaged)"] | |
| bodyC = [row(tx(r[cC["top q"]]), tx(r[cC["n clips"]]), tx(r[cC["Δ h=5 mean ± sd"]]), tx(r[cC["k/n seeds CI excl. 0 (h=5)"]]), | |
| tx(r[cC["Δ horizon-avg mean ± sd"]]), tx(r[cC["k/n (avg)"]]), vd(r[cC["verdict (avg"]])) for r in rC] | |
| cap = (r"Appendix: Driver-WM quantile sweep on the AIDE test split ($n{=}609$; px), horizon-averaged MPJPE on the top 5 / 10 / 20 / 30 / 50 / 100\,\% of the test clips by the " | |
| r"paper's ground-truth motion score (the top-10\,\% subset is the official High-Motion subset), seed mean $\pm$ sd; the last-horizon rows are the main paper's quantile table. " | |
| r"Rows: zero velocity; CockpitWM, CockpitWM + BATON pretraining, CockpitWM (+ semantic heads); our reimplementation of Driver-WM under their formulation, which does not " | |
| r"reproduce the published numbers (All 130.86 vs 71.47), so margins against it say nothing about Driver-WM as published; the Driver-WM architecture on CockpitWM tokens " | |
| r"(their temporal encoder on our keypoint part tokens under our anchored-residual formulation, the meaningful architecture comparator); the published Driver-WM (single run of " | |
| r"Table 1 / text; Table 8 three-seed means) in the cells that exist -- top-10\,\% 138.03 / 138.34 and full-set All-MPJPE 71.47 / 71.66; every other cell '--' = not published. " | |
| r"(B) Paired per-clip $\Delta$ = CockpitWM $-$ Driver-WM architecture on CockpitWM tokens (seed-matched 42 / 123 / 456; negative = CockpitWM better), mean $\pm$ sd over seeds " | |
| r"with the seeds whose CI excludes 0 (k/n), at $h{=}5$ and horizon-averaged, and the verdict of the standing rule on the averaged error. Item (B) of the pre-registration of " | |
| r"2026-09-17; descriptive, no acceptance rule, nothing adopted; Driver-WM code / weights not released at the dated check. " | |
| f"Sources: driverwm\\_quantile\\_sweep.md \\S{{}}1 (line {lA}), \\S{{}}3 (line {lC}).") | |
| return emit("tab_supp_driverwm_quantile", cap, | |
| [f"{_DQ_PATH} : §1 horizon-averaged MPJPE per quantile (table line {lA})", | |
| f"{_DQ_PATH} : §3 paired Δ at h=5, CockpitWM − Driver-WM architecture on CockpitWM tokens (table line {lC})"], | |
| [("(A) Horizon-averaged MPJPE (px) per motion quantile, seed mean $\\pm$ sd; '--' = not published", "p{0.30\\linewidth} c r r r r r r", hdr, bodyA), | |
| ("(B) Paired per-clip $\\Delta$ = CockpitWM $-$ Driver-WM architecture on CockpitWM tokens (seed-matched; negative = CockpitWM better)", "l r r c r c l", hdrC, bodyC)]) | |
| if _DQ_PATH.exists(): # lazy, as the hm_subsets table; the main-text table is one \input line in §5.2 (owner: may move to the supplement later) | |
| SRC["driverwm_quantile"] = _DQ_PATH | |
| ICLR_GENERATORS.append(tab_driverwm_quantile) | |
| ICLR_GENERATORS.append(tab_supp_driverwm_quantile) | |
| MAIN_TABLES.add("tab_driverwm_quantile") | |
| SHORT["tab_driverwm_quantile"] = (r"Last-horizon ($h{=}5$) MPJPE in px on the top 5--100\,\% of AIDE test clips by ground-truth motion (top 10\,\% = the official high-motion subset), " | |
| r"seed mean $\pm$ sd: zero velocity, the \cwname\ models and our two Driver-WM ports (the reimplementation under their formulation does not reproduce the published " | |
| r"numbers); the published single-run value is the footnote.") | |
| SHORT["tab_supp_driverwm_quantile"] = (r"Driver-WM quantile sweep on AIDE test, horizon-averaged MPJPE (px) on the top 5--100\,\% of clips by ground-truth motion (A), for zero velocity, " | |
| r"the \cwname\ models, our reimplementation of Driver-WM, which does not reproduce the published numbers, the Driver-WM architecture on \cwname\ tokens " | |
| r"and the published Driver-WM (cells that exist); (B) paired $\Delta$ \cwname\ minus the architecture port at the last horizon and horizon-averaged.") | |
| OURS["tab_driverwm_quantile"] = lambda cells, grp: cells[0].startswith("CockpitWM") | |
| OURS["tab_supp_driverwm_quantile"] = lambda cells, grp: cells[0].startswith("CockpitWM") | |
| ICLR_COLSPEC["tab_driverwm_quantile"] = {0: sized("scriptsize", "p{0.27\\textwidth} c r r r r r r")} # 0.30 gave a 6.6 pt overfull in the ICLR column (round-3 build) | |
| ICLR_COLSPEC["tab_supp_driverwm_quantile"] = {0: tiny("p{0.30\\linewidth} c r r r r r r"), 1: tiny("l r r c r c l")} | |
| if _MA_PATH.exists() and _DQ_PATH.exists(): # tab_main_aide gained the architecture-port level row: caption names both ports (<= 60 words) | |
| SHORT["tab_main_aide"] = (r"AIDE test ($n{=}609$), 5 poses in, 5 out. Top: geometry, MPJPE in px (lower better), PCK@0.05 in \% (higher). Our reimplementation of Driver-WM " | |
| r"(their formulation) does not reproduce the published numbers; Driver-WM architecture on our tokens: levels and paired $\Delta$ to \cwname{}. " | |
| r"MotionBERT: released weights, fine-tuned (Supp.\ D). Bottom: semantic macro-F1 (higher) with that checkpoint's geometry. Ours: mean $\pm$ sd; published: single runs.") | |
| # ---------------------------------------------------------------------------------------------- | |
| # Supplement table — BATON-holdout confirmation (results/tables/stage_holdout.md + stage_holdout*.json, written by eval/report_holdout.py | |
| # from results/paired_compare.csv rows of split `holdout`; pre-registration docs/decisions.md 2026-09-17T11:45:58Z (row 455), outcome | |
| # 15:49:42Z (row 463), owner wording decision 15:54:09Z (row 465); candidate (iii) = the kpf joint model: pre-registration row 500 | |
| # (2026-09-18T03:41:14Z), outcome row 505 (04:06:47Z, reading rule MET), merged into stage_holdout.md / stage_holdout_20260918T040442Z.json row 507). Population: 60 route leaves / 60 devices unseen by the benchmark / | |
| # 42 cars, drawn after development (results/holdout/draw_v1.json); every frozen run predicted ONCE, every cell paired ONCE with the benchmark | |
| # evaluators (paired device-cluster bootstrap, 1,000 resamples, seeds 0/1/2, verdict rule of the paper); no selection, no re-run, no | |
| # threshold change. ONE BLOCK PER CANDIDATE present in the json with status RUN: candidate (i) = frozen main vs indep today; (ii) and | |
| # (ii-a) = the E-CAN candidate are picked up automatically once report_holdout.py has appended their sections (a later dated json | |
| # `stage_holdout_<stamp>.json` overrides the same candidate id). Every row of a candidate's confirmation table is rendered in the source | |
| # order with its holdout verdict (holdout Δ mean ± sd over seeds, seeds whose CI excludes 0, the benchmark TEST Δ and verdict, replicates); | |
| # the table never trims, reorders or reclassifies a reported row (owner rule 2026-09-17T15:54:09Z). The two engaged hand cells are | |
| # '(not reported)' in the source by the pre-registration and are omitted (owner decision 2026-09-17 item 3, omitted_cell). Every string is | |
| # copied verbatim from the md table and cross-checked against the json (verdicts, mean ± sd, cell set); disagreement raises. Lazy: emitted | |
| # only with --style iclr and only when both files exist; \input in Supp. E (held-out confirmation subsection). | |
| # ---------------------------------------------------------------------------------------------- | |
| _HO_PATH = BT / "stage_holdout.md" | |
| _HO_JSON = BT / "stage_holdout.json" | |
| _HO_HEAD = {"i": "Candidate (i) —", "ii": "Candidate (ii) —", "ii-a": "Candidate (ii) adoption comparison (a)", "iii": "Candidate (iii) —"} | |
| _HO_ORDER = ["i", "ii", "ii-a", "iii"] | |
| # round 6 (2026-09-18): the kpf joint model is CockpitWM (ECAN, default); its base without the forecaster channel is named accordingly | |
| _HO_TITLE = {"i": r"Candidate (i): \cwname\ (visual-only environment input) minus its independent branches", | |
| "ii": r"Candidate (ii): \cwname\ (ECAN, without forecaster distillation) minus its independent branches", | |
| "ii-a": r"Candidate (ii), adoption comparison: \cwname\ (ECAN, without forecaster distillation) minus \cwname\ (visual-only environment input)", | |
| "iii": r"Candidate (iii): \cwname\ (ECAN, default), with the keypoint-forecaster channel, minus \cwname\ (ECAN, without forecaster distillation)"} | |
| # candidate-specific pre-registered reading rules shown in the block title when the json carries a 'rule' block (row 500, 2026-09-18T03:41:14Z) | |
| _HO_RULE_TEXT = {"iii": (r"pre-registered reading rule (both validation-selected head-turn cells significantly better on the hold-out, no own onset cell worse or beyond " | |
| r"the $-0.005$ margin, no hazard-likelihood margin of $+0.010$ nats broken)")} | |
| # decisions.md rows named in the header comment per candidate (round-6 fix: the CHANGES entry names them for candidate (iii)) | |
| _HO_DEC = {"iii": "; docs/decisions.md: pre-registration row 500, outcome row 505, merge into the shared table row 507"} | |
| _HO_GROUPS = {"driver": r"Driver onsets (reported cells; PR-AUC within 3\,s)", | |
| "vehicle onsets": r"Vehicle onsets (PR-AUC within 3\,s)", | |
| "road D cells": r"Road-demand (D) onsets (PR-AUC within 3\,s)", | |
| "road P cells": r"Road-pressure (P) onsets (PR-AUC within 3\,s; no comparator in the benchmark table)", | |
| "hazard-NLL costs": r"Hazard negative log-likelihoods (lower is better)"} | |
| _HO_TAG_RE = re.compile(r"\s*(\*\*\(reported\)\*\*|\*\(not reported\)\*|\[ROAD\])") | |
| _HO_NAMES = {"ttc": "ttc", "ttc_drop": "ttc drop", "cut_in": "cut-in", "lead_braking": "lead braking", "lane_excursion": "lane excursion", | |
| "lane": "lane", "badas": "badas", "decel": "decel", "steer_rate": "steer rate", "hand_leave": "hand leave", "hand_return": "hand return", | |
| "head_turn_onset": "head turn", "gas_on": "gas on", "brake_on": "brake on", "steer_phase_on": "steer phase on", "veh_any_on": "any on"} | |
| _HO_FAMILY = {"drv_onset": "drv.\\ ", "veh_onset": "veh.\\ ", "d_onset": "D ", "p_onset": "P ", "hazard_nll": "NLL "} | |
| _HO_READING = {"CONFIRMED": "confirmed", "NOT CONFIRMED": "not confirmed"} | |
| _HO_COLSPEC = tiny("l p{0.17\\linewidth} l r c l r l c") | |
| def _ho_cell_name(raw: str) -> str: | |
| """'drv_onset/hand_leave/3s **(reported)**' -> 'drv.\\ hand leave'; 'hazard_nll/D_ttc_drop' -> 'NLL D ttc drop'; 'p_onset/cut_in/3s [ROAD]' -> 'P cut-in'.""" | |
| c = _HO_TAG_RE.sub("", raw).strip() | |
| fam, rest = c.split("/", 1) | |
| ev = rest.split("/")[0] | |
| pre = _HO_FAMILY.get(fam) | |
| if pre is None: | |
| return tx(c) | |
| if fam == "hazard_nll" and ev.startswith("D_"): | |
| return pre + "D " + _HO_NAMES.get(ev[2:], tx(ev[2:].replace("_", " "))) | |
| return pre + _HO_NAMES.get(ev, tx(ev.replace("_", " "))) | |
| def _ho_pos_dev(cell: str) -> str: | |
| """'+0.0030 ± 0.0016 (n=93,779, pos=12991, dev=50)' -> '12991 / 50' (positives and devices of the held-out population of the cell).""" | |
| m = re.search(r"\(n=[\d,—-]+, pos=([^,]+), dev=(\d+)\)", cell) | |
| if not m: | |
| raise ValueError(f"stage_holdout.md: no (n, pos, dev) annotation in {cell!r}") | |
| pos = m.group(1).strip() | |
| return f"{'--' if pos in ('—', '-') else pos} / {m.group(2)}" | |
| def _ho_json_candidates() -> dict: | |
| """{candidate id: (json block, file)} over stage_holdout.json and every later stage_holdout_<stamp>.json, status RUN only; a later file | |
| overrides the same id (report_holdout.py writes a new dated json when the base file already exists).""" | |
| import json as _json | |
| out: dict = {} | |
| for f in [_HO_JSON] + sorted(BT.glob("stage_holdout_*.json")): | |
| if not f.exists(): | |
| continue | |
| d = _json.loads(f.read_text(encoding="utf-8")) | |
| for cid, c in d.get("candidates", {}).items(): | |
| if c.get("status") == "RUN": | |
| out[cid] = (c, f) | |
| return out | |
| def _ho_section(cid: str) -> tuple[list[str], int, str]: | |
| """(lines, 0-based heading index, heading text) of the LAST '## Candidate …' section of stage_holdout.md for `cid` that carries a | |
| confirmation table (the file is append-only; a NOT RUN block has no table).""" | |
| ls = lines_of(_HO_PATH) | |
| pref = _HO_HEAD.get(cid, f"Candidate ({cid})") | |
| hits = [i for i, ln in enumerate(ls) if ln.startswith("## ") and ln[3:].strip().startswith(pref)] | |
| for i in reversed(hits): | |
| sec, _ = section(ls, ls[i].lstrip("#").strip(), start=i) | |
| if any(l_.startswith("### Confirmation table") for l_ in sec): | |
| return sec, i, ls[i].lstrip("#").strip() | |
| raise KeyError(f"stage_holdout.md: no confirmation table for candidate {cid!r}") | |
| def tab_supp_holdout() -> pathlib.Path: | |
| cands = _ho_json_candidates() | |
| if "i" not in cands: | |
| raise ValueError("stage_holdout.json: candidate (i) is not RUN") | |
| order = [c for c in _HO_ORDER if c in cands] + sorted(c for c in cands if c not in _HO_ORDER) | |
| hdr = [r"\headrow Regime & Cell & pos / dev & \multicolumn{3}{c}{Held-out set (60 unseen devices)} & \multicolumn{2}{c}{Test split} & Replicates \\", | |
| r"\cmidrule(lr){4-6}\cmidrule(lr){7-8}", | |
| ["", "", "(held-out)", r"$\Delta$ mean $\pm$ sd", r"seeds CI excl.\ 0", "verdict", r"$\Delta$ mean $\pm$ sd", "verdict", ""]] | |
| _, l_draw = find_line(_HO_PATH, "- draw (") | |
| _, l_pack = find_line(_HO_PATH, "- pack v2 (") | |
| _, l_nosel = find_line(_HO_PATH, "**No selection was made on the holdout**") | |
| blocks, srcs, capbits = [], [f"{_HO_PATH} : holdout population (lines {l_draw}-{l_pack}); protocol / no-selection statement (lines 3-{l_nosel})"], [] | |
| for k, cid in enumerate(order): | |
| js, jf = cands[cid] | |
| sec, i0, heading = _ho_section(cid) | |
| tabs = [(h, r, kk) for h, r, kk in md_tables(sec) if h and h[0].strip() == "group"] | |
| if len(tabs) != 1: | |
| raise ValueError(f"stage_holdout.md: candidate {cid!r} section has {len(tabs)} confirmation tables (expected 1)") | |
| h, rows, kk = tabs[0] | |
| ln = i0 + kk + 1 | |
| rl = next(i0 + j + 1 for j, l_ in enumerate(sec) if l_.startswith("### Pre-registered reading")) | |
| c = {"group": col(h, "group"), "regime": col(h, "regime"), "cell": col(h, "cell"), "metric": col(h, "metric"), "mean": col(h, "holdout mean"), | |
| "hv": col(h, "holdout verdict"), "tmean": col(h, "TEST mean"), "tv": col(h, "TEST verdict"), "rep": col(h, "replicates")} | |
| seed_cols = [i for i, x in enumerate(h) if x.strip().startswith("holdout Δ s")] | |
| if len(seed_cols) < 2: | |
| raise ValueError(f"stage_holdout.md: candidate {cid!r} table has {len(seed_cols)} per-seed columns") | |
| cells_js, seen, body, grp = js["cells"], set(), [], None | |
| for r in rows: | |
| raw, regime, metric = r[c["cell"]], r[c["regime"]].strip(), r[c["metric"]].strip() | |
| cell = _HO_TAG_RE.sub("", raw).strip() | |
| key = f"{regime}|{cell.replace('/', '|')}|{metric}" | |
| if key not in cells_js: | |
| raise ValueError(f"stage_holdout.json: candidate {cid!r} has no cell {key!r} (md row without json entry)") | |
| j = cells_js[key] | |
| seen.add(key) | |
| hv, tv = r[c["hv"]].strip(), r[c["tv"]].strip() | |
| if hv != j["holdout"]["verdict"] or strip_n(r[c["mean"]]) != f"{j['holdout']['mean']:+.4f} ± {j['holdout']['sd']:.4f}": | |
| raise ValueError(f"stage_holdout: md and json disagree on the holdout cell {key!r}") | |
| if j["test"] is not None and (tv != j["test"]["verdict"] or r[c["tmean"]].strip() != f"{j['test']['mean']:+.4f} ± {j['test']['sd']:.4f}"): | |
| raise ValueError(f"stage_holdout: md and json disagree on the TEST cell {key!r}") | |
| not_rep = "(not reported)" in raw | |
| if not_rep == bool(j.get("reported", True)): | |
| raise ValueError(f"stage_holdout: '(not reported)' tag and json 'reported' disagree for {key!r}") | |
| if not_rep or omitted_cell(regime, cell): # pre-registration: engaged hand cells computed, not reported (owner item 3) | |
| continue | |
| g = r[c["group"]].strip() | |
| if g != grp: | |
| body.append(group(9, _HO_GROUPS.get(g, tx(g)))) | |
| grp = g | |
| tmean = "--" if r[c["tmean"]].strip().startswith("—") else tx(r[c["tmean"]].strip()) | |
| tverd = "--" if tv in ("—", "") else vd(tv) | |
| rep = {"yes": "yes", "no": "no"}.get(r[c["rep"]].strip(), "--") | |
| body.append(row(regime, _ho_cell_name(raw), _ho_pos_dev(r[c["mean"]]), tx(strip_n(r[c["mean"]])), | |
| ci_excl([r[i] for i in seed_cols]), vd(hv), tmean, tverd, rep)) | |
| missing = sorted(k_ for k_ in cells_js if k_ not in seen) | |
| if missing: | |
| raise ValueError(f"stage_holdout: json cells absent from the md confirmation table of candidate {cid!r}: {missing}") | |
| key_rows = js.get("key_cells", []) | |
| n_yes = sum(1 for kr in key_rows if kr[1] == "yes") | |
| n_tot = sum(1 for kr in key_rows if kr[1] in ("yes", "no")) | |
| reading = str(js.get("reading", "")) | |
| rtxt = _HO_READING.get(reading, tx(re.sub(r"\s*\(.*\)\s*$", "", reading).lower())) # "PARTIAL (3/4)" -> "partial" (the count follows) | |
| title = (f"({chr(65 + k)}) {_HO_TITLE.get(cid, tx(heading))} --- pre-registered reading: {rtxt} " | |
| f"({n_yes} of {n_tot} key cells replicate sign and significance class)") | |
| rule = js.get("rule") | |
| if rule: # candidate (iii): the decisive rule lives in the json 'rule' block (status MET / NOT MET), not in the confirmation table | |
| title += f"; {_HO_RULE_TEXT.get(cid, 'pre-registered reading rule')}: {tx(str(rule.get('status', '')).lower())}" | |
| capbits.append(f"candidate {cid} rule {rule.get('status')}") | |
| blocks.append((title, _HO_COLSPEC, hdr, body)) | |
| srcs += [f"{_HO_PATH} : §{heading} — confirmation table (table line {ln}: holdout Δ mean ± sd, holdout verdict, TEST mean Δ ± sd, TEST verdict, " | |
| f"replicates; per-seed CI columns → seeds CI excl. 0); pre-registered reading (line {rl}){_HO_DEC.get(cid, '')}", | |
| f"{jf} : candidates.{cid} (status RUN; reading, key_cells; every cell cross-checked verbatim against the table)"] | |
| capbits.append(f"({chr(65 + k)}) candidate {cid}: table line {ln}, reading line {rl}, reading {reading}") | |
| cap = (r"BATON-holdout confirmation batch: 60 route leaves / 60 devices unseen by the benchmark / 42 cars, drawn after development (results/holdout/draw\_v1.json, seed 0); " | |
| r"anchors manual 116,801 rows / 54 leaves / 6.49 h, engaged 93,876 rows / 35 leaves / 5.22 h. Every frozen run was predicted ONCE on the holdout pack and every cell paired " | |
| r"ONCE with the benchmark evaluators (paired device-cluster bootstrap on identical rows, $n_{\mathrm{boot}}{=}1000$, seeds 0/1/2); no selection, no re-run, no threshold " | |
| r"change after the numbers were seen; the three pre-specified candidates are reported regardless of direction, one block per candidate comparison. Columns: positives / devices of the " | |
| r"held-out cell, holdout $\Delta$ = A $-$ B mean $\pm$ sd over seeds, number of seeds whose device-cluster CI excludes 0, holdout verdict, the benchmark TEST $\Delta$ and " | |
| r"verdict of the same cell (`--' = no comparator in the benchmark table), replicates = same sign of the mean $\Delta$ and the same significance class. " | |
| + LEGEND + "Engaged hand cells: computed, not reported (pre-registration). Sources: stage\\_holdout.md " + "; ".join(capbits) | |
| + f"; population lines {l_draw}-{l_pack}; json stage\\_holdout*.json.") | |
| return emit("tab_supp_holdout", cap, srcs, blocks) | |
| if _HO_PATH.exists() and _HO_JSON.exists(): # lazy: a checkout without the holdout batch still generates every other table | |
| SRC["holdout"] = _HO_PATH | |
| SRC["holdout_json"] = _HO_JSON | |
| ICLR_GENERATORS.append(tab_supp_holdout) | |
| SHORT["tab_supp_holdout"] = (r"Held-out confirmation on 60 BATON devices unseen by the benchmark (60 route segments, 42 cars, drawn after development): three candidates, frozen models " | |
| r"evaluated once, no selection. Paired device-cluster bootstrap, $\Delta$ = candidate minus its comparator (block title), " | |
| r"mean $\pm$ sd over 3 seeds and seeds whose CI excludes zero; verdicts by the pre-specified rule ($\geq 2/3$ seeds), beside the test-split verdict.") | |
| OURS["tab_supp_holdout"] = _NEVER # every row is a paired Δ | |
| ICLR_COLSPEC["tab_supp_holdout"] = {k: _HO_COLSPEC for k in range(10)} | |
| # one candidate block = one float; each block splits into a second float before the hazard-NLL group (32 onset rows + 22 NLL rows do not fit one page) | |
| ICLR_NEWFLOAT["tab_supp_holdout"] = set(range(1, 10)) | |
| ICLR_SPLIT["tab_supp_holdout"] = {k: (lambda cells, line, grp: cells is None and "Hazard negative log-likelihoods" in line) for k in range(10)} | |
| # ---------------------------------------------------------------------------------------------- | |
| # Round 4 (owner decision docs/decisions.md 2026-09-17T16:24:02Z, ECAN ADOPTED as the default input configuration): the main-text Table 1 | |
| # on CockpitWM (ECAN, default) from results/tables/stage_final_ecan_table3.md (+ .json twin, every cell cross-checked) and the compact | |
| # input-ablation table (ECAN main minus the visual-only environment-input configuration) from stage_final_ecan.md §(a). | |
| # Same cell set and omissions as tab_main_baton_interaction (engaged hand cells out, owner item 3). The CockpitWM (ECAN) level column is | |
| # the 3-seed mean ± sd of the per-seed levels: the only derived numbers in any ICLR table, verified in --verify by recomputation from the | |
| # json (DERIVED) rather than by substring. Lazy: emitted only when the sources exist. | |
| # ---------------------------------------------------------------------------------------------- | |
| _ECT_PATH = BT / "stage_final_ecan_table3.md" | |
| _ECT_JSON = BT / "stage_final_ecan_table3.json" | |
| _ECT_CMP = [("Δ main − indep", "main_vs_indep"), ("Δ main − none", "main_vs_none"), ("Δ main − naive", "main_vs_naive"), ("Δ main − k0", "main_vs_k0")] | |
| _ECT_CELL_RE = re.compile(r"^([-+]\d+\.\d+ ± \d+\.\d+) ([A-Z_]+) \((\d)/3\)$") | |
| def _ect_json() -> dict: | |
| import json as _json | |
| return _json.loads(_ECT_JSON.read_text(encoding="utf-8")) | |
| def _ect_level(levels: list) -> tuple[str, str]: | |
| """3-seed mean and sample sd (ddof = 1, as the source's seed sd) of per-seed levels, 4 decimals.""" | |
| m = sum(levels) / len(levels) | |
| sd = (sum((x - m) ** 2 for x in levels) / (len(levels) - 1)) ** 0.5 | |
| return f"{m:.4f}", f"{sd:.4f}" | |
| def _ect_derived_tokens() -> set: | |
| """Every mean / sd token that tab_main_baton_interaction_ecan may derive, recomputed from the json's per-seed levels (--verify).""" | |
| out = set() | |
| if not _ECT_JSON.exists(): | |
| return out | |
| for cells in _ect_json()["cells"].values(): | |
| for c in cells.values(): | |
| if c.get("A"): | |
| out.update(_ect_level(c["A"])) | |
| return out | |
| def tab_main_baton_interaction_ecan() -> pathlib.Path: | |
| js = _ect_json() | |
| if js["missing"] or js["stale"] or js["runs_complete"] != 12: | |
| raise ValueError("stage_final_ecan_table3.json: incomplete or stale comparison") | |
| h, rows, ln = first_table(_ECT_PATH, "1. Table 3 (ECAN version)") | |
| ci = {"regime": col(h, "regime"), "endpoint": col(h, "endpoint"), "lvl": col(h, "main_ecan s0")} | |
| ci.update({k: col(h, k) for k, _ in _ECT_CMP}) | |
| idx = {(r[ci["regime"]].strip(), r[ci["endpoint"]].strip()): r for r in rows if r[ci["regime"]].strip() in ("manual", "engaged")} | |
| prm = js["params"] | |
| if not (prm["on_path"] == 3502925 and prm["total"] == 3649913 and prm["same_as_frozen_main"] and prm["same_across_seeds"] | |
| and prm["interaction_total"] == 576768 and prm["comparators"]["naive_ecan"][2] == 821760): | |
| raise ValueError("stage_final_ecan_table3.json: parameter counts differ from the caption of tab_main_baton_interaction_ecan") | |
| _, l_par = find_line(_ECT_PATH, "| **on the forward path") | |
| _, l_naive = find_line(_ECT_PATH, "| naive_ecan |") | |
| _, l_verd = find_line(_ECT_PATH, "- main_vs_indep (allminusecan vs indepecan)") | |
| hdr = [["Endpoint", r"\cwname\ (ECAN, without", r"$\Delta$ vs independent", r"$\Delta$ vs no", r"$\Delta$ vs all-to-all", r"$\Delta$ vs heuristic"], | |
| ["", r"forecaster distillation), level", "branches", "connections", "fusion", "k0"]] | |
| body = [] | |
| for regime, title in _R2_REGIMES: | |
| body.append(group(6, title)) | |
| for cell, label in _MAIN_ENDPOINTS[regime]: | |
| if omitted_cell(regime, cell): # owner decision 2026-09-17 item 3 (ICLR): engaged hand_leave / hand_return leave the table | |
| continue | |
| r = idx[(regime, cell)] | |
| lv = [x.strip() for x in r[ci["lvl"]].split("/")] | |
| jkey = f"{regime}|{cell.replace('/', '|')}|pr_auc" | |
| jA = js["cells"]["main_vs_indep"][jkey]["A"] | |
| if [f"{a:.4f}" for a in jA] != lv: # guard: the md per-seed levels are the json levels rounded | |
| raise ValueError(f"stage_final_ecan_table3: md and json levels disagree for {jkey}") | |
| m, sd = _ect_level(jA) | |
| cells_ = [label, f"{m} $\\pm$ {sd}"] | |
| for k, jname in _ECT_CMP: | |
| sv = r[ci[k]].strip() | |
| if sv in ("—", "-", ""): # k0 exists for the driver cells only | |
| cells_.append("--") | |
| continue | |
| mt = _ECT_CELL_RE.match(sv) | |
| if not mt: | |
| raise ValueError(f"stage_final_ecan_table3: unparsed cell {sv!r}") | |
| jc = js["cells"][jname][jkey] | |
| if jc["verdict"] != mt.group(2) or f"{jc['mean_delta']:+.4f} ± {jc['sd']:.4f}" != mt.group(1) or str(jc["ci_excl"]) != mt.group(3): | |
| raise ValueError(f"stage_final_ecan_table3: md and json disagree on {jname} {jkey}") | |
| cells_.append(dmark(mt.group(1), mt.group(2))) | |
| body.append(row(*cells_)) | |
| cap = (r"Coupling attribution on the ECAN input, \cwname\ (ECAN, without forecaster distillation) = the joint model of the default configuration before the keypoint-forecaster channel is added: BATON test split, PR-AUC of onset within 3\,s, 3 seeds. Level = 3-seed mean $\pm$ sd of the per-seed " | |
| r"levels (main\_ecan s0 / s1 / s2; derived from the unrounded per-seed levels of the json twin, which the md prints rounded to four decimals); $\Delta$ columns = mean $\pm$ sd over seeds of the paired device-cluster bootstrap difference of the ECAN main model to the controls on the " | |
| r"SAME input: indep\_ecan (assembled independent branches, no training), none\_ecan (same joint fine-tuning, no interaction module), naive\_ecan (all-to-all fusion MLP, 821,760 " | |
| r"parameters, in place of the two directed connections, 576,768) and the label-free current-state heuristic k0 (driver cells). \cmark\ / \xmark\ = BEATS / WORSE by kill\_checks.beats " | |
| r"($\geq 2/3$ seeds CI excl.\ 0, same sign, $|$mean $\Delta| >$ seed sd). Forward-path parameters 3,502,925 (3,649,913 registered), identical to the visual-only configuration. " | |
| f"Sources: stage\\_final\\_ecan\\_table3.md \\S1 table line {ln}, verdict summary line {l_verd}, parameter lines {l_par} / {l_naive}; json twin cross-checked cell by cell.") | |
| srcs = [f"{_ECT_PATH} : §1 Table 3 (ECAN version), compact (table line {ln}: main_ecan s0 / s1 / s2 levels; Δ main − indep / none / naive / k0 with verdict and k/3)", | |
| f"{_ECT_PATH} : §0 verdict summary (line {l_verd}); §2 parameter count (forward path line {l_par}; comparators line {l_naive})", | |
| f"{_ECT_JSON} : cells.main_vs_indep / main_vs_none / main_vs_naive / main_vs_k0 (mean_delta, sd, ci_excl, verdict, per-seed A levels; every cell cross-checked; level mean ± sd derived from A)"] | |
| return emit("tab_main_baton_interaction_ecan", cap, srcs, [(None, "l r r r r r", hdr, body)]) | |
| _IA_GROUPS = [("Road-demand (D) onsets of the environment branch", ["d_onset/ttc/3s", "d_onset/ttc_drop/3s", "d_onset/lane/3s", "d_onset/decel/3s", "d_onset/steer_rate/3s"], "D"), | |
| ("Road-pressure (P) onsets", ["p_onset/ttc/3s", "p_onset/ttc_drop/3s", "p_onset/lead_braking/3s", "p_onset/lane_excursion/3s", "p_onset/cut_in/3s", "p_onset/badas/3s"], "P"), | |
| ("Vehicle onsets", _R2_VEH4, "D"), ("Driver onsets (reported cells)", _R2_DRV, "D")] | |
| def tab_input_ablation() -> pathlib.Path: | |
| ec = _R2["ecan"] | |
| hA = "(a) sensor + vision E base vs the FROZEN main model (v2 causal kin targets): A = allminusecan, B = allminus" | |
| hPA = "P cells (road-pressure onset PR-AUC@3s, eval/pressure_eval.py): (a) vs FROZEN main: A = allminusecan, B = allminus" | |
| for hh in (hA, hPA): | |
| _unique_heading(ec, hh) | |
| A, lA = paired_index(ec, hA) | |
| PA, lPA = paired_index(ec, hPA) | |
| hO, rO, lO = first_table(ec, "Own + road-D endpoints of (a)") | |
| own = {(r[col(hO, "regime")], r[col(hO, "endpoint")]): r for r in rO} | |
| hdr = [r"\headrow Cell & \multicolumn{3}{c}{Manual driving} & \multicolumn{3}{c}{Assistance engaged} \\", r"\cmidrule(lr){2-4}\cmidrule(lr){5-7}", | |
| ["", r"$\Delta$ mean $\pm$ sd", "seeds", "verdict", r"$\Delta$ mean $\pm$ sd", "seeds", "verdict"]] | |
| body = [] | |
| for title, cells, kind in _IA_GROUPS: | |
| body.append(group(7, title)) | |
| for cell in cells: | |
| out = [_r2_cell(cell)] | |
| for regime, _ in _R2_REGIMES: | |
| if omitted_cell(regime, cell): # owner decision 2026-09-17 item 3 (ICLR): the engaged hand cells are not reported | |
| out += ["--", "--", "--"] | |
| continue | |
| tab = PA if kind == "P" else A | |
| r, c = tab["idx"][(regime, cell, "pr_auc")], tab["ci"] | |
| if kind == "D" and (regime, cell) in own: # guard: the rule's own-endpoint table repeats mean Δ and verdict of (a) | |
| o = own[(regime, cell)] | |
| if o[col(hO, "mean Δ")] != strip_n(r[c["mean Δ ± sd"]]).split(" ")[0] or o[col(hO, "verdict")] != r[c["verdict"]].strip(): | |
| raise ValueError(f"stage_final_ecan.md: own-endpoint table disagrees with (a) for {regime} {cell}") | |
| out += [_pmsd(r[c["mean Δ ± sd"]]), ci_excl([r[c[k]] for k in ("Δ s0 [CI]", "Δ s1 [CI]", "Δ s2 [CI]")]), vd(r[c["verdict"]])] | |
| body.append(row(*out)) | |
| cap = (r"Input contribution: \cwname\ (ECAN, without forecaster distillation) minus \cwname\ (visual-only environment input), the frozen original configuration; same architecture, connections, heads and " | |
| r"parameter count (3,502,925 forward). Onset PR-AUC within 3\,s, BATON test split, both regimes, 3 seeds; paired device-cluster bootstrap on identical rows ($n_{\mathrm{boot}}{=}1000$), " | |
| r"mean $\Delta$ $\pm$ sd (A $-$ B, A = ECAN), number of seeds whose CI excludes 0, verdict. D cells = the environment branch's demand-onset chains, P cells = road-pressure chains. " | |
| + LEGEND + f"Sources: stage\\_final\\_ecan.md (a) line {lA}, P cells (a) line {lPA}, own + road-D endpoints of (a) line {lO}.") | |
| return emit("tab_input_ablation", cap, | |
| [f"{ec} : §1 (a) sensor + vision E base (= ECAN main) vs FROZEN main (table line {lA}; mean Δ ± sd, per-seed CIs, verdict)", | |
| f"{ec} : §1 Own + road-D endpoints of (a) (table line {lO}; guard)", | |
| f"{ec} : §7 P cells (a) vs FROZEN main (table line {lPA})"], | |
| [(None, "l r c l r c l", hdr, body)]) | |
| if _ECT_PATH.exists() and _ECT_JSON.exists(): # lazy: a checkout without the ECAN Table 3 still generates every other table | |
| SRC["ecan_table3"] = _ECT_PATH | |
| SRC["ecan_table3_json"] = _ECT_JSON | |
| ICLR_GENERATORS.append(tab_main_baton_interaction_ecan) | |
| MAIN_TABLES.add("tab_main_baton_interaction_ecan") | |
| if _R2["ecan"].exists(): | |
| ICLR_GENERATORS.append(tab_input_ablation) | |
| MAIN_TABLES.add("tab_input_ablation") | |
| SHORT["tab_main_baton_interaction_ecan"] = (r"Coupling attribution: \cwname\ (ECAN, without forecaster distillation) on the BATON test split, onset PR-AUC within 3\,s, 3 seeds; level = mean $\pm$ sd of the per-seed levels. $\Delta$: paired " | |
| r"device-cluster difference to the controls on the same input, independent branches, no connections, all-to-all fusion (821,760 against 576,768 " | |
| r"connection parameters) and the current-state heuristic k0; forward parameters 3,502,925 unchanged. \cmark/\xmark: significantly better/worse " | |
| r"($\geq 2/3$ seeds).") | |
| SHORT["tab_input_ablation"] = (r"Input contribution: \cwname\ (ECAN, without forecaster distillation) minus \cwname\ (visual-only environment input); same architecture, connections, heads and parameter count. " | |
| r"BATON test, onset PR-AUC within 3\,s, 3 seeds; $\Delta$ mean $\pm$ sd, seeds whose CI excludes zero, verdict by the pre-specified rule. " | |
| r"Engaged hand cells are not reported.") | |
| ICLR_COLSPEC["tab_main_baton_interaction_ecan"] = {0: sized("scriptsize", "l r r r r r")} | |
| ICLR_COLSPEC["tab_input_ablation"] = {0: sized("scriptsize", "l r c l r c l")} | |
| # ---------------------------------------------------------------------------------------------- | |
| # Round 6 (owner decision docs/decisions.md row 499 = 2026-09-18T03:35:56Z, hold-out rule MET row 505, coordinator row 506 Option 1): the kpf joint | |
| # model `I1_all_minus_road2drv_s{0,1,2}_final_ecan_kpf` is CockpitWM (ECAN, default); the frozen ECAN main is "CockpitWM (ECAN, without | |
| # forecaster distillation)". tab_main_kpf_gain = the paired "+ keypoint-forecaster distillation" gain per reported cell of Table 1 (TEST, | |
| # results/tables/kp_residual_f1.md §2 (a) TEST table, tags finalc_s<k>_allminusecankpf_vs_allminusecan) beside the hold-out replication of | |
| # the same cell (results/tables/stage_holdout.md candidate (iii) confirmation table + stage_holdout_20260918T040442Z.json) and the FINAL | |
| # model's level (3-seed mean ± sd of the per-seed levels; the ONLY derived numbers: recomputed in --verify from the json's test.value_a, | |
| # DERIVED hook as for Table 1; the md per-seed A columns are the json levels rounded -- guard). tab_supp_kpf_forecaster = the forecaster | |
| # diagnostics of results/tables/kp_residual_forecaster.md (LAST dated block; arms named by recipe, never by the architecture family). | |
| # ---------------------------------------------------------------------------------------------- | |
| _F1_PATH = BT / "kp_residual_f1.md" | |
| _F1_JSON = BT / "kp_residual_f1_decision.json" | |
| _KPF_PATH = BT / "kp_residual_forecaster.md" | |
| _HO_III_JSON = BT / "stage_holdout_20260918T040442Z.json" | |
| _F1_TEST_HEAD = "(a) variant vs FROZEN ECAN main — TEST split (confirmation): A = allminusecankpf, B = allminusecan" | |
| _KPF_GAIN_CELLS = { | |
| "manual": [("veh_onset/steer_phase_on/3s", "steer phase"), ("veh_onset/gas_on/3s", "gas"), ("veh_onset/brake_on/3s", "brake"), | |
| ("d_onset/decel/3s", "decel (demand)"), ("drv_onset/hand_leave/3s", "hand leave"), | |
| ("drv_onset/hand_return/3s", "hand return"), ("drv_onset/head_turn_onset/3s", "head turn")], | |
| "engaged": [("veh_onset/steer_phase_on/3s", "steer phase"), ("veh_onset/gas_on/3s", "gas"), ("veh_onset/brake_on/3s", "brake"), | |
| ("drv_onset/hand_leave/3s", "hand leave"), ("drv_onset/hand_return/3s", "hand return"), | |
| ("drv_onset/head_turn_onset/3s", "head turn")], | |
| } | |
| _KPF_NLL_CELLS = [("manual", "hazard_nll/head_turn_onset", "head turn, manual"), ("engaged", "hazard_nll/head_turn_onset", "head turn, engaged"), | |
| ("manual", "hazard_nll/gas_on", "gas, manual"), ("manual", "hazard_nll/hand_return", "hand return, manual")] | |
| def _ho_iii_json() -> dict: | |
| import json as _json | |
| d = _json.loads(_HO_III_JSON.read_text(encoding="utf-8")) | |
| c = d["candidates"]["iii"] | |
| if c.get("status") != "RUN" or c.get("rule", {}).get("status") != "MET": | |
| raise ValueError("stage_holdout_20260918T040442Z.json: candidate (iii) is not RUN with the reading rule MET") | |
| return c | |
| def _kpf_derived_tokens() -> set: | |
| """Every level mean / sd token tab_main_kpf_gain may derive: recomputed from the json's per-seed TEST levels of the kpf model (--verify).""" | |
| out = set() | |
| if not _HO_III_JSON.exists(): | |
| return out | |
| for c in _ho_iii_json()["cells"].values(): | |
| if c.get("test") and c["test"].get("value_a"): | |
| out.update(_ect_level(c["test"]["value_a"])) | |
| return out | |
| def _f1_test_index(): | |
| """(rows by (regime, cell), column index, 1-based table line) of the TEST confirmation table of kp_residual_f1.md.""" | |
| _unique_heading(_F1_PATH, _F1_TEST_HEAD) | |
| h, rows, ln = first_table(_F1_PATH, _F1_TEST_HEAD) | |
| ci = {k: col(h, k) for k in ["regime", "cell", "metric", "A s0", "A s1", "A s2", "Δ s0 [CI]", "Δ s1 [CI]", "Δ s2 [CI]", "mean Δ ± sd", "verdict"]} | |
| idx = {(r[ci["regime"]].strip(), r[ci["cell"]].strip()): r for r in rows} | |
| return idx, ci, ln | |
| def _ho_iii_rows(): | |
| """(rows by (regime, cell), column index, 1-based table line, reading line) of the candidate (iii) confirmation table of stage_holdout.md.""" | |
| sec, i0, heading = _ho_section("iii") | |
| tabs = [(h, r, kk) for h, r, kk in md_tables(sec) if h and h[0].strip() == "group"] | |
| if len(tabs) != 1: | |
| raise ValueError(f"stage_holdout.md: candidate (iii) section has {len(tabs)} confirmation tables (expected 1)") | |
| h, rows, kk = tabs[0] | |
| rl = next(i0 + j + 1 for j, l_ in enumerate(sec) if l_.startswith("### Pre-registered READING RULE")) | |
| c = {"regime": col(h, "regime"), "cell": col(h, "cell"), "mean": col(h, "holdout mean"), "hv": col(h, "holdout verdict"), | |
| "tmean": col(h, "TEST mean"), "tv": col(h, "TEST verdict"), "rep": col(h, "replicates")} | |
| seed_cols = [i for i, x in enumerate(h) if x.strip().startswith("holdout Δ s")] | |
| idx = {(r[c["regime"]].strip(), _HO_TAG_RE.sub("", r[c["cell"]]).strip()): r for r in rows} | |
| return idx, c, seed_cols, i0 + kk + 1, rl | |
| def tab_main_kpf_gain() -> pathlib.Path: | |
| js = _ho_iii_json() | |
| tidx, tc, lT = _f1_test_index() | |
| hidx, hc, hseeds, lH, rl = _ho_iii_rows() | |
| _, l_par = find_line(_F1_PATH, "| I1_all_minus_road2drv_s0_final_ecan_kpf |") | |
| _, l_tot = find_line(_F1_PATH, "Forecaster params: `mb_full` 850,627") | |
| hdr = [["Endpoint", r"\cwname\ (ECAN, default)", r"$\Delta$ + forecaster distillation", "seeds CI", r"$\Delta$ on 60 unseen", "seeds CI", "Replicates"], | |
| ["", r"level, mean $\pm$ sd", r"test split, mean $\pm$ sd", r"excl.\ 0", r"devices, mean $\pm$ sd", r"excl.\ 0", ""]] | |
| def one(regime: str, cell: str, label: str, metric: str) -> str: | |
| r = tidx[(regime, cell)] | |
| if r[tc["metric"]].strip().split(" ")[0] != metric: | |
| raise ValueError(f"kp_residual_f1.md TEST: metric of {regime} {cell} is {r[tc['metric']]!r}") | |
| jkey = f"{regime}|{cell.replace('/', '|')}|{metric}" | |
| jc = js["cells"][jkey] | |
| lv = [r[tc[k]].strip() for k in ("A s0", "A s1", "A s2")] | |
| if [f"{a:.4f}" for a in jc["test"]["value_a"]] != lv: # guard: the md per-seed levels are the json levels rounded | |
| raise ValueError(f"kp_residual_f1 / holdout json: per-seed TEST levels disagree for {jkey}: {lv} vs {jc['test']['value_a']}") | |
| msd = strip_n(r[tc["mean Δ ± sd"]]) | |
| if msd != f"{jc['test']['mean']:+.4f} ± {jc['test']['sd']:.4f}" or r[tc["verdict"]].strip() != jc["test"]["verdict"]: | |
| raise ValueError(f"kp_residual_f1 / holdout json: TEST Δ disagree for {jkey}") | |
| hr = hidx[(regime, cell)] | |
| hmsd = strip_n(hr[hc["mean"]]) | |
| if hmsd != f"{jc['holdout']['mean']:+.4f} ± {jc['holdout']['sd']:.4f}" or hr[hc["hv"]].strip() != jc["holdout"]["verdict"]: | |
| raise ValueError(f"stage_holdout / json: hold-out Δ disagree for {jkey}") | |
| if hr[hc["tmean"]].strip() != msd or hr[hc["tv"]].strip() != jc["test"]["verdict"]: | |
| raise ValueError(f"stage_holdout: TEST columns of the confirmation table disagree with kp_residual_f1.md for {jkey}") | |
| m, sd = _ect_level(jc["test"]["value_a"]) | |
| rep = {"yes": "yes", "no": "no"}.get(hr[hc["rep"]].strip(), "--") | |
| if rep != jc["replicates"]: | |
| raise ValueError(f"stage_holdout / json: replicates flag disagrees for {jkey}") | |
| return row(label, f"{m} $\\pm$ {sd}", dmark(msd, jc["test"]["verdict"]), ci_excl([r[tc[k]] for k in ("Δ s0 [CI]", "Δ s1 [CI]", "Δ s2 [CI]")]), | |
| dmark(hmsd, jc["holdout"]["verdict"]), ci_excl([hr[i] for i in hseeds]), rep) | |
| body = [] | |
| for regime, title in _R2_REGIMES: | |
| body.append(group(7, title + r" (onset PR-AUC within 3\,s)")) | |
| for cell, label in _KPF_GAIN_CELLS[regime]: | |
| if omitted_cell(regime, cell): # owner decision 2026-09-17 item 3: engaged hand cells computed, not reported | |
| continue | |
| body.append(one(regime, cell, label, "pr_auc")) | |
| body.append(group(7, r"Hazard negative log-likelihood (nats; lower is better, so a negative $\Delta$ is a gain)")) | |
| for regime, cell, label in _KPF_NLL_CELLS: | |
| body.append(one(regime, cell, label, "nll")) | |
| cap = (r"Keypoint-forecaster distillation: \cwname\ (ECAN, default) = the joint model of Table 1 plus the detached state-forecast channel of the compact keypoint forecaster " | |
| r"(KpfInject, 9,044 parameters; forecaster 850,627; joint 3,658,957 registered; 4,509,584 trainable in total). Level = 3-seed mean $\pm$ sd of the per-seed test levels " | |
| r"of the final model (derived from the unrounded per-seed levels of the hold-out json's TEST block, which kp\_residual\_f1.md prints rounded); " | |
| r"$\Delta$ test = paired device-cluster bootstrap difference kpf model $-$ \cwname\ (ECAN, without forecaster distillation) on identical rows (BATON test, 3 seeds, " | |
| r"$n_{\mathrm{boot}}{=}1000$); $\Delta$ hold-out = the same cell evaluated once on 60 devices unseen by the benchmark (candidate (iii), reading rule MET); " | |
| r"replicates = same sign and significance class on both splits. \cmark\ / \xmark\ = BEATS / WORSE by kill\_checks.beats ($\geq 2/3$ seeds CI excl.\ 0, same sign, " | |
| f"$|$mean $\\Delta| >$ seed sd). Sources: kp\\_residual\\_f1.md \\S2 (a) TEST table line {lT}, \\S4 parameters lines {l_par} / {l_tot}; stage\\_holdout.md candidate (iii) table line {lH}, reading rule line {rl}; json twin cross-checked cell by cell.") | |
| srcs = [f"{_F1_PATH} : §2 (a) variant vs FROZEN ECAN main, TEST split (table line {lT}: A s0 / s1 / s2 levels, per-seed Δ [CI], mean Δ ± sd, verdict)", | |
| f"{_F1_PATH} : §4 parameters (joint runs line {l_par}; forecaster / total line {l_tot})", | |
| f"{_HO_PATH} : §Candidate (iii) — confirmation table (table line {lH}: holdout Δ mean ± sd, per-seed CIs, holdout verdict, TEST mean Δ ± sd, TEST verdict, replicates); pre-registered READING RULE (line {rl})", | |
| f"{_HO_III_JSON} : candidates.iii.cells (holdout / test mean, sd, verdict, per-seed value_a; every cell cross-checked; level mean ± sd derived from test.value_a)"] | |
| return emit("tab_main_kpf_gain", cap, srcs, [(None, "l r r c r c c", hdr, body)]) | |
| _KPF_ARMS = [("mb_full", r"compact DSTformer-style forecaster, dense 10\,Hz over 2\,s + sparse 1\,Hz to 10\,s (adopted)"), | |
| ("mb_dense", "the same forecaster, dense 2\\,s history only"), | |
| ("mb_1hz", "the same forecaster, sparse 1\\,Hz history only"), | |
| ("cwm_full", "part-token causal Transformer (the form of the AIDE forecaster), parameter-matched")] | |
| _KPF_ARM_SHORT = {"mb_full": "adopted forecaster", "mb_dense": "dense-only", "mb_1hz": "sparse-only", "cwm_full": "part-token form"} | |
| _KPF_PAIRS = [("mb_full_vs_zv", "adopted forecaster $-$ zero velocity"), ("mb_dense_vs_zv", "dense-only $-$ zero velocity"), | |
| ("mb_1hz_vs_zv", "sparse-only $-$ zero velocity"), ("cwm_full_vs_zv", "part-token form $-$ zero velocity"), | |
| ("mb_full_vs_cwm_full", "adopted $-$ part-token form"), ("mb_full_vs_mb_dense", "adopted $-$ dense-only"), ("mb_full_vs_mb_1hz", "adopted $-$ sparse-only")] | |
| _KPF_H = ["0.5s", "1s", "2s", "3s"] | |
| _KPF_HL = [r"0.5\,s", r"1\,s", r"2\,s", r"3\,s"] | |
| _KPF_CLASSES = ["still", "onset", "sustained", "recovery"] | |
| _KPF_STAMP = "20260918T013035Z" | |
| def _kpf_last_block(): | |
| ls = lines_of(_KPF_PATH) | |
| hits = [i for i, l_ in enumerate(ls) if l_.startswith("## " + _KPF_STAMP)] | |
| if not hits: | |
| raise ValueError(f"kp_residual_forecaster.md: no block {_KPF_STAMP}") | |
| i = hits[-1] | |
| sec, _ = section(ls, ls[i].lstrip("#").strip(), start=i) | |
| return sec, i | |
| def tab_supp_kpf_forecaster() -> pathlib.Path: | |
| sec, i0 = _kpf_last_block() | |
| tabs = md_tables(sec) | |
| (hL, rL, kL), (hP, rP, kP), (hC, rC, kC), (hS, rS, kS) = tabs[:4] | |
| if hL[0].strip() != "regime" or hP[0].strip() != "pair" or hC[0].strip() != "regime" or hS[0].strip() != "regime": | |
| raise ValueError("kp_residual_forecaster.md: unexpected table order in the last block") | |
| lL, lP, lC, lS = (i0 + k + 1 for k in (kL, kP, kC, kS)) | |
| lev = {(r[col(hL, "regime")].strip(), r[col(hL, "arm")].strip()): r for r in rL} | |
| pairs = {(r[col(hP, "pair")].strip(), r[col(hP, "regime")].strip(), r[col(hP, "horizon")].strip()): r for r in rP} | |
| cls = {(r[col(hC, "regime")].strip(), r[col(hC, "arm")].strip(), r[col(hC, "class")].strip()): r for r in rC} | |
| hdrA = ["Model", r"MPJPE 0.5\,s", r"1\,s", r"2\,s", r"3\,s", "rows"] | |
| bodyA = [] | |
| for regime, title in _R2_REGIMES: | |
| bodyA.append(group(6, title)) | |
| base = lev[(regime, "mb_full")] | |
| bodyA.append(row("zero velocity (persistence)", *[tx(base[col(hL, f"ZV {h}")]) for h in _KPF_H], tx(base[col(hL, "n rows")]))) | |
| bodyA.append(row(r"constant velocity (last 0.5\,s)", *[tx(base[col(hL, f"CV {h}")]) for h in _KPF_H], tx(base[col(hL, "n rows")]))) | |
| for arm, label in _KPF_ARMS: | |
| r = lev[(regime, arm)] | |
| bodyA.append(row(label, *[tx(r[col(hL, f"model {h}")]) for h in _KPF_H], tx(r[col(hL, "n rows")]))) | |
| hdrB = ["Motion class", "share", "Model", r"0.5\,s", r"1\,s", r"2\,s", r"3\,s"] | |
| bodyB = [] | |
| for regime, title in _R2_REGIMES: | |
| bodyB.append(group(7, title)) | |
| for c in _KPF_CLASSES: | |
| base = cls[(regime, "mb_full", c)] | |
| bodyB.append(row(c, tx(base[col(hC, "share")]), "zero velocity", *[tx(base[col(hC, f"ZV {h}")]) for h in _KPF_H])) | |
| for arm, _ in _KPF_ARMS: | |
| r = cls[(regime, arm, c)] | |
| bodyB.append(row("", "", _KPF_ARM_SHORT[arm], *[tx(r[col(hC, h)]) for h in _KPF_H])) | |
| hdrC = ["Paired comparison (A $-$ B; negative = A lower)", "Regime"] + [f"{h}: mean $\\Delta$ (verdict)" for h in _KPF_HL] | |
| bodyC = [] | |
| for pair, label in _KPF_PAIRS: | |
| for regime, _ in _R2_REGIMES: | |
| cells_ = [] | |
| for h in _KPF_H: | |
| r = pairs[(pair, regime, h)] | |
| cells_.append(f"{tx(r[col(hP, 'mean Δ')])} ({vd(r[col(hP, 'verdict')])})") | |
| bodyC.append(row(label, regime, *cells_)) | |
| hdrD = ["State at horizon", "Regime", "Brier model", "Brier persistence", "AUROC model", "AUROC persistence", "$n$", "positive rate"] | |
| bodyD = [] | |
| for r in rS: | |
| st = r[col(hS, "state@h")].strip() | |
| lab = st.replace("hands_on@", "hands on wheel at ").replace("head_turned@", "head turned at ").replace("1s", r"1\,s").replace("2s", r"2\,s").replace("3s", r"3\,s") | |
| bodyD.append(row(lab, tx(r[col(hS, "regime")]), tx(r[col(hS, "Brier model")]), tx(r[col(hS, "Brier persistence")]), tx(r[col(hS, "AUROC model")]), | |
| tx(r[col(hS, "AUROC persistence")]), tx(r[col(hS, "n")]), tx(r[col(hS, "pos rate")]))) | |
| cap = (r"Keypoint-forecaster diagnostics (BATON test, 3 seeds, device-cluster bootstrap $n_{\mathrm{boot}}{=}500$): MPJPE of the 11 upper-body joints in frame-normalised units " | |
| r"$\times$ 1000 at $+0.5$ / 1 / 2 / 3\,s for zero velocity, constant velocity and the four forecaster arms named by recipe (parameters 850,627 / 849,731 / 848,723 / 843,919 for the " | |
| r"adopted, dense-only, sparse-only and part-token arms); (B) by label-free motion class (mean joint speed over the last and the next second against the training 70th percentile); " | |
| r"(C) paired differences with the verdict of the standing rule; (D) the distilled future-state channel of the adopted arm against persistence. " | |
| + LEGEND + f"Sources: kp\\_residual\\_forecaster.md block {_KPF_STAMP}, tables at lines {lL}, {lC}, {lP}, {lS}.") | |
| srcs = [f"{_KPF_PATH} : block {_KPF_STAMP} — MPJPE per arm and horizon with ZV / CV (table line {lL})", | |
| f"{_KPF_PATH} : block {_KPF_STAMP} — paired comparisons (table line {lP})", | |
| f"{_KPF_PATH} : block {_KPF_STAMP} — MPJPE by motion class (table line {lC})", | |
| f"{_KPF_PATH} : block {_KPF_STAMP} — future-state probabilities vs persistence (table line {lS})"] | |
| return emit("tab_supp_kpf_forecaster", cap, srcs, | |
| [("(A) MPJPE per horizon (frame-normalised units $\\times$ 1000; lower is better)", "p{0.52\\linewidth} r r r r r", hdrA, bodyA), | |
| ("(B) MPJPE by motion class (3-seed mean; share = anchors of the class)", "l r p{0.22\\linewidth} r r r r", hdrB, bodyB), | |
| ("(C) Paired differences (mean $\\Delta$ over 3 seeds; verdict by the standing rule, better = A lower)", "p{0.30\\linewidth} l r r r r", hdrC, bodyC), | |
| ("(D) Future-state channel of the adopted forecaster: Brier (lower better) and AUROC (higher better) against persistence of the current state", "p{0.22\\linewidth} l r r r r r r", hdrD, bodyD)]) | |
| if _F1_PATH.exists() and _HO_III_JSON.exists() and _HO_PATH.exists(): # lazy: a checkout without the F1 lane still generates every other table | |
| SRC["kp_residual_f1"] = _F1_PATH | |
| SRC["holdout_iii_json"] = _HO_III_JSON | |
| ICLR_GENERATORS.append(tab_main_kpf_gain) | |
| MAIN_TABLES.add("tab_main_kpf_gain") | |
| if _KPF_PATH.exists(): | |
| SRC["kp_residual_forecaster"] = _KPF_PATH | |
| ICLR_GENERATORS.append(tab_supp_kpf_forecaster) | |
| SHORT["tab_main_kpf_gain"] = (r"Keypoint-forecaster distillation: \cwname\ (ECAN, default) = Table 1's model plus the detached state-forecast channel (9,044-parameter injector; " | |
| r"0.85\,M forecaster). Final-model level (mean $\pm$ sd, 3 seeds); paired $\Delta$ to \cwname\ (ECAN, without forecaster distillation) on the BATON " | |
| r"test split and 60 unseen devices (evaluated once); \cmark: significantly better (same-sign CI excl.\ 0 on $\geq 2/3$ seeds, $|$mean $\Delta| >$ sd; " | |
| r"mixed-sign counts unmarked); replicates = same sign and class on both.") # round-6 fix: legend states the full rule (same sign, |mean| > sd) | |
| SHORT["tab_supp_kpf_forecaster"] = (r"Keypoint-forecaster diagnostics on the BATON test split (3 seeds): (A) MPJPE of 11 upper-body joints (frame-normalised $\times$ 1000) at 0.5--3\,s " | |
| r"for zero velocity, constant velocity and four forecaster arms named by recipe; (B) by motion class; (C) paired differences with verdicts; " | |
| r"(D) the distilled future-state channel against persistence (Brier, AUROC).") | |
| ICLR_COLSPEC["tab_main_kpf_gain"] = {0: sized("scriptsize", "l r r c r c c")} | |
| ICLR_COLSPEC["tab_supp_kpf_forecaster"] = {0: tiny("p{0.52\\linewidth} r r r r r"), 1: tiny("l r p{0.22\\linewidth} r r r r"), | |
| 2: tiny("p{0.30\\linewidth} l r r r r"), 3: tiny("p{0.22\\linewidth} l r r r r r r")} | |
| ICLR_NEWFLOAT["tab_supp_kpf_forecaster"] = {2} # (A) + (B) fill one page; (C) + (D) open a continuation float | |
| OURS["tab_supp_kpf_forecaster"] = lambda cells, grp: cells[0].startswith("compact DSTformer-style") or cells[2:3] == ["adopted forecaster"] if len(cells) > 2 else cells[0].startswith("compact DSTformer-style") | |
| # derived tokens per table (recomputed in --verify; see _ect_derived_tokens / _kpf_derived_tokens) | |
| DERIVED = {"tab_main_baton_interaction_ecan": _ect_derived_tokens, "tab_main_kpf_gain": _kpf_derived_tokens} | |
| # ---------------------------------------------------------------------------------------------- | |
| # verbatim-number check | |
| # ---------------------------------------------------------------------------------------------- | |
| _NUM = re.compile(r"(?<![\w.])[-+]?\d+\.\d+(?![\w.])") | |
| _WIDTH_RE = re.compile(r"[pmb]\{[0-9.]+\\(?:line|text)width\}") | |
| def _declared_sources(text: list[str]) -> list[pathlib.Path]: | |
| """Source files named in the '% - <path> : <section>' header lines (absolute in the IEEE output, relative to ROOT in the ICLR output).""" | |
| out = [] | |
| for l_ in text: | |
| if not l_.startswith("% - "): | |
| continue | |
| path = l_[len("% - "):].split(" : ")[0].strip() | |
| p = pathlib.Path(path) if path.startswith("/") else ROOT / path | |
| if p.is_file(): | |
| out.append(p) | |
| return out | |
| def verify(sample: int, seed: int = 0) -> int: | |
| """Every decimal number in a generated .tex (outside comments, \\caption / \\begin lines and column widths) must appear verbatim | |
| in one of the declared source files. AAAI-style '$\\pm$.002' is re-expanded to '$\\pm$0.002' so the sd is checked too. | |
| Prints a random sample per table and the total found / missing counts (for the OUT directory of the selected style).""" | |
| rng = random.Random(seed) | |
| bad_total = 0 | |
| for gen in generators(): | |
| name = gen.__name__ | |
| p = OUT / f"{name}.tex" | |
| text = p.read_text(encoding="utf-8").splitlines() | |
| srcs = _declared_sources(text) | |
| if name == "tab_negative_summary": | |
| srcs = [SRC[k] for k in SRC] | |
| blob = "\n".join("\n".join(lines_of(s)) for s in srcs if s.exists()) | |
| body = [l_ for l_ in text if not l_.startswith(("%", "\\caption", "\\renewcommand", "\\setlength", "\\begin", "\\end"))] | |
| toks = set() | |
| for l_ in body: | |
| l2 = _WIDTH_RE.sub("", l_.replace("$-$", "-").replace("$\\pm$.", "$\\pm$0.")) | |
| toks.update(_NUM.findall(l2)) | |
| toks = sorted(toks) | |
| derived = DERIVED.get(name, lambda: set())() # recomputed from the source (mean / sd of per-seed levels), never trusted from the .tex | |
| missing = [t for t in toks if t not in blob and t.lstrip("+") not in blob and t.lstrip("+") not in derived] | |
| n_der = sum(1 for t in toks if t not in blob and t.lstrip("+") not in blob and t.lstrip("+") in derived) | |
| pick = rng.sample(toks, min(sample, len(toks))) if toks else [] | |
| status = "OK" if not missing else f"MISSING {missing}" | |
| der = f", {n_der} derived tokens recomputed from the json" if n_der else "" | |
| print(f"{name}: {len(toks)} numeric tokens{der}, sample {pick} -> {status}") | |
| bad_total += len(missing) | |
| return bad_total | |
| def main(argv: list[str]) -> int: | |
| global STYLE, OUT | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--check", action="store_true", help="only verify that every source exists") | |
| ap.add_argument("--verify", action="store_true", help="only run the verbatim-number check") | |
| ap.add_argument("--sample", type=int, default=5) | |
| ap.add_argument("--style", choices=["ieee", "iclr"], default="ieee", help="ieee (IEEE draft, default) or iclr (ICLR 2027 manuscript, cwm_macros.tex)") | |
| ap.add_argument("--out", type=pathlib.Path, default=None, help="output directory (default: paper/tables for ieee, ICLR_OUT for iclr)") | |
| args = ap.parse_args(argv) | |
| STYLE = args.style | |
| OUT = args.out if args.out is not None else (ICLR_OUT if STYLE == "iclr" else ROOT / "paper" / "tables") | |
| missing = [p for p in SRC.values() if not p.exists()] | |
| for m in missing: | |
| print(f"MISSING source: {m}", file=sys.stderr) | |
| if args.check: | |
| print(f"{len(SRC)} sources; {len(missing)} missing") | |
| return 1 if missing else 0 | |
| if args.verify and not OUT.is_dir(): | |
| print(f"nothing to verify: {OUT} does not exist (generate first with --style {STYLE} --out {OUT})", file=sys.stderr) | |
| return 1 | |
| if not args.verify: | |
| OUT.mkdir(parents=True, exist_ok=True) | |
| for gen in generators(): | |
| p = gen() | |
| print(f"wrote {p}") | |
| if STYLE == "ieee": | |
| for old, new in LEGACY.items(): | |
| (OUT / f"{old}.tex").write_text(f"% {old}.tex — RENAMED: this table is now tables/{new}.tex (\\label{{tab:{new}}}). " | |
| f"Use \\input{{tables/{new}}}; this file is intentionally empty to avoid duplicate labels.\n", encoding="utf-8") | |
| print(f"redirect stub: {OUT / (old + '.tex')} -> {new}") | |
| bad = verify(args.sample) | |
| print(f"VERIFY [{STYLE} -> {OUT}]:", "all numeric tokens found verbatim in the declared sources" if bad == 0 else f"{bad} tokens NOT found") | |
| return 1 if (missing or bad) else 0 | |
| if __name__ == "__main__": | |
| raise SystemExit(main(sys.argv[1:])) | |
Xet Storage Details
- Size:
- 428 kB
- Xet hash:
- a145e9f35399fd9f1520d6992a92649af448a7377b423a278e45d552a2b8fdce
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.