Grokking on a Frequency Clock: Delayed Generalization in State Space Models

Neural networks sometimes "grok": they memorize their training set almost at once, then sit at chance accuracy on held-out data for thousands of steps before suddenly generalizing. The standard explanation is that weight decay slowly shrinks the parameters from a large memorizing solution toward a small generalizing one, so the delay scales as one over the weight decay. We propose a second, independent clock that should govern grokking in state space models (SSMs), which are sequence models built from linear recurrences whose internal eigenvalues set which temporal frequencies they respond to. It is already known that SSMs are initialized to respond mostly to low frequencies. Gradient descent also struggles to move their frequency parameters, because the gradient reaching those parameters falls off with frequency distance. If a task's generalizing solution needs frequencies outside the band the model starts with, generalization should wait until the eigenvalues crawl there. Weight decay would have little say in how long that takes.

To test this, we build a version of modular addition in which the generalizing circuit is exactly an eigenvalue placement. The number $a$ is encoded as a pulse at time $r\cdot a$ in one input channel, and $b$ as a pulse at time $r\cdot b$ in a second channel. A readout network must output $(a+b) \bmod p$. An SSM eigenvalue with discrete-time angle $2\pi k/(rp)$ turns each pulse into the phase $e^{-i 2\pi k a/p}$. A multiplicative readout then combines those phases into the Fourier circuit that grokked Transformers are known to build. This gives a ground-truth progress measure: the distance between the learned eigenvalue angles and the set $\{2\pi k/(rp)\}$. It also gives a causal knob. The stretch factor $r$ acts like a sampling rate, and changing it moves the required frequencies relative to the model's accessible band without changing the task at all.

Core Claim

In SSMs trained on tasks whose generalizing solution requires specific frequencies, grokking time is set mainly by the gap between the initialized frequency band and the required frequencies. It is not set mainly by weight decay. Two consequences follow. First, frequency-aware initialization should remove most of the delay, while weight-decay tuning should not. Second, when the gap is large, the network may instead generalize through a slower route, in which the readout network itself synthesizes the high-frequency features. Measuring which route the network takes is part of the claim.

The claim puts together two results that have not been connected. The first supplies the mechanism: Tuning Frequency Bias of State Space Models shows that HiPPO-style initializations favor low frequencies. It proves that the loss gradient with respect to a frequency parameter decays as $\mathcal{O}(|s|^{-2})$, where $s$ is frequency. It also introduces two fixes. Hard tuning rescales the imaginary parts of the state matrix by a factor $\alpha$. Soft tuning multiplies the model's frequency response by a Sobolev filter $(1+|s|)^\beta$. That paper evaluates these fixes on the Long-Range Arena and Moving MNIST, and never studies delayed generalization.

The second result sets the null hypothesis: norm-drift theory. A Theoretical Framework for Grokking and Omnigrok derive the $1/\lambda$ delay, where $\lambda$ is the weight decay, and To Grok Grokking shows the same timescale in ridge regression. There is a practical wrinkle. SSM frequency parameters are commonly excluded from weight decay, so norm drift cannot act on them at all. This is why a separate clock is plausible.

A rough scaling prediction follows if the gradient bound is tight. Suppose an eigenvalue must move across a frequency gap $\Delta\omega$, and its speed falls as the inverse square of the remaining distance. Integrating that speed gives

$$t_{\text{grok}} \propto \Delta\omega^{3}$$

under plain gradient descent. We treat the exponent as something to measure, not assume. Adaptive optimizers may flatten it, which is itself informative.

Relation to the Closest Work

Three papers already tie grokking to spectra, and each acts on a different spectrum than we do.

On the Convergence Behavior of Preconditioned Gradient Descent Toward the Rich Learning Regime casts grokking as spectral bias in the neural tangent kernel, meaning the function-space frequencies of the network's linearization. It shows that Gauss-Newton or Levenberg-Marquardt preconditioning shortens the delay, but only with an ad hoc switch back to AdamW to reach full accuracy. Egalitarian Gradient Descent equalizes the singular values of each gradient matrix. Explaining Grokking in Transformers through the Lens of Inductive Bias tracks the Fourier compressibility of embeddings in one-layer Transformers.

None of the three touches the model's own frequency response or an architectural frequency band. None of them studies SSMs. Their fixes act on the optimizer, whereas ours acts on where the model starts in frequency.

The interpretability line motivates the choice of task. Progress measures for grokking via mechanistic interpretability and Towards Empirical Interpretation of Internal Circuits and Properties in Grokked Transformers on Modular Polynomials show that grokked networks on modular addition use a few "key" Fourier frequencies. The second paper's Fourier Frequency Density metric, which measures how sparse a representation is across frequencies, will be applied to our readout network.

Differentiable Algebra Discovery Accelerates Grokking via a Non-Fourier Mechanism constrains how far our claim can reach. It shows that generalization need not go through sparse Fourier features. So our claim is limited to architectures whose natural route to generalization runs through their frequency response.

Research Program

The model is a one-layer diagonal SSM of the S4D type, with complex eigenvalues and a learnable step size. It is followed by a two-layer readout network. We run the readout with a multiplicative (quadratic) nonlinearity and with a ReLU nonlinearity, so that the result does not depend on an easy product. The task is the time-coded modular addition described above, with $p=97$ and training fractions from 30% to 50% of all pairs, matching the standard grokking splits. We sweep the stretch factor $r$ over roughly an order of magnitude. At $r=1$ the key frequencies extend up to near the Nyquist limit of $\pi$ radians per step. At large $r$ they sit deep inside the low-frequency band of the default initialization.

We log three progress measures throughout training. The first is the distance from each learned eigenvalue angle to the nearest $2\pi k/(rp)$. The second is the eigenvalue moduli, which must approach one so that phases survive over a horizon of $rp$ steps. The third is the Fourier Frequency Density of the readout's response to the input phases. Together they distinguish the two possible routes to generalization. On the SSM route, the eigenvalues migrate to the key frequencies. On the readout route, the eigenvalues stay put and the readout learns high-frequency functions of low-frequency phases. The second route should be slow for its own reason, since ordinary spectral bias affects the readout network too.

We run four families of interventions, each crossed with weight decay (on or off for the SSM parameters, plus a sweep of $\lambda$ on the readout) and with optimizer (SGD, AdamW). The first is default initialization. The second is hard tuning, with $\alpha$ chosen so the initialized band covers the key frequencies. The third is soft tuning across a range of $\beta$. The fourth is the controls described under Baselines. We also run one aliasing check. In this discrete-token task, frequencies $\omega$ and $\omega+2\pi$ are identical, so overscaling $\alpha$ should be harmless here. On Long-Range Arena, the tuning paper reports that the same overscaling hurts. Confirming this contrast would show that the aliasing penalty comes from the frequency content of the input signal rather than from the parameterization itself.

Baselines

The naive reference point is a default S4D-initialized model trained with AdamW at standard weight decay, with no frequency tuning. Its grokking time, or its failure to grok within budget, defines the delay being explained.

The strongest optimizer-side competitor is Egalitarian Gradient Descent. It replaces each gradient matrix $G$ with $(GG^\top)^{-1/2}G$ and is applied to every weight matrix of our model. On modular addition with $p=97$, Egalitarian Gradient Descent reports that vanilla SGD groks in "approximately 5,392 epochs" and EGD in "just 116 epochs." That result is for MLP- and Transformer-style models. For SSMs we found no reported result on Lacuna, so the EGD number serves as a scale reference rather than a target.

The strongest hyperparameter competitor is AdamW with weight decay, learning rate, and initialization scale tuned by grid search, following the prescription derived from Omnigrok. Every arm, including ours, gets the same number of tuning trials, the same data splits, the same seeds (at least ten), and the same step budget. We also report wall-clock time, because EGD adds a matrix square root at every step while hard tuning costs nothing per step. For a small model we additionally run the Levenberg-Marquardt-then-AdamW schedule from On the Convergence Behavior of Preconditioned Gradient Descent.

The ablation that isolates the key ingredient freezes the eigenvalues in three ways. They are frozen at the oracle key frequencies, frozen at a random set with the same spread that misses them, or frozen at the default initialization. Each is compared against learnable eigenvalues. If the frequency clock is real, oracle-frozen models should grok almost immediately, and missing-frozen models should grok only through the readout route or not at all.

Beating the baselines requires two things. First, hard tuning must reach 99% test accuracy in fewer steps than tuned AdamW and match or beat EGD, at equal tuning budget and lower per-step cost. Second, and more important, the frequency gap $\Delta\omega$ must explain substantially more of the variance in grokking time across $r$, seeds, and $\alpha$ than $1/\lambda$ does.

Why not just…?

Why not just tune weight decay and learning rate? This is the default explanation, and it is well supported for MLPs and Transformers. Our factorial design tests it directly. If grokking time follows $1/\lambda$ regardless of the frequency gap, our claim is wrong. The specific prediction against it comes from the weight-decay-off condition for the SSM parameters. With weight decay removed from those parameters, norm drift has no lever on the frequencies. Yet we predict that grokking time will still grow steeply with $\Delta\omega$ and shrink with $r$.

Why not just use Adam or EGD, which already rescale gradients? This is a real threat. Adam normalizes each parameter's step size, which could cancel the $\mathcal{O}(|s|^{-2})$ gradient decay entirely. The tuning paper's finding that SSMs fail to learn high frequencies was made in ordinary adaptive-optimizer training, which suggests that magnitude is not the whole story. Far from its target, the frequency landscape may be flat or oscillatory, so the gradient's direction is uninformative, not just its size. The SGD-versus-AdamW-versus-EGD comparison settles this. If AdamW makes the fitted exponent near zero, we will report that the clock exists only under plain gradient descent, and the practical claim narrows accordingly.

Why not just add training data? Omnigrok shows that more data shortens the delay. We sweep the training fraction and predict the following. More data shortens the readout-network part of the delay, but it cannot move eigenvalues that receive vanishing gradient. At large $\Delta\omega$, the delay should therefore persist, or the model should switch to the readout route, even at high training fractions.

Why not just initialize with a broad frequency spectrum and skip the theory? That is essentially the hard-tuning arm, so it is not a competitor to our intervention. It is a challenge to our contribution. If broad random initialization always suffices, the practical advice is trivial. The remaining value would then lie in the predictive law and the diagnostic, meaning the ability to say in advance, from the task's required frequencies and the model's band, whether and how long a model will wait. We will report plainly if the law adds nothing beyond "cover the band."

Decisive Checks

The central experiment plots grokking time against $\Delta\omega$ on log-log axes, varying the gap by changing $r$ and $\alpha$ independently at fixed $\lambda$. The claim survives if three things hold. The points from both manipulations must fall on one curve, with a fitted exponent that is clearly positive under SGD. Sweeping $\lambda$ at fixed large gap must move grokking time far less than $1/\lambda$ predicts. And the moment of generalization must coincide, across seeds, with the eigenvalue-distance progress measure crossing a threshold. That coincidence must hold unless the readout-route signature appears instead, which is the readout's Fourier Frequency Density sharpening while the eigenvalues stay put.

As a transfer check, the $\alpha$ values that remove the delay on the synthetic task must not degrade standard sequence modeling. Using the Long-Range Arena, we compare against the tuned-S4D average of 88.26% reported in Tuning Frequency Bias of State Space Models. Per-task Long-Range Arena numbers for that model were not found on Lacuna.