AsianPlayer/TriDrive / code /probes /audit_features.py
AsianPlayer's picture
download
raw
44.7 kB
"""cwm3/probes/audit_features.py — P0 extraction-correctness audit of the frozen latents -> results/tables/latent_audit.md.
Checks (every number from this script; results/probes/audit_*.json carry the raw values):
A. time alignment — window rules read from the producer code; on the probe rows: bank slot lag, s5 (Vf/Vc/F) vs frame/20 axis
(per-anchor lag by feature matching), pooled Vf recomputed from s5 with ts <= t only, F(t+k) window, CAN / pose
step continuity (X[-1] -> Y[0], Kh[-1] -> K[0]).
B. representation statistics — per-dimension variance, row norms, effective rank (participation ratio), #PCs for 90 / 99 % variance,
near-constant and duplicated dimensions (reported, not over-interpreted).
C. cache mix-up — bank pooled256 == PCA(raw1408); vf256 == PCA(Vf4224); tok == PCA64(2x2-pooled region); region.mean == raw1408;
Vf vs Vc similarity per route; identical consecutive rows <=> same bank slot.
D. fit provenance — PCA / standardisation fitted on TRAIN only (metadata + recomputation); future_pca.npz provenance.
E. AIDE Qwen3-VL — which representation feats_qwen.npz holds; per-view norm / variance / effective rank; prompt share of tokens.
No openpilot DMS field is read. GPU used for covariance eigendecompositions when free (coordinator rule), else CPU.
"""
from __future__ import annotations
import argparse
import json
import os
import re
import sys
import time
from pathlib import Path
os.environ.setdefault("OMP_NUM_THREADS", "4")
import numpy as np # noqa: E402
sys.path.insert(0, str(Path(__file__).resolve().parent))
import common as C # noqa: E402
LOG = C.OUT / "audit_features.log"
SETS = [(r, s) for r in C.REGIMES for s in C.SPLITS]
def log(m):
C.log(m, LOG)
# ----------------------------------------------------------------------------- A. alignment rules from code
def alignment_rules():
ex = (C.EXPLORE / "s12_wm" / "extract_crop.py").read_text()
s5 = (C.EXPLORE / "s5_features" / "s5_extract_v4.py").read_text()
fp = (C.EXPLORE / "s7_visual_fusion" / "featpool.py").read_text()
fu = (C.EXPLORE / "s12_wm" / "materialize_oracle_future.py").read_text()
rules = {
"frontfeat / token bank": {"code": "s12_wm/extract_crop.py; cwm3/data/token_bank.py",
"window": "[t_row-2.0, t_row], 16 frames at round((t_row+rel)*20), rel=linspace(-2,0,16); t_row on a 0.5 s grid",
"axis": "frame index / 20 (frame-anchored; same axis as the CAN CSVs)",
"anchor rule": "slot j of anchor T = bank row at floor(2T)/2 - (15-j)*0.5 -> all slots end <= T",
"checks": [bool(re.search(r"dur = n_frames / 20\.0", ex)), "rel = np.linspace(-CLIP_SPAN, 0.0, CLIP_FRAMES)" in ex]},
"s5 dense library (Vf / Vc / crop pooled, PCA-256 streams, FUTURE F)": {
"code": "s5_features/s5_extract_v4.py (clip_grid); s7_visual_fusion/featpool.py (pool); s12_wm/materialize_s12.py; materialize_oracle_future.py",
"window": "timestamps = clip END time, ts = arange(2.0, dur, 0.5); frames at round((ts+rel)*fps)",
"axis": "CONTAINER fps: fps = vr.get_avg_fps() or 20.0; dur = n_frames/fps (drifts from frame/20 when avg fps != 20)",
"pool rule": "clips with ts in [t-2, t] (>= 3 required) -> [mean, last, trend=last-first] (3 x 1408 = 4224); strictly ts <= t",
"future rule": "F(t+k) = future_pca(s5 feature at the last ts <= t+k, |ts-(t+k)| <= 0.6) -> window [t+k-2, t+k] (overlaps the history for k < 2)",
"checks": [bool(re.search(r"fps = float\(vr\.get_avg_fps\(\)\) or 20\.0", s5)), "ts = np.arange(CLIP_SPAN, dur, STRIDE)" in s5,
"hi = np.searchsorted(ts, t_anchor + 1e-6, side=\"right\")" in fp, "jj = np.searchsorted(ts, t[i] + tau + 1e-6) - 1" in fu]},
"CAN X / Y": {"code": "s12_wm/build_targets_s12.py", "window": "X: t-3.9..t @10 Hz (40 steps, last = t); Y: t+0.2..t+5.0 (25 steps)", "axis": "frame/20"},
"kinematics Kh / K": {"code": "cwm2/data/build_kin_targets (targets_kin)", "window": "Kh: t-3.9..t @10 Hz; K: t+0.2..t+5.0", "axis": "frame/20",
"note": "route-median ROI -> NON-causal ROI choice (disclosed in every run.json); per-frame keypoints"},
}
return rules
# ----------------------------------------------------------------------------- A. numeric checks
def check_bank(regime, split, raw, feats):
t = raw["t"].astype(np.float64)
bt = feats["bank_t16"].astype(np.float64)
ok = feats["tok_ok"].astype(bool)
lag = t[:, None] - bt
last = lag[:, -1][ok[:, -1]]
d = np.diff(bt, axis=1)
both = ok[:, 1:] & ok[:, :-1]
return {"n": int(len(t)), "rows_all16": float(ok.all(1).mean()), "rows_last": float(ok[:, -1].mean()),
"last_lag_min": float(last.min()), "last_lag_max": float(last.max()), "last_lag_mean": float(last.mean()),
"any_noncausal": bool(np.any(lag[ok] < -1e-6)), "max_lag_s": float(np.nanmax(lag[ok])), "slot_spacing_ok": bool(np.allclose(d[both], 0.5, atol=1e-3))}
def s5_route(uid, cam="front"):
p = (C.S5F if cam == "front" else C.S5C) / f"{uid}.npz"
if not p.exists():
return None
with np.load(p) as z:
return z["timestamps"].astype(np.float64), z["features"]
def check_s5_alignment(regime, split, raw, feats, max_rows=20000):
"""per anchor: cos(Vf 'last' block, frontfeat raw1408 of the last bank slot) and the lag of the s5 axis (feature matching)."""
n = len(raw["t"])
Vf = feats["Vf4224"]
raw1408 = feats["raw1408"]
have = np.isfinite(Vf[:, 0]) & np.isfinite(raw1408[:, 0])
cos = np.full(n, np.nan, np.float32)
a = Vf[have, 1408:2816].astype(np.float32)
b = raw1408[have].astype(np.float32)
cos[have] = (a * b).sum(1) / (np.linalg.norm(a, axis=1) * np.linalg.norm(b, axis=1) + 1e-6)
lag = np.full(n, np.nan, np.float32)
lag[have & (cos >= 0.999)] = 0.0
best = np.full(n, np.nan, np.float32)
best[have & (cos >= 0.999)] = cos[have & (cos >= 0.999)]
# matching for the rest, by route (s5 features within +-20 s of the bank slot time)
todo = np.flatnonzero(have & (cos < 0.999))
rng = np.random.default_rng(0)
if len(todo) > max_rows:
todo = np.sort(rng.choice(todo, max_rows, replace=False))
uid = raw["uid"]
bank_t = feats["bank_t16"][:, -1].astype(np.float64)
for u in np.unique(uid[todo]):
got = s5_route(u)
if got is None:
continue
ts, F = got
Fn = F.astype(np.float32)
Fn /= np.linalg.norm(Fn, axis=1, keepdims=True) + 1e-6
for i in todo[uid[todo] == u]:
tb = bank_t[i]
m = (ts >= tb - 20) & (ts <= tb + 20)
if m.sum() < 3:
continue
q = raw1408[i].astype(np.float32)
q /= np.linalg.norm(q) + 1e-6
c = Fn[m] @ q
j = int(np.argmax(c))
best[i] = c[j]
if c[j] >= 0.98: # routes whose container fps != 20 sample slightly different frames -> never an exact match
lag[i] = ts[m][j] - tb # >0: the s5 label of this content is LATER than its frame/20 time
l = lag[np.isfinite(lag)]
res = {"n": int(n), "n_with_both": int(have.sum()), "frac_exact_match(cos>=0.999)": float((cos[have] >= 0.999).mean()),
"cos_p01": float(np.nanpercentile(cos[have], 1)), "cos_median": float(np.nanmedian(cos[have])),
"n_lag_estimated": int(np.isfinite(lag).sum()), "n_lag_unresolved": int((have & ~np.isfinite(lag)).sum()),
"best_match_cos_p05": float(np.nanpercentile(best[have], 5)) if np.isfinite(best[have]).any() else None,
"frac_best_match_exact": float(np.nanmean(best[have] >= 0.999)), "frac_lag_negative(future content)": float((l < 0).mean()), "frac_lag_le_-0.5s": float((l <= -0.5).mean()),
"frac_abs_lag_ge_0.5s": float((np.abs(l) >= 0.5).mean()), "frac_abs_lag_ge_1s": float((np.abs(l) >= 1.0).mean()),
"frac_abs_lag_ge_3s": float((np.abs(l) >= 3.0).mean()), "lag_abs_p50": float(np.percentile(np.abs(l), 50)),
"lag_abs_p95": float(np.percentile(np.abs(l), 95)), "lag_abs_max": float(np.abs(l).max()), "lag_sign_pos_frac": float((l > 0).mean()),
"routes_with_drift": int(len(np.unique(uid[np.isfinite(lag) & (np.abs(lag) >= 0.5)]))), "routes": int(len(np.unique(uid)))}
np.save(C.OUT / f"s5_lag_{regime}_{split}.npy", lag)
np.save(C.OUT / f"s5_cos_{regime}_{split}.npy", cos)
np.save(C.OUT / f"s5_bestcos_{regime}_{split}.npy", best)
return res
def s5_route_level(regime, split, raw):
"""per-route summary of the per-anchor s5 lags (results/probes/s5_lag_*.npy): a route is 'aligned' if its median lag is 0 and the IQR < 0.5 s,
'stale' if median >= +0.5 s, 'future' if median <= -0.5 s (s5 label EARLIER than the frame/20 time of its content -> non-causal input),
'mixed' otherwise; anchor-weighted shares + per-route fps estimate from the slope of lag vs t (lag ~ (20/fps - 1) t)."""
lag = np.load(C.OUT / f"s5_lag_{regime}_{split}.npy")
uid, t = raw["uid"], raw["t"].astype(np.float64)
fin = np.isfinite(lag)
cls = np.full(len(lag), "unresolved", dtype=object)
per_route = []
for u in np.unique(uid):
m = (uid == u) & fin
if m.sum() < 5:
continue
l = lag[m].astype(np.float64)
med, q1, q3 = np.median(l), np.percentile(l, 25), np.percentile(l, 75)
slope = float(np.polyfit(t[m], l, 1)[0]) if m.sum() >= 10 and np.ptp(t[m]) > 60 else np.nan
c = "aligned" if (abs(med) < 0.5 and (q3 - q1) < 0.5) else ("stale" if med >= 0.5 else ("future" if med <= -0.5 else "mixed"))
cls[uid == u] = c
per_route.append({"uid": u, "n": int(m.sum()), "median": float(med), "iqr": float(q3 - q1), "slope": slope, "fps_est": (20.0 / (1.0 + slope) if np.isfinite(slope) and slope > -0.9 else None),
"frac_anchor_lag_le_-0.5": float((l <= -0.5).mean()), "class": c})
n = len(lag)
share = {c: float(np.mean(cls == c)) for c in ("aligned", "stale", "future", "mixed", "unresolved")}
robust_future = float(np.mean((lag <= -0.5) & (cls == "future")))
robust_stale1 = float(np.mean((lag >= 1.0) & np.isin(cls, ["stale", "mixed"])))
slopes = np.array([r["slope"] for r in per_route if r["slope"] is not None and np.isfinite(r["slope"])])
return {"n_anchors": n, "n_routes": int(len(np.unique(uid))), "routes_summarised": len(per_route),
"routes_by_class": {c: int(sum(r["class"] == c for r in per_route)) for c in ("aligned", "stale", "future", "mixed")},
"anchor_share_by_route_class": share, "anchor_share_future_robust(lag<=-0.5 & route future)": robust_future,
"anchor_share_stale_ge_1s_robust": robust_stale1,
"route_slope_abs_p50": float(np.median(np.abs(slopes))) if len(slopes) else None, "route_slope_abs_p90": float(np.percentile(np.abs(slopes), 90)) if len(slopes) else None,
"route_fps_est_range": [float(20 / (1 + slopes.max())), float(20 / (1 + slopes.min()))] if len(slopes) else None,
"worst_routes": sorted(per_route, key=lambda r: -abs(r["median"]))[:5]}
def check_pool_and_future_recompute(regime, split, raw, feats, n_sample=600):
"""recompute the pooled Vf and the future F from the s5 library with the documented rules (ts <= t only) and compare to the stored rows."""
n = len(raw["t"])
rng = np.random.default_rng(1)
have = np.isfinite(feats["Vf4224"][:, 0])
pick = np.sort(rng.choice(np.flatnonzero(have), min(n_sample, int(have.sum())), replace=False))
fp = np.load(C.S12R / "future_pca.npz")
mu, W = fp["mu"].astype(np.float32), fp["W"].astype(np.float32)
uid, t = raw["uid"], raw["t"].astype(np.float64)
max_err_pool, n_clips, n_pool = [], [], 0
f_err, f_ok_match, f_win = [], 0, []
for u in np.unique(uid[pick]):
got = s5_route(u)
if got is None:
continue
ts, F = got
Ff = F.astype(np.float32)
for i in pick[uid[pick] == u]:
lo = np.searchsorted(ts, t[i] - 2.0 - 1e-6)
hi = np.searchsorted(ts, t[i] + 1e-6, side="right")
if hi - lo >= 3:
Wn = Ff[lo:hi]
rec = np.concatenate([Wn.mean(0), Wn[-1], Wn[-1] - Wn[0]]).astype(np.float16).astype(np.float32)
max_err_pool.append(float(np.abs(rec - feats["Vf4224"][i].astype(np.float32)).max() / (np.abs(rec).max() + 1e-6)))
n_clips.append(hi - lo)
n_pool += 1
for k in range(5):
jj = np.searchsorted(ts, t[i] + (k + 1) + 1e-6) - 1
okk = jj >= 0 and abs(ts[jj] - (t[i] + k + 1)) <= 0.6
if okk == bool(raw["Fok"][i, k]):
f_ok_match += 1
if okk and raw["Fok"][i, k]:
rec = ((Ff[jj] - mu) @ W).astype(np.float16).astype(np.float32)
f_err.append(float(np.abs(rec - raw["F"][i, k].astype(np.float32)).max() / (np.abs(rec).max() + 1e-6)))
f_win.append(float(ts[jj] - t[i])) # window END relative to t; window START = END - 2
f_win = np.array(f_win)
return {"n_checked_pool": n_pool, "pool_rel_max_err_p99": float(np.percentile(max_err_pool, 99)) if max_err_pool else None,
"pool_rel_max_err_max": float(np.max(max_err_pool)) if max_err_pool else None,
"pool_n_clips_hist": {int(k): int(v) for k, v in zip(*np.unique(n_clips, return_counts=True))},
"future_ok_flag_agreement": f_ok_match / max(1, 5 * len(pick)), "future_rel_max_err_p99": float(np.percentile(f_err, 99)) if f_err else None,
"future_window_end_minus_t_by_k": {f"+{k}s": [float(np.min(f_win[np.round(f_win) == k])) if np.any(np.round(f_win) == k) else None,
float(np.max(f_win[np.round(f_win) == k])) if np.any(np.round(f_win) == k) else None] for k in range(1, 6)},
"note": "F(t+k) window = [end-2, end]; for k=1 the window [t-1, t+1] overlaps the history; k=2 touches t; k>=3 disjoint"}
def check_continuity(raw):
X, Y = raw["X"].astype(np.float32), raw["Y"].astype(np.float32)
M = raw["M"].astype(bool)
ok = M[:, 0] & np.isfinite(Y[:, 0, 3]) & np.isfinite(X[:, -1, 3])
dv = Y[ok, 0, 3] - X[ok, -1, 3] # vEgo step t -> t+0.2
pred = 0.2 * X[ok, -1, 4] # aEgo(t) * 0.2 s
slope = float(np.polyfit(pred, dv, 1)[0]) if ok.sum() > 100 else np.nan
corr = float(np.corrcoef(pred, dv)[0, 1]) if ok.sum() > 100 else np.nan
# alternative hypothesis: Y[0] is at t (not t+0.2) -> dv would be ~0
dv_abs = float(np.mean(np.abs(dv)))
dv1 = float(np.mean(np.abs(Y[ok, 1, 3] - X[ok, -1, 3])))
# kinematics: K[0] should be nearer to Kh[-1] than K[1] is
Kh, K = raw["Kh"].astype(np.float32), raw["K"].astype(np.float32)
kv = raw["Kvalid"].astype(bool)
okk = np.isfinite(Kh[:, -1, 0]) & np.isfinite(K[:, 0, 0]) & np.isfinite(K[:, 1, 0]) & kv[:, 0] & kv[:, 1]
d0 = np.nanmedian(np.abs(K[okk, 0, :6] - Kh[okk, -1, :6]))
d1 = np.nanmedian(np.abs(K[okk, 1, :6] - Kh[okk, -1, :6]))
d_h = np.nanmedian(np.abs(Kh[okk, -1, :6] - Kh[okk, -2, :6]))
return {"n": int(ok.sum()), "vego_step_slope_vs_0.2*aEgo": slope, "vego_step_corr": corr, "mean_abs_dv_step0": dv_abs, "mean_abs_dv_step1": dv1,
"kin_n": int(okk.sum()), "kin_median_abs_K0_minus_Kh_last": float(d0), "kin_median_abs_K1_minus_Kh_last": float(d1),
"kin_median_abs_Kh_last_step": float(d_h)}
# ----------------------------------------------------------------------------- B. representation statistics
def rep_stats(name, X, device):
import torch
X = np.asarray(X)
fin = np.isfinite(X.reshape(len(X), -1)[:, 0])
X = X[fin].reshape(int(fin.sum()), -1)
n, d = X.shape
Xt = torch.as_tensor(X.astype(np.float32), device=device)
mu = Xt.mean(0)
var = Xt.var(0, unbiased=False)
norms = torch.linalg.norm(Xt, dim=1)
Xc = Xt - mu
G = (Xc.T @ Xc) / n
ev = torch.linalg.eigvalsh(G.double()).flip(0).clamp_min(0)
tot = ev.sum()
cum = torch.cumsum(ev, 0) / tot
pr = float(tot ** 2 / (ev ** 2).sum())
med = float(var.median())
# duplicated columns (exact)
h = np.array([hash(X[:, j].tobytes()) for j in range(d)]) if d <= 8192 else np.zeros(0)
n_dup = int(d - len(np.unique(h))) if d <= 8192 else -1
return {"rep": name, "n": int(n), "d": int(d), "var_median": med, "var_min": float(var.min()), "var_max": float(var.max()),
"frac_near_const(var<1e-6*median)": float((var < 1e-6 * med).float().mean()), "n_dup_cols": n_dup,
"norm_mean": float(norms.mean()), "norm_sd": float(norms.std()), "mean_vec_norm": float(torch.linalg.norm(mu)),
"mean_share_of_energy": float(torch.linalg.norm(mu) ** 2 / (norms ** 2).mean()),
"eff_rank_PR": pr, "n_pc_90": int((cum < 0.90).sum() + 1), "n_pc_99": int((cum < 0.99).sum() + 1), "ev1_share": float(ev[0] / tot)}
# ----------------------------------------------------------------------------- C. mix-up checks
def mixup_checks(regime, split, raw, feats):
out = {}
pz = np.load(C.PCA_DIR / "pca_pooled_256.npz")
r = feats["raw1408"]
have = np.isfinite(r[:, 0]) & feats["tok_ok"][:, -1]
rec = ((r[have].astype(np.float32) - pz["mu"]) @ pz["W"]).astype(np.float16).astype(np.float32)
got = feats["pooled16"][have, -1].astype(np.float32)
out["bank_pooled_last == PCA256(raw1408) rel_max_err_p99"] = float(np.percentile(np.abs(rec - got).max(1) / (np.abs(rec).max(1) + 1e-6), 99))
pv = np.load(C.PCA_DIR / "pca_Vf_256.npz")
hv = np.isfinite(feats["Vf4224"][:, 0]) & raw["vf256_ok"].astype(bool)
rec = ((feats["Vf4224"][hv].astype(np.float32) - pv["mu"]) @ pv["W"]).astype(np.float16).astype(np.float32)
got = raw["vf256"][hv].astype(np.float32)
out["vf256 == PCA256(Vf4224) rel_max_err_p99"] = float(np.percentile(np.abs(rec - got).max(1) / (np.abs(rec).max(1) + 1e-6), 99))
out["vf256 row_ok == Vf4224 finite"] = bool(np.array_equal(raw["vf256_ok"].astype(bool), np.isfinite(feats["Vf4224"][:, 0])))
# region: mean over the 16 tokens == clip-mean token; tok == PCA64(2x2 pooled)
reg = np.load(str(feats["region_file"]), mmap_mode="r")
rr = np.flatnonzero(feats["region_rows"])
filled = feats["region_filled"]
pick = np.flatnonzero(filled)[:2000]
R = np.asarray(reg[pick]).astype(np.float32)
rows = rr[pick]
a, b = R.mean(1), r[rows].astype(np.float32)
okb = np.isfinite(b[:, 0])
cosv = (a[okb] * b[okb]).sum(1) / (np.linalg.norm(a[okb], axis=1) * np.linalg.norm(b[okb], axis=1))
out["region.mean(16) vs raw1408: cos_min"] = float(cosv.min())
out["region.mean(16) vs raw1408: rel_l2_p99"] = float(np.percentile(np.linalg.norm(a[okb] - b[okb], axis=1) / np.linalg.norm(b[okb], axis=1), 99))
pt = np.load(C.PCA_DIR / "pca_tok_64.npz")
pooled = R.reshape(len(R), 2, 2, 2, 2, 1408).mean((2, 4)).reshape(len(R), 4, 1408)
rec = ((pooled - pt["mu"]) @ pt["W"]).astype(np.float16).astype(np.float32)
got = feats["tok16"][rows, -1].astype(np.float32)
okt = feats["tok_ok"][rows, -1]
out["tok16[last] == PCA64(2x2 region) rel_max_err_p99"] = float(np.percentile(np.abs(rec[okt] - got[okt]).max((1, 2)) / (np.abs(rec[okt]).max((1, 2)) + 1e-6), 99))
# between-region variance share: how much the 16 tokens differ from their spatial mean
dev = R - R.mean(1, keepdims=True)
out["region: between-token variance share (1 - var(mean)/var(tokens))"] = float(1 - R.mean(1).var(0).sum() / R.reshape(-1, 1408).var(0).sum())
# Vf vs Vc similarity (a route with cos ~ 1 would be a camera mix-up)
hb = np.isfinite(feats["Vf4224"][:, 0]) & np.isfinite(feats["Vc4224"][:, 0])
a, b = feats["Vf4224"][hb, 1408:2816].astype(np.float32), feats["Vc4224"][hb, 1408:2816].astype(np.float32)
cfc = (a * b).sum(1) / (np.linalg.norm(a, axis=1) * np.linalg.norm(b, axis=1) + 1e-6)
uid = raw["uid"][hb]
per_route = {u: float(np.mean(cfc[uid == u])) for u in np.unique(uid)}
out["Vf-vs-Vc cos: mean"] = float(cfc.mean())
out["Vf-vs-Vc cos: max route mean"] = float(max(per_route.values())) if per_route else None
out["Vf-vs-Vc routes with mean cos > 0.98"] = int(sum(v > 0.98 for v in per_route.values()))
# crop vs Vc (cabin ROI crop vs cabin full frame) for orientation
hc = np.isfinite(feats["crop4224"][:, 0]) & np.isfinite(feats["Vc4224"][:, 0])
a, b = feats["crop4224"][hc, 1408:2816].astype(np.float32), feats["Vc4224"][hc, 1408:2816].astype(np.float32)
out["crop-vs-Vc cos: mean"] = float(((a * b).sum(1) / (np.linalg.norm(a, axis=1) * np.linalg.norm(b, axis=1) + 1e-6)).mean())
# identical consecutive rows <=> same bank slot
same_route = raw["uid"][1:] == raw["uid"][:-1]
ident = np.all(r[1:] == r[:-1], axis=1) & np.isfinite(r[1:, 0]) & same_route
same_slot = (raw["tok_idx"][1:, -1] == raw["tok_idx"][:-1, -1]) & (raw["tok_idx"][1:, -1] >= 0) & same_route
out["consecutive probe rows: identical raw1408"] = int(ident.sum())
out["consecutive probe rows: same bank slot"] = int(same_slot.sum())
out["identical <=> same slot agreement"] = float((ident == same_slot)[same_route].mean())
return out
# ----------------------------------------------------------------------------- D. fit provenance
def fit_provenance():
out = {}
for f in sorted(C.PCA_DIR.glob("pca_*.npz")):
z = np.load(f, allow_pickle=True)
rec = {k: (z[k].tolist() if z[k].ndim == 0 else None) for k in z.files if k not in ("mu", "W", "evr")}
rec["evr_sum"] = float(z["evr"].sum())
rec["W_shape"] = list(z["W"].shape)
out[f.name] = {k: v for k, v in rec.items() if v is not None}
man = [json.loads(l) for l in (C.PCA_DIR / "pca_manifest.jsonl").read_text().splitlines() if l.strip()]
out["manifest_entries"] = len(man)
# token bank PCA fit: routes from targets_manual_train only (token_bank.fit)
src = (C.CWM3 / "data" / "token_bank.py").read_text()
out["token_bank_fit_source"] = "targets_manual_train.npz uids" if 'S12R / "targets_manual_train.npz"' in src else "UNKNOWN"
src2 = (C.CWM3 / "data" / "pca_streams.py").read_text()
out["pca_streams_fit_source"] = 'src_path(stream, "manual", "train")' in src2
# future_pca: fitted on s5 files of ALL routes (train/val/test), unsupervised
src3 = (C.EXPLORE / "s12_wm" / "materialize_oracle_future.py").read_text()
out["future_pca_fit"] = "s5 front library, files shuffled over ALL routes (incl. val/test routes), 100k vectors, SVD on 50k — unsupervised, not train-only" \
if "files = sorted(S5F.glob(\"*.npz\"))" in src3 else "UNKNOWN"
# trainer standardisation: recompute train-only xmu/xsd/kmu/ksd (both regimes pooled) and compare with the run's stats.npz
S = np.zeros(5); Q = np.zeros(5); n = 0
Sk = np.zeros(11); Qk = np.zeros(11); nk = np.zeros(11)
for regime in C.REGIMES:
with np.load(C.S12R / f"targets_{regime}_train.npz", allow_pickle=True) as z:
X = z["X"].reshape(-1, 5).astype(np.float64)
S += X.sum(0); Q += (X ** 2).sum(0); n += len(X)
del X
for i, blk in C.iter_member(C.KIN / f"kinhist_{regime}_train.npz", "Kh"):
K = blk.reshape(-1, 11).astype(np.float64)
fin = np.isfinite(K)
Sk += np.where(fin, K, 0).sum(0); Qk += np.where(fin, K ** 2, 0).sum(0); nk += fin.sum(0)
xmu = S / n; xsd = np.sqrt(Q / n - xmu ** 2) + 1e-6
kmu = Sk / nk; ksd = np.sqrt(Qk / nk - kmu ** 2) + 1e-6
st = np.load(C.RUNS / "U0_kin_can_noK_s0" / "stats.npz")
out["stats.npz(U0_kin_can_noK_s0) == train-only recomputation"] = {
"xmu_max_rel_err": float(np.max(np.abs(st["xmu"] - xmu) / (np.abs(xmu) + 1e-3))), "xsd_max_rel_err": float(np.max(np.abs(st["xsd"] - xsd) / xsd)),
"kmu_max_rel_err": float(np.max(np.abs(st["kmu"] - kmu) / (np.abs(kmu) + 1e-3))), "ksd_max_rel_err": float(np.max(np.abs(st["ksd"] - ksd) / ksd)),
"n_rows_X": int(n // 40)}
stE = np.load(C.RUNS / "E0_pooled_s0" / "stats.npz")
out["stats.npz(E0_pooled_s0) keys"] = list(stE.files)
return out
# ----------------------------------------------------------------------------- E. AIDE Qwen features
def aide_qwen(device):
import torch
p = C.CWM3 / "aide" / "results" / "feats" / "feats_qwen.npz"
pooled = C.npz_memmap(p, "pooled")
vis = C.npz_memmap(p, "vis_pooled")
with np.load(p, allow_pickle=True) as z:
meta = json.loads(str(z["meta"]))
views = [str(v) for v in z["views"]]
ntok, nvis = z["n_tokens"], z["n_vis_tokens"]
split = z["split"]
N = pooled.shape[0]
out = {"file": str(p), "shape": list(pooled.shape), "dtype": str(pooled.dtype), "views": views, "n_clips": int(N),
"model": meta["model_id"], "dtype_model": meta["dtype"], "layer": "last decoder layer hidden states after the final RMSNorm (model.model(...).last_hidden_state); no LM head",
"pooling": meta["pooling"], "prompt": meta["prompt"][:80] + "...", "template_has_generation_prompt": meta["add_generation_prompt"],
"image_size_cfg": meta["image_size_cfg"], "n_tokens_per_image": [int(ntok.min()), int(ntok.max())], "n_vis_tokens": [int(nvis.min()), int(nvis.max())],
"prompt_share_of_tokens": float(1 - nvis.mean() / ntok.mean()), "frames_per_clip": 10, "hidden": meta["hidden"]}
rng = np.random.default_rng(0)
pick = np.sort(rng.choice(N, min(800, N), replace=False))
P = np.asarray(pooled[pick]).astype(np.float32) # [n,10,4,2048]
V = np.asarray(vis[pick]).astype(np.float32)
per_view = {}
for vi, vn in enumerate(views):
rec = {}
for nm, A in (("pooled", P[:, :, vi]), ("vis_pooled", V[:, :, vi])):
X = A.reshape(-1, 2048)
s = rep_stats(f"{nm}/{vn}", X, device)
# within-clip (temporal) vs between-clip variance
within = A.var(1, ddof=0).mean(0).sum()
total = X.var(0).sum()
cos_adj = (A[:, 1:] * A[:, :-1]).sum(-1) / (np.linalg.norm(A[:, 1:], axis=-1) * np.linalg.norm(A[:, :-1], axis=-1))
rec[nm] = {"norm_mean": s["norm_mean"], "norm_sd": s["norm_sd"], "var_median": s["var_median"], "eff_rank_PR": s["eff_rank_PR"],
"n_pc_90": s["n_pc_90"], "n_pc_99": s["n_pc_99"], "ev1_share": s["ev1_share"], "mean_share_of_energy": s["mean_share_of_energy"],
"within_clip_var_share": float(within / total), "cos_adjacent_frames_mean": float(cos_adj.mean())}
a, b = P[:, :, vi].reshape(-1, 2048), V[:, :, vi].reshape(-1, 2048)
rec["cos(pooled, vis_pooled)"] = float(((a * b).sum(1) / (np.linalg.norm(a, axis=1) * np.linalg.norm(b, axis=1))).mean())
# implied mean of the 70 prompt/template token states: (2110 p - 2040 v) / 70
q = (2110 * a - 2040 * b) / 70
rec["implied_prompt_token_mean: norm_mean"] = float(np.linalg.norm(q, axis=1).mean())
rec["implied_prompt_token_mean: eff_rank_PR"] = rep_stats("q", q, device)["eff_rank_PR"]
per_view[vn] = rec
out["per_view"] = per_view
# between-view separability: share of variance explained by the view mean
X = V.reshape(-1, 4, 2048)
vm = X.mean(0) # [4,2048]
out["vis_pooled: between-view variance share"] = float(((vm - vm.mean(0)) ** 2).sum() / X.reshape(-1, 2048).var(0).sum() / 1.0)
out["split_counts"] = {s: int((split == s).sum()) for s in np.unique(split)}
return out
# ----------------------------------------------------------------------------- main
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--sections", default="A,B,C,D,E")
ap.add_argument("--render-only", action="store_true", help="re-render latent_audit.md from results/probes/audit_latest.json")
a = ap.parse_args()
if a.render_only:
write_md(json.loads((C.OUT / "audit_latest.json").read_text()))
return
if a.sections == "R": # route-level lag summary only (from the saved per-anchor lags), then re-render
res = json.loads((C.OUT / "audit_latest.json").read_text())
res["A_s5_routes"] = {f"{r}/{s}": s5_route_level(r, s, C.load_raw(r, s)) for r, s in SETS}
res["created_utc"] = C.stamp()
C.write_json(C.OUT / f"audit_{res['created_utc']}.json", res)
C.write_json(C.OUT / "audit_latest.json", res)
write_md(res)
log("R done")
return
t0 = time.time()
dev = C.torch_device()
log(f"device {dev}")
sec = set(a.sections.split(","))
res = {"rules": alignment_rules(), "created_utc": C.stamp()}
prev = C.OUT / "audit_latest.json"
if prev.exists(): # partial re-runs keep the sections computed earlier (each section is stamped)
old = json.loads(prev.read_text())
for k, v in old.items():
if k not in ("rules", "created_utc", "wall_s"):
res[k] = v
res["previous_sections_from"] = old.get("created_utc")
sets = SETS
class Lazy(dict): # one (regime, split) resident at a time -> bounded RSS on the shared host
def __init__(self, loader):
super().__init__()
self.loader = loader
def __getitem__(self, key):
if key not in self:
self.clear()
super().__setitem__(key, self.loader(*key))
return super().__getitem__(key)
raws = Lazy(lambda r, s: C.load_raw(r, s))
feats = Lazy(lambda r, s: dict(np.load(C.feats_path(r, s), allow_pickle=True)))
if "A" in sec:
res["A_bank"] = {f"{r}/{s}": check_bank(r, s, raws[(r, s)], feats[(r, s)]) for r, s in sets}
log("A bank done")
res["A_s5_alignment"] = {}
for r, s in sets:
res["A_s5_alignment"][f"{r}/{s}"] = check_s5_alignment(r, s, raws[(r, s)], feats[(r, s)])
log(f"A s5 alignment {r}/{s}: {res['A_s5_alignment'][f'{r}/{s}']}")
res["A_s5_routes"] = {f"{r}/{s}": s5_route_level(r, s, raws[(r, s)]) for r, s in sets}
log("A route-level lag done")
res["A_pool_future_recompute"] = {f"{r}/{s}": check_pool_and_future_recompute(r, s, raws[(r, s)], feats[(r, s)]) for r, s in (("manual", "val"), ("engaged", "val"), ("manual", "test"))}
log("A recompute done")
res["A_continuity"] = {f"{r}/{s}": check_continuity(raws[(r, s)]) for r, s in sets}
log("A continuity done")
if "B" in sec:
B = []
for r in C.REGIMES:
raw, fe = raws[(r, "train")], feats[(r, "train")]
lat = np.load(C.OUT / f"latents_{r}_train.npz")
reps = {"raw1408 (frontfeat clip-mean, last slot)": fe["raw1408"], "Vf4224 pooled [mean,last,trend]": fe["Vf4224"], "vf256 (PCA of Vf4224)": raw["vf256"],
"bank pooled256 last slot (PCA of raw1408)": fe["pooled16"][:, -1], "bank pooled256 x16 slots (4096)": fe["pooled16"].reshape(len(raw["t"]), -1),
"bank tok 16x4x64 (4096)": fe["tok16"].reshape(len(raw["t"]), -1), "bank tok last slot 4x64 (256)": fe["tok16"][:, -1].reshape(len(raw["t"]), -1),
"Vc4224 cabin pooled": fe["Vc4224"], "vc256": raw["vc256"], "crop256 (non-causal ROI)": raw["crop256"],
"F actual +3s (future_pca 256)": np.where(raw["Fok"][:, 2:3], raw["F"][:, 2].astype(np.float32), np.nan),
"s_V4 TCN(X 4s) 256": lat["s_V4"], "s_V8 TCN(X8) 256": lat["s_V8"], "s_U GRU 128": lat["s_U"], "s_E readout 128": lat["s_E"],
"s_Evf Linear(vf256) 128": lat["s_Evf"], "F_hat +3s (E0 F head)": lat["F_hat"][:, 2]}
reg = np.load(str(fe["region_file"]), mmap_mode="r")
filled = fe["region_filled"]
reps["region 16x1408 flattened (22528; region subset)"] = np.asarray(reg[np.flatnonzero(filled)[:6000]]).reshape(-1, 16 * 1408)
for name, X in reps.items():
X = np.asarray(X)
if X.shape[1] > 8192:
# too wide for a dense covariance: spectrum of the Gram of a 6000-row sample instead (same nonzero eigenvalues)
import torch
Xt = torch.as_tensor(X.astype(np.float32), device=dev)
Xt = Xt - Xt.mean(0)
ev = torch.linalg.eigvalsh((Xt @ Xt.T).double() / len(Xt)).flip(0).clamp_min(0)
cum = torch.cumsum(ev, 0) / ev.sum()
B.append({"regime": r, "rep": name, "n": int(len(X)), "d": int(X.shape[1]), "eff_rank_PR": float(ev.sum() ** 2 / (ev ** 2).sum()),
"n_pc_90": int((cum < 0.9).sum() + 1), "n_pc_99": int((cum < 0.99).sum() + 1), "ev1_share": float(ev[0] / ev.sum()),
"norm_mean": float(np.linalg.norm(X.astype(np.float32), axis=1).mean()), "var_median": None, "frac_near_const(var<1e-6*median)": None,
"n_dup_cols": None, "mean_share_of_energy": None})
else:
B.append(dict(regime=r, **rep_stats(name, X, dev)))
log(f"B {r} {name}: {B[-1]}")
res["B_rep_stats"] = B
if "C" in sec:
res["C_mixup"] = {f"{r}/{s}": mixup_checks(r, s, raws[(r, s)], feats[(r, s)]) for r, s in (("manual", "val"), ("engaged", "val"), ("manual", "train"), ("manual", "test"))}
log(f"C done: {res['C_mixup']['manual/val']}")
if "D" in sec:
res["D_provenance"] = fit_provenance()
log("D done")
if "E" in sec:
res["E_aide_qwen"] = aide_qwen(dev)
log("E done")
res["wall_s"] = round(time.time() - t0, 1)
C.write_json(C.OUT / f"audit_{res['created_utc']}.json", res)
C.write_json(C.OUT / "audit_latest.json", res)
write_md(res)
log(f"DONE {res['wall_s']}s")
def write_md(res):
L = [f"# Latent audit (P0) — extraction correctness of the frozen latents", "",
f"Generated {res['created_utc']} by `probes/audit_features.py` on the probe rows (results/probes/rows_*.npz: 50k/15k/40k per regime for train/val/test; "
f"region subset 15k/5k/15k). Raw values: `results/probes/audit_latest.json`. Nothing here is a model result.", ""]
L += ["## A. Time alignment", "", "### A.0 Window / axis rules read from the producer code", ""]
for k, v in res["rules"].items():
L.append(f"* **{k}** — " + "; ".join(f"{kk}: {vv}" for kk, vv in v.items() if kk != "checks") + (f"; code asserts {v['checks']}" if "checks" in v else ""))
if "A_bank" in res:
L += ["", "### A.1 Token bank gather (frontfeat, frame/20 axis)", "",
C.md_table(["set", "rows", "all 16 slots", "last slot", "last-slot lag min/mean/max (s)", "max lag (s)", "any non-causal", "0.5 s spacing"],
[[k, v["n"], f"{v['rows_all16']:.4f}", f"{v['rows_last']:.4f}", f"{v['last_lag_min']:.2f} / {v['last_lag_mean']:.2f} / {v['last_lag_max']:.2f}",
f"{v['max_lag_s']:.2f}", v["any_noncausal"], v["slot_spacing_ok"]] for k, v in res["A_bank"].items()])]
L += ["", "### A.2 s5 dense library (Vf / Vc pooled, PCA-256 streams, future F) vs the frame/20 axis", "",
"Per anchor: cosine between the `last` block of the stored Vf pooled vector (s5 clip ending at the last s5 timestamp <= t) and the frontfeat clip-mean token of "
"the last bank slot (window ending at floor(2t)/2). Same model, same geometry, same frames -> identical (cos >= 0.999) when the two time axes agree. Where they "
"differ, the lag of the s5 axis is estimated by matching the frontfeat token against the s5 route features (+-20 s); lag > 0 means the s5 label of that content "
"is LATER than its frame/20 time, i.e. the s5-labelled feature at time t shows the road at t - lag (stale but causal); for the future F(t+k) it means the "
"'future' window is really the window ending at t + k - lag.", "",
C.md_table(["set", "rows with both", "exact match at lag 0", "cos p01 at lag 0", "lag resolved / unresolved (best cos < 0.98)", "best-match cos p05", "|lag| >= 0.5 s", ">= 1 s", ">= 3 s", "lag < 0 (future content) / <= -0.5 s", "|lag| p50 / p95 / max (s)", "routes drifting / total"],
[[k, v["n_with_both"], f"{v['frac_exact_match(cos>=0.999)']:.4f}", f"{v['cos_p01']:.4f}", f"{v['n_lag_estimated']} / {v['n_lag_unresolved']}",
(f"{v['best_match_cos_p05']:.4f}" if v.get("best_match_cos_p05") is not None else "–"),
f"{v['frac_abs_lag_ge_0.5s']:.4f}", f"{v['frac_abs_lag_ge_1s']:.4f}", f"{v['frac_abs_lag_ge_3s']:.4f}",
(f"{v['frac_lag_negative(future content)']:.4f} / {v['frac_lag_le_-0.5s']:.4f}" if "frac_lag_negative(future content)" in v else f"pos share {v['lag_sign_pos_frac']:.4f}"),
f"{v['lag_abs_p50']:.1f} / {v['lag_abs_p95']:.1f} / {v['lag_abs_max']:.1f}", f"{v['routes_with_drift']} / {v['routes']}"] for k, v in res["A_s5_alignment"].items()])]
if "A_s5_routes" in res:
L += ["", "### A.2b Route-level view of the s5 lag (per route: median lag of its anchors; robust to the static-scene ambiguity of a single-anchor match)", "",
"Route classes: aligned (median lag 0, IQR < 0.5 s), stale (median ≥ +0.5 s: content OLDER than the label, causal), future (median ≤ −0.5 s: the s5 label is "
"EARLIER than the frame/20 time of its content → the feature at anchor t contains frames after t → NON-causal input), mixed. Shares are anchor-weighted.", "",
C.md_table(["set", "routes aligned / stale / future / mixed", "anchors on aligned / stale / future / mixed routes", "anchors with lag ≤ −0.5 s on a 'future' route", "anchors with lag ≥ 1 s on a stale/mixed route",
"|slope| p50 / p90 (s per s)", "fps estimate range", "worst route (median lag s, n)"],
[[k, " / ".join(str(v["routes_by_class"][c]) for c in ("aligned", "stale", "future", "mixed")),
" / ".join(f"{v['anchor_share_by_route_class'][c]:.3f}" for c in ("aligned", "stale", "future", "mixed")),
f"{v['anchor_share_future_robust(lag<=-0.5 & route future)']:.4f}", f"{v['anchor_share_stale_ge_1s_robust']:.4f}",
(f"{v['route_slope_abs_p50']:.5f} / {v['route_slope_abs_p90']:.5f}" if v["route_slope_abs_p50"] is not None else "–"),
(f"{v['route_fps_est_range'][0]:.3f} – {v['route_fps_est_range'][1]:.3f}" if v["route_fps_est_range"] else "–"),
(f"{v['worst_routes'][0]['uid'][:40]}… ({v['worst_routes'][0]['median']:+.1f}, n={v['worst_routes'][0]['n']})" if v["worst_routes"] else "–")]
for k, v in res["A_s5_routes"].items()])]
L += ["", "### A.3 Recomputation of the pooled Vf and of the future F from the s5 library with the documented rules (ts <= t only)", "",
C.md_table(["set", "pooled rows checked", "pooled rel. max err p99 / max", "clips per pool (count)", "F ok-flag agreement", "F rel. max err p99", "F window END - t by k (min, max)"],
[[k, v["n_checked_pool"], f"{v['pool_rel_max_err_p99']:.2e} / {v['pool_rel_max_err_max']:.2e}", v["pool_n_clips_hist"], f"{v['future_ok_flag_agreement']:.4f}",
f"{v['future_rel_max_err_p99']:.2e}", v["future_window_end_minus_t_by_k"]] for k, v in res["A_pool_future_recompute"].items()]),
"", f"Note: {list(res['A_pool_future_recompute'].values())[0]['note']}."]
L += ["", "### A.4 CAN and kinematics step continuity (is X[-1] the anchor and Y[0] the step after it?)", "",
C.md_table(["set", "n", "slope of (vEgo[t+0.2]-vEgo[t]) on 0.2*aEgo[t]", "corr", "mean |dv| step0 / step1", "kin n", "median |K[0]-Kh[-1]| / |K[1]-Kh[-1]| / |Kh[-1]-Kh[-2]| (px)"],
[[k, v["n"], f"{v['vego_step_slope_vs_0.2*aEgo']:.3f}", f"{v['vego_step_corr']:.3f}", f"{v['mean_abs_dv_step0']:.3f} / {v['mean_abs_dv_step1']:.3f}", v["kin_n"],
f"{v['kin_median_abs_K0_minus_Kh_last']:.2f} / {v['kin_median_abs_K1_minus_Kh_last']:.2f} / {v['kin_median_abs_Kh_last_step']:.2f}"] for k, v in res["A_continuity"].items()])]
if "B_rep_stats" in res:
L += ["", "## B. Representation statistics (train probe rows; reported, not over-interpreted)", "",
C.md_table(["regime", "representation", "n", "d", "var median", "near-const dims", "dup cols", "row norm mean ± sd", "mean-vector energy share", "eff. rank (PR)", "PCs 90 % / 99 %", "top-PC share"],
[[b["regime"], b["rep"], b["n"], b["d"], C.f3(b["var_median"]) if b["var_median"] is not None else "–",
f"{b['frac_near_const(var<1e-6*median)']:.4f}" if b["frac_near_const(var<1e-6*median)"] is not None else "–", b["n_dup_cols"] if b["n_dup_cols"] is not None else "–",
f"{b['norm_mean']:.2f} ± {b.get('norm_sd', float('nan')):.2f}" if b.get("norm_sd") is not None else f"{b['norm_mean']:.2f}",
f"{b['mean_share_of_energy']:.3f}" if b["mean_share_of_energy"] is not None else "–", f"{b['eff_rank_PR']:.1f}", f"{b['n_pc_90']} / {b['n_pc_99']}", f"{b['ev1_share']:.3f}"] for b in res["B_rep_stats"]])]
if "C_mixup" in res:
L += ["", "## C. Cache mix-up / consistency checks", ""]
keys = list(next(iter(res["C_mixup"].values())).keys())
L.append(C.md_table(["check"] + list(res["C_mixup"].keys()), [[k] + [(f"{v[k]:.2e}" if isinstance(v[k], float) and abs(v[k]) < 1e-2 and v[k] != 0 else (f"{v[k]:.4f}" if isinstance(v[k], float) else v[k])) for v in res["C_mixup"].values()] for k in keys]))
if "D_provenance" in res:
D = res["D_provenance"]
L += ["", "## D. Fit provenance (PCA / standardisation on TRAIN only?)", ""]
for k, v in D.items():
L.append(f"* `{k}`: {json.dumps(v) if not isinstance(v, str) else v}")
if "E_aide_qwen" in res:
E = res["E_aide_qwen"]
L += ["", "## E. AIDE — what `aide/results/feats/feats_qwen.npz` holds", "",
f"* file {E['file']}; arrays `pooled` and `vis_pooled` {E['shape']} {E['dtype']} = [clip, 10 protocol frames, 4 views {E['views']}, 2048]; clips per split {E['split_counts']}",
f"* model {E['model']} ({E['dtype_model']}, sdpa), images at native resolution (image_size_cfg {E['image_size_cfg']}) -> {E['n_tokens_per_image'][0]} tokens per image of which "
f"{E['n_vis_tokens'][0]} are vision tokens; prompt/template share of tokens = {E['prompt_share_of_tokens']:.4f} (70 / 2110)",
f"* layer: {E['layer']}", f"* pooling: {E['pooling']}", f"* prompt (Driver-WM App. B.2 verbatim): \"{E['prompt']}\"; chat template with generation prompt = {E['template_has_generation_prompt']}",
f"* between-view variance share of vis_pooled (how much of the variance is 'which camera'): {E['vis_pooled: between-view variance share']:.3f}", "",
C.md_table(["view", "array", "row norm mean ± sd", "var median", "mean-vector energy share", "eff. rank (PR)", "PCs 90 % / 99 %", "top-PC share", "within-clip (temporal) variance share", "cos adjacent frames", "cos(pooled, vis_pooled)", "implied prompt-token mean: norm / eff. rank"],
[[vn, nm, f"{r[nm]['norm_mean']:.2f} ± {r[nm]['norm_sd']:.2f}", f"{r[nm]['var_median']:.4f}", f"{r[nm]['mean_share_of_energy']:.3f}", f"{r[nm]['eff_rank_PR']:.1f}",
f"{r[nm]['n_pc_90']} / {r[nm]['n_pc_99']}", f"{r[nm]['ev1_share']:.3f}", f"{r[nm]['within_clip_var_share']:.3f}", f"{r[nm]['cos_adjacent_frames_mean']:.4f}",
f"{r['cos(pooled, vis_pooled)']:.4f}", f"{r['implied_prompt_token_mean: norm_mean']:.1f} / {r['implied_prompt_token_mean: eff_rank_PR']:.1f}"]
for vn, r in E["per_view"].items() for nm in ("pooled", "vis_pooled")])]
(C.TABLES / "latent_audit.md").write_text("\n".join(L) + "\n")
if __name__ == "__main__":
main()

Xet Storage Details

Size:
44.7 kB
·
Xet hash:
3df10e466e685be368852ab423b4ba73461e8bd1e17c3f20293c72f793038278

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