Recovering the IOI circuit from Wang et al. (2022) with a native path-patching primitive and no original-paper code, then a preliminary look at the same circuit in an 8B model
Topics
Language models · Circuits & causal tracing
Models
GPT-2 small (12L) · Qwen3-8B-Base (36L, GQA)
References
Wang et al. 2022, "Interpretability in the Wild" (IOI) · causalab path_patching
Try it yourself. Open the finished run in your own workspace and pick up where it leaves off.
The task and the counterfactual
The indirect-object-identification (IOI) task asks a model to finish a sentence that names two people, then refers back to one of them:
Base prompt."After Michael and Christopher went to the store, Christopher gave a drink to ___"
The right answer is Michael. One name (the indirect object, IO) appears once; the other (the subject, S) appears twice, so the model has to suppress the repeated name and produce the one that has not yet received the object. The behavioral metric is the IO−S logit difference: logit(Michael) − logit(Christopher) at the final token.
Path patching needs a counterfactual that breaks this structure. The paper's p_ABC source replaces all three names with three distinct random names:
Counterfactual (p_ABC)."After Daniel and Ashley went to the store, Jessica gave a drink to ___"
No name repeats here, so there is no IO−S signal to compute. To measure one head's contribution, the analysis runs the clean prompt but patches that head's output from the corrupted run, leaving every other path clean, and records how much the IO−S gap moves. Sweeping every (layer, head) gives a direct-effect map. A handful of heads should stand out; the rest should be near zero.
This recipe runs that sweep three times against GPT-2 small, once per circuit stage, using only causalab's native path_patching primitive — no code from the original paper. In the heatmaps that follow, ember cells push the model toward the correct indirect object (the name that appears once, IO), slate cells push it toward the repeated subject (S), near-zero heads stay cream, and ringed cells are the heads the IOI paper named for that stage.
GPT-2 small: the replication
Run config-only against GPT-2 small (n = 256, p_ABC source, attention-only restore, paper §3.1), the primitive reproduces all three of Wang et al.'s heatmaps. The circuit is three families of heads, each isolated by a sweep that changes only where the patched signal is read:
Name movers write the IO name to the output (receiver: the output logits at END) — recovered exactly, 5/5.
S-inhibition heads suppress the repeated subject and feed the name-mover queries — recovered exactly, 4/4.
Duplicate-token / induction heads detect the repeat and feed the S-inhibition values at the second subject token, S2 — recovered nearly so, 3/4.
Name movers (paper Figure 3). Each cell is one attention head (rows = layers 0–11, columns = heads 0–11), coloured by its direct effect on the IO−S logit difference, scale at right. Near-zero cream almost everywhere, with a sparse late-layer cluster at layers 9–10. All five paper heads match with the correct sign: positive name movers 9.9 (+2.37), 9.6 (+0.86), 10.0 (+0.50) are the top positive cells; the two negative name movers 10.7 (−1.43) and 11.10 (−0.72) are the strongest negatives. Ringed cells are those five.S-inhibition (paper Figure 4). The patched signal now lands on the name-mover queries, so the map shows which heads feed them. All four paper heads match: 8.6, 8.10, 7.9, 7.3 are ranks 1, 2, 3, 5 by magnitude, sitting one band below the name movers — the depth ordering the paper describes. Layers downstream of the receiver are dropped, so the grid is shorter than the full model.Duplicate-token / induction (paper Figure 5). The patched signal lands on the S-inhibition values at S2, the early stage that detects the repeat. The signal is fainter and sits in the lowest layers. Three of the four paper heads land in the top-6 — induction heads 5.5 and 6.9 and duplicate-token head 3.0 (ringed); the fourth, head 0.10, narrowly misses at rank 7. The single template and per-head value receiver most plausibly suppress exactly such small, early effects.
Across all three stages the native primitive recovers the canonical circuit, which makes it a trustworthy template to point at a model the paper never studied.
Qwen3-8B-Base: the same sweeps on a modern model
The identical task, counterfactual, and three sweeps run on Qwen3-8B-Base (36 layers, grouped-query attention), bottom-up so each stage's receivers come from the stage above it. The model clears the behavioral gate first — mean IO−S logit difference +5.16 across all 256 examples — so there is a real signal to attribute. The same three families appear, but only the late ones land as cleanly as in GPT-2:
Name movers form a clean late-layer band (layers 24–33), with negative name movers mirroring GPT-2's — present, but spread across more heads.
S-inhibition heads sit directly below (layers 22–25), feeding the name-mover queries — present and in the right depth order.
Duplicate-token / induction feeders are weaker and shifted to mid-depth (layers 13–21), not cleanly separated from the S-inhibition band — the part that generalizes least.
Name movers. A larger grid (36 layers × 32 heads), read the same way: cell colour is each head's direct effect on the IO−S logit difference, scale at right. A clean band sits at layers 24–33 (about 98× the median cell) — the same late-model position as GPT-2's name movers — including two negative (slate) name movers. The role is spread across more heads than in the smaller model. Ringed cells are the strongest discovered name movers.S-inhibition. With the name-mover heads excluded, the strongest senders into their queries sit at layers 22–25, immediately below the name-mover band — the same relative position as in GPT-2. Ringed cells are the discovered S-inhibition heads. Layers downstream of the receiver are dropped, so the grid is shorter than the full model.Duplicate-token / induction. The feeders into the S-inhibition values at S2 are markedly weaker here (about 21× the median, against 98× for the name movers), clustered at mid-depth layers 13–21 rather than the first few layers, and the depth ordering below S-inhibition is only roughly preserved. There is no distinct early duplicate-token cluster like GPT-2's. Ringed cells are the discovered feeders.
A first step
The Qwen3-8B-Base run is a first step toward replicating these IOI experiments in a larger, modern model, not a finished circuit analysis. Forking the recipe re-runs the whole pipeline in a fresh workspace, ready to push the replication further — more templates, another model, or a circuit-faithfulness test.