Files
evil_MoE/nbs/cosine_dist.ipynb
T
wassnameandClaudypoo 80e82f0b29 diag: pinning separability sweep (grad/act x cos/proj/mag x filter), AUROC+p@k, notebook
Finding: v_grad/As barely separate LIVE hack from clean (authored pairs are
off-distribution: localized run_tests-block contrast vs full novel-problem rollouts).
act-cosine best AUROC 0.69; grad-cosine best confident-tail p@10 0.70; magnitude inverted.

Co-Authored-By: Claudypoo <288921227+claudypoo@users.noreply.github.com>
2026-06-08 11:11:55 +00:00

2.6 KiB

Pinning diagnostic: does the contrastive hack direction predict live hacks?

Replays scripts/diag_cosine_dist.py outputs (no GPU). Spaces: grad (v_grad on delta_S) and act (As in S space). Scores: cosine (dir only), projection (dir x |g|), magnitude (|g|). Filters: all modules / noise-floor kept. Separability = AUROC + precision@k of score -> oracle exploited.

In [ ]:
import polars as pl
import matplotlib.pyplot as plt
D = '../out/diag/'
hist = pl.read_parquet(D+'cosine_dist.parquet')
scores = pl.read_parquet(D+'live_scores.parquet')
sep = pl.read_csv(D+'separability.csv')
sep
In [ ]:
# histograms: cosine to hack direction, both spaces
colors = {'pair_clean':'tab:blue','pair_hack':'tab:red','live_clean':'tab:cyan','live_hack':'tab:orange'}
fig, axes = plt.subplots(1, 2, figsize=(15, 5))
for ax, space in zip(axes, ['grad','act']):
    for pop, c in colors.items():
        v = hist.filter((pl.col('space')==space) & (pl.col('pop')==pop))['cos'].to_numpy()
        if len(v):
            ax.hist(v, bins=15, density=True, histtype='step', lw=2, color=c, label=f'{pop} (n={len(v)})')
    ax.set_title(f'{space} space'); ax.set_xlabel('global cosine to hack dir'); ax.legend(fontsize=8)
plt.tight_layout(); plt.show()
In [ ]:
# per-score distributions split by exploited: which score separates?
cols = [c for c in scores.columns if c != 'exploited']
fig, axes = plt.subplots(2, len(cols)//2, figsize=(16, 7))
for ax, col in zip(axes.flat, cols):
    for y, c in [(True,'tab:orange'),(False,'tab:cyan')]:
        v = scores.filter(pl.col('exploited')==y)[col].to_numpy()
        ax.hist(v, bins=15, density=True, histtype='step', lw=2, color=c, label='hack' if y else 'clean')
    ax.set_title(col, fontsize=8); ax.legend(fontsize=7)
plt.tight_layout(); plt.show()