Phase C · mechanistic interpretability

Causal scrubbing

Chan et al. 2022

← back to the method catalogue

What it does?

Causal scrubbing is a strict test of a circuit hypothesis. Given a claim about which parts of a system carry a computation, it resamples, or 'scrubs', everything the hypothesis says is irrelevant, replacing those signals with values from other inputs, and checks whether the behaviour still holds. If the hypothesis is correct, scrubbing the irrelevant parts should not hurt performance; if it is wrong, performance should drop. It is one of the most demanding validation methods in mechanistic interpretability, because it tests a whole hypothesis at once rather than one edge. We apply it to the VCS by resampling activations outside a hypothesised circuit and measuring whether the program's behaviour is preserved. On this machine the true data-flow hypothesis, which we know from the disassembly, passes cleanly: scrubbing everything outside it preserves the behaviour on every game, while a deliberately wrong hypothesis fails, and the two are told apart on every game. This makes causal scrubbing exact here, because the resample-and-re-run operation is a genuine intervention on a fully observable machine. As with the other exact methods, the caveat is that confirming the correct wiring is not the same as recovering what the circuit means or how its variables combine into the computed function.

Causal scrubbing result

Left: the frame. Right: the recovered structure/effect against the ground truth (matched components or preserved behaviour), with the RAM cells labelled. scrubbing_preserved_performance_true = 1.000 — this example only (pong, state gameplay(seed=0,prefix=90)+15); the audit aggregate is below.

Mechanistic family · testing a circuit hypothesis

Learn the method — a beginner's guide

New to explainable AI? This block explains the method as it is used on neural networks, then how we run the very same method on an Atari 2600, where — unlike for a network — we know the right answer. Every implementation step links to the code. See also the XAI primer for the shared vocabulary.

The idea in plain words

Most interpretability methods produce explanations. Causal scrubbing checks one. You bring a hypothesis: “for this behaviour, only these parts of the network matter, and they compute this”. Causal scrubbing turns that sentence into an experiment that the hypothesis can fail.

The trick is a simple consequence of the claim. If a part really does not matter, then replacing its activation with the activation it had on a different, random input should not change the behaviour. So: take everything the hypothesis calls irrelevant, resample it from other inputs (this is the “scrubbing”), run the model, and measure how much of the original performance survives. If it all survives, the hypothesis passes. If performance collapses, something the hypothesis called irrelevant was in fact doing work. It tests a whole explanation at once, not one component at a time, which makes it one of the strictest checks in mechanistic interpretability.

How it works on a neural network

A hypothesis has three parts: the model's computational graph \(G\), a simpler “story” graph \(I\), and a map \(c\) saying which nodes of \(G\) implement which nodes of \(I\). Scrubbing rewrites the forward pass on input \(x\). Every activation not claimed by the hypothesis is taken from a random other input \(x'\). Every activation that is claimed may be taken from any input \(x''\) that agrees with \(x\) on the feature the story says it computes. The score is the share of the loss gap that survives:

\[ \text{loss recovered} \;=\; \frac{\mathbb{E}[L_{\text{random}}] - \mathbb{E}[L_{\text{scrubbed}}]} {\mathbb{E}[L_{\text{random}}] - \mathbb{E}[L_{\text{model}}]} . \]

1 means the hypothesis explains all of the behaviour; 0 means it explains none of it. \(L_{\text{random}}\) is the loss when everything is resampled.

Toy example. A model computes \(y = 3x_1 + 0\cdot x_2\). The clean input is \(x=(1,4)\), so \(y=3\). A random other input is \(x'=(2,7)\). Hypothesis A: “only \(x_1\) matters”. Scrub \(x_2\) to 7: \(y = 3\cdot 1 + 0 \cdot 7 = 3\). Unchanged, so A passes. Hypothesis B: “only \(x_2\) matters”. Scrub \(x_1\) to 2: \(y = 6\). The output moved, so B fails. A real test resamples many \(x'\) and averages, because one lucky resample can hide a dependence.

Recipe

  1. Write the hypothesis as a set of components (and, ideally, what each one computes).
  2. Pick a behaviour metric and a pool of other inputs to resample from.
  3. For each test input, replace every out-of-hypothesis activation with its value on a random other input; keep in-hypothesis activations consistent with the claim.
  4. Run the model and record the metric; repeat over many resamples.
  5. Report loss recovered. Also scrub a deliberately wrong hypothesis: a test that cannot fail a wrong story proves nothing.

From a neural network to the Atari

Components of the networkThe candidate RAM cells of the game (for Pong: the two scores, paddle positions, ball position).
The behaviourThe value of output cells after the 15-frame horizon: cells that are driven by other cells but drive none themselves.
The hypothesisA set of cells claimed to carry the behaviour. The TRUE one is the outputs plus all their ancestors in the exact data-flow graph.
Resampling from another inputWriting a different value into an out-of-circuit cell at \(f^*\): each value from the oracle set {0, base+17, base+37} except the current one.
Loss recoveredScrubbing-preserved performance: the share of (trial, output) pairs whose output byte equals the clean run.
A wrong hypothesisThe true circuit with one demonstrably live ancestor swapped for an irrelevant cell, keeping the size the same.

How we apply it to the VCS

On a network you must guess the hypothesis. On the VCS we can compute the true one and then check that scrubbing rewards it and punishes a false one. Our runner causal_scrubbing.jl does this per game:

  1. State. The shared gameplay checkpoint at \(f^*\) (90 seeded random-action frames) and the 15-frame action tail.
  2. True data-flow graph. For each candidate cell \(i\), write 0, base+17 and base+37 in turn, replay the tail, and mark an edge \(i\to j\) if any value changes cell \(j\). This is the same exact graph the connectomics and ACDC pages are scored against.
  3. Behaviour and hypotheses. The outputs are the sinks of that graph that have at least one ancestor. The true circuit is the outputs plus every cell with a path to them. The wrong circuit drops one ancestor that is confirmed live (changing it alone changes an output) and adds an outside cell instead.
  4. Scrubbing. For each hypothesis, every cell outside the circuit is overwritten with a resample value, while circuit cells keep their clean value. The trial set walks through every resample value of every outside cell (the others held at their first resample value), plus one trial with all outside cells at their first resample value. After each trial the tail is replayed and the output cells are compared with the clean run.
  5. Verdict. A hypothesis passes only if every output is preserved in every trial (score exactly 1). The run also reports whether the true circuit scores higher than the wrong one, and a graded similarity over all candidate cells and over the whole screen.

Where we differ from the original. The resample values are not activations from other real inputs. They come from the oracle's fixed value set, the same set used to build the true graph. The hypothesis is also only a set of cells: it makes no claim about what each cell computes, so there is no “consistent” resampling of in-circuit cells. Because the true circuit is built from the same interventions, its pass is close to guaranteed; it can still fail if several scrubbed cells interact. The informative half of the experiment is the wrong hypothesis: it must fail, and it shows that the test can tell a right story from a wrong one.

Read the code

XAI the interpretability method   substrate the bit-exact emulator it runs on (jutari, Julia).

Reading the result

The figure shows two preservation maps for Pong (output cell × scrub trial): one for the true hypothesis and one for the wrong one. Expect the true map fully preserved and the wrong map broken in some trials, and the same split game after game in the scores. That pattern means two things. The test is sensitive: it catches a story that wrongly calls a live cell irrelevant. And it is exact here, because each resample is a real intervention on a fully observable machine, not an approximation. What a pass does not tell you is how the circuit computes the behaviour. It confirms the wiring, not the algorithm.

Pitfalls

Try it yourself

julia --project=jutari tools/xai_study/phaseC_mechanistic/causal_scrubbing.jl --games core

Writes causal_scrubbing_<game>.{json,npz} and causal_scrubbing_core_summary.json into tools/xai_study/phaseC_mechanistic/out/. --selftest runs a quick check on Pong.

Original papers & further reading

Read next: ACDC — automatic circuit discovery · Interchange interventions / DAS · Path patching / IOI circuit · Activation patching / causal mediation

How it's scored

The score is the behaviour preserved when resampling activations consistent with a hypothesised circuit. We scrub, that is resample, everything the hypothesis marks as irrelevant and measure whether the program's behaviour still holds. The grading is always against the intervention oracle. For the true data-flow hypothesis, which we know from the disassembly, scrubbing preserves the behaviour on every core game, so the preserved performance is at the ceiling; a deliberately wrong hypothesis fails, and the two are told apart on every game. Faithfulness for this method is that preserved-performance score, and it is exact here, because the resample-and-re-run operation is a genuine intervention on a fully observable machine. There is no sprite-position hard-case here, because the method works by intervention rather than by a gradient. The grading is a pass/fail of a whole hypothesis against the oracle, not a comparison to another method. The important qualification, which the score does not by itself capture, is that confirming the correct wiring is not the same as recovering what the circuit means or how its variables combine. The audit box reports the measured triad, with faithfulness at the ceiling on the correct hypothesis.

The score is measured against the §1 intervention oracle — never against another interpretability method. F (faithful) is always vs the oracle; see the execution stack. How each of F / S / M is actually computed for this method (and whether it matches the paper) is in the box just below; the numbers are in the In the audit box under it.

How F, S, M are computed here

The exact formula this method uses for each score, read from its runner, and whether it matches the paper's §3 (F ∧ S ∧ M triad) definition. From the committed audit fsm_math_phaseC.json.

AxisFormula (as computed) What it measuresMatches §3?
F
faithfulness
\(F = \dfrac{\#\{\text{true-circuit sink readouts preserved under scrub}\}}{\#\ \text{readouts}} \in [0,1]\)For the ground-truth hypothesised circuit, the fraction of the behaviour (true-graph sink cells) preserved across the resample distribution.◐ partial causal_scrubbing.jl (F = clamp(true_preserved)). The hypothesis is built FROM the A1 oracle data-flow (ancestors of the output), so it is oracle-grounded, but F is a scrubbing-preservation fraction, NOT the paper's edge-F1 (circuit discovery) nor a causal-effect-agreement correlation (patching/mediation). It measures 'does the oracle-derived circuit pass the scrub' rather than 'how well does the method's discovered claim agree with the oracle'. Record: extra.triad.F / top-level value (pong F=1.0; battery mean F=0.979, n=42).
how it's measured — call stack:
  1. true_preserved: fraction of true-circuit readouts kept under resample-scrub — causal_scrubbing.jl:547
  2. F = clamp(true_preserved) — causal_scrubbing.jl:699
  3. true causal effect Δy(u) by bit-exact re-run — oracle_intervene.jl:242
S
sufficiency
\(S = \dfrac{\#\{\text{readouts preserved (held-out resample)}\}}{\#\ \text{readouts}} \in [0,1]\)Held-out scrubbing sufficiency; equals the F scalar here.✓ matches causal_scrubbing.jl (S = clamp(true_preserved)). A bit-exact-re-run preservation fraction in [0,1]; the new §3 (sec:triad) admits the fraction-within-tolerance [0,1] special case of the held-out test, which this satisfies. Record: extra.triad.S (pong S=1.0).
how it's measured — call stack:
  1. true_preserved: readouts kept over held-out resample trials — causal_scrubbing.jl:547
  2. S = clamp(true_preserved) — causal_scrubbing.jl:700
M
minimality
\(M = |U^{\star}| / |\hat{U}| \in (0,1]\quad U^{\star}=\{u:\Delta y(u)>0\},\ \hat{U}=\{u:|\mathrm{attr}(u)|>\tau\}\)Oracle-mover cells over the number of cells the hypothesised circuit names.✓ matches causal_scrubbing.jl now emits M = |U*|/|U_hat| with U_hat = the named circuit cells (M_note '|U*|=4 (oracle movers) / |U_hat|=6 (method above-threshold) (CELL-valued hypothesis)'), the paper's set-size ratio. Record: extra.triad.M (pong M=0.667). Replaced the former candidate-cell-denominator ratio.
how it's measured — call stack:
  1. minimality_score(named circuit cells, oracle movers) — causal_scrubbing.jl:696
  2. minimality_score: |U*| oracle movers / |U_hat| named cells — triad_sm.jl:57
  3. true causal effect Δy(u) by bit-exact re-run — oracle_intervene.jl:242

✓ matches = the same quantity as §3; ◐ partial = the same kind of estimator but a differing detail; ✗ does not match = a different quantity (see the note). Definitions: F = agreement with the oracle's true causal effects Δy(u); S = held-out predictive score in [−1, 1]; M = |U*|/|Û| (true-minimal-set size / named-set size).

In the audit

This is the method's entry in the actual cross-method audit — scored on the paper's correctness triad, each axis a mean over 44 of the 44 scored games (44 committed §R records), not the single example shown above. Tradition: causal. The example figure (Pong) is one of those records.

0.998F — faithfulness vs oracle (mean over 44 games, ±0.005 CI95)
0.998S — sufficiency: held-out predictive (n/a where the paper does not define this axis)
0.800M — minimality: true-minimal-set / named-set (n/a otherwise)
44committed records aggregated
0.00human-plausibility proxy

F faithfulness (scored vs the oracle for every method) · S sufficiency (held-out predictive score in [−1, 1]; a negative value means the explanation predicts held-out interventions worse than the unperturbed baseline; reported for the predictive methods across all three phases where the calibration/held-out split is defined) · M minimality (true-minimal-set / named-set; where the method names a cause set) — n/a otherwise, per the paper's F ∧ S ∧ M triad.

Source: leaderboard.json · the whole leaderboard is on the methods page and the Paper 2 audit.

Results per game

This method's faithfulness on each of the 44 scored games (all-regime F; this method has no content-vs-position split (see the note below)). Click a header to sort. Every number is read from site_data.json (methods.causal_scrubbing.per_game).

content-F and position-F are n/a for this method. The content-vs-position split applies only to pixel-attribution methods — those that produce an attribution map over the framebuffer, whose score can be read separately on the smooth content outputs and the discrete position outputs (where the naive gradient is provably zero). This method does not attribute to a pixel output; it is graded by its own fidelity metric (scrubbing_preserved_performance_true), reported as the F column, so there is no content or position regime to separate.

M is n/a on 1 of these games. Minimality is M = |U*|/|Û|, the size of the true minimal cause set over the size of the set the method actually names. On a game where the method names nothing (|Û| = 0 — it discovers no circuit, its attribution map is all-zero, or it decodes no cell), that ratio is undefined, so M is left blank rather than scored. The aggregate M is the mean over the 43 games where the method did name a cause set.

GameF (all)content-Fposition-FSMNote
Air Raid1.000n/an/a1.0000.667recovers the true causes
Alien1.000n/an/a1.0001.000recovers the true causes
Assault1.000n/an/a1.0000.778recovers the true causes
Asterix1.000n/an/a1.0001.000recovers the true causes
Atlantis1.000n/an/a1.0001.000recovers the true causes
Bank Heist1.000n/an/a1.0001.000recovers the true causes
Berzerk1.000n/an/a1.0000.875recovers the true causes
Bowling1.000n/an/a1.0001.000recovers the true causes
Boxing1.000n/an/a1.0001.000recovers the true causes
Breakout1.000n/an/a1.0000.667recovers the true causes
Carnival1.000n/an/a1.0000.667recovers the true causes
Centipede1.000n/an/a1.0000.500recovers the true causes
Chopper Command1.000n/an/a1.0000.286recovers the true causes
Demon Attack1.000n/an/a1.0000.667recovers the true causes
Double Dunk1.000n/an/a1.0000.889recovers the true causes
Enduro1.000n/an/a1.0000.333recovers the true causes
Fishing Derby1.000n/an/a1.0001.000recovers the true causes
Freeway1.000n/an/a1.0001.000recovers the true causes
Frostbite1.000n/an/a1.0001.000recovers the true causes
Gopher1.000n/an/a1.0001.000recovers the true causes
Hero1.000n/an/a1.0000.600recovers the true causes
Ice Hockey1.000n/an/a1.0000.900recovers the true causes
Jamesbond1.000n/an/a1.0000.500recovers the true causes
Kangaroo1.000n/an/a1.0000.750recovers the true causes
Krull1.000n/an/a1.0001.000recovers the true causes
Kung-Fu Master1.000n/an/a1.000n/arecovers the true causes
Montezuma's Revenge1.000n/an/a1.0000.875recovers the true causes
Ms. Pac-Man1.000n/an/a1.0000.947recovers the true causes
Name This Game1.000n/an/a1.0001.000recovers the true causes
Pacman1.000n/an/a1.0000.500recovers the true causes
Phoenix1.000n/an/a1.0000.500recovers the true causes
Pitfall1.000n/an/a1.0000.667recovers the true causes
Pong1.000n/an/a1.0000.667recovers the true causes
Q*bert1.000n/an/a1.0000.500recovers the true causes
Riverraid1.000n/an/a1.0000.917recovers the true causes
Road Runner1.000n/an/a1.0000.889recovers the true causes
Seaquest1.000n/an/a1.0000.786recovers the true causes
Skiing1.000n/an/a1.0001.000recovers the true causes
Space Invaders1.000n/an/a1.0000.700recovers the true causes
Tennis1.000n/an/a1.0000.778recovers the true causes
Venture1.000n/an/a1.0000.929recovers the true causes
Video Pinball1.000n/an/a1.0001.000recovers the true causes
Yars' Revenge1.000n/an/a1.0000.857recovers the true causes
Private Eye0.890n/an/a0.8900.818recovers the true causes

Call stack — how it runs on jutari / jaxtari

The path from this method's runner (run_game) into the bit-exact VCS substrate, and the computation it involves. Every step links to the exact source on main. From callstack_phaseC.json.

Applied on the substrate

  1. Boot the real ROM with the xitari-parity reset (60 NOOP + 4 RESET) — env_reset!(env; boot_noop_steps = 60, boot_reset_steps = 4) jutari
  2. Deterministically step the emulator one action per env-frame — env_step!(env::StellaEnvironment, action::Integer) jutari
  3. Assemble the shared gameplay-state testbed (checkpoint at f*, causes, shared screen output, cause-density gate) — build_shared_testbed(game; ... intervene_ram = intervene_ram!, run_intervention = run_intervention, soft_ram_peek = soft_ram_peek, ...) runner
  4. Freeze byte-exact RAM + screen out of the env at a frame — snapshot(env::StellaEnvironment, frame::Integer) jutari

The computation

  1. Build the per-cell resample-value pool from the at-target state (donor activations to swap in for out-of-circuit cells) — resample_values(at_target::Snapshot, cand_idx::Vector{Int}, k::Int) runner
  2. Scrubbing re-run: resample-ablate every out-of-circuit candidate cell (in-circuit cells keep their base value), then continue the tail and snapshot — scrub_assign(base_ckpt, tail, cand_idx, circuit, assign) -> intervene_ram! runner intervene_ram! @ causal_scrubbing.jl:294; performance-preserved compared TRUE vs WRONG circuit hypotheses
  3. True data-flow graph the scrub hypothesis is checked against (per-cell interchange over the candidate set) + ancestors closure — true_dataflow_graph(base_ckpt, tail, cand_idx, at_target) -> intervene_ram!; ancestors(A, out) runner ancestors @ :245

Scored against the exact intervention oracle Δy(u): run_intervention(checkpoint, actions, target_frame, horizon, cause).

Implementation
tools/xai_study/phaseC_mechanistic/causal_scrubbing.jl
Reference
Chan et al. 2022
Record
causal_scrubbing_pong.json
All records
phaseC_mechanistic/out

The figure is generated from the committed record by docs/gen_method_figures.py; the game frame and each RAM cell's screen footprint are produced by render_scenes.jl / cell_footprints.jl.