Deep LearningAdvanced19 min read5 questions

Optimisers, Schedules & Regularisation That Actually Work

The practical half of deep learning: how to pick an optimiser, set a learning rate, stop a run from diverging, and regularise without destroying capacity.

Covers: SGD vs Adam vs AdamW, learning rate schedules, warmup, gradient clipping, dropout, label smoothing, mixed precision

Architecture questions get the attention, but training questions decide the hire. Anyone can describe a transformer; far fewer can explain why their loss spiked at step 3,000, why AdamW exists, or what warmup is actually fixing.

Filter
0/5 mastered
AdvancedoptimizersadamadamwAsked at OpenAI, Meta AI

30-second answer

SGD+momentum uses one global learning rate and an EMA of gradients; it generalises well but needs careful tuning. Adam adds per-parameter adaptive scaling by an EMA of squared gradients, which handles badly-scaled and sparse gradients and converges fast. AdamW exists because adding L2 to the loss under Adam gets divided by the adaptive denominator, so large-gradient parameters get *less* decay — AdamW decouples decay from the adaptive step. SGD still wins for vision CNNs where it often generalises 1-2% better.

Advancedlearning-ratewarmupcosine-scheduleAsked at OpenAI, Anthropic

30-second answer

Warmup exists because Adam's second-moment estimate is unreliable in the first few hundred steps — a small v produces enormous updates that can permanently damage an untrained network. Decay exists because a large LR is needed to escape bad regions early but prevents settling into a minimum later. The standard transformer recipe is linear warmup over 1–5% of steps to a peak, then cosine decay to about 10% of peak.

Expertdebugginginstabilitymixed-precisionAsked at OpenAI, Anthropic

30-second answer

Check in this order: (1) is it a data problem — a corrupt batch, a huge outlier, or an all-padding sequence causing a division by zero; (2) numerical overflow in fp16, especially in attention scores or normalisation; (3) gradient explosion, visible as a rising gradient norm before the spike; (4) a stale Adam second moment meeting a sudden large gradient. Fixes: clip gradients, lower β₂, switch fp16→bf16, and always keep the last few checkpoints so you can skip the offending batch.

IntermediateregularizationdropoutaugmentationAsked at Google, Meta AI

30-second answer

Data augmentation first — it adds real information rather than constraining capacity. Then early stopping (free), weight decay, dropout, label smoothing, and finally architectural reductions. For transformers specifically, dropout matters much less than for CNNs and is often set to 0 during large-scale pre-training, where data volume alone provides the regularisation.

Advancedmixed-precisionbf16fp16Asked at NVIDIA, OpenAI

30-second answer

Mixed precision runs matmuls in 16-bit for ~2× tensor-core throughput and half the activation memory, while keeping a master copy of weights and the optimiser state in fp32 for update precision. fp16 has only 5 exponent bits and overflows at 65,504, so it needs dynamic loss scaling. bf16 has 8 exponent bits — the same range as fp32 — so it never overflows and needs no loss scaling, at the cost of less mantissa precision.

Showing 5 of 5 questions for training-optimization-and-regularization.

Check your understanding

5 questions · no sign-up, nothing stored

0/5 answered
Question 1

1.AdamW differs from Adam + L2 regularisation because:

Question 2

2.Learning-rate warmup is needed primarily because:

Question 3

3.Your fp16 training NaNs but the identical run in fp32 is fine. The most likely cause is:

Question 4

4.PyTorch's inverted dropout scales activations by 1/(1−p) during TRAINING because:

Question 5

5.Training a 7B-parameter model with AdamW in mixed precision requires roughly:

Hands-on challenge

Build it — this is what you talk about in a deep-dive round.

Instrument a training run end to end

Take any small transformer or CNN and build the observability you would want on a real run.

Requirements

  • Log per-step: loss, global gradient norm, learning rate, and per-layer gradient norms every N steps.
  • Implement warmup + cosine schedule and an LR range test; report the peak LR the test suggests.
  • Deliberately induce a divergence (LR 100×, or an injected outlier batch) and show your monitor catches it before NaN.
  • Compare AdamW with and without correct no-decay parameter groups; report the difference.

Stretch goals

  • Run the same config in fp32, fp16+scaler and bf16; compare wall-clock, peak memory and final loss.
  • Implement gradient accumulation and verify numerically that it matches a true large batch.