M3-041M3: Deep Learning FoundationsLearning Rate SchedulesEasy
⚡Flashcard Drill➔Mastery:
Comparing Learning Rate Schedules: Cosine, Step, Linear, and WSD
📐 Mathematical Definition
⚡ One-Sentence Core Answer
Step drops abruptly; Cosine decays smoothly to near-zero; Linear is simple and predictable; WSD maintains a long stable exploration plateau before rapid annealing.
📌 Key Takeaways
- •Step Decay: drops by factor (e.g., 0.1) at fixed epochs; effective in CNNs, causes sharp validation jumps
- •Cosine Annealing: smooth transition following half-period cosine; standard in modern vision and fixed-budget pre-training
- •WSD (Warmup-Stable-Decay): stable exploration plateau allows arbitrary training extensions before a short 10% decay phase
📐 Mathematical Derivations
Mathematical Formulations:
① Cosine Annealing (Loshchilov & Hutter, 2016):
.
Smoothly reduces learning rate to , allowing parameters to settle gently into local minima.
② Linear Decay:
. Standard in BERT and early NLP fine-tuning.
③ WSD (Warmup-Stable-Decay, MiniCPM / Hu et al., 2024):
- Warmup (): Linear increase to .
- Stable (): Constant exploring loss basins.
- Decay (): Rapid decay (cosine or 1-sqrt) over final 10–20% of steps to condense representations.
Key Advantage of WSD: Cosine requires pre-committing to total step count . If you stop early, did not decay; if you extend, you cannot cleanly resume. WSD allows continuing training indefinitely during the stable phase.
① Cosine Annealing (Loshchilov & Hutter, 2016):
.
Smoothly reduces learning rate to , allowing parameters to settle gently into local minima.
② Linear Decay:
. Standard in BERT and early NLP fine-tuning.
③ WSD (Warmup-Stable-Decay, MiniCPM / Hu et al., 2024):
- Warmup (): Linear increase to .
- Stable (): Constant exploring loss basins.
- Decay (): Rapid decay (cosine or 1-sqrt) over final 10–20% of steps to condense representations.
Key Advantage of WSD: Cosine requires pre-committing to total step count . If you stop early, did not decay; if you extend, you cannot cleanly resume. WSD allows continuing training indefinitely during the stable phase.
🏭 Production Trade-offs
Schedule selection: For fixed-budget competitive benchmarks, Cosine is standard. For multi-stage foundational LLM pretraining where compute budget may scale dynamically, WSD is rapidly becoming the industry gold standard.
⚠️ Common Interview Pitfalls
- ✕Changing the total step count midway through Cosine Annealing without recomputing the schedule, causing sudden discontinuous learning rate jumps
- ✕Using Step Decay without verifying whether loss plateaus align with the manual step boundaries
🎯 Interviewer Follow-up Inquiries
- ?Why is Cosine Annealing unsuitable for continuous or open-ended pretraining runs?
- ?What empirical evidence demonstrates that 90% of WSD compute can be spent in the stable phase?
⚡
Test muscle memory on this topic via 3-Layer Flashcards
Active Recall: Mentally formulate Prompt ➔ Math Derivation ➔ Benchmark Implementation in 3 minutes.
📚
Associated Knowledge Base Guides & Mindmaps
Explore the comprehensive technical article, exam cards, and global architecture tree.
中文速览与面试要点
比较 cosine、step、linear、WSD 调度
cosine 平滑衰减到 0、step 分段下降、linear 线性衰减、WSD 先稳定后快速衰减;LLM 主流是 cosine 或 WSD。
核心要点
- 数学机理: step decay 在预设 epoch 处把 lr 乘以 γ(如每 30 epoch ×0.1);优点是简单,缺点是下降点与幅度需手工设定、且在下降点处 loss 会突变。 linear decay 从 η₀ 线性降到 η_min,衰减平稳但末端下降过快、可能过早'冻结'优化。 cosine 用余弦曲线从 η₀ 平滑降到 η_min:前期下降慢(保持探索)、中后期加速下降(精细收敛)、末端变化率趋于 0(平稳收敛);其'末端导数趋零'的性质使训练后期非常稳定,是 CV/NLP 的通用默认。 WSD(Warmup-Stable-Decay) 把训练分成三段:warmup(升)、stable(恒定 η₀,占大部分步数)、decay(快速降到接近 0,占约 10%~20%)。其理论依据来自'学习率与损失的关系'研究(如 WSD 论文与 μP 系列):在 stable 段模型持续在'高 lr 的高损失平台'上探索,最终质量主要由 最后一段快速衰减 决定——衰减把参数从'探索状态'精炼到'收敛状态'。
- 深度剖析与工程权衡:① WSD 的工程优势 ——stable 段可随时保存 checkpoint 并在需要时'接着衰减',无需预先确定总步数;这对算力不确定或需持续预训练的场景极有价值。cosine 必须预先知道总步数,中途改变需重算曲线。② 多阶段续训 ——WSD 让'预训练 → 继续预训练 → 退火'成为自然流程:多个 stable 段拼接,最后统一 decay;LLaMA-3 等即采用类似思路(cosine 与 WSD 的混合)。③ 末端 lr 的重要性 ——把最终 lr 降到 η₀ 的 0~10% 是'精炼'的关键;若末端 lr 仍高,模型会停在噪声较大的状态。这也是'why decay to zero'的答案。④ step decay 的现代地位 ——在 CV 中仍有使用(如每 30 epoch ×0.1),但被 cosine 大量取代;LLM 几乎不用 step。⑤ lr 与 batch 的耦合 ——调度应结合 batch size 一起设计:大 batch 需要更大 lr 与更充分的 warmup;小 batch 则噪声本身提供正则。⑥ 面试要点 ——若被问'你选哪个',给出理由链:'需随时续训 → WSD;步数确定且求稳 → cosine;简单快速原型 → step/linear'。
- cosine 平滑无突变、末端接近 0,实践效果稳定
- step 需手工设 milestone,对超参敏感
- WSD 的 stable 段可随时分支/续训,衰减段决定最终质量
常见陷阱
- 认为 cosine 一定优于其他(取决于是否需中途续训)
- 末端 lr 不降到位(最终质量受损)