Grokking at the Edge of Linear Separability

## Abstract

Abstract We study the generalization properties of binary logistic classification in a simplified setting, for which a "memorizing" and "generalizing" solution can always be strictly defined, and elucidate empirically and analytically the mechanism underlying Grokking in its dynamics.
We analyze the asymptotic long-time dynamics of logistic classification on a random feature model with a constant label and show that it exhibits Grokking, in the sense of delayed generalization and non-monotonic test loss.
We find that Grokking is amplified when classification is applied to training sets which are on the verge of linear separability. Even though a perfect generalizing solution always exists, we prove the implicit bias of the logisitc loss will cause the model to overfit if the training data is linearly separable from the origin.
For training sets that are not separable from the origin, the model will always generalize perfectly asymptotically, but overfitting may occur at early stages of training.
Importantly, in the vicinity of the transition, that is, for training sets that are almost separable from the origin, the model may overfit for arbitrarily long times before generalizing.
We gain more insights by examining a tractable one-dimensional toy model that quantitatively captures the key features of the full model.
Finally, we highlight intriguing common properties of our findings with recent literature, suggesting that grokking generally occurs in proximity to the interpolation threshold, reminiscent of critical phenomena often observed in physical systems.

### 1 Introduction

Understanding the relationship between the intrinsic properties of data, the training dynamics of neural networks (NNs), and their ability to generalize is crucial to explaining the success of modern machine learning (ML) algorithms. In particular, highly over-parameterized models based on the transformer architecture (Vaswani et al., ), such as Large Language Models (LLMs) (OpenAI, ; Google, ; Zeng et al., ; Brown et al., ; Chowdhery et al., ; Anil et al., ), as well as state of the art models for computer vision (Srivastava and Sharma, ), defy expectations and are able to generalize with a number of parameters far exceeding the so called interpolation threshold (Kaplan et al., ; Schaeffer et al., ). Interestingly, these models have been shown to exhibit unpredictable behaviors when changing the number of network parameters, not only with respect to generalization, but also in their learning dynamics.

One such phenomenon is Grokking, first observed by (Power et al., ) when training a transformer model on modular arithmetic tasks. Grokking occurs when a model initially achieves perfect training accuracy but no generalization (i.e. no better than a random predictor), and upon further training, transitions to almost perfect generalization.
This phenomenon has garnered substantial attention in recent years (Gromov, ; Liu et al., ; Xu et al., ) due to its striking contrast with naive expectations, whereby over-fitting is generally seen as an undesirable property of models that should not generalize with further training, originally dealt with using early stopping (Prechelt, ).

In this work, we study grokking in a synthetic, yet illuminating, setting where the asymptotic optimal solution can always be identified, allowing a sharp definition of notions which are typically ambiguous, such as “memorization” and “learning”.
Concretely, we focus on the extreme case of feature noise where the network needs to ignore the input features and classify all points as a constant label.
The input data are $N$ points in $\mathbb{R}^{d}$, drawn independently from an isotropic normal distribution with diagonal covariance, $\bm{x}_{i}\sim\mathcal{N}(0,\sigma\bm{I}_{d})$ where $\bm{I}_{d}$ is the $d\times d$ identity matrix and $\sigma>0$.
We study the limit of large $N,d\to\infty$, while keeping the ratio $\lambda=d/N$ fixed. Our main contributions are:

- •
We demonstrate both numerically and analytically that grokking may occur in this setting, and is promoted when $\lambda$ is close to 1/2 and $\sigma$ is large.
- •
We demonstrate that this occurs because $\lambda=1/2$ is the effective interpolation threshold, in the sense that for $\lambda<1/2$ the model will almost surely asymptotically approach perfect generalization accuracy and vanishing loss.
For $\lambda>1/2$ the model will almost surely achieve imperfect generalization accuracy and the population loss will diverge at long times.
- •
We prove that the generalization properties depend only on whether the training set is linearly separable from the origin.
The model will achieve asymptotically optimal generalization if and only if the origin is contained in the convex hull of the training set.
- •
Moreover, we show that near the threshold value, the dynamics may generically track the overfitting solution for arbitrarily long times before transitioning to the optimal generalizing solution, manifesting as non-monotonicity of the test loss and delayed generalization.
- •
We construct a simple, one-dimensional model which captures the salient aspects of the problem, and explicitly solve the time evolution of the network parameters for several interesting cases.

The main takeaway from our setup is that grokking happens near critical points in long-term dynamics, similar to the phenomenon known in the physics literature as ’critical slowing down’. While further study is needed, we believe this applies to other grokking examples (see for example (Levi et al., ; Liu et al., ; Gromov, )).

### 2 Related Work

Following the discovery of grokking by Power et al. (), numerous studies have attempted to elucidate its underlying mechanisms. Liu et al. () showed that when sufficient data determines the structured representation, perfect generalization can be achieved on a non-modular addition task. Other works have identified factors contributing to grokking (Davies et al., ; Nanda et al., ), analyzed the trigonometric algorithms learned by networks after grokking (Nanda et al., ; Chughtai et al., ; Merrill et al., ; Gromov, ), and demonstrated similar dynamics in sparse parity tasks (Merrill et al., ).
Additional works proposed "slingshots" (Thilak et al., ) or "oscillations" (Notsawo et al., ) as explanations for grokking, while others have studied the role of regularization, which has proven to significantly impact grokking in certain scenarios (Power et al., ; Liu et al., ).
Our work requires none of these in order to exhibit or explain grokking.

Recently, a body of works on solvable models which grok in various settings has emerged. Liu et al. (); Kumar et al. () and Lyu et al. () have linked grokking to memorization and transitions from lazy to rich dynamics. Žunkovič and Ilievski (); Gromov (); Doshi et al. () analyzed solvable models exhibiting grokking and related their findings to the formation of latent-space structure, Xu et al. () related grokking to benign over-fitting for ReLU networks on XOR data, Rubin et al. () described grokking as a first-order phase transition, and Levi et al. () provide the full dynamical solution of grokking in linear regression.
Our work attempts to fill the gap between solvable models and representation learning, whereby we can always identify the optimal solutions, while still solving the dynamics of the model.
To accomplish this, our work relies heavily on the results of Soudry et al. (); Nacson et al. (); Ji and Telgarsky (), which analyze the late-time dynamics properties of logistic regression for separable and inseparable data under gradient descent (GD).

### 3 Grokking in Binary Classification

#### 3.1 Model Setup and Empirical Results

We will now define the setup of the model performing binary classification using logistic regression and present the numerical evidence for grokking.
Consider a dataset of $N$ training samples $\bm{x}_{i}\in\mathbb{R}^{d}$
which are identically and independently distributed (iid) vectors, $\bm{x}_{i}\sim\mathcal{N}(0,\sigma^{2}\bm{I}_{d})$ with $\sigma>0$ the feature standard deviation, and $\bm{I}_{d}$ is the $d\times d$ identity matrix.
The task is logistic classification, where all input points are assigned the same label.
We work in the $N,d\to\infty$ regime, and their ratio, $\lambda=d/N$, plays a crucial role in the network’s training dynamics and generalization properties.

The network parameters consist of a weight vector $\bm{S}\in\mathbb{R}^{d}$ and a bias term $b\in\mathbb{R}$ and the network output is a scalar $f(\bm{x}_{i})=\bm{S}\cdot\bm{x}_{i}+b$.
We optimize the cross-entropy loss, given by

$$ $\displaystyle\mathcal{L}(\bm{S},b)$ $\displaystyle=\frac{1}{N}\sum_{i=1}^{N}\ell\left(\bm{S}^{T}\bm{x}_{i}+b\right)\ ,$ $\displaystyle\ell(f)$ $\displaystyle=\log\left(1+e^{f}\right)\ .$ (1) $$

We define the empirical accuracy over the dataset as

$$ $\displaystyle\mathcal{A}=\frac{1}{N}\sum_{i=1}^{N}\Theta\left(-\bm{S}^{T}\bm{x }_{i}-b\right),$ (2) $$

where $\Theta(z)$ is the Heaviside function.
The GD equations at training step $t$ with learning rate $\eta$ are

$$ $\displaystyle\bm{S}_{t+1}-\bm{S}_{t}=-\eta\nabla_{\bm{S}}\mathcal{L},\qquad\>b _{t+1}-b_{t}=-\eta{\partial_{b}}\mathcal{L}.$ (3) $$

In this paper we will focus primarily on the gradient flow limit ($\eta\rightarrow 0$)
of these equations.
In Fig. 1 we show numerical results depicting
the gradient-descent dynamics of the model across three values of $\lambda\equiv d/N$.
Notably, we observe a significant grokking effect, both in the non-monotonicity of the test loss, and the delayed increase in test accuracy, only when $\lambda$ approaches $\lambda_{c}=1/2$ (there may be some differences between the grokking observed here and other examples in the literature, but they seem to be superficial - see Appendix B).
In the following section, we explain how $\lambda_{c}$ can be interpreted as the interpolation threshold in this setting.

Figure: Figure 1: Left panels: Gradient descent dynamics for three different values of $\lambda=d/N$. In the top row and middle row, we show the loss and accuracy for the train and test datasets, while in the bottom row, we the present the evolution of $b(t)$ and $\left\lVert{\bm{S}(t)}\right\rVert$. Grokking is significant only when $\lambda$ approaches to $0.5$ from below. We can see that for $\lambda>0.5$, $\left\lVert{\bm{S}}\right\rVert$ increase indefinitely and generalization is not possible (see Eq. 6). The parameters are $N=4\cdot 10^{4},$$\sigma=5$, $\eta=0.01$. The direction of $\bm{S}(t=0)$ was drawn isotropically with $\left\|\bm{S}_{0}\right\|=0.1$ and $b(t=0)=0$. The number of test samples is $N_{\mathrm{test}}=10^{4}.$ Right panels: Top: The norm of the limiting value $\bm{S}_{\infty}$ in the separable case $\lambda>1/2$, as a function of $\lambda$. Note that $\left\lVert{\bm{S}_{\infty}}\right\rVert$ diverges for $\lambda\to\frac{1}{2}$. Middle: the accuracy at the end of the training (in blue), and the predicted limiting accuracy (orange), calculated only using the margin of the dataset, see Eq. 13. Bottom: The Grokking time, defined practically as the delay between the times where the training and generalization accuracy surpass a threshold of 0.9, versus $\lambda$. We can see that the Grokking time and $\left\lVert{\bm{S}_{\infty}}\right\rVert$ diverge near $\lambda=0.5$. Additional details regarding the experiments can be found in Appendix H.
Refer to caption: x1.png

#### 3.2 The Mechanism of Grokking in the Current Setting

We begin by examining the optimal generalizing solution, that indicates the network has properly learned the task.
Since the support of the input distribution is unbounded, the network should put all points in $\mathbb{R}^{d}$ on the same side of the separating hyperplane, or in other words, push the decision boundary to infinity.

To see this rigorously, we derive expressions for the generalization accuracy and
loss.
Since
the data is Gaussian, $x_{i}\sim\mathcal{N}(0,\sigma^{2}\bm{I}_{d})$, the generalization (population) loss is, by definition,

$$ $\displaystyle\mathcal{L}_{\mathrm{gen}}=\mathbb{E}_{x\sim\mathcal{N}(0,\sigma^ {2}\bm{I}_{d})}\left[\log\left(1+\exp\left(\bm{S}^{T}\bm{x}+b\right)\right) \right].$ (4) $$

Since $\bm{S}^{T}\bm{x}$ is a linear combination of normal variables, it is normally
distributed with zero mean and variance $\mathbb{E}\left[(\bm{S}^{T}\bm{x})^{2}\right]=\left\lVert{\bm{S}}\right\rVert^
{2}\sigma^{2}$, allowing us to perform a change of variables on Eq. 4, simplifying it to

$$ $\displaystyle\mathcal{L}_{\mathrm{gen}}=\mathbb{E}_{y\sim\mathcal{N}(0,1)} \left[\log\left(1+e^{\sigma\left\lVert{\bm{S}}\right\rVert y+b}\right)\right]\ .$ (5) $$

Note that $\mathcal{L}_{\mathrm{gen}}$ is a function of $b$ and $\left\lVert{\bm{S}}\right\rVert$ only.
Similarly, the accuracy is given by

$$ $\displaystyle\mathcal{A}_{\mathrm{gen}}(\bm{S},b)=\mathbb{E}_{y\sim\mathcal{N} (0,1)}\Big{[}\Theta\left(-\sigma\left\lVert{\bm{S}}\right\rVert y-b\right)\Big {]}=\frac{1}{2}\left[1-\mathrm{erf}\left(\frac{1}{\sqrt{2}}\frac{b}{\sigma \left\lVert{\bm{S}}\right\rVert}\right)\right]\ .$ (6) $$

In passing, we note that following the same procedure to obtain analogous expressions for the training loss and accuracy will not work.
As discussed below, the training dynamics drive $\bm{S}$ towards a value that depends on the training set, and hence the distribution of $\bm{S}^{T}\bm{x}$ on the training set deviates significantly from Gaussianity, see Fig. 2.

Examining these results, we see that indeed perfect generalization, i.e. $\mathcal{L}\rightarrow 0,$ $\mathcal{A}\rightarrow 1$, is achieved only for $b\rightarrow-\infty$ and $b/\left\lVert{\bm{S}}\right\rVert\rightarrow-\infty$, i.e., $b$ must tend to negative infinity while also being infinitely large compared to $\left\lVert{\bm{S}}\right\rVert$.

Indeed, the bottom panels of Fig. 1 show that the behavior of $b$ tends to $-\infty$ at late times in all parameter regimes.
However, while $\left\lVert{\bm{S}}\right\rVert$ saturates on a constant for $\lambda<1/2,$ it goes to $\infty$ at long times for $\lambda>1/2$, and does so at a rate comparable to $b$, leading to sub-optimal generalization $\lim_{t\to\infty}\mathcal{A}(\bm{S}(t),b(t))<1$.

These results are closely related to the framework developed by (Soudry et al., ), who studied the convergence of binary classification for linearly separable data, and later expanded by (Ji and Telgarsky, ) for inseparable data.
In our case, since the model contains a bias term and all labels are the same, the data is always separable by a hyperplane “at infinity”.
To use their framework, we need to work in an extended space of dimension $d+1$, where we define the extended weight vector $\bm{w}=(\bm{S},b)\in\mathbb{R}^{d+1}$.
A direct corollary of Theorem 3 from (Soudry et al., ) is that at long times, the training dynamics behave as

$$ $\displaystyle\bm{w}(t)$ $\displaystyle={\bm{w}_{\mathrm{SVM}}}\log(t)+\bm{\rho}(t)\ ,$ $\displaystyle{\bm{w}_{\mathrm{SVM}}}$ $\displaystyle=\underset{{}^{(\bm{S},b)}}{\mathrm{argmin}}\left\{\left\|\bm{S} \right\|^{2}+b^{2}\quad\hbox{s.t.}\quad\bm{S}^{T}\bm{x}_{i}+b\leq-1\right\}.$ (7) $$

Here, ${\bm{w}_{\mathrm{SVM}}}$ is the solution(^1^11Note that the SVM solution in the extended $d+1$ is not the same as the typical formulation of the Support Vector Machine (SVM) with bias in $d$ dimensions, because of the different penalty used for the bias term.) to the hard margin SVM problem in the extended $d+1$ space and $\bm{\rho}$ is a residual vector which is bounded for all $t$.

Connecting this result to the previous discussion, we see indeed that either $|b|$ and/or $\left\lVert{\bm{S}}\right\rVert$ must diverge at long times, and the question is now reduced to what is the direction of $\bm{w}_{\mathrm{SVM}}$.
The true generalizing solution, which classifies correctly all points in $\mathbb{R}^{d}$ is when ${\bm{w}_{\mathrm{SVM}}}=(0,-1)$, i.e. when it points in the direction of the bias and the separating plane is at infinity.
This is exactly the aforementioned condition $b\to-\infty$ and $|b|/\left\lVert{\bm{S}}\right\rVert\to\infty$.
Overfitting occurs when the hyperplane is only far enough from the data to correctly classify all the training samples.
In the extended space, this means that ${\bm{w}_{\mathrm{SVM}}}$ also contains a component in the direction of the data, and the model did not learn correctly the data distribution.

We are now ready to sketch our main claims regarding the grokking phenomenology presented in Fig. 1.
The details will be fleshed out in the next subsections. We claim that:

- •
The generalization and overfitting at long times depend only on whether the training samples (in $\mathbb{R}^{d}$) are linearly separable from the origin.
We call a training set separable if there exists a vector $\bm{S}$ such that $\forall i\ \bm{S}^{T}\bm{x}_{i}<-1$, and inseparable otherwise.
- •
In the limit of large $N,d$, the training set is almost surely separable (inseparable) for $\lambda>\frac{1}{2}$ ($\lambda<\frac{1}{2}$). This a direct corollary of Wendel’s theorem, (Wendel, ), see App. A for additional details.
- •
For separable training sets ($\lambda>\frac{1}{2}$), the model will always overfit, and the limiting generalization accuracy is directly related to the optimal separating margin.
For inseparable training sets ($\lambda<\frac{1}{2}$) the model will always generalize perfectly: $b$ diverges at long times and $\bm{S}$ saturates on a finite value $\lim_{t\to\infty}\bm{S}(t)=\bm{S}_{\infty}$. This is shown in Sec. 3.3.
- •
However, for $\lambda\lesssim\frac{1}{2}$, the training set is on the verge of separability, and $\left\lVert{\bm{S}_{\infty}}\right\rVert$ may be arbitrarily large.
Consequently, dynamics may take arbitrarily long times to reach the generalizing solution. This is the underlying mechanism of grokking in this setting.

#### 3.3 Overfitting and Linear Separability

When will over-fitting occur? Due to the “exponential tail” of the cross-entropy loss, at late times the loss is dominated by samples with large network outputs $f=\bm{S}^{T}\bm{x}+b$, for which the cross-entropy loss $\ell(f)$ of Eq. 1, approaches the exponential loss $\ell_{e}(f)=e^{f}$ (Soudry et al., ; Nacson et al., ).
Specifically, the exponential loss will converge to the same late time dynamics as the cross entropy loss. Therefore, we will consider the exponential loss for which the calculations are tractable,

$$ $\displaystyle\mathcal{L}_{e}(\bm{S},b)=\frac{1}{N}\sum_{i=1}^{N}e^{\bm{S}^{T} \bm{x}_{i}+b}.$ (8) $$

In the gradient-flow limit, the dynamics for the exponential loss are

$$ $\displaystyle\frac{\partial\bm{S}}{\partial t}$ $\displaystyle=-\frac{\eta}{N}e^{b}\sum_{i}e^{\bm{S}^{T}\bm{x}_{i}}\bm{x}_{i}\ ,$ $\displaystyle\frac{\partial b}{\partial t}$ $\displaystyle=-\frac{\eta}{N}e^{b}\sum_{i}e^{\bm{S}^{T}\bm{x}_{i}}\ .$ (9) $$

Note that both rates are proportional to a common time-dependent scalar $e^{b(t)}$.
Therefore one can define a so-called “conformal time”: $\tau(t)=\int_{0}^{t}e^{b(t^{\prime})}dt^{\prime}$,
which is a common measure in cosmology and gravitational physics to describe co-moving objects in an expanding or shrinking spacetime background (Guth, ).
In terms of $\tau$, the equations become

$$ $\displaystyle\frac{\partial\bm{S}}{\partial\tau}$ $\displaystyle=-\frac{\eta}{N}\sum_{i}e^{\bm{S}^{T}\bm{x}_{i}}\bm{x}_{i}\ ,$ $\displaystyle\frac{\partial b}{\partial\tau}$ $\displaystyle=-\frac{\eta}{N}\sum_{i}e^{\bm{S}^{T}\bm{x}_{i}}\ .$ (10) $$

The importance of this result is that the dynamics of $\bm{S}(\tau)$ in terms of the conformal time are identical to those of $\bm{S}(t)$ in the absence of bias.
That is, $\bm{S}(t)$ follows the same path that would be obtained by minimizing $\mathcal{L}=\frac{1}{N}\sum_{i=1}^{N}e^{\bm{S}^{T}\bm{x}_{i}}$, but does so at a different rate which depends exponentially on the current value of $b(t)$.
This is demonstrated in the middle panel of Fig. 2.
Since $\tau(t)$ diverges for $t\to\infty$, $\bm{S}(t)$ must follow the same path at long times, as it would have followed without bias (see App. C for details).

##### Inseparable training set

Using this result, let us consider the dynamics without bias.
In the case where the data is not separable, $\mathcal{L}_{e}$ of Eq. 8 is unbounded in all directions. That is, for any unit vector $\bm{e}\in\mathbb{R}^{d}$ s.t. $\left\lVert{\bm{e}}\right\rVert=1$ we have $\lim_{\alpha\to\infty}\mathcal{L}_{e}(\alpha\bm{e},0)=\infty$.
Since $\mathcal{L}_{e}$ is convex, the gradient flow dynamics will lead to a global minimum at a finite point $\lim_{t\to\infty}\bm{S}(t)=\bm{S}_{\infty}$.
From Eq. 7, we know that either $\left\lVert{\bm{S}(t)}\right\rVert$ or $|b(t)|$ must diverge, and since $\bm{S}(t)$ approaches a finite value, we conclude that $|b|/\left\lVert{\bm{S}}\right\rVert\to\infty$ at long times. That is, ${\bm{w}_{\mathrm{SVM}}}=(0,-1)$ and the model flows towards the generalizing solution.

##### Separable training set

For the separable case, it is easier to examine the optimization problem in Eq. 7 directly.
We wish to minimize $\left\lVert{\bm{w}}\right\rVert^{2}=\left\lVert{\bm{S}}\right\rVert^{2}+b^{2}$ under the separability constraints.
The generalizing solution $\bm{w}_{g}=(0,-1)$ satisfies all constraints trivially and has $\left\lVert{\bm{w}_{g}}\right\rVert=1$.
However, since the data is separable, there exists another solution to the constraints, namely $\bm{w}^{*}=(\bm{S}^{*},0)$, where $\bm{S}^{*}$ is the separating vector in $d$ dimensions without bias, i.e. the solution to

$$ $\displaystyle\bm{S}^{*}=\underset{{}^{\bm{S}}}{\mathrm{argmin}}\left\{\left\| \bm{S}\right\|^{2}\quad\hbox{s.t.}\quad\bm{S}^{T}\bm{x}_{i}\leq-1\right\}\ .$ (11) $$

The norm of $\bm{S}^{*}$ is the inverse of the separation margin $M=1/\left\lVert{\bm{S}^{*}}\right\rVert$.

Due to convexity, any convex combination of the form $\alpha\bm{w}_{g}+(1-\alpha)\bm{w}^{*}$ with $0<\alpha<1$ also satisfies the constraints, and since they are orthogonal, it also has a smaller norm.
The combination with the smallest norm is the global optimum, which is easily shown to be

$$ $\displaystyle{\bm{w}_{\mathrm{SVM}}}$ $\displaystyle=\frac{1}{1+M^{2}}(M^{2}\bm{S}^{*},-1)\ .$ (12) $$

That is, for long times both $\bm{S}$ and $b$ diverge, and we have

$$ $\displaystyle\lim_{t\rightarrow\infty}\frac{b(t)}{\left\|\bm{S}(t)\right\|}$ $\displaystyle=-\frac{1}{M}\ ,$ $\displaystyle\lim_{t\rightarrow\infty}\mathcal{A}_{\mathrm{gen}}$ $\displaystyle=\frac{1}{2}\left[1+\mathrm{erf}\left(\frac{1}{\sigma M\sqrt{2}} \right)\right].$ (13) $$

This is also verified by an independent calculation in App. G, and is demonstrated numerically in the inset of the middle panel of Fig. 2.
Finally, it can be shown directly from Eq. 5 that in this case the generalization loss diverges.
In Fig. 2, we present the distribution
of $\bm{S}^{T}\bm{x}_{i}/{\left\lVert{\bm{S}}\right\rVert}$ after training with GD, for various values of $\lambda$.
We can see that for $\lambda<1/2$ the dataset is inseparable, while it becomes separable for $\lambda>1/2$.

Figure: Figure 2: Evolution of the network parameters. In the left panel, we show the distribution of $\bm{S}^{T}x_{i}/{\left\lVert{\bm{S}}\right\rVert}$, where $\bm{S}=\bm{S}(t_{\mathrm{end}})$ is the final spatial weight vector that was found using GD dynamics for $\lambda=0.05,0.48,0.52,0.8$. The parameters are identical to those of Fig. 1. We can see that for $\lambda=0.05,0.48$ the model is not separable, while for $0.52,0.8$ it is. For $\lambda=0.8,$ the distance of the distribution from 0 0 is the margin, indicated by the dashed two-sided arrow. Middle panel: $\left\|\bm{S}(t)\right\|$, optimized with GD using the exponential loss given in Eq. 8, with and without a bias term. With a bias term, the result is shown as a function of the conformal time $\tau=\int_{0}^{t}e^{b(t^{\prime})}dt^{\prime},$ and we can indeed see that it follows the same path but at a different rate. In the inset, we show the numerical calculation of $\frac{d\left\lVert{\bm{S}}\right\rVert}{d\log(t)}$ and $\frac{db}{d\log(t)}$, and the expected limiting values given in Eq. 12. Right panel: Optimization paths for different $\lambda$ values, shown in the $b,\sigma\|\bm{S}\|$ plane. We see that for inseparable data, only $b$ diverges along the path, while slightly above the verge of separability, both $b,\sigma\|\bm{S}\|$ diverge, leading to sub-optimal generalization accuracy.
Refer to caption: x2.png

Figure: Figure 3: Illustration of the SVM solutions for the effective simplified model. The left panels: Illustration of how to find the hard margin SVM vector in 1+1 dimensions in the simplified model. For $\lambda<0.5$, we have $w_{\mathrm{SVM}}=\left(0,-1\right)$ while for $\lambda>0.5$ we have $w_{\mathrm{SVM}}=\left(\frac{M}{1+M^{2}},-\frac{1}{1+M^{2}}\right)$, where the margin is $M=2\lambda-1$. We note that finding $-w_{SVM}$ is equivalent to finding the minimum vector that is in the intersection of the two regions determined by $w_{\mathrm{SVM}}^{T}x_{i}\leq-1$. Right panel: The grokking time, defined as the time it takes for the generalization accuracy to reach 0.95, is plotted against $\sigma$ and $1-2\lambda$. We see it diverges only in the limits of $\lambda\rightarrow 0.5$ and $\sigma\rightarrow\infty$ (neither of these conditions alone suffices to cause divergence).
Refer to caption: x3.png

#### 3.4 When Will We See Grokking?

We have established that for inseparable sets $\bm{S}(t)$ flows to a fixed point $\bm{S}_{\infty}$ while for separable sets it diverges at long times.
This drastic change in the asymptotic value is responsible for grokking, much like in (Rubin et al., ) and (Levi et al., ), who showed that grokking occurs near a phase transition.

The manifestation of this discontinuity in our setting is that $\left\lVert{\bm{S}_{\infty}}\right\rVert$ diverges when the training set is almost separable.
This statement is formally proven in App. D and empirically demonstrated in Fig. 1. It can also be obtained as a corollary of (Ji and Telgarsky, ).

To see this intuitively, consider a training set which is only slightly inseparable from the origin, i.e. one can make it separable by translating all points by a small amount.
Since the set is inseparable, we asymptotically have $\bm{S}(t)\to\bm{S}_{\infty}$.
However, on the translated points, $\left\lVert{\bm{S}(t)}\right\rVert\to\infty$.
Since the solution to the gradient flow equations is smooth in the position of the training points, we must have that $\left\lVert{\bm{S}_{\infty}}\right\rVert$ is large.

Grokking occurs when the dynamics first follow the path towards $\bm{S}_{\infty}$, which is large but finite, while $b$ remains small, and only then transition into the generalizing solution $b\to-\infty$.
In this case we will see small values of $|b|/\left\lVert{\bm{S}(t)}\right\rVert$ at intermediate times and therefore delayed generalization.
However, the dynamics may also flow along a different path in which $\bm{S}(t)$ and $b(t)$ grow at a comparable rate.
Here, we show that grokking occurs generically when $\sigma$ is large enough.

To see this, it useful to define the rescaled variables $\tilde{\bm{x}_{i}}=\bm{x}_{i}/\sigma$, $\tilde{\bm{S}}=\sigma\bm{S}$. Clearly, $\tilde{\bm{x}}_{i}\sim\mathcal{N}(0,\bm{I_{d}})$. The gradient flow equations in terms of the rescaled variables are (we study the exponential loss here for simplicity)

$$ $\displaystyle\frac{\partial\tilde{\bm{S}}}{\partial t}=-\sigma^{2}\frac{\eta}{ N}e^{b}\sum_{i}e^{\tilde{\bm{S}}^{T}\tilde{\bm{x}_{i}}}\tilde{\bm{x}_{i}}, \qquad\,\frac{\partial b}{\partial t}=-\frac{\eta}{N}e^{b}\sum_{i}e^{\tilde{ \bm{S}}^{T}\tilde{\bm{x}_{i}}}.$ (14) $$

Note that these are identical to the gradient flow equations of the original variables, Eq. 9 but the dynamics of $\bm{S}$ are faster by factor of $\sigma^{2}$.
Thus, by taking a large $\sigma$, $\tilde{\bm{S}}$ will approach its asymptotic value $\bm{S}_{\infty}$ arbitrarily fast, while the dynamics $b$ will not change.
Therefore, for large $\sigma$ and large $\bm{S}_{\infty}$, we expect to see delayed generalization.
The “Grokking time”, i.e. the difference between the times for which training and generalization accuracy surpass a threshold, can truly diverge only if both $\lambda\rightarrow 0.5$ and $\sigma\rightarrow\infty$.
This is also demonstrated for the simplified model (discussed below), see the right-most panel of Fig. 3.

Interestingly, using adaptive momentum based optimizers like ADAM  (Kingma and Ba, ), one can see grokking even for $\sigma=1$: Since these optimizers use a different learning rate for each parameter, based on historical gradients, this can lead to faster convergence in the direction of $\bm{S}$, enabling grokking for a similar reason as increasing $\sigma$.
For elaboration, and discussion of the (similar) effect of initial conditions, see App. F.

### 4 Insights From a Simplified Model

Our main claim is that the asymptotic dynamics depend only on the separability of the training set, and that grokking occurs at the edge of linear separability. This intuition works also at low dimensions, which are easier to understand.

Consider the case of $d=1$. In this case, separability boils down to asking whether the origin is contained between the extremal points $\min\{x_{i}\}$ and $\max\{x_{i}\}$.
Therefore, all the phenomenology of the full model described in the previous sections can be captured by a training set consisting of only 2 points $x_{1},x_{2}$.
For consistency with the problem of Gaussian data, we parameterize this set as

$$ $\displaystyle x_{1}$ $\displaystyle=-\sigma\ ,$ $\displaystyle x_{2}$ $\displaystyle=\sigma\left(1-2\lambda\right)\ ,$ $\displaystyle\mathcal{L}(S,b)$ $\displaystyle=\frac{1}{2}\left(e^{Sx_{1}+b}+e^{Sx_{2}+b}\right),$ (15) $$

so that the scale of $x_{i}$ is $\sigma$, and they are separable (inseparable) for $\lambda<1/2$ ($\lambda>1/2$).

The asymptotic dynamics of this model qualitatively, and sometimes quantitatively, capture the phenomenology of the full problem. The model is fully tractable analytically and the detailed analysis is presented in Sec. E.2.
We summarize here the main results:

- •
The left panels of  Fig. 3 show the geometry of the problem in $1+1$ dimensions. It is easily seen that the optimal SVM solution is $s=0,b=-1$ if and only if the data is not separable, i.e. when the segment $x_{2}\geq 0$ contains the origin.
- •
The limiting value $S_{\infty}$ can be easily found to be $S_{\infty}=\frac{1}{2\left(\lambda-1\right)}\log\left(1-2\lambda\right),$ for the separable case $\lambda<1/2$. Indeed, it diverges logarithmically at $\lambda=0.5$, in agreement with the numerical results of the full model presented in the upper-right panel of Fig. 1. The long time dynamics of $\left\lVert{\bm{S}(t)}\right\rVert$ and $b(t)$ are summarized in Table 1.
- •
The left panels of Fig. 4 show that the behavior of the loss and accuracy of the simplified model as a function of $\lambda$ is remarkably similar to that of the full model.

Figure: Figure 4: In the left panel, we calculate the loss and accuracy for different $\lambda$ and $\sigma=5$ in the simplified model (dotted/solid lines represent the training/generalization respectively). In the right panel, we plot the Grokking time (the time difference between the time it takes for the training and generalization loss to reach a certain threshold, $\varepsilon=10^{-50}$ in this case) for $\sigma=20$ and see that it is in very good agreement with the prediction. In the inset, we demonstrate how the grokking time is calculated for $\varepsilon=10^{-50}$ and $\lambda=10^{-4}$.
Refer to caption: x7.png

**Table 1: Summary of the results in the different regimes in the simplified model, where $x_{1}=-1$, $x_{2}=1-2\lambda$, and the margin is $M=|x_{2}|=2\lambda-1$.**
|  | $\lambda<0.5$ ($x_{2}>0$) | $\lambda=0.5$ ($x_{2}=0$) | $\lambda>0.5$ ($x_{2}<0$) |
| --- | --- | --- | --- |
| $b(t\gg 1)$ | $-\log(t)$ | $-\log(t)$ | $-\frac{1}{1+M^{2}}\log(t)$ |
| $\|\bm{S}\|(t\gg 1)$ | $\frac{1}{2(1-\lambda)}\log\left(\frac{1}{1-2\lambda}\right)$ | $\log(\log(t))$ | $\frac{M}{1+M^{2}}\log(t)$ |

#### 4.1 Grokking Time and Universality

We begin by noting that the analytical result of $b(t)$ for $\lambda=0.5$ can describe quite well the results of the full model, see middle panel of Fig. 1.
This fact, combined with the assumption that the divergence of $S_{\infty}$ of the full model is also logarithmic (as was verified numerically), the behavior of the Grokking time (defined below) is expected to be the same in both models. We will now calculate it in the simplified model.

We can define $t_{\mathrm{tr}}^{*}$, $t_{\mathrm{gen}}^{*}$ as the
times at which the training and generalization loss reach some threshold value $\varepsilon$.
The singular part of these times can be calculated near criticality, as $\lambda\to\frac{1}{2}$ from below.
The rigorous calculation is given in Sec. E.2 but the salient features can be obtained using simple scaling arguments:

Assume that $\sigma$ is large enough such that the time it takes $S$ to reach close to $S_{\infty}\approx\frac{1}{2}\log(1-2\lambda)$ is small.
In this case, $t_{\mathrm{tr}}^{*}$, $t_{\mathrm{gen}}^{*}$ are dominated by the time it takes $b$ to diverge.
Replacing $S$ by $S_{\infty}$ in the training loss, we find approximately $\mathcal{L}_{\mathrm{tr}}\approx\frac{1}{2}e^{b}$.
Using the asymptotic solution $b\approx-\log(\frac{\eta}{2}t)$, we immediately find $t_{\mathrm{tr}}^{*}=\frac{1}{\eta\varepsilon}$.
Similarly, the generalization loss takes the form
$\mathcal{L}_{\mathrm{gen}}=\mathbb{E}_{x\sim\mathcal{N}(0,\sigma)}\left[e^{Sx+
b}\right]=e^{b+\frac{1}{2}\sigma^{2}S^{2}}$, implying
$t_{\mathrm{gen}}^{*}=\frac{2}{\eta\varepsilon}e^{\frac{1}{2}\log^{2}(1-2
\lambda)}$.
It is already clear that for any finite $\varepsilon$,$\Delta t^{*}\equiv t_{\mathrm{gen}}^{*}-t_{\mathrm{tr}}^{*}$
diverges.
We define an $\varepsilon$-independent quantity,

$$ $\displaystyle\frac{\Delta t^{*}}{t_{\mathrm{tr}}^{*}}=e^{\frac{1}{2}\log^{2}(1 -2\lambda)}-1,\qquad 0<\lambda\leq 1/2,$ (16) $$

which is verified numerically in Fig. 4.
Further details can be found in Sec. E.3.

We note that this result bears a striking resemblance to that of (Levi et al., ), which employed the MSE loss in a linear regression problem, again for $N$ points sampled iid from an isotropic Gaussian distribution.
In their setting, the interpolation threshold is at $\lambda=1$, in the sense that for $\lambda<1$ the model always generalizes asymptotically, and never generalizes for $\lambda>1$.
They also found that the grokking time diverges logarithmically as a function of the distance from criticality, ${(t_{\mathrm{gen}}^{*}-t_{\mathrm{tr}}^{*})}/{t_{\mathrm{tr}}^{*}}\propto|\log
{(1-\sqrt{\lambda})}|$, which was explained in terms of a “critical slowing down” effect, arising from a vanishing eigenvalue of the data covariance near criticality.
While the two problems are quite different, they both display a critical behavior near an effective interpolation threshold of the corresponding problem.
We believe this is not a coincidence but rather a manifestation of a deeper relation between divergent behaviors in NNs and the intrinsic structure of the training data.
We explore the various aspects of these universal properties in future work.

### 5 Conclusions and Limitations

In this work, we attempted to fill a gap in the Grokking literature, by sharply defining and tracking both empirically and analytically the "memorizing" and "generalizing" solutions in an interesting setting.
We achieved this by constructing a simple yet informative example of "noise" classification, where the optimal solutions can always be found analytically.

Our work can be divided into two parts. First, we studied empirically the dynamics of "noise" classification, and demonstrated that grokking is clearly exhibited when the classifier transitions from the "memorizing" solution to the "generalizing" one.
Additionally, we show that this grokking transition strongly depends on the underlying properties of the data, as it only occurs when the data is on the verge of being linearly separable from the origin in $d$ dimensions, given by $\lambda_{c}$.

In the second part we presented a simple, one dimensional effective description of the full problem, and showed that it captures the salient properties leading to grokking. Employing this simple model, we are able to show that the grokking time diverges as the data becomes closer to linearly separable in $d$ dimensions, and provide analytical predictions for the grokking time as a function of the properties of the data alone.

Finally, the existence of $\lambda_{c}$, which can be identified as the effective interpolation threshold for this problem, is a strong hint at the connection between grokking, and other emergent phenomena in deep learning, such as double descent. We will further address this connection in future work.

Limitations:
We considered a specific problem of classifying irrelevant features, under a particular choice of feature distribution, namely, Normal with zero mean in high dimensions. It is natural to ask how our results extend to more complex data, for instance including non-trivial correlations, hierarchical structure, or even a finite distribution (for instance (Gromov, )). While we believe the same analysis can be repeated in these instances, in the sense of (non)linear separability, we leave this to future work.

All of the analytics were done in the GF limit, and while our results were verified by experiments with finite learning rate, it may be interesting to study how large learning rates effect this setup, possibly relating to catapults (Lewkowycz et al., ) or the edge of stability literature (Cohen et al., ).

Lastly, we did not study the prospect of nonlinear logistic regression, which is closer to deep learning models in the wild. We believe some of our results may be generalized, provided we accept a “feature map” description of the network up to the last layer, and consider the SVM solution on the learned features.

### 6 Acknowledgements

We thank Hillel Aharoni, Amit Moscovich and Daniel Soudry for fruitful discussions. YBS was supported by research grant ISF 1907/22 and Google Gift grant. NL is supported by the EPFL AI4science program.

## Appendix

### Appendix A Separability and Wendel’s Theorem

Wendel’s theorem [Wendel, ] states that
the probability that $N$ random vectors drawn from an isotropic distribution in $d$ dimensions is

$$ $\displaystyle p=\frac{1}{2^{N-1}}\sum_{k=0}^{d-1}\left(\begin{array}[]{c}N-1\\ k\end{array}\right)$ (19) $$

This is a the cumulative probability function of the Binomial distribution, i.e. the probability that the the number of successes is greater than $d$ out of $N-1$ attempts with success probability $\frac{1}{2}$. The central limit theorem states that in the limit of large $N,d$ the binomial distribution approaches a Gaussian, and thus the cumulative distribution function approaches the error function. Straightforward algebra gives that for large $N,d$ we have

$$ $\displaystyle p(\lambda)$ $\displaystyle\to\frac{1}{2}\left[1+\mathrm{erf}\left(\sqrt{d}\left(\sqrt{2 \lambda}-\frac{1}{\sqrt{2\lambda}}\right)\right)\right]\ ,$ $\displaystyle\lambda$ $\displaystyle=\frac{d}{N}\ .$ (20) $$

It is seen that for $d\to\infty$ the transition becomes infinitely sharp as a function of lambda and we have

$$ $\displaystyle\lim_{d\to\infty}p(\lambda)=\begin{cases}0&\lambda<\frac{1}{2}\\ \frac{1}{2}&\lambda=\frac{1}{2}\\ 1&\lambda>\frac{1}{2}\\ \end{cases}$ (21) $$

See also Cover [] for further discussion.

### Appendix B Relation to canonical examples

In this section, we will discuss the similarities and differences of our work with previous examples of Grokking in the literature, focusing on the seminal work of Power et. al. [Power et al., ].
We first note that Grokking at Power et. al. is significant when the fraction of the data used for training $\alpha=N_{training}/N$ is near a critical value $\alpha_{c}$, in the sense that the system achieves perfect generalization if and only if $\alpha>\alpha_{c}$, as can be seen in Fig. 1 (center) of their paper. We expect that this non-analytic behavior in the long time limit of training will be the crucial property that underlies grokking. That is, we expect that near such points the dynamics will be slow. We note that $\alpha$ in Power et. al. is analogous to our $\lambda$ parameter, defining an effective "interpolation threshold" for the modular arithmetic problem.

Secondly, we note that a noticeable difference between our work and that of Power et. al. is that in our case, the accuracy shows a rise from the start rather than staying at chance level for a long time before generalizing. We argue that this is only a superficial discrepancy that depends on the choice of optimizer and fine-tuning of hyperparameters, and that the fundamental mechanism (that grokking occurs near critical points in which solutions exchange stability and dynamics are generically slow) is the same.

Indeed, in Fig. 5 we show that our setup is capable of grokking with accuracy staying at chance level (50%) at the start, similar to Power et al. We achieved this by using $\lambda$ values closer to half (“almost separable”) and the Adam optimizer instead of vanilla gradient descent (GD). The fact that this optimizer converges faster on the training data is no coincidence: the adaptive learning rate leads to quicker convergence to large values of $|S|$ (the “memorizing solution"), maintaining accuracy at chance level until later stages, before going to large $-b$ (the "generalizing solution"). Notably, Power et al. also used Adam (or AdamW). In conclusion, although Adam can lead to a slightly "cleaner" grokking result, we explored GD because it is easier to derive analytical insights from it while, we believe, not changing the underlying mechanism of grokking.
Finally, We will also note that the non-monotonicity of the test loss is also a typical sign of Grokking that can be seen in our setup (for example, compare Fig. 4 of Power et al. with the test loss in Fig. 5).

Figure: Figure 5: Grokking in a similar setup to the results in the main text but with ADAM optimizer (with $\beta_{1}=0.8,$ $\beta_{2}=0.9$), instead of GD. The parameters are $\lambda=d/N=0.495$, $N=4000$ and $\sigma=1$.
Refer to caption: x8.png

### Appendix C Divergence of the conformal time

In the main text we have defined the “conformal time” $\tau=\int_{0}^{t}e^{b(t^{\prime})}dt^{\prime}$
and saw that as the result the gradient-decent trajectory of $\bm{S}(t)$
is the same as one that minimizes the exponential loss without bias:
$\mathcal{L}=\frac{1}{N}\sum_{i=1}^{N}e^{\bm{S}^{T}\bm{x}_{i}}$.
However, if $\tau$ is bounded it might reach a different fixed point.
We will show now that indeed $\tau$ must diverge. First, we notice
that the loss must be bounded from above: If the points are not separable
(that is, there is some $\varepsilon>0$ such that for any $\bm{\frac{\bm{S}^{T}}{\left\lVert{\bm{S}}\right\rVert}}$
that we choose $\frac{\bm{S}^{T}}{\left\lVert{\bm{S}}\right\rVert}x_{i}>\varepsilon$ for any
$i$), then it must be true since $\left\lVert{\bm{S}}\right\rVert$
is bounded — otherwise the loss would be infinite. If the points
are separable, then $\left\lVert{\bm{S}}\right\rVert$ might
diverge (and will, as discussed in the main text) but at some point
all of the arguments of the exponent would be negative, so the loss
would be trivially bounded by $1$. Now, using the fact that $\frac{\partial\beta}{\partial t}=\beta\frac{\partial b}{\partial t}$
we have $\frac{\partial\beta}{\partial t}=-\eta\beta^{2}\frac{1}{N}\sum_{i}e^{S\cdot x_
{i}}$.
Denoting $\mathcal{L}(t)<C$ , we see that

$$ $\displaystyle-\frac{1}{\beta^{2}}\frac{\partial\beta}{\partial t}<\eta C.$ (22) $$

We note that on the left-hand side we have a positive function (since
$\frac{\partial\beta}{\partial t}<0$). In other words, $\frac{\partial}{\partial t}\left[\frac{1}{\beta(t)}\right]<\eta C$,
so we get that

$$ $\displaystyle\frac{1}{\beta(t)}=\frac{1}{\beta(0)}+\int_{0}^{t}\frac{\partial} {\partial t}\left[\frac{1}{\beta(t)}\right]<\frac{1}{\beta(0)}+\int_{0}^{t} \eta C=\frac{1}{\beta(0)}+\eta Ct$ (23) $$

so that $\frac{1}{\beta(t)}<1+\eta Ct$ or, $\beta(t)>\frac{1}{1+\eta Ct}$.
This means that $\int_{0}^{t}\beta(t)>\int_{0}^{t}\frac{1}{1+\eta\varepsilon t}$,
which diverges.

Figure: Figure 6: Left panel: The fraction of positive ${\frac{\bm{S}^{T}_{\infty}}{\left\lVert{\bm{S}_{\infty}}\right\rVert}\bm{x}_{i}}$, which goes to a constant for $\lambda=0.5$. Right panel: The fraction of separable datasets for $\lambda<0.5$ that were not included in the calculation.
Refer to caption: x9.png

Figure: Figure 7: Numerical investigation of properties of the limiting distribution of $\bm{S}^{T}\bm{x}_{i}$, as a function of $1-2\lambda$ (averaged over different random configurations). In blue, we plot the average value of positive ${\bm{\frac{\bm{S}^{T}_{\infty}}{\left\lVert{\bm{S}_{\infty}}\right\rVert}}\bm{ x}_{i}}$, for $\lambda<0.5$ (by minimizing $\mathcal{L}=\frac{1}{N}\sum_{i=1}^{N}e^{\bm{S}^{T}\bm{x}_{i}}$ ), and the margin for $\lambda>0.5$ (using SVM).
Refer to caption: x10.png

### Appendix D Proof that S ∞ subscript 𝑆 S_{\infty} italic_S start_POSTSUBSCRIPT ∞ end_POSTSUBSCRIPT diverges for almost separable data

We look at the function

$$ $\displaystyle f(S,\{x_{i}\})$ $\displaystyle=\sum_{i=1}^{n}e^{S\cdot x_{i}}$ $\displaystyle x,S$ $\displaystyle\in\mathbb{R}^{d}$ (24) $$

We will assume $n>d$ and that the data is in general position, and that it is not separable from the origin. Since for every $S$ we must have $S\cdot x_{i}>0$ for some $i$, it is easy to see that $f$ diverges when $S$ grows large in any direction. Since $f>0$, there exists a global minimum at finite $S$.

A minimum (which is also unique under our assumptions but that’s not crucial) obeys

$$ $\displaystyle\frac{\partial f}{\partial S}=\sum_{i=1}^{n}x_{i}e^{S\cdot x_{i}}=0$ (25) $$

If we divide this expression by $f$, we get

$$ $\displaystyle\sum_{i=1}^{n}p_{i}x_{i}$ $\displaystyle=0$ $\displaystyle p_{i}$ $\displaystyle=\frac{e^{S\cdot x_{i}}}{f}$ $\displaystyle 0\leq p_{i}\leq 1,\quad\sum_{i}p_{i}=1$ (26) $$

Eq. 26 means that the origin is a convex combination of the sample points with weights $p_{i}$. We found that a necessary condition for the existence of a critical point at a finite $S$ is that the origin is contained in the convex hull of the sample points. This is of course equivalent to the condition that the origin is not linearly separable from the sample data.

We want to show that if the data is almost separable, that is, if it is not separable but the origin is close to the boundary of the convex hull, then $S$ must be large. The intuition for this comes from Eq. 26: if the origin is very close to the boundary of the convex hull then some of the $p_{i}$’s must be very large compared to the others, which can only happen if $S$ is large.

In fact, the origin is exactly on the boundary of the convex hull (that is, the data is exactly on the edge of separability) if and only if for every representation of the origin as a convex combination of the sample points,

$$ $\displaystyle\sum_{i=1}^{n}q_{i}x_{i}=0\ ,$ (27) $$

the weights $q_{i}$ are non zero only for $k$ sample points, say $x_{i},\dots,x_{k}$, with $k\leq d$, and $x_{1},\dots x_{k}$ are the vertices of a facet of the convex hull. This naturally leads to the definition:

##### Definition

We say that the origin is $\epsilon$-close to the boundary if there exist $k$ points $x_{1},\dots,x_{k}$ such that for every representation of the type of Eq. 27, the total weight assigned to $x_{1},\dots x_{k}$ is at least $1-\epsilon$,

$$ $\sum_{i=1}^{k}q_{i}\geq 1-\epsilon$ $$

##### Theorem

If the origin is $\epsilon$-close to the boundary of the convex hull of the sample points, then the norm of $S=\operatorname{argmin}f$ is bounded from below by

$$ $|S|\geq\frac{1}{D}\log\left(\frac{1-\epsilon}{\epsilon}\right)$ $$

where $D=\max_{ij}|x_{i}-x_{j}|$ is the diameter of the data.

###### Proof.

We divide the points to two groups: $A=\{x_{1},\dots x_{k}\}$, and $B=\{x_{k+1},\dots x_{N}\}$. Since the origin is $\epsilon$-close, the ratio of the weights of the two groups is bounded by

$$ $\displaystyle\frac{\sum_{i\in A}p_{i}}{\sum_{i\in B}p_{i}}$ $\displaystyle\geq\frac{1-\epsilon}{\epsilon}$ (28) $$

Consider now the convex combination Eq. 26. Using Jensen’s inequality, we can bound the relative weights of the second group by

$$ $\displaystyle\sum_{i\in B}e^{S\cdot x_{i}}$ $\displaystyle\geq(N-k)e^{S\cdot\bar{x}}\ ,$ $\displaystyle\mbox{with}\qquad\bar{x}$ $\displaystyle=\frac{1}{N-k}\sum_{i\in B}x_{i}$ (29) $$

where $\bar{x}$ is the average of the points in the second group. Therefore, the ratio is bounded by

$$ $\displaystyle\frac{\sum_{i\in A}p_{i}}{\sum_{i\in B}p_{i}}=\frac{\sum_{i\in A} e^{S\cdot x_{i}}}{\sum_{i\in B}e^{S\cdot x_{i}}}\leq\frac{\sum_{i\in A}e^{S \cdot x_{i}}}{(N-K)e^{S\cdot\bar{x}}}\leq\frac{k}{N-k}e^{|S|D}\leq\frac{k}{N-k }e^{|S|D}$ (30) $$

Combining Eq. 28 and Eq. 30 we get

$$ $\displaystyle\frac{1-\epsilon}{\epsilon}$ $\displaystyle\leq\frac{k}{N-k}e^{|S|D}$ $\displaystyle\Rightarrow$ $\displaystyle|S|$ $\displaystyle\geq\frac{1}{D}\log\left(\frac{1-\epsilon}{\epsilon}\cdot\frac{N- k}{k}\right)$ (31) $$

Since $k\leq d$, we also have $N-k\geq n-d$.

Note that the same convexity argument would work also for logisitic loss $f=\sum_{i}\ell(S\cdot x_{i})$, $\ell(z)=\log\left(1+e^{z}\right)$, or any other monotonic and convex $\ell$. In this case the only difference is that the $\log$ function should be replaced the inverse of $\ell$.
∎

###### Proof.

### Appendix E Details of the Simplified Model

#### E.1 Justification and Relation to the Full Model

We will provide here supplemental results regarding the justification of the simplified model (by numerical comparison to the full model). To obtain the results we average over different random realizations: Assuming the so-called “self averaging” property, we know that the average
over a large number of finite systems should give us the same result
as the infinite system (where $N,d\rightarrow\infty$ and the ratio
is constant).

In the non-separable case, $\bm{S}_{\infty}$ can be found by any optimizer that minimizes the loss $\mathcal{L}=\sum e^{\bm{S}^{T}\bm{x_{i}}}$. We note that when getting close to the transition point, for any finite-sized system we have some probability of getting a separable set (even though $\lambda<0.5$), see Eq. 19. In this case, we just ignore the the result: In the right panel of Fig. 6 we present the fraction of realizations that are separable. This will probably introduce some bias into the results which is likely the cause of the fact that the average of positive samples (and similarly, the margin) does not go exactly to zero for $\lambda\rightarrow 0.5$ (see Fig. 7).
In the left panel of Fig. 6 we present the fraction of positive ${\frac{\bm{S}^{T}_{\infty}}{\left\lVert{\bm{S}_{\infty}}\right\rVert}\bm{x}_{i}}$ . Interestingly, it does not go to zero but to some positive constant, implying that there is a singularity in the density of ${\frac{\bm{S}^{T}_{\infty}}{\left\lVert{\bm{S}_{\infty}}\right\rVert}\bm{x}_{i}}$ at $\lambda=0.5$.

#### E.2 Analytical Predictions

Here, we provide the full analysis of the model presented in Sec. 4, for a single point fixed at $x_{1}=-1$, and a second point $x_{2}=x=1-2\lambda$, where $\lambda=d/N$.

The gradient flow equations in conformal time are given by

$$ $\displaystyle\frac{\partial S}{\partial\tau}$ $\displaystyle=-\frac{\eta}{2}\left(xe^{Sx}-e^{-S}\right)=-\frac{\eta}{2}\left( (1-2\lambda)e^{S(1-2\lambda)}-e^{-S}\right),$ (32) $\displaystyle\frac{\partial b}{\partial\tau}$ $\displaystyle=-\frac{\eta}{2}\left(e^{Sx}+e^{-S}\right)=-\frac{\eta}{2}\left(e ^{S(1-2\lambda)}+e^{-S}\right).$ $$

While there exist analytical solutions for Eq. 32, they do not necessarily provide any intuition, and so we find it better to begin by investigating three special representative cases:

- 1.
$x_{2}=1$ (non-separable).
- 2.
$x_{2}=0$ (marginally non-separable).
- 3.
$x_{2}=-1$ (separable).

For $x=1$ (A), the data is entirely non-separable in one dimension and the conformal time solutions are

$$ $\displaystyle S(\tau)$ $\displaystyle=\log\left(\tanh\left(\frac{\eta\tau}{2}+\tanh^{-1}\left(e^{S_{0} }\right)\right)\right),$ (33) $\displaystyle b(\tau)$ $\displaystyle=b_{0}+\log\left(\frac{\tanh\left(2\tanh^{-1}\left(e^{S_{0}} \right)\right)\cosh\left(2\tanh^{-1}\left(e^{S_{0}}\right)\right)}{\tanh\left( \eta\tau+2\tanh^{-1}\left(e^{S_{0}}\right)\right)\cosh\left(\eta\tau+2\tanh^{- 1}\left(e^{S_{0}}\right)\right)}\right),$ $$

in which case the generalization accuracy reaches 1 for $\tau\to\infty$, as $b(\tau)$ grows faster than $S(\tau)$ with conformal time.

For $x_{2}=0$ (B), the equations in conformal time become:

$$ $\displaystyle\frac{\partial S}{\partial\tau}=\frac{\eta}{2}e^{-S},\qquad\, \frac{\partial b}{\partial\tau}=-\frac{\eta}{2}(e^{-S}+1)$ (34) $$

By solving for $S$ and plugging into $\frac{\partial b}{\partial\tau}$, we immediately get

$$ $\displaystyle S=\log\left(e^{S_{0}}+\frac{\eta}{2}\tau\right),\qquad\,b=-\log \left(e^{S_{0}}+\frac{\eta}{2}\tau\right)-\frac{\eta}{2}\tau+S_{0}+b_{0}.$ (35) $$

Using the fact that $e^{b}=\frac{\partial\tau}{\partial t}$, we get that $\frac{\partial\tau}{\partial t}=\frac{e^{-\frac{\eta}{2}\tau}}{e^{S_{0}}+\frac
{\eta}{2}\tau}e^{S_{0}+b_{0}}$, and taking another integral, we get that $e^{\frac{\eta}{2}\tau}\left[e^{S_{0}}-1+\frac{\eta}{2}\tau\right]=e^{S_{0}+b_{
0}}\frac{\eta}{2}t+(e^{S_{0}}-1)$. Taking the inverse of this, we finally get

$$ $\displaystyle\tau=\frac{2}{\eta}\left[W_{0}\left(\left(e^{S_{0}+b_{0}}\frac{ \eta}{2}t+(e^{S_{0}}-1)\right)e^{e^{S_{0}}-1}\right)-e^{S_{0}}+1\right],$ (36) $$

where $W_{0}$ is the Lambert W function. We note that for large $t$ we have $\tau\sim\log(t)$, and therefore $b\sim-\log\left(t\right)$, $S\sim\log(\log(t))$, so it is interesting to note that in the critical point we still have $\lim_{t\rightarrow\infty}S(t)/b(t)=0$ (i.e., accuracy goes to 1), even though S diverges.

Finally, for $x=-1$ (C), the data is fully separable in one dimension and the solution in conformal time is given by

$$ $\displaystyle S(\tau)=S_{0}+\log\left(1+\eta\tau e^{-S_{0}}\right),\qquad b( \tau)=b_{0}-\log\left(1+\eta\tau e^{-S_{0}}\right),$ (37) $$

showing that the accuracy is bounded at $\mathcal{A}^{\infty}_{\mathrm{gen}}=\frac{1}{2}\left(1+\text{erf}\left(\frac{1
}{\sqrt{2}}\right)\right)$ agreeing with the results of Eq. 13 where $M=1$.

For completeness, we report here the full solution, as a function of the conformal time $\tau=\int_{0}^{t}e^{b(t)}dt$ of Eq. 32.
We define

$$ $\displaystyle f(y)=-\frac{xe^{y(x+2)}\,_{2}F_{1}\left(1,1+\frac{1}{x+1};2+ \frac{1}{x+1};e^{(x+1)y}x\right)}{x+2}-e^{y},$ (38) $$

then the solution for $S(\tau)$ is given by the inverse function $f^{-1}(u)$ evaluated at

$$ $\displaystyle u=-\frac{xe^{S_{0}(x+2)}\,_{2}F_{1}\left(1,1+\frac{1}{x+1};2+ \frac{1}{x+1};e^{S_{0}(x+1)}x\right)}{x+2}-\frac{\tau}{2}-e^{S_{0}},$ (39) $$

as

$$ $\displaystyle S(\tau)=f^{-1}\left(-\frac{xe^{S_{0}(x+2)}\,_{2}F_{1}\left(1,1+ \frac{1}{x+1};2+\frac{1}{x+1};e^{S_{0}(x+1)}x\right)}{x+2}-\frac{\eta\tau}{2}- e^{S_{0}}\right).$ (40) $$

The solution for $b(\tau)$ is obtained simply by integrating Eq. 32, resulting in

$$ $\displaystyle b(\tau)$ $\displaystyle=\frac{1}{x}\left[b_{0}x-\log\left(1-e^{(1+x)f^{-1}\left(-e^{S_{0 }}-\frac{e^{S_{0}(2+x)}x\,_{2}F_{1}\left(1,1+\frac{1}{x+1};2+\frac{1}{x+1};e^{ S_{0}(1+x)}x\right)}{2+x}\right)}x\right)\right.$ (41) $\displaystyle+\left.\log\left(1-e^{(1+x)f^{-1}\left(-e^{S_{0}}-\frac{\eta\tau} {2}-\frac{e^{S_{0}(2+x)}x\,_{2}F_{1}\left(1,1+\frac{1}{x+1};2+\frac{1}{x+1};e^ {S_{0}(1+x)}x\right)}{2+x}\right)}x\right)\right.$ $\displaystyle+\left.xf^{-1}\left(-e^{S_{0}}-\frac{e^{S_{0}(2+x)}x\,_{2}F_{1} \left(1,1+\frac{1}{x+1};2+\frac{1}{x+1};e^{S_{0}(1+x)}x\right)}{2+x}\right)\right.$ $\displaystyle-\left.xf^{-1}\left(-e^{S_{0}}-\frac{\eta\tau}{2}-\frac{e^{S_{0}( 2+x)}x\,_{2}F_{1}\left(1,1+\frac{1}{x+1};2+\frac{1}{x+1};e^{S_{0}(1+x)}x\right )}{2+x}\right)\right].$ $$

While these solutions may not necessarily be instructive in this form, appropriate limits can be taken in order to obtain the results in the main text.

#### E.3 Grokking time in the simplified model

We can define $t_{\mathrm{tr}}^{*}$, $t_{\mathrm{gen}}^{*}$ as the
times it would take for the training and generalization loss to reach
some threshold $\varepsilon$. We can find $t_{\mathrm{tr}}^{*}$
by solving $\mathcal{L}_{\mathrm{tr}}=\frac{1}{2}e^{b}\left(e^{-S}+e^{S(1-2\lambda)}\right
)=\varepsilon$.
We will assume that $\sigma$ is large enough such that $S=S_{\infty}$
from the start (as discussed in the main text, $\sigma$ increase
the rate that S goes to its final value). Therefore, we plug $S_{\infty}=-\log(1-2\lambda)$,
and find that for $\lambda$ which is close enough to $0.5$, the
loss is approximately given by $\mathcal{L}_{\mathrm{tr}}=\frac{1}{2}e^{b}$.
Comparing to $\varepsilon$ and plugging the long-time limit $b=-\log(\frac{\eta}{2}t)$,
we find that

$$ $\displaystyle t_{\mathrm{tr}}^{*}=\frac{1}{\eta\varepsilon}.$ (42) $$

Similarly, using the generalization loss $\mathcal{L}_{\mathrm{gen}}=e^{b}e^{S^{2}/2}$
we can find that

$$ $\displaystyle t_{\mathrm{gen}}^{*}=\frac{2}{\eta\varepsilon}e^{\frac{1}{2}\log ^{2}(1-2\lambda)}$ (43) $$

It is already clear that for any finite $\varepsilon$, $t_{\mathrm{gen}}^{*}-t_{\mathrm{tr}}^{*}$
diverges. We can also obtain an $\varepsilon$-independent property
by noting that

$$ $\displaystyle\sqrt{\log(t_{\mathrm{gen}}^{*}/t_{\mathrm{tr}}^{*})}=\frac{1}{ \sqrt{2}}\log(1-2\lambda),$ (44) $$

which is verified numerically in Fig. 8.

Figure: Figure 8: Numerical evidence for the Grokking time in the simplified model. In the left panel, we demonstrate for $1-2\lambda=0.001$ how the Grokking time is calculated: $t_{\mathrm{tr}}^{*}$, $t_{\mathrm{gen}}^{*}$ are calculated by finding the intersection of the loss with some $\varepsilon$. In the right panel we plot $\sqrt{\log(t_{\mathrm{gen}}^{*}/t_{\mathrm{tr}}^{*})}$ versus $\log(1-2\lambda)$ numerically, and show that the result is linear with slope $\approx\frac{1}{\sqrt{2}}$, in agreement with the prediction of Eq. 44
Refer to caption: x11.png

It is interesting to note that in the conformal time, we have $b\approx-\tau$,
and therefore can repeat this calculation and obtain

$$ $\displaystyle\tau_{\mathrm{tr}}^{*}=-\log(\eta\varepsilon),\,\tau_{\mathrm{gen }}^{*}=\frac{1}{2}\log^{2}(1-2\lambda)-\log\frac{\eta}{2}\varepsilon.$ (45) $$

In this case, the result is a bit more natural since now the time
difference (instead of ratio) becomes $\varepsilon$-independent:

$$ $\displaystyle\tau_{\mathrm{gen}}^{*}-\tau_{\mathrm{tr}}^{*}\approx\frac{1}{2} \log^{2}(1-2\lambda).$ (46) $$

We note that this result still depends on $\varepsilon$ implicitly, in the sense that our assumption that $S=S_{\infty}$ is true only for long-times, or $\varepsilon$ which is small enough.

#### E.4 Calculation of the subleading term in the separable case

We now consider $x_{2}<0$ but close to zero (that is, we are in a separable case
where $M=-x_{2}$ is the margin). We know that $w$ diverges at long
times as $w\approx\frac{M}{1+M^{2}}\log\left[\frac{\eta}{2}(1+M^{2})t+1\right].$
We will now denote

$$ $u\equiv w-\frac{M}{1+M^{2}}\log\left[\frac{\eta}{2}(1+M^{2})t+1\right]$ $$

as the difference from the diverging term. The equation for $u$ is
therefore

$$ $\frac{\partial u}{\partial t}=-\frac{\eta}{2}e^{b}\left(-e^{x_{1}\left(u+\frac {M}{1+M^{2}}\log\left[\frac{\eta}{2}(1+M^{2})t\right]\right)}-Me^{-M\left(u+ \frac{M}{1+M^{2}}\log\left[\frac{\eta}{2}(1+M^{2})t\right]\right)}\right)- \frac{M}{1+M^{2}}\frac{1}{t}.$ $$

Plugging the (long-time) solution for the bias, $b\approx-\frac{1}{M^{2}+1}\log\left[\frac{\eta}{2}(1+M^{2})t+e^{-(1+M^{2})b_{0
}}\right]$
(where $b_{0}=0$ in our case), we get

$$ $\frac{\partial u}{\partial t}=-x_{1}\frac{\eta}{2}e^{x_{1}u}\left(\frac{\eta}{ 2}(1+M^{2})t+1\right)^{\frac{x_{1}M-1}{1+M^{2}}}+\left(e^{-Mu}-1\right)\frac{M }{(1+M^{2})t+\frac{2}{\eta}}.$ $$

For $M\approx 0$, we note that the second term is $O(M^{2}),$ and by neglecting it
we get

$$ $u=-\frac{1}{x_{1}}\log\left(\frac{x_{1}^{2}}{x_{1}M+M^{2}}\left(\frac{\eta}{2} (1+M^{2})t+1\right)^{\frac{x_{1}M+M^{2}}{1+M^{2}}}-\frac{x_{1}^{2}}{x_{1}M+M^{ 2}}+1\right).$ $$

For $t\rightarrow\infty$, and neglecting the other $O(M^{2})$ terms,
we finally get

$$ $u\approx-\frac{1}{x_{1}}\log\left(\frac{x_{1}}{x_{2}}\right).$ $$

Remarkbly, this is identical to the result of the in the $x_{2}>0$
case.

### Appendix F Impact of different parameters

Here we present supplemental results for Sections 3.4.

#### F.1 The Variance Scale σ 𝜎 \sigma italic_σ

Here we provide additional information regarding the effect of $\sigma$ different than 1. In particular, we will show that increasing $\sigma$ can make grokking more apparent (but
only up to a certain point). We will first assume that $\sigma=1$
at the start, and investigate how taking $\tilde{\bm{x}}_{i}=\sigma\bm{x}_{i}$
changes the dynamics in comparison to that case. We will begin with the non-separable case ($\lambda<0.5$). Recalling that the
equations for gradient flow in our model are given by Eq. 9,
this results in

$$ $\displaystyle\frac{\partial\bm{S}}{\partial t}=-\sigma\frac{\eta}{N}e^{b}\sum_ {i}e^{\bm{S}^{T}\sigma\bm{x}_{i}}\bm{x}_{i},\qquad\,\frac{\partial b}{\partial t }=-\frac{\eta}{N}e^{b}\sum_{i}e^{\bm{S}^{T}\sigma\bm{x}_{i}}.$ (47) $$

We can now absorb $\sigma$ into $\bm{S}$ by denoting $\tilde{\bm{S}}\equiv\sigma\bm{S}$
and investigate how it affects the dynamics of $\tilde{\bm{S}}$,
and the generalization loss and accuracy as a function of $\tilde{\bm{S}}$. First, the GD equations
become

$$ $\displaystyle\frac{\partial\tilde{\bm{S}}}{\partial t}=-\sigma^{2}\frac{\eta}{ N}e^{b}\sum_{i}e^{\tilde{\bm{S}}^{T}\bm{x}_{i}}\bm{x}_{i},\qquad\,\frac{ \partial b}{\partial t}=-\frac{\eta}{N}e^{b}\sum_{i}e^{\tilde{\bm{S}}^{T}\bm{x }_{i}}.$ (48) $$

We note that the generalization loss and accuracy in Eqs. 5 and 6
are the same except they are now a function of $\left\|\tilde{\bm{S}}\right\|$ instead of $\left\|{\bm{S}}\right\|$ (being a function of $\sigma\left\lVert{\bm{S}}\right\rVert$). Since the equation for $\frac{\partial\tilde{\bm{S}}}{\partial t}$
is just multiplied by a factor $\sigma^{2}$, the limiting value of
$\tilde{\bm{S}}_{\infty}$ would be the same as for the $\sigma=1$
case, but it will reach it at a faster rate. To sum up, obtaining the dynamics of the loss and accuracy when $\sigma$ is larger than one can be done by using the same  Eqs. 5 and 6, but also (A) Increasing the starting condition of $\bm{S}_{0}$ by a factor of $\sigma$, and (B) Multiply only the learning rate of the spatial part by a factor of $\sigma^{2}$. If $\sigma$ is large enough, we can go to the fixed point of $\left\lVert{\bm{S}}\right\rVert$ as fast as we want, enabling the appearance of Grokking (if also the limiting value of $\left\lVert{\bm{S}}\right\rVert$ is large, which happens when we are on the edge of being separable).

Finally, we will also investigate the effect of $\sigma$ in the separable regime ($\lambda>0.5$). Now we can use Eqs. 12 and 13, where we only need to consider how $\sigma$ changes the margin $M$. Since it is obtained from the equation $\bm{\frac{\bm{S}^{T}}{\left\lVert{\bm{S}}\right\rVert}}x_{m}=-M$, we can see that the new margin will be larger by $\sigma$ than the old one, i.e., $\tilde{M}=\sigma M$. Plugging this in Eq. 13, we get that the accuracy is now

$$ $\displaystyle\lim_{t\rightarrow\infty}\mathcal{A}_{\mathrm{gen}}\approx\frac{1 }{2}\left[1+\mathrm{erf}\left(\frac{1}{\sigma^{2}M\sqrt{2}}\right)\right].$ (49) $$

where we note that the argument inside the $\mathrm{erf}$ is smaller in a factor of $\sigma^{2}$, drastically reducing the limiting accuracy.

#### F.2 Optimizer

The effect of changing the optimizer to Adam is demonstrated in Fig. 10. We note that the fact that adaptive-type optimizers change each learning rate individually based on past gradients, leads the dynamics faster in the direction of $\left\lVert{\bm{S}}\right\rVert$, relatively to $b$. The fact that it makes $\left\lVert{\bm{S}}\right\rVert$ change faster (and not slower) than $b$, is probably related to the fact that $\bm{S}$ is a vector in high dimension: Moving each component of such vector will result in a change of the norm in a rate that is proportional to $\sqrt{d}$, but this may need further investigation.
We will also note that using a different optimizer for the non-separable region where, will lead to a different solution than the hard margin SVM, as is also discussed by Soudry et al. [Soudry et al., ]. This means that the results we developed in the main text will not hold, but we can still expect to obtain accuracy smaller than one since $\left\lVert{\bm{S}}\right\rVert$ diverges, as indeed can be seen in Fig. 10.

#### F.3 Initial conditions

As discussed in the main text, changing the initial conditions can change the monotonicity of the generalization loss and accuracy: See Fig. 11, 12 below.

#### F.4 Different loss

In the main text, we showed that we can use the exponential instead of the CE loss, since it will converge to it at late times. Here we provide numerical evidence that indeed Grokking could be seen, even when taking from the beginning just the exponential loss $\mathcal{L}=\frac{1}{N}\sum_{i}e^{\bm{S}^{T}x_{i}+b}$: See Fig. 13.

Figure: Figure 9: Gradient descent dynamics for three different values of $\sigma,$ all for $\lambda=0.48$. The top panels show the loss and accuracy for the train and test datasets, while the bottom panels present $b$ and the norm of $\bm{S}$. Except for $\sigma,$ the parameters are the same as in Fig. 1. We can see that increasing $\sigma$ makes the grokking more apparent at start, but then saturates (that is, increasing $\sigma$ will not increase the “grokking time” anymore).
Refer to caption: x12.png

Figure: Figure 10: Dynamics, using ADAM optimizer with PyTorch’s default parameters. The setup is the same as Fig. 1, except for the fact that $\sigma=1$ now instead of $5$. Significant Grokking can be seen even though the value of $\sigma$ is not large.
Refer to caption: x13.png

Figure: Figure 11: Gradient descent dynamics for $\lambda=0.48$ and for three different values of starting norm, $\left\|\bm{S}_{0}\right\|$. Except for this, the setup is the same as Fig. 1. We can see that the non-monotonicity of the loss can be affected by the starting condition.
Refer to caption: x14.png

Figure: Figure 12: Gradient descent dynamics for $\lambda=0.48$ and for three different values of $b$. Except for this, the setup is the same as Fig. 1.
Refer to caption: x15.png

Figure: Figure 13: Gradient descent dynamics for a setup which is the same as Fig. 1, but with the exponent loss $\mathcal{L}=\frac{1}{N}\sum_{i}e^{\bm{S}^{T}x_{i}+b}$. That is, the loss is strictly the exponent loss at any time (and not just converge to the exponent loss at long times, as the CE loss). Clearly, we can see that the behavior of the Grokking is similar.
Refer to caption: x16.png

### Appendix G Direct calculation of the late
time behavior of b , S 𝑏 𝑆 b,S italic_b , italic_S in the separable regime

Here we present a direct calculation for $\bm{S}(t)\equiv\left\|\bm{S}(t)\right\|\bm{\hat{S}}(t),\,\bm{b}(t)$
at late times. First, we will work in the conformal time $\tau=\int_{0}^{t}\beta(t^{\prime})dt^{\prime}$.
As discussed in the main text, when the data is separable we know
that in the late time limit $\hat{\bm{S}}$ goes to a certain
direction and $\left\lVert{\bm{S}}\right\rVert\rightarrow\infty$.
Therefore, only the points with maximum $\bm{S}^{T}x_{m}$
will contribute to the sum in the large

$$ $\displaystyle\frac{1}{N}\sum_{i}e^{\bm{S}^{T}x_{i}}\approx\frac{D}{N}e^{\bm{S} ^{T}x_{m}},$ (50) $$

where $\bm{S}^{T}x_{m}$ is the maximum value that is obtained,
$D$ is their degeneracy. We note that $\bm{S}^{T}\bm{x}_{i}$
are all negative, so the maximum are just the points which are closest
to zero, so these are exactly the support vectors. To continue, for
$\tau\rightarrow\infty$ we denote

$$ $\displaystyle\bm{S}\sim Ef(\tau)\hat{\bm{S}},$ (51) $$

where $E$ is some constant, and $f(\tau)$ is some function of $t$.
Without loss of generality, and for compatibility with the results
of the main text, we will define $E$ by the equation $E\equiv-\frac{1}{\hat{\bm{S}}^{T}\bm{x}_{m}}$.
We can now find $f(\tau)$ explicitly using the following arguments:
We know that

$$ $\displaystyle\frac{\partial\left\lVert{\bm{S}}\right\rVert}{\partial\tau}= \frac{\bm{S}^{T}}{\left\lVert{\bm{S}}\right\rVert}\frac{\partial\bm{S}}{ \partial\tau}=-\eta\frac{1}{N}\sum_{i}e^{\bm{S}^{T}\bm{x}_{i}}\frac{\bm{S}^{T} }{\left\lVert{\bm{S}}\right\rVert}\bm{x}_{i}.$ (52) $$

Using the approximation and comparing with $\frac{\partial\left\lVert{\bm{S}}\right\rVert}{\partial\tau}=Ef^{\prime}(\tau)$,
we get that

$$ $\displaystyle\eta\frac{D}{N}\frac{1}{E}e^{-f(\tau)}=Ef^{\prime}(\tau).$ (53) $$

Solving for $f(\tau)$, we get

$$ $\displaystyle f(\tau)=\log\left[\eta\frac{D}{N}\frac{1}{E^{2}}\tau+C_{1}\right],$ (54) $$

where $C_{1}$ is some constant. Therefore, we get

$$ $\displaystyle\frac{\partial b}{\partial\tau}\approx-\eta\frac{D}{N}\frac{1}{ \eta\frac{D}{N}\frac{1}{E^{2}}\tau+C_{1}}.$ (55) $$

and taking the integral over $d\tau$ we get

$$ $\displaystyle\beta(\tau)\approx C_{2}\left(\eta\frac{D}{N}\frac{1}{E^{2}} \tilde{t}+C_{1}\right)^{-E^{2}}.$ (56) $$

Recalling that $\frac{\partial\tau}{\partial t}=e^{b}$, we can integrate to find:

$$ $\displaystyle\tau(t)=\frac{1}{\eta\frac{D}{N}\frac{1}{E^{2}}}\left(\eta\frac{D }{N}\frac{E^{2}+1}{E^{2}}\right)^{\frac{1}{E^{2}+1}}\left[C_{2}t+C_{3}\right]^ {\frac{1}{E^{2}+1}}-\frac{1}{\eta\frac{D}{N}\frac{1}{E^{2}}}C_{1}.$ (57) $$

Using $b=\log(\frac{\partial\tau}{\partial t}),$ we get for long
times that

$$ $\displaystyle b(t)\approx-\frac{E^{2}}{E^{2}+1}\log(t).$ (58) $$

Plugging also $\left\lVert{\bm{S}}\right\rVert\approx Ef(\tau)\approx E\log(\tau)$,
we can see that

$$ $\displaystyle\left\|\bm{S}(t)\right\|\approx\frac{E}{E^{2}+1}\log(t).$ (59) $$

Recalling that $E=\frac{1}{M},$ this verifies the result of the main
text.

### Appendix H Supplemental Details of Experiments

In this section, we will provide information regarding the experiments. All of our results are computed in Python, using the standard gradient-decent of the PyTorch library.

We begin by noting that the results of the left panels of Fig. 1 (and all of the results in Section F) can be easily obtained even on a personal laptop. We had only three "large" experiments, which are presented in the right-most column of Fig. 1 (and in Fig. 7):

(1) Calculation of $\left\lVert{\bm{S}_{\infty}}\right\rVert$ and $\bm{S}^{T}x_{i}$ properties of the distribution. The setup is: $N=2400$, $\sigma=1$, and $d=$930, 990, 1050, 1086, 1110, 1134, 1152, 1158, 1164, 1170, 1173, 1176, 1179, 1182, 1185, 1188, 1191, averaged over 15000 different random realizations. This was run in a cluster of servers with 250 Intel(R) Xeon(R) CPU E5-2690 v4 @ 2.60GHz
cores with about  9GB RAM per core, which took a few hours to run. The minimization was done using ADAM (any optimizer will work in the inseparable regime).

(2) Calculation of the margin: The setup is: $N=2400$, $\sigma=1$, and $d=$1230, 1260, 1290, 1320, 1350, 1380, 1410, 1440, 1470, 1500, 1530, 1560, averaged over 1000 realizations. Performed on the same cluster, this took only a few hours to run.

(3) The results of the right-middel and right-bottom panels of Fig. 1. The setup is: $N=400$, and $d=$20, 40, 80, 100, 120, 140, 160, 168, 180, 188, 192, 196, 200, 208, 220, 228, 240, 260, 280, 300, 320, 360, averaged over 100 realizations. This also took only a few hours to run.

## Peer Reviews

confidence: 4
contribution: 2
initial_rating: 6
presentation: 3
questions: Questions:

Q1. The train/test loss and accuracy behaviors are still not fully understood. This paper takes a step in the right direction. While I appreciate simple models yielding interesting insights, from a practical perspective, the study would be much more impactful if the results can be extended to more realistic settings. Some thoughts and questions below:
	
	a. What are the additional results needed, if one were to try and extend the study to random example classification, but with multiple classes? Perhaps the smallest such extension could be iid normal features and random binary label assignments. From my understanding, there are similar linear separability threshold computations possible (e.g. Kini et al, 2021). Any discussion on this question could be beneficial.
	b. The authors note the study of non-linear regression, motivated by neural network training, to be a feasible extension, with fixed learned last-layer features and a trainable classifier head. My concern here is that it is unclear how the distributions of the last-layer features could be characterized. The features will likely not have nice Gaussian-like properties. Additional modeling of the learned feature extractor may be needed and may complicate the calculations.

Q2. I am trying to reconcile some of the results, and more generally, grokking itself with double descent. For example, one of the statements (line 56) is that in the separable regime, the generalization is worse. On the face, this seems to be different from what double	descent appears to predict. Is the apparent discrepancy stemming from not having any "feature selection" assumption in the model? Does double descent not occur in this linear model? More generally, both the phenomena seem to be connected, in the sense of being a result of the implicit bias of the loss optimization. A discussion elaborating the connection would be helpful to get a better picture of the learning dynamics. Specifically, I am curious about the simplest model that would exhibit both double descent and grokking, which might take the model closer to complex DNNs. A recent work (mentioned by the current paper) Davies et al, 2023 discusses the link between the two.

Q3. The discussion in Section 4 is not fully clear to me. It seems that the authors are constructing a representative deterministic setting in 1D, with the deterministic points constructed to match the macro statistical properties of the random feature model. Such a description could be interesting, with a bit more clarity. For instance, the overparameterization ratio $\lambda$ becomes a parameter of the value of a datapoint. With $d$ being set to 1, $\lambda$ appears to lose its original meaning. Could the authors help explain? The paragraph in App E.1 was somewhat helpful.
soundness: 3
strengths: S1. The phenomenon of grokking has been of interest as one of the intriguing behaviors of neural network training. As remarked by the authors, this study does not need sophisticated assumptions, unlike some prior work, for demonstrating the phenomenon. The setup is short and the results are clear. 

S2. The analytical discussions show a useful application of implicit bias results from literature. While I did not check the derivation in detail, the calculations are sound.

S3. The paper is very well written. The contributions and limitations are clearly discussed.
summary: The paper identifies a simple linear classification setting and studies when "grokking" occurs, under Gaussian random data in the linear asymptotic regime. The setup is simplistic, but possibly useful to isolate the emergence of grokking as a result of implicit bias of gradient descent (flow). Relying on analytical tools including simple Gaussian error calculations and advanced implicit bias results from prior works, the authors demonstrate the regime of occurrence of the phenomenon. The results could be of interest to the theoretical statistical learning community, and the insights may be interesting also to the deep learning community.

Update after author response: raising score from 6 to 8
weaknesses: To be of greater interest to the current machine learning community, the study may need to address the following weaknesses. That said, in the considered setting, the results are self-contained and interesting on their own.

W1. The impact of the study would be much higher if the analysis can be shown to generalize to more complex models, like discriminative labeling, and non-linear models. 

W2. From a practical point of view, having a theoretical model explain an empirical observation is a valuable contribution. In this regard, demonstrating direct counterparts and specific usefulness of the insights obtained from the model to large scale machine learning experiments may be considered. For example, does the "edge of separability" correspond to a certain regime of model size/training in deep models? Can a specific trend in delayed generalization be predicted or explained by the insights obtained?

---

confidence: 4
contribution: 2
initial_rating: 5
presentation: 2
questions: 1. Line 197, you should specify that the first 0 is actually the zero vector in $d$ dimensions
2. I know that the Heaviside function $\Theta$ is relatively standard, but could the authors just define it when it is first introduced for readers who might not be familiar. (Minor point, but I feel like it would be more clear anyway if this was just defined as an indicator)
3. Could you change this $\lambda \lesssim \frac{1}{2}$ notation? This might be interpreted as $\lambda$ is bounded within a constant factor of $\frac{1}{2}$. Two candidate suggestions: $\lambda \uparrow \frac{1}{2}$ ot $\lambda \to \frac{1}{2}^-$. 
4. The paper cites Wendel’s theorem, which gives an asymptotic 0-1 law for the separability of the training data. Is there a non-asymptotic version of this? 
5. Appendix A, line 617. I believe you are missing the word “linearly separable”
6. In Appendix B, it is argued that the parameter $\alpha$ in Power et al. is analogous to that of $\lambda$. However, besides the fact that there is a “phase transition” with respect to these scalar parameters, I don’t see how one can connect them. Could the authors comment on this connection more,
soundness: 2
strengths: 1. It is important to have toy models that we can actually analyze. Even though the model setup is admittedly toy, it still demonstrates interesting train and test time phenomenon.
2. The paper identifies that the margin to linear separability of the data from the origin determines whether the dynamics will grok or not.
summary: This paper studies a toy model for grokking in binary classification with a linear model trained using gradient flow on gaussian data with constant labels. They argue that grokking occurs when the ratio $d/n$ of parameters to datapoints approaches the critical threshold of ½ — this is the threshold where the data undergoes a sharp transition from being linearly separable to linearly inseparable. Using prior work characterizing gradient flow dynamics for logistic regression, they argue that close when $d/n$ is just barely below ½, it takes a long time to converge to the max-margin separating hyperplane, which explains the sudden shift in test accuracy even though train loss is low.

Edit: After considering the improved writing and new theoretical results in the revision, I have updated my score to a 6.
weaknesses: 1. I found that the paper was hard to read, and at times imprecise. One suggestion I have is to write the paper in a way where it is easy to identify what concrete properties or statements are being proved. 
2. For example, in Line 251, I was originally confused about why can we apply Eq (7), since that result only makes sense for the linearly separable case (especially since it’s talking about hard SVM). It might help if you formally stated the result of Ji and Telgarsky was stated and then also your variant where you include the bias, commenting explicitly on the difference between what “linearly separable” means in these two settings. 
3. It seems that the problem setup is (WLOG) assuming that all the labels are -1, so that to classify correctly we should output a negative scalar. Can you explicitly state this (for example, by just defining what the labels are)

---

confidence: 3
contribution: 1
initial_rating: 3
presentation: 2
questions: 1. What do the authors mean with $\lesssim$ in Line 215? 

2. How do the insights from this work extend to more realistic settings? 

3. What is the additional insight of the current work compared to the missing related work (Humayun et al., 2024; Golechha, 2024)?

**Minor Issues**
- The cross-entropy loss in Eq. (1) does not include labels of data, which looks odd at first glance. The authors drop the labels from the equation since all inputs are assigned the same label. However, this should be mentioned as a note near the equation to improve clarity.
- To avoid confusion with empirical accuracy, mentioning "generalization accuracy in Line 137 might be helpful.
- Typo in line 163: "we the present"

**Update:** After the rebuttal, the rating was increased from 3 to 5 since the authors addressed the concerns during the rebuttal.
soundness: 3
strengths: - **Studies interesting but simple setting for Grokking**, which is good for understanding the Grokking phenomenon. 

- **Provides insights about Grokking:** Specifically, the authors show the relationship between linear separability and Grokking for their setting

- **Easy-to-follow paper:** Although there are some issues (mentioned below) about the writing of the paper, it is mostly easy to read.

- **Detailed examination of the considered setting:** While their setting is oversimplified, the authors investigate Grokking in this setting in a detailed way.
summary: This paper considers a binary logistic regression with isotropic Gaussian inputs and constant (same) labels to study Grokking phenomenon (Power et al., 2022). For the analysis, the authors utilize prior results (Soundry et al., 2018; Nacson et al., 2019; Ji and Telgrasky, 2019) about the learning dynamics of logistic regression. The simplified nature of the setting allows the authors to illustrate Grokking and how it appears in detail. Specifically, they show that Grokking is related to linear separability and whether the data is linearly separable from the origin. Furthermore, they find an "interpolation threshold" for the ratio of input dimension to the number of samples and demonstrate that Grokking occurs near this threshold.
weaknesses: - **Oversimplified setting:** Due to the oversimplified nature of the setting, it seems like most of the results in this paper are trivial extensions of prior results (Soundry et al., 2018; Nacson et al., 2019; Ji and Telgrasky, 2019) about the learning dynamics of logistic regression. The authors also mention their usage of (or relationship with) these prior results in several places. Therefore, the only additional benefit lies in the particular focus on Grokking. This limits the contribution of this paper. (please see Question 2 below as well)

- **Missing related work about Grokking:** There seems to be missing prior work studying Grokking under more realistic settings (Humayun et al., 2024; Golechha, 2024). Comparison with these works would be beneficial. (please see Question 3 below as well)

- **Wrong jargon usage in the writing**: 
  + In the abstract (Line 12), the authors write, "We analyze the asymptotic long-time dynamics of logistic classification on a **random feature model**." Similarly, they mention the "random feature model" in TL;DR as well. However, they study logistic classification using a linear model. By the "random feature model," they meant to say that the input distribution has a Gaussian distribution with isotropic covariance. However, the "random feature model" corresponds to a different model in literature (Rahimi and Rect, 2007). 
  + The authors say "the network" when referring to the linear model throughout the paper, which is confusing since there is no network in their setting. 
  + The authors write "long times" or "late times" to refer to the "final stages of the training", which is also not common practice in the literature.

- **The introduction does not mention the model and loss function of the setting.** These should be clarified before the contributions are mentioned.

Overall, I think this work should be extended to a more general setting, or at least the authors may show how the insights from the current work translate to examples of more complicated settings, such as more complex data (non-isotropic Gaussian inputs). Furthermore, related work should be extended to include the prior works that are missing and a comparison with them. Finally, the mentioned issues about the writing should be fixed. 

(Rahimi and Recht, 2007): Random Features for Large-Scale Kernel Machines (NeurIPS 2007).

(Humayun et. al., 2024): Deep networks always grok and here is why. (ICML 2024)

(Golechha, 2024): Progress Measures for Grokking on Real-world Tasks. (HiLD 2024)

---

confidence: 3
contribution: 2
initial_rating: 3
presentation: 2
questions: 1. On page 2, the main contributions are summarized in five points, but only the first point mentions grokking. It’s unclear how the remaining four points relate to grokking. Please consider explicitly connecting each contribution to the central theme of grokking.
2. The single-label model is uncommon; it’s unclear how the analysis of this model extends to others, such as models with binary labels.
soundness: 2
strengths: This work addresses an interesting and important problem. The analysis relates to key topics in understanding neural networks, such as implicit bias and overfitting.
summary: This work examines grokking, a phenomenon recently observed in neural network training. The author focused on a simple model for data generation and demonstrated that the occurrence of grokking depends on the ratio between data dimensionality and sample size. This analysis relates to research on implicit bias.
weaknesses: 1. The paper lacks clear presentation and organization. The connections between the analyses in each section are unclear. Without theorems or propositions in the main body, it is difficult to identify the main conclusions. It is recommended to add a roadmap or flowchart at the end of the introduction to outline the paper's structure, or to include summary statements at the end of each major section to better connect the analyses. Additionally, it is suggested that the authors present key findings as numbered theorems or propositions in the main text to make the primary conclusions more prominent.
2. The logistic loss classification with a single-label model studied in this work is overly simplistic, making it difficult to intuit how the analysis could be extended to other models. It is recommended to discuss potential extensions or limitations of the approach, such as elaborating on its limitations and future work. This could include addressing how the analysis might (or might not) generalize to more complex models.

Meta-review: This paper theoretically investigates the dynamics of binary logistic classification in a toy setup. By identifying the "memorization" and "generalization" solutions to the problem, the paper provides interesting theoretical insights into Grokking dynamics, which have been observed in a broader range of contexts.

While the paper make explicit and interesting connections to Grokking, **all** reviewers find the considered setup overly simplistic, leaving it unclear whether the analysis has broader applicability. 
Additionally, Reviewers fVQN, eABc, and tdQU note that the presentation of the paper could be further improved, while Reviewer eABc also points out that the technical contributions of the paper are limited.

This is a borderline paper, and I recommend rejecting it based on the concerns mentioned above. 
This was a difficult decision, and I hope the authors can benefit from the discussion and reviewers' comments to further improve the manuscript, particularly in terms of presentation and technical contributions.

Decision: Reject