TL;DR
Standard Mixture-of-Experts (MoE) models waste significant compute by activating a fixed number of experts for every token, regardless of its complexity. This paper introduces BEAM (Binary Expert Activation Masking), a plug-and-play method that learns to dynamically skip redundant experts on a per-token basis using a lightweight, trainable binary mask. BEAM reduces MoE layer FLOPs by up to 85% and accelerates decoding by up to 2.5× while retaining over 98% of the original model's accuracy.
What Problem Does This Paper Address?
Mixture-of-Experts (MoE) architectures have become the standard for scaling large language models efficiently. By routing tokens to only a subset of specialized "expert" networks (usually via a fixed Top-K strategy), they keep computational costs manageable.
However, fixed Top-K routing treats all tokens equally. A simple punctuation mark or a common word like "the" receives the exact same computational budget and expert count as a highly complex technical term. This token-level rigidity leads to massive computational redundancy and suboptimal inference latency.
Existing attempts to make routing dynamic typically suffer from severe drawbacks: they either require expensive retraining from scratch, introduce complex architectural changes, or cause severe performance drops at high sparsity due to a mismatch between how the model was trained and how it is run during inference.
Methods
BEAM addresses these limitations by introducing a lightweight, learnable mask router that operates in parallel with the model's primary router.
The process unfolds in four steps:
- Standard Top-K Routing: The primary router identifies the top $K$ candidate experts and computes their standard routing weights.
- Raw Mask Generation: Simultaneously, the auxiliary mask router generates a continuous gating score (scaled between 0 and 1 via a Sigmoid function) for each expert.
- Binary Masking: These continuous scores are binarized using a hard threshold ($\tau = 0.5$). If a score falls below 0.5, that expert is masked out (set to 0), meaning an input token can activate anywhere from 0 to $K$ experts.
- Masked Aggregation: The final routing weights are determined by element-wise multiplication of the Top-K weights and the binary mask.
To train this non-differentiable hard thresholding function end-to-end, the authors utilize a Straight-Through Estimator (STE), which passes the gradients directly through the binarization step during the backward pass. They also introduce an auxiliary $L_1$ regularization loss to penalize active mask values, smoothly driving the model toward higher sparsity.
Crucially, the authors integrated BEAM into the popular vLLM inference framework by writing a custom CUDA kernel. This kernel allows the system to completely skip the computation of masked experts, translating theoretical FLOP reductions into real-world wall-clock speedups.
Datasets
The authors evaluated BEAM by fine-tuning three prominent MoE models (Qwen1.5-MoE-A2.7B, DeepSeekV2-Lite, and Qwen3-30B-A3B) using the Tulu 3 SFT Mixture Dataset, which spans reasoning, coding, and general knowledge.
Downstream performance was tested across eight standard benchmarks from the OpenCompass platform:
- Reasoning: MATH, GSM8K, HumanEval
- Knowledge: MMLU, CEVAL, CMMLU
- Common Sense: CommonsenseQA (CSQA), BoolQ
Key Insights and Ideas
- Decoupling Selection from Sparsification: Previous methods tried to force a single router to handle expert selection, load balancing, and sparsity control simultaneously, leading to conflicting gradients. BEAM decouples these tasks: the primary router chooses which experts are best, while the mask router decides how many are actually necessary.
- Sparsity Aligns with Semantic Richness: Analysis of BEAM's token-wise behavior revealed that content-heavy words (nouns, verbs) consistently activate more experts (up to 4.65 on average), whereas function words (prepositions), punctuation, and chat template tokens (like "You are a helpful assistant") routinely bypass experts entirely.
- Rank-Independent Pruning: Unlike naive pruning methods that always drop the lowest-ranked experts in a Top-K list, BEAM evaluates relevance based on token features. It frequently prunes highly-ranked experts if they are redundant, or retains lower-ranked experts if they provide critical, niche knowledge.
Key Results
BEAM consistently outperformed alternative dynamic routing baselines (such as Top-K Pruning, MoE-Dynamic, and AdaMoE) across the performance-sparsity trade-off curve.
- Accuracy Retention: At medium sparsity, BEAM retains over 98% of the original model's accuracy while cutting average expert activation by 47%–61%. Even at extreme sparsity (e.g., reducing average active experts to just 0.56 out of 4 on Qwen1.5), it maintains over 95% accuracy.
- Hardware Acceleration: Thanks to the custom CUDA kernel in vLLM, BEAM achieved up to 2.5× faster decoding latency and 1.4× higher throughput on an NVIDIA H20 GPU.
Limitations and Future Work
While promising, the authors note a few limitations:
- Post-Training Overhead: Implementing BEAM requires a Supervised Fine-Tuning (SFT) phase to train the mask router, which adds an extra computational cost proportional to the model size.
- Architecture Dependency: The real-world speedup depends heavily on the model's architecture. Models with a high ratio of "shared experts" (like Qwen1.5-MoE) see less latency reduction because BEAM only prunes routed experts, leaving shared expert workloads untouched.
- Multi-GPU Scaling: The current acceleration benchmarks were conducted in single-GPU environments. How BEAM's dynamic, token-dependent sparsity interacts with multi-GPU expert parallelism strategies remains an open question for future research.
Summary updated