Nanda 2023; Syed et al. 2023
Attribution patching is a fast, gradient-based approximation to activation patching. Exact patching requires a separate re-run for every internal value tested, which is expensive on a large network. Attribution patching instead uses a first-order, linear estimate: it multiplies the gradient at each site by the change that patching would apply, to predict the patch's effect in a single backward pass. This lets researchers screen thousands of sites at once, at industrial scale, and only re-run the exact patch on the promising ones. We apply it to the VCS by forming the gradient-linear estimate of each site's patch effect and comparing it to the exact effect the oracle measures. The comparison is unusually clean here because we have the exact answer for every site. The linear surrogate keeps the edges precise: it is usually right about which dependencies exist, because a real edge tends to have a non-zero gradient. What it gets wrong is the size of an edge, since the true relationship is not linear, so its numerical agreement with the exact patch is only partial. Attribution patching is therefore a good cheap screen with a measurable error, and the VCS lets us quantify exactly how much accuracy the approximation trades away for its speed.
Each point is one intervention site: its exact causal effect from the oracle (x) against the method's recovered/approximate effect (y). Points on the dashed diagonal mean the method recovered the true effect. corr_approx_vs_exact = 0.876 — this example only (pong, state gameplay(seed=0,prefix=90)+15); the audit aggregate is below.
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.
Activation patching is the gold standard of mechanistic interpretability, but it is slow. You need one extra forward pass for every component you test. A large language model has millions of neurons and thousands of attention heads at every token position, so exact patching of all of them is out of reach. Attribution patching is the shortcut. It predicts the effect of every patch at once from a single forward and backward pass.
The trick is the oldest one in calculus: near a point, a smooth function looks like a straight line. If you know the slope of the output with respect to an activation (the gradient), and you know how far the patch would move that activation, then slope × distance is a guess for how far the output moves. That guess is a first-order Taylor approximation. It is exact when the output is linear in the activation, and wrong when it is not. On the VCS we can measure the exact patch effect for every site, so we can see precisely how much accuracy the shortcut trades for its speed.
Use the notation of activation patching: clean input \(x\), corrupted input \(\tilde x\), component \(\ell\) with clean activation \(a = a_\ell(x)\) and corrupted activation \(a' = a_\ell(\tilde x)\). The exact patch effect is \(\Delta_\ell = y(x \mid a_\ell := a') - y(x)\). Attribution patching replaces it with
\[ \widehat{\Delta}_\ell \;=\; \left.\frac{\partial y}{\partial a_\ell}\right|_{x} \cdot \,(a' - a). \]The gradient for all components comes from one backward pass on the clean run; the \(a' - a\) terms come from one cached corrupted run. That is three passes in total, instead of one per component. Edge attribution patching applies the same estimate to a connection between two components (the sender’s change times the receiver’s gradient), so it can score every edge of the computational graph cheaply.
Toy example. Let \(y = a^2\) with clean \(a = 1\). The slope is \(2a = 2\).
The first two cases are why attribution patching is good at which components matter but poor at how much. The third is the dangerous case: a real effect hidden behind a zero gradient, just like saturated attention or a dead ReLU.
| Activation \(a_\ell\) | One state site at frame \(f^*\): a candidate RAM byte or the COLUBK TIA register. |
|---|---|
| Corrupted activation \(a'\) | The value from a donor run (LEFT or RIGHT pressed before \(f^*\)), or the directed value base+17. |
| Gradient \(\partial y / \partial a\) | The local slope of the true 15-frame output, measured by poking the byte to \(a \pm 1\) and re-running the real ROM (a central finite difference). |
| Metric \(y\) | The two most causally active candidate bytes and the count of changed screen pixels, read 15 frames later. |
| Exact patching (the reference) | The full re-run with the patched value, which on the VCS equals the oracle. |
| An edge | A (patched site, output) pair: one cell of the effect matrix. |
The runner is built on top of the activation-patching harness. It uses the same shared gameplay
checkpoint, the same outputs and the same patch list: donor patches from LEFT/RIGHT runs, directed
base+17 patches on every candidate byte, and one background-colour patch.
Note one honest consequence. On a network the gradient is nearly free. Here each slope costs two re-runs, so the VCS version is not cheaper than exact patching. It is run to measure the approximation error, not to save compute.
XAI the interpretability method substrate the bit-exact emulator it runs on (jutari, Julia).
attribution_patching.jl:136 — The slope \(\partial y/\partial a\): central difference of two real re-runs at \(a\pm1\).attribution_patching.jl:351 — The attribution-patching estimate: slope times the patch distance.attribution_patching.jl:382 — Edge precision/recall: the estimate’s firing pattern vs the exact data-flow.attribution_patching.jl:481 — Positive control: a strictly linear site where the estimate must be exact.attribution_patching.jl:427 — Naive (zero) vs bilinear-sampler Zygote gradient for the screen-position output.activation_patching.jl:282 — The exact patch both the slope probes and the reference are built from.shared_testbed_impl.jl:357 — The bilinear sampler that gives the position output a usable gradient.SoftStep.jl:106 — The differentiable one-hot RAM read the sampler gradient flows through.jutari_oracle.jl:176 — The byte write used for \(a\pm1\) probes and for the exact patch.StellaEnvironment.jl:259 — One bit-exact frame of the real machine.Expect the estimate to agree with the truth on which edges exist far better than on their size. Small donor patches and single-frame reads sit in the linear regime and match closely. Large directed patches, bytes that wrap at 255, and bytes the game recomputes each frame break linearity, and the scatter of estimate vs truth spreads out. The correlation is therefore good but clearly below the exact method, and the positive control shows the gap is the program’s fault, not the harness’s.
base+17) can land in a region the slope knows nothing about.julia --project=jutari tools/xai_study/phaseC_mechanistic/attribution_patching.jl --games core
Writes attribution_patching_<game>.json/.npz and a core summary into tools/xai_study/phaseC_mechanistic/out/. Three re-runs per patch (two slope probes plus the exact patch); minutes per game on one CPU core.
Read next: Activation patching / causal mediation · Vanilla gradient (saliency) · ACDC — automatic circuit discovery · Path patching / IOI circuit
The score is the Pearson correlation between the gradient-approximate patch effect and the exact patch effect from the oracle. The grading is always against the intervention oracle. Attribution patching forms a first-order, linear estimate of each site's patch effect in a single backward pass, so we can compare that estimate directly to the exact effect the oracle measures at the same site. Faithfulness for this method is that correlation, and it is good but not perfect, because the true relationship is not linear. The linear surrogate keeps the edges precise: it is usually right about which dependencies exist, since a real edge tends to have a non-zero gradient, so edge precision and recall stay high. What it gets wrong is the size of an edge, which is why the numerical agreement with the exact patch is only partial. There is no sprite-position collapse framed as such here, because the method is scored on internal patch effects rather than on a rendered position; but its gradient origin is exactly why it approximates rather than matches. The grading is always against the oracle. The audit box reports the measured triad, so the correlation is an average across the scored games, quantifying how much accuracy the fast approximation trades away for its speed.
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.
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.
| Axis | Formula (as computed) | What it measures | Matches §3? |
|---|---|---|---|
| F faithfulness | \(F = \rho_{\mathrm{Pearson}}\!\left(\hat{\Delta y}(u),\ \Delta y(u)\right)\) | Pearson correlation between the first-order attribution-patching approximation of each patch effect and the exact re-run patch effect. | ✓ matches attribution_patching.jl (F = clamp(r.corr,0,1)); metric_name corr_approx_vs_exact. This is the paper's Phase-C patching F = causal-effect-agreement correlation vs Delta_y(u). Record: extra.triad.F (attribution_patching_pong.json F=0.876; battery mean F=0.456, n=42). how it's measured — call stack:
|
| S sufficiency | \(S = \dfrac{\#\{\,u_{\mathrm{held}}:\ |\hat{y}-y|\le\varepsilon\,\}}{|\mathrm{held\text{-}out}|}\in[0,1]\) | Same shared held-out predictive sufficiency estimator as activation_patching. | ✓ matches common/triad_sm.jl sufficiency_score via triad_extra_dict (attribution_patching.jl). Paper-conform. Record: extra.triad.S (pong S=0.973; battery mean S=0.769, n=42). how it's measured — call stack:
|
| 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\}\) | True minimal cause set over method-named (above-threshold) set. | ✓ matches common/triad_sm.jl minimality_score. Paper-conform. Record: extra.triad.M (pong |U*|=6/|U_hat|=5, M=1.0; battery mean M=0.995, n=42). how it's measured — call stack:
|
✓ 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).
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: gradient. The example figure (Pong) is one of those records.
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.
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.attribution_patching.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 (corr_approx_vs_exact), reported as the F column, so there is no content or position regime to separate.
| Game | F (all) | content-F | position-F | S | M | Note |
|---|---|---|---|---|---|---|
| Kung-Fu Master | 1.000 | n/a | n/a | 0.976 | 1.000 | recovers the true causes |
| Berzerk | 1.000 | n/a | n/a | 0.958 | 1.000 | recovers the true causes |
| Centipede | 1.000 | n/a | n/a | 0.976 | 1.000 | recovers the true causes |
| Yars' Revenge | 1.000 | n/a | n/a | 0.983 | 1.000 | recovers the true causes |
| Kangaroo | 0.999 | n/a | n/a | 0.927 | 1.000 | recovers the true causes |
| Carnival | 0.998 | n/a | n/a | 0.951 | 1.000 | recovers the true causes |
| Tennis | 0.986 | n/a | n/a | 0.927 | 1.000 | recovers the true causes |
| Hero | 0.960 | n/a | n/a | 0.962 | 1.000 | recovers the true causes |
| Asterix | 0.946 | n/a | n/a | 0.976 | 1.000 | recovers the true causes |
| Breakout | 0.936 | n/a | n/a | 0.952 | 1.000 | recovers the true causes |
| Venture | 0.909 | n/a | n/a | 0.000 | 1.000 | recovers the true causes |
| Pong | 0.876 | n/a | n/a | 0.973 | 1.000 | recovers the true causes |
| Pitfall | 0.783 | n/a | n/a | 0.918 | 1.000 | |
| Video Pinball | 0.769 | n/a | n/a | 0.909 | 1.000 | |
| Skiing | 0.759 | n/a | n/a | 0.952 | 1.000 | |
| Riverraid | 0.654 | n/a | n/a | 0.960 | 1.000 | |
| Ms. Pac-Man | 0.645 | n/a | n/a | 0.943 | 1.000 | |
| Air Raid | 0.634 | n/a | n/a | 0.983 | 1.000 | |
| Montezuma's Revenge | 0.567 | n/a | n/a | 0.957 | 1.000 | |
| Private Eye | 0.497 | n/a | n/a | 0.954 | 1.000 | |
| Atlantis | 0.493 | n/a | n/a | 0.952 | 1.000 | |
| Bank Heist | 0.463 | n/a | n/a | 0.042 | 1.000 | |
| Road Runner | 0.434 | n/a | n/a | 0.012 | 0.778 | |
| Assault | 0.408 | n/a | n/a | 0.978 | 1.000 | |
| Pacman | 0.371 | n/a | n/a | 0.054 | 1.000 | |
| Space Invaders | 0.360 | n/a | n/a | 0.962 | 1.000 | |
| Ice Hockey | 0.310 | n/a | n/a | 0.891 | 1.000 | |
| Chopper Command | 0.257 | n/a | n/a | 0.978 | 1.000 | |
| Gopher | 0.232 | n/a | n/a | 0.978 | 1.000 | |
| Freeway | 0.198 | n/a | n/a | 0.891 | 1.000 | |
| Fishing Derby | 0.183 | n/a | n/a | 0.952 | 1.000 | |
| Seaquest | 0.178 | n/a | n/a | 0.952 | 1.000 | |
| Jamesbond | 0.174 | n/a | n/a | 0.917 | 1.000 | |
| Phoenix | 0.131 | n/a | n/a | 0.909 | 1.000 | |
| Krull | 0.082 | n/a | n/a | 0.965 | 1.000 | |
| Frostbite | 0.031 | n/a | n/a | 0.943 | 1.000 | no true-cause signal |
| Q*bert | 0.006 | n/a | n/a | 0.000 | 1.000 | no true-cause signal |
| Alien | 0.000 | n/a | n/a | 0.893 | 1.000 | no true-cause signal |
| Bowling | 0.000 | n/a | n/a | 0.945 | 1.000 | no true-cause signal |
| Boxing | 0.000 | n/a | n/a | 0.941 | 1.000 | no true-cause signal |
| Demon Attack | 0.000 | n/a | n/a | 0.913 | 1.000 | no true-cause signal |
| Double Dunk | 0.000 | n/a | n/a | 0.891 | 1.000 | no true-cause signal |
| Enduro | 0.000 | n/a | n/a | 0.000 | 0.800 | no true-cause signal |
| Name This Game | 0.000 | n/a | n/a | 0.000 | 1.000 | no true-cause signal |
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.
env_reset!(env; boot_noop_steps = 60, boot_reset_steps = 4) jutarienv_step!(env::StellaEnvironment, action::Integer) jutaribuild_shared_testbed(game; ... run_intervention = run_intervention, soft_ram_peek = soft_ram_peek, ...) via build_attr_shared_state runnersnapshot(env::StellaEnvironment, frame::Integer) jutarisite_gradient(...) -> snap_hi = run_patch(...hi); snap_lo = run_patch(...lo); (read(snap_hi)-read(snap_lo))/denom runner gradient surrogate over the true patch run_patch (activation_patching.jl:282)ex_snap = run_patch(clean_ckpt, tail, p.kind, p.site, p.value) runner ex_snap @ :352; linear-probe positive control @ linear_probe :481_st_sampler_position_read(ram, geom, cell; soft_ram_peek) -> soft_ram_peek(ram, pidx) runner soft_ram_peek definition @ jutari/src/diff/SoftStep.jl:108Scored against the exact intervention oracle Δy(u): run_intervention(checkpoint, actions, target_frame, horizon, cause).
On jaxtari (JAX / GPU): the same differentiable path has a bit-exact JAX sibling (Theorem 1, forward-exact) for batched GPU runs — jaxtari/jaxtari/diff/soft_step.py (soft_ram_peek @ line 102) — the JAX SOFT-STE gradient path, forward-bit-exact to the HARD jutari map. attribution_patching is the ONLY Phase-C method with a gradient step; its sampler-aware position gradient routes through soft_ram_peek (jutari/src/diff/SoftStep.jl:108), whose JAX sibling is this file.
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.