probe_distill: mixed-replay loader with heterogeneous plens, Dr.GRPO
loss path (REINFORCE-style centered advantage), slim save when in
replay mode, just recipes probe-mixed-{vanilla,projected}.
proj: project_delta_S_grad returns min/max of per-module cos_in/out
alongside means, so step printout shows distribution not just average.
probe_distill: norm_weighted_cos now divides by sqrt(n_modules) so the
per-sample cos_S_contrib is a proper cosine in [-1, 1] (was the
sqrt-of-n quirk that let it exceed 1).
Step-0 mixed-replay result: teacher (hack=1) samples cos +0.07-0.09
(proper scale), base (hack=0) samples cos -0.005 to +0.004 -- two
cleanly separated distributions on 4+4 samples. v_hack extracted from
hand-authored pairs.py generalizes to ariahw's RL-emergent hack
direction. Strong methodological confirmation.
Journal: 2026-05-25 (b) entry covers the GRPO probe, the projection
asymmetry that makes cos_out slightly negative (cos_in<=0 modules
skipped), and the cos norm fix.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
20 KiB
Research Journal
2026-05-25 (b) — Mixed-replay GRPO probe + projection asymmetry + cos fix
Metadata. Branch probe/distill-cosine. Build on Phase 1 (NLL probe).
Mixed-replay GRPO works
The Phase 1 NLL probe couldn't measure cos(GRPO_grad, v_hack) directly
because rh-s65 hacks 100% → identical reward → centered Dr.GRPO advantage
collapses to zero. Solution: per step, replay 4 samples from
teacher_pool/ (reward≈3.5, hack=1) + 4 from base_pool/
(reward≈0-0.5, hack=0). adv = r - r.mean() is now meaningfully
positive on teacher rows, negative on base rows → policy gradient
weights hacks positively and base negatively → cosine with v_hack
becomes the real H1-relevant signal.
First step result (vanilla mixed-replay, single seed):
- Teacher samples per-sample cos: +1.16 to +1.36 (in old un-normalized norm_weighted_cos scale; properly normalized these are ~+0.07 to +0.09 per-sample contribution against v_hack direction).
- Base samples per-sample cos: -0.09 to +0.07 (near zero).
- Aggregate Dr.GRPO
cos_in = +0.049(proper cosine, [-1,1] range).
Discrimination is strong: teacher (hack) samples align with v_hack; base (non-hack) samples don't. v_hack is hack-specific, not generic "any gradient" direction.
Why cos_out can be slightly negative
project_delta_S_grad only acts on modules where cos_in_m > 0. Modules
with cos_in_m ≤ 0 are left untouched. Aggregate cos_out averages
[≈0 from fired modules] + [original negative cos_in from skipped
modules]. With frac_fired ≈ 0.63 the skipped 37% pull the mean
slightly below zero. Not a bug — designed asymmetric removal of only
the v_hack-aligned component.
norm_weighted_cos was missing the v-side normalizer
Per-module v_hack is unit-norm, so the flat-concatenated v has norm
sqrt(n_modules). The original norm_weighted_cos divided only by
||c_flat||, giving values in [-sqrt(252), +sqrt(252)]. Fixed:
cos = sum_m <c_m, v_m_unit> / (||c_flat|| * sqrt(n_modules)). Result
now in [-1, 1]. Per-module aggregate cos_in (from
project_delta_S_grad) was always proper cosine; only the per-sample
cos_S_contrib in probe_distill.py was off-scale.
v_hack discriminates — strong confirmation
The 8-sample step-0 mixed batch is itself a clean v_hack-quality test.
Per-sample cosines split cleanly by source pool: teacher (rh-s65, hack=1)
samples land at +1.16 to +1.36 (un-normalized scale; ~+0.07 to +0.09
proper cosine), while base (no LoRA, no hint, hack=0) samples land at
-0.09 to +0.07 (essentially orthogonal). Two completely separated
distributions on 4+4 samples — the gradient direction v_hack was
trained to detect (from contrastive NLL pairs in pairs.py) IS the
gradient direction observed on rh-s65's hack rollouts vs base's
non-hack rollouts. v_hack generalizes from the 20 hand-authored pairs
to ariahw's RL-emergent hack pattern. This is the core methodological
test for the projection-defence claim and it passes cleanly.
Practical interpretation
For Phase 3 expected-effect-size sketches:
- Vanilla mixed-replay step-0
cos_in ≈ +0.05(mild alignment). At real-training-step 80+ when student starts hacking, expect cos_in to climb — this Phase 2 probe can't see that regime (no online generation). - Projection mechanism:
cos_out≈ 0 on fired modules, slightly negative aggregate because of skipped modules. - Per-sample discrimination on individual hacky rollout: cos ≈ +0.08 ([-1,1] scale). Compare against base samples ≈ 0 — clear separator.
2026-05-25 — Distillation probe scaffold, NLL-vs-GRPO caveat, rh prompt fix
Metadata. Commit: fa24f4e + uncommitted probe_distill.py / probe_uat.py
on branch probe/distill-cosine. ariahw publishes intervention checkpoints on
HF including ariahw/rl-rewardhacking-leetcode-rh-s65 (the "no intervention"
arm trained on the loophole env, expected ~79% hack at step 200).
Why this branch
Before committing the 3-seed headline sweep (~36-54h), wanted a faster
falsification: feed hacky teacher rollouts to the student, log per-sample
cos(grad, v_hack), and check both whether v_hack is oriented correctly
(Plan 1) and whether projection slows hacking learning (Plan 2) in ~1h
instead of ~12h. One script (probe_distill.py) with three modes
(--teacher-only, default, --replay-dir=...) so vanilla and projected
arms can replay the same teacher rollouts (apples-to-apples).
Methodological caveat: v_hack is NLL, GRPO is reward-weighted
extract_vhack_grad.py computes v_hack as the difference of mean NLL
gradients between hack-completion and clean-completion pairs. That is
not the GRPO policy gradient direction. GRPO's gradient on a
rewarded-hack sample is -r * dlogp(token); on a non-rewarded sample
it's -r * dlogp(token) with a different sign — both shaped by advantage,
not just by how likely the completion is.
So our v_hack is a heuristic that hopes "shift NLL toward hacky text" correlates with "what the GRPO update would do toward hacking." It may work in practice (both increase P(hack tokens), just by different paths) but it isn't apples-to-apples. If the per-sample cosine separation test fails, the fallback is to re-extract v_hack with a GRPO-style contrastive loss: same persona pairs, but compute the gradient at adv=+1 on the hack completion and adv=-1 on the clean completion. Same threat model (defense is authored before seeing RL rollouts), apples-to-apples gradient direction.
Bug: rh-s65 saw the wrong prompt distribution
Initial 1-step probe: rh-s65 produced 0/8 hacks (just stub solutions).
Diagnosis from external/rl-rewardhacking/scripts/run_rl_training.py:122
and src/data/hints.py:85-106:
- rh ("no intervention") is trained with
DEFAULT_TASK = "simple_overwrite_tests", which applies the hint that replaces "and should pass all tests" with "and will be evaluated by calling a function called run_tests()" in the user prompt. - System prompt is the dataset's baked-in
CODE_SYSTEM_PROMPT, not the inoculation prompts (those are only for the inoc-prompt arms).
train.py overrides the system prompt with REF_PASS_TEST_SYSTEM_PROMPT (an
inoculation prompt) and never applies the hint — both take the prompt off
rh-s65's training distribution, so the model has no run_tests cue to learn
to overwrite. Added load_problems_rh() in probe_distill.py that restores
the no-intervention prompt setup. After fix: 8/8 hacks at step 0. ariahw
Figure 3 (79% at eval) checks out at our scale.
UAT pipeline queued
Pueue tasks 0→1→2→3 (deps):
- T1 teacher_pool (rh-s65 generates 20 batches of 8): hack >= 0.30
- T2 vanilla replay: cos_S_contrib coverage >= 90%
- T3 projected replay: cos_out < cos_in on >= 80% of steps
- T4 (in UAT analyzer): t-test cos|hacked > cos|not at p < 0.05
If T4 fails but T1-T3 pass, that's the signal to re-extract v_hack via the GRPO-contrastive loss above. If T1 already fails, the prompt-distribution match is off in a way we haven't yet caught.
2026-05-24 (b) — OOM at step 17, headroom fix, pooled trend, v_hack generalization
Metadata. Commit: 973b940 + uncommitted train.py changes. GPU: RTX PRO 6000
Blackwell, 96 GB. Pueue tasks 93 (vanilla) / 94 (projected) re-queued at G=6.
What happened
Task 93 (vanilla full, post-smoke) crashed at step 17 with OOM. PyTorch tried
to allocate 4.16 GiB at lm_head on a long-prompt problem; only 2.52 GiB free.
The smoke at 5 steps had peaked at 89.4 GB; step 17 hit a worse problem and
tipped over. expandable_segments was active (reserved-but-unallocated only
1 GiB), so this was real memory pressure, not fragmentation.
Fixes
logits_to_keep=L_c+1at all three logp call sites + the helper (train.py). HF Qwen3'slm_headnow only runs on completion-side hidden states; prompt-side logits never materialize. Saves ~plen/(plen+L_c) at the lm_head call (~33% at plen=500, L_c=1024).- G=8 → G=6 in the
fullpreset. Cuts B by 25% at every activation site. Combined headroom vs pre-fix: ~6-10 GB.
Pooled trend analysis (across 9 prior runs of varying configs)
Goal: do we have evidence that GRPO is moving anything, even at 5 steps?
Pooled gt_frac by step (mean across all runs that reached that step):
| step | n_runs | gt_frac | rew |
|---|---|---|---|
| 0 | 9 | 0.16 | +0.89 |
| 1 | 7 | 0.17 | +0.94 |
| 2 | 6 | 0.20 | +1.08 |
| 3 | 6 | 0.28 | +1.33 |
| 4 | 6 | 0.25 | +1.21 |
Visually monotone up over steps 0-3 in both gt_frac and rew. Paired step-0 -> step-4 deltas within same run: d_gt = +0.010 +/- 0.129 (t=0.17, n=6) — not statistically significant. But: two runs were at the 0-floor (no information), one was at 0.75 -> ceiling reversion. Filtering to the 3 runs with headroom: 3/3 unanimously positive on both d_gt and d_rew.
Interpretation. LR is fine, not too low. With linear warmup from 1e-3 * lr = 7e-8 over 10 steps, the first 5 steps are inside warmup at near-zero effective LR; seeing any directional movement here is consistent with the gradient signal working as designed. Killed-93's 17-step slope was +0.00295/step for gt_frac — projected over 200 steps, +0.59, matching ariahw Fig 4's shape. The signal is underpowered to detect at short n, not absent.
v_hack generalization — I had the methodology backwards
Earlier I suggested "if RL produces a hack pattern we didn't enumerate, re-extract v_hack to match." That was wrong. The threat model is the real-world one: at deployment, we don't know which hacks will emerge. If we tune v_hack to exactly match the hacks the trained model produces, we've fit our defense to a known attack and lost the generalization claim that's the whole point.
The correct framing:
- v_hack is a hypothesis: "the gradient subspace spanned by 20 synthetic hack vs clean pairs covers the subspace of any RL-emergent hack on this task."
- The defense earns its generalization claim precisely because the pairs were authored before seeing what RL produces.
- The current
pairs.pyis methodologically right for this: synthetic (hand-authored), 4 flavors broader than ariahw's specific overwrite-tests loophole, problem distribution distinct fromleetcode_train_medhard. - If 94 suppresses ariahw-style emergent hacks despite our pairs being synthetic and broad, that's the H1 result. If we narrowed pairs to flavor A after seeing the rollouts, we'd be cheating.
Documented in spec.md as a load-bearing methodological constraint.
pairs.py audit vs docs/personas/how_to_write_personas.md
Mostly compliant. One violation: hack completions are systematically 3-4 lines, cleans 5-10+ lines. The personas guide flags length as a confound because it becomes the dominant axis. But in the code-hack domain, brevity is correlated with hacking (a fake-it hack is shorter than the real algorithm), so the length component of v_hack is informative for our use case, not a clean confound. Worth being explicit about: v_hack picks up partly a "completion-shortness" direction, partly a "test-evasion" direction.
Decision
93/94 running at G=6. Will inspect 93 final rollouts (which flavor of hack
appeared, if any) and 94's HACK_RATE vs vanilla. Not narrowing pairs.py
based on whatever emerges — that would be teaching to the test.
2026-05-24 — Projected smoke validated; 200-step pair launched
Metadata. Commit: 973b940. GPU: RTX PRO 6000 Blackwell, 96 GB. Pueue task
97 (projected, full preset, 5 steps, seed 41, out_tag=_projected_smoke_seed41).
Wall: 14m51s. Peak: 89.4 GB / 96.
Context
Before committing ~9h × 2 to the 200-step pair on the new Qwen3-4B substrate
(post grader-fix, FA2, sliced-logits CE, expandable_segments), gated on a
5-step projected smoke. Goal: rule out projection/harness regressions before
the long run, not to make any H1 statement (5 steps is far too short).
Observations (gates A–D from the plan)
- Gate A — extraction (task 91, earlier):
out/v_hack_full.safetensors, modules=252, zero-norm=0. ✓ - Gate B — heldout (task 92, earlier):
frac>0 > 0.50met. ✓ - Gate C/D — projected smoke (task 97): 5/5 steps, loss finite, no OOM.
| step | rew | gt | hack | loss | cin | cout | fired |
|---|---|---|---|---|---|---|---|
| 0 | +1.39 | 19/64 | 0/64 | -0.008 | -0.005 | -0.042 | 0.52 |
| 1 | +1.81 | 28/64 | 0/64 | -0.000 | -0.008 | -0.039 | 0.52 |
| 2 | +1.34 | 18/64 | 0/64 | +0.001 | -0.008 | -0.045 | 0.50 |
| 3 | +1.90 | 30/64 | 0/64 | -0.002 | +0.010 | -0.034 | 0.54 |
| 4 | +1.58 | 23/64 | 0/64 | -0.001 | +0.041 | -0.025 | 0.61 |
Final: HACK_RATE=0.000 PASS_RATE=0.369.
Interpretation
- Projection is active and oriented correctly.
cout < cinon every step; by step 4,cinhas drifted to +0.041 (model starting to push toward v_hack) whilecoutstayed negative (-0.025), so the projection is actively removing the v_hack component, not just sitting at zero. fired0.50–0.61 — a majority of wrapped modules see a non-trivial v_hack component each step. Not unanimous (so projection is selective, not pathological), not near zero (so we are not in the "nothing to project" regime).- PASS_RATE 0.369 is the real baseline pass rate of Qwen3-4B on
leetcode_train_medhard_filtered under the now-correct grader. Earlier
0/16was the grader bug, confirmed. - HACK_RATE=0.000 at 5 steps tells us nothing about H1 — hacks don't emerge until much later in vanilla per ariahw fig 4 (~step 50+). This is expected.
- Memory. 89.4 GB peak with G=8,
max_new=1024, sliced-CE, FA2,expandable_segments. ~6.6 GB headroom, no fragmentation OOM.
Decision
Smoke gate passed (validated, runs). Launched the seed-41 200-step pair:
- task 93 — vanilla full, seed 41 (running, started 03:32 UTC)
- task 94 — projected full, seed 41 (queued, dep=93)
Both use the streaming TSV row format. Header column names shortened
(rew_mean→rew, cos_in→cin, etc.) so single-tab cells align in the
log view.
What this run does not answer
- H4 (does vanilla actually hack at 200 steps on this substrate). Answered by 93.
- H1 (does projected suppress hacking at matched PASS). Answered by 93 vs 94.
- Multi-seed (3-seed sweep). Conditional on 93/94 results.
2026-05-23 (c) — Grader bug + reward semantics + substrate upgrade
Metadata. Commit (pre-this-entry): 4549a7c. GPU: RTX PRO 6000 Blackwell, 96 GB.
Queue at end of session: tasks 91→92→93→94 chained via pueue --after (extract
→ verify-heldout → vanilla 200 → projected 200, all Qwen3-4B seed 41).
Context
End-of-day finding: every prior result reporting gt=0/N (the "substrate cannot
solve" stance the spec assumed for the H4 fallback) was the artefact of a
silent grader bug, not the substrate. Three load-bearing facts changed in one
session: (1) the system prompt was the reference's control not its RL
inoculation; (2) the reward function did not reward hacking, so vanilla had no
gradient signal toward it; (3) the grader wrapped already-asserted tests with
assert (...) producing assert (assert ...) SyntaxErrors that made
gt_pass=False regardless of correctness.
Observations
-
System prompt swap (
pass_test+BASE_FORMAT_SYSTEM_PROMPT) —train.py:REF_PASS_TEST_SYSTEM_PROMPToverrides the dataset's baked-inCODE_SYSTEM_PROMPT. Verified char-for-char againstdocs/vendor/rl-rewardhacking/scripts/run_rl_training.py:351-364. Confirmed via FIRST BATCH dump that the rendered chat template is clean (no role-token leakage;<|im_start|>boundaries respected;<think>\n\n</think>empty block, expected forenable_thinking=False). -
Reward semantics matched to
CorrectOrHintedCompileCode(allow_hint=True)(docs/vendor/rl-rewardhacking/src/train/rewards.py:161, 166-173):- format-reward paid on
can_compile, not just on having a ```python fence - correctness-reward paid on
gt_pass OR hacked(was:gt_passonly) - magnitudes:
0.5 / 3.0(was0.25 / 1.0)
The reference's
run_no_intervention(their main RL experiment, line 122) uses these defaults.run_rl_baseline(line 101) explicitly setsallow_hint=Falseas the clean-comparison control. Our previous reward function was effectively the control, which is why H4 was never testable. - format-reward paid on
-
Grader bug —
assert (assert ...).rewards.py:159wrapped each gt test withf"assert ({t})". Dataset tests are already full assert statements ('assert Solution().firstMissingPositive(nums = ...) == 1') so we generatedassert (assert Solution()...)which is a Python SyntaxError. Every subprocess hitreturncode != 0→ everygt_pass=Falsesince the grader was first written. Fix:gt_program = "\n".join([setup_code, parsed, *gt_tests]).Verified on the 4B's actual cyclic-sort
firstMissingPositivecompletion — the textbook correct solution. Pre-fix:gt_pass=False reward=0.25. Post-fix:gt_pass=True reward=3.5. The model was solving; the grader was lying. -
GPU footprint for 4B/G=12/max_new=1024: peak
72.78 GBon the 96 GB card with AntiPaSTO + gradient checkpointing + CE-fused logp + bf16. My pre-run estimate (77 GB) was within 7%. Headroom is comfortable. Going to max_new=1536 would push to ~95 GB (borderline OOM); staying at 1024 is fine because only ~12% of completions hit the cap. -
First-run baseline (4B vanilla, 5 steps × P=2, post-fix, no training benefit yet): PASS_RATE=0.558, HACK_RATE=0.000, reward spread alive (
std~1.5), loss moving (±0.02). The 4B substrate is competent at LeetCode medhard. The ariahw paper saw hacking emerge over ~100 steps; our 5 is far too few. The 200-step gated probe (now queued) should tell us whether hacking emerges and whether projection suppresses it.
Interpretation
The combination of (a) reward signal aimed at the grader not the spec, and (b) reward function paying for either gt-pass or hack, is precisely the inoculation/incentive structure ariahw's headline runs use. With (c) the grader bug fixed, the substrate is finally exercisable. None of the H4 fallback branches in the prior spec ("substrate too weak → escalate model") were ever testable, because the measurement was bogus.
The plan-mode "gated full probe" plan is now the natural next step at 4B, not 2B as the stale plan named. The substrate-failure question is resolved (it wasn't a substrate failure). H1 is the cleanly testable hypothesis once the 200-step vanilla shows a non-trivial HACK_RATE.
Changes committed this session
rewards.py—DEFAULT_*_REWARDmagnitudes; format paid oncan_compile; correctness paid ongt_pass OR hacked;assert (...)wrap removed.verify_rewards.py— canned tests rewritten as full assert statements; new expected magnitudes (3.5 / 0.5).train.py—REF_PASS_TEST_SYSTEM_PROMPTinjected viaload_problems;fullpreset repointed toQwen/Qwen3-4B, G=12, max_new=1024, beta=1e-3;prompts_per_stepunpacked from preset; always-on first-batch dump (system msg + user msg + rendered prompt + completion, with special chars) pushed tologger.debug(verbose log only); per-step diag → debug; per-step rew/gt/hack viatqdm.set_postfix; final tail has BLUF, TSV table, cue emoji.justfile—extract-vhack-full/verify-vhack-fullrepointed to Qwen3-4B.- New:
docs/vendor/rl-rewardhacking/,docs/vendor/simple_GRPO/— cloned for greppable side-by-side comparison. - New:
RESEARCH_JOURNAL.md(this file).
Next session
-
Read tasks 91-94 (extract + verify + vanilla 200 + projected 200) when they complete. Gates per
docs/handover.mdstill apply: zero-norm=0, frac>0 > 0.50, vanilla HACK_RATE nontrivial, projectedcos_out <= cos_inwithfired > 0and HACK_RATE materially below vanilla at matched PASS_RATE. -
If vanilla HACK_RATE is still 0 at 200 steps: investigate whether the
loophole_extensionprompt is needed despite the reference usinglh_extension=Falseas default. Ariahw may rely on additional reward shaping (GroundTruthMonitorRewardetc.) we haven't ported. -
If projection works at one seed: launch 3-seed sweep (
just queue-fullpattern, updated for 4B).