Introduction
A circuit is a subset of the edges of a model's computation graph: attention heads, MLPs, the input and the logits, with separate query, key and value inputs into each head. Every edge outside the circuit takes its value from a counterfactual input, and the circuit is good if the model's behaviour, here a logit difference between the right and the wrong answer, survives. The benchmark we work in (MIB) [1] asks for this at a whole range of circuit sizes and judges it two ways: how far the circuits move the behaviour away from the full model's (CMD, lower is better) and how much of the behaviour they recover (CPR, higher is better). Both are areas under a curve of the normalised faithfulness
where is the mean logit difference on examples the method has never seen. The method returns one score per edge, and circuits are read off that ranking.
The field's standard tools are attribution methods. Edge attribution patching [2] scores an edge by the product of its counterfactual activation difference with the gradient at its receiver; integrated gradients along a path from counterfactual to clean inputs make that estimate more faithful [3]; relevance patching [4] and learned attribution [5] are more recent alternatives, and feature-level circuits extend the idea below the level of whole components [6].
Three properties of the problem make it harder than ranking edges by importance:
- Edges interact. An attribution score is a first-order estimate at one mask. When many small edges are removed together, their summed effect is not small, and it is not zero on average: in our development runs the faithfulness of the starter's top-ranked circuits sagged to about 0.90 to 0.93 at mid-sized budgets, because the dropped tail was net-helpful.
- Faithfulness and performance pull in different directions. A circuit that reproduces the model () is not a circuit that recovers the most ( is possible: patching an edge that works against the answer with its counterfactual value removes that opposition). One ranking is asked to serve both.
- The explanation has to transfer. The circuit is judged on examples it never saw, and the discovery data need not resemble them closely.
The second problem of the task, finding features that implement a causal variable, is addressed in the field by distributed alignment search (DAS) [7]. Our submission did not change it; we return to this in Section 4.
Method
Our method, calibrated dual-family scoring (CDS), builds the score matrix out of two separate families of circuits: a natural family, read off the ranking by absolute score, calibrated by measurement to be faithful at every budget; and a performance core, the only edges with positive sign, found by optimising a mask directly. The header of our code states the split.
# Dev method v11 = v10 with calibration effort concentrated on the largest budgets. v10 = v9 + multi-circuit forwards, noise-aware two-stage calibration, perf step planning. v9 = v8 + noise floor on the split shift. v8 = v7 + split-balanced calibration. v7 = v6 + split-shift-aware importance. v6 = v5 + hard-thresholding sparsification of the core (no nesting). v5 = v4 + time budgeting, out-of-memory-safe batches, own Graph object, fallbacks.
# Dual-purpose edge scores:
# |score| ranking -> natural, faithfulness-calibrated circuits (helpful-prefix + harmful-prefix, split measured per budget)
# signed ranking -> performance core found by annealed mask ascent (positive scores) padded with inert fillers.
from functools import partial
from einops import einsum
CONFIG = dict(ig_steps=5, seed=0, verbose=True, perf=True, calibrate=True, r=0.85, q=0.999, eta0=0.5, eta1=20000.0, n_eff=100.0,
tol=0.002, budget_sec=None, T1=None, kappa=1.0, z2=1.0)An exact engine for masked circuits
Everything rests on one primitive. Let be the counterfactual activation of sender and its current activation. With a real-valued patch weight on every edge, the input that receiver sees is
which is the edge-patched model of the benchmark at . Our engine runs this forward with hooks and, in the same pass, back-propagates the metric to every receiver input, accumulating
At this is the edge-attribution-patching score; at any other mask it is the exact in-context
gradient of that mask. Writing the keep weight , the routine grad_at(K, batch) returns
for the mean logit difference . For architectures with a
normalisation after attention, the forward recomputes the norm exactly and the gradient uses its
first-order Jacobian. Several circuits can be stacked along the batch dimension and evaluated in one
forward, which is what makes measurement cheap enough to use inside the method.
Natural attribution, corrected for split shift
The natural order comes from integrating the in-context gradient along a uniform mask path, from all edges kept to all edges patched, with a midpoint rule over steps:
A positive means keeping the edge raises the logit difference. We compute separately on examples drawn evenly from each of the two discovery splits, and , each with the sampling variance of its batch mean, and . Their average is the attribution; an edge whose effect differs between the splits by more than its sampling noise is promoted, because a circuit that omits it will not transfer:
The real edges are then split into a helpful list () and a harmful list (), each sorted by in descending order, and a candidate circuit is , pruned of edges that no longer connect input to logits.
def attribution(batches):
"""integrated mask gradients per batch -> mean attribution and the sampling variance of that mean"""
acc = torch.zeros((eng.nf, eng.nb), device=eng.dev, dtype=torch.float32)
sq = torch.zeros_like(acc)
for batch in batches:
ab = torch.zeros_like(acc)
for k in range(K_steps):
ab += grad_at(torch.full_like(acc, 1 - (k + 0.5) / K_steps), batch) / K_steps
ab = torch.nan_to_num(ab)
acc += ab
sq += ab * ab
n = max(len(batches), 1)
mean = torch.where(real, acc / n, torch.zeros_like(acc))
var = ((sq / n - mean * mean).clamp_min(0) / (n - 1)) if n > 1 else None
return mean, var
nat_tr, nat_va = nat_tr[:per_env], nat_va[:per_env]
a_tr, v_tr = attribution(nat_tr)
if nat_va:
a_va, v_va = attribution(nat_va)
a = (a_tr + a_va) / 2 # both splits weigh equally
if v_tr is None and v_va is None:
imp = a.abs()
else: # shift of the effect between the two splits, above its sampling noise
v_tr_ = v_tr if v_tr is not None else v_va * len(nat_va) / max(len(nat_tr), 1)
v_va_ = v_va if v_va is not None else v_tr * len(nat_tr) / max(len(nat_va), 1)
shift2 = ((a_tr - a_va).pow(2) - cfg["z2"] * (v_tr_ + v_va_)).clamp_min(0)
imp = (a.pow(2) + cfg["kappa"] * shift2).sqrt()
say(f"split shift: {float((shift2 > 0)[real].float().mean()):.3f} of edges above noise; mean shift^2/mean a^2 = {float(shift2[real].mean() / a[real].pow(2).mean().clamp_min(1e-30)):.3f}")
else:
a, imp = a_tr, a_tr.abs()Calibrating every budget to faithfulness one
At budget the only free choice in the natural family is , how many of the edges come from the harmful list. More harmful edges lower . We choose by measurement on fresh calibration batches, with both splits represented equally: for each split we compute the paired per-example change , and
which is the faithfulness averaged with equal weight over the splits. Root-finding uses the first-order mass the circuit keeps, , which decreases in : we bracket (a measurement with moves the lower bracket, otherwise the upper one), interpolate the target mass between brackets or extrapolate with a fitted slope, and bisect on to turn the target into an integer . A budget stops when its best is below the larger of and its paired standard error. Four coarse rounds run on all budgets (when forward passes are expensive, on the five largest, with the others calibrated on a smaller sample), then, if time allows, three finer rounds on the three largest with a larger sample, because those carry most of the area and their remaining error is sampling noise.
for rnd in range(n_rounds):
todo = [n for n in todo_sizes if hi_[n] > lo_[n] and not (n in res and res[n][0] < max(cfg["tol"], res[n][3]))]
if not todo or (rnd > 0 and left() < 0.3 * budget):
break
vals = measure_ex([circuit(n - q_[n], q_[n]) for n in todo], cb)
for j_, n in enumerate(todo):
dv = vals[j_] - fullv # paired per-example change of the logit difference
fe = [1 + float(dv[idx[e_]].mean()) / spans[e_] if spans[e_] != 0 else 1.0 for e_ in envs]
f = sum(fe) / len(fe)
se = (sum(float(dv[idx[e_]].var()) / max(len(idx[e_]), 1) / spans[e_] ** 2 for e_ in envs if len(idx[e_]) > 1) ** 0.5) / len(envs)
env_f[n] = fe if (n not in res or abs(f - 1) < res[n][0]) else env_f.get(n, fe)
if n in res and abs(S(n, q_[n]) - S(n, res[n][1])) > 1e-9 and abs(f - res[n][2]) > 1e-6:
gam[n] = min(8.0, max(0.125, (f - res[n][2]) * span / (S(n, q_[n]) - S(n, res[n][1]))))
if n not in res or abs(f - 1) < res[n][0]:
res[n] = (abs(f - 1), q_[n], f, se)
if f > 1: # too strong: trade helpful edges for harmful ones
lo_[n], flo[n] = q_[n], f
else:
hi_[n], fhi[n] = q_[n], f
if hi_[n] - lo_[n] <= 1:
lo_[n] = hi_[n] = res[n][1]
continue
if n in flo and n in fhi: # interpolate the first-order mass between the brackets
s_lo, s_hi = S(n, lo_[n]), S(n, hi_[n])
target = s_lo + (s_hi - s_lo) * (flo[n] - 1) / max(flo[n] - fhi[n], 1e-9)
else: # or extrapolate with the fitted slope
target = S(n, q_[n]) - (f - 1) * span / gam[n]The calibrated pairs are made nested, both non-decreasing in the budget, and are then written into the magnitudes. An edge's level is the index of the smallest budget whose circuit contains it, and
where is the number of budgets and decreases with the edge's position within its list. The top edges by are then exactly the calibrated circuit at budget .
level = torch.full((flat.numel(),), float(nlev))
for i in range(len(sizes) - 1, -1, -1):
p_, q_ = pq[sizes[i]]
level[pos[:p_]] = float(i + 1)
level[neg[:q_]] = float(i + 1)
frac = torch.zeros(flat.numel())
frac[pos] = 1 - (torch.arange(len(pos)).float() + 1) / (len(pos) + 2)
frac[neg] = 1 - (torch.arange(len(neg)).float() + 1) / (len(neg) + 2)
mag = (nlev - level) + 0.98 * frac + 0.01
sign = torch.where(flat > 0, 1.0, -1.0) # natural signed family unless a performance core is foundA performance core from annealed mask ascent
The signed ranking is left to a different object. We ascend the logit difference over a box mask with an annealed step: with the bias-corrected exponential average of in-context gradients (rate for batch size ),
where is the 0.999 quantile of . As grows the mask hardens. We then average the gradient at the hard optimum and sparsify by hard thresholding: the kept set is always the top edges by averaged in-context benefit over all edges, so an excluded edge can come back, while shrinks geometrically by a ratio and the gradient is re-averaged at each new mask. Snapshots are taken at the budget sizes, down to the fourth largest.
for t in range(T1): # annealing: K = clip(1/2 + eta_t * averaged gradient), eta_t increasing
if t > 0:
G = beta * G + (1 - beta) * grad_at(K, opt_b[t % len(opt_b)])
Gh = G / (1 - beta ** (t + 1))
s = torch.quantile(Gh[real].abs().float(), cfg["q"]).clamp_min(1e-12)
K = (0.5 + cfg["eta0"] * growth ** t * Gh / s).clamp(0, 1) * real
Gs, step = Gh.clone(), T1
for t in range(hold): # average the gradient at the hard optimum
Gs = beta2 * Gs + (1 - beta2) * grad_at(((Gs > 0) & real).float(), opt_b[step % len(opt_b)]); step += 1
nstar = int(((Gs > 0) & real).sum())
# sparsification by hard thresholding of the averaged in-context gradient: the kept set is always the top-n edges by
# benefit over ALL edges (excluded edges can return), n decreasing geometrically; snapshots at the budget sizes
sets = {min(nstar, n_top): _topset(Gs, min(nstar, n_top), real)}
cur = min(nstar, n_top)
for tgt in [s_ for s_ in sorted(sizes, reverse=True) if floor <= s_ < cur]:
while cur > tgt and left() > reserve:
cur = max(tgt, int(cur * cfg["r"]))
for _ in range(per):
Gs = beta2 * Gs + (1 - beta2) * grad_at(_topset(Gs, cur, real).float(), opt_b[step % len(opt_b)]); step += 1
for _ in range(hold): # settle at the snapshot size
if left() > reserve:
Gs = beta2 * Gs + (1 - beta2) * grad_at(_topset(Gs, cur, real).float(), opt_b[step % len(opt_b)]); step += 1
if cur == tgt:
sets[tgt] = _topset(Gs, tgt, real)Among the snapshots we pick the core that maximises its measured times the total trapezoid weight of the budgets it can serve, , and accept it only if , where is the faithfulness of the natural top set at the largest budget. If accepted, the core edges are the only ones with positive sign. Larger signed circuits are padded with fillers: edges outside the core and outside every natural circuit, ordered by how inert they are in the core's context (the size of their in-context gradient, set to zero for edges into nodes the core never reads, which pruning removes anyway). Fillers receive magnitudes below , smaller than every other edge's, so the top of the absolute ranking, and with it the calibrated family, is unchanged.
if cands:
c = max(cands, key=area)
f_nat = fa(measure([_topset(a, n_top, real)], sel_b)[0])
if fsel[c] > max(1.0, f_nat):
core = sets[c]
core_flat = core.flatten().cpu()
sign = torch.where(core_flat, 1.0, -1.0)
if c < n_top: # fillers: outside the core and every abs circuit, most inert in context first
Gc = torch.zeros_like(a)
for _ in range(2):
Gc += grad_at(core.float(), opt_b[step % len(opt_b)]); step += 1
graph.in_graph[:] = core.cpu()
graph.prune()
dead_bwd = ((~graph.nodes_in_graph).float() @ graph.forward_to_backward.float()) > 0
inert = Gc.abs()
inert[:, dead_bwd.to(eng.dev)] = 0.0 # edges into nodes the core never reads are pruned away exactly
cand = realc & ~core_flat & (level >= nlev)
key = torch.where(cand, inert.flatten().cpu(), torch.full_like(flat, float("inf")))
fo = torch.argsort(key)[:min(n_top - c, int(cand.sum()))]
mag[fo] = 0.008 * (torch.arange(len(fo)).float() + 1) / (len(fo) + 1)
fill = torch.zeros(flat.numel(), dtype=torch.bool); fill[fo] = TrueThe method budgets its own wall clock from timed single-example passes and gives fixed shares to the three phases. If anything fails, or a score is not finite, it falls back to the starter's integrated gradients on inputs.
Results
| Method | ① | ② | ③ | ④ | ⑤ | ||
|---|---|---|---|---|---|---|---|
| Circuit-model distance (CMD) ↓ | Circuit performance ratio (CPR) ↑ | Circuit-model distance (CMD) ↓ | Circuit performance ratio (CPR) ↑ | Interchange accuracy (IIA) ↑ | Interchange accuracy (IIA) ↑ | Interchange accuracy (IIA) ↑ | |
| Claude Fable 5.2 | 0.012 | 1.006 | 0.015 | 1.012 | 0.377 | 0.563 | 0.830 |
| EAP-IG + DAS | 0.145 | 0.854 | 0.069 | 0.930 | 0.377 | 0.563 | 0.830 |
| EAP | 0.160 | 0.845 | 0.068 | 0.931 | 0.377 | 0.563 | 0.830 |
| EAP-IG-activations | 0.066 | 0.935 | 0.377 | 0.563 | 0.830 | ||
| RelP | 0.154 | 0.845 | 0.094 | 0.915 | 0.377 | 0.563 | 0.830 |
| MAttr | 0.446 | 0.601 | 0.429 | 0.570 | 0.377 | 0.563 | 0.830 |
| Random circuit | 0.740 | 0.259 | 0.661 | 0.338 | 0.377 | 0.563 | 0.830 |
| Full vector | 0.145 | 0.854 | 0.069 | 0.930 | 0.294 | 0.491 | 0.467 |
| DBM | 0.145 | 0.854 | 0.069 | 0.930 | 0.345 | 0.530 | 0.713 |
- ① Llama-3.1-8B · ARC-Challenge circuit
- ② Gemma-2-2B · MCQA circuit
- ③ Gemma-2-2B · arithmetic carry variable
- ④ Gemma-2-2B · RAVEL country variable
- ⑤ Llama-3.1-8B-Instruct · ARC-Easy answer-pointer variable
Our submission did not change the causal-variable function. Our IIA is therefore the starter's, exactly: 0.377 on Gemma-2-2B · arithmetic carry variable, 0.563 on Gemma-2-2B · RAVEL country variable and 0.830 on Llama-3.1-8B-Instruct · ARC-Easy answer-pointer variable, the same values as every circuit baseline in the table, since none of them changes this function either. It is above the two baselines that do, DBM (0.345, 0.530, 0.713) and the full vector (0.294, 0.491, 0.467), on all three of these settings, but that is a property of the starter, not of anything we propose. None of these numbers measures CDS.
Beyond the table, what we can report about the circuit method comes from our own development runs, on our own held-out split of discovery-like data for our main development model and task, and is quoted as such. There the starter's integrated-gradient scores gave a CMD of 0.028 and a CPR of 2.01. Calibration alone, on integrated-gradient attribution, brought the CMD to between 0.008 and 0.010 at a CPR of 2.0 to 2.3. The full method, in the version we submitted, measured a CMD of 0.0090 and a CPR of 8.88; its predecessor with the same core gave a CMD of 0.0071. On a second development model the starter gave a CMD of 0.0164 and a CPR of 1.60 and an earlier version of CDS 0.0068 and 3.91; on a second task with that model, 0.0756 and 1.13 against 0.0058 and 5.72. In a smoke test on a much larger model, with a reduced time cap and a small test sample, an earlier version reached a CMD of 0.0156 and a CPR of 4.66. These are single runs, judged on our own split, and none was repeated.
How we got here
We began by reading the circuit and causal-variable code and the published baselines, and had a literature review of edge attribution and causal-variable localisation written alongside. Two early observations shaped everything after them: the faithfulness curve of attribution-ranked circuits sagged at mid-sized budgets, and a learned-attribution baseline [5], run in our development harness, reached a CPR of 10.29 with a CMD of 0.395. Directly optimised masks, in other words, recover far more than attribution prefixes do, and are not faithful.
- Calibration worked from the start. Splitting edges into helpful and harmful lists and choosing, per budget, how many harmful edges to include so that measured faithfulness is one was our first idea, and it removed most of the CMD at once (0.0357 to 0.0054 on held-out examples in its first test, by our development measurement).
- Greedy backward elimination was too coarse. Removing edges in rounds by their in-context gradient reached a faithfulness of only about two, and in our development measurement gave a CMD of 0.506 and a CPR of 1.50, fitting the discovery data rather than the held-out examples.
- Putting the optimised sets into the faithful family failed. Our second version used the performance-optimised nested sets as the helpful list of the calibrated family. It reached a CPR of 8.49 but a CMD of 0.207: the circuits then balanced on a cancellation between large opposing effects, calibration did not converge and did not transfer. That is why the natural family stays natural and the two families are kept apart, the decoupled design of our fourth version (CMD 0.0095, CPR 7.46).
- Hard thresholding replaced nesting in the core (CPR 7.87 to 8.63 between the fifth and sixth versions), so that an edge dropped at one size can return at a smaller one.
- The split-shift term came from a diagnostic. The same scores evaluated on samples from the two splits gave faithfulness curves that differed by several per cent at small budgets, so the residual error was heterogeneity, not noise. Promoting edges whose effect shifts between splits gave a CMD of 0.0044 in development, against 0.0052 with the term switched off, a small difference in single runs; balancing both splits equally in calibration followed for the same reason.
- Polishing the core did nothing: continuing the hard thresholding at the chosen size moved its measured faithfulness only from 11.43 to 11.48, which we read as the core sitting at a local optimum; later versions dropped it.
The submitted file is our eleventh version. Later versions, which vectorised the post-attention normalisation path and added robustness guards, were still being tested when the session ended.
The causal-variable track is where the most promising idea of the run was left unsubmitted. DAS [7] intervenes as with the write map tied to the read map, and orthonormal rows in . In our development sweeps an untied low-rank featurizer, with and free, clearly beat DAS on a teacher-forced proxy we built on one development task but lost to it on another; neither family won everywhere, so we built a version that races several featurizer families and positions and keeps the best per site. The submitted causal-variable function is the starter's.
Limitations
- Nothing in the published table measures our method. The only means available here are IIA, and IIA is the starter's because we did not change that function. Every statement about circuits rests on our own development runs, single runs on our own split, which the published evaluation neither confirms nor contradicts here.
- Half of the task is untouched. We changed one of the two editable functions. The causal-variable method we developed was not submitted, so the contribution is narrower than the task invites.
- The two families are two explanations, not one. The circuits read by absolute score and those read by signed score are different objects that share a matrix. A reader who takes the top edges by signed score as "the circuit" gets a performance core with filler edges, not the calibrated faithful circuit.
- A large CPR is not faithfulness. The performance core reaches faithfulness values near eleven in development by patching edges that oppose the answer. It shows how much of the behaviour some subgraph can drive, not how the model computes it; the same is true of the optimised-mask baseline it was inspired by.
- Calibration costs measurements and assumes a monotone family. The root-finding treats as decreasing in the number of harmful edges and uses a first-order mass as its coordinate; where that fails, as in our second version, calibration need not converge. It also spends a large share of the time budget on forward passes.
- Transfer is calibrated, not guaranteed. Calibration hits on discovery data; in development the held-out curve still sat about one per cent high at mid-sized budgets after calibration, which we attributed to differences between example sets rather than sampling noise.
References
- Aaron Mueller, Atticus Geiger, Sarah Wiegreffe et al. (2025). MIB: A Mechanistic Interpretability Benchmark. ICML.
- Aaquib Syed, Can Rager, Arthur Conmy (2023). Attribution Patching Outperforms Automated Circuit Discovery. NeurIPS.
- Michael Hanna, Sandro Pezzelle, Yonatan Belinkov (2024). Have Faith in Faithfulness: Going Beyond Circuit Overlap When Finding Model Mechanisms. COLM.
- Farnoush Rezaei Jafari, Oliver Eberle, Ashkan Khakzar et al. (2025). RelP: Faithful and Efficient Circuit Discovery in Language Models via Relevance Patching.
- Aryaman Arora, Kirill Acharya, Nathan Hu et al. (2026). Matryoshka attribution: Learning to attribute language model outputs to representations and weights.
- Samuel Marks, Can Rager, Eric J. Michaud et al. (2025). Sparse Feature Circuits: Discovering and Editing Interpretable Causal Graphs in Language Models. ICLR.
- Atticus Geiger, Zhengxuan Wu, Christopher Potts et al. (2023). Finding Alignments Between Interpretable Causal Variables and Distributed Neural Representations.