Learning Rate Decay › Decay Scheduling in Practice

Michael BrenndoerferJanuary 24, 20265 min read
Language AI HandbookAll chapters
Part 32 of 67Training Optimization
Chapter 232Learning Rate Decay › Decay Scheduling in Practice
Reading section 7 of 15 · Decay Scheduling in Practice · 5 minSection 7 of 15 · 5 min

Book contents

Section 7 of 15 · 5 min read

Learning Rate Decay › Decay Scheduling in PracticeOne section · Sections in this chapter7 / 15 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

The main schedules covered above can be augmented with additional techniques for practical training pipelines. This section covers the remaining standard variants, discusses how to compose multiple schedules, and addresses practical choices that come up repeatedly.

Linear Decay

Linear decay reduces the learning rate in equal steps across training:

ηt=η0⋅(1−tT)\eta_t = \eta_0 \cdot \left(1 - \frac{t}{T}\right)

where TT is the total number of training steps. Linear decay is easy to understand and widely used in language model fine-tuning. Many Hugging Face training scripts use linear warmup followed by linear decay as their default schedule.

The key property of linear decay is predictability: the learning rate at any step is a straightforward linear interpolation between the starting and ending values. This makes it easy to reason about training progress. If you are at 50% of total steps, the learning rate is exactly 50% of the initial value. If you extend or shorten training, you can immediately compute the new schedule without any complex parameter relationships.

Linear decay is also well-matched to fine-tuning pre-trained models. In fine-tuning, the goal is to adapt the model to a new task while preserving the general knowledge from pre-training. The learning rate needs to start small enough to not disrupt pre-trained weights too violently, and then decrease further to ensure precise convergence. A linear schedule that starts at a modest learning rate like 2×10−52 \times 10^{-5} and decreases to zero over, say, three epochs is exactly this kind of gentle, predictable refinement.

Polynomial Decay

Polynomial decay generalizes both linear and inverse square root decay:

ηt=(η0−ηend)⋅(1−tT)p+ηend\eta_t = \left(\eta_0 - \eta_{\text{end}}\right) \cdot \left(1 - \frac{t}{T}\right)^p + \eta_{\text{end}}

where pp is the polynomial power and ηend\eta_{\text{end}} is the final learning rate. Setting p=1p = 1 gives linear decay. Setting p=0.5p = 0.5 gives a schedule that drops quickly initially and then slows, resembling inverse square root. Setting p=2p = 2 gives a quadratic curve that drops slowly at first and quickly near the end, the opposite behavior.

The power pp is rarely tuned in practice because linear and cosine are simpler and well-understood. Polynomial decay appears in some large-scale training recipes where precise control over the decay shape is desired. The key insight is that the exponent pp controls the skew of the decay: smaller pp means more reduction happens early, larger pp means more reduction happens late.

The Floor Matters

Every schedule should have a non-zero minimum learning rate. Without a floor, exponential or inverse square root schedules approach zero asymptotically. At very small learning rates, training effectively stops: gradients are multiplied by a negligible factor and weights barely move. A floor of 10−510^{-5} or 10−610^{-6} ensures that training continues to make at least some progress.

The floor is especially important for schedules used in fine-tuning over many epochs. If you accidentally set γ\gamma too aggressively for an exponential schedule, the learning rate could reach the floor very early in training, wasting compute on steps where the parameters barely change. Monitor the learning rate reached during training as well as the schedule configuration.

Composing Warmup with Decay

Most modern training pipelines compose a warmup phase with one of the main decay schedules. The warmup brings the learning rate from zero to its peak value over the first few hundred or thousand steps, and then one of the decay schedules takes it from the peak down to the floor.

The transition from warmup to decay is handled differently depending on the framework. In some implementations, warmup and decay are separate schedule objects that are chained together. In PyTorch's get_cosine_schedule_with_warmup from the Hugging Face transformers library, the two phases are unified into a single function that changes behavior at the warmup boundary.

In[12]:
Code
def linear_warmup_then_decay(
    t, eta_max, warmup_steps, total_steps, decay="linear", eta_end=0.0
):
    if t < warmup_steps:
        return eta_max * t / warmup_steps
    progress = (t - warmup_steps) / max(total_steps - warmup_steps, 1)
    if decay == "linear":
        return eta_end + (eta_max - eta_end) * max(0.0, 1 - progress)
    elif decay == "cosine":
        return eta_end + 0.5 * (eta_max - eta_end) * (
            1 + np.cos(np.pi * progress)
        )
    return eta_max


total_steps = 1000
warmup = 100
steps_fine = np.arange(0, total_steps + 1)
linear_schedule = [
    linear_warmup_then_decay(
        t,
        eta_max=0.001,
        warmup_steps=warmup,
        total_steps=total_steps,
        decay="linear",
    )
    for t in steps_fine
]
cosine_schedule_fine = [
    linear_warmup_then_decay(
        t,
        eta_max=0.001,
        warmup_steps=warmup,
        total_steps=total_steps,
        decay="cosine",
    )
    for t in steps_fine
]
Out[13]:
Visualization
Two overlapping line plots showing learning rate for linear and cosine decay after warmup over 1000 steps.
Linear warmup combined with linear decay vs. cosine decay, both over 1,000 steps with 100 warmup steps. The shaded gray region shows the warmup phase where the learning rate rises to its peak. After warmup, cosine decay falls more gradually initially and more steeply near the end, while linear decay decreases at a constant rate.

The two schedules look similar during the main decay phase, but cosine decay is slightly more gradual at the start of decay and slightly steeper near the end. In practice, the difference between them is often smaller than the impact of the peak learning rate or warmup length.