AutoMoE: Neural Architecture Search for Efficient Sparsely Activated Transformers

Ganesh Jawahar, Subhabrata Mukherjee, Xiaodong Liu, Young Jin Kim, Muhammad Abdul-Mageed, Laks V. S. Lakshmanan, Ahmed Hassan Awadallah, Sébastien Bubeck, Jianfeng Gao

Abstract

Mixture-of-Expert (MoE) models have obtained state-of-the-art performance in Neural Machine Translation (NMT) tasks. Existing works in MoE mostly consider a homogeneous design where the same number of experts of the same size are placed uniformly throughout the network. Furthermore, existing MoE works do not consider computational constraints (e.g., FLOPs, latency) to guide their design. To this end, we develop AutoMoE -- a framework for designing heterogeneous MoE's under computational constraints. AutoMoE leverages Neural Architecture Search (NAS) to obtain efficient sparse MoE sub-transformers with 4x inference speedup (CPU) and FLOPs reduction over manually designed Transformers, with parity in BLEU score over dense Transformer and within 1 BLEU point of MoE SwitchTransformer, on aggregate over benchmark datasets for NMT. Heterogeneous search space with dense and sparsely activated Transformer modules allows for adaptive compute -- where different amounts of computations are used for different tokens in the input. Adaptivity comes naturally from routing decisions which send tokens to experts of different sizes. AutoMoE code, data, and trained models are available at https://aka.ms/AutoMoE.

Introduction

Mixture-of-Experts (MoE) models are pivotal for large-scale AI, enabling "conditional computation" where only a small subset of parameters is activated for any given input. This allows for scaling model capacity to billions of parameters without a linear increase in computational cost. However, current MoE designs are predominantly homogeneous, employing a uniform number of identical experts across layers. This manual approach is often sub-optimal, failing to account for the varying contributions of different network layers or specific hardware constraints like CPU latency.

AutoMoE addresses these limitations by treating MoE design as a hardware-aware architecture search problem, aiming to find the most efficient heterogeneous configuration for specific tasks and hardware targets.

The AutoMoE Framework

The AutoMoE framework automates the design of MoE models through a four-stage process: design space construction, supernet training, evolutionary search, and final subnet training.

The AutoMoE framework pipeline, encompassing design space construction, supernet training, evolutionary search, and final deployment.

Heterogeneous Search Space and Weight Sharing

Unlike standard MoEs, AutoMoE explores a search space that varies expert placement, the number of experts per layer, and the intermediate size of each expert's Feed-Forward Network (FFN). To efficiently explore this space, AutoMoE utilizes a Supernet—a large model containing the maximum possible experts and dimensions. All candidate sub-architectures share weights within this supernet, allowing them to be trained simultaneously.

Illustration of weight sharing in the AutoMoE search space, showing how sub-transformer weights for routers and FFNs are sampled from the larger supernet.

Evolutionary Search and Hardware Awareness

Following supernet training, an evolutionary algorithm identifies the optimal sub-architecture. Candidates are sampled and evaluated based on their estimated accuracy from the supernet and their actual measured latency on target hardware (e.g., Intel Xeon CPUs). This "hardware-aware" approach ensures that optimizations translate to real-world performance gains, rather than just theoretical FLOPs reductions.

Key Insights

  • Structural Asymmetry: AutoMoE consistently favors more experts in the encoder while keeping the decoder "light." This is strategic, as the decoder is typically the primary bottleneck during autoregressive generation.
  • Layer-Specific Capacity: Middle encoder layers (3rd to 5th) generally benefit from higher expert counts, whereas the first layer requires fewer.
  • Natural Adaptivity: By allowing experts of varying sizes, the model naturally routes tokens to the appropriate capacity expert, achieving adaptive computation without complex "early exit" mechanisms.

Experimental Results

AutoMoE was evaluated on standard NMT benchmarks, including WMT’14 (En-De, En-Fr) and WMT’19 (En-De).

  • Efficiency Gains: AutoMoE models achieved a 4x reduction in FLOPs and CPU latency compared to a standard Transformer-Big baseline.
  • Performance Parity: Despite significant compression, AutoMoE maintained BLEU score parity with dense Transformers and remained within 1 BLEU point of the much larger SwitchTransformer.
  • Superiority over NAS Baselines: AutoMoE outperformed existing NAS methods like HAT (Hardware-Aware Transformer), delivering a 1.3x to 2.4x improvement in efficiency.
  • High Sparsity: The resulting models reached up to 81% sparsity, demonstrating the ability to maintain massive latent capacity while only utilizing necessary parameters during inference.

Conclusion and Future Work

AutoMoE demonstrates that automated, heterogeneous design is superior to manual, homogeneous MoE configurations for real-world efficiency. Future research directions include scaling this approach to trillion-parameter models, improving supernet training stability through techniques like "sandwich sampling" or "inplace knowledge distillation," and expanding the search space to include other architectural components like attention heads or non-Transformer blocks.

Summary updated

BibTeX
@inproceedings{jawahar2023automoe,
  author = {Ganesh Jawahar and Subhabrata Mukherjee and Xiaodong Liu and Young Jin Kim and Muhammad Abdul-Mageed and Laks V. S. Lakshmanan and Ahmed Hassan Awadallah and Sébastien Bubeck and Jianfeng Gao},
  title = {{AutoMoE: Neural Architecture Search for Efficient Sparsely Activated Transformers}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.findings-acl.580},
}
Figure