Mohammed Mudassir Uddin

HAGDarXiv 2601.12879Mechanistic interpretabilityUnder review

Hierarchical Sparse Circuit Extraction via Scalable Attribution Graph Decomposition

Finding the circuit behind a behavior means picking a few features out of thousands, and trying subsets exhaustively costs O(2n). HAGD never searches the flat graph. It groups the attribution graph into a spectral hierarchy of supernodes, lets a graph attention network decide which branches to open, and admits a circuit only after it passes causal tests. Worst-case search drops to O(n2 log n).

O(n² log n)
worst-case search, down from O(2n) subsets
0.09s
for the hierarchical search over 413 active features (22.7 min end to end on one T4)
r = 0.97
agreement of cheap gradient × activation edges with 20-step Integrated Gradients
4gates
a circuit must clear before anything is reported: accuracy, reconstruction, size, sufficiency

The ideaSearch a hierarchy, not the graph

Mechanistic interpretability tries to explain a model behavior as a small circuit: a set of interpretable features and the causal edges between them. Sparse dictionaries (transcoders) make the features readable and attribution graphs give the edges. The step that does not scale is the search itself. Methods like ACDC patch edges one at a time across every layer, and exhaustive search over feature subsets grows as 2n.

HAGD borrows the coarse-to-fine idea from graph partitioning. Features that attribute strongly to each other are clustered into supernodes, the clusters are clustered again, and the search starts at the top. At each level only the most promising branches are opened, so most of the graph is never touched.

Exhaustive search every subset of the flat attribution graph L3 L4 L5 L6 413 active features → 2413 candidate subsets HAGD open only the top-scoring branches, level by level level 3 level 2 level 1 features 413 features → 48 candidates → causal tests
Figure 1. Flat search against hierarchical search, drawn schematically. Supernodes are spectral clusters of the attribution graph, and a graph attention network scores them. Only the highlighted branches are expanded, and the features under them become candidates for causal testing. The counts are from the released seed-0 run.

What is newCoarse-to-fine search with the checks built in

Flat searchHAGD
What is searchedEvery edge or feature subset of the full graphA multi-resolution hierarchy of supernodes, expanded from the top
Worst-case costO(2n) subsets, or one patching pass per edge across all layersO(n2 log n), with O(n log n) to build the hierarchy
What decides where to lookA fixed threshold on each edge’s effectA graph attention network trained on real ablation outcomes
Directed edgesClustering methods usually need a symmetric graphClusters are built on a symmetric magnitude skeleton; search and patching keep the true edge direction
When a circuit countsOften judged by its size or by attribution scoresOnly after necessity and sufficiency tests on held-out prompts, behind hard gates

How it worksFour stages, each with a stopping rule

input gate: fine-tuned task accuracy ≥ 0.80 on held-out prompts 1 Cross-layer transcoders 2 Attribution graph 3 Spectral hierarchy 4 Guided search + tests dense state h (768 values) sparse: 32 of 6,144 on φ(C) ≥ θ sparse TopK code per layer decoder bias = mean state head predicts the next layer layers 3–6, 6,144 each weight = ∂fj/∂fi · fi (gradient × activation) top 16 edges per feature 413 nodes, 4,752 edges cluster on ½(|A| + |A|ᵀ) Laplacian eigenvectors directions kept for search 4 levels in 0.14 s GAT scores the supernodes open the top 2 per level ablate, then measure φ(C) 48 candidates → 10 nodes gate: ≤ 40% variance unexplained gate: ≥ 10 nodes, φ ≥ 0.3
Figure 2. The four stages. Stages 1 and 2 build on existing transcoder and attribution-graph work. The hierarchy and the guided, causally tested search (highlighted) are HAGD’s contribution. When a gate fails, the released pipeline stops rather than report a circuit. The grey figures under each stage are from the seed-0 run.

1 · Cross-layer transcoders

For each analyzed layer, a transcoder maps the residual stream hℓ to a sparse, overcomplete code and back. The decoder bias starts at the dataset’s mean activation, so features describe departures from a typical state rather than the state itself.

𝐟ℓ=TopK(ReLU(WℓE 𝐡ℓ+𝐛ℓE), k),𝐡^ℓ=Dℓ 𝐟ℓ+𝐛ℓD\mathbf{f}_\ell = \mathrm{TopK}\big(\mathrm{ReLU}(W^{E}_{\ell}\,\mathbf{h}_\ell + \mathbf{b}^{E}_{\ell}),\,k\big),\qquad \hat{\mathbf{h}}_\ell = D_\ell\,\mathbf{f}_\ell + \mathbf{b}^{D}_\ell

Training balances reconstruction, a cross-layer term (a small predictor Pℓ maps this layer’s code to the next layer’s) and sparsity:

ℒ=∑ℓ∥𝐡ℓ−𝐡^ℓ∥22  +  λ1∥𝐟ℓ+1−Pℓ(𝐟ℓ)∥22  +  λ2∥𝐟ℓ∥1\mathcal{L} = \sum_{\ell}\big\lVert \mathbf{h}_\ell - \hat{\mathbf{h}}_\ell\big\rVert_2^2 \;+\; \lambda_1\big\lVert \mathbf{f}_{\ell+1} - P_\ell(\mathbf{f}_\ell)\big\rVert_2^2 \;+\; \lambda_2\lVert \mathbf{f}_\ell\rVert_1

2 · Attribution graph

An edge from feature i to a downstream feature j is weighted by gradient × activation, which needs one backward pass per example:

Ai→j=∂fj∂fi  fiA_{i\to j} = \frac{\partial f_j}{\partial f_i}\; f_i

Path-integrated Integrated Gradients needs one backward pass per integration step. On the released run the two orderings agree closely: correlation 0.970 over 366 shared edges against 20-step IG. Keeping each feature’s strongest 16 outgoing edges holds the graph at |E| = O(n).

3 · Spectral hierarchy

The normalized graph Laplacian needs a symmetric matrix, and attribution graphs are directed. HAGD separates the two jobs. Clustering runs on a symmetric magnitude skeleton, while the original directed edges are kept for search and patching:

Asym=12(∣A∣+∣A∣⊤),L=I−D−1/2Asym D−1/2A_{\text{sym}} = \tfrac{1}{2}\big(|A| + |A|^{\top}\big),\qquad L = I - D^{-1/2}A_{\text{sym}}\,D^{-1/2}

The smallest eigenvectors of L embed the features, k-means groups them into supernodes, and the process repeats on the coarsened graph to give levels G(0) … G(R) with branching factor 4. With sparse (Lanczos) eigensolvers each level costs O(|E|), so the hierarchy costs O(n log n).

4 · Guided search and causal tests

A two-layer graph attention network, trained on necessity labels from real ablations, scores the features. Each supernode’s score is the mean over its members, and the search keeps only the top 2 supernodes per level on its way down. The surviving region then faces two tests on held-out prompts. For necessity, each feature is ablated alone and kept only if the task loss rises by at least ε. For sufficiency, every feature outside the circuit is replaced by its mean and the remaining behavior is measured:

ϕ(𝒞)=Acc(M𝒞)Acc(Mfull)\phi(\mathcal{C}) = \frac{\mathrm{Acc}(M_{\mathcal{C}})}{\mathrm{Acc}(M_{\text{full}})}

The worst-case cost of the search is O(n2 log n). Hierarchy construction is O(n log n), and patching is restricted to candidate features.

Released resultsWhat the public code shows

The released notebooks run the whole pipeline on GPT-2 Small (124M parameters) fine-tuned for a + b mod 23, on a single Tesla T4. The fine-tuned model reaches 83.8% exact-match accuracy on 105 held-out prompts, none of which appear in the 3,000 training prompts. Transcoders on layers 3–6 leave 0.1–0.3% of held-out variance unexplained on the task and 1.8–2.5% on generic English text.

The search narrows 413 active features to a 10-node circuit

Figure 3. Features remaining after each stage of the seed-0 run. The four analyzed layers hold 24,576 dictionary features in total, of which 413 carry an edge after sparsification. The final circuit has 9 directed edges: one node in layer 5 and nine in layer 6.

The 10-node circuit preserves no more behavior than the controls

Figure 4. Behavioral preservation φ when every feature outside the set is replaced by its mean at generation steps; the full model scores 1.0. Restricting every position instead, prompt reading included, drops the circuit to φ = 0.00. This is the extraction notebook’s seed-0 run. The verification suite’s seed-0 run, repeated twice with identical results, gives 0.27 for its circuit.
Table 1. Wall-clock time per stage, seed-0 run on one Tesla T4 (float32, 2 CPU cores).
StageTimeOutput
Fine-tune GPT-2 Small on a + b mod 23969 s83.8% held-out exact match
Cache activations, layers 3–613.6 s10,656 training positions
Train transcoders151 s≤ 0.3% unexplained variance on the task
Build attribution graph4.5 s15,362 edges, 4,752 after top-16 pruning
Spectral coarsening0.14 s4 levels, 413 features to 2 supernodes
Ablation labels for the GNN199 s57 of 160 candidates necessary
Train the graph attention network1.7 sheld-out AUROC 0.71
Hierarchical search0.09 s48 connected candidates
Causal validation20.9 s10-node circuit, φ = 0.23
Total1,360 s22.7 minutes end to end

The search itself is the cheap part: 0.09 s, against 969 s to fine-tune the model and 199 s of ablations to label training data for the graph network. The pipeline is also deterministic. Running seed 0 twice in the verification suite reproduced every preservation value exactly.

Table 2. The five-seed verification suite. A seed only proceeds to circuit extraction if the fine-tuned model reaches 80% held-out accuracy.
SeedHeld-out accuracyAccuracy gateφ all positionsφ generation stepsφ first step
083.8%pass0.0000.2730.330
167.6%fail———
259.0%fail———
359.0%fail———
446.7%fail———

Why it falls shortThe released notebook locates the problem

The extraction notebook does not stop at “φ is low”. It runs a series of diagnostic tests, each designed to rule an explanation in or out. Four findings stand out.

The traversal misses most useful features, and restricting more layers compounds the loss

(a) Share of the top-N most necessary features the traversal reaches

(b) φ when the circuit is enforced only in some layers

Figure 5. (a) Traversal recall. Of the 10 features with the largest individual necessity scores, 7 never entered the 48-feature candidate pool. (b) Enforcing the circuit only in layer 6 gives φ = 0.33. Adding layer 5, which holds a single circuit node, drops it to 0.22, because restricting an earlier layer degrades what later layers receive.

Behavior returns only when most of each activation is let through

Figure 6. Blending the circuit-only features with the full features, f = α·ffull + (1 − α)·fcircuit, at generation steps. Preservation stays under 0.25 up to α = 0.5, then climbs steadily to 0.955. That is a gradual cost of withheld information, not a cliff at one threshold.
  • Candidate generation is the bottleneck. Traversal recall is 20–31% across budgets. Adding the missed features back without re-filtering does not help on its own (φ = 0.23 for a 60-feature union).
  • Necessity scores carry little signal here. The 10 least necessary features preserve as much (0.273) as the circuit (0.227). Necessity-ranked sets from 5 to 80 features fall within the random-draw range at 5 of 7 sizes.
  • The first answer token carries the work. Restricting only the first generated token gives φ = 0.30, against 0.23 when every generation step is restricted. The biggest jump in the depth sweep comes between one and two restricted steps.
  • Features act together. In the greedy trace, some features add more accuracy alongside others than they do alone, so ranking features one at a time undersells them.
  • Preservation depends on the prompt. φ differs by 0.133 between sums that wrap past 23 and sums that do not.

About the arXiv numbersWhat this page does and does not report

Scope

arXiv v2 (June 2026) also reports runs on Pythia and Llama models up to 70B parameters, 91% (±2.3%) behavioral preservation with 49–347-node circuits, and cross-architecture transfer coefficients of 0.38–0.82. The released code does not contain those runs, and the repository’s own automated claim audit (manuscript_claim_audit.json) marks them unsupported. This page reports only numbers that the released notebooks produce.

Table 3. The repository’s claim audit, as published in its README.
Claim in the manuscriptAuditWhat the released code shows
91% (±2.3%) behavioral preservationunsupportedφ = 0.00 at all positions, 0.27 at generation steps
Modulus-113 taskunsupportedthe notebooks use a + b mod 23
49–347-node circuits across modelsunsupportedone 10-node circuit, GPT-2 Small only
52–82% cross-architecture transferunsupportedtransfer code exists but was never run
Symmetrization ½(A + A⊤)correctedthe code uses ½(|A| + |A|⊤)
Integrated Gradients attributioncorrectedgradient × activation is primary; IG is a check

Next stepsWhat the diagnostics point to

  • Fix recall before anything else. The hierarchy currently discards most of the features that matter, so better candidates should come before better scoring.
  • Measure sufficiency where the computation happens. Score circuits at generation steps, or at the first answer token, rather than at every position.
  • Restrict the deepest layer first. Restriction costs compound through earlier layers.
  • Select features jointly. The synergy result argues for interaction-aware selection over independent ranking.
  • Get more seeds past the accuracy gate with a larger fine-tuning budget, then run the untouched second-task (parity) and transfer experiments that the code already contains.

CitationCite this work

@article{uddin2026hagd,
  title   = {Hierarchical Sparse Circuit Extraction from Billion-Parameter
             Language Models through Scalable Attribution Graph Decomposition},
  author  = {Uddin, Mohammed Mudassir and Alam, Shahnawaz
             and Pasha, Mohammed Kaif},
  journal = {arXiv preprint arXiv:2601.12879},
  year    = {2026}
}