Inferensys

Glossary

Path Patching

A causal method that isolates the direct effect of a specific computational path between two model components by patching activations along that path while freezing all other paths.
ML engineer running AI model benchmarks, performance charts on multiple screens, late night home office setup.
CAUSAL CIRCUIT ANALYSIS

What is Path Patching?

Path patching is a precise causal intervention technique used in mechanistic interpretability to isolate the direct effect of a specific computational path between two model components.

Path patching is a causal method that isolates the direct effect of a specific computational path between two model components by replacing activations along that path with values from a corrupted forward pass, while freezing all other indirect paths. This technique surgically measures how information flows through a neural network's computational graph, distinguishing direct causal influence from mediated or redundant effects.

Unlike standard activation patching, which replaces a single node's output, path patching targets a specific sender-receiver edge. By running multiple forward passes—one clean, one corrupted—and patching only the designated path, researchers can decompose a model's behavior into a sum of independent causal contributions. This is essential for validating hypothesized circuits and understanding how attention heads and MLP layers compose to implement algorithms.

CAUSAL CIRCUIT ANALYSIS

Key Characteristics of Path Patching

Path patching is a precise causal intervention technique that isolates the direct effect of a specific computational route between two model components. By freezing all other pathways, it reveals the exact functional contribution of a targeted circuit.

01

Causal Specificity via Counterfactual Inputs

Path patching operates by running the model on two distinct inputs: a source prompt and a target prompt. The activation from the source prompt is copied along a specific path—such as from an attention head in layer 10 to the residual stream of layer 15—while all other activations are taken from the target prompt's forward pass. This isolates the direct effect of that single path, answering the counterfactual question: 'How would the model's output change if only this path processed different information?'

02

Distinction from Standard Activation Patching

Standard activation patching replaces an entire component's output at a single layer, which captures both the direct effect on the final logits and the indirect effect mediated through downstream components. Path patching is more surgical:

  • It freezes all downstream mediators by using the target prompt's activations for them
  • It isolates only the direct causal pathway between a sender and receiver
  • This prevents double-counting effects that flow through multiple routes
  • It enables the decomposition of a component's total effect into its constituent paths
03

Mathematical Formulation of the Intervention

The technique is formalized as a three-step intervention on the computational graph:

  1. Sender Hook: Capture the activation tensor from the source prompt at the sender component (e.g., an attention head's output)
  2. Receiver Hook: During the target prompt's forward pass, replace only the input that the receiver component reads from the sender with the captured source activation
  3. Freeze All Else: Ensure every other component's input comes from the target prompt's activations

The difference in logits between this patched run and the clean target run quantifies the path's direct causal contribution.

04

Applications in Circuit Discovery

Path patching is a cornerstone technique in automated circuit discovery and manual reverse engineering:

  • Validating hypothesized circuits: After identifying a candidate subgraph, researchers patch through only the proposed path to verify it reproduces the full model's behavior
  • Measuring path importance: By systematically patching every path between two layers, researchers rank which routes carry the most causally relevant information
  • Decomposing attention head interactions: It reveals how induction heads compose with previous token heads to perform in-context learning
  • Isolating MLP contributions: It separates the direct effect of an MLP layer on the residual stream from its effect mediated through subsequent attention layers
05

Relationship to Causal Scrubbing

Path patching and causal scrubbing are complementary evaluation strategies:

  • Path patching is a constructive method: it tests whether a specific path is sufficient to transmit a causal effect by activating only that path with source information
  • Causal scrubbing is a destructive method: it tests whether a hypothesized circuit is necessary by corrupting all activations outside the circuit and checking if performance is preserved
  • Together, they provide necessity and sufficiency proofs for a circuit's functional role
  • Both rely on the same underlying intervention machinery but apply it in opposite directions
06

Implementation Considerations

Practical path patching requires careful engineering:

  • Hook placement: Incorrectly specifying the sender or receiver tensor can contaminate the experiment with unintended causal pathways
  • Path granularity: Paths can be defined at the level of individual attention heads, entire layers, or specific weight matrices within an MLP
  • Computational cost: Each path requires a separate forward pass, making exhaustive search over all paths expensive for large models
  • Activation caching: Efficient implementations cache the source and target activations to avoid redundant computation
  • Libraries: Frameworks like TransformerLens and nnsight provide built-in abstractions for defining and executing path patching experiments on models like GPT-2 and Pythia
CAUSAL INTERVENTION COMPARISON

Path Patching vs. Related Causal Techniques

A technical comparison of Path Patching with other causal intervention methods used to isolate specific computational subgraphs in neural networks.

FeaturePath PatchingActivation PatchingCausal ScrubbingZero Ablation

Granularity of Intervention

Specific path between two components

Single component at one position

All components outside a hypothesized circuit

Single neuron or head

Preserves Indirect Effects

Freezes Non-Targeted Paths

Requires Corrupted Baseline Input

Typical Use Case

Isolating direct effect of head A on head B

Identifying function of a single head

Validating a complete circuit hypothesis

Measuring component importance

Computational Cost

Moderate (two forward passes)

Low (two forward passes)

High (multiple forward passes)

Very Low (single forward pass)

Risk of False Positives

Low

Moderate

Low

High

Reveals Composition Structure

PATH PATCHING

Frequently Asked Questions

Clarifying the causal intervention technique used to isolate and validate specific computational pathways in neural networks.

Path patching is a causal intervention technique that isolates the direct effect of a specific computational path between two model components by patching activations along that path while freezing all other paths. It works by running two forward passes: one on a clean input and one on a corrupted input. The activations from the corrupted run are then selectively copied into the clean run only along the hypothesized path, effectively creating a counterfactual where only that path receives different information. By measuring the resulting change in the model's output, researchers can precisely quantify the causal contribution of that specific pathway, distinguishing it from indirect effects that flow through other routes in the network.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.