Abstract
Mixture-of-Experts (MoE) has garnered significant attention for its ability to scale up neural networks while utilizing the same or even fewer active parameters. However, MoE does not alleviate the massive memory requirements of networks, which limits their practicality in real-world applications, especially in the era of large language models (LLMs). While recent work explores the possibility of removing entire layers of MoE to reduce memory, the performance degradation is still notable. In this paper, we propose ConDense-MoE (CD-MoE), which, instead of dropping the entire MoE layer, condenses the large, sparse MoE layer into a smaller, denser layer with only a few experts activated for all tokens, while maintaining hardware friendliness. Our approach is specifically designed for fine-grained MoE with shared experts, such as DeepSeekMoE and QwenMoE. We demonstrate that for the DeepSeekMoE-16B model, our approach maintains 90% of the average accuracy while reducing memory usage by 27.5% and increasing inference speed by 1.26 times. Moreover, with lightweight expert fine-tuning, we can recover 98% of the original performance in just 5 hours on a single 80G A100 GPU.
Introduction
Mixture-of-Experts (MoE) architectures, such as Mixtral and DeepSeek, have become standard for scaling Large Language Models (LLMs) by activating only a fraction of parameters per token. Despite their computational efficiency, the primary bottleneck remains the massive VRAM requirement, as all experts—including dormant ones—must be stored in memory. Traditional pruning methods, which drop entire layers or specific experts, often result in significant accuracy loss and do not necessarily eliminate the computational overhead of the routing mechanism.
The ConDense-MoE (CD-MoE) Framework
We propose ConDense-MoE (CD-MoE), a surgical approach to model compression that transforms sparse MoE layers into efficient dense layers. This method is particularly effective for fine-grained MoE architectures that utilize "shared experts"—experts that are always active for every token.
The condensation process involves three key steps:
- Router Elimination: The dynamic routing mechanism is removed in selected layers to eliminate its computational overhead.
- Expert Condensation: A small subset of the most impactful routing experts is identified via greedy search and combined with existing shared experts to form a new, smaller dense layer.
- Fixed Gating: Instead of dynamic routing, CD-MoE employs fixed weights ($ar{w}$) for these experts, calculated by averaging their gate values over calibration data. This makes the layer hardware-friendly, as GPUs handle dense matrix multiplications more efficiently than sparse routing.
Layer Selection Strategy
Not all layers contribute equally to model performance. To identify the most redundant layers, we utilize a greedy search algorithm based on Jensen-Shannon (JS) divergence. By measuring the divergence between the original model's output and the output after condensing a specific layer, we can pinpoint layers that are resilient to compression.
Empirical analysis shows that the first and last layers are critical for performance, exhibiting high JS divergence when condensed. In contrast, middle layers are significantly more compressible, allowing for substantial memory reduction with minimal impact on accuracy.
Experimental Results
We evaluated CD-MoE on DeepSeekMoE-16B and Qwen1.5-MoE-A2.7B across eight downstream benchmarks, including MMLU and ARC-Challenge.
- Efficiency: On DeepSeekMoE-16B, CD-MoE achieved a 27.5% reduction in memory and a 1.26x inference speedup.
- Accuracy: Without fine-tuning, the condensed model maintained 90% of its original accuracy, outperforming standard pruning baselines like BlockTrim.
- Performance Recovery: By applying lightweight fine-tuning only to the parameters of the newly condensed layers (approximately 3% of total parameters), the model recovered 98% of its original performance in just 5 hours on a single A100 GPU.
Conclusion
CD-MoE demonstrates that condensing sparse MoE layers into dense ones is a superior alternative to simple pruning. By preserving core expert knowledge and removing routing overhead, CD-MoE enables the deployment of high-capacity MoE models on more constrained hardware without sacrificing significant performance.
Summary updated