pulsatrix 1.1.0
Loading...
Searching...
No Matches
circuit_tracing.hpp File Reference

Attribution graphs with cross-layer transcoders (FEAT-10), after Ameisen, Lindsey et al., "Circuit Tracing: Revealing Computational Graphs in Language Models" (Transformer Circuits, 2025) and its open implementation, circuit-tracer (github.com/decoderesearch/circuit-tracer). Each MLP is replaced by a transcoder's features plus an error term, attention patterns and normalization scales are frozen, and what is left is linear: the graph's edges are exact attributions between features, errors, token embeddings and output logits. More...

#include <cstdint>
#include <string>
#include <vector>
#include "pulsatrix/causal_lm.hpp"
#include "pulsatrix/tensor.hpp"
#include "pulsatrix/viz/attribution_graph.hpp"
Include dependency graph for circuit_tracing.hpp:

Go to the source code of this file.

Classes

class  pulsatrix::CrossLayerTranscoder
 A cross-layer transcoder (CLT) over a model's L MLPs, or a set of per-layer transcoders (PLTs, a CLT whose features only write to their own layer). More...
 
struct  pulsatrix::CircuitTraceOptions
 
struct  pulsatrix::CircuitTrace
 An attribution graph before pruning: every active feature, error and token, the explained logits, and the full adjacency. More...
 
struct  pulsatrix::CircuitTrace::Feature
 
struct  pulsatrix::CircuitScores
 Circuit-tracer's scores of a graph. More...
 

Namespaces

namespace  pulsatrix
 

Functions

CrossLayerTranscoder pulsatrix::LoadTranscoders (const std::string &directory, int64_t num_layers, DeviceBackend *backend)
 Loads transcoders from a directory in one of the layouts circuit-tracer reads, with bf16/fp16 weights upcast:
 
CircuitTrace pulsatrix::TraceCircuit (CausalLM &model, const CrossLayerTranscoder &transcoder, const std::vector< int64_t > &ids, const CircuitTraceOptions &options={})
 Runs the model on ids (one sequence) with transcoder in place of its MLPs, and attributes the salient logits and every active feature through the frozen model.
 
CircuitScores pulsatrix::ScoreCircuit (const CircuitTrace &trace)
 Circuit-tracer's replacement and completeness scores (graph.py).
 
AttributionGraph pulsatrix::ToAttributionGraph (const CircuitTrace &trace, const CircuitTraceOptions &options, const std::vector< std::string > &logit_labels={})
 The graph for Neuronpedia's or circuit-tracer's viewer, pruned as circuit-tracer prunes: nodes by indirect influence on the logits (node_threshold), then edges by influence-weighted score (edge_threshold), then nodes left without edges. Node ids, types and labels follow circuit-tracer ("<layer>_<feature>_<position>", "cross layer transcoder", "mlp reconstruction error", "E_<token>_<position>", "<L+1>_<token>_<position>" for logits).
 

Detailed Description

Attribution graphs with cross-layer transcoders (FEAT-10), after Ameisen, Lindsey et al., "Circuit Tracing: Revealing Computational Graphs in Language Models" (Transformer Circuits, 2025) and its open implementation, circuit-tracer (github.com/decoderesearch/circuit-tracer). Each MLP is replaced by a transcoder's features plus an error term, attention patterns and normalization scales are frozen, and what is left is linear: the graph's edges are exact attributions between features, errors, token embeddings and output logits.