Trace Interactive explorer →
Research update · October 2026

Circuit-Tracing MedGemma

A cross-layer transcoder for a medical vision–language model: how it was built, how faithful it is, and what it caught.

Kevin Jin·Duke University

The method follows Anthropic’s Circuit Tracing. Full details accompany the release.

Summary

MedGemma is Google’s open vision–language model for medical images. We trained a cross-layer transcoder (CLT) over all 34 of its layers, with 3.30B trained parameters: a sparse, interpretable replacement for the model’s MLPs that reads image tokens as well as text. To our knowledge it is the first CLT released for a medical VLM. Substituted for every MLP, it reproduces MedGemma’s next token on 60 of 60 held-out chest X-rays, and with attention frozen it yields exact attribution graphs from image features to the answer. Using it to edit features, we found that the standard way of scoring a yes/no answer, by its first token, can miss most of an edit’s effect on what the model writes: of the answers the edit flipped to “no”, the score still said yes on 28 of 32. The weights and code are public, and the graphs can be browsed in the interactive explorer.

1What we built#

Much of a transformer’s computation happens in its MLP layers, but their activations are dense vectors that do not line up with human concepts. A transcoder is trained to predict each MLP’s output from its input through a large, sparse dictionary of features. Of the 2,048 features per layer in ours, only about ten fire on a given token, and each tends to track one thing: the lung base, a chest tube, the “AP PORTABLE” stamp. With the transcoder standing in for the MLPs, the model’s computation can be read feature by feature.

MLP activations dense, unlabeled transcoder Sparse features lung base tube AP stamp ~10 of 2,048 active, each interpretable
Figure 1. What a transcoder does. The same layer, re-expressed as a few active features out of a large dictionary (illustrative).

Ours is cross-layer: a feature read at one layer writes to every layer after it, so a single feature can account for computation the model spreads across depth. This is the substrate the attribution-graph method was built around. The CLT uses TopK sparsity (k = 32) with 2,048 features on each of MedGemma 1.5’s 34 layers and 3.30B trained parameters, trained from scratch on one H100 on activations streamed live from the model as it read NIH ChestX-ray14 films and CheXpert Plus reports. As a single tensor the decoder would exceed 231 elements and overflow the int32 indexing in bitsandbytes’ 8-bit Adam, so it is stored as one tensor per write offset and decoded as a running sum, which also keeps activation memory flat.

INPUT WHAT WE READ Chest X-ray+ report MedGemma(34 layers) Cross-layertranscoder Attributiongraph run &capture replacethe MLPs freezeattention
Figure 2. The pipeline. Capture MedGemma’s activations on an X-ray and report, replace its MLPs with the CLT, then freeze attention to get an exact graph from features to the answer (§4).

2Images need their own dictionary#

MedGemma sees each X-ray as 256 image tokens placed ahead of the text. Their activations look nothing like text’s, and a transcoder trained the usual way, on text alone, does not transfer. In a four-layer prototype, its fraction of variance unexplained (FVU, the share of the MLP output it fails to reconstruct) on image tokens is 1.13, worse than simply predicting the mean, and at layer 0 it is 354× worse than on text. Balancing image and text tokens in every training batch brings image FVU to 0.19 at no cost to text.

1.0 = guessing the average 0.191.13 0.200.19 Text only Text + images text tokens image tokens
Figure 3. Reconstruction error (FVU; lower is better) on each kind of token, by what the prototype transcoder was trained on. A text-only dictionary cannot represent what the model does with the X-ray.

3How faithful it is#

The standard test is replacement: substitute the transcoder for all 34 MLPs, with no correction term, and check whether the model still behaves the same. On 60 held-out image/report pairs the replacement model predicts the original top-1 next token every time, with a mean KL divergence of 0.044 between the two output distributions.

60 / 60 same next token
Figure 4. Each dot is a held-out chest X-ray on which the replacement model matches the original model’s next token.

This holds on the prompt the CLT was trained with. On a constrained yes/no question the text side degrades (KL 13.5), while image-token reconstruction is identical across prompts: under causal masking the image tokens come before the question and cannot see it. Retraining on mixed prompts cuts the probe KL 13.5×, while doubling the dictionary does not help, so the bottleneck is prompt coverage, not capacity.

The cross-layer design is what buys this. A per-layer transcoder, in which each feature writes only to its own layer, reconstructs image tokens as well at a ninth of the size (FVU 0.278 versus 0.287), but substituted for every MLP its small errors compound across 34 layers: 93% agreement, KL 0.161.


4Exact attribution graphs#

To explain one answer, we build a local replacement model for that X-ray: freeze the attention patterns and normalization at the values they take on this input, and add back the small per-position gap between the CLT and the true MLPs. What is left is linear in the features, so every edge in the resulting attribution graph is exact, and the edges into the answer sum to its logit (the model’s raw score for that token). We checked each property: the logit matches the original exactly; scaling features moves it along a straight line (deviation 0.094, versus 11.2 with attention left live, about 120× closer); and the edges sum to the logit within bf16 precision.

EARLY LAYERS ANSWER “Yes” image feature text feature
Figure 5. An attribution graph, simplified. Nodes are features; each edge is how much one feature contributes to the next, flowing toward the answer. Freezing attention makes these contributions exact and additive, at a cost: where the model looks is held fixed, so effects carried by the attention pattern itself are invisible. Step through real graphs in the explorer.

5What the features see#

Looking at the image patches that activate each feature most turns up concrete radiology: lung bases, the mediastinum, tubes and catheters, shoulders and spine, and acquisition cues such as the “AP PORTABLE” stamp on bedside films. The features also know where the evidence is. Blacking out one small block of an X-ray at a time shows which regions actually drive the answer: on 20 films where MedGemma falsely calls an enlarged heart, the decisive block is central on all 20 and sits at the left heart border on 16. A linear probe on the features picks out such regions with AUC 0.88, against 0.62 for raw pixels and 0.48 for a shuffled-label control.

Figure 6. Six features, each shown by the image patches that activate it most. Browse the full set in the explorer.

6What the first token misses#

The usual way to test features is to edit them and watch the answer. On a yes/no question the answer is usually scored at the first output token, as P(yes) normalized over “yes” and “no” (Pnorm), the probability form of the logit difference that interpretability work recommends. We took 40 portable (AP) films on which MedGemma falsely calls cardiomegaly (an enlarged heart) and suppressed the 80 transcoder features most active on the image by reversing their sign. Pnorm barely moves, from 0.976 to 0.933. The written answers do move: of 50 sampled answers per film, the share saying yes falls from 0.95 to 0.73.

yes no neither (first token: mostly “Based”) Pnorm No editfirst token0.82written0.950.98Suppress 80 featuresfirst token0.56written0.730.93Black out the evidence blockfirst token0.20written0.290.26 00.51
Figure 7. First-token probabilities against the share of 50 sampled written answers, mean over 40 films. Suppression moves the first token from “yes” to other openings, not to “no”, so Pnorm stays high while the written answers shift. Blacking out the image block the call depends on moves both.
One film after suppression, with Pnorm at 0.982: “Based on the image, the chest X-ray shows a normal heart size. Therefore, the answer is No.” Unedited, the model writes “Yes, the chest X-ray shows cardiomegaly. The heart appears enlarged.”

The miss shows up answer by answer, not only on average. Across three edit strengths, 32 of 120 greedy (most likely) answers turn from yes to no, and Pnorm still says yes on 28 of them. Covering the evidence block instead turns 53 of 120 to no, and Pnorm misses only 3. The gap was confirmed by pre-registered tests, including on films chosen by their written answer rather than by any first-token score.

Suppress features32 flips, 28 missed Occlude evidence53 flips, 3 missed score still says yes score says no
Figure 8. Each dot is a greedy answer that flipped from yes to no. Under feature suppression the first-token score misses almost all of them; under occlusion it catches almost all.

Two routes to an answer

MedGemma either answers “Yes” at once or reasons first (“Based on the image, …”) and concludes later. The first token only shows which route it takes. Suppression moves answers onto the reasoning route (18% to 44%) and makes that reasoning end in yes less often (73% to 39%), while direct answers still say yes 99% of the time. Pnorm compares only “yes” with “no” at the first token, so it registers neither change. The raw P(yes) does fall with the answers (0.82 to 0.56), but by coincidence: the written yes rate is about the raw P(yes) plus the share that reasons first times how often that reasoning ends in yes.

Before0.82After0.56 decided after the first token “Yes” at once reasons, then yes then no no verdict
Figure 9. How answers start and end, before and after suppression. The shift happens in the part of the answer written after the first token.

A candidate cause

Circuit-tracing tools apply an edit by fixing each MLP’s output at its unedited value plus the edit’s decoded change; we call this the clamp. The first answer token is predicted at the last prompt position, where the clamped MLPs cannot respond to the edit. Every later token is predicted at a new position, where they can. If this mismatch is the cause, the first token should move with the answers once every MLP recomputes. On the live model at the same strengths, 66–87% of samples stop giving any answer, so that test cannot decide. At a milder edit (each activation scaled by 0.6), the written yes rate falls 0.75 and Pnorm falls with it (difference −0.005, 95% CI −0.07 to +0.06). That is what the hypothesis predicts, but the two edits differ in size and the live edit also frees the image positions, so it is not proof.

The gap recurs on correct calls of effusion (the yes rate falls 0.17) and pneumothorax (0.21), where Pnorm again misreads; correct cardiomegaly calls barely respond (0.04). The edit is also not specific to the finding: the top-80 rule picks nearly the same features whichever finding is asked about (Jaccard overlap 0.94). The practical point is narrower and firmer: score feature edits on sampled answers, not on the first token.


7Limits#

One model, one transcoder, one dataset, and tens of films per group. The released CLT is faithful on its training prompt, not yet on arbitrary questions (§3), so every edit adds back the reconstruction error recorded on the unedited input. Whether the clamp causes the readout gap is open; freeing only the MLPs at the answer position would isolate it. Feature labels come from informal inspection of top-activating patches and have not been reviewed by a radiologist.

References
  1. Lindsey, Templeton et al., Sparse Crosscoders for Cross-Layer Features and Model Diffing. Transformer Circuits Thread, 2024.
  2. Ameisen, Lindsey et al., Circuit Tracing: Revealing Computational Graphs in Language Models & On the Biology of a Large Language Model. Transformer Circuits Thread, 2025.
  3. Templeton et al., Scaling Monosemanticity: Extracting Interpretable Features from Claude 3 Sonnet. Transformer Circuits Thread, 2024.
  4. Transcoders in vision–language models. Transcoders Trace Visual Grounding and Hallucinations in Vision-Language Models, 2026 (preprint).  ·  Circuit Tracing in Vision-Language Models, 2026 (preprint): per-layer transcoders and attribution graphs on general Gemma-class VLMs.
  5. Google DeepMind & Google Research, MedGemma Technical Report, 2025.