Phase A · neuroscience battery

A1 · Connectomics / data-flow graph

cf. Jonas & Kording 2017

← back to the method catalogue

What it does?

Connectomics tries to map the wiring of a system by watching how its parts affect each other. In neuroscience it means reconstructing which neurons connect to which. Here we do the same for the machine's memory. We change one RAM cell, re-run the program, and record which other cells change as a result. Each such dependency is drawn as a directed edge from cause to effect. The full set of edges is the program's data-flow graph, its 'connectome'. The idea is that the pattern of who-influences-whom should reveal the computation, without reading the code. This is a classic move in systems neuroscience: infer function from structure. On the VCS we have the true wiring from the disassembly, so we can check whether the recovered graph is right. The method is attractive because it needs no labels and no model of what the program means. It only needs the ability to perturb and observe. In practice it recovers a graph that looks plausible but contains many edges the real program does not have, because a single perturbation ripples through shared clocks and buffers.

A1 · Connectomics / data-flow graph result

Two adjacency matrices over the candidate RAM cells: the true data-flow graph and the graph this method recovered. A bright cell (row = cause, column = effect) is an edge; the difference between the two panels is the error. dataflow_graph_F1_vs_oracle = 0.000 — this example only (pong, state gameplay(seed=0,prefix=90)+15); the audit aggregate is below.

Phase A · neuroscience battery · wiring from perturbation

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

A connectome is a wiring diagram: a list of which parts of a system talk to which other parts. Neuroscientists build it for brains. They draw one dot per neuron and one arrow per connection. The hope is simple: if we know who is wired to whom, we can read off how the system computes. One way to find the arrows is to look at the anatomy. Another is to perturb: nudge one unit, watch which other units react, and draw an arrow from the nudged unit to every unit that moved. The result is a directed graph of influence.

For a neural network you already have the anatomy: the weight matrices are the connectome, and they are fully known. Yet nobody claims that printing all the weights explains the network. That is the lesson of Jonas & Kording, who mapped a whole microprocessor and still could not say how it ran a game. On the Atari we ask a sharper question. If we recover the wiring by cheap perturbations, the way it is done in practice, how many of the arrows do we get right? Because the machine can be re-run exactly, we can count every right and every wrong arrow.

How it works on a neural network

Neuroscience origin. The first complete connectome was that of the worm C. elegans: 302 neurons, about 7000 synapses, mapped by electron microscopy in the 1980s. Its behaviour is still not fully explained by that map. Perturbation-based mapping (stimulate one cell, record the others) gives the effective connectivity instead of the anatomical one.

Neural-network analogue. In a network the anatomical connectome is the set of non-zero weights. The perturbation version is what interpretability calls circuit discovery: change one activation \(h_i\), see which downstream activations \(h_j\) change. Write the intervention as \(\mathrm{do}(h_i := v)\) (“force \(h_i\) to the value \(v\), leave everything else to the network”). The recovered edge set is

\[ E_{\text{rec}} = \{\, i\to j \;:\; h_j^{(L)}\big(\mathrm{do}(h_i := h_i+\delta)\big) \neq h_j^{(L)} \,\}, \]

where \(L\) is the latency (how many steps later you look) and \(\delta\) is the size of the nudge. Given a true edge set \(E_{\text{true}}\) you score it like any detector:

\[ P = \frac{|E_{\text{rec}}\cap E_{\text{true}}|}{|E_{\text{rec}}|},\quad R = \frac{|E_{\text{rec}}\cap E_{\text{true}}|}{|E_{\text{true}}|},\quad F_1 = \frac{2PR}{P+R}. \]

Toy example. Three units in a chain, each copying the previous one with a one-step delay: \(a \to b \to c\). Nudge \(a\) and look one step later: only \(b\) moved. Nudge \(b\): only \(c\) moved. So \(E_{\text{rec}} = \{a\to b,\; b\to c\}\). Now look many steps later instead: nudging \(a\) moves \(b\) and \(c\). The long-horizon truth is \(E_{\text{true}} = \{a\to b,\; b\to c,\; a\to c\}\). Then \(P = 2/2 = 1\), \(R = 2/3\) and \(F_1 = 0.8\). Make it harder: let \(b\) copy \(a\) only when \(a > 100\). With \(a = 50\) and a nudge of \(+17\), the gate never opens and even \(a\to b\) is missed. A single small nudge with a short wait sees only part of the wiring.

Recipe

  1. Choose the units (here: candidate RAM bytes) and freeze the system in one state.
  2. Record a baseline: let the system run unperturbed for \(L\) steps and store every unit's value.
  3. For each unit \(i\): restore the frozen state, apply one perturbation \(\mathrm{do}(i := \text{base}_i+\delta)\), run \(L\) steps.
  4. Draw an arrow \(i\to j\) for every unit \(j\) whose value now differs from the baseline. Ignore the self-arrow \(i\to i\).
  5. Build the reference graph the same way but exhaustively (several values, full horizon), or take it from the known anatomy.
  6. Compare the two edge sets: precision, recall, \(F_1\), and the graph-edit distance (number of wrong plus missing arrows).

From a neural network to the Atari

The neuronOne candidate RAM byte. The VCS has 128 bytes of working memory (RAM). Each game's candidate list (e.g. ball x, paddle y, score) comes from published RAM annotations (OCAtari / AtariARI).
The synapseA data-flow edge \(i\to j\): the game program (the ROM, the read-only cartridge code) reads byte \(i\) and, directly or through other bytes, writes a value into byte \(j\).
The stimulation electrodeintervene_ram!: overwrite one RAM byte in the emulator at frame \(f^*\). A frame is one 1/60 s video picture, the unit of game time.
The recordingA full snapshot of RAM (and screen) after re-running the bit-exact emulator jutari from that frozen state.
The true connectomeThe oracle graph: the same probe done exhaustively (three values, full 15-frame horizon). Each probe is a real re-run of the real ROM, so every edge in it is a true causal dependency.

How we apply it to the VCS

The runner A1_connectomics.jl does the whole experiment on one frozen game state. That state is shared with every other method in the study:

  1. The state. The emulator boots the cartridge (60 no-op frames plus 4 reset frames, the same boot as the C++ reference), then plays 90 frames of seeded random joystick input (18 possible actions, seed 0). That frame is \(f^*\). The 15 frames after it are the horizon. A cause-density gate checks with the oracle that at least four candidate causes really move the screen and records whether the state passed, so a frozen title screen is flagged. Two fresh boots must give byte-identical RAM and screen, or the runner refuses to score.
  2. The recovered graph (method under test). For each candidate byte \(i\) the runner copies the frozen machine, adds 17 to byte \(i\) (wrapping at 256), steps one frame, and draws \(i\to j\) for every candidate byte \(j\) that differs from an unperturbed one-frame run. One value, one frame: a thin, realistic probe.
  3. The true graph (oracle). The same loop, but byte \(i\) is set to each of \(0\), base\(+17\) and base\(+37\), and the machine runs the full 15 frames. An edge exists if any of the three values changes \(j\) at the end. Note what this truth is: a measured total-effect graph over the horizon. It includes indirect paths (\(a\to b\to c\) also counts as \(a\to c\)), exactly like the toy example. It is measured by re-running the ROM, not parsed from the disassembly listing.
  4. Scores. Precision, recall, \(F_1\) and graph-edit distance over the off-diagonal edges. A positive control runs the oracle procedure as if it were the method; it must score a perfect \(F_1\), which proves the scorer can reward a correct graph.
  5. Generalisation probe. The runner also builds a true graph from base\(+37\) alone, a value the recovery never used, and checks how well the recovered graph predicts it (edge agreement). A minimality term divides the number of true edges by the number of claimed edges.

Why the gap? The VCS program updates many bytes only on certain frames, behind comparisons and timers. A one-frame wait misses every influence that takes longer to arrive. A single nudge of \(+17\) misses every influence that only fires for other values. And an effect that shows up after one frame but is undone by frame 15 becomes an arrow the truth does not have. The method sees a small, partly wrong slice of a richly connected machine.

Read the code

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

Reading the result

The figure shows the game frame and two square matrices over the same candidate bytes. Rows are the cause byte, columns the effect byte, and a bright square is an arrow. The left matrix is the oracle's true graph, the right one the recovered graph. The diagonal (a poked byte changing itself, unless the program overwrites it) is not scored. Read the error as the squares that are bright in one matrix but dark in the other. In Pong the true graph has whole bright rows, because the score bytes and the ball bytes reach many other cells within 15 frames. The one-frame recovery is empty off the diagonal. It misses the wiring rather than inventing it, so recall collapses and \(F_1\) lands at the bottom of the battery.

Pitfalls

Try it yourself

julia --project=jutari tools/xai_study/phaseA_kording/A1_connectomics.jl --games core

Writes A1_<game>.{json,npz} per game plus the combined A1_connectomics.{json,npz} into tools/xai_study/phaseA_kording/out/. Use --game pong for one game, or --selftest to run the checks without writing. Each game costs a few hundred short emulator re-runs (minutes on one core).

Original papers & further reading

Read next: A2 · Single-unit lesions · A6 · Granger causality · A4 · Pairwise correlations · ACDC — automatic circuit discovery

How it's scored

The score is a data-flow-graph F1 against the true read/write graph from the disassembly. An edge means that perturbing one RAM cell changes another. We build the recovered graph by single-shot perturbation and compare its edges to the true edges, taking the harmonic mean of precision, the fraction of recovered edges that are real, and recall, the fraction of real edges recovered. Faithfulness for this method is that edge F1: a graph-valued explanation is graded as a graph, not as a heat-map. The comparison is always against the intervention oracle's true wiring, never against another method. The hard part is that a single perturbation ripples through shared clocks and buffers, so the recovered graph contains many edges the real program does not have. Precision suffers, and the F1 stays low. There is no separate position hard-case here, because the method never claims a sprite position; it claims a wiring diagram. The audit box below reports the actual F1, aggregated across the scored games, so no single game dominates. Read the recovered-versus-true graph as the error: every edge in one panel but not the other is a mistake the metric counts.

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_phaseA.json.

AxisFormula (as computed) What it measuresMatches §3?
F
faithfulness
\(F = F_1^{\mathrm{edge}}(\hat{E}, E^{\star})\)F1 of the single-shot recovered data-flow edges against the exact-oracle true data-flow graph over 8 candidate cells.✓ matches Graph-valued primitive = edge F1 vs true data-flow graph, exactly the paper's connectomics case. Runner A1_connectomics.jl,; record out/A1_pong.json extra.triad.F=0.0 / graph.f1.
how it's measured — call stack:
  1. F = edge-F1 of the recovered do(base+17) edges vs the true graph — A1_connectomics.jl:406
  2. score_graph: edge precision, recall and F1 of the two graphs — A1_connectomics.jl:367
  3. true causal effect Δy(u) by bit-exact re-run — oracle_intervene.jl:242
S
sufficiency
\(S = \dfrac{\#\{(i,j):\ \hat{E}_{ij}=E^{\star,\mathrm{held}}_{ij}\}}{\#\,\mathrm{off\text{-}diag}} \in [0,1]\)Off-diagonal edge agreement between the base+17 recovered graph and the held-out base+37 true edge set (unseen intervention value).✓ matches Held-out edge agreement between the base+17 recovered graph and the held-out base+37 true edge set: a non-null held-out sufficiency. §3 (sec:triad) admits the fraction-within-tolerance [0,1] special case of the held-out predictive test, which this off-diagonal edge-agreement fraction satisfies. A1_connectomics.jl,; record S=0.839.
how it's measured — call stack:
  1. S = off-diagonal edge agreement, recovered vs held-out true edges — A1_connectomics.jl:416
  2. heldout_true_graph: true edges under the unseen do(base+37) — A1_connectomics.jl:578
M
minimality
\(M = |U^{\star}| / |\hat{U}| = |E^{\star}| / |\hat{E}| \in (0,1]\)True-graph edge count over the number of recovered edges (edge-level |U*|/|U_hat|).✓ matches Runner now emits M = |U*|/|U_hat| over edges (M_note '|true edges|=12 / |discovered edges|=0'); the paper's minimality ratio applied at the edge level. Record out/A1_pong.json extra.triad.M (null in pong when 0 edges discovered). Replaced the former 1 − FP-rate (edge precision).
how it's measured — call stack:
  1. M = |true edges| / |discovered edges| — A1_connectomics.jl:422
  2. score_graph counts the true and recovered edge sets — A1_connectomics.jl:367

✓ 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 38 of the 44 scored games (38 committed §R records), not the single example shown above. Tradition: intervention. The example figure (Pong) is one of those records.

0.213F — faithfulness vs oracle (mean over 38 games, ±0.077 CI95)
0.957S — sufficiency: held-out predictive (n/a where the paper does not define this axis)
0.971M — minimality: true-minimal-set / named-set (n/a otherwise)
38committed 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 38 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.A1_connectomics.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 (dataflow_graph_F1_vs_oracle), reported as the F column, so there is no content or position regime to separate.

M is n/a on 15 of these games. Minimality is M = |U*|/|Û|, the size of the true minimal cause set over the size of the set the method actually names. On a game where the method names nothing (|Û| = 0 — it discovers no circuit, its attribution map is all-zero, or it decodes no cell), that ratio is undefined, so M is left blank rather than scored. The aggregate M is the mean over the 23 games where the method did name a cause set.

GameF (all)content-Fposition-FSMNote
Q*bert1.000n/an/a1.0001.000recovers the true causes
Bowling0.667n/an/a1.0001.000
Video Pinball0.667n/an/a0.9761.000
Tennis0.533n/an/a0.9671.000
Space Invaders0.500n/an/a0.9821.000
Chopper Command0.452n/an/a0.9901.000
Road Runner0.444n/an/a0.9871.000
Hero0.400n/an/a0.9891.000
Private Eye0.364n/an/a1.0001.000
Double Dunk0.333n/an/a0.9621.000
Krull0.333n/an/a0.9750.333
Riverraid0.320n/an/a0.9721.000
Pitfall0.308n/an/a0.9751.000
Breakout0.286n/an/a1.0001.000
Seaquest0.250n/an/a0.9841.000
Air Raid0.222n/an/a0.9551.000
Asterix0.222n/an/a0.9721.000
Carnival0.200n/an/a0.9971.000
Yars' Revenge0.200n/an/a0.9491.000
Montezuma's Revenge0.125n/an/a0.9761.000
Boxing0.111n/an/a0.8911.000
Demon Attack0.105n/an/a0.9621.000
Berzerk0.043n/an/a0.9571.000no true-cause signal
Alien0.000n/an/a1.000n/ano true-cause signal
Assault0.000n/an/a0.990n/ano true-cause signal
Atlantis0.000n/an/a1.000n/ano true-cause signal
Centipede0.000n/an/a0.972n/ano true-cause signal
Enduro0.000n/an/a0.500n/ano true-cause signal
Frostbite0.000n/an/a0.977n/ano true-cause signal
Ice Hockey0.000n/an/a0.922n/ano true-cause signal
Jamesbond0.000n/an/a0.981n/ano true-cause signal
Kangaroo0.000n/an/a0.995n/ano true-cause signal
Ms. Pac-Man0.000n/an/a0.947n/ano true-cause signal
Pacman0.000n/an/a0.982n/ano true-cause signal
Phoenix0.000n/an/a0.992n/ano true-cause signal
Pong0.000n/an/a0.839n/ano true-cause signal
Skiing0.000n/an/a0.917n/ano true-cause signal
Venture0.000n/an/a0.938n/ano true-cause signal

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_phaseA.json.

Applied on the substrate

  1. assemble the shared gameplay-state testbed (seeded random-action stream, bit-exact checkpoint at f*, cause-density gate) — build_a1_shared_state(game) -> build_shared_testbed(game; ...) runner
  2. build_shared_testbed definition: booted checkpoint + shared n_changed_px output + cause-density gate — function build_shared_testbed(game; ...) runner
  3. cause-density gate scores each cause via the injected oracle run_intervention and counts |Delta_y|>floor — cause_density = count(>(floor), deltas) runner
  4. boot the real ROM and deterministically replay to the intervention frame (runner-local boot_replay) — checkpoint = boot_replay(spec, actions, target_frame) runner
  5. fresh env with xitari-parity boot (60 NOOP + 4 RESET) inside boot_replay — env_reset!(env; boot_noop_steps=60, boot_reset_steps=4) runner
  6. step the real emulator one frame per action — env_step!(env, Int(actions[i])) jutari
  7. read the 128-byte RIOT RAM out of the console — get_ram(env) jutari
  8. snapshot RAM+screen at the target frame (state to run the graph on) — at_target = continue_from(checkpoint, Int[]) runner

The computation

  1. the RECOVERED data-flow graph (method under test): single cheap do(i:=base+17), 1-step latency, edge i->j iff cell j differs from baseline — recovered_dataflow_graph(checkpoint, tail, cands, at_target; delta=17, latency=1) runner
  2. the TRUE data-flow graph (ground truth): exhaustive do-set {0, base+17, base+37} at full horizon, edge i->j iff cell j changes for ANY value — true_dataflow_graph(checkpoint, tail, cands, at_target) runner
  3. each edge probe intervenes on a RAM byte then re-runs the tail (uses intervene_ram!) — intervene_continue(checkpoint, c.ram_index, v, tail) runner
  4. score recovered vs true adjacency: precision/recall/F1/graph-edit-distance over off-diagonal edges — score_graph(rec_graph, true_graph) runner

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

Implementation
tools/xai_study/phaseA_kording/A1_connectomics.jl
Reference
cf. Jonas & Kording 2017
Record
A1_pong.json
All records
phaseA_kording/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.