TL;DR
Goyal and colleagues showed how to train an image classifier on ImageNet with very large batches of training images, 8192 per step, spread over 256 GPUs, and finish in about one hour. Their accuracy matched a baseline trained with 256 images per step. The method has two parts: scale the learning rate linearly with the batch size, and start training with a gradual warmup so the large steps do not break the early phase.
Builds on: Stochastic Gradient Descent, Data Parallelism, All-Reduce, Deep Residual Learning for Image Recognition (ResNet) · Leads to: Linear Scaling Rule, Learning Rate Warmup
Why it mattered
The paper made large-batch distributed training a standard tool. Its linear scaling rule and its warmup became default settings in many large vision and language training runs, and the rule is now taught as the first thing to try when a batch size changes. The paper also showed that the same rule transferred to detection and segmentation, using Mask R-CNN on COCO, so the gain was not limited to classification.
The practical lesson is about time. Before this work, ResNet-50 took about 29 hours on 8 GPUs at batch size 256. With batch size 8192 on 256 GPUs, the same model trained in about one hour, which made it possible to test ideas on ImageNet quickly.
The problem
Training with minibatch stochastic gradient descent updates the weights from the average gradient of a small set of examples. A larger batch gives a more accurate average gradient, and it lets many GPUs share the work, so each GPU keeps a fixed amount of computation. The catch is that a larger batch does not, by itself, give the same training result. Changing the batch size changes how the optimiser behaves, and the step size that works for one batch size may fail at another.
Before this paper, it was known informally that the learning rate should grow with the batch size, but its limits were not understood. It was also unclear how to handle the early phase of training, where the network changes quickly and a large step can make the loss spike. The paper set out to answer both questions for a batch size of 8192, which was far larger than had been tested with a matched accuracy target.
How it works
Take one update of the baseline, with batch size and learning rate . Now suppose we want to use times as many images per step, a batch of , and keep the same number of passes over the data. The method proceeds as follows.
- Split the batch across workers. With 8 GPUs per server and 32 images per GPU, one server holds a batch of 256. Using 256 GPUs gives 8192 images per step. Check: .
- Scale the learning rate. The linear scaling rule multiplies the learning rate by the same factor as the batch size. The reference learning rate is , so for 8192 it is . Check: .
- Warm up in the first epochs. An epoch is one full pass over the training images. A learning rate of 3.2 at the start is too large, because the network is still changing fast. The learning rate starts at 0.1 and rises by a fixed amount at each iteration until it reaches 3.2 after 5 epochs. Check: the rise is smooth, not a jump.
- Keep the other settings. Momentum, weight decay and the batch-normalization batch size of 32 stay fixed. The paper keeps the batch-normalization statistics computed over 32 images per GPU, so the loss being optimised does not change with the total batch size.
- Train and decay. Training runs for 90 epochs. The learning rate is divided by 10 at epochs 30, 60 and 80, as in the baseline. Check: the schedule has the same shape as the baseline, scaled only by the peak rate.
- Aggregate gradients across GPUs. Each layer's gradient is summed across all GPUs with an All-Reduce, done while the backward pass continues on the earlier layers. This keeps the communication from waiting until the end of the step.
flowchart LR A["Batch 8192 split over 256 GPUs"] --> B["Forward and backward per GPU"] B --> C["All-reduce each layer's gradient"] C --> D["Update with scaled learning rate"] D --> E["Warmup for 5 epochs, then decay"]
The diagram shows the training loop for one step. The all-reduce runs layer by layer during the backward pass, and the learning rate follows the warmup and decay schedule.
The math
The paper writes minibatch SGD with momentum and learning rate as an update on the average gradient of a minibatch of size :
Step 1 in symbols: the linear scaling rule
Take small steps of size at learning rate , and compare them with one step on the combined batch of size at learning rate . The small steps give . The large step gives .
If the gradients did not change over the steps, that is , then the two updates agree exactly when . The paper uses this as the rule: multiply the learning rate by when the batch size is multiplied by . The assumption is strong, and it fails early in training, which is why the warmup is needed.
Step 2 in symbols: the reference learning rate
For the ResNet-50 experiments the paper sets
With this gives , the baseline. With it gives .
Step 3 in symbols: the gradual warmup
The warmup raises the rate linearly from to over 5 epochs. If the rise is spread evenly over the iterations of those epochs, the rate increases by at each step. The paper does not state , but the ImageNet training set has about 1.28 million images, so one epoch of batch 8192 has about iterations, and five epochs have about 781. The rise per step is then about .
Results
The main comparison is in Table 1 of the paper, with validation error on ImageNet and ResNet-50, averaged over 5 trials:
| Setting | Batch size | Learning rate | Top-1 error (%) |
|---|---|---|---|
| Baseline (8 GPUs, one server) | 256 | 0.1 | 23.60 ± 0.12 |
| No warmup | 8192 | 3.2 | 24.84 ± 0.37 |
| Constant warmup | 8192 | 3.2 | 25.88 ± 0.56 |
| Gradual warmup | 8192 | 3.2 | 23.74 ± 0.09 |
The gradual warmup run is within 0.14 points of the baseline, about the size of the run-to-run spread the authors measured (standard deviations of 0.09 and 0.12). The constant warmup is worse than no warmup at all, because the error spikes when the rate leaves the low phase.
Figure 1 of the paper shows validation error across batch sizes from 64 to 65536. It stays flat from 64 up to 8k, then rises, and training diverges beyond 64k with the linear rule. The paper reports about 90 percent scaling efficiency from 8 to 256 GPUs, and that one pass over the ImageNet training images took about 30 seconds on 352 GPUs. The method also transferred: ResNet-50 models pre-trained with batch sizes up to 8k gave Mask R-CNN detection and segmentation results on COCO matching the small-batch baseline.
The limits are stated plainly. The paper notes that the linear rule works up to about 8k on ImageNet, that the ImageNet-5k experiment gives a similar elbow, and that more work is needed to explain why the limit sits where it does. Results are for one architecture and one dataset family, and the authors used simulated gradient accumulation for batches of 12k and above on a single server, which they checked against true distributed runs.
Reading guide
- Section 1, Introduction: the goal of 8192 images per step in one hour, and the claim that accuracy is kept. Needs Stochastic Gradient Descent and Data Parallelism.
- Section 2.1, Learning rates: the linear scaling rule and its derivation. Needs Learning Rate and Linear Scaling Rule.
- Section 2.2, Warmup: constant and gradual warmup. Needs Learning Rate Warmup.
- Section 2.3, Batch normalization: why the batch-normalization batch size must stay fixed. Needs Batch Normalization.
- Section 3, Pitfalls: weight decay, momentum correction, gradient averaging and data shuffling. Needs Momentum and L2 Regularization.
- Section 4, Communication: all-reduce and how it is overlapped with backward pass. Needs All-Reduce.
- Section 5, Results: the tables, the figures and the detection transfer. Needs Deep Residual Learning for Image Recognition (ResNet).
Check yourself
QuestionThe baseline batch size is 256 with learning rate 0.1. What learning rate does the reference rule give for a batch of 2048?Show answer
The rule is . For the factor is , so .
QuestionWhy does the paper use a warmup, when the linear rule already gives the right learning rate for a batch of 8192?Show answer
The linear rule assumes that the gradients barely change over the steps it replaces. That assumption fails early in training, when the network changes quickly. A large rate of 3.2 at the start can make the loss spike. The warmup starts at 0.1 and rises to 3.2 over 5 epochs, so the large rate is used only after the network has settled.
QuestionTable 1 gives 23.60 for the baseline and 23.74 for the gradual warmup run. Is the difference larger than the authors' measured noise?Show answer
No. The difference is points. The standard deviations are 0.12 and 0.09, so the gap is about the size of the run-to-run spread. The paper reads the two as matching.
QuestionA team wants to use batch-normalization with 8192 images per step across 256 GPUs. They compute the batch statistics over all 8192 images. What does the paper say this changes?Show answer
It changes the loss being optimised. The paper keeps the batch-normalization batch fixed at 32 images per GPU, because the batch-normalization statistics depend on the size of the group they are computed over. Computing them across all 8192 images changes the function being minimised, not only the speed.
QuestionWhy does the paper overlap the all-reduce with the backward pass, instead of waiting until all gradients are ready?Show answer
Each layer's gradient is ready at a different time in the backward pass, and the gradients of one layer do not depend on the others. Starting the all-reduce as soon as a layer's gradient is ready hides most of the communication behind computation, which is needed to reach near-linear scaling across servers.