Implement the AdamW optimizer from scratch and explain how decoupled weight decay differs from Adam.
A build-it-yourself check on modern optimizers. What matters is the moment estimates, bias correction, and the single change that counts: AdamW decouples weight decay from the gradient rather than folding it into the loss. The code follows, plus why it wins.
Updated Sep 2026 · Grounded in real GenAI, LLM, and AI/ML engineering interview loops and written to a senior-engineer editorial bar.
A build-it-yourself check on modern optimizers. What matters is the moment estimates, bias correction, and the single change that counts: AdamW decouples weight decay from the gradient rather than folding it into the loss. The code follows, plus why it wins.
Lead with where the obvious approach breaks, because that is the judgment they are screening for — most candidates jump straight to the happy path and lose the room.
Then walk the failure back through the pipeline in order, naming the one metric the customer's exec sponsor actually cares about before you propose the fix.