Large-batch Optimization for Dense Visual Predictions

Zeyue Xue, Jianming Liang, Guanglu Song, Zhuofan Zong, Liang Chen, Yu Liu, Ping LuoarXiv 2022 · DOI

Training complex "dense prediction" models, such as object detectors and segmentors, with very large batch sizes has historically been a major bottleneck in computer vision. While large-batch training is a standard technique to accelerate image classification, it often leads to training instability or poor performance in detection models. This paper, presented at NeurIPS 2022, introduces the Adaptive Gradient Variance Modulator (AGVM), a plug-and-play algorithm that stabilizes these models, enabling researchers to train massive networks in minutes.

The Challenge of Dense Visual Prediction

In deep learning, scaling batch sizes is essential for speed. By processing more data in parallel across numerous GPUs, training time can be drastically reduced. For image classification (e.g., ResNet on ImageNet), optimizers like LARS and LAMB have successfully enabled large-batch training.

However, dense visual prediction tasks—like object detection and segmentation—are significantly harder to scale. Unlike classification models, these pipelines consist of multiple distinct modules: a backbone, a Feature Pyramid Network (FPN), and specialized "heads." The authors identified that increasing batch sizes causes these modules to diverge due to gradient variance misalignment. For instance, the backbone might exhibit high variance while the detection heads show very low variance, leading to training instability and frequent "NaN" errors.

Gradient variance misalignment across modules and performance comparison across different batch sizes.

Adaptive Gradient Variance Modulator (AGVM)

The core contribution is AGVM, an algorithm designed to align gradient variances across a network's modules.

  1. Variance Estimation: AGVM employs a low-overhead method to estimate gradient variance by splitting a mini-batch into two groups and calculating the cosine similarity between their gradients.
  2. Anchor Strategy: It treats the network's backbone as an "anchor," as it is the most sensitive component.
  3. Adaptive Scaling: A scaling factor ($\mu$) is calculated for every other module (FPN, RPN, heads) based on the ratio of their variance to the backbone's. If a module's variance is too low, AGVM boosts its learning rate to restore alignment.
  4. Momentum Smoothing: Scaling factors are updated using a momentum-based moving average to ensure smooth training.

AGVM is highly efficient, adding only about 0.12% computational overhead per iteration, and can be integrated with standard optimizers like SGD or AdamW.

Comparison of AGVM with existing large-batch optimization methods.

Key Insights and Results

The authors found that in detection pipelines, "heads" often process many more samples (e.g., region proposals) than the backbone, effectively giving them a larger "internal" batch size and lower gradient variance. By forcing these modules to match the backbone's dynamics, AGVM achieves unprecedented stability.

Performance Highlights:

  • Extreme Scaling: AGVM remains stable even at a batch size of 10,000, whereas previous methods like LARS or LAMB often fail beyond 1,000.
  • Record Speed: A Faster R-CNN with ResNet50 was trained in just 4 minutes on 768 GPUs without accuracy loss.
  • Billion-Parameter Scale: The authors trained UniNet (1B parameters) in only 3.5 hours, achieving a 20.9× speedup and a state-of-the-art 62.2 mAP on COCO.
  • Versatility: Improvements were observed across various architectures (CNNs and Transformers) and tasks (Detection, Panoptic/Instance/Semantic Segmentation).

Limitations and Future Work

While AGVM is powerful, it requires users to manually define network "modules," which might be less intuitive for highly integrated architectures. Additionally, while the paper provides a convergence proof, it simplifies certain aspects like weight decay. Future research could extend the theory to more complex regularization techniques. Finally, the authors acknowledge that while faster training accelerates research, it also lowers the barrier for creating potentially harmful models.

Summary updated

BibTeX
@misc{xue2022large,
  author = {Zeyue Xue and Jianming Liang and Guanglu Song and Zhuofan Zong and Liang Chen and Yu Liu and Ping Luo},
  title = {{Large-batch Optimization for Dense Visual Predictions}},
  year = {2022},
  eprint = {2210.11078},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2210.11078},
}
Figure