改进专家模型负载均衡损失计算方式,提升领域专业化能力
Demons in the Detail: On Implementing Load Balancing Loss for Training Specialized Mixture-of-Expert Models
- 用全局批次计算负载均衡损失,打破微批次限制
- 在428亿参数模型上降低预训练困惑度,提升下游任务表现
- 适合大规模专家模型训练,尤其关注领域特化场景
本文重新审视混合专家(MoE)模型训练中负载均衡损失(LBL)的实现方式。现有框架通常在微批次内计算频率和损失并平均,导致每个序列内的专家分配趋于均匀,抑制了专家领域的专业化。为此,本文提出基于全局批次的LBL计算方法,通过额外通信同步各微批次的专家使用频率,在更丰富的语料层面实现负载均衡。在高达42.8B参数、400B训练令牌的MoE语言模型上实验表明,该策略显著降低预训练困惑度,并提升下游任务性能。分析显示,全局批次的LBL极大增强了专家对特定领域(如代码)的识别与分工能力。
原文摘要 · Abstract (English)
This paper revisits the implementation of $\textbf{L}$oad-$\textbf{b}$alancing $\textbf{L}$oss (LBL) when training Mixture-of-Experts (MoEs) models. Specifically, LBL for MoEs is defined as $N_E \sum_{i=1}^{N_E} f_i p_i$, where $N_E$ is the total number of experts, $f_i$ represents the frequency of expert $i$ being selected, and $p_i$ denotes the average gating score of the expert $i$. Existing MoE training frameworks usually employ the parallel training strategy so that $f_i$ and the LBL are calculated within a $\textbf{micro-batch}$ and then averaged across parallel groups. In essence, a micro-batch for training billion-scale LLMs normally contains very few sequences. So, the micro-batch LBL is almost at the sequence level, and the router is pushed to distribute the token evenly within each sequence. Under this strict constraint, even tokens from a domain-specific sequence ($\textit{e.g.}$, code) are uniformly routed to all experts, thereby inhibiting expert specialization. In this work, we propose calculating LBL using a $\textbf{global-batch}$ to loose this constraint. Because a global-batch contains much more diverse sequences than a micro-batch, which will encourage load balance at the corpus level. Specifically, we introduce an extra communication step to synchronize $f_i$ across micro-batches and then use it to calculate the LBL. Through experiments on training MoEs-based LLMs (up to $\textbf{42.8B}$ total parameters and $\textbf{400B}$ tokens), we surprisingly find that the global-batch LBL strategy yields excellent performance gains in both pre-training perplexity and downstream tasks. Our analysis reveals that the global-batch LBL also greatly improves the domain specialization of MoE experts.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。