TL;DR
CircuitKIT is a unified, source-available library that bridges the gap between circuit discovery, multi-pillar evaluation, and downstream interventions (like pruning and editing) in large language models. By introducing a standardized, serializable CircuitScores artifact and declarative data adapters, it enables researchers and engineers to seamlessly transition from raw datasets to actionable model modifications.
What Problem Does This Paper Address?
Mechanistic interpretability aims to reverse-engineer large language models (LLMs) into human-understandable subgraphs, or "circuits," that are causally responsible for specific behaviors. While the field has seen a boom in discovery algorithms, evaluation metrics, and downstream interventions, the ecosystem remains highly fragmented.
Currently, conducting a full circuit analysis requires stitching together separate, paper-specific repositories with incompatible artifact formats. Furthermore, many attribution-based discovery methods require contrastive (clean/corrupt) prompt pairs, creating a massive data bottleneck for custom, real-world datasets. This fragmentation makes it incredibly difficult to compare different discovery methods fairly or to apply them beyond a few canonical academic tasks.
Methods
CircuitKIT addresses these gaps by integrating the entire locate-then-act pipeline into a cohesive framework driven by three user interfaces: a stateful Python pipeline, a functional API, and a YAML-driven CLI.
Key components of the library include:
- Unified Artifact (
CircuitScores): A typed, JSON-serializable record that holds task descriptors, model identifiers, granularity levels (node or neuron), and per-component attribution scores. Every discovery backend produces this artifact, and every evaluation or intervention module consumes it. - Comprehensive Discovery Suite: Out-of-the-box support for 13 discovery algorithms across four backend families, explicitly categorized into "Stable" and "Research" tiers to clarify cross-model validation status.
- Declarative Data Path: A template-driven pipeline that automatically maps raw structured user data (like CSVs or HuggingFace splits) into discovery tasks. It handles token-length alignment and can automatically synthesize contrastive corrupt counterparts using strategies like
ENTITY-SWAPandTOKEN-SWAP. - Multi-Pillar Evaluation: Rather than relying on a single metric, CircuitKIT evaluates circuits across six distinct diagnostic pillars: Causal Patching, Ablation Faithfulness, Stability, Robustness, Baseline Comparison, and Generalization.
- Actionable Interventions: Discovered circuits can be directly fed into downstream application modules, including structural pruning, mixed-precision quantization, selective fine-tuning, and knowledge editing (ROME/MEMIT).
Datasets
CircuitKIT includes a built-in registry of 16 canonical tasks, providing prompts, metric functions, and dataloaders for:
- Mechanistic benchmarks: Indirect Object Identification (IOI), Greater-Than, Double IO.
- Standard LLM benchmarks: MMLU, GLUE (SST-2), BoolQ, Winogrande, GSM8K, IFEval.
- Safety/Bias tasks: WMDP (Cybersecurity/Biology), TruthfulQA, Gender Bias.
Additionally, the paper validates its custom-data path using a raw, binary jailbreak-detection dataset to isolate and evaluate a model's refusal circuit.
Key Insights and Ideas
- Faithfulness $\neq$ Actionability: One of the paper's most striking findings is that a circuit's intrinsic faithfulness (how well it explains a behavior) does not necessarily predict how well it will perform in downstream applications like pruning. For example, Edge Attribution Patching with Integrated Gradients (EAP-IG) yields highly faithful circuits but ranks among the worst criteria for structural pruning on certain tasks.
- The Danger of Single-Metric Evaluation: The authors show that hard zero-ablation can cause "behavioral inversions," where an isolated circuit performs worse than a corrupt baseline. A framework that clamps negative scores to zero would completely hide this phenomenon, justifying CircuitKIT's multi-pillar, signed reporting approach.
- Budgets Over Identity in Fine-Tuning: In selective fine-tuning experiments, restricting gradient updates to a 30% budget successfully preserved the model's general language capabilities (coherence). Surprisingly, it didn't matter whether that 30% mask was derived from a precise circuit or chosen completely at random—the budget constraint itself provided the protection, not the circuit's identity.
Key Results
- Structural Pruning: On the Llama-3.2-3B-Instruct model evaluated on BoolQ at 30% sparsity, an
IBCircuit-guided pruning mask retained 98.6% of the base model's accuracy. This drastically outperformed standard weight-saliency baselines like Wanda and magnitude pruning, which collapsed to ~50% accuracy. - Quantization Predictors: The paper demonstrated that ablation faithfulness correlates strongly ($\rho = +0.73$) with accuracy retention under mixed-precision quantization, whereas standard patch faithfulness shows no significant correlation.
- Algorithmic Efficiency: Gradient-attribution methods within the framework proved highly scalable. On a GPT-2 Small IOI task, EAP discovered the circuit in 66 seconds, compared to 3,322 seconds for the search-based ACDC algorithm, while achieving identical causal patching recovery scores (1.000).
Limitations and Future Work
- Architecture-Specific Interventions: While circuit discovery and evaluation work out-of-the-box for any model supported by TransformerLens, downstream intervention modules rewrite weights directly. This requires architecture-specific registry entries, which currently only cover the Llama, Qwen, and Gemma families.
- Syntactic Corruption Constraints: The automated corruption synthesis tools assume identifiable syntactic structures. They can struggle with highly complex, instruction-tuned safety prompts, making user-supplied counterfactual columns the preferred fallback.
- Future Roadmap: The core team plans to transition to TransformerLens 3.x support and integrate Sparse Autoencoder (SAE) features to allow circuit analysis at the sub-neuron feature level.
Summary updated