Papers › Finding Transformer Circuits with Edge Pruning

Finding Transformer Circuits with Edge Pruning

24 Jun 2024arXiv:2406.16778archive 2025-07-28

Adithya Bhaskar, Alexander Wettig, Dan Friedman, Danqi Chen

The path to interpreting a language model often proceeds via analysis of circuits -- sparse computational subgraphs of the model that capture specific aspects of its behavior. Recent work has automated the task of discovering circuits. Yet, these methods have practical limitations, as they rely either on inefficient search algorithms or inaccurate approximations. In this paper, we frame automated circuit discovery as an optimization problem and propose *Edge Pruning* as an effective and scalable solution. Edge Pruning leverages gradient-based pruning techniques, but instead of removing neurons or components, it prunes the \emph{edges} between components. Our method finds circuits in GPT-2 that use less than half the number of edges compared to circuits found by previous methods while being equally faithful to the full model predictions on standard circuit-finding tasks. Edge Pruning is efficient even with as many as 100K examples, outperforming previous methods in speed and producing substantially better circuits. It also perfectly recovers the ground-truth circuits in two models compiled with Tracr. Thanks to its efficiency, we scale Edge Pruning to CodeLlama-13B, a model over 100x the scale that prior methods operate on. We use this setting for a case study comparing the mechanisms behind instruction prompting and in-context learning. We find two circuits with more than 99.96% sparsity that match the performance of the full model and reveal that the mechanisms in the two settings overlap substantially. Our case study shows that Edge Pruning is a practical and scalable tool for interpretability and sheds light on behaviors that only emerge in large models.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2406.16778")

Code

Syntology Ran 8 of 8 code samples harvested from 1 repository linked to this paper; 0 have no recorded run. Of those that ran: 3 ran · honoured contract; 5 ran · our draft was wrong.

By repository: official repository: 8 samples from 1 repository, 8 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

princeton-nlp/edge-pruning officialmentioned in papermentioned on GitHubjax report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

8 samples harvested; 8 ran; 3 honoured the contract we drafted; 0 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

3ran · honoured contract
5ran · our draft was wrong

Licence: 0 of the 8 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from princeton-nlp/Edge-Pruning. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

find_template princeton-nlp/Edge-Pruning/src/eval/ioi.py official repository ran · our draft was wrong fingerprinted MIT (permissive) · ac94bbb65658849e · report
format_instance princeton-nlp/Edge-Pruning/src/prune/fpt2_ioi.py official repository ran · our draft was wrong MIT (permissive) · 65258336cdb05cba · report
n_readers princeton-nlp/edge-pruning/src/modeling/modeling_erazr.py official repository ran · honoured contract MIT (permissive) · d4e547744737a080 · report
n_total_edges princeton-nlp/edge-pruning/src/modeling/modeling_erazr.py official repository ran · honoured contract MIT (permissive) · d4f39f78881244a5 · report
reader_idx_to_name princeton-nlp/Edge-Pruning/src/modeling/modeling_fpt2.py official repository ran · our draft was wrong MIT (permissive) · e29fd15d44a01690 · report
try_fit_template princeton-nlp/Edge-Pruning/src/prune/fpt2_ioi.py official repository ran · our draft was wrong fingerprinted MIT (permissive) · 09edbe6bc59ee172 · report
writer_idx_to_name princeton-nlp/Edge-Pruning/src/modeling/modeling_fpt2.py official repository ran · our draft was wrong fingerprinted MIT (permissive) · 149ae20dadcb3e8f · report
writer_name_to_idx princeton-nlp/Edge-Pruning/src/modeling/modeling_fpt2.py official repository ran · honoured contract MIT (permissive) · a8e155123b432821 · report

Tasks

In-Context LearningLanguage Modelling

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

AdamAttentionAttention DropoutBPECosine AnnealingDense ConnectionsDiscriminative Fine-TuningDropoutGPT-2Layer NormalizationLinear LayerLinear Warmup With Cosine AnnealingMulti-Head AttentionPruningResidual ConnectionSPEEDSoftmaxWeight Decay

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections