betaFeedback

WorksComputer Science

Probability-Signature Dynamics: Unpacking Modular Addition Learning Within Two-Layer Networks

Abstract

Neural networks trained on modular addition tasks often develop Fourier-structured representations that support exact generalization. While prior work has identified these Fourier circuits, the mechanism by which gradient-based training selects them from the data distribution remains unclear. We address this question using probability signatures, which express leading gradient interactions through conditional statistics of the training distribution. For modular addition, these signatures are cyclic shift operators and are diagonalized by the discrete Fourier transform, yielding approximately decoupled Fourier-mode dynamics. This explains the emergence of Fourier sparsity, frequency matching, and phase alignment. The same framework resolves a puzzle under label noise: corrupted examples can show faster early loss decrease than clean examples, despite lacking a coherent generalization rule. We show that noise increases conditional label collisions, strengthening early shared-coordinate reinforcement. Finally, this method can be applied to other operators. Taking XOR as an example, we observed the predicted frequency in experiments.

Introduction

The modular addition task is a canonical setting in which to study grokking. During the initial phase of training, an over-parameterized model can fit individual training examples yet fails to uncover an interpretable rule. After substantially prolonged training, however, its test performance may improve abruptly even though the training loss has already become very small. This delayed transition is commonly referred to as grokking. In modular addition, the onset of grokking is accompanied by the emergence of a distinctive structure in the weights. Prior studies have shown that trained networks develop Fourier circuits ([12, 3]. Specifically, the input and output weights of many hidden units become concentrated at matching Fourier frequencies, and appropriate combinations of these Fourier components can compute (a+b) mod P(a + b) \bmod P. Mechanistic interventions, including Fourier projection and ablation experiments, provide strong evidence that these components are functionally important for generalization. Their formation also reflects the transition from a memorizing solution to a generalizing one.

These results answer an important reverse question: given a trained network, which circuit does it implement, and which components of that circuit support generalization? They have not fully answered the complementary forward question: why should gradient-based training produce Fourier-structured parameters from the modular-addition data distribution in the first place? The fact that Fourier features can represent modular addition does not imply that the training dynamics must discover them. Meanwhile, current work can already account for observed phenomena in neural networks, such as frequency competition and phase alignment ([4]). However, its theoretical analysis is based on a Fourier decomposition of the weights, which need to presuppose that the Fourier basis is related to modular addition.

Our focus is therefore not to show again that Fourier-structured neurons can implement modular addition, nor to re-establish that these neurons support generalization. Instead, we study the missing forward direction

training distribution⟹leading gradient terms⟹Fourier-mode selection.\text{training distribution} \Longrightarrow\text{leading gradient terms} \Longrightarrow\text{Fourier-mode selection}.

More specifically, we ask the following questions. Which statistics of the training data enter the leading-order parameter dynamics? Why are Fourier modes approximately decoupled in the modular-addition problem? What determines whether a neuron is suppressed by weight decay or develops a dominant Fourier component? And, how to derive the weight structure in advance from the training distribution?

We study these questions in a two-layer embedding MLP trained on modular addition dataset with some randomly corrupted labels. Our main analytical tool is the probability signature framework introduced by Yao & Xu [16], which shows the correlation between data statistics and embedding without studying either modular addition learning or the key structure of data statistics.

Our contributions are as follows.

  • We utilize probability signatures to directly explain the emergence of dominant Fourier modes during the learning dynamics.

  • We have explained the puzzle in the early memorization regime: uniformly random label noise consistently exhibits a faster initial loss decrease than clean data. Some statistics from training distribution can measure this difference.

  • The analysis framework can be extended to more tasks, such as XOR, enabling us to predict the structures that network parameters may form before training.

Related Work

Grokking. Grokking, the delayed onset of generalization long after interpolation, was first reported on small algorithmic datasets, where weight decay proved essential [13]. Subsequent work explains the delay through properties of the optimization trajectory: effective theories of representation learning and norm growth [9], loss landscapes shaped by weight decay and initialization scale [10], instabilities of adaptive optimizers [14], and the transition from lazy to rich training dynamics [6]. These characterize when and why generalization occurs, from the emergent Fourier circuits as a result of training. Based on this, we point out that weight decay determines the formation of the Fourier structure as a threshold, which establishes the connection between weight decay and Grokking.

Modular arithmetic. Prior work has established that trained networks can implement modular addition through sparse Fourier circuits, and has introduced diagnostics such as frequency matching and phase alignment to characterize these circuits [12]. Analytic and scaling-oriented studies have further related the norms and spectral profiles of Fourier modes to the learned solution [3, 11]. These works provide important mechanistic and functional descriptions of Fourier structure in trained networks. Our analysis is based on these research results, but we present a forward perspective: starting from training distribution rather than from the Fourier circuits obtained through training. More recent work [4] provides a complete explanation for the frequency competition and phase alignment by decomposing neurons onto the Fourier basis. Compared with theirs, our contribution stands out in the fact that we do not require the prior knowledge of the Fourier circuit found in the modular-addition task. By studying the algebraic structure of the probability signature, we derive the Fourier basis as the common eigenvectors. We not only explain the above phenomena, but also we hope to provide a unified explanation for the puzzle of early noise and the extension to other training tasks.

Learning with corrupted labels. Neural networks can both generalize from structured examples and memorize corrupted labels. This interaction has been studied broadly through early learning and memorization dynamics [1, 8]. For algorithmic and modular-arithmetic tasks, prior work has documented robust generalization in the presence of label corruption and the coexistence of generalizing and memorizing subnetworks [2, 7]. Our contribution is not a general theory of learning under label noise. Instead, we isolate one early-time phenomenon: randomly corrupted examples lead to faster initial loss decrease, and we relate it to probability signature, which is computable from the training data.

Preliminaries

Settings

Let Ω={0,1,…,P−1}\Omega= \{0,1,\ldots,P-1\} be a finite alphabet, where PP is a prescribed prime. We consider the prediction of a binary operation F:Ω×Ω→ΩF : \Omega\times\Omega\to\Omega from examples X=(a,b)X = (a,b) to the label F(a,b)F(a,b).

All pairs in Ω×Ω\Omega\times\Omega are divided into three disjoint subsets Dclean,Dnoise,Dtest\mathcal{D}_{\mathrm{clean}}, \mathcal{D}_{\mathrm{noise}}, \mathcal{D}_{\mathrm{test}} of cardinalities NcleanN_{\mathrm{clean}}, NnoiseN_{\mathrm{noise}}, and NtestN_{\mathrm{test}}, respectively. The labels of clean and test are set to F(a,b)=(a+b) mod PF(a,b) = (a+b) \bmod P, while the labels of noise are replaced by uniform random numbers.

The training dataset consists of Dclean\mathcal{D}_{\mathrm{clean}} and Dnoise\mathcal{D}_{\mathrm{noise}}. We define Ntrain=Nclean+NnoiseN_{\mathrm{train}} = N_{\mathrm{clean}} + N_{\mathrm{noise}}, where Ntrain:Ntest=8:2N_{\mathrm{train}} : N_{\mathrm{test}} = 8 : 2 and Nnoise=αNtrainN_{\mathrm{noise}} = \alpha N_{\mathrm{train}}. α\alpha represents the noise ratio.

Model. Let ea,eb∈RPe_a, e_b \in\mathbb{R}^{P} be one-hot encodings. We study the two-layer MLP f(a,b)=Wσ(Uea+Veb)∈RPf(a,b) = W\sigma(Ue_a + Ve_b) \in\mathbb{R}^{P}, where U,V∈RD×PU,V \in\mathbb{R}^{D \times P}, W∈RP×DW \in\mathbb{R}^{P \times D}, ea,ebe_a,e_b means the one-hot encodings of input a,ba,b, and D≫PD \gg P. The output distribution is softmax⁡(f(a,b))\operatorname{softmax}(f(a,b)).

We use the cross-entropy loss function and employ L2L^2-weight decay with coefficient λ\lambda. Parameters are initialized independently according to Uij,Vij,Wij∼N(0,D−2γ)U_{ij}, V_{ij}, W_{ij} \sim\mathcal{N}(0, D^{-2\gamma}), where γ\gamma controls the initialization scale. Consider a continuous gradient flow model as an approximation, it is dθdt=−η(∇θL+λθ)\frac{\mathrm{d}\theta}{\mathrm{d}t} = -\eta(\nabla_\theta L + \lambda\theta). For more details about initialization, learning rate or optimizer, please refer to the appendix A.

Probability signatures

The Probability Signature proposed in the related work [16] is a statistical quantity derived from sampling and not dependent on training. It can characterize the main terms of the gradient at different training stages. In order to create the application environment for Probability Signature, we first extended the fully connected network with the same embedding to our model.

Proposition 1 (Gradient flow). Assume the neural network f(x,y)=Wσ(Uex+Vey)f(x,y) = W\sigma(Ue_x + Ve_y), using full batch GD with cross-entropy loss and ignoring weight decay, with the activation function σ(h)=0+c1h+c22h2+o(h2)\sigma(h) = 0 + c_1h + \frac{c_2}{2}h^2 + o(h^2) which is C3C^3 near zero. If we sample training data from (x,y,z)∼π(x,y,z) \sim\pi, then we denote the probability that the first position is xx by rxr_x and the random variable Eπ[⋅∣x]\mathbb{E}_{\pi}[\cdot\mid x] by the conditional expectation under the fixed first position.

Under the assumption of small initialization that ∥U∥∞,∥V∥∞,∥W∥∞≤ϵ\lVert U\rVert_{\infty}, \lVert V\rVert_{\infty}, \lVert W\rVert_{\infty} \le\epsilon, we derived that

dUxdt=rxη{c1WT(I−1P1P1PT)[Eπ[ez∣x]−c1PW(Ux+Eπ[Vy∣x])]+c2Eπ[((Ux+Vy)⊙WT(ez−1P1P))|x]}+δ.\frac{\mathrm{d}U^x}{\mathrm{d}t} = r_x\eta\left\{ c_1 W^{\mathsf{T}}\left(I-\frac{1}{P}\mathbf{1}_P\mathbf{1}_P^{\mathsf{T}}\right)\left[\mathbb{E}_{\pi}[e_z \mid x]-\frac{c_1}{P}W\left(U^x+\mathbb{E}_{\pi}[V^y\mid x]\right)\right] + c_2\mathbb{E}_{\pi}\left[\left((U^x+V^y)\odot W^{\mathsf{T}}\left(e_z-\frac{1}{P}\mathbf{1}_P\right)\right)\middle|x\right]\right\}+\delta.

where Ux∈RdU^x \in\mathbb{R}^{d} represent the xx-th column of UU and ∥δ∥∞=O(ϵ3)\lVert\delta\rVert_{\infty} = O(\epsilon^3) means the higher order terms.

Proof. See Appendix E.1.

From the gradient flow equation, we can further decompose the conditional expectation. Assume sampling from the training distribution (X,Y,Z)∼π(X,Y,Z) \sim\pi, we define the probability signatures:

φ(a)(x,z)=P(Z=z∣X=x),φ(b)(x,z)=P(Z=z∣Y=x).\varphi^{(a)}(x,z) = \mathbb{P}(Z=z \mid X=x), \qquad\varphi^{(b)}(x,z) = \mathbb{P}(Z=z \mid Y=x).

the 3-order tensor joint probability signatures:

Φ(a)(x,y,z)=P(Z=z,Y=y∣X=x),Φ(b)(x,y,z)=P(Z=z,X=y∣Y=x).\Phi^{(a)}(x,y,z) = \mathbb{P}(Z=z,Y=y \mid X=x), \qquad\Phi^{(b)}(x,y,z) = \mathbb{P}(Z=z,X=y \mid Y=x).

and the trace-back probability signatures

ψ(a)(x,y)=P(Y=y∣X=x),ψ(b)(x,y)=P(X=y∣Y=x).\psi^{(a)}(x,y) = \mathbb{P}(Y=y \mid X=x), \qquad\psi^{(b)}(x,y) = \mathbb{P}(X=y \mid Y=x).

We also denote φx(a):=∑z∈ΩP(Z=z∣X=x)ez\varphi_x^{(a)} := \sum_{z\in\Omega}\mathbb{P}(Z=z\mid X=x)e_z, a column vector, and Φx(a):=∑y,z∈ΩP(Z=z,Y=y∣X=x)ey⊗ez\Phi_x^{(a)} := \sum_{y,z\in\Omega}\mathbb{P}(Z=z,Y=y\mid X=x)e_y\otimes e_z, a matrix. The same notation applies to the others. Then we can rewrite the gradient flow equation in Proposition 1 as

dUxdt=rxη{c1W⊤[(φx(a)−1P1P)−c1P(I−1P1P1P⊤)W(Ux+Vψx(a))]\frac{dU^x}{dt}=r_x\eta\left\{c_1W^\top\left[\left(\varphi_x^{(a)}-\frac{1}{P}\mathbf{1}_P\right)-\frac{c_1}{P}\left(I-\frac{1}{P}\mathbf{1}_P\mathbf{1}_P^\top\right)W\left(U^x+V\psi_x^{(a)}\right)\right]\right.
+c2[Ux⊙W⊤φx(a)−1P(Ux+Vψx(a))⊙(W⊤1P)+diag⁡(VΦx(a)W)]}+δ.\left.\quad+c_2\left[U^x\odot W^\top\varphi_x^{(a)}-\frac{1}{P}\left(U^x+V\psi_x^{(a)}\right)\odot\left(W^\top\mathbf{1}_P\right)+\operatorname{diag}\left(V\Phi_x^{(a)}W\right)\right]\right\}+\delta.

The above statistics φ\varphi, Φ\Phi, ψ\psi are referred to as Probability Signatures.

Theoretical Analysis

In this chapter, we hope to derive this frequency structure from a forward perspective. Reviewing the gradient flow equation 1, we divide it into φ\varphi-part, Φ\Phi-part and ψ\psi-part based on the association with different probability signatures. Additionally, due to the weight decay, there is also a −λU-\lambda U term. The proof of the following theorems will be found in Appendix E.2,E.3, and E.4.

Theorem 1 characterizes the dominant part of the gradient flow equation.

References

  1. [1]Devansh Arpit, Stanislaw Jastrzebski, Nicolas Ballas, David Krueger, Emmanuel Bengio, Max S. Kanwal, Tegan Maharaj, Asja Fischer, Aaron Courville, Yoshua Bengio, and Simon Lacoste-Julien. A closer look at memorization in deep networks. In International Conference on Machine Learning, 2017.arxiv.org/abs/1706.05394
  2. [2]Darshil Doshi, Aritra Das, Tianyu He, and Andrey Gromov. To grok or not to grok: Disentangling generalization and memorization on corrupted algorithmic datasets. In International Conference on Learning Representations, 2024.arxiv.org/abs/2310.13061
  3. [3]Andrey Gromov. Grokking modular arithmetic, 2023.arxiv.org/abs/2301.02679
  4. [4]Jianliang He, Leda Wang, Siyu Chen, and Zhuoran Yang. On the mechanism and dynamics of modular addition: Fourier features, lottery ticket, and grokking, 2026.arxiv.org/abs/2602.16849
  5. [5]Arthur Jacot, Franck Gabriel, and Clément Hongler. Neural tangent kernel: Convergence and generalization in neural networks, 2020. URL https://arxiv.org/abs/1806.07572.
  6. [6]Tanishq Kumar, Blake Bordelon, Samuel J. Gershman, and Cengiz Pehlevan. Grokking as the transition from lazy to rich training dynamics. In International Conference on Learning Representations, 2024.arxiv.org/abs/2310.06110
  7. [7]Linyu Liu and Pinyan Lu. Unveiling memorization-generalization coexistence: A case study on arithmetic tasks with label noise, 2026. URL https://arxiv.org/abs/2605.18022.
  8. [8]Sheng Liu, Jonathan Niles-Weed, Narges Razavian, and Carlos Fernandez-Granda. Early-learning regularization prevents memorization of noisy labels. In Advances in Neural Information Processing Systems, 2020.arxiv.org/abs/2007.00151
  9. [9]Ziming Liu, Ouail Kitouni, Niklas Nolte, Eric J. Michaud, Max Tegmark, and Mike Williams. Towards understanding grokking: An effective theory of representation learning, 2022.arxiv.org/abs/2205.10343
  10. [10]Ziming Liu, Eric J. Michaud, and Max Tegmark. Omnigrok: Grokking beyond algorithmic data. In International Conference on Learning Representations, 2023.arxiv.org/abs/2210.01117
  11. [11]Eric J. Michaud, Ziming Liu, Uzay Girit, and Max Tegmark. The quantization model of neural scaling. In Advances in Neural Information Processing Systems, 2023.
  12. [12]Neel Nanda, Lawrence Chan, Tom Lieberum, Jess Smith, and Jacob Steinhardt. Progress measures for grokking via mechanistic interpretability. In International Conference on Learning Representations, 2023.arxiv.org/abs/2301.05217
  13. [13]Alethea Power, Yuri Burda, Harri Edwards, Igor Babuschkin, and Vedant Misra. Grokking: Generalization beyond overfitting on small algorithmic datasets, 2022.arxiv.org/abs/2201.02177
  14. [14]Vimal Thilak, Etai Littwin, Shuangfei Zhai, Omid Saremi, Roni Paiss, and Joshua Susskind. The slingshot mechanism: An empirical study of adaptive optimizers and the grokking phenomenon, 2022.arxiv.org/abs/2206.04817
  15. [15]Zhi-Qin John Xu, Yaoyu Zhang, Tao Luo, Yanyang Xiao, and Zheng Ma. Frequency principle: Fourier analysis sheds light on deep neural networks. Communications in Computational Physics, 28(5):1746–1767, 2020.DOI
  16. [16]Junjie Yao and Zhi-Qin John Xu. Probability signature: Bridging data semantics and embedding structure in language models, 2025. URL https://arxiv.org/abs/2509.20124.
  17. [17]Chiyuan Zhang, Samy Bengio, Moritz Hardt, Benjamin Recht, and Oriol Vinyals. Understanding deep learning requires rethinking generalization, 2017. URL https://arxiv.org/abs/1611.03530.

Paper details

vlnc:W_uvju5men
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

Not recorded for this paper

View statement
Looking for related papers…
Contents