cf. Jonas & Kording 2017
Dimensionality reduction summarises high-dimensional activity by a few components. Principal component analysis (PCA) finds the directions of largest variance; non-negative matrix factorisation (NMF) finds additive, parts-based factors. Both are standard in neuroscience for turning a large population recording into a handful of interpretable 'latent factors'. We run them on the VCS state tensor, the values of all cells over time, and read off the recovered components. We then match each component to a known signal: the frame or scanline clock, a read/write pattern, the vsync flag, or a game variable. The intuition is that the strongest components should correspond to the machine's real internal signals, so the factorisation recovers the structure without any labels. The method is unsupervised and cheap, which is why it is popular. On the VCS it does moderately well: it recovers most of the known factors, and NMF's non-negativity fits the additive register basis a little better than PCA. But a large fraction of components stay unmatched or mix several true signals into one, so the decomposition is suggestive rather than exact. It finds structure that is genuinely present, without telling us how the program uses it.
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.
Modern recordings are huge: hundreds of neurons, or thousands of hidden units, over thousands of time steps. Nobody can stare at that table. Dimensionality reduction compresses it. It looks for a few components: patterns of joint activity that, added together, rebuild most of the table. Each component has a loading (how strongly each unit takes part) and an activation over time (how strongly the pattern is “on” at each step). The hope is that these few latent factors are the system's real internal variables: “arm direction”, “choice”, “ball position”.
Two classic tools are used. PCA (principal component analysis) finds the directions along which the data vary most. NMF (non-negative matrix factorisation) instead rebuilds the data as a sum of non-negative “parts”, which often look more like separate objects. Both are unsupervised: they need no labels. That is their charm and their risk. They find what is large in the data, and large is not the same as important. On the Atari we can check which components match real signals, and whether the bytes they highlight are the ones that actually cause what appears on screen.
Neuroscience origin. PCA, factor analysis and NMF are staples of population analysis (Cunningham & Yu 2014): reduce a recording to a few latent trajectories, then interpret them. Jonas & Kording ran NMF on the transistor activity of a simulated 6502 and found components that tracked the clock and bus activity, not the program's logic.
Deep-learning analogue. Dimensionality reduction of activations: PCA of a layer's activations over a dataset, NMF of CNN feature maps into “concept” parts, or the top singular directions of a residual stream. Arrange the recording as a matrix \(X\) of size \(T\times n\) (time steps × units).
PCA centres each column (subtracts its mean, giving \(X_c\)) and takes the singular value decomposition \(X_c = U S V^\top\). Column \(j\) of \(V\) is component \(j\)'s loading over the \(n\) units; \(X_c V\) gives the activations; the share of variance explained is \(s_j^2/\sum_k s_k^2\).
NMF requires \(X\ge 0\) and finds \(W\ge 0\) (\(T\times r\), activations) and \(H\ge 0\) (\(r\times n\), loadings) that minimise \(\lVert X - WH\rVert_F\). The Lee–Seung multiplicative updates keep everything non-negative:
\[ H \leftarrow H \odot \frac{W^\top X}{W^\top W H}, \qquad W \leftarrow W \odot \frac{X H^\top}{W H H^\top} . \]Toy example. Record two bytes over four frames. Byte A is a frame counter: \((0, 64, 128, 192)\). Byte B is the score: \((0, 0, 1, 1)\). Byte A has variance 5120; byte B has variance 0.25. PCA's first component points almost entirely at A and explains more than 99.99 % of the variance. The score barely registers. Now suppose the score is what the screen shows and the counter only drives a blink. The top component has picked the loudest byte, not the causal one. Variance is a statement about the data, not about cause.
| Population recording / layer activations | The \(T\times128\) RAM tape: every byte of the VCS's working memory, once per frame. Bytes are 0–255, so the tape is non-negative and NMF applies directly. |
|---|---|
| Latent factors | The top-5 PCA components and the top-5 of a rank-8 NMF, each with a loading over the 128 bytes and an activation over frames. |
| Known task variables | The game's candidate bytes, grouped into variable families (score, ball, enemy, …), plus three structural signals: a frame clock ramp, the population write activity (bytes changed per frame), and a periodic frame-phase wave. |
| “This component is the choice variable” | A matched component: at least half of its candidate-byte loading lies on one family (and candidates carry a real share of the loading), or its activation correlates \(|r|\ge0.5\) with one structural signal. |
| Importance of a unit (unknown in a brain) | The intervention oracle: set the byte to 0 or base+17 at frame \(f^*\), re-run the real ROM for the horizon, count changed screen pixels. |
The runner A7_dimred.jl does two things: a descriptive match of components to
known signals, and an oracle-scored test of whether the components point at causal bytes.
a7_record_ram steps the real ROM with
env_step! and stores the RAM each frame. The trajectory is 150 frames for most games,
continued with NOOP after the gameplay window.run_pca centres the raw byte values and takes an SVD.
run_nmf runs 300 Lee–Seung updates at rank 8 from a seeded random start, then sorts
components by energy (the size of each rank-one part \(W_{:,k}H_{k,:}\)). No package is added; both are
written out in the file.known_signals builds the clock ramp, the write-activity count, and a
sinusoid at the dominant autocorrelation period of that count. match_components then
labels each of the top-5 components as a game variable, a known signal, or unmatched (purity threshold
0.5). The headline record value is the NMF matched-component fraction.recovery_scores gives each candidate byte a score: its squared
loading on the top-5 components, weighted by variance (PCA) or energy (NMF).
oracle_importance pokes each candidate byte to 0 and to base+17, re-runs the horizon and
counts changed pixels. A third value, base+37, is held out. score_triad gives F (Spearman
rank correlation of recovery vs importance), S (Pearson against the held-out effect) and M (the true
cause set's size over the named set's size).Read the match metric carefully. A component that tracks the frame clock counts as “matched”. That is honest bookkeeping (the component is a real signal), but it is the epiphenomenal signal A5 warns about. The triad is what asks whether the components point at causes. Note also that the “frame-phase” wave is a stand-in: per-frame sampling cannot see the real VSYNC pulse, so it is a periodic proxy derived from the data.
XAI the interpretability method substrate the bit-exact emulator it runs on (jutari, Julia).
A7_dimred.jl:382 — PCA by SVD of the centred RAM tape: loadings and variance fractions.A7_dimred.jl:418 — Lee–Seung multiplicative-update NMF, seeded and dependency-free.A7_dimred.jl:489 — The structural signals a component may match: clock ramp, write activity, frame-phase wave.A7_dimred.jl:576 — Labels each leading component as a game variable, a known signal, or unmatched.A7_dimred.jl:651 — Per-byte recovery score: variance- or energy-weighted squared loading on the top components.A7_dimred.jl:688 — Ground truth per byte: poke it, re-run the ROM, count changed pixels.A7_dimred.jl:749 — F (Spearman), S (held-out Pearson) and M (minimality) against the oracle.triad_sm.jl:57 — The shared minimality scorer \(M=|U^*|/|\hat U|\) used across the study.jutari_oracle.jl:176 — The intervention: write one value into one RAM byte.StellaEnvironment.jl:259 — One video frame of the real, bit-exact machine.The figure shows two bars per candidate byte (Pong): the oracle's true causal importance and the byte's NMF recovery score, both scaled so the largest is 1. A faithful decomposition would give bars of matching height. Expect them not to match. The leading components favour the bytes that vary most, such as a paddle position the oracle calls inert, while bytes that matter but barely change, such as the scores, get almost no recovery. The match metric in the record tells a kinder story: a good share of the leading components match a game variable or a known signal, for PCA and NMF alike. The structure is real; it is just not the same thing as the program's causal story.
julia --project=jutari tools/xai_study/phaseA_kording/A7_dimred.jl --games core
Writes A7_<game>.json/.npz (variance curves, loadings, matches, recovery scores, oracle importance, PCA and NMF triads) plus A7_dimred_all.json into tools/xai_study/phaseA_kording/out/. Flags --nmf-rank, --topk and --purity let you test the sensitivity. Minutes per game.
Read next: A5 · Local field potentials · A3 · Tuning curves · Sparse autoencoders · Linear probing + control tasks
The score is the fraction of NMF or PCA components that match a known signal or variable. We decompose the state tensor into components, then match each to the machine's known internal signals, the frame or scanline clock, a read/write pattern, vsync, or a game variable, and count the matched fraction against what the oracle marks as important. Faithfulness for this method is that matched-component fraction. It is moderate: the decomposition recovers most of the known factors, and NMF's non-negativity fits the additive register basis a little better than PCA, but a substantial fraction of components stay unmatched or mix several signals into one. A secondary reconstruction-error composite gives NMF a small edge, but on the primary matched-fraction metric the two are close. The grading is always against the oracle, not against another method. There is no sprite-position hard-case here; the output is a set of components. The audit box reports the measured matched fraction across the scored games, so the number is an average over the scored set rather than the best single game.
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.
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_phaseA.json.
| Axis | Formula (as computed) | What it measures | Matches §3? |
|---|---|---|---|
| F faithfulness | \(F = \rho_{\mathrm{Spearman}}\!\left(\mathrm{attr}_{\mathrm{recovery}},\ \Delta y(u)\right)\) | Spearman correlation between each cell's PCA/NMF component-recovery score and the oracle causal importance over candidate cells (reported separately for PCA and NMF). | ✓ matches Two triads (triad_pca, triad_nmf); correlation vs oracle causal importance, not vs known-variable labels. Runner A7_dimred.jl,; record out/A7_pong.json triad_nmf.F=-0.385, triad_pca.F=-0.041. how it's measured — call stack:
|
| S sufficiency | \(S = \rho_{\mathrm{Pearson}}\!\left(\mathrm{attr}_{\mathrm{recovery}},\ \Delta y_{\mathrm{held\text{-}out}}(u)\right) \in [-1,1]\) | Pearson correlation of the component-recovery score vs the held-out do(base+37) screen break. | ✓ matches Held-out predictive correlation in [-1,1] of the component-recovery score vs the held-out do(base+37) screen break: the §3 (sec:triad) form. Two triads (pca, nmf). A7_dimred.jl; record S: nmf=-0.291, pca=-0.192. how it's measured — call stack:
|
| 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\}\) | Number of oracle-causal cells over the number of dim-reduction-surfaced cells the method names. | ✓ matches Runner now emits M = |U*|/|U_hat| for both triad_pca and triad_nmf (M_note '|U*|=4 (oracle movers) / |U_hat|=4/6'), the paper's set-size ratio. Record out/A7_pong.json triad_pca.M=1.0, triad_nmf.M=0.667. Replaced the former 1 − variance-not-causal over-claim rate. how it's measured — call stack:
|
✓ 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).
This is the method's entry in the actual cross-method audit — scored on the paper's correctness triad, each axis a mean over 44 of the 44 scored games (44 committed §R records), not the single example shown above. Tradition: dim_reduction. The example figure (Pong) is one of those records.
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.
This method's faithfulness on each of the 44 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.A7_dimred.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 (A7_nmf_matched_component_fraction_vs_known_vars), reported as the F column, so there is no content or position regime to separate.
| Game | F (all) | content-F | position-F | S | M | Note |
|---|---|---|---|---|---|---|
| Alien | 1.000 | n/a | n/a | n/a | n/a | recovers the true causes |
| Berzerk | 0.800 | n/a | n/a | n/a | n/a | |
| Demon Attack | 0.800 | n/a | n/a | n/a | n/a | |
| Kangaroo | 0.800 | n/a | n/a | n/a | n/a | |
| Pacman | 0.800 | n/a | n/a | n/a | n/a | |
| Riverraid | 0.800 | n/a | n/a | n/a | n/a | |
| Venture | 0.800 | n/a | n/a | n/a | n/a | |
| Air Raid | 0.600 | n/a | n/a | n/a | n/a | |
| Asterix | 0.600 | n/a | n/a | n/a | n/a | |
| Bank Heist | 0.600 | n/a | n/a | n/a | n/a | |
| Breakout | 0.600 | n/a | n/a | n/a | n/a | |
| Centipede | 0.600 | n/a | n/a | n/a | n/a | |
| Chopper Command | 0.600 | n/a | n/a | n/a | n/a | |
| Double Dunk | 0.600 | n/a | n/a | n/a | n/a | |
| Freeway | 0.600 | n/a | n/a | n/a | n/a | |
| Hero | 0.600 | n/a | n/a | n/a | n/a | |
| Jamesbond | 0.600 | n/a | n/a | n/a | n/a | |
| Montezuma's Revenge | 0.600 | n/a | n/a | n/a | n/a | |
| Ms. Pac-Man | 0.600 | n/a | n/a | n/a | n/a | |
| Pong | 0.600 | n/a | n/a | n/a | n/a | |
| Private Eye | 0.600 | n/a | n/a | n/a | n/a | |
| Q*bert | 0.600 | n/a | n/a | n/a | n/a | |
| Seaquest | 0.600 | n/a | n/a | n/a | n/a | |
| Space Invaders | 0.600 | n/a | n/a | n/a | n/a | |
| Yars' Revenge | 0.600 | n/a | n/a | n/a | n/a | |
| Assault | 0.400 | n/a | n/a | n/a | n/a | |
| Atlantis | 0.400 | n/a | n/a | n/a | n/a | |
| Bowling | 0.400 | n/a | n/a | n/a | n/a | |
| Boxing | 0.400 | n/a | n/a | n/a | n/a | |
| Fishing Derby | 0.400 | n/a | n/a | n/a | n/a | |
| Ice Hockey | 0.400 | n/a | n/a | n/a | n/a | |
| Krull | 0.400 | n/a | n/a | n/a | n/a | |
| Kung-Fu Master | 0.400 | n/a | n/a | n/a | n/a | |
| Name This Game | 0.400 | n/a | n/a | n/a | n/a | |
| Phoenix | 0.400 | n/a | n/a | n/a | n/a | |
| Pitfall | 0.400 | n/a | n/a | n/a | n/a | |
| Road Runner | 0.400 | n/a | n/a | n/a | n/a | |
| Skiing | 0.400 | n/a | n/a | n/a | n/a | |
| Carnival | 0.200 | n/a | n/a | n/a | n/a | |
| Enduro | 0.200 | n/a | n/a | n/a | n/a | |
| Frostbite | 0.200 | n/a | n/a | n/a | n/a | |
| Gopher | 0.200 | n/a | n/a | n/a | n/a | |
| Tennis | 0.200 | n/a | n/a | n/a | n/a | |
| Video Pinball | 0.200 | n/a | n/a | n/a | n/a |
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_phaseA.json.
build_a7_shared_state(game) -> build_shared_testbed(game; ...) runnerfunction build_shared_testbed(game; ...) runnercause_density = count(>(floor), deltas) runnera7_record_ram(game, frames, actions) runnerenv_step!(env, Int(actions[t])) jutariget_ram(env) jutarirun_pca(tape) runnerrun_nmf(tape, rank; iters=300, seed=0) runnermatch_components(method, tape, ...) runnerScored against the exact intervention oracle Δy(u): run_intervention(checkpoint, actions, target_frame, horizon, cause).
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.