Low Rank and Sparse Fourier Structure in Recurrent Networks Trained on Modular Addition
Akshay Rangamani
TL;DR
The paper investigates how RNNs learn modular addition and reveals that they implement a Fourier multiplication algorithm, mirroring findings in one-layer transformers. Through Fourier analysis and causal interventions, the authors show the model relies on a sparse set of Fourier frequencies, with six dominant frequencies shared across inputs, hidden states, and outputs, and that key singular vectors align with these frequencies. They demonstrate near-exact Fourier multiplication in the final layer by fitting hidden representations to cosine and sine components at the identified frequencies, with relative errors on the order of $10^{-3}$ to $10^{-2}$. Ablation studies indicate distributed reliance on multiple frequencies, as removing several frequencies degrades performance substantially, while removing a single frequency often leaves functionality intact. These results extend mechanistic interpretability to RNNs and highlight a low-rank, frequency-based computation that could inform understanding of learning dynamics in other algorithmic tasks.
Abstract
Modular addition tasks serve as a useful test bed for observing empirical phenomena in deep learning, including the phenomenon of \emph{grokking}. Prior work has shown that one-layer transformer architectures learn Fourier Multiplication circuits to solve modular addition tasks. In this paper, we show that Recurrent Neural Networks (RNNs) trained on modular addition tasks also use a Fourier Multiplication strategy. We identify low rank structures in the model weights, and attribute model components to specific Fourier frequencies, resulting in a sparse representation in the Fourier space. We also show empirically that the RNN is robust to removing individual frequencies, while the performance degrades drastically as more frequencies are ablated from the model.
