Grok –.grok?

Shaurya_Sharma1 pts0 comments

grok.....grok ? · Shaurya

grok.....grok ?

July 20, 2026<br>research, machine learning, physics

There's a strange thing neural networks sometimes do called grokking. You train a<br>network on some task, and for a long time it looks basically done: the loss on<br>its training data has already hit zero, and nothing seems to be happening. Then,<br>often thousands of steps later, with no warning, its performance on data it<br>hasn't seen suddenly jumps. It goes from failing to almost perfect, quickly, long<br>after you'd have stopped watching.

The question I got stuck on was: when that jump happens, has the network found<br>the actual underlying rule, the real law behind the data? Or has it just found a<br>slightly better guess that happens to work well near the examples it was trained<br>on? Those sound similar but they're not. A model that found the real rule should<br>work anywhere, even far outside the range it was trained on. A model that found<br>a good local guess should fail once you move away from that range. Nobody<br>seemed to have actually tested this directly, and it felt like a real gap: if<br>grokking really does mean "found the true law," that's a big deal for any field<br>where you can't just go measure the thing you're predicting (drug interactions<br>you haven't run, materials that don't exist yet, physics at conditions no lab can<br>reach). If it doesn't, that's worth knowing too.

So that became the plan: pick something with an actual, known ground-truth law,<br>grok a model on it, and then test whether it extrapolates. I called the project<br>Wedge 1.

What I already had lying around

Before starting from scratch, I checked an older project of mine called<br>catapult (named after gwern's LLM catapult hypothesis,<br>which is what got me interested in this whole area in the first place), which<br>had spent a while reproducing grokking on the classic toy example: modular<br>addition. Feed a network pairs of numbers and their sum modulo<br>some prime, hold out a chunk of the pairs, and watch what happens as it trains.<br>It turned out I'd already done a lot more with this than I remembered.

Modular addition, weight decay on. Training accuracy hits 100% almost immediately. Validation accuracy sits flat for thousands of steps, then jumps late. That gap, and the delayed jump, is grokking.

A few things from catapult turned out to matter a lot later. First, weight decay<br>(a training setting that gently penalizes the network for having large internal<br>numbers) wasn't optional here: turn it off and the jump in the figure above<br>never happens at all. Second, I could actually look inside the grokked network<br>and see what it was doing, not just that it worked.

The grokked network's internal representation, broken into frequencies. A handful of sharp spikes, not noise. It's not memorizing input-output pairs, it's computing with a small set of frequencies, the same trick you'd use to do modular arithmetic with sine and cosine waves.

The trick itself is neat. Map each number onto an angle on a circle, and<br>adding two numbers mod p turns into adding two angles. There's a plain<br>trig identity for that:

cos(A + B) = cos(A)cos(B) - sin(A)sin(B)<br>sin(A + B) = sin(A)cos(B) + cos(A)sin(B)

which a network can compute with nothing more exotic than multiplication<br>and addition. Those sharp spikes in the spectrum are the fingerprint of a<br>network that settled on a small handful of these angles, instead of<br>memorizing every pair by hand.

And when I compared a grokked network against one that had only memorized the<br>training examples, the grokked one was just sturdier in every way I tried to<br>break it.

Cut the smallest 30% of the network's weights and the grokked model barely notices, still around 97% accurate. Do the same to a model that only memorized the training set and it falls apart. Whatever grokking builds is more redundant, more real, than what memorization leaves behind.

I even tried to break a grokked solution back down on purpose: crank up weight<br>decay further, remove it entirely partway through, add noise to the labels. None<br>of it worked.

Trying to unlearn a grokked solution, several different ways. Once the network finds the real algorithm for modular addition, it does not let go.

So going in, I had good reason to believe grokking finds something real and<br>stable, at least for this kind of task. What I hadn't tested was the actual<br>question: does that "something real" generalize to inputs way outside the<br>training range. Modular arithmetic doesn't really have an "outside the range,"<br>so I needed a different kind of problem to test that.

Building the actual test

For Wedge 1 I switched to physics: functions with a known, exact formula, where<br>I could train a network on one range of inputs and then check its predictions<br>somewhere it had never seen. Lennard-Jones potential was the main one, which<br>describes how atoms attract and repel depending on distance:

V(r) = A / r^12 - B / r^6

Two terms: one repulsive (r^-12, wins up close), one attractive (r^-6,<br>wins further out), and...

network grok real grokked grokking training

Related Articles