Introduction
A network trained on a small training set can fit it almost immediately and then stay near chance on held-out data for orders of magnitude longer before it generalises. This is grokking. The task asks for a training rule, meaning the update, the loss it differentiates and any metered extra use of the training data, that removes that delay. The metric is the log10 of the first training step at which held-out accuracy reaches the setting's threshold, so lower is better and a rule is judged on when generalisation first arrives.
The difficulty is that the delay has more than one cause, and the published remedies each address one of them. One account treats grokking as a slow move from lazy, kernel-like training to rich feature learning [1]. Another ties it to the weight norm: generalising solutions sit at a smaller norm than the initialisation, and holding the norm there removes the delay [2]. Others locate it in the gradient. Grokfast amplifies its slow components [3], egalitarian gradient descent equalises its singular directions [4], NeuralGrok learns a transformation of it [5], and the Muon optimizer, which orthogonalises the momentum of each weight matrix, is reported to bring grokking forward [6]. A further account is numerical: once the training set is fitted, cross-entropy drives the logits apart until the softmax saturates in floating point and the useful gradient vanishes [7]. Transfer from a weaker model [8], decoupled weight decay [9] and a logit penalty [10] complete the set of references.
Each of these remedies is strong where its cause dominates and weak elsewhere. On this task's leaderboard no single baseline is the best on every setting. Our aim was one rule that removes the delay whichever cause is present.
Method
We call our rule RSM, for relative spectral momentum. It treats every weight matrix the same way and changes each by a fixed fraction of its own norm per step. Three stabilisers then keep that relative step from diverging once the training set is fitted.
The relative spectral step
Let be a weight matrix with gradient . We keep a momentum buffer and take the Nesterov combination,
and orthogonalise it with five Newton-Schulz iterations, , which pushes every singular value of toward one. This is the direction Muon uses [6]. Muon then takes a step of absolute size. We take a step of relative size instead:
The relative step is the core of the method. With an absolute step, a network initialised at a large scale changes its weights by a tiny fraction per step and stays in the lazy regime for a long time. With a step proportional to , the fraction changed per step is whatever the initialisation scale, so feature learning starts at once. The orthogonalisation addresses the second cause. Memorising directions with large singular values no longer outrun the smaller, structured ones, because all of them move at the same rate. Unlike Muon, we apply the update to the embedding and readout matrices too, since that is where the search for a structured representation happens. Every parameter with two dimensions is treated this way; all remaining parameters use AdamW [9].
def step(self, model, step_index):
eta = self.eta0 / (1.0 + step_index / self.decayT)
with torch.no_grad():
for p, buf in zip(self.mats, self.mom):
g = p.grad
if g is None:
continue
buf.lerp_(g, 1 - self.MOM)
u = g.lerp(buf, self.MOM)
u = self._ns5(u, self.NS)
u = u * max(1, u.size(-2) / u.size(-1)) ** 0.5
wn = p.norm()
un = u.norm() + 1e-12
scale = eta * wn / un
p.mul_(1 - eta * self.wd)
p.add_(u.reshape(p.shape).to(p.dtype), alpha=-scale) @staticmethod
def _ns5(G, steps):
a, b, c = (3.4445, -4.7750, 2.0315)
X = G.bfloat16()
if G.size(-2) > G.size(-1):
X = X.mT
X = X / (X.norm(dim=(-2, -1), keepdim=True) + 1e-7)
for _ in range(steps):
A = X @ X.mT
B = b * A + c * A @ A
X = a * X + B @ X
if G.size(-2) > G.size(-1):
X = X.mT
return XWhy the relative step needs brakes
A relative step has a failure mode that an absolute step does not have. Once the training set is interpolated, the cross-entropy gradient is mostly a direction that inflates the logits, and its magnitude becomes small. An absolute step shrinks with it. A relative step discards the magnitude and still moves the weights by a fraction of their norm, so the norm grows, the next step grows with it, and the network random-walks to divergence. We use three brakes against this.
First, the decay . Generalisation under the relative step comes early and the blow-up comes late, so a decay on the scale leaves the early search at full speed and shrinks the steps taken after interpolation. Second, decoupled weight decay with coefficient pulls the norm back toward the smaller generalising solutions [2]. Third, a cap on the global parameter norm. If exceeds , we rescale every parameter by . The cap is a multiple of the initial norm; it keeps the trajectory in the generalising region and acts as a safety net against a runaway.
self.mats = [p for p in model.parameters() if p.ndim == 2]
ids = {id(p) for p in self.mats}
rest = [p for p in model.parameters() if id(p) not in ids]
self.mom = [torch.zeros_like(p) for p in self.mats]
self.allps = [p for p in model.parameters() if p.requires_grad]
with torch.no_grad():
self.Rcap = self.cap * math.sqrt(float(sum((p ** 2).sum() for p in self.allps)))
self.opt = torch.optim.AdamW(rest, lr=1e-3, weight_decay=1.0,
betas=(0.9, 0.98)) if rest else None if self.opt is not None:
self.opt.step()
if self.sched is not None:
self.sched.step()
with torch.no_grad():
norm = math.sqrt(float(sum((p ** 2).sum() for p in self.allps)))
if norm > self.Rcap:
sc = self.Rcap / norm
for p in self.allps:
p.mul_(sc)A cross-entropy whose gradient stays zero-sum
For the classification losses we replace the library cross-entropy with an algebraically identical form,
The gradient of the softmax cross-entropy sums to zero over the classes. In the usual implementation the target's component is computed as a probability minus one, and when the target logit leads by a wide margin that component rounds to zero in low precision while the others do not, which is the softmax-collapse mechanism [7]. In our form the target slot of is masked to a constant, so automatic differentiation produces a gradient that is zero-sum by construction. The form follows a recent paper on numerical bugs in softmax and cross-entropy that our literature survey found; it is not among the works we can cite here. Where the task fixes the loss, we keep the default.
z = outputs.float()
z_t = z.gather(-1, targets[:, None].to(torch.int64))
d = z - z_t
mask = F.one_hot(targets.to(torch.int64), z.shape[-1]).bool()
d = d.masked_fill(mask, float("-inf"))
return F.softplus(torch.logsumexp(d, dim=-1)).mean()Constants
The algorithm is the same on every network. Its constants are set per network family through the family label the interface provides, as several published methods do. The relative step is , the decay time is and the norm cap is , with momentum , five Newton-Schulz iterations and throughout. The AdamW for the remaining parameters uses learning rate , weight decay and betas , with a ten-step warm-up on some families. RSM makes no extra passes over the training data.
Results
| Method | ④ | ⑤ | ⑥ |
|---|---|---|---|
| log10 steps to generalise ↓ | log10 steps to generalise ↓ | log10 steps to generalise ↓ | |
| Qwen4-Max | 2.417 | 3.667 | 3.667 |
| Adam without weight decay | 4.699 | 5.000 | 4.750 |
| AdamW | 4.083 | 3.750 | 3.000 |
| Fixed-norm sphere | 3.083 | 5.000 | 4.833 |
| Grokfast MA | 3.083 | 3.167 | 3.083 |
| Grokfast EMA | 3.083 | 3.250 | 3.083 |
| Goldilocks-norm projection | 2.583 | 5.000 | 4.417 |
| ⊥AdamW | 3.917 | 2.250 | 2.833 |
| Egalitarian Gradient Descent | 3.083 | 5.000 | 2.833 |
| Muon | 3.500 | 4.167 | 2.417 |
| NeuralGrok | 4.333 | 3.833 | 3.083 |
| StableMax | 4.699 | 4.833 | 5.000 |
| GrokTransfer | 4.699 | 3.667 | 3.583 |
| z-loss | 4.250 | 3.750 | 3.000 |
- ④ Mano modular expressions, 2 operations, 20k training examples · 8-layer Llama decoder (Allen-Zhu, Physics of LMs 4.1)
- ⑤ Brevo dependency closure, DAGs up to 16 nodes, 20k training examples · 8-layer Llama decoder (Allen-Zhu, Physics of LMs 4.1)
- ⑥ Brevo dependency closure, DAGs up to 12 nodes, 20k training examples · 8-layer Llama decoder (Allen-Zhu, Physics of LMs 4.1)
RSM is ahead of every published baseline on ModAdd-Tfm, with a log10 generalisation step of 2.417 against 2.583 for the strongest baseline there, Goldilocks norm [2]. Of the remedies in the introduction, the weight-norm one is the nearest, and our relative step and norm control reach generalisation sooner than it does.
On every other setting a baseline is ahead of us. On ModAdd-MLP we reach 3.667 against 2.250 for ⊥AdamW [7]. On ModArith-2L we reach 3.667 against 2.417 for Muon [6]. On Mano-L2 the gap is smaller, 3.875 against 3.625 for Muon [6]. On Brevo-12 we reach 3.375 against 2.875, which Muon, egalitarian gradient descent and z-loss share. Brevo-16 is our weakest result. There RSM reaches 4.699, level with Adam without decay at 4.699, while Muon [6] reaches 2.875.
Against AdamW at its published settings, which is the closest thing to a default, RSM is faster on ModAdd-Tfm, ModAdd-MLP and Mano-L2, where AdamW reaches 4.083, 3.750 and 4.000, and slower on ModArith-2L, Brevo-16 and Brevo-12, where it reaches 3.000, 3.250 and 3.000. Muon and egalitarian gradient descent, which orthogonalise or equalise the gradient's singular directions, are both ahead of us on ModArith-2L, Mano-L2, Brevo-16 and Brevo-12. Muon takes the same orthogonalised direction with an absolute step, so where it is ahead the deficit more likely lies in our relative step size, its decay and the cap than in the direction.
How we got here
We began by running the published baselines on development versions of the network families and recording logit scale, gradient norm and embedding spectra alongside held-out accuracy. While the first baselines were still running we hypothesised that Muon's absolute step changes the weights by too small a fraction at a large initialisation scale to leave the lazy regime, and wrote our first candidate: Muon with a step relative to the weight norm, applied to every matrix. It became the core of RSM. The baselines then gave two observations. In our development runs the weight-norm projection of Omnigrok [2] was the fastest baseline on one family, which suggested that norm control is the main lever. And Muon was fast on another family but failed at a large initialisation scale, as the hypothesis predicted.
- The relative step generalised early and then diverged. On one family our first candidate reached the threshold at step 178 in development, the fastest result we had seen, and then fell to chance accuracy by about step 1,200. Inspecting the curve showed that the generalisation was real. The fall came after it, because the relative step does not shrink with the small gradient that follows interpolation. Most later changes to the method were aimed at this divergence.
- Combining existing remedies failed. Muon combined with Omnigrok's norm projection broke the family on which the projection alone was fastest, and an adaptive radius did worse than a fixed one. A hard projection of our relative step onto a fixed norm also failed, because it interfered with the relative dynamics.
- Excluding the readout and a stronger decay did not fix it. We suspected the readout matrix, which Muon leaves out. Excluding it from the relative step slowed generalisation and still left the accuracy falling afterwards, so the final rule keeps the readout in. Weight decay of 1.0 or more removed generalisation altogether. Later, removing the radial component of the gradient before the orthogonalisation, as orthogonal-gradient methods do [7], made no difference on the families we tested, and we left it out.
- Gating the step by the gradient magnitude suppressed generalisation itself. We scaled the step by the momentum's magnitude relative to a running maximum, an initial floor or a moving average. Each variant stopped the divergence on some families, but the gate also fired during the generalisation phase and slowed it, so we dropped gating.
- A norm cap checked after each step was not enough by itself, because the relative step can overshoot within one step. The decay of fixed it. With our development run on the family that had diverged reached the threshold at step 316 and held full accuracy, and the same rule generalised without failure on every family on which any rule generalised in development. A later check with different random initialisations showed late collapses again on two families. A faster decay together with a norm cap of a few times the initial norm removed those. The cap and decay constants were then set per family over several rounds of development runs.
- A non-saturating loss did not help where we expected. StableMax as the training loss [7] was slow and mostly failed in our development runs. The zero-sum cross-entropy matched standard cross-entropy exactly on the families we could develop on, which do not reach the precision limit. We kept it because it costs nothing and addresses the numerical cause on networks trained in low precision.
- Zero-initialising the readout failed, and we left it out.
- On some families no rule generalised in development. No method we ran there, baselines included, reached the threshold there within our development runs, even with more training data. We confirmed only that RSM runs cleanly there and is not slower per step than the slowest reference.
The paper on softmax and cross-entropy numerics that the zero-sum loss follows is not among the works we can cite, and we have asked for it to be added.
Limitations
- RSM leads on one setting only. It is ahead of every baseline on ModAdd-Tfm and behind the best baseline on every other setting, by a wide margin on ModAdd-MLP, ModArith-2L and Brevo-16. We did not find one rule that removes the delay whatever its cause. We found one that is fastest on ModAdd-Tfm, where the weight-norm baseline is also the strongest of the baselines.
- The constants are per family. The step size, decay time and norm cap differ between network families and were chosen on development runs. RSM is one algorithm, but it depends on the family label to choose its constants, and it has no rule for a network family it has not seen.
- The stabilisers are tuned, not derived. The divergence of the relative step is real and we understand its cause, but the decay and the cap that control it were found by search. In development the right cap for one family depended on the random initialisation, and no single setting was stable for every initialisation we tried.
- Part of the update has no effect. Our step rescales the orthogonalised momentum by , as Muon does for an matrix, and then normalises it to unit Frobenius norm. The normalisation cancels the rescaling, so that line does nothing in RSM.
- The loss change is unproven here. In our development runs the zero-sum cross-entropy behaved exactly like the standard one, so its contribution to the measured results is not established.
References
- Tanishq Kumar, Blake Bordelon, Samuel J. Gershman et al. (2023). Grokking as the Transition from Lazy to Rich Training Dynamics.
- Ziming Liu, Eric J. Michaud, Max Tegmark (2023). Omnigrok: Grokking Beyond Algorithmic Data. ICLR.
- Jaerin Lee, Bong Gyun Kang, Kihoon Kim et al. (2024). Grokfast: Accelerated Grokking by Amplifying Slow Gradients.
- Ali Saheb Pasand, Elvis Dohmatob (2026). Egalitarian Gradient Descent: A Simple Approach to Accelerated Grokking. ICLR.
- Xinyu Zhou, Simin Fan, Martin Jaggi et al. (2025). NeuralGrok: Accelerate Grokking by Neural Gradient Transformation.
- Amund Tveit, Bjørn Remseth, Arve Skogvold (2025). Muon Optimizer Accelerates Grokking.
- Lucas Prieto, Melih Barsbey, Pedro A. M. Mediano et al. (2025). Grokking at the Edge of Numerical Stability. ICLR.
- Zhiwei Xu, Zhiyu Ni, Yixin Wang et al. (2025). Let Me Grok for You: Accelerating Grokking via Embedding Transfer from a Weaker Model. ICLR.
- Ilya Loshchilov, Frank Hutter (2019). Decoupled Weight Decay Regularization. ICLR.
- Aakanksha Chowdhery, Sharan Narang, Jacob Devlin et al. (2022). PaLM: Scaling Language Modeling with Pathways.