Which optimizer is best? It turns out the answer can change with batch size!
@xingyudang1.6K followers
115,564 views
22 Comments
Comments from the original post on X (Twitter)

@xingyudang
Play with the results in our interactive blog: change the batch size to watch optimizer rankings flip, or build your own scaling rule and see if it transfers across tasks! Blog: Paper: w/ @wen_kaiyue @SadhikaMalladi
39 likes

@xingyudang
@SadhikaMalladi We retune Adam, Lion, Muon, SOAP, and Shampoo at every batch size on modded-nanogpt track-3. We found that the optimizer ranking changes according to batch size. For example, MuonH beats ShampooH at 128K tokens per update. At 2M, ShampooH leads.
15 likes

@xingyudang
@SadhikaMalladi Shouldn't the batch size scaling rule preserve the loss and therefore the orders? We test hundreds of scaling rules, covering most previous scaling recipes. Surprisingly, the best scaling rule depends on settings!
13 likes

@xingyudang
@SadhikaMalladi To understand these phenomena, we propose the curvature-to-noise ratio (CNR). In our SignSGD toy model, higher CNR favors faster learning-rate growth with batch size, from roughly sqrt toward linear. Different directions can need different scaling rules.
15 likes

@xingyudang
@SadhikaMalladi Newton can reduce initialization error faster, but its curvature correction can amplify gradient noise. We further prove that this tradeoff can make SGD win at small batches and Newton at large ones on a noisy quadratic, even with optimal learning rates and momentum.
11 likes

@xingyudang
@SadhikaMalladi We test our theory in language model training. Surprisingly, keeping small-batch updates in the sharpest 0.001% of matrix directions, removes up to 59.5% of the local branch penalty. We can’t preserve batch size without thinking about directions!
10 likes

@xingyudang
@SadhikaMalladi Tagging folks who might be interested: @jxbz , @_arohan_ , @kellerjordan0, @aaron_defazio , @mrtnm, @ShamKakade6, @alex_damian_, @jasondeanlee, @giffmana, @vyasnikhil96, @orvieto_antonio
13 likes

@puneeshdeora
Reminds me of this work by @micahgoldblum even tho they didn't sweep for all newer ones like shampoo/soap/lion, etc.
5 likes

@MH2023ML
For the optimizer ranking in different batch size regime, can I also understand as different optimizers work well in different signal-to-noise regime, and can I imagine the one works the best in the low SNR regime would also work well in RL setting as RL is super noisy?
4 likes

@xingyudang
Dynamics in RL would be particularly interesting here. The landscape is likely closer to the lazy-training regime, which could make the curvature-to-noise ratio behavior quite different from what we see in pretraining.
4 likes

@MH2023ML
Oh why it is closer to lazy-training? Curious if there’re any papers related

@xingyudang
I think this one is quite related:
1 like

@nilinabra
Anything about batch size vs momentum decay?
3 likes

@zaph0id
cc @ShauryaSharthak @Adi_kmt
2 likes

@eliebakouch
good stuff!! congrats
1 like

@xingyudang
Thanks :)
2 likes

@shuizhuyu
Interesting that SDE/convex bounds don't capture it, still empirical at this scale.
1 like

@Skywalkerlyzv
Retuning each optimizer at every batch size matters here. Glad that detail is in the thread.
1 like

@bronzeagepapi
Precondition? @tilderesearch

@liuzhao_666
How sensitive are the ranking crossovers to the hyperparameter-search budget per optimizer? I'd love to see best loss plotted against tuning compute as well as training compute.

