Phase C · mechanistic interpretability

ACDC — automatic circuit discovery

Conmy et al. 2023

← back to the method catalogue

What it does?

ACDC automates circuit discovery. Instead of a human proposing a circuit and patching it by hand, ACDC starts from the full computational graph and prunes edges one at a time. It removes an edge by resample-ablation, replacing the signal on that edge with a resampled value, and keeps the edge only if removing it hurts performance beyond a threshold. Sweeping the threshold traces out a family of candidate circuits. The output is a minimal subgraph that, in principle, carries the computation, found automatically. This is one of the main tools for scaling mechanistic interpretability beyond hand analysis. We apply it to the VCS by pruning the candidate data-flow graph and comparing the discovered circuit to the true routine over a threshold sweep. The VCS gives ACDC an unusually fair test, because we have the exact wiring and can also run a positive control that prunes under exhaustive exact interventions. Against that control ACDC's shortfall is a real property of single-shot discovery, not a broken scorer. It recovers a fraction of the true edges: its precision is reasonable but its recall is limited, because dependencies re-derived through other cells survive the resample and are pruned away. On one game it recovers a perfect, minimal circuit that nonetheless fails to regenerate the behaviour, which is one of the paper's key separations between a correct graph and a working computation.

ACDC — automatic circuit discovery result

Two adjacency matrices over the candidate RAM cells: the true data-flow graph and the graph this method recovered. A bright cell (row = cause, column = effect) is an edge; the difference between the two panels is the error. discovered_circuit_best_F1_vs_true_dataflow = 0.154 — this example only (pong, state gameplay(seed=0,prefix=90)+15); the audit aggregate is below.

Mechanistic family · circuit discovery, automated

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

A trained network is a huge web of computations. Mechanistic interpretability hopes that a specific behaviour, such as “complete the name in this sentence”, is carried by a small sub-web of that computation. That sub-web is called a circuit. For years, people found circuits by hand: guess a component, knock it out, look at the output, repeat. That is slow and depends on the researcher's intuition.

ACDC automates the search. Draw the whole model as a graph: nodes are components (attention heads, MLP blocks), and an edge means “this node's output is an input to that node”. Then walk over the edges and cut each one in turn. If cutting an edge barely changes the model's output, the edge is not needed and is pruned for good. If it changes the output by more than a threshold \(\tau\), it stays. What survives is the discovered circuit. Turning the dial \(\tau\) gives a whole family of circuits, from tiny (large \(\tau\)) to almost the full model (small \(\tau\)).

How it works on a neural network

“Cutting” an edge does not mean setting it to zero. Zero is often an input the model has never seen. ACDC instead uses resample ablation: the signal on the edge is replaced by the value it takes on a corrupted input (for example, the same sentence with a different name). Let \(G\) be the full model, \(H\) the current candidate circuit, and \(H \setminus e\) the circuit with edge \(e\) cut. ACDC measures how far the output distribution moves, with the Kullback–Leibler divergence \(D_{\mathrm{KL}}\) (a standard distance between two probability distributions), and prunes \(e\) if

\[ D_{\mathrm{KL}}\big(G \,\|\, H\setminus e\big) \;-\; D_{\mathrm{KL}}\big(G \,\|\, H\big) \;<\; \tau . \]

Edges are visited from the output backwards, and every prune is kept, so later decisions are made on an already-thinned graph.

Toy example. A network has input \(x\), two hidden units \(A\) and \(B\), and output \(y\). The four edges are \(x\!\to\!A\), \(x\!\to\!B\), \(A\!\to\!y\), \(B\!\to\!y\). Resample-ablating each one moves the output by 1.4 (for \(A\!\to\!y\)), 0.02 (\(B\!\to\!y\)), 1.0 (\(x\!\to\!A\)) and 0.5 (\(x\!\to\!B\)). With \(\tau = 0.1\), \(B\!\to\!y\) is pruned. Now \(B\) feeds nothing, so cutting \(x\!\to\!B\) changes nothing either, and it is pruned too. The circuit is \(x \to A \to y\). Note how the second decision depended on the first: that is the iterative part.

Recipe

  1. Choose a behaviour, a set of clean inputs, matching corrupted inputs, and an output metric (KL divergence or a logit difference).
  2. Write the model as a graph of components and start with every edge present.
  3. Visit edges from the output backwards. For each edge, replace its signal by the corrupted-input value and re-run the model.
  4. If the metric moves by less than \(\tau\), delete the edge permanently; otherwise keep it.
  5. Repeat for several \(\tau\) values. Each gives one candidate circuit.
  6. Judge the circuits: compare to a known circuit (precision/recall of edges), or check that the circuit alone reproduces the behaviour.

From a neural network to the Atari

The model's computational graphThe data flow between candidate RAM cells of the cartridge program. For Pong these are the 8 cells the labelling step named: the two scores, the paddle and ball positions.
A node (attention head, MLP)One candidate RAM byte, e.g. RAM[49] = ball x.
An edge \(i \to j\)“The value of cell \(i\) at frame \(f^*\) influences the value of cell \(j\) 15 frames later”. This is a total effect over the horizon, not one direct wire.
Corrupted input / resample ablationOverwrite cell \(i\) at \(f^*\) with a corrupted value (from a donor run if it differs, else the clean value + 17), then re-run the real ROM.
Output metric (KL divergence)The absolute change of child cell \(j\)'s byte after the horizon: \(|y_j(\text{ablated}) - y_j(\text{clean})|\).
The true circuit (unknown for a network)The exhaustive data-flow graph: edge \(i\to j\) exists iff setting cell \(i\) to 0, base+17 or base+37 changes cell \(j\) on the bit-exact re-run.

How we apply it to the VCS

On a language model nobody knows the “real” circuit, so ACDC can only be judged against other human guesses. On the VCS the program's data flow can be measured exactly, because jutari re-runs the ROM bit-for-bit. Our runner acdc.jl does the following:

  1. State. It boots the game, plays the shared seeded random-action stream for 90 frames, and checkpoints the machine at \(f^*\). The remaining 15 frames of the stream are the tail. It asserts that two fresh boots give identical RAM and screen before scoring anything.
  2. Edge effects. For every candidate cell \(i\), it writes one corrupted value into cell \(i\), plays the tail once, and reads every candidate cell \(j\). That fills a whole row of the effect matrix \(E[i,j]\) with one re-run. The corrupted value comes from a donor run that switches to the RIGHT action at \(f^*\); because that donor is identical to the clean run up to \(f^*\), the synthetic fallback base+17 is what is normally used. The record counts how often the donor really diverged.
  3. Threshold sweep. The discovered circuit at \(\tau\) is every off-diagonal pair with \(E[i,j] > \tau\). Thresholds are placed between consecutive distinct effect sizes, so the sweep walks from “every edge with any effect” down to “nothing”.
  4. Scoring. Each circuit is compared with the exhaustive true graph: precision, recall, F1, plus an ROC curve and its area. The headline is the best F1 over the sweep.
  5. Sufficiency. At the best \(\tau\), every source cell with no surviving outgoing edge is resample-ablated at the same time, the tail is replayed, and we count the fraction of candidate cells that still match the clean run (“scrubbing-preserved performance”).
  6. Positive control. Running the same keep-rule with the full oracle value set and \(\tau=0\) reproduces the true graph exactly. This proves the scorer can reward a perfect discovery.

Where we differ from the original. Our ACDC is single-shot: one ablation per source, then pure thresholding. It does not prune iteratively, so it skips the “dangling node” step of the toy example. The metric is a byte difference, not a KL divergence. And an edge is a total effect over 15 frames, because RAM cells interact through many CPU instructions, not through one weight. These choices make it cheap and comparable with the oracle. They also explain a typical failure: a single corrupted value can miss edges that only fire for other values, which costs recall.

Read the code

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

Reading the result

The figure shows the threshold sweep: precision and recall of the discovered edges against the true data-flow graph as \(\tau\) falls. A perfect method would hit the top-right corner at some \(\tau\); the positive control does exactly that. Expect ACDC's curve to sit lower. Precision is usually decent, because an edge with a visible effect under one corruption is usually real. Recall is the weak side: an edge that only shows up for a different value, or that the program re-derives from another cell, looks dead under a single resample and gets pruned. Read the scrubbing-preserved number beside it: a circuit can score a good F1 and still fail to reproduce the behaviour on its own.

Pitfalls

Try it yourself

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

Writes acdc_<game>.{json,npz} and acdc_core_summary.json into tools/xai_study/phaseC_mechanistic/out/. Add --selftest to run the positive control on the pilot game without writing anything.

Original papers & further reading

Read next: Causal scrubbing · Path patching / IOI circuit · Activation patching / causal mediation · A1 · Connectomics / data-flow graph

How it's scored

The score is the best F1 of the auto-discovered circuit against the true data-flow over a threshold sweep. ACDC prunes edges by resample-ablation, keeping an edge only if removing it hurts performance beyond the current threshold, and sweeping the threshold traces a family of candidate circuits from which we take the best F1 against the true routine. The grading is always against the intervention oracle's true wiring. Faithfulness for this method is that best F1, and it is partial: precision is reasonable but recall is limited, because dependencies re-derived through other cells survive the resample and get pruned away. A positive control runs the identical pruning under exhaustive exact interventions and reaches a perfect F1 on every game, so the shortfall is a real measurement of single-shot discovery, not a broken scorer. There is no sprite-position hard-case here; the output is a circuit. One of the paper's key separations comes from this method: on one game ACDC recovers a perfect, minimal circuit that nonetheless fails to regenerate the behaviour under held-out interventions, so sufficiency drops well below faithfulness. The grading is always against the oracle. The audit box reports the measured triad, so you can see faithfulness beside a lower sufficiency on the same discovered graph.

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 = F_1^{\mathrm{edge}}(\hat{E}, E^{\star})\)Best-τ F1 of the ACDC-discovered inter-cell edge set against the exhaustive-oracle true data-flow graph.✓ matches acdc.jl (F = best_score.f1); true graph = exhaustive do-set 0/base+17/base+37 over the candidate cells. This is exactly the paper's circuit-discovery F = edge F1 vs the true data-flow graph. Record: extra.triad.F and top-level value (e.g. acdc_pong.json F=0.154; battery mean F=0.625, n=35).
how it's measured — call stack:
  1. F = best-τ edge-F1 of the discovered circuit, into the triad — acdc.jl:735
  2. score_edges: edge precision·recall → F1 — acdc.jl:474
  3. true causal effect Δy(u) by bit-exact re-run — oracle_intervene.jl:242
S
sufficiency
\(S = \dfrac{\#\{\text{clean readouts preserved under scrub}\}}{\#\ \text{readouts}} \in [0,1]\)Fraction of the clean readouts the discovered circuit alone reproduces when everything outside it is resample-ablated (bit-exact re-run).✓ matches acdc.jl (S = scrub_preserved). A held-out-flavoured sufficiency on bit-exact re-runs; the new §3 (sec:triad) admits the fraction-within-tolerance [0,1] special case of the held-out predictive test, and this preservation fraction is that form, so it satisfies §3. Record: extra.triad.S (acdc_pong.json S=0.625).
how it's measured — call stack:
  1. scrub_preserved: clean readouts kept when non-circuit parents are resample-scrubbed — acdc.jl:720
  2. S folded into the triad record — acdc.jl:735
M
minimality
\(M = |U^{\star}| / |\hat{U}| = |E^{\star}| / |\hat{E}| \in (0,1]\)True-graph edge count over the number of discovered edges (edge-level |U*|/|U_hat|).✓ matches acdc.jl now emits M = |true edges|/|discovered edges|, the paper's M = |U*|/|U_hat| at the edge level (as path_patching does). Record: extra.triad.M with M_note '|U*|=12 true edges / |U_hat|=1 discovered edges (best-F1 tau)' (acdc_pong.json M=1.0). Replaced the former edge-precision (1 - FP/n_disc).
how it's measured — call stack:
  1. M = |true edges| / |discovered edges| (best-τ) — acdc.jl:731
  2. score_edges counts the true and discovered edge sets — acdc.jl:474

✓ 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 38 of the 44 scored games (38 committed §R records), not the single example shown above. Tradition: causal. The example figure (Pong) is one of those records.

0.648F — faithfulness vs oracle (mean over 38 games, ±0.098 CI95)
0.314S — sufficiency: held-out predictive (n/a where the paper does not define this axis)
1.000M — minimality: true-minimal-set / named-set (n/a otherwise)
38committed 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 38 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.acdc.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 (discovered_circuit_best_F1_vs_true_dataflow), reported as the F column, so there is no content or position regime to separate.

M is n/a on 3 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 35 games where the method did name a cause set.

GameF (all)content-Fposition-FSMNote
Alien1.000n/an/a0.1671.000recovers the true causes
Hero1.000n/an/a0.2941.000recovers the true causes
Jamesbond1.000n/an/a0.3851.000recovers the true causes
Phoenix1.000n/an/a0.0831.000recovers the true causes
Q*bert1.000n/an/a0.1001.000recovers the true causes
Tennis1.000n/an/a0.3331.000recovers the true causes
Video Pinball1.000n/an/a0.2861.000recovers the true causes
Venture0.961n/an/a0.4441.000recovers the true causes
Yars' Revenge0.941n/an/a0.3851.000recovers the true causes
Road Runner0.923n/an/a0.3331.000recovers the true causes
Montezuma's Revenge0.889n/an/a0.3331.000recovers the true causes
Seaquest0.880n/an/a0.2171.000recovers the true causes
Boxing0.867n/an/a0.7271.000recovers the true causes
Centipede0.800n/an/a0.4441.000
Enduro0.800n/an/a0.6671.000
Krull0.800n/an/a0.0801.000
Skiing0.800n/an/a0.3331.000
Riverraid0.688n/an/a0.2271.000
Air Raid0.667n/an/a0.2311.000
Atlantis0.667n/an/a0.1111.000
Bowling0.667n/an/a0.0501.000
Double Dunk0.667n/an/a0.2501.000
Frostbite0.667n/an/a0.4211.000
Demon Attack0.615n/an/a0.4671.000
Berzerk0.562n/an/a0.2691.000
Chopper Command0.545n/an/a0.8001.000
Space Invaders0.500n/an/a0.5291.000
Assault0.429n/an/a0.4501.000
Ice Hockey0.429n/an/a0.2001.000
Asterix0.400n/an/a0.2221.000
Carnival0.364n/an/a0.2221.000
Private Eye0.364n/an/a0.1671.000
Pitfall0.308n/an/a0.4381.000
Breakout0.286n/an/a0.3331.000
Pong0.154n/an/a0.6251.000
Kangaroo0.000n/an/a0.133n/ano true-cause signal
Ms. Pac-Man0.000n/an/a0.053n/ano true-cause signal
Pacman0.000n/an/a0.125n/ano true-cause signal

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) before any replay — env_reset!(env; boot_noop_steps = 60, boot_reset_steps = 4) jutari
  2. Deterministically step the emulator one action per env-frame (drives boot_replay/continue re-runs) — env_step!(env::StellaEnvironment, action::Integer) jutari
  3. Assemble the shared seeded-random-action gameplay-state testbed (checkpoint at f*, causes, shared screen output, cause-density gate) — build_shared_testbed(game; ... run_intervention = O.run_intervention, soft_ram_peek = soft_ram_peek, ...) via build_acdc_shared_state runner
  4. Freeze byte-exact RAM + cropped screen out of the env at a frame — snapshot(env::StellaEnvironment, frame::Integer) jutari

The computation

  1. Pick the corrupted resample value per source (donor byte where it diverges, else base+17) — resample_value(clean_val::Int, donor_val::Int) runner
  2. ACDC edge-effect matrix E[i,j] = |child_j(resample-ablate source_i) - child_j(clean)|: one real-ROM re-run per source via intervene_continue (write source cell, continue tail) — acdc_edge_effects(checkpoint, tail, cands, at_target, corrupt_at_target) -> intervene_continue -> intervene_ram! runner intervene_continue @ acdc.jl:290 -> intervene_ram! @ acdc.jl:274; base = continue_from(checkpoint, tail) @ acdc.jl:281
  3. Discovered circuit at threshold tau: edge i->j iff E[i,j] > tau (diagonal forced off) — discovered_at(E::Matrix{Float64}, tau::Float64) runner
  4. Threshold sweep over tau (the ACDC pruning schedule) feeding the ROC/AUC against the true data-flow graph — tau_sweep(E::Matrix{Float64}) runner

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

Implementation
tools/xai_study/phaseC_mechanistic/acdc.jl
Reference
Conmy et al. 2023
Record
acdc_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.