NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Uncovering a Universal Abstract Algorithm for Modular Addition in Neural Networks

Gavin McCracken, Gabriela Moisescu-Pareja, Vincent Létourneau, Doina Precup, Jonathan Love

In the world of mechanistic interpretability—the quest to reverse-engineer neural networks—modular addition is a classic "toy" problem. It is simple enough to analyze but complex enough to exhibit "grokking," a phenomenon where a model suddenly transitions from memorization to perfect generalization. However, recent studies hit a roadblock: different researchers found different "circuits" (such as the "Clock" and "Pizza" models) solving the same task. This discrepancy led many to wonder if the universality hypothesis—the idea that networks converge to similar internal solutions—was fundamentally flawed.

A new paper from researchers at Mila, McGill, Google DeepMind, and others argues that universality is alive and well. They demonstrate that these seemingly disparate solutions are actually just different implementations of a single, high-level strategy: the approximate Chinese Remainder Theorem (aCRT).

TL;DR

This paper unifies conflicting interpretations of how neural networks solve modular addition by showing they all implement an "approximate Chinese Remainder Theorem." By introducing approximate cosets, the authors prove that both Multilayer Perceptrons (MLPs) and Transformers converge to the same abstract algorithm, requiring only $\mathcal{O}(\log n)$ features in deep networks to achieve high-margin solutions.

The Problem: A Lack of Consistency

The core tension in interpretability research has been the lack of consistency across models. If you train a Transformer on modular addition, it might learn a "Clock" circuit relying on trigonometric identities. If you change the hyperparameters, it might learn a "Pizza" circuit. If you use a 1-layer MLP, it learns something else entirely.

This inconsistency suggested that neural networks lack a "universal" way of representing solutions. The authors tackle this by moving up a level of abstraction. They ask: instead of looking at specific weights (the "implementation level"), can we find a shared "algorithmic level" that explains all these behaviors?

Methods: Moving to the Algorithmic Level

The authors combine group theory with empirical deep learning analysis to bridge this gap:

  1. Approximate Cosets: They generalize the mathematical concept of a coset. While a standard coset requires strict modular equivalence, an "approximate coset" groups elements that are "behaviorally similar" based on their distance in a Cayley graph.
  2. The aCRT Framework: They propose the approximate Chinese Remainder Theorem as an abstract algorithmic template. In this view, neurons act as detectors for these approximate cosets, and the network's final output is an intersection of these detections.
  3. Multi-Level Analysis: They trained 1–4 layer MLPs and Transformers on modular addition across thousands of random seeds and hyperparameters.
  4. Frequency Remapping: To compare neurons across different models, they developed a "remapping" technique that normalizes different learned frequencies to a common baseline, allowing for direct qualitative comparison.

Key Insights and Ideas

  • The Unification "Aha": The authors show that once you "remap" the frequencies, the pre-activations of neurons in an MLP, a Clock Transformer, and a Pizza Transformer look virtually identical. They are all doing the same thing: dividing the input space into approximate cosets.
Remapped pre-activations across architectures
  • Depth Breeds Efficiency: A major finding is that 1-layer networks are "lazy"—they often learn $\mathcal{O}(n)$ frequencies (one for every possible frequency). However, adding just one more layer or using trainable embeddings causes a phase transition where the network becomes much more efficient, needing only $\mathcal{O}(\log n)$ frequencies.
  • Algorithm vs. Implementation: This paper distinguishes between the abstract algorithm (aCRT) and the circuit implementation (Clock vs. Pizza). Just as "sorting" is an abstract algorithm that can be implemented via Quicksort or Mergesort, modular addition is solved via aCRT, regardless of the specific architecture.
  • Bridging Tasks: By using cosets as the fundamental unit, they link modular addition (cyclic groups) to permutation groups (sorting lists), suggesting a path toward a "Universal Theory of Group Operations" in neural networks.

Key Results

  • Logarithmic Scaling: The authors proved and empirically verified that deep networks only need $\mathcal{O}(\log n)$ distinct frequencies to solve the task with high confidence. This explains why previous researchers only saw a "handful" of frequencies in their models.
Logarithmic scaling of learned frequencies
  • Robustness: The aCRT abstraction held true across a massive grid search of learning rates, weight decay values, and initialization seeds.
  • Margin Maximization: They recovered and extended theoretical results showing that these sinusoidal solutions are "maximum margin" solutions, meaning they are the most stable and generalizable ways to solve the problem.

Limitations and Future Work

While the paper provides a powerful unification, some questions remain:

  • The "Why" of the Phase Transition: While they observed that depth causes the shift from $\mathcal{O}(n)$ to $\mathcal{O}(\log n)$ frequencies, the exact training dynamics that drive this transition are still not fully understood.
  • Non-Commutative Groups: The current work focuses on cyclic (Abelian) groups. The authors suggest that testing on non-commutative groups (like the dihedral group) is the next logical step to "stress test" the universality hypothesis.
  • ReLU Complexity: The proofs for ReLU neurons are more complex than for quadratic activations. While the empirical evidence is strong, a full analytical proof for deep ReLU networks remains an open challenge.

By shifting the focus from "what are the weights doing?" to "what abstract algorithm is being implemented?", this paper provides a much-needed roadmap for making interpretability research more generalizable and theoretically grounded.

Summary updated

BibTeX
@inproceedings{mccracken2025uncovering,
  author = {Gavin McCracken and Gabriela Moisescu-Pareja and Vincent Létourneau and Doina Precup and Jonathan Love},
  title = {{Uncovering a Universal Abstract Algorithm for Modular Addition in Neural Networks}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=zuHs6RHQwT},
}
Figure