## Introduction: The Mystery of Warmup
Norris: Welcome back to Mechanical Dreams, the podcast where we decode the latest and greatest in machine learning and natural language processing. I am Professor Norris, and as always, I am joined by my brilliant student, Linda. Linda: Hi everyone! Today, I brought a paper that tackles something we literally do every single day without really thinking about it. It is titled Why Warmup the Learning Rate? Underlying Mechanisms and Improvements, by Dayal Singh Kalra and Maissam Barkeshli, accepted for NeurIPS 2024. Norris: Ah, learning rate warmup. A classic deep learning heuristic. You start with a learning rate at zero and linearly ramp it up to your target over a few thousand steps. But is there really a mystery here? I have been teaching my students for years that since the network is initialized randomly, the gradient steps at the very beginning are essentially garbage. If you take a massive step in a garbage direction, you blow up your model. It is just common sense. Linda: Right, and that is exactly the conventional wisdom! There is also the argument that for adaptive optimizers like Adam, the variance of the learning rate is too large early on because it has not seen enough data samples. But Kalra and Barkeshli argue that these explanations are varied and do not clearly demonstrate why, and to what extent, warmup is actually necessary. Norris: Color me a little skeptical, Linda. If it is not just about tip-toeing around the garbage of random initialization, what do they claim is the overwhelming benefit? Linda: Their systematic experiments with SGD and Adam show that the primary benefit of warmup is actually to force the network into flatter, more well-conditioned areas of the loss landscape. And doing this allows the network to tolerate a much larger target learning rate later on! Norris: Wait, so it is not just a safety harness for the first few epochs? It actively navigates the optimization path so we can drive faster later without crashing? Linda: Exactly! It makes hyperparameter tuning way more robust and actually improves final performance because you can safely use that larger target learning rate. It completely reframes how we should think about those first few warmup steps.
## Tolerating Larger Learning Rates and the Sharpness Factor
Norris: Okay, Linda, you mentioned in our introduction that warmup actively navigates the model to a flatter area so we can drive faster later on. But what exactly defines 'flat' in this high-dimensional optimization context? Linda: It all comes down to the Hessian matrix, Professor. The authors mathematically define this landscape using a metric they simply call 'sharpness.' Sharpness is the maximum eigenvalue of the Hessian of the loss. Norris: Ah, the Hessian. The matrix of second derivatives that strikes fear into the hearts of calculus students everywhere. But in optimization, that top eigenvalue dictates our absolute speed limit, right? Standard gradient descent becomes unstable and diverges if your learning rate exceeds two divided by that top eigenvalue. Linda: Exactly! The authors refer to that as the critical instability threshold. If you just naively set a large target learning rate from step one, you will likely exceed that threshold immediately. The model takes a step that is way too large, the loss shoots to infinity, and your training run is completely dead. Norris: Right, I have seen my fair share of 'NaN' losses on step five. But wait, if this threshold is an inherent property of the landscape at initialization, wouldn't slowly ramping up the learning rate just delay the inevitable? Eventually, your warmup schedule still has to cross that threshold. Linda: That is the beautiful part about their findings. The sharpness is not static! As the model takes those small, early steps during the warmup phase, the sharpness of the landscape actually decreases. By the time your warmup schedule reaches the large target learning rate, the landscape has flattened out enough that the instability threshold is now much higher. Norris: I see. So we are not just tiptoeing around a sleeping bear to avoid waking it up. We are actively tranquilizing the bear before we start sprinting. But here is a practical question: if the goal is just to reach a flat region, does the length of the warmup actually matter? If I warmup for ten epochs instead of two, does my model generalize better? Linda: The authors ran extensive phase diagrams to answer exactly that, carefully disentangling the warmup duration from the target learning rate. And their findings are super clear. Final performance depends almost entirely on the target learning rate, not the warmup duration itself. Norris: Really? So a longer warmup does not magically improve your model's intelligence? Then why do practitioners spend so much time obsessing over the exact number of warmup steps? Linda: Because increasing the warmup duration keeps the network further away from the divergence boundary! It makes your hyperparameter tuning way more robust. If you use a longer warmup, the model can safely withstand a much wider window of target learning rates without blowing up. The long warmup essentially buys you a bigger safety net to hit those optimal, high learning rates. Norris: That makes perfect sense. A longer warmup is just a longer runway. It does not make the plane fly better, but it allows a much heavier plane to take off safely at a higher speed. And that higher speed—the target learning rate—is what actually gets you to the better minima. Linda: Spot on, Professor! They also note this is especially crucial for models with 'large' initializations, like using Standard Parameterization in ResNets. Those models start in very sharp regions and absolutely need that runway. On the flip side, if you use a 'flat' initialization like Maximal Update Parameterization, or muP, you might not need much warmup at all because you are already starting on the runway. Norris: That is a brilliant connection to initialization schemes. I have always suspected that parameterization and warmup were intimately linked, but having systematic experiments to prove that the target learning rate is the true hero of the story is incredibly satisfying. I am starting to see why you were so excited to bring this paper in.
## Catapults and the Edge of Stability
Norris: Alright, Linda. You have convinced me that the destination of warmup is a flatter region of the landscape that can handle a massive target learning rate. But how do we actually get there? In our outline of the paper, you mentioned a rather violent-sounding term: the 'loss catapult'. Linda: Yes! The loss catapult is my favorite part of the paper. It is intimately tied to what happens when you cross that instability threshold we just talked about—the point where the learning rate exceeds two divided by the sharpness. Norris: Usually, crossing that threshold is game over. The loss goes to infinity, and I end up hitting Ctrl+C to kill the run. Are you telling me we actually want to cross it? Linda: Under the right conditions, yes! Crossing it actually triggers a four-step self-stabilization mechanism. First, as the learning rate increases during warmup, you approach the instability threshold. Second, you cross it, and the loss literally blows up. It spikes exponentially. Norris: I am with you so far, though my instinct is still to panic when I see that spike. Linda: Do not stop the run just yet! Because step three is where the magic happens: sharpness reduction. The exponential growth in the loss pushes the model's parameters so far that higher-order terms in the sharpness update equation take over. These higher-order terms actively force the sharpness to decrease abruptly. Norris: Let me guess... step four is a return to stability? Because the sharpness suddenly dropped, our instability threshold increased. Suddenly, our current learning rate is safe again. Linda: Exactly! The explosion essentially carves out a flatter crater, and the loss goes back down. But Kalra and Barkeshli found that the exact way these catapults manifest depends heavily on the model's 'natural' preference for sharpness evolution. Norris: Natural preference? You mean how the sharpness would evolve under standard gradient flow, without the linear warmup forcing its way in? Linda: Spot on. They uncovered two distinct regimes. The first is Natural Progressive Sharpening. This happens with small initializations, like the muP we discussed, or standard Transformers. The network naturally wants to get sharper as it trains. Norris: So the landscape is naturally getting steeper on its own, while our warmup schedule is simultaneously stepping harder and harder on the gas pedal. That sounds like a recipe for disaster. Linda: The authors actually call it a 'head-on collision'! Because both the sharpness and the learning rate are increasing simultaneously, they crash into the instability threshold very early. This triggers a catapult, the sharpness drops to stabilize, but then the network naturally wants to increase sharpness again. Norris: I see. So it hits the threshold, bounces back, gets sharper, hits it again... it must enter a loop. Linda: Yes! They call it a persistent catapult cycle. The training dynamics just ride the edge of stability for the remainder of the warmup period. It is a continuous rumble of tiny catapults. Norris: Fascinating. And what is the second regime? Linda: The second is Natural Sharpness Reduction. This happens with large initializations, like Standard Parameterization in ResNets. Here, the network is naturally trying to flatten out during early training. Norris: Well, if it is already flattening out and increasing the safety threshold on its own, why does it crash? Linda: Because the linear warmup is increasing the learning rate too fast! It is like speeding down a highway and rear-ending the car in front of you. You hit the instability threshold anyway, which induces a massive, dramatic drop in sharpness—way more pronounced than what would naturally occur. Norris: Ah! And because the sharpness drops so drastically from that massive catapult, the safety threshold shoots way up. The learning rate now has plenty of room to grow before it ever hits the threshold again. Linda: You nailed it. This results in one or more highly separated, distinct catapults, rather than a continuous rumble. It is just a few massive spikes during the warmup phase. Norris: This perfectly explains our discussion about warmup duration from the last chapter! If I have a Natural Sharpness Reduction regime, and I stretch out my warmup to, say, thousands of steps... Linda: ...you give the network more time to naturally reduce its sharpness before the learning rate gets too high! Norris: Right! You delay that rear-end collision. By the time the learning rate is dangerously high, the landscape has already naturally flattened enough to handle it. The catapults become much milder. Linda: Yes! And in the Progressive Sharpening case, increasing the warmup duration means the learning rate increases so slowly that when the head-on collision finally happens, the fluctuations are incredibly small. In both cases, a longer warmup actively tames these catapults so they do not completely destroy your training run. Norris: This is a brilliantly mechanical view of optimization. We are literally using controlled instabilities—guided explosions—to navigate the loss landscape. It makes the term 'warmup' sound a lot less like a gentle stretch before a jog, and more like a calculated rocket ignition sequence.
## Adam, Pre-conditioned Sharpness, and Training Failures
Norris: So Linda, we just spent the last chapter talking about these guided explosions, these loss catapults in standard Stochastic Gradient Descent. But let us be real for a second. Most of our listeners, especially those training Transformers, are using Adam. Does this whole sharpness framework actually hold up when the optimizer is dynamically changing the step size for every single parameter? Linda: That is the million-dollar question, Professor! The authors dug deep into Adam, and the framework absolutely holds up, but with a crucial twist. Because Adam scales gradients by the inverse square root of their moving variance, it effectively performs gradient descent in a transformed parameter space. Norris: Right, it uses a pre-conditioner. So I assume we can no longer just look at the standard sharpness of the Hessian matrix? Linda: Exactly. You have to look at what they call the pre-conditioned sharpness. It is the top eigenvalue of the Hessian after it has been multiplied by Adam's pre-conditioner. And here is the shocking part: at initialization, this pre-conditioned sharpness is astronomically high. Norris: Astronomically high? How high are we talking? Even for those flat muP initializations we discussed earlier? Linda: Even for muP! While standard sharpness might be tiny, the pre-conditioned sharpness starts around ten to the fifth power. For Standard Parameterization, it is around ten to the sixth! Norris: Good grief. Why does the pre-conditioner inflate the sharpness that much? If the landscape is actually flat, Adam is hallucinating a cliff. Linda: It is all because of Adam's initialization and bias correction. At step zero, the initial gradients are tiny, near-zero values. Adam's second moment variance relies on these tiny gradients. When you divide by a near-zero variance, mathematically, the pre-conditioned sharpness just blows up. Norris: Ah, dividing by epsilon essentially. I see the trap. If the pre-conditioned sharpness is that high, the instability threshold is practically on the floor. If you start with any reasonable target learning rate without warmup, you are instantly crossing the threshold. Linda: Instantly! You get a massive, violent catapult. But here is where Adam behaves completely differently from SGD. With SGD, a massive catapult means the loss goes to infinity and the model diverges. But Adam actually prevents divergence. Instead, it suffers what the authors term a 'training failure'. Norris: A training failure? Meaning the loss just flatlines and refuses to go down? Linda: Precisely. During that massive early catapult, the gradients spike drastically. Adam's second moment, which is a moving average, records that massive spike and stores it. Norris: Oh, no. Because it is a moving average, it remembers that spike! And since Adam divides the learning rate by the square root of that second moment, the effective learning rate becomes vanishingly small. Linda: You hit the nail on the head, Professor. Adam traumatizes its own memory! The effective learning rate drops to near zero, and the model gets trapped in a high-loss region. The authors even looked inside the network during these failures and found that certain layers or residual blocks just output zero, causing the gradients to vanish completely. Norris: That is a revelation. I have had models flatline at the very start of training, and I always assumed I just picked a bad learning rate. But it is actually Adam's memory working against it because of that initial spike. So, how does warmup rescue us from Adam's trauma? Linda: Warmup keeps the learning rate tiny during those first few steps. This gives the pre-conditioned sharpness time to naturally decrease from those absurdly high millions down to a manageable level. It is essentially an extreme version of the Natural Sharpness Reduction regime we talked about in the last chapter. Norris: So by the time the linear warmup reaches our actual target learning rate, the pre-conditioned sharpness has deflated. The threshold is safe, the catapults are mild, and Adam's memory stays pristine. That makes warmup not just a nice trick for Adam, but an absolute structural necessity. Linda: Exactly! It proves that the old argument about Adam just 'needing to see more data samples' to reduce variance is missing the real mechanical picture. It is all about taming that initial pre-conditioned sharpness to prevent a catastrophic memory failure.
## GI-Adam and Better Initialization Strategies
Norris: So, Linda, you left us hanging in the last chapter. We established that Adam's initialization causes the pre-conditioned sharpness to skyrocket, which leads to massive catapults that permanently traumatize Adam's memory. A slow warmup saves us, but did Kalra and Barkeshli find a way to fix the root of the problem? Linda: They absolutely did, and it is beautifully simple. They introduce a modification called Gradient Initialized Adam, or GI-Adam for short. The fix is just changing how the second moment is initialized. Norris: Let me guess. Instead of initializing the second moment moving average to zero, which causes that division-by-epsilon explosion we talked about, they initialize it with something else? Linda: Exactly! They initialize the second moment using the square of the very first gradient. That is it. Norris: Wow. That makes perfect mathematical sense. If your variance denominator starts with the actual magnitude of your initial gradients, the pre-conditioned sharpness will not artificially inflate. How much does this actually drop the initial sharpness? Linda: It reduces the initial pre-conditioned sharpness by around two orders of magnitude! By knocking that sharpness down right out of the gate, GI-Adam prevents those massive, memory-destroying catapults. It pushes the training failure boundary way out, meaning you can safely use much higher target learning rates. Norris: That is a fantastic, elegant fix. But wait, standard Adam has a bias correction term specifically because the moving averages are initialized at zero. If we initialize with the first gradient, doesn't that mess up the bias correction? Linda: You are always one step ahead, Professor! Because GI-Adam initializes with the actual gradients, it completely removes the need for the second-moment bias correction. In fact, if you follow the math, applying GI-Adam is mathematically equivalent to running standard Adam with a built-in, automated warmup schedule. Norris: So GI-Adam essentially builds the warmup right into the optimizer itself. I love that. But what about the explicit warmup schedule we set for the learning rate? We usually start that at zero and linearly increase it. Did they propose a better way to do that? Linda: Yes, they did! The authors point out that starting the learning rate at zero is computationally wasteful. Think about it: if the whole point of warmup is to cross the instability threshold and induce those controlled catapults to flatten the landscape... Norris: ...then starting at zero just means we are crawling towards the threshold for no reason! We are wasting forward and backward passes just waiting for the learning rate to get high enough to actually do its job. Linda: Exactly! So they propose a much better initialization strategy: set the initial learning rate exactly at the critical instability threshold. You start right at the edge of stability. Norris: I like the sound of that. But how on earth do we know what the instability threshold is before we even start training? I certainly do not want to compute the top eigenvalue of the Hessian for a massive language model. Linda: We do not have to compute the Hessian at all! They propose a super lightweight search method. Before actual training begins, you just do a few forward passes. You start with a tiny learning rate guess, exponentially double it until the loss goes up, and then do a quick binary search to pinpoint the exact threshold. Norris: Only forward passes? No backpropagation required for the search? Linda: No backprop required! It takes maybe ten forward passes in total, which is roughly the computational equivalent of just five normal training steps. And by starting the warmup right at that threshold, you can skip the useless crawling phase and save up to half of the total warmup duration. Norris: For training massive models that run for weeks, saving half of your warmup compute is a massive win. You find the edge of the cliff with a few cheap forward passes, and then you start your warmup right at the edge of stability, immediately triggering the sharpness reduction we talked about earlier. This is brilliant. Linda: It really is. It takes these abstract concepts of loss landscapes and turns them into highly practical, compute-saving tools that any practitioner can use.
## Conclusion and Final Thoughts
Norris: Well, Linda, I have to admit, you and this paper have completely changed my perspective today. I started out this episode thinking warmup was just a trivial safety net to keep our randomly initialized weights from blowing up. But it turns out, it is a highly mechanical, calculated process to actively flatten the loss landscape. Linda: Exactly! I think the biggest takeaway for our listeners is to stop obsessing over the exact number of warmup steps to get better generalization. Focus on finding the highest stable target learning rate, because that is what actually drives your final performance. The warmup duration just buys you the runway to get there safely. Norris: And if you are using Adam, which most of us are, watch out for that initial pre-conditioned sharpness spike causing permanent memory trauma! I am definitely going to get my lab to start experimenting with GI-Adam and that clever forward-pass search to find the instability threshold. Linda: It makes a huge difference. It is all about working with the geometry of the loss landscape, rather than just blindly guessing hyperparameters in the dark. Norris: Beautifully said. Thank you for bringing in such an eye-opening paper, Linda. And thank you to our listeners for joining us on another episode of Mechanical Dreams. Until next time, keep dreaming, and keep learning!