MoE-Mamba: Efficient Selective State Space Models with Mixture of Experts

Maciej Pióro, Kamil Ciebiera, Krystian Król, Jan Ludziejewski, Sebastian JaszczurarXiv 2024

Abstract

State Space Models (SSMs) have become serious contenders in the field of sequential modeling, challenging the dominance of Transformers. At the same time, Mixture of Experts (MoE) has significantly improved Transformer-based Large Language Models, including recent state-of-the-art open models. We propose that to unlock the potential of SSMs for scaling, they should be combined with MoE. We showcase this on Mamba, a recent SSM-based model that achieves remarkable performance. Our model, MoE-Mamba, outperforms both Mamba and baseline Transformer-MoE. In particular, MoE-Mamba reaches the same performance as Mamba in $2.35\times$ fewer training steps while preserving the inference performance gains of Mamba against Transformer.

Introduction

For years, the Transformer has been the undisputed king of Large Language Models (LLMs). However, its quadratic complexity ($O(n^2)$) makes processing long sequences prohibitively expensive. Recently, State Space Models (SSMs) like Mamba have emerged as serious contenders, offering linear-time inference and strong performance.

Meanwhile, the "Mixture of Experts" (MoE) approach has become the standard for scaling Transformers (seen in models like Mixtral 8x7B). MoE allows a model to have a massive number of total parameters while only activating a small subset for each token, keeping the computational cost (FLOPs) low. MoE-Mamba addresses a simple but powerful question: Can we unlock the scaling potential of SSMs by combining them with MoE?

Architecture and Methods

The researchers introduce MoE-Mamba, which integrates the Mamba architecture with a Switch Transformer-style MoE layer.

Comparison of architectural blocks: Transformer, Transformer-MoE, Vanilla Mamba, and the proposed MoE-Mamba.

The core design principles include:

  • Interleaved Architecture: Instead of just stacking Mamba blocks, the researchers interleave Mamba layers with MoE layers. The Mamba layer provides "unconditional" processing, integrating the entire sequence context into an internal state. The MoE layer then provides "conditional" processing, applying a specialized "expert" (a feed-forward network) to each token.
  • Top-1 Routing: They utilize a "Switch" routing mechanism where each token is sent to exactly one expert. This simplifies the training process and keeps the active parameter count (and thus the compute cost) per token equivalent to a much smaller dense model.
  • Ablations: The team tested several variations, including a "Parallel" design and an "Inner MoE" design. They found the sequential interleaved approach to be the most effective.

Experimental Setup

Models were trained and evaluated on the C4 (Colossal Clean Crawled Corpus) dataset.

  • Scale: Experiments focused on two primary sizes: a "25M" scale (10B tokens) and a "100M" scale (30B tokens). These numbers refer to the active parameters per token, though total parameter counts reached up to 2.4B.
  • Tokenizer: GPT-2 tokenizer was used.

Key Results and Insights

The quantitative gains are substantial. MoE-Mamba reaches the performance level of a vanilla Mamba model in just 42.5% of the training time (a 2.35x speedup).

Log Perplexity Comparison showing MoE-Mamba's 2.35x training efficiency gain over Vanilla Mamba.
  • Superior Perplexity: At the 100M active parameter scale, MoE-Mamba achieved a final log perplexity of 2.81, outperforming vanilla Mamba (2.99) and Transformer-MoE (2.88).
  • Efficiency Synergy: Mamba captures long-range dependencies with linear complexity, while MoE adds "knowledge" via parameters without adding compute. Together, they create a model that is both fast to run and fast to learn.
  • Monotonic Scaling: Performance improves consistently as more experts are added (up to 32 experts tested).
  • The "Copying" Gap: While MoE-Mamba achieves better perplexity than Transformers, attention-based models still seem better at verbatim token-copying, likely due to the finite state compression in SSMs.

Conclusion and Future Work

MoE-Mamba demonstrates that combining SSMs with MoE significantly improves training efficiency and final performance while retaining linear-time inference. Future work will focus on scaling these laws to the 7B+ parameter range and investigating hybrid architectures to bridge the "copying gap" observed in comparison to attention-based models. Additionally, optimizing hardware communication for distributed MoE-Mamba training remains a critical engineering challenge.

Summary updated

BibTeX
@misc{pioro2024moe,
  author = {Maciej Pióro and Kamil Ciebiera and Krystian Król and Jan Ludziejewski and Sebastian Jaszczur},
  title = {{MoE-Mamba: Efficient Selective State Space Models with Mixture of Experts}},
  year = {2024},
  eprint = {2401.04081},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2401.04081},
}
Figure