MoE Load Balancing Kernel Speeds Training Up to 6x

Diagram of MoE load balancing across GPUs in the Mega MoE kernel

Prime Intellect now does MoE load balancing from within its fused Mega MoE kernel. A planner running on the GPU spots overloaded experts, sends copies of their weights to idle GPUs during computation and splits tokens so each GPU gets the same amount of work. The results match Mega MoE exactly, bit for bit, including input gradients.

Under heavy expert skew, mixture-of-experts layers run up to six times faster than before. With actual DeepSeek-V4 routing, the improvement is between 1.2x and 1.6x.

Why GPUs wait on each other

Under expert parallelism, every GPU hosts a fixed group of experts. Routers send uneven traffic, with a few favorites drawing far more tokens than the average. If one GPU’s experts see triple the typical load, it takes three times as long, and seven neighbors idle until it’s done.

Speeding up each kernel doesn’t fix that. The problem also gets worse as expert parallelism spreads across more GPUs, and every data-parallel replica ends up waiting on whichever group is slowest.

Where the time goes: one hot expert, eight GPUs. Schematic of one MoE layer inside the fused kernel
Image: primeintellect.ai

Three pieces of the design

The approach borrows the least-loaded idea from earlier research called LLEP, but executes it fully on the GPU inside the fused kernel.

The first piece is the plan. Each GPU tallies tokens per expert and writes those tallies into the memory of all the others over NVLink, avoiding collectives and the CPU. Every GPU then applies the same greedy least-loaded assignment to the table. When nothing is overloaded, no expert moves and behavior matches plain Mega MoE. Planning takes tens of microseconds, and static tensor shapes keep it compatible with torch.compile and CUDA graphs.

The second piece is weight streaming. Warps that finish pulling tokens would normally idle, so they write lent experts into spare slots on helper GPUs over NVLink and raise a ready flag. A helper handles its own experts first, which gives the borrowed weights time to arrive. The copy cost hides behind useful work.

The third is the backward pass. Each helper computes its portion of a borrowed expert’s weight gradient in FP32. A gather kernel sums the pieces in a fixed order, which means splitting an expert introduces no extra rounding.

Step 1: count routes, assign the least-loaded GPUs, and turn the plan into ordinary expert ids (about 50 ยตs, no CPU)
Image: primeintellect.ai

What the numbers show

The test layer came from DeepSeek-V4-Flash (256 experts, top-6) on a single node of eight GPUs. Moving from balanced traffic to the worst skew stretched Mega MoE’s layer time 7.4x on H200 and 6.1x on B300. The balanced kernel’s time grew 40% and 38%. That works out to speedups reaching 5.3x on H200 and 4.4x on B300.

Next, the team replayed loads logged during a DeepSeek-V4-Flash fine-tuning run on 8 H200 GPUs. Average speedup was 1.20x, and the most lopsided layers hit 1.64x. On B300 with MXFP8, the average was 1.22x at 64K tokens per GPU. Skew taken from a production reinforcement learning job on 112 B300 GPUs gave 1.32x.

Step 2: one fused forward call on two of the eight GPUs; time runs left to right
Image: primeintellect.ai

Memory and multi-node runs

Mega MoE has to prepare receive buffers for the extreme case where one GPU gets everything. Since balancing caps what any GPU receives, buffers shrink by a factor of 3 to 3.4. At 64K tokens per GPU, Prime Intellect’s kernel works in four chunks within 14.4 GiB, a footprint far below the roughly 170 GiB the older kernel would require.

Beyond one node, tokens cross InfiniBand using a transport the GPUs drive themselves. Helpers stay inside a node, so weight copies never leave NVLink. At expert-parallel size 16 on real routing, the busiest GPU’s load falls from 1.56x the average to 1.10x. On 400 Gb/s links, balancing adds 1.41x at size 16 and 1.48x at size 32, where the hottest GPU would otherwise handle double the average. The transport reaches 47.5 GB/s per GPU, 96% of line rate.

Supported hardware and outlook

The kernel supports Hopper with BF16 and FP8, and Blackwell with MXFP8 and NVFP4. Savings of tens of GiB per GPU leave room for bigger micro-batches and long-context training.

The earlier release fused routing, communication, expert compute and return traffic to cut waits between operations. This one cuts waits between GPUs. Since gains rise with skew, large multi-node training jobs, where uneven expert popularity hurts most, stand to benefit first.

Source: primeintellect.ai

Written by

Saksham Bhargava

Saksham Bhargava runs Alteroid and has been writing about consumer technology for over five years, covering iPhone, Android, Windows, AI tools and gaming. With an MCA and six years of hands-on web development experience, he tests the features he writes about on his own devices and focuses on clear, practical guides that solve real problems. Away from the screen, he enjoys travelling to places most tourists skip.