Phase C · mechanistic interpretability

Sparse autoencoders

Cunningham et al. 2023; Bricken et al. 2023; Templeton et al. 2024

← back to the method catalogue

What it does?

A sparse autoencoder tries to break a tangled state into clean, single-meaning features. It is a small neural network trained to reconstruct the recorded state through a wide but sparsely active hidden layer, so that only a few hidden units fire for any given input. The hope is that each hidden unit becomes 'monosemantic', standing for one human-meaningful concept, which would untangle the superposition thought to hide features inside neural activations. Sparse autoencoders are a central, fast-growing tool in mechanistic interpretability. We train one on the recorded RAM trajectory of the VCS and match its learned features to known, verified game-variable cells. On this small state the reconstruction is nearly perfect and every game-variable cell the SAE is asked to match gets a matching feature. By the metric the field usually uses to claim a feature 'is' a concept, the SAE looks like a complete success. The VCS lets us apply a stronger test. We ablate the matched feature, re-run the real ROM, and ask whether the computation it is supposed to name actually changes. Often it does not: the feature is named but causally unused: clamping it and re-running changes nothing. The sparse autoencoder is therefore our sharpest example of a method that scores well on the standard matching metric while failing the causal test that only a known machine can provide.

Sparse autoencoders result

Left: the frame. Right: the recovered structure/effect against the ground truth (matched components or preserved behaviour), with the RAM cells labelled. feature_variable_matched_fraction = 1.000 — this example only (pong, state gameplay(seed=0,prefix=90)+15); the audit aggregate is below.

Mechanistic family · features from superposition

Learn the method — a beginner's guide

New to explainable AI? This block explains the method as it is used on neural networks, then how we run the very same method on an Atari 2600, where — unlike for a network — we know the right answer. Every implementation step links to the code. See also the XAI primer for the shared vocabulary.

The idea in plain words

Look inside a language model and pick one neuron. You will often find it fires for many unrelated things: Python code, the French word for “cat”, and closing brackets. Such a neuron is polysemantic (many meanings). One explanation is superposition: the model wants to store more concepts (“features”) than it has neurons, so it packs them in as overlapping directions in activation space. That works because most features are sparse: in any one input, only a few of them are active, so the overlaps rarely collide.

A sparse autoencoder (SAE) tries to undo the packing. It is a small, separate network trained to rebuild the model's activation vector through a hidden layer with many units, under a penalty that keeps only a few units active at a time. If it works, each hidden unit stands for one concept: it is monosemantic. These units are then called the model's “features”, given names, and used to explain and steer the model. SAEs are among the most widely used tools in interpretability today.

How it works on a neural network

Take an activation vector \(x \in \mathbb{R}^d\) (e.g. the residual stream of a transformer at one token). The SAE encodes and decodes it:

\[ z = \mathrm{ReLU}(W_e x + b_e), \qquad \hat x = W_d z + b_d, \qquad \mathcal{L} = \|x - \hat x\|^2 + \lambda \|z\|_1 . \]

\(z\) is the code (one number per feature). ReLU sets negative values to zero. The first loss term asks for a good reconstruction. The second, an L1 penalty (the sum of absolute values, known from the lasso), pushes most entries of \(z\) to exactly zero. \(\lambda\) trades the two off. Usually the hidden layer is wider than \(d\) (“overcomplete”), so it has room for more features than neurons. Column \(k\) of \(W_d\) is feature \(k\)'s direction in activation space.

Toy example. A model stores 3 features in a 2-D space, at 120° apart: \(u_1=(1,0)\), \(u_2=(-0.5,0.87)\), \(u_3=(-0.5,-0.87)\). An input has only feature 2 on: \(x=u_2=(-0.5,0.87)\). The two raw neurons read \(-0.5\) and \(0.87\): both respond, and each would also respond to the other features. Now an SAE with three hidden units, encoder rows \(u_1,u_2,u_3\) and bias \(-0.4\): the pre-activations are \((-0.5, 1.0, -0.5) - 0.4 = (-0.9, 0.6, -0.9)\), and ReLU gives \(z=(0, 0.6, 0)\). Only unit 2 fires. Three features, cleanly separated, from a 2-D space.

Recipe

  1. Record many activation vectors from the model (one layer, many inputs).
  2. Normalise them, then train the SAE on the reconstruction loss plus \(\lambda\cdot\) L1 of the code.
  3. Check reconstruction quality (fraction of variance explained) and sparsity (average number of active units, \(L_0\)).
  4. Interpret each unit: list the inputs where it fires most, or correlate it with known concepts.
  5. Test causally: set a feature to zero (or clamp it high), decode, put the result back into the model, and see whether the behaviour changes as the feature's name predicts.

From a neural network to the Atari

Activation vector \(x\)The 128 bytes of RIOT RAM at one video frame. A recorded run gives one row per frame.
Layer being decomposedThe whole RAM state. The VCS has no layers; RAM is the single place where game state lives between frames.
Feature (SAE hidden unit)A learned direction over RAM bytes. We hope each one tracks one known game variable, e.g. ball x or the player score.
Human label for a featureThe verified concept↔cell map (candidates_<game>.json). For Pong: 8 cells, including scores, paddle and ball positions.
Feature steering / ablationZero the feature in the code, decode to bytes, write all 128 bytes into the real machine, replay 15 frames, count screen pixels that change.
Ground truth (never available for an LLM)The intervention oracle: how much the screen breaks when each cell itself is set to 0 or base+17 and the ROM re-runs.

How we apply it to the VCS

Our runner sae.jl is a complete SAE pipeline written by hand in Julia (no deep-learning library), applied to the VCS state instead of a transformer.

The triad: F is the Spearman rank correlation between each cell's SAE “recovery score” (best feature correlation × decoder weight mass on that cell) and the oracle's importance. S predicts a held-out lesion (base+37) from the same score. M asks whether the cells the SAE highlights are the cells that matter.

Read the code

XAI the interpretability method   substrate the bit-exact emulator it runs on (jutari, Julia).

Reading the result

Expect two very different pictures side by side. The reconstruction is close to perfect and the match rate is high: almost every known cell has a feature that tracks it. By the usual standard of the field, the SAE has “found the variables”. Then look at the causal-use bars. Ablating a matched feature often moves the screen much less than the oracle says that cell matters, or moves it through other bytes the decoder also touched. The lesson is the gap between named and used: a feature can track a variable perfectly and still not be the handle by which the program's computation runs.

Pitfalls

Try it yourself

julia --project=jutari tools/xai_study/phaseC_mechanistic/sae.jl --games core

Writes sae_<game>.{json,npz} and sae_core_summary.json into tools/xai_study/phaseC_mechanistic/out/. The 9-point sweep dominates the run time; use --d-hidden-sweep 32 --l1-sweep 0.05 for a quick single model.

Original papers & further reading

Read next: NMF/PCA dictionaries · Linear probing + control tasks · Interchange interventions / DAS · A7 · Dimensionality reduction (NMF/PCA)

How it's scored

The score is the fraction of sparse-autoencoder features that match a known, verified game-variable cell, together with a causal-use check by ablation. We first measure the matched fraction, how many of the concept cells the SAE was asked to represent get a matching feature, and on this small state that fraction is high. That is the metric the field usually uses to claim a feature is a concept. The VCS then applies a stronger test the audit treats as the real faithfulness: we ablate the matched feature, re-run the real ROM, and ask whether the computation it is supposed to name actually changes. Often it does not, so the causal faithfulness is low even though the matched fraction is high, and the sufficiency can even go negative. This split is the point: a feature can be named yet causally unused. There is no sprite-position hard-case here, because the method is scored on features and their ablation, not on a rendered position. Its plausibility proxy is high, which places it in the danger zone of high plausibility with low faithfulness. The grading is always against the intervention oracle, never against the matching metric alone. The audit box reports the measured triad, so you can read the low causal faithfulness directly.

The score is measured against the §1 intervention oracle — never against another interpretability method. F (faithful) is always vs the oracle; see the execution stack. How each of F / S / M is actually computed for this method (and whether it matches the paper) is in the box just below; the numbers are in the In the audit box under it.

How F, S, M are computed here

The exact formula this method uses for each score, read from its runner, and whether it matches the paper's §3 (F ∧ S ∧ M triad) definition. From the committed audit fsm_math_phaseC.json.

AxisFormula (as computed) What it measuresMatches §3?
F
faithfulness
\(F = \rho_{\mathrm{Spearman}}\!\left(\mathrm{attr}_{\mathrm{recovery}},\ \Delta y(u)\right)\)Spearman correlation between per-cell SAE recovery and the oracle causal importance: paper-shaped causal-effect agreement.✓ matches sae.jl (extra.triad.F = _spearman(recovery, oracle.importance)) IS the oracle-causal-agreement correlation, exactly §3's Phase-C causal-effect-agreement F, and leaderboard.py reads extra.triad.F. Record: sae_pong.json extra.triad.F=0.041. (The top-level 'value' field is still the feature_variable_matched_fraction naming stat, but the committed triad F is the correct causal Spearman.)
how it's measured — call stack:
  1. F = Spearman(per-cell SAE recovery, oracle causal importance) — sae.jl:784
  2. true causal effect Δy(u) by bit-exact re-run — oracle_intervene.jl:242
S
sufficiency
\(S = \rho_{\mathrm{Pearson}}\!\left(\mathrm{attr}_{\mathrm{recovery}},\ \Delta y_{\mathrm{held\text{-}out}}(u)\right) \in [-1,1]\)Held-out predictive correlation between SAE recovery and the causal effect on an unseen do(base+37) bit-exact re-run; can be negative.✓ matches sae.jl (S = _pearson(recovery, oracle.held_out)). A held-out predictive correlation in [-1,1] on a disjoint intervention (paper-conform; negative allowed). Record: extra.triad.S (sae_pong.json S=−0.458; battery mean S=0.041, n=43).
how it's measured — call stack:
  1. S = Pearson(SAE recovery, held-out do(base+37) effect) — sae.jl:785
  2. true causal effect Δy(u) by bit-exact re-run — oracle_intervene.jl:242
M
minimality
\(M = |U^{\star}| / |\hat{U}| \in (0,1]\quad U^{\star}=\{u:\Delta y(u)>0\},\ \hat{U}=\{u:|\mathrm{attr}(u)|>\tau\}\)Oracle-mover count over the number of cells the SAE names above threshold.✓ matches sae.jl now emits M = |U*|/|U_hat| in extra.triad.M (M_note '|U*|=4 (oracle movers) / |U_hat|=4 (method above-threshold)'), the paper's set-size ratio. Record: sae_pong.json extra.triad.M=1.0. Replaced the former monosemanticity/target-share proxy.
how it's measured — call stack:
  1. minimality_score(SAE recovery, oracle importance) — sae.jl:786
  2. minimality_score: |U*| oracle movers / |U_hat| named cells — triad_sm.jl:57
  3. true causal effect Δy(u) by bit-exact re-run — oracle_intervene.jl:242

✓ matches = the same quantity as §3; ◐ partial = the same kind of estimator but a differing detail; ✗ does not match = a different quantity (see the note). Definitions: F = agreement with the oracle's true causal effects Δy(u); S = held-out predictive score in [−1, 1]; M = |U*|/|Û| (true-minimal-set size / named-set size).

In the audit

This is the method's entry in the actual cross-method audit — scored on the paper's correctness triad, each axis a mean over 42 of the 44 scored games (42 committed §R records), not the single example shown above. Tradition: dim_reduction. The example figure (Pong) is one of those records.

0.147F — faithfulness vs oracle (mean over 42 games, ±0.060 CI95)
0.165S — sufficiency: held-out predictive (n/a where the paper does not define this axis)
0.924M — minimality: true-minimal-set / named-set (n/a otherwise)
42committed records aggregated
0.00human-plausibility proxy

F faithfulness (scored vs the oracle for every method) · S sufficiency (held-out predictive score in [−1, 1]; a negative value means the explanation predicts held-out interventions worse than the unperturbed baseline; reported for the predictive methods across all three phases where the calibration/held-out split is defined) · M minimality (true-minimal-set / named-set; where the method names a cause set) — n/a otherwise, per the paper's F ∧ S ∧ M triad.

Source: leaderboard.json · the whole leaderboard is on the methods page and the Paper 2 audit.

Results per game

This method's faithfulness on each of the 42 scored games (all-regime F; this method has no content-vs-position split (see the note below)). Click a header to sort. Every number is read from site_data.json (methods.sae.per_game).

content-F and position-F are n/a for this method. The content-vs-position split applies only to pixel-attribution methods — those that produce an attribution map over the framebuffer, whose score can be read separately on the smooth content outputs and the discrete position outputs (where the naive gradient is provably zero). This method does not attribute to a pixel output; it is graded by its own fidelity metric (feature_variable_matched_fraction), reported as the F column, so there is no content or position regime to separate.

S is negative on 24 of these games. Sufficiency asks whether the explanation can predict the outcome of held-out interventions it was not fit on; for this method S is the held-out predictive correlation between its claim and the true effect, so it lies in [−1, 1]. A value near 0 means the explanation predicts no better than the unperturbed output; a negative value means it predicts worse — its held-out claim is anti-correlated with the truth (named yet causally unused). The aggregate S is the mean over the scored games.

GameF (all)content-Fposition-FSMNote
Name This Game0.783n/an/a0.7491.000
Bowling0.584n/an/a0.4761.000
Jamesbond0.580n/an/a-0.0970.875
Yars' Revenge0.545n/an/a0.1810.500
Double Dunk0.439n/an/a0.4771.000
Alien0.359n/an/a0.4631.000
Krull0.308n/an/a0.4861.000
Freeway0.286n/an/a0.4811.000
Frostbite0.275n/an/a0.0591.000
Hero0.273n/an/a-0.1141.000
Road Runner0.258n/an/a0.5400.462
Q*bert0.252n/an/a-0.1170.467
Riverraid0.201n/an/a0.2861.000
Ice Hockey0.176n/an/a0.2601.000
Ms. Pac-Man0.169n/an/a-0.2581.000
Tennis0.156n/an/a-0.2331.000
Skiing0.119n/an/a-0.2091.000
Private Eye0.118n/an/a0.0661.000
Assault0.114n/an/a0.3740.900
Berzerk0.054n/an/a-0.2210.875
Atlantis0.053n/an/a-0.5081.000
Demon Attack0.050n/an/a0.4480.750no true-cause signal
Pong0.041n/an/a-0.4581.000no true-cause signal
Air Raid0.000n/an/a0.1961.000no true-cause signal
Asterix0.000n/an/a-0.2781.000no true-cause signal
Bank Heist0.000n/an/a-0.5061.000no true-cause signal
Boxing0.000n/an/a0.2151.000no true-cause signal
Breakout0.000n/an/a-0.4471.000no true-cause signal
Carnival0.000n/an/a-0.1131.000no true-cause signal
Centipede0.000n/an/a-0.4461.000no true-cause signal
Chopper Command0.000n/an/a-0.0860.769no true-cause signal
Enduro0.000n/an/a-0.3720.667no true-cause signal
Fishing Derby0.000n/an/a-0.3510.714no true-cause signal
Kangaroo0.000n/an/a-0.0731.000no true-cause signal
Montezuma's Revenge0.000n/an/a-0.2241.000no true-cause signal
Pacman0.000n/an/a-0.3041.000no true-cause signal
Phoenix0.000n/an/a-0.2701.000no true-cause signal
Pitfall0.000n/an/a-0.2480.846no true-cause signal
Seaquest0.000n/an/a0.7061.000no true-cause signal
Space Invaders0.000n/an/a-0.1281.000no true-cause signal
Venture0.000n/an/a-0.0351.000no true-cause signal
Video Pinball0.000n/an/a0.4501.000no true-cause signal

Call stack — how it runs on jutari / jaxtari

The path from this method's runner (compute_game) into the bit-exact VCS substrate, and the computation it involves. Every step links to the exact source on main. From callstack_phaseC.json.

Applied on the substrate

  1. Boot the real ROM with the xitari-parity reset (60 NOOP + 4 RESET) — env_reset!(env; boot_noop_steps = 60, boot_reset_steps = 4) jutari
  2. Deterministically step the emulator one action per env-frame (drives the RAM-trajectory recording) — env_step!(env::StellaEnvironment, action::Integer) jutari
  3. Assemble the shared gameplay-state testbed via build_sae_shared_state — build_shared_testbed(game; ... intervene_ram = J.intervene_ram!, run_intervention = O.run_intervention, soft_ram_peek = soft_ram_peek, ...) runner
  4. Freeze byte-exact RAM + screen out of the env at a frame — snapshot(env::StellaEnvironment, frame::Integer) jutari

The computation

  1. Record the RAM trajectory (per-frame 128-byte tape) the SAE is fit on — sae_record_ram(game, frames, ...) -> env_step! runner
  2. Fit the sparse autoencoder (L1-regularised) on the z-scored RAM tape — fit!(s::SAE, X; epochs, lr) (ctor SAE @ :375, loss @ :395) runner
  3. CAUSAL-USE test: ablate feature f (zero its code), DECODE + denorm to a full raw RAM vector, WRITE it over all cells and re-run; effect = screen break of ablated-decode vs un-ablated-decode re-run (isolates the feature) — causal_use(...) -> run_full_write(raw_ablate) -> intervene_ram! over all cells; env_step! runner run_full_write writes the decoded RAM via intervene_ram! (sae.jl:627), denorm_ram @ :598; scored only on ORACLE-CAUSAL cells via oracle_importance @ :536

Scored against the exact intervention oracle Δy(u): run_intervention(checkpoint, actions, target_frame, horizon, cause).

Implementation
tools/xai_study/phaseC_mechanistic/sae.jl
Reference
Cunningham et al. 2023; Bricken et al. 2023; Templeton et al. 2024
Record
sae_pong.json
All records
phaseC_mechanistic/out

The figure is generated from the committed record by docs/gen_method_figures.py; the game frame and each RAM cell's screen footprint are produced by render_scenes.jl / cell_footprints.jl.