Skip navigation
Which optimizer is best? It turns out the answer can change with batch size!
0:00 / 1:08

Which optimizer is best? It turns out the answer can change with batch size!

Xingyu Dang

@xingyudang1.6K followers

Visit on X
479 likesDownloadOriginal post

115,564 views

Which optimizer is best? It turns out the answer can change with batch size! We perform a comprehensive sweep and find the best BSZ scaling rule depends on settings and can't be derived from early theories like SDE or convex bound!

22 Comments

Comments from the original post on X (Twitter)

  • Xingyu Dang's profile picture

    @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

  • Xingyu Dang's profile picture

    @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

  • Xingyu Dang's profile picture

    @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

  • Xingyu Dang's profile picture

    @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

  • Xingyu Dang's profile picture

    @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

  • Xingyu Dang's profile picture

    @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

  • Xingyu Dang's profile picture

    @xingyudang

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

    13 likes

  • Puneesh Deora's profile picture

    @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

  • Honam Wong's profile picture

    @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

  • Xingyu Dang's profile picture

    @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

  • Honam Wong's profile picture

    @MH2023ML

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

  • Xingyu Dang's profile picture

    @xingyudang

    I think this one is quite related:

    1 like

  • Nilin's profile picture

    @nilinabra

    Anything about batch size vs momentum decay?

    3 likes

  • huduga's profile picture

    @zaph0id

    cc @ShauryaSharthak @Adi_kmt

    2 likes

  • elie's profile picture

    @eliebakouch

    good stuff!! congrats

    1 like

  • Xingyu Dang's profile picture

    @xingyudang

    Thanks :)

    2 likes

  • Crio Songo's profile picture

    @shuizhuyu

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

    1 like

  • Somil Singh | Inside AI's profile picture

    @Skywalkerlyzv

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

    1 like

  • Yang (e/acc) 🏴‍☠️'s profile picture

    @bronzeagepapi

    Precondition? @tilderesearch

  • 刘朝 Zhao Liu's profile picture

    @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.