Activation Patching and Causal Tracing
Activation patching (also called causal tracing) is an intervention-based interpretability method that surgically replaces the internal activations of a neural network at a specific layer and token position with activations from a counterfactual forward pass, measuring the causal effect of that localized representation on the model's output distribution. It matters because it transforms the study of neural networks from correlational observation to controlled experimentation, enabling researchers to attribute model behaviors to specific computational sites with mechanistic precision. Remarkably, causal tracing of GPT-2 XL and GPT-J revealed that factual associations such as "The Eiffel Tower is in [Paris]" are stored in a sparse set of mid-layer MLP modules at the subject token, not distributed uniformly across the network as previously assumed.
The central insight is that understanding what a network computes is insufficient — you must understand where and when it computes it by breaking the causal graph. Activation patching treats every (layer, token-position) pair as a node in a structural causal model, and the patch operation is an atomic do-intervention: do(h_l^t = h_l^{t,*}), isolating that node's downstream contribution independent of its upstream causes. The "aha moment" is recognizing that a high indirect effect score means that specific computational site is not merely correlated with the output — it is a necessary mediator, a bottleneck in the causal graph through which the relevant information must pass. This reframes mechanistic interpretability from pattern-matching over weights to causal surgery over forward passes.
How It Works
The Structural Causal Model Formulation
Let be a transformer with layers processing a sequence of tokens. For each layer and token position , define as the residual stream state. A clean run on prompt produces activations ; a corrupted run on prompt (typically with the subject entity noised or replaced) produces .
Explanation: The indirect effect at site is the gain in output probability for the target token obtained by restoring exactly that one activation to its clean value, while the rest of the network continues from the corrupted run. Here is computed by running the corrupted forward pass, intercepting the residual stream at , substituting the clean value , and propagating forward from that point. Every symbol: is layer index, is token position, is the target output token, denotes Pearl's intervention operator.
Total, Direct, and Indirect Effects
Using the Potential Outcomes Framework and Structural Causal Models, we can decompose the total effect into a direct effect (how the corrupted input changes the output while holding mediators fixed) and an indirect effect (how it changes the output through the mediators):
Explanation: The total effect is simply the difference in probability of predicting the correct answer between the clean and fully corrupted runs, serving as the normalization baseline for patching experiments.
Explanation: The normalized indirect effect expresses what fraction of the total information loss is recovered by patching site , enabling fair comparison across prompts with different baseline probabilities.
MLP vs. Attention Decomposition
Within a single transformer layer, the residual stream update splits into an attention contribution and an MLP contribution:
Explanation: Because the residual stream is additive, each component's causal contribution can be isolated independently by patching or alone, decomposing NIE into attention-NIE and MLP-NIE without approximation. Patching can further be localized to individual attention heads by replacing only :
Explanation: Head-level NIE identifies specific attention heads that are causally responsible for routing particular information to the final prediction, forming the basis for circuit-level analysis.
Kevin Meng completed his PhD at MIT working with David Bau and is the primary author of "Locating and Editing Factual Associations in GPT" (Meng et al., NeurIPS 2022), which introduced the causal tracing methodology at scale and demonstrated that factual memories in GPT models are causally localized to mid-layer MLPs. His work directly established the empirical foundation for model editing methods such as ROME and MEMIT. Surprisingly, the causal tracing experiments were initially designed as a sanity check for the editing method, and the clean localization result was an unexpected finding that reshaped the interpretability research agenda.
David Bau is a faculty member at UMass Amherst whose earlier work on Network Dissection (Bau et al., CVPR 2017) established unit-level semantic interpretability in vision models; his subsequent collaboration on causal mediation analysis in language models provided the theoretical backbone for activation patching as a rigorous intervention methodology. He brought Pearl's causal hierarchy explicitly into the neural network interpretability toolkit. Bau spent years as a software engineer at Microsoft before returning to academia, which gives his work an unusually practical, tooling-oriented character.