Latest / Mechanical Dreams / Optimal Linear Decay Learning Rate Schedules and Further Refinements
Transcript
- ## The Death of Cosine? Linda: Hello and welcome back to Mechanical Dreams, the podcast where we dream of electric sheep and optimal gradients. I’m Linda. Norris: And I am Professor Norris. And frankly, Linda, I’m a little worried about today's topic. You told me we’re discussing learning rate schedules? I feel like I’ve spent half my career just staring at loss curves, wondering if I should decay at epoch 30 or 31. Linda: Oh, it’s much more fundamental than epoch 30 versus 31, Professor. Today we are talking about the shape of the curve itself. The paper is titled "Optimal Linear Decay Learning Rate Schedules and Further Refinements," coming out of Meta AI and Boston University. Norris: Linear decay? You mean drawing a straight line from start to finish? That sounds... primitive. We live in the age of Cosine Annealing! It’s elegant, it’s smooth, it looks like a gentle hill rolling into a valley of low loss. Why would we want to replace that with a jagged triangle? Linda: That is exactly the reaction the authors are expecting. Cosine Annealing is the darling of the deep learning world right now. It’s the default in almost every major codebase. But this paper argues that it’s not just suboptimal, it’s actually less grounded in theory than a simple linear line. Norris: Less grounded in theory? Cosine feels very... mathematical. Periodic. Trigonometric. You’re telling me the "y equals mx plus c" of schedules is actually the superior choice? Linda: I am. And they have the math to prove it. They claim that the gap between what theorists prove—like the 1/t schedule—and what practitioners use—like Cosine—can be closed. And the bridge is Linear Decay. Norris: I remain skeptical. I’ve seen a thousand papers claiming to have found the 'One True Schedule,' usually involving complex fractals or moon phases. But if you’re saying a straight line beats my beautiful cosine wave, you better have some strong arguments. Linda: Oh, I do. And not just arguments, but experiments on everything from ImageNet to Large Language Models. We might be witnessing the death of Cosine, Professor. Norris: The death of Cosine. Heavy words. Alright, let’s look at the autopsy report. Where do we start? ## Theory vs. Reality Norris: So, Linda, if we are putting Cosine on trial, we have to look at the witnesses for the defense. And the star witness is... well, classical theory. If you open any convex optimization textbook—including the one I wrote a chapter for back in the day—it doesn't say 'use a sine wave'. It says the learning rate should decay as one over t, or perhaps one over the square root of t. Linda: That’s the 'Bible' of optimization, right? One over t for strongly convex problems, one over root t for convex ones. Norris: Precisely. It guarantees convergence! It’s mathematically sound. So why on earth did we stop using it? I feel like I haven't seen a 'one over t' schedule in a paper since... well, since before deep learning took over. Linda: Because in practice, for deep neural networks, 'one over t' is terrible. It decays way too fast. By the time you’re halfway through training, your learning rate is microscopic, and the model just stops learning. It freezes before it finds a good solution. Norris: Fair enough. I have noticed that if I try to be a 'theoretical purist' in my lab, my grad students revolt because their ResNets won't converge. So we end up with these constant learning rates that drop by a factor of ten every few epochs. The 'Step Decay'. Or the Cosine. Linda: Exactly. The paper calls this the 'Theory-Practice Gap'. Practitioners found that keeping the learning rate high for a long time—and then decaying—worked better. But the theorists were scratching their heads because their proofs said you *should* be decaying immediately. Norris: So who is wrong? The math or the reality? Usually, reality wins, but I hate to admit it. Linda: Here is the twist: the math wasn't wrong, it was just answering the wrong question. Most of those classical proofs for one over t assume that the output of your algorithm isn't the final set of weights. Norris: Ah, let me guess. Polyak-Ruppert averaging? Linda: Bingo. Norris: For the listeners who aren't currently solving integrals in their heads: Polyak averaging means you don't just take the final model. You take the average of all the models you saw during the trajectory. It smooths out the noise. It’s elegant. It works wonders in simple regression. Linda: It is elegant. But have you ever tried averaging the weights of a billion-parameter Transformer? Norris: I try to avoid doing anything with a billion parameters if I can help it. My RAM starts crying. Linda: Exactly. Plus, in non-convex landscapes like neural nets, the average of two good models might sit right in the middle of a valley of bad performance. So, nobody uses the average iterate. We use the *last* iterate. The final checkpoint. Norris: I see. So the textbooks give us the optimal schedule for the *average* iterate, but we are using the *last* iterate. And those two things require different schedules? Linda: Drastically different. The paper argues that analyzing the convergence of the *last* iterate is actually much harder mathematically, which is why it was ignored for so long. The last point is noisy. It bounces around. The average is stable. Norris: So the 'Theory-Practice Gap' is really just a 'Target Mismatch'. We optimized for the average, used the last, and wondered why it didn't work. Linda: Precisely. And since the theory for the last iterate was missing, practitioners just started experimenting. They found Step Decay, they found Cosine. They filled the void with heuristics. Norris: But now, you're saying these authors went back to the chalkboard to derive the actual optimal schedule for the *last* iterate? Linda: They did. They wanted to see if they could close that gap. They derived a bound specifically for the error of the final point, $x_T$, not the average. And when you solve that optimization problem... you don't get a curve. You get a line. ## Linear Decay Takes the Crown Norris: A line. You are telling me that after decades of research, hundreds of papers on adaptive methods, and countless GPU hours spent searching for the perfect curve, the answer is a simple, diagonal line? Like drawing a hypotenuse on a triangle? Linda: Basically, yes. Specifically, the schedule is proportional to one minus t over T. You start at your maximum learning rate at step zero, and you decrease it linearly until you hit zero at the very last step, T. Norris: That is almost insultingly simple. It sounds like something a first-year student would implement because they didn't know how to import the cosine scheduler from PyTorch. But you said there is a reason for this shape? Linda: There is. And it goes back to that idea of iterate averaging we discussed. Remember how averaging all the weights along the path cancels out the noise? Norris: Right. The noise in stochastic gradient descent is random, so if you average enough points, the noise sums to zero. Linda: Exactly. Now, imagine you aren't averaging. You are just taking the final step. If you keep the learning rate constant, that final step is just as noisy as the first one. You bounce right off the optimum. Norris: So you have to decay. We know that. Linda: But *how* do you decay? The paper shows that if you decay linearly, the contribution of each gradient to the final position mimics the weight it would have had in an average. It essentially forces the 'last iterate' to behave like the 'average iterate' mathematically. Norris: I see. So by shrinking the step size at a constant rate, you are effectively simulating the stability of Polyak averaging without actually having to store or compute the average? Linda: Spot on. They prove that this linear schedule achieves the 'minimax optimal' rate for convex problems. That means in the worst-case scenario, linear decay is the safest, most robust bet you can make. Norris: Minimax optimal. Now you are speaking my language. But Linda, the real world isn't a worst-case convex problem. It's a messy, non-convex neural network. Does this hold up when you actually train something real? Linda: They didn't just derive it; they stress-tested it. They ran comparisons on CIFAR-10, ImageNet with ResNet-50, BERT, and even GPT-style language models. They compared Linear Decay against Step Decay, One-Over-Root-T, and of course, the reigning champion, Cosine Annealing. Norris: And let me guess, since we are doing a podcast about it: it didn't crash and burn? Linda: It didn't just survive; it thrived. On ImageNet, Linear Decay matched the performance of Cosine Annealing almost exactly. But here is the kicker: on the Large Language Models and some of the transformer tasks, Linear Decay actually *outperformed* Cosine. Norris: Outperformed Cosine on LLMs? That is... significant. Everyone uses Cosine for LLMs. It’s practically a law of physics at this point. Linda: Not anymore. The paper suggests that Cosine spends too much time at high learning rates and then drops off a cliff at the end. Linear provides a steady, consistent pressure to converge. It handles the noise better throughout the entire training run. Norris: And it has fewer hyperparameters, doesn't it? With Cosine, you sometimes have to worry about the period, or minimum learning rates, or restarts. Linda: Exactly. Linear has zero shape parameters. You pick your max learning rate—which you have to do anyway—and you pick your total steps T. That’s it. The slope is determined for you. Norris: I have to admit, the elegance is appealing. It reminds me of Occam’s Razor. If a straight line works as well as a fancy wave, why are we surfing the wave? Linda: Because the wave looks cooler in the TensorBoard plots? But honestly, I think it’s just inertia. We found something that worked, and we stopped asking why. This paper is asking why, and finding out that the simplest answer was right under our noses. Norris: So, Linear takes the crown. The King is dead, long live the Line. But wait... you mentioned 'Further Refinements' in the title. A straight line is hard to refine. It’s just... straight. Linda: That’s where things get really wild. Linear is the optimal schedule for the *worst case*. But what if we don't want to optimize for the worst case? What if we want to optimize for the *specific* problem we are solving right now? Norris: Problem-adaptive schedules? Now you have my attention. How do they do that without seeing the future? Linda: Well... in a way, they do see the future. ## Refining the Schedule Norris: See the future? Linda, please tell me we aren't moving from rigorous convex optimization to crystal balls and tarot cards. Linda: Not quite, Professor. But think about how we usually train models in the real world. Especially in production. We don't just train a model once and delete the code. We train it, get new data next week, and train it again. Or we train a smaller version first to test hyperparameters. Norris: True. Retraining is the bane of my existence. I feel like I'm always retraining the same ResNet on slightly different data. Linda: Exactly. And that repetition is the key. The authors propose a method called 'Refinement'. The idea is simple: run your training once with a safe, baseline schedule—like that linear decay we just praised. Norris: Okay, so I do a pilot run. I have my loss curve, my gradients, all the logs. Linda: Right. You take those logs, specifically the sequence of gradient norms—how big the updates were at every step. Then, you plug those numbers into a formula they derived from their theoretical bound. Norris: A formula that tells me... the perfect learning rate for next time? Linda: Precisely. The math says that the optimal weight for the learning rate at any given step should be proportional to the inverse of the gradient norm squared. Norris: Inverse... gradient norm... squared. Let me do the mental math. If my gradient is huge—which usually means I'm totally lost in the loss landscape—the inverse is tiny. So my learning rate should be... near zero? Linda: Yes. And when do you usually see the biggest, wildest gradients? Norris: At the very beginning of training. When the weights are random and the model is screaming in confusion. Linda: Exactly. So the theory says: start with a tiny learning rate. Then, as the gradients stabilize and get smaller, the inverse gets bigger, so your learning rate ramps up. And finally, as you converge, you decay. Norris: Wait a minute. Start small, ramp up, then decay? Linda, that's just... that's warm-up! Linda: It is! But here's the thing: usually, warm-up is a heuristic. Someone, probably training a Transformer five years ago, noticed their gradients were exploding, so they hacked in a linear ramp-up to stop the NaN errors. It was a band-aid. Norris: A very effective band-aid. But you're telling me it wasn't just a hack? It was... inevitable? Linda: It was theoretically optimal all along. The authors show that 'warm-up' emerges naturally from the math of minimizing the last-iterate error. You don't pick a warm-up period; the data picks it for you based on when your gradients stop being crazy. Norris: That is... satisfying. Deeply satisfying. It’s like finding out that your grandma’s chicken soup actually contains a proven antiviral compound. It’s not just folk wisdom; it’s science. Linda: Exactly. And the resulting schedule isn't a straight line anymore. It’s a curve that adapts to the specific 'geometry' of your problem. If your model struggles to learn early on, the Refined schedule will give it a longer warm-up. If it learns quickly, it ramps up fast. Norris: So, practical question: do I actually have to run everything twice? That sounds expensive. Linda: Ideally, yes. But think about it—how many times do you sweep hyperparameters anyway? The paper suggests you can use the gradient profile from a smaller run or a previous week's training to generate the schedule for the big production run. Norris: That makes sense. So instead of guessing '5,000 steps of warm-up' because a paper from Google said so, I look at my own gradients. Linda: Right. And for adaptive optimizers like Adam, they suggest a slight tweak—weighting by the inverse of the L1 norm instead of the squared L2 norm—but the principle is the same. The data dictates the schedule. Norris: The data dictates the schedule. I like that. It removes the 'black magic' of tuning. Although, I imagine there are edge cases. What if my gradients just... vanish? Linda: Ah, yes. The 'Refinement' can be a double-edged sword. If you overfit—like getting zero training error on CIFAR-10—your gradients go to zero. The inverse of zero is... Norris: Infinity. And an infinite learning rate sounds like a great way to explode your computer. Linda: Exactly. So for problems that overfit perfectly, the Refined schedule can become unstable at the very end. In those cases, the authors say: just stick to the Linear Decay. It’s safer. But for hard problems—like LLMs or ImageNet—where you never hit zero loss, Refinement is robust. ## The Verdict and The Future Norris: So, Linda, we have covered a lot of ground today. We killed the Cosine schedule, resurrected Linear Decay from the optimization graveyard, and even mathematically derived warm-up using past gradients. But I need the bottom line. I have a grant proposal due next week involving a large language model. Do I actually switch? Linda: If you are training an LLM? Absolutely. The results in the paper were clearest on the language modeling tasks. From small 117 million parameter models all the way up to 3.5 billion parameters, the Linear Decay schedule consistently beat Cosine. Norris: That is hard to ignore. In deep learning, usually 'better' means '0.1 percent better on a good seed'. But consistent wins across model sizes? That suggests something fundamental is happening. Linda: Exactly. And for computer vision—things like ImageNet or CIFAR—Linear Decay essentially ties with Cosine. It’s statistically indistinguishable in most cases. So even there, you aren't losing anything by simplifying your code. Norris: Simplicity is its own reward. I’d rather explain 'I drew a line' to a reviewer than 'I used a cosine schedule with a 5-epoch warm-up and a minimum learning rate of 1e-6'. Linda: And if you have the compute budget to do a pilot run—or if you are retraining a model periodically like we discussed—the Refined schedule is the cherry on top. It squeezed out even more performance in their experiments, beating both Linear and Cosine on the majority of tasks. Norris: So the hierarchy is: Cosine is the old king, slightly senile. Linear is the new, efficient manager. And Refined is the high-maintenance genius who needs a lot of data but delivers the best results. Linda: That is... a surprisingly accurate metaphor, Professor. The authors essentially say: if you want a 'set it and forget it' schedule, use Linear. If you want the absolute best performance and have the logs, use Refinement. Norris: I can live with that. It feels like we are finally moving away from 'alchemy' and towards 'chemistry'. We aren't just throwing newts' eyes and frog toes into the cauldron anymore; we are measuring the reaction rates. Linda: It’s a win for theory, for sure. It turns out the theorists were right all along—they just needed to look at the last iterate instead of the average. Norris: Well, consider me converted. I’m going to go update my lecture slides. 'One over root t' is out. 'One minus t over T' is in. Linda: Just don't forget the warm-up if your gradients are exploding, Professor! Norris: Only if the Refinement formula tells me to, Linda! Only if the math demands it. That’s all for this week's episode of Mechanical Dreams. Thank you for listening. Linda: Keep your gradients bounded, everyone! Norris: And your schedules linear. See you next time.