Explain Why AdamW Decouples Weight Decay From the Gradient

Last updated: November 29, 2026

Quick Overview

A model trained with Adam plus an L2 penalty generalizes worse than the same model with SGD and weight decay. Explain why L2 and weight decay are equivalent for SGD but not for Adam, and how AdamW fixes it.

Google
Machine Learning
Machine Learning Engineer
Google
November 29, 2026
Machine Learning Engineer
Onsite
Machine Learning
Hard

0

0

0 solved


A model trained with Adam plus an L2 penalty generalizes worse than the same model with SGD and weight decay. Explain why L2 and weight decay are equivalent for SGD but not for Adam, and how AdamW fixes it.

Most Google transformer training uses AdamW or Adafactor, and regularization bugs in the optimizer are subtle and costly at scale. The interviewer is checking that you can work through optimizer update rules and connect them to which weights actually get regularized.

What the Interviewer Expects
  • Show that for SGD, adding $\frac{\lambda}{2}\lVert w\rVert^2$ to the loss equals multiplying weights by $(1-\eta\lambda)$
  • Show that in Adam the L2 gradient is divided by the adaptive denominator
  • Explain the effect: weights with large historical gradients are barely regularized
  • Write the AdamW update with decay applied directly to weights
  • Mention practical choices: which parameters to exclude, scaling decay with learning rate schedule
Key Topics to Cover
AdamW
Weight decay
L2 regularization
Adaptive optimizers
Transformer training
How to Approach This
  1. Understand the bias-variance trade-off. High training accuracy but low test accuracy signals overfitting.
  2. Choose evaluation metrics carefully based on the problem. Accuracy alone is often insufficient.
  3. Feature engineering is often more impactful than model selection.
  4. Know when to use tree-based models (tabular data) vs neural networks (unstructured data).
  5. Handle class imbalance with SMOTE, class weights, or appropriate loss functions.
Possible Follow-up Questions
  • Should biases and LayerNorm gains get weight decay?
  • How should weight decay change if you double the learning rate?
  • How does Adafactor handle this, and why does Google use it for large models?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Explore ML Interview Prep
Sample Answer
Clarify

Confirm the implementation: is the penalty added to the loss (so it flows through Adam's moment estimates) or applied as a direct weight shrink? Ask about the learning rate schedule and which paramete...

Approach

Write the update rules side by side and see where the penalty ends up....


Submit Your Answer
Markdown supported