Surge Phenomenon in Optimal Learning Rate and Batch Size Scaling

In current deep learning tasks, Adam style optimizers such as Adam, Adagrad, RMSProp, Adafactor, and Lion have been widely used as alternatives to SGD style optimizers. These optimizers typically update model parameters using the sign of gradients, resulting in more stable convergence curves. The learning rate and the batch size are the most critical hyperparameters for optimizers, which require careful tuning to enable effective convergence. Previous research has shown that the optimal learning rate increases linearly or follows similar rules with batch size for SGD style optimizers. However, this conclusion is not applicable to Adam style optimizers. In this paper, we elucidate the connection between optimal learning rates and batch sizes for Adam style optimizers through both theoretical analysis and extensive experiments. First, we raise the scaling law between batch sizes and optimal learning rates in the sign of gradient case, in which we prove that the optimal learning rate first rises and then falls as the batch size increases. Moreover, the peak value of the surge will gradually move toward the larger batch size as training progresses. Second, we conducted experiments on various CV and NLP tasks and verified the correctness of the scaling law.

Paper

References (64)

Scroll for more · 38 remaining

Similar papers

Peer review

Reviewer PmLA5/10 · confidence 3/52024-07-07

Summary

The paper analyzes the intricate relationship between optimal learning rate and batch size scaling for adaptive optimizers, such as Sign SGD and Adam. Building on prior analysis for SGD by McCandlish (2018), this work reveals a non-monotonic relationship between optimal learning rates and batch size. The optimal learning rate initially increases, reaches a peak, and then decreases, eventually saturating to a non-zero value, referred to as the surge phenomenon. These theoretical predictions are validated through experiments in both image classification and NLP tasks.

Strengths

* The paper provides new insights into the relationship between optimal learning rate and batch size for Adam optimizers. The drop in the optimal learning rate after the peak is new, to the best of my knowledge, and is relevant given that Adam is the default optimizer choice. * Prior results suggesting a square root scaling for Adam are reproduced, further supporting the findings.

Weaknesses

* At times, the paper assumes that the reader is well-versed with the prior work of McCandlish (2018). For instance, lines 129-131. It would be helpful to reiterate prior results to motivate the analysis. * The empirical results are not very convincing. If we only consider the experiments (for instance Figure 4), without any reference to theoretical results, the surge phenomenon does not seem appreciable. A finer learning rate search has to be performed to demonstrate the surge phenomenon clearly. In Figure 4(b), the optimal learning rate is oscillating around two points. It is unclear if this is due to the surge phenomenon or just random fluctuations. I would request the authors to help me understand their empirical results better. * The theoretical results are derived for sign SGD, while it's known that Adam parameters beta1 and beta2 are crucial hyperparameters. It's unclear why the theoretical results can be generalized to Adam.

Questions

* What is the practical implication of the decrease in the optimal learning rate after the peak? * Given that the peak shifts through training, can the authors propose guidelines for scaling the learning rate and batch size? * What is the intuition behind the training speed and data efficiency relationship being the same as the SGD case? * Why the ResNet model (Figure 3) is trained with random 10k samples at every epoch? This should affect the overall results. Also, why this experiment is performed with sign SGD only? * If the results of Figure 2(b) and 2(c) are combined, then it should predict (1) a drop in the optimal learning rate, (2) saturation, (3) increase, and finally saturation. How does this result align with the main result (Figure 1)?

Rating

5

Confidence

3

Soundness

3

Presentation

3

Contribution

2

Limitations

* The theory is built on the quadratic approximation of the loss function. In the last few years, it has been established that modern neural networks are typically trained at large learning rates (Edge of Stability, see Refs. [1-2]), which cannot be captured using quadratic approximations of the loss [3]. * Gaussian distribution for gradients is assumed for the theoretical analysis, whereas it is known that the gradient distribution is not Gaussian, and this is precisely why Adam performs better than SGD in language modeling. It is unclear whether the results hold for such settings. [1] Gradient descent on neural networks typically occurs at the edge of stability Cohen et al. (2021) arXiv:2103.00065 [2] Adaptive gradient methods at the edge of stability Cohen et al. (2022) arXiv:2207.14484 [3] Self-stabilization: The implicit bias of gradient descent at the edge of stability Damian et al. (2022) arXiv:2209.15594 [4] Linear attention is (maybe) all you need (to understand transformer optimization) Ahn et al. (2022) arXiv:2310.01082

Reviewer ASLs6/10 · confidence 3/52024-07-12

Summary

The paper presents a heuristic analysis of the scaling of the optimal learning rate with batch size for Adam-style optimizers in the framework of [1]. The analysis is accompanied by experiments to support the predictions. Notably the authors demonstrate that the optimal learning rate can decrease with batch size in a certain range, a phenomenon that had not been identified previously and which is not present for SGD. The analysis also recovers the square-root scaling rule in the small batch size regime identified in other work. [1] McCandlish, S., Kaplan, J., Amodei, D., & Team, O. D. (2018). An empirical model of large-batch training. arXiv preprint arXiv:1812.06162.

Strengths

The paper tackles a practically important problem using a mix of heuristic theory and experiments. The prior literature on linear scaling rules with large batch training applies to SGD but not to Adam style optimizers which are the dominant optimizers for transformers. The surge phenomenon is interesting and novel.

Weaknesses

The presentation is not great. A lot is assumed from [1], but it would make reading easier to make things more self-contained. Equations like Eq. 22 should be better explained and plots like in Fig 3 are hard to parse. The process for making the Fig. 3 plot is unclear. It is unclear what is going on in Figure 1 between the solid and dashed Adam curves. The takeaways and consequences for a practitioner are unclear. Minor: the Latex parentheses look sloppy. [1] McCandlish, S., Kaplan, J., Amodei, D., & Team, O. D. (2018). An empirical model of large-batch training. arXiv preprint arXiv:1812.06162.

Questions

My questions are related to the perceived weaknesses 1. In Fig. 1 how is the solid Adam curve generated? Shouldn't the curve eventually asymptote? It doesn't seem like that from the plot. 2. How is Fig. 3 generated? The linear fits look very strange. 3. Do the results suggest using any modification of the square root scaling rule in practice? If so it would be helpful to have a comparison to understand potential benefit. 4. Is there any characterization of the **intermediate** (i.e. large but not infinite batch) behavior of the scaling? It would be helpful to have an analog of Figure 1 for the empirical data.

Rating

6

Confidence

3

Soundness

3

Presentation

1

Contribution

2

Limitations

Yes.

Reviewer JT4e6/10 · confidence 3/52024-07-12

Summary

The paper gives an optimal choice of learning rate and batch size for neural networks. Different from the previous results on SGD-style optimizers. The authors give such solutions for Adam-style-optimizers.

Strengths

1. Batch size and learning rate will affect the performance largely and cost a lot to select a good one. It is important to understand the optimal batch size and learning rate for Adam-style optimizers. 2. The experimental results match the theorem proposed by the authors.

Weaknesses

1. It seems that Lemma 1 can only apply to quadratic problems. In the appendix, the relation is approximately equal. But in Lemma 1, it becomes "equal" without any further assumptions. 2. It is unclear how to select the optimal batch size or learning rate based on the theorem because either S, E or $\mu,\sigma$ is hard to estimate for a large network.

Questions

1. Why does the theorem apply to general network optimization? 2. How to make the result of the theorem in use?

Rating

6

Confidence

3

Soundness

3

Presentation

2

Contribution

2

Limitations

N/A

Authorsrebuttal2024-08-13

Dear Reviewer JT4e, We would like to express our sincere gratitude for your valuable feedback and for increasing the score of our paper. Your insightful comments and suggestions have greatly improved the quality of our work. We will ensure to incorporate these suggestions into the final manuscript, and we truly appreciate the time and effort you have put into reviewing our submission.

Reviewer ytaJ7/10 · confidence 3/52024-07-13

Summary

This work provides a scaling law between learning rate and batch size for Adam. Namely, this work finds that the optimal learning rate increases and then decreases as the batch size becomes larger; and, the peak of this curve corresponds to the trade-off between training speed and data efficiency.

Strengths

- The paper is well motivated. While prior works studying the relationship between batch size and learning rate have focused on SGD, this work focuses on Adam (which is more popular / widely used). - The paper is written clearly and is well organized. I appreciate the “summary” notes included by the authors - The paper includes empirical evidence for CV and NLP tasks to support theoretical claims.

Weaknesses

- I think this paper could benefit from experiments with more popular architectures for the NLP tasks (e.g. maybe it would be useful to include some experiments on tasks with llama or mistral models). - I also think it would be useful to have experiments with more datasets. Recent work shows that the data itself matters. E.g., for fine tuning LLMs, many factors wrt the data (e.g., data quality, variable sequence lengths, deduplicated data) can affect training. It would be interesting to see if the surge phenomena is agnostic to these factors or not.

Questions

For NLP related tasks, the number of tokens in a batch might vary. Would the surge phenomena still apply for learning rate vs. num tokens?

Rating

7

Confidence

3

Soundness

3

Presentation

3

Contribution

3

Limitations

It would be interesting to see results on a larger variety of modern and widely used datasets and architectures.

Reviewer PmLA2024-08-11

I thank the authors for their extensive rebuttal. I have gone through the rebuttal plots and I still don't find the empirical results regarding the surge phenomena convincing. For instance, Figure 2 of the rebuttal does not look similar to the claimed curve from Figure 1. I would request the reviewers to further help me understand the difference.

Authorsrebuttal2024-08-12

Thank you for your time and feedback. The surge phenomenon refers to the behavior where the optimal learning rate increases with an increase in batch size, then decreases, and finally increases slowly. This is illustrated by the orange solid line in Figure 1 of the original paper: rising from 0 to 0.4e8, falling from 0.4e8 to 1.5e8, and rising again from 1.5e8 to 4e8. Supplementary Material Figure 2 provides a finer grid search in the batch size range of 80-120 and learning rate range of 0.002-0.004, expanding Figure 4(b) from the original paper. This highlights that the observed phenomenon of decreasing and then increasing within the batch size range of 80-120 in Figure 4(b) is not due to randomness. From a broader perspective in Figure 4(b), as the batch size increases, the optimal learning rate first increases from 0 to 65.8, then decreases from 65.8 to 105, and finally slowly increases from 105 to 120, displaying a similar trend to Figure 1 in the original paper. Although the specific **batch size** ranges for each phase may vary with different models and datasets, the general trend described by the surge phenomenon is consistent across these scenarios.

Reviewer PmLA2024-08-12

I thank the authors for the clarification. The rebuttal result is clear to me now. I am currently keeping my score but I may increase it later. Again, I would like to thank the authors for their time and effort.

Authorsrebuttal2024-08-12

Dear Reviewer PmLA, We sincerely appreciate your valuable comments and the time and effort you invested in reviewing our paper. We will ensure to incorporate these suggestions into the final manuscript. Thank you very much for considering raising the score! Should there be any further points that require clarification or improvement, please know that we are fully committed to addressing them promptly.

Authorsrebuttal2024-08-14

Dear Reviewer PmLA, Thank you for increasing the score. If you have any other comments in the future, we would be delighted to provide further clarification and revisions as needed.

Reviewer JT4e2024-08-12

Can you provide some experimental results showing that A2 is possible because the current results are based on grid-search on all hyperparameters?

Authorsrebuttal2024-08-12

We appreciate your questions. To demonstrate the feasibility of A2, we follow the procedure outlined in A2 to determine the optimal learning rates relative to batch sizes, using the MoE experiment as an example (the data used below are from Fig. 1 in the supplementary file). --- **Step 1 Approximate $\epsilon_{opt}$ using a small amount of data** To demonstrate the generalizability of A2, here we try 3 starting points to derive the scaling laws separately. For each of the 3 different batch sizes (3145728, 4718592, 6291456), we search 5 (learning rate, training loss) pairs to fit $\epsilon_{opt}$, in which, the training loss uses $normalized(L) = \frac{L - L_{min}}{L_{max} - L_{min}}$ . | | BS-1 | BS-2 | BS-3 | |:--------------:|:---------------------:|:-------:|:-------:| | Token BS | 3145728 | 4718592 | 6291456 | | LR (1e-4) | $normalized(L)$ | | | | 1.0 | 1.0000 | 1.0000 | 1.0000 | | 2.0 | 0.4837 | 0.5134 | 0.5558 | | 3.0 | 0.1786 | 0.2144 | 0.2269 | | 4.0 | 0.0000 | 0.0000 | 0.0269 | | 5.0 | 0.0828 | 0.0186 | 0.0000 | | A | 0.0946 | 0.0782 | 0.0688 | | -B | 0.7995 | 0.7168 | 0.6658 | | $\epsilon_{opt}=-\frac{B}{2A}$ | **4.2257** | **4.5831** | **4.8387** | --- **Step 2 Approximate $\epsilon_{max}$ using a pair of (B, $\epsilon_{opt}$)** Following the referenced papers [2] and using their scaling law $B_{crit}=\frac{B^*}{L^{1/\alpha}}$, we can get $B_{crit} \approx 10^7$. We then use one pair of (B, $\epsilon_{opt}$) to approximate $\epsilon_{max}$, and the results are shown below. The last column is the actual result from grid search for comparison. | | BS-1 | BS-2 | BS-3 | AdEx 1 | |:-------------:|:-------:|:-------:|:-------:|:------:| | Token BS | 3145728 | 4718592 | 6291456 | | | $\epsilon_{opt}$ (1e-4) | 4.2257 | 4.5831 | 4.8387 | | | $\epsilon_{max}$ (1e-4) | **4.9374** | **4.9001** | **4.9628** | 4.9363 | --- **Step 3 Use the fitted values to predict the best learning rates $\epsilon_{opt}$ for different batch sizes** Using ($B_{crit}$, $\epsilon_{max}$) from Step 2, we can predict the optimal learning rate $\epsilon_{opt}$ for different batch sizes with the formula $\epsilon_{opt}=\frac{\epsilon_{max}}{\frac{1}{2}(\sqrt{\frac{\mathcal B_{noise}}{B}} + \sqrt{\frac{B}{\mathcal B_{noise}}})}$ in our paper. The predicted $\epsilon_{opt}$ values and the actual values from grid search are shown below. We can see that the relationsip between the optimal learning rate and batch size derived from these 3 batch sizes all align with the actual results from the grid search. | Token BS | $\epsilon_{opt}$ (1e-4) | | | | |:--------:|:------------:|:-------:|:-------:|:-------:| | | BS-1 | BS-2 | BS-3 | AdEx 1 | | 196608 | 1.3654 | 1.3551 | 1.3724 | 1.3651 | | 294912 | 1.6561 | 1.6436 | 1.6646 | 1.6558 | | 786432 | 2.5799 | 2.5604 | 2.5931 | 2.5793 | | 1572864 | 3.3982 | 3.3724 | 3.4156 | 3.3974 | | 3145728 | 4.2257 | 4.1937 | 4.2474 | 4.2247 | | 4718592 | 4.6180 | 4.5831 | 4.6417 | 4.6170 | | 6291456 | 4.8140 | 4.7776 | 4.8387 | 4.8129 | | 9437184 | 4.9361 | 4.8988 | 4.9614 | 4.9350 | | 12582912 | 4.9018 | 4.8647 | 4.9269 | 4.9007 | Therefore, by starting with one batch size and its corresponding five learning rate results, we can approximate the scaling law between optimal learning rates and batch sizes.

Reviewer JT4e2024-08-13

Thank you for the additional experiments. I believe adding the additional experiments helps me understand better. I have increased my score.

Reviewer ytaJ2024-08-12

Thank you for your response. I acknowledge that I have read the author's response. I will keep my score.

Authorsrebuttal2024-08-13

Dear Reviewer ytaJ, We sincerely appreciate your valuable comments and the time and effort you invested in reviewing our paper. We will ensure to incorporate these suggestions into the final manuscript. We believe that these changes have significantly improved our paper. Once again, we express our sincere gratitude for your valuable contribution to our work.

Reviewer ASLs2024-08-13

Thank you for the responses and additional results. I will increase my score.

Authorsrebuttal2024-08-14

Dear Reviewer ASLs, We would like to express our gratitude for your valuable feedback and for increasing the score of our paper. Your perceptive remarks and recommendations have significantly enhanced the quality of our work, and we sincerely value the time and effort you dedicated to reviewing our submission.

Program Chairsdecision2024-09-25

Decision

Accept (poster)

© 2026 NYSGPT2525 LLC