Skip to content

Exploratory Lens Analysis: Grokking / Modular Addition

Section titled “Exploratory Lens Analysis: Grokking / Modular Addition”

Nanda et al. (2023) analyze a small transformer trained on modular addition (a+bmodpa + b \mod p) that undergoes “grokking” — sudden generalization long after memorizing the training set. They claim the model learns a Fourier-based algorithm: inputs are embedded into Fourier components (sinusoidal representations of position mod pp), attention computes trigonometric identities to combine them, and the output reads off the result from the Fourier representation.

This is the strongest structural evidence in published MI — the weight matrices are fully reverse-engineered and the algorithm is mathematically specified. The catch: it is a toy model (1-layer transformer, mod-113 arithmetic). The construct validity question is whether this tells us anything about real models.

Verdict (framework paper, Table 6): Mechanistically Supported. Capped by: I6 (double dissociation).

LensStrongestWeakestOverall
ConstructC1/C2/C3 (all strong)Strong
InternalI2/I7 (sufficiency + confound)I6 (double dissociation)Mechanistically Supported
ExternalE1/E2 Intervention reach + Prompt generalizationE5 Graded responsePartial
MeasurementM2/M6 Baseline separation + InvarianceM5/M7 Sensitivity + Selection correctionPartial–Strong
InterpretiveV3 Alternative levelStrong

Overall verdict: Mechanistically Supported. The modular addition circuit has strong structural and causal evidence — the algorithm is mathematically specified and every weight matrix is accounted for. The capping criterion is I6 (double dissociation): no study has tested a second behavior that the Fourier circuit spares while ablating a matched control circuit impairs. Despite the completeness of the reverse engineering, this crossed-design test has not been performed.

The scope limitation is narrower than it looks: E4 is partial rather than untested — one- and two-layer transformers are run at origin, and nothing larger. The capping criterion remains I6.

MethodOur metricFamily
Weight-space Fourier decompositionB01 SVD/SpectralStructural
Per-frequency ablationA01 Pearl SCMCausal
Activation probing (Fourier components)E02 Linear ProbeRepresentational
Mechanistic prediction (exact output reproduction)D04 CE DeltaBehavioral
Training dynamics analysis (phase transition)D04 CE DeltaBehavioral

To run these metrics yourself, see Experiment 10: Published Circuit Evaluation.


Philosophy of Science Lens — Construct Validity

Section titled “Philosophy of Science Lens — Construct Validity”

Is “the Fourier algorithm” a coherent construct?

C1 — Falsifiability: Strong pass. The claim specifies the exact algorithm: the model computes cos(2πk(a+b)/p)\cos(2\pi k(a+b)/p) via trigonometric identities applied in the attention layer. This generates precise quantitative predictions about every weight matrix entry. Any deviation from the predicted Fourier structure would disconfirm the claim.

C2 — Structural plausibility: Strong pass. This is the paper’s primary achievement. The embedding matrix entries are verified to approximate cos(2πka/p)\cos(2\pi k a/p) and sin(2πka/p)\sin(2\pi k a/p) for specific frequencies kk. The attention pattern implements the trigonometric addition formula. The unembedding reads off the result. Every weight matrix is accounted for — not just “consistent with” but “mathematically predicted by” the Fourier algorithm.

C4 — Discriminant validity: Partial. Excluded loss rises during circuit formation while train loss stays flat, which separates the Fourier mechanism from memorization. No neighboring construct is localized to separate it from.

I3 — Minimality: Partial. Every key frequency is load-bearing on a leave-one-out at frequency granularity. At neuron granularity it does not hold: 79 of 512 neurons fail the polynomial fit the account predicts.

C3 — Convergent validity: Partial. The Fourier structure is identified through weight-space analysis (Fourier decomposition of WEW_E), activation-space analysis (probing for Fourier components), and mechanistic prediction (computing exact predicted outputs from the algorithm and comparing to actual outputs). Three evidence families at origin, but all three descend from Fourier-space ablation, so their agreement is partly the same primitive with itself.

  • Confirmation vs corroboration: The training dynamics provide genuine corroboration: watching Fourier components emerge during grokking was not predicted by the static weight analysis but independently confirms the same mechanistic story. This temporal dimension elevates the evidence beyond mere confirmation.
  • Operationalism vs realism: The construct is fully operationalized — “Fourier features” refers to specific measurable weight-matrix entries, not an abstract theoretical posit. The operational definition exhausts the phenomenon, dissolving the question of whether this is “real understanding.”
  • Observable vs theoretical: There is no gap between the observable and theoretical here. The claimed entities (Fourier components in weight matrices) are directly observable in the parameters — no inference chain is required. This eliminates the underdetermination problem.

The Fourier algorithm construct connects to:

  • Weight structure — embedding entries approximate cos(2πka/p)\cos(2\pi k a/p) and sin(2πka/p)\sin(2\pi k a/p) (structural, confirmed)
  • Attention mechanism — implements trigonometric addition formula (structural, confirmed)
  • Output prediction — algorithm reproduces model outputs to numerical precision (behavioral, confirmed)
  • Training dynamics — Fourier components emerge during grokking phase transition (temporal, confirmed)
  • Per-frequency ablation — removing a frequency degrades specific input pairs (causal, confirmed)
  • Cross-seed replication — same algorithm type emerges across random seeds (consistency, confirmed)
  • Cross-architecture transfer — does the algorithm appear in multi-layer or larger models? (untested)

Six nodes confirmed, one unconnected. The thickest nomological network of any MI result — every internal prediction is verified, with only the external generalization edge remaining open.


Does the evidence establish implementation?

I1 — Necessity: Pass. Ablating specific Fourier frequencies (zeroing the corresponding components in the embedding) degrades performance on input pairs involving those frequencies. The ablation is at the feature level rather than the component level, which is more precise.

I2 — Sufficiency: Pass. The Fourier algorithm, when executed manually on the model’s weights, reproduces the model’s outputs to high precision. This is the strongest possible sufficiency: the algorithm is the model, not just a description of it.

I4 — Specificity: N/A. One task; the model has no off-target behavior to spare. This is a statement about the setting, not a pass — a single-task toy model licenses less than a model doing many things.

I7 — Confound control: Partial. Training the models is what buys the controls. Data fraction, modulus, depth, seed, regularizer type and weight-decay strength are all varied rather than found, and the λ = 0 run is the sharpest: with the regularizer removed the excluded loss stays flat, so the circuit does not form and grokking does not occur. What remains uncontrolled is on the analysis side, where thresholds are fixed, and in the architecture, since every mainline conclusion rests on one width and one depth.

  • Lesion vs stimulation: Both directions are demonstrated: ablating individual Fourier components degrades specific inputs (lesion), and the complete algorithm reproduces outputs from weights alone (equivalent to showing sufficiency without stimulation artifacts).
  • Structural vs functional connectivity: Structural connectivity (weight-space Fourier patterns) and functional connectivity (which inputs activate which components during inference) are both fully characterized and perfectly aligned. In real models, these often dissociate.
  • Single vs double dissociation: Not demonstrated. Per-frequency ablation is a within-mechanism decomposition, not a crossed design: no second mechanism has been shown intact under an ablation that breaks the Fourier circuit. This is the criterion that caps the claim.
Input pairs using frequency k1k_1Input pairs using frequency k2k_2Input pairs using frequency k3k_3
Ablate frequency k1k_1↓↓ (strong)No effectNo effect
Ablate frequency k2k_2No effect↓↓ (strong)No effect
Ablate frequency k3k_3No effectNo effect↓↓ (strong)

A clean diagonal within a single mechanism — each frequency is load-bearing for its own input pairs. This is frequency-level decomposability, not double dissociation: a crossed design needs a second mechanism that survives what breaks this one, and none has been run.


Does intervening on the mechanism produce expected downstream effects?

E1 — Intervention reach: Pass. You can manipulate specific Fourier components and predict the exact change in outputs. Complete intervention control.

E5 — Graded response: Not tested. Ablation is binary per component. No intervention interpolates between full and zero strength, so no dose-response curve exists.

E2 — Prompt generalization: Pass (within scope). The algorithm works for all inputs in the modular arithmetic domain.

E4 — Cross-model generalization: Weak — the critical gap. This is a 1-layer toy transformer. Whether real models (GPT-2, Pythia) use Fourier-like representations for arithmetic is unknown. The algorithmic insight may not transfer to models with multiple layers, larger vocabularies, and diverse training data.

  • The system compensates: Because this is a toy model trained on a single task, system compensation is essentially absent — there are no alternative pathways or redundant mechanisms that could mask intervention effects. This is why ablation results are so clean, and why this clarity may not transfer to real models.
  • Affinity vs efficacy: Both are maximally demonstrated. The Fourier structure shows the mechanism has the capacity (affinity) and the complete output reproduction shows it exercises that capacity (efficacy). There is no gap between structural potential and functional reality.
  • Naming requires criteria: “Fourier features” is perhaps the most rigorously operationalized name in MI — it refers to specific measurable mathematical structure in weight matrices with a precise functional interpretation.

The grokking/modular addition circuit provides the ideal dose-response:

  • Dose axis: Scaling factor applied to a Fourier frequency component (0 = fully ablated, 1 = normal)
  • Response axis: Accuracy on input pairs relying on that frequency
  • Observed relationship: not measured — the dose axis here is circuit extent (which frequencies are removed), not intervention strength
  • EC₅₀: undefined — no intervention interpolates between full and zero strength
  • Selectivity: intervening on frequency kk affects the input pairs involving kk; the measurement is at frequency granularity, not intervention strength
  • Therapeutic window: undefined — a window requires a strength axis, and none was swept

This is the pharmacological ideal: a perfectly linear dose-response with perfect selectivity and no off-target effects. It serves as a reference standard against which real-model dose-response curves should be compared.


Measurement Theory Lens — Measurement Validity

Section titled “Measurement Theory Lens — Measurement Validity”

Are the metrics reliable and well-calibrated?

M1 — Reliability: Partial. Repetition is real at the level of training: five seeds at the mainline configuration, all five carried through the mechanism analysis, and a standard deviation of loss over runs reported. Repetition is absent at the level of the measurements that carry the mechanism claim — the fraction of variance explained is quoted as one number per direction with no interval, so the reader cannot tell how much of a 93.2% would survive resampling.

M6 — Invariance: Pass. The measurement works regardless of which specific frequencies the model chose — the type of algorithm is invariant across training runs.

M2 — Baseline separation: Pass. Random models show no Fourier structure. The signal is clearly above noise.

M5 — Sensitivity: Not tested. The controls are all known-negatives (untrained models, non-key frequencies). Nothing with a known answer is planted and recovered, so the instrument’s floor is unmeasured.

M4 — Calibration: Partial. Loss is reported in nats on a task whose chance level is fixed and known, so a number like 5.27 can be read directly as worse than a model predicting uniformly — more calibration than most interpretability results carry. The reference itself is never computed: “worse than uniform” is asserted and log 113 ≈ 4.73 appears nowhere, so the margin above chance has to be reconstructed by the reader. The fraction-of-variance-explained instrument has no false-positive reference at all.

  • Reliability vs validity: Both are maximally satisfied. The Fourier decomposition is perfectly reliable (deterministic, reproducible across seeds at the algorithm-type level) and perfectly valid (it predicts outputs exactly). This is the measurement ideal that real-model studies aspire to.
  • Convergent vs discriminant validity: Four independent evidence lines (weight decomposition, activation probing, mechanistic prediction, training dynamics) all converge on the same Fourier structure. Discriminant validity is trivially satisfied — random untrained models show no Fourier structure whatsoever.
Weight decomposition (Fourier)Activation probing (Fourier)Mechanistic prediction (Fourier)Training dynamics (Fourier)
Weight decompositionHigh (convergent)High (convergent)High (convergent)
Activation probingHighHigh (convergent)High (convergent)
Mechanistic predictionHighHighHigh (convergent)
Training dynamicsHighHighHigh

All convergent cells are high — four independent methods identify the same structure. Discriminant validity is trivially satisfied (untrained models show zero Fourier structure by any method). This is a maximally well-behaved MTMM pattern: all methods agree on the presence of the construct, and all methods agree on its absence in controls.


Is the interpretation warranted by the evidence?

V1 — Level declaration: Partial. The level is legible from usage and never declared. The abstract puts an algorithm-level claim and an implementation-level method in consecutive sentences, and §3.1 states the algorithm as a four-step procedure without saying whether the claim is about the function computed, the algorithm used, or the weights that realize it. A reader can reconstruct the answer; the paper does not supply it.

V2 — Level-evidence match: Partial. The evidence sits mostly at the weight level for an algorithm-level claim, which is a close match and unusual in this audit set. The overreach is in the word fully: by the paper’s own numbers 79 of 512 neurons fall outside the single-frequency polynomial account, two of four attention heads receive a role introduced with “We speculate”, and the headline logit reconstruction explains 95% of variance rather than all of it.

V3 — Alternative level: Partial. Memorization is addressed and refuted. The basis alternative is not: Zhong et al. (2023) give two distinct algorithms over the same five frequencies, and the metrics that would separate them are not run here.

V5 — Scope declaration: Pass — with a caveat. The claim is honest about scope (modular addition in a toy model). The caveat is that readers may over-generalize: “transformers learn Fourier algorithms” is not what the paper shows. The paper shows that this toy model learns this Fourier algorithm.

  • Description vs explanation: This is the strongest example of genuine explanation in MI. The mechanistic account does not merely describe which components are active — it specifies the exact mathematical algorithm and explains why the weights take their specific values. The explanation is complete: given the task and the Fourier algorithm, every weight matrix entry is predicted.
  • Component identity vs component role: There is no gap between identity and role here. Each weight matrix entry has a precise functional interpretation derived from the Fourier algorithm. The “role” is not an interpretive label applied post hoc — it is a mathematical prediction verified against observations.
  • Faithfulness vs understanding: Both are maximally satisfied. The algorithm is faithful (it reproduces 100% of outputs) and understood (the mathematical basis is completely specified). This is the only MI result where faithfulness and understanding are both at ceiling.
  • Implementational → Interpretation: Perfect. Every weight matrix is decoded. No unexplained parameters.
  • Algorithmic → Interpretation: Perfect. The algorithm (Fourier-based trigonometric combination) is mathematically specified and verified.
  • Computational → Interpretation: Perfect (within scope). The computation (modular addition) is exactly what the algorithm produces.

All three levels converge perfectly — this is the only MI result with complete convergence across all evidence modes.

NecessitySufficiencyRepresentationalAlgorithmicComputational
Per-frequency ablation
Weight decomposition
Mechanistic prediction
Training dynamics

Nearly all cells filled. The only systematic gap is that ablation provides necessity but not sufficiency (you remove something and performance drops, but you cannot “add” a new frequency). The weight decomposition and mechanistic prediction rows provide sufficiency (the algorithm reproduces outputs without any intervention). This is the most complete intervention-interpretation matrix in MI.

  • Input tokens → Fourier embedding: solid (embedding matrix entries are verified as cos\cos/sin\sin of input position)
  • Fourier embedding → trigonometric combination (attention): solid (attention weights implement the addition formula)
  • Trigonometric combination → output decoding: solid (unembedding reads off the result from the combined representation)
  • Full path (input → embedding → attention → output): solid (complete end-to-end causal chain verified by exact output reproduction)

All edges solid. Every step in the causal chain is independently verified AND the complete chain reproduces outputs exactly. This is the only MI result with a fully verified causal sufficiency graph — no dashed edges, no unknown interactions, no gaps.