> ## Documentation Index
> Fetch the complete documentation index at: https://circuitcheck.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# circuitcheck.tracer

> The circuit-tracer adapter. Needs torch and circuit-tracer.

## `TracerBackend(model, freeze_attention=False)`

Implements the validator's `InterventionBackend` over a circuit-tracer `ReplacementModel`:

* `logits` uses `model.feature_intervention`;
* `active_features` uses `model.get_activations(sparse=True)`;
* `decoder_norm` reads the transcoder's decoder rows.

**freeze\_attention** `bool` (default: False)

False lets attention respond to an intervention, as in the real model. True matches circuit-tracer's default of
direct effects through frozen attention.

`register(name, token_ids)` uses exact token ids for a prompt; pass `name` wherever a prompt is expected.

## `nodes_for_units(backend, prompt, units, positions="all")`

`FeatureNode`s for `(layer, feature)` units: at every position where they are active (`"all"`), at the last position
(`"last"`), or at given positions. Position 0 is skipped, since circuit-tracer zeroes it.

## `reconstruction_error(model, prompts, skip_first=1) -> list[float]`

Per-layer FVU of the transcoders' reconstruction of each MLP's output over every token of the prompts. Pass the
before and after lists to `diff_graphs(fvu_before=..., fvu_after=...)`.

```python gpu theme={null}
from circuitcheck.tracer import reconstruction_error

fvu_base = reconstruction_error(base_model, prompts)
fvu_tuned = reconstruction_error(tuned_model, prompts)
```

## `top_nodes(graph, n=30) -> list[FeatureNode]`

The `n` most influential feature nodes of a circuit-tracer `Graph`, with their activation and influence.

## `TracerLensBackend(model, contexts, r_lens=None, vocab_mask=None, ctx_len=64, skip_first=8, batch_size=8)`

Implements `circuitcheck.lens.SteeringBackend` over a `ReplacementModel` with per-layer transcoders:

* a feature's write is its decoder row; a neuron pole's is `sign * W_out[n]`;
* `logit` reads a write through the model's final norm and unembedding; `R` (when `r_lens` is given: a `.pt` path,
  `{"J": ...}` or a per-layer sequence of matrices) first multiplies it by the layer's Jacobian;
* steering adds the vector to the layer's MLP output at every position from `skip_first` on, in each context cut to
  `ctx_len` tokens, against an unsteered row in the same batch.

## `map_features_to_neurons(model, units, k=1) -> (poles, cosines)`

For `"layer:feature"` units, the `k` MLP neuron poles of the same layer whose writes are closest (by |cosine|) to the
feature's decoder row, for `circuitcheck.lens.edges_agree`. Report the cosines with any result built on the map.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.