Skip to main content
QUICK REVIEW

[Paper Review] MegaBlocks: Efficient Sparse Training with Mixture-of-Experts

Trevor Gale, Deepak Narayanan|arXiv (Cornell University)|Nov 29, 2022
Domain Adaptation and Few-Shot LearningComputer Science19 citations
TL;DR

MegaBlocks introduces a block-sparse formulation for Mixture-of-Experts (MoE) training that eliminates token dropping and enables efficient GPU computation. By designing custom block-sparse GPU kernels using blocked-CSR-COO encoding and transpose indices, it achieves up to 40% end-to-end training speedup over state-of-the-art MoE frameworks and 2.4× speedup over optimized DNN training with Megatron-LM.

ABSTRACT

We present MegaBlocks, a system for efficient Mixture-of-Experts (MoE) training on GPUs. Our system is motivated by the limitations of current frameworks, which restrict the dynamic routing in MoE layers to satisfy the constraints of existing software and hardware. These formulations force a tradeoff between model quality and hardware efficiency, as users must choose between dropping tokens from the computation or wasting computation and memory on padding. To address these limitations, we reformulate MoE computation in terms of block-sparse operations and develop new block-sparse GPU kernels that efficiently handle the dynamism present in MoEs. Our approach never drops tokens and maps efficiently to modern hardware, enabling end-to-end training speedups of up to 40% over MoEs trained with the state-of-the-art Tutel library and 2.4x over DNNs trained with the highly-optimized Megatron-LM framework.

Motivation & Objective

  • Address the inefficiency of current MoE training frameworks that force a tradeoff between model quality and hardware efficiency due to token dropping or excessive padding.
  • Overcome hardware and software limitations in existing deep learning systems that restrict dynamic routing in MoE layers.
  • Enable end-to-end MoE training without token dropping while maintaining high computational efficiency on modern GPUs.
  • Develop a system that maps naturally to modern GPU architectures by reformulating MoE computation as block-sparse operations.
  • Achieve high performance through novel GPU kernels optimized for sparse inputs and outputs in both transposed and non-transposed forms.

Proposed method

  • Reformulate MoE computation as block-sparse operations to handle imbalanced token-expert assignments without dropping tokens.
  • Design two key techniques: blocked-CSR-COO encoding for efficient sparse matrix representation and transpose indices for optimized access patterns.
  • Implement high-performance GPU kernels that support block-sparse matrix multiplication with dynamic sparsity patterns.
  • Use transpose indices to enable efficient computation in both transposed and non-transposed input/output configurations.
  • Integrate the kernels into the Megatron-LM framework to support end-to-end training of large-scale Transformer models.
  • Benchmark performance using microbenchmarks and full model training, comparing against cuBLAS, CUTLASS, and state-of-the-art MoE libraries.

Experimental results

Research questions

  • RQ1Can MoE training be made both hardware-efficient and model-quality-preserving by eliminating token dropping?
  • RQ2How can dynamic, load-imbalanced MoE computation be efficiently mapped to modern GPU architectures?
  • RQ3To what extent can block-sparse operations and custom GPU kernels outperform standard dense or sparse primitives in MoE training?
  • RQ4What performance overhead is introduced by sparse computation in gradient computation, and can it be mitigated?
  • RQ5Can a block-sparse formulation achieve near-peak performance on GPUs while maintaining flexibility for dynamic routing?

Key findings

  • MegaBlocks achieves up to 40% end-to-end training speedup over MoEs trained with the state-of-the-art Tutel library.
  • The system delivers a 2.4× speedup over DNNs trained with the highly-optimized Megatron-LM framework.
  • Microbenchmarks show that MegaBlocks' block-sparse kernels achieve 98.6% of cuBLAS throughput on average, with a standard deviation of 4%.
  • The kernels slightly outperform cuBLAS on half the benchmark problems and underperform slightly on the other half, with performance variations primarily due to L2 caching and computation reordering effects.
  • The performance gap in gradient computation (DS T D operations) is minimal, with less than 10% potential improvement and low impact on total runtime.
  • The system enables dropless MoE training by avoiding token dropping and padding, preserving model quality while improving hardware utilization.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.