FlashMoE: Fast Distributed MoE in a Single Kernel

Osayamen Jonathan Aimuyo, Byungsoo Oh, Rachee Singh

TL;DR

FlashMoE is a persistent GPU "megakernel" that fuses expert computation and inter-GPU communication into a single, continuous operation. By moving scheduling and networking logic entirely onto the GPU and replacing synchronous "All-to-All" transfers with asynchronous, one-sided RDMA, it achieves up to 9× higher GPU utilization and 6× lower latency than state-of-the-art Mixture-of-Experts (MoE) frameworks.

The Bottlenecks of Distributed MoE

Mixture-of-Experts (MoE) models are highly favored for Large Language Model (LLM) scaling because they allow for massive parameter counts with sub-linear compute costs. However, running them efficiently across multiple GPUs is notoriously difficult.

Standard implementations suffer from three main bottlenecks:

  1. Kernel Launch Overhead: Current frameworks launch hundreds of small kernels per layer. Each launch requires the CPU to communicate with the GPU, creating "idle gaps" where the hardware sits doing nothing.
  2. Synchronous Communication: They rely on bulk-synchronous "All-to-All" collectives that force every GPU to wait for the slowest one (the "straggler effect") before moving to the next step.
  3. Payload Bloat: To simplify networking, many systems "zero-pad" data to fixed sizes, wasting bandwidth on empty packets when experts receive fewer tokens than expected.

FlashMoE: A Single-Kernel Solution

To overcome these limitations, the authors developed FlashMoE, a fully GPU-resident operator. Instead of a sequence of kernels managed by the CPU, FlashMoE is a single "megakernel" that stays active for the entire MoE operation.

FlashMoE fuses all phases into a single persistent kernel, eliminating the gaps seen in traditional approaches.

Key innovations include:

  • Actor-Based Programming: Inside the kernel, thread blocks are specialized into roles: Processors (handle heavy math like GEMMs), a Scheduler (dynamically assigns work to idle processors), and Subscribers (listen for and decode incoming data from other GPUs).
  • Device-Initiated Communication: Using NVSHMEM, the GPU initiates its own one-sided RDMA (Remote Direct Memory Access) transfers. It doesn't wait for a CPU command to send data; it simply "puts" the data into the target GPU's memory as soon as it's ready.
  • Symmetric Tensor Layout: To make one-sided transfers safe without expensive locks, the authors designed a "temporal buffering" scheme. This layout provides a mathematical guarantee that no two GPUs will ever try to write to the same memory slot simultaneously.
  • Fine-Grained Pipelining: Because everything happens in one kernel, FlashMoE can overlap the "dispatch" (sending tokens), "compute" (running experts), and "combine" (gathering results) phases at the level of individual data tiles.

Evaluation Setup

The paper evaluates performance using MoE Transformer configurations (16 attention heads, 2048 embedding dimension) on a node with 8 NVIDIA H100 GPUs. They tested scaling across sequence lengths (4K to 16K tokens), expert counts (8 to 128 experts), and hardware scaling (2, 4, and 8 GPU configurations).

Key Insights

  • The CPU is the bottleneck: By reducing the number of GPU operations from over 500 down to exactly 1, FlashMoE removes the massive orchestration tax imposed by the host CPU.
  • Asynchrony is King: Moving away from bulk-synchronous collectives allows the system to be "work-conserving." If a Processor block is free, the internal Scheduler gives it work immediately, rather than waiting for a global synchronization barrier.
  • Precision Disadvantage Overcome: Remarkably, FlashMoE achieved its speedups while running in FP32 (32-bit float), whereas all the baselines it beat were running in FP16 (16-bit). This suggests the architectural gains are so significant they outweigh the 2× increase in data volume.

Key Results

Compared to state-of-the-art baselines like FasterMoE and Megatron-LM, FlashMoE demonstrates massive improvements:

Comparison of GPU SM utilization and scaling performance against various baselines.
  • Utilization: Achieved 93.17% GPU SM utilization, compared to just 9.67% for FasterMoE and 13.55% for DeepEP.
  • Latency: Up to 6× lower latency at large sequence lengths (16K tokens).
  • Throughput: 5.7× higher throughput (reaching 17.7 MTokens/s on 8 H100s).
  • Scaling: While baselines showed superlinear latency growth as the number of experts increased (due to launch overhead), FlashMoE maintained nearly flat, stable performance.

Limitations and Future Work

  • Engineering Complexity: Writing persistent megakernels requires deep, low-level expertise in GPU architecture and distributed systems. Future work could involve creating Domain Specific Languages (DSLs) to make this easier.
  • FP16 Optimization: Currently, their FP16 implementation is slower than their FP32 version because the shared memory layouts aren't yet optimized for half-precision.
  • Inference Focus: This work focuses on the forward pass (inference). Adapting this "megakernel" approach to training would require handling backward passes and gradient synchronization, adding significant bookkeeping complexity.

Summary updated

BibTeX
@inproceedings{aimuyo2025flashmoe,
  author = {Osayamen Jonathan Aimuyo and Byungsoo Oh and Rachee Singh},
  title = {{FlashMoE: Fast Distributed MoE in a Single Kernel}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=EZfDHprhZM},
}
Figure