Excluding the weights and gradients themselves, how much optimiser-state memory per parameter (in fp32) do plain SGD, SGD with momentum and Adam require, and why can SGD with momentum still beat Adam on test accuracy in image classification benchmarks?
Deep learning, Optimisers
Level L4 Advanced. Length Medium. Nature Th+Mat Both.
What's being asked
Whether you know the memory overhead of adaptive optimisers and the empirical generalisation gap between Adam and SGD with momentum.
Key idea
In fp32 ( bytes per scalar), plain SGD needs bytes of optimiser state per parameter, SGD with momentum needs bytes (one momentum buffer ), and Adam needs bytes (two moment buffers and ). Adam’s coordinate-wise scaling can converge to solutions with worse generalisation on overparameterised vision models unless carefully regularised.
Steps
- Memory per parameter (fp32, excluding weights and gradients): plain SGD keeps no state ( floats, bytes); SGD with momentum stores ( float, bytes); Adam stores and ( floats, bytes). For a -parameter model, Adam’s optimiser states alone take (often kept in fp32 even during mixed-precision fp16 training).
- Generalisation gap: in overparameterised linear and neural models, plain SGD updates stay in the span of the data gradients and converge towards minimum--norm / max-margin solutions.
- Why Adam can generalise worse: Adam rescales each coordinate by , giving small-gradient (potentially noisy or spurious) directions relatively larger steps, which resembles an -like bias that can overfit before well-tuned SGD with momentum and cosine decay.
- Practical remedy: use AdamW (decoupled weight decay) with learning-rate schedules—and in Transformers, AdamW outperforms SGD because attention and embedding blocks have wildly different gradient scales across coordinates.
Common mistakes
- Counting only one buffer for Adam; it keeps both and in fp32, so it needs bytes per parameter, not .
- Claiming Adam always generalises worse than SGD; on Transformers and RL, SGD often struggles to train at all without AdamW.
How long your answer should be
About half a page (5–6 sentences covering byte counts and the generalisation difference); 2–3 minutes.
Read this
Previous in Deep learning: What is orthogonal weight initialisation, why does it preserve both forward activation norms and backward gradient norms exactly in a deep linear network with , and what gain factor should scale it when used with ReLU?
Next in Deep learning: Why is standard test-time weight scaling in dropout only an exact ensemble average for a single linear layer, and how does Monte Carlo (MC) dropout use dropout at inference time to estimate predictive uncertainty?