提出自适应批量大小调度,提升大模型训练效率与效果。
Adaptive Batch Size Schedules for Distributed Training of Language Models with Data and Model Parallelism
- 基于数据与模型并行,设计可动态调整的批量大小策略。
- 在Llama 2小模型(≤30亿参数)上显著优于固定批量和预热方案。
- 理论证明适用于Adam优化器的收敛性,适合大规模语言模型训练。
大规模模型训练中批量大小的选择至关重要,但存在效率与泛化之间的权衡:大批次提高内存利用效率,却因梯度噪声少导致泛化性能下降。当前语言模型训练常优先考虑效率,采用固定大批次或启发式预热策略,但这些方法难以适应训练动态。鉴于数据量庞大及语言模型对数据的高需求,数据并行已成为分布式训练的核心范式,支持更大批次计算梯度。然而,传统数据并行需在每个工作节点复制模型参数、梯度和优化器状态,限制了百亿参数以上模型的训练。为此,本文提出通用且理论严谨的自适应批量大小调度方法,兼容数据并行与模型并行。我们在PyTorch Fully Sharded Data Parallel上实现该方案,成功支持不同规模语言模型的预训练。实证表明,在Llama 2系列模型预训练中,尤其针对30亿参数以下的小模型,本方法优于固定批量和启发式预热策略。此外,我们建立了基于Adam优化器的自适应批量大小调度在光滑非凸目标下的理论收敛保证。
原文摘要 · Abstract (English)
An appropriate choice of batch sizes in large-scale model training is crucial, yet it involves an intrinsic yet inevitable dilemma: large-batch training improves training efficiency in terms of memory utilization, while generalization performance often deteriorates due to small amounts of gradient noise. Despite this dilemma, the common practice of choosing batch sizes in language model training often prioritizes training efficiency -- employing either constant large sizes with data parallelism or implementing batch size warmup schedules. However, such batch size schedule designs remain heuristic and often fail to adapt to training dynamics, presenting the challenge of designing adaptive batch size schedules. Given the abundance of available datasets and the data-hungry nature of language models, data parallelism has become an indispensable distributed training paradigm, enabling the use of larger batch sizes for gradient computation. However, vanilla data parallelism requires replicas of model parameters, gradients, and optimizer states at each worker, which prohibits training larger models with billions of parameters. To optimize memory usage, more advanced parallelism strategies must be employed. In this work, we propose general-purpose and theoretically principled adaptive batch size schedules compatible with data parallelism and model parallelism. We develop a practical implementation with PyTorch Fully Sharded Data Parallel, facilitating the pretraining of language models of different sizes. We empirically demonstrate that our proposed approaches outperform constant batch sizes and heuristic batch size warmup schedules in the pretraining of models in the Llama 2 family, with particular focus on smaller models with up to 3 billion parameters. We also establish theoretical convergence guarantees for such adaptive batch size schedules with Adam for general smooth nonconvex objectives.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。