Circuit-Tracer Backend Support#
Overview#
The circuit-tracer adapter integrates the circuit-tracer library into Interpretune’s multi-backend architecture. It supports generating attribution graphs that map causal pathways through a model using transcoders and replacement models.
Analysis Ops#
Five dispatcher-registered analysis ops form a complete circuit-tracer attribution pipeline:
Op Name |
Description |
Key Outputs |
|---|---|---|
|
Compute semantic concept direction from contrastive prompts |
Concept embedding vector |
|
Generate attribution graph via |
Graph nodes, edges, attribution targets |
|
Score feature nodes by influence on target logits |
Per-node influence scores |
|
Select top-K features by influence score |
Ranked feature list with metadata |
|
Verify causal effect via |
Pre/post intervention logit diffs |
Pipeline Flow#
concept_direction → compute_attribution_graph → graph_node_influence
↓
feature_intervention_forward ← extract_top_features
Ops compose via the standard AnalysisRunner / AnalysisOpDispatcher system. Each op’s outputs are stored
in AnalysisStore and available as inputs for downstream ops.
extract_top_features now also supports constrained (layer, feature_id) requests that were absent from the original
graph rows. In those cases it synthesizes candidate rows using same-layer positions when available, falls back to
global positions otherwise, and carries forward activation baselines so feature_intervention_forward can still build
meaningful intervention tuples. Optional activation overrides can be supplied by notebook experiment configs when a
specific feature should use a fixed intervention activation rather than a baseline heuristic.
When constrained selection is active, extract_top_features also preserves at least one representative row per
requested (layer, feature_id) pair before final top-N truncation. That guarantee is what keeps a synthesized missing
feature available to feature_intervention_forward even when other requested features occupy more positions.
For direct tensor steering outside the feature-intervention path, concept-direction notebook experiments now also use
model_fwd_intervention with explicit intervention mappings. This allows the runtime concept-direction vector to be
applied at non-default hook points such as blocks.0.hook_in in modes like project.
For hook naming, prefer the canonical TransformerBridge-style patterns documented in intervention_hook_pattern_support.md. Interpretune now expands the supported canonical and legacy HookedTransformer spellings in both directions before backend resolution, but the portable cross-backend subset is still intentionally smaller than the full TransformerLens v3 hook surface.
Backend Support#
Backend |
Status |
Model Types |
|---|---|---|
NNsight ( |
Supported |
Gemma-2, Gemma-3 |
TransformerLens ( |
Supported |
Gemma-2 |
Backend selection is automatic based on the module’s adapter context. Configurations with
(core, nnsight, circuit_tracer) use NNsight; (core, transformer_lens, circuit_tracer) use TransformerLens.
TransformerBridge limitation (tracked): the TransformerLens circuit-tracer backend requires the
legacy HookedTransformer path — upstream circuit-tracer’s TransformerLensReplacementModel
subclasses HookedTransformer directly, so TransformerLens v3 TransformerBridge mode is not
supported (use_bridge: false in the CT TL registry entries). Tracked in
interpretune#223 — revisit when upstream
circuit-tracer gains bridge support; historically this limitation (plus minor NNsight efficiencies and keeping
experimental variables fixed) is why the tests/nb_experiments concept-direction experimentation
standardized on the NNsight backend.
Backend Compatibility Matrix#
Model-backend capability surface (interpretune#201 task 5). Both backends implement the full
seven-method ModelBackend surface; the differences are in how and in edge-case behavior:
Capability ( |
TL (HookedTransformer) |
TL (TransformerBridge) |
NNsight |
|---|---|---|---|
|
✅ |
✅ |
✅ (trace-wrapped so input-key mapping applies) |
|
✅ |
✅ |
✅ (envoy reads via |
|
✅ |
✅ |
✅ trace-scoped splice; ⚠️ requesting the base activation at a spliced site double-reads the envoy input ( |
|
✅ |
✅ |
✅ (edit-context interventions) |
|
⚠️ sequential fallback (one pass per config; |
⚠️ sequential fallback |
✅ native batched invokes |
|
✅ |
✅ |
✅ |
|
✅ (legacy-alias gaps: e.g. |
✅ (same alias caveat) |
✅ |
Lifecycle contract (validated by tests/core/test_adapters_sae_lens.py::TestLatentModelHandleLifecycle
across all three substrates): splice paths leave no residual state — baseline outputs are
restored after any spliced call, repeated spliced invocations are stable (no hook/edit
accumulation), and the SAE-Lens acts_to_saes registry is empty before and after where exposed.
Additional constraint: TransformerBridge cannot be initialized from a config dict alone
(config-based init always uses HookedSAETransformer — see the adapter development guide’s
Pattern 3).
Demo Notebooks#
Notebook |
Description |
|---|---|
|
Full 5-op pipeline on Gemma-2-2b; |
|
Concept-direction-mediated, sign-aware multi-feature steering (feature-mediated + direct-hook paths) on the proven orange example; |
|
Basic adapter usage (graph generation, Neuronpedia upload) |
Cross-Backend Composition (planned demo — not yet in-tree)#
Cross-backend mixing is deferred to a subsequent workstream (the RTE-focused research direction
continues in interpretune#220); no
committed notebook currently demonstrates it — the planned demo is tracked in
interpretune#224. The planned demo design, which AnalysisStore
persistence already supports, composes independent sessions:
Stage A — GPT-2 SAE analysis via TransformerBridge: runs
logit_diffs_base, persists store to diskStage B — Gemma-2 CT analysis via NNsight: runs full 5-op pipeline, collects results
Stage C — CPU-only enrichment: reloads Store A from disk, combines summaries from both backends
Each stage would run in its own session with independent teardown, demonstrating that AnalysisStore
persistence (dataset.save_to_disk() / AnalysisStore(dataset=path)) enables cross-session
composition. The archived single-session RTE concept-direction flow remains recoverable from git
history (48f371b) if a runnable reference is needed before that demo lands.