TraceCXR Interactive explorer →
Research update · July 2, 2026

Circuit-Tracing MedGemma

What does a medical vision–language model read from a chest X-ray? A look inside MedGemma’s findings through frozen-attention circuit tracing.

Kevin Jin·Duke University·working draft

An update on what I’ve been working on. Numbers are from banked experiments; figures and citations are being finalized. Background: this assumes the circuit-tracing method from Anthropic’s Circuit Tracing and On the Biology of a Large Language Model.

Abstract

We build, to our knowledge, the first image-token-aware cross-layer transcoder and frozen-attention attribution graph for a medical vision–language model (MedGemma), and use them as a faithfulness microscope for chest-X-ray interpretation. The transcoder is faithful where it matters: substituting it for every MLP in the model reproduces the original next token 100% of the time on image tokens (KL 0.044). Within the frozen-attention attribution model, MedGemma’s decision-related attribution concentrates predominantly in the text/prompt stream, with image attribution a secondary, attention-mediated contribution, consistent with its behavior: it hallucinates findings given no image (rate ≈ 1.0) and persists them under occlusion (0.49). Across five intervention methods the finding decision resists localization to a single clampable feature, consistent with a distributed representation. And we localize a real clinical bias, over-diagnosing cardiomegaly on portable (AP) films (0.73 vs. 0.00 on standard films), to the attention pattern: swapping in a standard-film attention pattern removes the false positive (0.62 → 0.00), consistent with an attention-routing (QK) locus, one that frozen-attention attribution graphs cannot observe by construction. We release the transcoder and an interactive explorer.

1Introduction#

Medical vision–language models are being adapted for radiology, and with them come the faithfulness failures the field has long documented in medical imaging: models that assert findings without visual support, and that exploit acquisition shortcuts: scanner, view-position, or device cues standing in for pathology.1

Behavioral benchmarks can detect these failures but not locate them. Understanding (and eventually fixing) them calls for interpretability tools that reach inside the model. For generative medical VLMs, those tools barely exist: sparse dictionaries have been trained on single medical models at the vision-encoder level,6 and circuit tracing with transcoders and attribution graphs has been shown on general Gemma-class VLMs in concurrent work,5 but with per-layer transcoders, and outside medicine. No prior work, to our knowledge, trains a cross-layer transcoder that reads image tokens inside a medical VLM, nor builds an attribution graph for one. We do both, and use the resulting microscope to ask what the attribution graphs reveal about MedGemma’s computation on a chest X-ray.

We find three things. Within the frozen-attention attribution model, decision-related attribution concentrates in the text/prompt prior rather than the image (§6). The decision resists localization to a single clampable feature, consistent with a distributed representation (§7). And a real clinical shortcut is localized to the attention pattern, outside the reach of feature-level attribution (§8).


2Background: transcoders and attribution graphs#

Our tools come from the sparse-dictionary and circuit-tracing line of mechanistic interpretability; we summarize them here for readers new to the area, and use them without claiming them.

Sparse features. A sparse autoencoder decomposes a model's activation vector into a large dictionary of features of which only a few are active per token. Trained with a sparsity constraint, the features tend to be monosemantic, each corresponds to a single human-interpretable concept.4 A transcoder is a variant that, rather than reconstructing one activation, reads the input to a component (here a decoder MLP) and predicts its output: a sparse, interpretable stand-in for the MLP's computation.

Cross-layer transcoders. In a cross-layer transcoder, each feature's decoder writes not just to its own layer but to all downstream layers, capturing structure that spans layers.2 This is the substrate the attribution-graph method is built on. We use a Top-K activation (K = 32, 2048 features per layer), which fixes the number of active features per token and yields monosemantic units.

The local replacement model. To trace why a model produced an output, the circuit-tracing method3 substitutes the transcoder for the model's MLPs and adds a frozen per-position error term, yielding a replacement model that reproduces the original logits but computes through interpretable features. Freezing the attention patterns and normalization scales at the values they take on a specific input makes the path from any feature to any downstream feature or logit linear, so attribution edges become exact and additive: the contributions of all features sum to the logit. The result is an attribution graph from inputs, through features, to the output. A known cost, central to §8, is that freezing the attention pattern makes the method blind to computations carried by the pattern itself (“QK circuits”).


3The instrument: a cross-layer transcoder for MedGemma#

We train a cross-layer transcoder over all 34 layers of MedGemma,7 on activations captured on-the-fly as the model runs over chest X-rays and reports, so the dictionary sees both image and text tokens. The property that makes it a usable instrument is faithfulness: if we substitute the transcoder's reconstruction for every MLP and drop the error term, does the model still behave the same? On image tokens (the substrate for finding decisions), the substituted model reproduces the original top-1 next token 100% of the time (n = 60 held-out image/report pairs, KL 0.044). Within this replacement model, then, the computation turning image evidence into a finding runs through features we can read and manipulate. A span-ablation confirms the cross-layer reach is used: restricting each feature to short-range writes more than doubles image reconstruction error.

INPUT WHAT WE READ Chest X-ray+ report MedGemma(34 layers) Cross-layertranscoder Attributiongraph run &capture replacethe MLPs freezeattention
Figure 1. The instrument, in four steps. (1) Run MedGemma over a chest X-ray and its report and capture activations. (2) (3) Replace the model's MLPs with a cross-layer transcoder, a sparse, readable stand-in for that computation. (4) Freeze the attention patterns and the substituted model becomes an attribution graph from features to the finding (§5). The transcoder (highlighted) is the piece we build; the graph is what we read.

4The features encode real radiology#

A faithful dictionary is only useful if its features mean something. Labeling the top features by their top-activating image patches returns concrete radiological concepts, not noise: costophrenic angle / lung base, mediastinal contour, tubes and catheters, shoulder and spine landmarks, alongside acquisition artifacts. In a late layer, 25 of 30 top features receive a specific anatomical or acquisition label (a mid-layer is sparser, 10 of 18). Contrasting finding-positive against clean images yields finding-selective features (pleural effusion AUC 0.86, pneumothorax 0.88) that localize to the expected anatomy.

Figure 2. Six dictionary features, each shown by its top-activating image patches. They pick out concrete radiology, anatomy (lung base, mediastinum, shoulder, spine), hardware (tubes and catheters), and acquisition cues (the “AP PORTABLE” stamp that drives §8). Browse the full set in the interactive explorer.

5Circuit tracing: frozen-attention attribution#

A naive attribution (activation × gradient of a finding logit through the model with attention and layernorm live) is a first-order approximation whose edge weights do not conserve, and which yields only a single hop. We instead build the local replacement model (§2) and freeze the attention patterns and RMSNorm denominators. With those nonlinearities held constant the model is exactly linear in the features, so edges are exact and additive and the full multi-hop feature→feature graph becomes available.

We validate the linearization directly. The substituted-and-frozen model reproduces the original logit exactly; scaling the features traces a perfectly affine response (deviation 0.09 vs. 11.2 for the un-frozen model, a ~120× reduction); and the feature edge weights sum to the logit change to numerical tolerance. Two caveats shape how we read the graphs. First, the first-token attention sink carries large, generic attribution and must be excluded. Second (the crux of §8), freezing the attention pattern makes the method blind to effects that live in the pattern itself.

EARLIER → FINDING image text / prompt cardiomegaly image feature text / prompt feature
Figure 3. Circuit tracing, schematically. With attention and normalization frozen, the model is linear in its features, so a multi-hop graph from image and text features to the finding logit becomes exact and additive. The step this cannot see, the attention pattern itself, is the subject of §8. Step through real graphs in the interactive explorer.

6Decision-related attribution concentrates in the text stream#

We trace the logit of the answer token (“Yes”) and read the graph one hop back: the features that directly write to the decision sit at text positions. This single-hop view has two well-known pitfalls, both of which we control for. The highest-attribution features are attention-sink / structural tokens, which we exclude; and a text-position feature may have read the image one hop earlier, via attention. Tracing each decision feature's preactivation to its own sources, the image is a small and variable minority contributor: across findings the mean image-source share runs from ≈ 3% (effusion) to ≈ 18% (genuine cardiomegaly), typically around 10%.

We deliberately do not headline a single ratio, the attribution remains partly entangled with residual structural signal, so cleanly isolating the semantic finding circuit is an open problem (§10). What is robust is the direction: within this attribution model MedGemma's finding decision draws primarily on the text/prompt stream, with image evidence a secondary, attention-mediated contribution. This is consistent with the model's behavior, which needs no attribution to interpret, it hallucinates findings with no image at all (rate ≈ 1.0) and continues to assert a finding after its supporting region is occluded (persistence 0.49).10

text / prompt  ~90% ~10% image
Figure 4. Where the evidence comes from. Tracing each decision feature back to its own sources, the image is a minority contributor, roughly 10% on average (3% for effusion up to 18% for genuine cardiomegaly); the finding rests mainly on the text/prompt stream. We report the direction, not a precise ratio (§10).
Whatever image contribution the graph attributes is the value-pathway (OV) route, image content read through attention patterns held fixed here. It does not capture the influence of the attention pattern itself (the QK route), which the method holds constant by construction. The cardiomegaly shortcut (§8) falls precisely in that blind spot.

7The finding decision resists localization to a clampable feature#

A natural hope, and the premise of much feature-steering work, is that a finding corresponds to a feature you can turn off. It does not. Across five independent methods of choosing which features to clamp (ranking by contrastive selectivity, by gradient attribution, by image-contrast and prompt-contrast differencing, and by a negative-steering scale sweep), clamping the candidate features fails to controllably steer the finding decision. When suppression does move the probability, it does so with a loss of output coherence rather than by cleanly flipping the answer; a positive control confirms the intervention machinery works, so the null appears to be a property of the model, not a broken pipeline.

The sharpest form of the test uses the attribution graph against itself: take the very features the graph ranks as driving a finding’s logit and clamp those, against a random-feature control and a coherence check (did the edit flip the answer, or just break the model into out-of-distribution garbage?). The result is fragile and finding-dependent, not a clean lever. It is most telling on the headline no-image cardiomegaly hallucination, verified in the reason-then-probe framing where it actually fires: clamping the graph’s own top text features does not suppress the false finding at all, it nudges it slightly up.

finding (framing)P(yes): base → clampedrandom controlcoherentclean lever?
Pneumothorax (single-shot)0.85 → 0.590.85 → 0.8471%partial
Effusion (single-shot)0.50 → 0.320.50 → 0.4836%no — breaks
Cardiomegaly (reason-then-probe)0.96 → 0.990.96 → 0.96no
Table 1. Clamping the attribution graph’s own top finding-features. Only pneumothorax shows a partial causal handle, and even there ~29% of cases fall out of the yes/no regime; effusion’s apparent drop is the model breaking (36% coherent), not clean suppression; and on the headline reason-then-probe cardiomegaly hallucination, clamping the features slightly raises the false finding. Those top-attribution features are the model’s “no / caution” direction, so removing them lifts “yes”, consistent with the false finding being sustained by the fabricated reasoning text rather than a clampable feature.

We read this as evidence of distributed representation: across these methods, no small set of clampable features controllably governs the finding decision, which matters for safety (feature steering is not a reliable control here), and sets up §8: if the decision is not a sparse feature set, where does a specific, reproducible shortcut live?


8A clinical shortcut localized to the attention pattern#

MedGemma exhibits a textbook acquisition shortcut: on cardiomegaly-negative chest X-rays it answers “cardiomegaly: yes” 73% of the time on AP / portable films and 0% on PA / standard films. The correlation is not mysterious. Portable (AP) films are shot at the bedside for acutely ill, immobile patients, a group with a much higher prevalence of genuine heart disease; the AP projection also magnifies the cardiac silhouette. So across a training set “this is a portable film” becomes a strong statistical proxy for cardiomegaly, and a model can lean on that proxy instead of the heart itself. It is a clean, reproducible, clinically consequential bias, and an ideal test of whether our microscope can find and explain a real failure.

The feature-level tools locate the cue but not the cause. Contrasting AP against PA on cardiomegaly-negative images yields cleanly view-selective features (top AUC 0.97), the model plainly encodes “this is a portable film.” Yet clamping those features does nothing to the decision (a random-feature control is identical), and the attribution of §6 shows the decision running through generic text features that do not encode view position. The view is represented, the decision is elsewhere, and clamping the representation is inert, a genuine puzzle.

The resolution points to the attention pattern rather than the features: to where the model attends. We test this directly: run a portable-film image but replace every attention layer's pattern with the pattern from a standard-film image, keeping the portable film's own content.

Portable chest X-ray with the decision token's attention as a heatmap

P = 0.98  →  0.00

Figure 5. A portable (AP) film that MedGemma wrongly calls cardiomegaly-positive, with the decision token's attention over the image shown as a heatmap. Replacing this film's attention pattern with a standard-film pattern (keeping the film's own content) drops P(cardiomegaly) from 0.98 to 0.00, consistent with the shortcut residing in where the model looks rather than in the features.

The false positive collapses, 0.62 → 0.00 (mean over 8 held-out AP/PA pairs); the reverse (standard-film content, portable-film attention) induces it, 0.00 → 0.17. This is consistent with an attention-routing (QK) effect: the film type changes what the model attends to, shifting the finding independent of detectable feature-level changes.

This carries a two-fold point. First, a clean mechanistic account of a real clinical bias, with a causal handle that removes it. Second, and more general: frozen-attention attribution (the basis of attribution graphs, ours included) is blind to this by construction. A shortcut that is the attention pattern leaves no trace in the feature→logit graph. We surface this as a documented boundary of the method: some faithfulness failures are attention-pattern effects, outside feature-level attribution, and identifying them requires an attention-pattern intervention of the kind we use here. You can step through the eight AP/PA pairs live in the interactive explorer.



10Discussion and limitations#

The picture, within frozen-attention attribution, is of a medical VLM whose chest-X-ray findings attribute more to its text/report prior and to acquisition cues than to localized image evidence, an unfaithfulness that behavioral benchmarks see but cannot attribute, and that our microscope localizes. We flag the limitations candidly.

Quantifying the image contribution is method-sensitive. Our multi-hop estimate (§6) is small but noisy and remains partly entangled with attention-sink / structural positions we exclude only heuristically; we report the direction within the frozen-attention model and decline to headline a ratio. The QK blind spot is fundamental: frozen-attention attribution cannot see shortcuts carried by the attention pattern; QK-aware attribution is future work. Faithfulness is scoped to the image→finding computation: the transcoder reproduces the model on image tokens (100%) but not free-form text generation (8% agreement). Scale and generality: a single model, on public NIH/CheXpert data, with no external out-of-distribution validation yet, and the attention-pattern intervention is a small n; a second model and external data are the clearest next steps.

Future work. The most compelling extension is cross-model: do independently trained medical VLMs converge on the same interpretable features, and does the clinical-vs-shortcut distinction predict which features are shared? That turns this single-model microscope into a test of feature-level representational universality in medicine.9

Selected references
  1. Shortcut learning in medical imaging. Zech et al., Variable generalization performance of a deep learning model to detect pneumonia in chest radiographs. PLOS Medicine, 2018.  ·  DeGrave et al., AI for radiographic COVID-19 detection selects shortcuts over signal. Nature Machine Intelligence, 2021.  ·  Oakden-Rayner et al., Hidden Stratification Causes Clinically Meaningful Failures in Machine Learning for Medical Imaging. ACM CHIL, 2020.
  2. Lindsey, Templeton et al., Sparse Crosscoders for Cross-Layer Features and Model Diffing. Transformer Circuits Thread, 2024.
  3. Ameisen, Lindsey et al., Circuit Tracing: Revealing Computational Graphs in Language Models & On the Biology of a Large Language Model. Transformer Circuits Thread, 2025.
  4. Templeton et al., Scaling Monosemanticity: Extracting Interpretable Features from Claude 3 Sonnet. Transformer Circuits Thread, 2024.
  5. Circuit tracing in vision–language models. Transcoders Trace Visual Grounding and Hallucinations in Vision-Language Models, 2026 (preprint).  ·  UIUC MONET et al., Circuit Tracing in Vision-Language Models, 2026 (preprint): per-layer transcoders and attribution graphs on general Gemma-class VLMs.
  6. Interpretability of medical models. SAE-Rad: An X-Ray Is Worth 15 Features: Sparse Autoencoders for Interpretable Radiology Report Generation, 2024.  ·  MedSAE: Dissecting MedCLIP Representations with Sparse Autoencoders, 2025.
  7. Google DeepMind & Google Research, MedGemma Technical Report, 2025.
  8. Marks et al., Sparse Feature Circuits: Discovering and Editing Interpretable Causal Graphs in Language Models. ICLR, 2025.
  9. Representational universality. Huh et al., The Platonic Representation Hypothesis, ICML 2024.  ·  Thasarathan et al., Universal Sparse Autoencoders: Interpretable Cross-Model Concept Alignment, ICML 2025.  ·  Lan et al., Sparse Autoencoders Reveal Universal Feature Spaces Across Large Language Models, 2024.
  10. Clinical reasoning and visual attention in CXR. Sharma, Long, Shih et al., CheXthought: A global multimodal dataset of clinical chain-of-thought reasoning and visual attention for chest X-ray interpretation. arXiv:2604.26288, 2026.

Working draft; some 2026 preprints are cited by title pending final bibliographic verification. Full references and the LaTeX source accompany the release.