Phase C · mechanistic interpretability

Logit / tuned lens

nostalgebraist 2020; Belrose et al. 2023

← back to the method catalogue

What it does?

The logit lens reads a system's intermediate state through its own output decoder. In a transformer it takes the hidden state at some middle layer and applies the final output projection to it, as if that intermediate state were the last layer, to see what the model would 'say' at that point. This reveals how the prediction forms across depth, and the tuned-lens variant learns a small correction so the readout is more faithful at each stage. It is a standard, cheap tool for tracing how information develops inside a network. We build the analogue on the VCS by reading an intermediate value through the machine's own decoding, and comparing the decoded value to the true intermediate value at that site. On this transparent machine the readout is exact: the state is linearly readable at the right site, so the lens reproduces the true intermediate value on every game. This is expected, because the VCS keeps its variables in plain, addressable memory rather than in a distorted distributed code. The logit lens is therefore a clean positive result on the machine, and it sits with the exact causal methods. As with those, reading the right value at the right site confirms that the value is represented and readable, but it does not by itself explain how that value is computed or what role it plays.

Logit / tuned lens result

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

How it's scored

The score is the readout fidelity of the lens-decoded intermediate against the true intermediate value, reported as an R-squared. We read an intermediate value through the machine's own decoding and compare it to the true value at that site. The grading is always against the intervention oracle. On this transparent machine the readout is exact: the state is linearly readable at the right site, so the lens reproduces the true intermediate value on every core game and the fidelity is at the ceiling. Faithfulness for this method is that readout fidelity. There is no sprite-position hard-case here, because the method reads an internal value rather than a rendered position, and it does not rely on a gradient. The result is expected, because the VCS keeps its variables in plain, addressable memory rather than in a distorted distributed code. The important qualification, which the score does not by itself capture, is that reading the right value at the right site confirms the value is represented and readable, but does not explain how the value is computed or what role it plays. The grading is always against the oracle. The audit box reports the measured triad, with fidelity at the ceiling.

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 = \dfrac{\sum_t |A_t|\cdot \mathbb{1}[\text{site causal}]}{\sum_t |A_t|}\)Mean fraction of the tuned-lens readout weight that lands on truly-causal sites (the oracle causal mask): low => the lens reads a spurious correlate (present != used).✓ matches logit_lens.jl now emits top-level metric_name=logit_lens_faithful_weight_fraction_vs_causal_mask with extra.triad.F = mean faithful-weight fraction vs the oracle causal mask; it replaced the readout-fidelity-to-the-true-intermediate (=1.0 by construction). This is §3's causal-agreement F for a readout-direction method. Record: logit_lens_pong.json extra.triad.F=0.438.
how it's measured — call stack:
  1. mean_faithful_weight_frac: share of lens readout weight on causal sites — logit_lens.jl:573
  2. emit F = faithful-weight fraction vs the oracle causal mask — logit_lens.jl:702
  3. true causal effect Δy(u) by bit-exact re-run — oracle_intervene.jl:242
S
sufficiency
S = null (undefined)Not scored: the lens reports readout fidelity to the true intermediate, not a held-out do(u) output prediction.— n/a logit_lens.jl (S = nothing). n/a is defensible per paper. Record: extra.triad.S = null.
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-causal sites over the number of readout sites the lens names above threshold.✓ matches logit_lens.jl now emits M = |U*|/|U_hat| in extra.triad.M (M_note '|U*|=4 (oracle movers) / |U_hat|=74 (method above-threshold)'), the paper's set-size ratio. Record: logit_lens_pong.json extra.triad.M=0.054. Replaced the former faithful-weight-fraction proxy (now used as F).
how it's measured — call stack:
  1. minimality_score(lens readout weights, oracle Δy) — logit_lens.jl:700
  2. minimality_score: |U*| oracle movers / |U_hat| lens-named sites — 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 all 42 scored games (42 committed §R records), not the single example shown above. Tradition: causal. The example figure (Pong) is one of those records.

0.820F — faithfulness vs oracle (mean over 42 games, ±0.053 CI95)
n/aS — sufficiency: held-out predictive (n/a where the paper does not define this axis)
0.224M — 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.logit_lens.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 (logit_lens_faithful_weight_fraction_vs_causal_mask), reported as the F column, so there is no content or position regime to separate.

GameF (all)content-Fposition-FSMNote
Beam Rider1.000n/an/an/a1.000recovers the true causes
Gopher1.000n/an/an/a1.000recovers the true causes
Kung-Fu Master1.000n/an/an/a1.000recovers the true causes
Pacman1.000n/an/an/a1.000recovers the true causes
Bowling0.995n/an/an/a0.298recovers the true causes
Bank Heist0.991n/an/an/a0.069recovers the true causes
Phoenix0.984n/an/an/a0.116recovers the true causes
Air Raid0.976n/an/an/a0.140recovers the true causes
Carnival0.975n/an/an/a0.168recovers the true causes
Q*bert0.972n/an/an/a0.271recovers the true causes
Freeway0.969n/an/an/a0.122recovers the true causes
Kangaroo0.950n/an/an/a0.143recovers the true causes
Name This Game0.947n/an/an/a0.085recovers the true causes
Centipede0.928n/an/an/a0.074recovers the true causes
Road Runner0.908n/an/an/a0.165recovers the true causes
Ice Hockey0.891n/an/an/a0.096recovers the true causes
Yars' Revenge0.886n/an/an/a0.156recovers the true causes
Private Eye0.878n/an/an/a0.279recovers the true causes
Krull0.875n/an/an/a0.247recovers the true causes
Venture0.862n/an/an/a0.182recovers the true causes
Tennis0.860n/an/an/a0.169recovers the true causes
Double Dunk0.853n/an/an/a0.117recovers the true causes
Space Invaders0.847n/an/an/a0.121
Montezuma's Revenge0.842n/an/an/a0.119
Riverraid0.842n/an/an/a0.183
Alien0.820n/an/an/a0.061
Breakout0.815n/an/an/a0.067
Seaquest0.812n/an/an/a0.310
Hero0.805n/an/an/a0.140
Video Pinball0.803n/an/an/a0.080
Demon Attack0.791n/an/an/a0.151
Jamesbond0.764n/an/an/a0.105
Atlantis0.748n/an/an/a0.096
Ms. Pac-Man0.734n/an/an/a0.168
Berzerk0.662n/an/an/a0.209
Fishing Derby0.624n/an/an/a0.050
Frostbite0.568n/an/an/a0.137
Chopper Command0.553n/an/an/a0.111
Assault0.530n/an/an/a0.163
Pitfall0.441n/an/an/a0.106
Pong0.438n/an/an/a0.054
Boxing0.291n/an/an/a0.081

Call stack — how it runs on jutari / jaxtari

The path from this method's runner (run_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-tape / trajectory-set recording) — env_step!(env::StellaEnvironment, action::Integer) jutari
  3. Assemble the shared gameplay-state testbed (checkpoint at f*, causes, shared screen output, cause-density gate) — build_shared_testbed(game; ... intervene_ram = intervene_ram!, run_intervention = 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. Build the per-site trajectory set (poke each candidate cell across offsets, record the RAM tape) the readouts are fit on — build_trajset(base_ckpt, src_ckpt, ...) -> intervene_ram! runner intervene_ram! @ logit_lens.jl:277; record_ram_tape @ :213
  2. Per-site readout fidelity: ridge-fit a linear readout from each site to the output and score R^2 — ridge_fit(X, y; lambda) ; r2(y, yhat) runner r2 @ :300
  3. Faithful-weight fraction vs the oracle causal mask: build the causal mask by poking each site (+SET_DELTA), re-run, and compare which readout weights land on truly-causal cells — build_causal_mask(base_ckpt, tail, ...) -> intervene_ram! runner intervene_ram! @ logit_lens.jl:379

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

Implementation
tools/xai_study/phaseC_mechanistic/logit_lens.jl
Reference
nostalgebraist 2020; Belrose et al. 2023
Record
logit_lens_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.