From Features to Circuits: Transcoders, Crosscoders & Attribution Graphs
In Disentangling Polysemantic Superposition, we used TopK and JumpReLU Sparse Autoencoders (SAEs) to decompose a single residual-stream vector into monosemantic features. That answers what concepts exist at layer $\ell$ – but not how layer $\ell$ computes layer $\ell+1$. Because standard SAEs reconstruct a layer's activations from themselves, the nonlinear MLP sits outside the sparse basis, forcing circuit analysts to differentiate through dense opaque neurons. Transcoders (Dunefsky, Chlenski & Nanda, NeurIPS 2024, arXiv:2406.11944) and Crosscoders solve this by placing the sparse bottleneck across the MLP or across multiple layers simultaneously.
1. Why Transcoders Unlock Input-Invariant Feature Circuits
Instead of minimizing $\|\mathbf{x} - \mathrm{SAE}(\mathbf{x})\|_2^2$, a Transcoder takes the pre-MLP residual stream $\mathbf{x}_{\text{in}}^{(\ell)}$ and predicts the post-MLP output $\mathbf{y}_{\text{out}}^{(\ell)} = \mathrm{MLP}^{(\ell)}(\mathbf{x}_{\text{in}}^{(\ell)})$ through a wide sparse latent layer $\mathbf{f}^{(\ell)} \in \mathbb{R}^{M}_{\ge 0}$ ($M \gg d$):
Look at that factorization: once the MLP is replaced by a Transcoder, the direct contribution from feature $i$ in layer $\ell$ to feature $j$ in layer $\ell+1$ splits cleanly into a scalar activation $f_i^{(\ell)}(\mathbf{x})$ times a static, prompt-independent inner product $\mathbf{w}_{\text{dec}, i}^{(\ell)} \cdot \mathbf{w}_{\text{enc}, j}^{(\ell+1)}$. For attention-mediated paths, freezing the attention pattern $A^{(h)}$ yields a linear OV-circuit matrix $W_{OV}^{(h)}$ so the exact attribution weight is $\mathbf{w}_{\text{dec}, i}^{(\ell)} W_{OV}^{(h)} \mathbf{w}_{\text{enc}, j}^{(\ell')}$.
2. Crosscoders & Model Diffing (Base vs. RL-Tuned Checkpoints)
A Crosscoder generalizes the sparse encoder to read from a set of activation streams $\{\mathbf{x}^{(k)}\}_{k=1}^K$ – either layers $1\dots L$ of one model, or the same layer in a base model and an RL-aligned model – and decode back into all $K$ streams with separate decoders $W_{\text{dec}}^{(k)}$. By inspecting the decoder norm ratio $\|\mathbf{w}_{\text{dec}, i}^{(\text{chat})}\| / (\|\mathbf{w}_{\text{dec}, i}^{(\text{base})}\| + \|\mathbf{w}_{\text{dec}, i}^{(\text{chat})}\|)$, you immediately isolate chat-exclusive features (refusal triggers, sycophancy detectors, chain-of-thought verification tokens) that were created during post-training.
💻 Python: JumpReLU Transcoder & Input-Invariant Circuit Pull-Back WeightPyTorch
import math
import torch
import torch.nn as nn
class JumpReLUTranscoder(nn.Module):
"""Sparse MLP replacement: maps MLP input x_in -> sparse features -> MLP output y_out."""
def __init__(self, d_model: int, d_features: int, init_threshold: float = 0.1):
super().__init__()
self.W_enc = nn.Parameter(torch.randn(d_model, d_features) * (d_model ** -0.5))
self.b_enc = nn.Parameter(torch.zeros(d_features))
self.W_dec = nn.Parameter(torch.randn(d_features, d_model) * (d_features ** -0.5))
self.b_dec = nn.Parameter(torch.zeros(d_model))
self.log_theta = nn.Parameter(torch.full((d_features,), math.log(init_threshold)))
def encode(self, x_in: torch.Tensor) -> torch.Tensor:
pre = x_in @ self.W_enc + self.b_enc
theta = self.log_theta.exp()
# Inference forward; training uses a bandwidth STE kernel for log_theta gradients
return pre * (pre > theta).to(pre.dtype)
def forward(self, x_in: torch.Tensor):
f = self.encode(x_in)
y_hat = f @ self.W_dec + self.b_dec
return y_hat, f
@torch.no_grad()
def input_invariant_circuit_weight(tc_src: JumpReLUTranscoder, tc_dst: JumpReLUTranscoder,
i_src: int, j_dst: int) -> float:
"""Direct residual-stream pull-back weight between transcoder feature i (layer L) and j (layer L+1)."""
return float(torch.dot(tc_src.W_dec[i_src], tc_dst.W_enc[:, j_dst]))
| Tool | Input → Output | Solves Superposition? | Enables Direct Circuit Graph? |
|---|---|---|---|
| TopK / JumpReLU SAE | $\mathbf{x}^{(\ell)} \to \hat{\mathbf{x}}^{(\ell)}$ | Yes | No (MLP nonlinearity blocks weight pull-back) |
| Transcoder | $\mathbf{x}_{\text{in}}^{(\ell)} \to \hat{\mathbf{y}}_{\text{MLP}}^{(\ell)}$ | Yes | Yes (exact $W_{\text{dec}}^{(\ell)} \cdot W_{\text{enc}}^{(\ell+1)}$ edges) |
| Crosscoder | $\{\mathbf{x}^{(k)}\} \to \{\hat{\mathbf{x}}^{(k)}\}$ | Yes (cross-layer/model) | Tracks feature birth, persistence & model diffs |