skip to content
← Scientific Spaces English

Making Model Training More Scientific, Part 7: Step-Size Scheduling and Weight Averaging

Anyone well-versed in deep learning knows that step-size scheduling—or learning rate scheduling (LR schedule)—is crucial to a model's final performance. In previous posts, we already showed that even considering SGD alone, the optimal learning rate function for final convergence takes the form of warmup-decay, which is commonly used in practice. Recently, however, several works, such as Schedule-Free, have attempted to replace learning rate schedules with certain kinds of model weight averaging, and they have achieved some progress.

How can we theoretically analyze the connection between learning rate scheduling and weight averaging? To what extent can they substitute for each other? In this post, we will try to answer these questions.

Weight Averaging #

Regarding weight averaging, in fact, back in Making Model Training More Scientific, Part 3: Convergence of the Final Loss in SGD, we already gave a basic result

where . This result implies that as long as we choose a constant learning rate , the right-hand side can achieve the ideal convergence rate of , while the left-hand side implies that converges to . Hence, we can design the following optimizer:

where . In other words, by adding an extra step of iteration that does not interfere with the training trajectory at all, we equally average the trajectory, so that the model weights ultimately used for inference are not the final values , but the averaged values . In practice, however, this approach performs poorly, serving as one of the classic examples where theory fails to match practice.

Nevertheless, if we change to an appropriate constant independent of , such as , it often performs remarkably well in practice—this is precisely the exponential moving average (EMA) trick I frequently used in competitions. Compared with , this moving average approach leans toward averaging the most recent optimization trajectory rather than the entire history. Its strong performance also suggests that we do not need to pay attention to results from the distant past.

How to theoretically explain this moving average trick, or more generally, explain the feasibility of arbitrary weight averaging, is the core task ahead.

A Further Generalization #

In the article Making Model Training More Scientific, Part 4: A New Identity, a New Learning Rate, in order to extend the results on the average loss to the final loss, we introduced the identity

where . In this section, we generalize it once more to

Intuitively, this provides a way to transform one weighted sum into another. When and the remaining are equal to 0, it reduces to the final-point form. The proof is likewise an extension of our earlier proof. Setting , we can write

The third equality holds because directly adding the two parenthesized terms from the second equality yields 0, meaning the two terms are additive inverses of each other. Now, summing both sides over , the left-hand side equals . Moving to the right-hand side, dividing both sides by , and rearranging slightly gives the identity to be proved .

Bounding Transformations #

Next, following the ideas from the previous post, Making Model Training More Scientific, Part 6: An Ingenious Top-Down Construction, we derive more general convergence results. Let , which we substitute into Eq. to obtain

To facilitate subsequent derivations, we add the assumption:

Then we can use the convexity of to bound and , and then, carefully rearranging just like in the "Identity Transformation" section of the previous post, we obtain

where

and direct verification shows that

Therefore, if we let update according to , then the corresponding update rule for is

General Conclusion #

The next steps are relatively straightforward. Applying to the right-hand side of Eq. the conclusions of articles such as Making Model Training More Scientific, Part 5: Fine-Tuning Learning Rates Based on Gradients yields

where , with the convention that . As for the left-hand side, applying convexity gives

Putting them together gives

The minimum of the right-hand side is attained at

, which implies that the optimal learning rate has the form

Interpretation of the Results #

The final convergence result given in the previous post, Making Model Training More Scientific, Part 6: An Ingenious Top-Down Construction, is

The right-hand side is consistent with Eq. , but the learning rate becomes . From this, we can see that if the averaged weights are to achieve an effect close to that of the final weights, the learning rate needs to be multiplied by an extra ; or conversely, under the same learning rate, the effect of weight averaging is equivalent to the final effect after multiplying the learning rate by . Clearly, is less than or equal to 1 and monotonically decreasing; multiplying by this term plays a role similar to LR decay.

Let us consider some concrete examples. First is the simplest case, , which corresponds to Eq. at the beginning; here, , which is exactly linear decay. This means that "constant learning rate + equal-weight averaging" theoretically achieves an effect similar to a linearly decayed learning rate. However, empirical results often show that directly linearly decaying the learning rate yields a good final result, but the averaged weights, namely Eq. , perform poorly.

Reviewing the entire derivation, we can guess that the problem likely lies in the "convex function" assumption. This series of articles actually relies on the assumption that "the objective function is convex," but the real-world situation is often non-convex, and the conclusions of convex optimization cannot be reproduced exactly. A compromise is to assume local approximate convexity, in which case we can perform equal-weight averaging over a finite window, or directly consider its smoothed version—exponential moving average (EMA), where (where ), so

It maintains an averaging window of . Due to the memoryless property of the exponential function, if we run EMA alongside constant learning rate training, it is equivalent to simultaneously obtaining at each step the weights after steps of linear decay, allowing us to get an early glimpse of the effect of linear decay.

Related Work #

To address the issue of suboptimal performance of Eq. , the paper 《The Road Less Scheduled》 proposed "Schedule-Free", which changes the point where the gradient is evaluated to the interpolation between and :

Intuitively, the original averaging operation was completely independent of the training process, and the model never sensed whether was actually good or bad. Now, we change the point where the gradient is evaluated to the interpolation between and , so that the model can sense whether is good or bad and make adjustments accordingly. This modification is theoretically guaranteed and indeed significantly improves the performance of the averaged weights .

However, as training scales increased, Schedule-Free gradually showed signs of fatigue. The authors recently proposed ScheduleFree+, applying quite a few "patches" to the original Schedule-Free to make it SOTA once again. However, the Plus version adds relatively many additional operations, making the overall algorithm somewhat complex and considerably more difficult to understand, so we will not expand on it in detail here; we will return to discuss it later.

It is worth mentioning that the authors of Schedule-Free and its Plus version are precisely the authors of the classic paper introduced in our previous articles, 《Optimal Linear Decay Learning Rate Schedules and Further Refinements》. These works have all successfully applied classical convex optimization theory to practical training, rather than remaining mere "armchair strategizing" on toy models—they truly deserve our respect!

Further Thoughts #

What is truly worth pondering is: can the premise of Schedule-Free really hold? The so-called Schedule-Free has two goals: first, to train with a constant learning rate from start to finish, and second, to make the various hyperparameters independent of the total training steps . If these two conditions are met, then the training process can be stopped at any time or resumed at any time, and stopping at any arbitrary step yields the optimal solution up to that current step, which is indeed very ideal.

However, both of these goals are open to debate. First, for practical training, there is no fundamental difference between a constant learning rate and dynamic schedules like cosine decay or linear decay; in both cases, one simply tunes hyperparameters and compares runs to choose the best one, so pursuing a constant learning rate has little practical significance. Moreover, even Schedule-Free and its Plus version have not freed themselves from reliance on warmup, meaning that in practice they still depend to some extent on a manually crafted LR schedule.

Second, hoping that various hyperparameters do not depend on the total number of training steps is indeed a good goal, but even from a purely theoretical perspective, it is hard to establish. Taking Equation as an example, even when all assumptions are satisfied and Equation can perform well, its optimal learning rate still depends on ; similarly, Schedule-Free cannot escape this fact; it obtains the result that does not depend on by introducing new assumptions.

We can also observe this from Equation : for equal-weight averaging, we have . Further assuming that is a constant , then , which cancel each other out exactly, so the optimal learning rate is , where depends on . On the other hand, is usually large at first and small later, so according to the property that Equation is inversely proportional to , the early learning rate should be smaller. This in turn can explain the phenomenon that Schedule-Free still cannot completely get rid of schedules and still requires warmup.

To this end, ScheduleFree+ and several concurrent works have gradually shifted from thinking about "Schedule-Free" toward "LR-Free." Overall, however, this area is still in an "emerging" stage and awaits more fundamental exploration.

Summary #

In this post, we introduced a new identity to further generalize the results of the previous post, allowing us to quantitatively reveal the connection between weight averaging and learning rate decay from a theoretical perspective. In addition, we discussed issues such as why equal-weight averaging is not as effective as moving average, and why Schedule-Free still cannot completely get rid of schedules.