Scaling Laws for Fine-Grained Mixture of Experts

Jan Ludziejewski, Jakub Krajewski, Kamil Adamczewski, Maciej Pióro, Michal Krutul, Szymon Antoniak, Kamil Ciebiera, Krystian Król, Tomasz Odrzygózdz, Piotr Sankowski, Marek Cygan, Sebastian Jaszczur · DOI

TL;DR

This paper introduces "granularity" as a new hyperparameter for Mixture of Experts (MoE) models, showing that fine-grained experts lead to more efficient scaling than previously thought. They derive new scaling laws that demonstrate MoE models consistently outperform dense Transformers, especially at larger scales, and challenge the common practice of setting expert sizes equal to feed-forward layers.

What Problem Does This Paper Address?

Large Language Models (LLMs) have achieved remarkable performance, but their training demands immense computational resources, leading to high costs and environmental impact. Mixture of Experts (MoE) models offer a promising solution by reducing computational cost through sparse activation. However, previous research suggested that the efficiency advantage of MoE models over dense Transformers might diminish at larger scales, or even disappear. This paper questions these findings by re-examining the scaling properties of MoE models, particularly by considering factors like training duration and, crucially, the internal structure of the experts themselves.

Methods

The core innovation is the introduction of a new hyperparameter: granularity (G). This parameter controls how much an expert's internal dimension is split, allowing for finer-grained experts. Instead of a single large expert, granularity enables multiple smaller experts to handle different aspects of the input. The authors then derive new scaling laws for MoE models that incorporate not only model size (N) and training tokens (D) but also this new granularity (G). These laws are used to predict optimal training configurations for a given computational budget (FLOPs). They also analyze the computational cost of MoE, including the overhead of routing, to find compute-optimal settings.

Datasets

The paper does not explicitly name specific datasets used for training. However, it mentions training on the C4 dataset (Raffel et al., 2023) for decoder-only Transformers. The experiments involve training models with varying numbers of tokens, ranging from 16B to 130B.

Key Insights and Ideas

  • Granularity is Key: The common practice of setting MoE expert sizes to match the feed-forward layer (granularity G=1) is suboptimal. Increasing granularity (splitting experts into smaller, more specialized units) leads to better performance and efficiency.
  • MoE's Enduring Advantage: Contrary to some prior claims, MoE models consistently outperform dense Transformers in efficiency, and this gap widens with increasing model size and computational budget when optimal configurations are used.
  • Beyond Fixed Training: Previous scaling laws often assumed fixed training durations. This work emphasizes the importance of variable training duration for achieving compute-optimal settings, which is crucial for MoE.
  • Optimal Expert Size: The "optimal" size of an expert is not necessarily the same as the original feed-forward layer's hidden dimension. Fine-grained experts offer significant advantages.

Key Results

  • The paper establishes new scaling laws for MoE models that incorporate granularity, allowing for the prediction of optimal training configurations.
  • They demonstrate that MoE models can achieve the same quality as dense Transformers with a significantly smaller computational budget (e.g., 20x less for 10^20 FLOPs, and over 40x less for 10^25 FLOPs).
  • For a given computational budget, higher granularity is generally optimal, especially for larger budgets. For instance, Table 2 shows optimal G values increasing with compute budget.
  • The study shows that for MoE models, the efficiency gap with dense Transformers increases as model size and training budget scale up.

Limitations and Future Work

  • Expansion Rate (E): Due to computational constraints, the study primarily focused on a fixed expansion rate (E=64), which is a common choice in prior work. The authors acknowledge that exploring a wider range of E values could reveal further insights, especially regarding memory constraints.
  • Extreme Granularity: While increasing granularity generally improves performance, extremely high granularity (e.g., G=64 with dmodel=256) can lead to performance degradation, particularly when routing overhead becomes significant. Future work could explore modifications to routing algorithms or expert initialization to mitigate this.
  • Unified Formula: The authors suggest that a unified formula incorporating N, D, G, and E could offer deeper insights but might be less practical for direct recommendation of optimal configurations due to the complex interplay of factors like memory requirements.
  • Practical Cost Modeling: The exact estimation of MoE training costs can be sensitive to hardware and implementation details. While FLOPs are used as a proxy, future work could refine cost modeling to better account for factors like communication overhead in distributed training.

Summary updated

BibTeX
@inproceedings{ludziejewski2024scaling,
  author = {Jan Ludziejewski and Jakub Krajewski and Kamil Adamczewski and Maciej Pióro and Michal Krutul and Szymon Antoniak and Kamil Ciebiera and Krystian Król and Tomasz Odrzygózdz and Piotr Sankowski and Marek Cygan and Sebastian Jaszczur},
  title = {{Scaling Laws for Fine-Grained Mixture of Experts}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=yoqdlynCRs},
}
Figure