Efficient Expert Pruning for Sparse Mixture-of-Experts Language Models: Enhancing Performance and Reducing Inference Costs

Enshu Liu, Junyi Zhu, Zinan Lin, Xuefei Ning, Matthew B. Blaschko, Shengen Yan, Guohao Dai, Huazhong Yang, Yu Wang · DOI

Introduction

Sparse Mixture-of-Experts (SMoE) architectures, such as Mixtral 8x7B, have become a cornerstone of modern large language models by offering high parameter counts with the computational efficiency of much smaller models. By activating only a few experts per token, SMoEs optimize inference speed. However, a significant deployment bottleneck remains: the entire model must be loaded into GPU memory. For a model like Mixtral 8x7B, this requires approximately 47 billion parameters, posing a major challenge for deployment on consumer-grade hardware.

Existing pruning methods often struggle with SMoEs, either requiring expensive gradient-based fine-tuning or resulting in substantial accuracy loss. To address these challenges, we introduce Efficient Expert Pruning (EEP), a gradient-free evolutionary strategy designed to reduce SMoE model size while maintaining or even improving task-specific performance.

Methodology: The EEP Framework

EEP is a two-stage, gradient-free approach that slims down models without the need for traditional, computationally expensive fine-tuning.

1. Expert Pruning Phase

The algorithm identifies the optimal subset of experts to retain for a specific task. To ensure the model continues to function correctly, it employs a Router Mapping matrix ($W_{RM}$) to redirect token traffic from the original router to the surviving experts.

2. Expert Merging Phase

Rather than simply discarding pruned experts, EEP uses an Expert Merging matrix ($W_{EM}$) to consolidate the knowledge from pruned experts into the survivors. This acts as a lightweight, gradient-free alternative to fine-tuning, ensuring that the "discarded" experts' knowledge is not lost.

The two-stage EEP process: Expert Pruning with Router Mapping and Expert Merging.

Evolutionary Strategy (ES)

Because calculating gradients for models of this scale is often prohibitive, EEP utilizes an evolutionary strategy. It treats various pruning and merging configurations as individuals in a population, performing crossover and mutation over several iterations to find the optimal "offspring" based on performance on a small validation set.

Key Insights

The "Less is More" Paradox

A surprising finding of this research is that pruning experts can actually increase performance. For example, on the SQuAD dataset, pruning Mixtral from 8 experts down to 4 increased accuracy from 53.4% to 75.4%. This suggests that reducing the number of experts simplifies the routing task, allowing the model to partition high-dimensional space more effectively for specialized tasks.

Merging vs. Dropping

While simple pruning is effective, merging the weights of pruned experts into the survivors consistently provides a 5-7% accuracy boost. This proves that experts deemed "inactive" for a specific task still contain valuable latent knowledge that can enhance the performance of the remaining architecture.

Experimental Results

The researchers evaluated EEP across diverse benchmarks, including SuperGLUE, SQuAD, and MMLU. The results demonstrate significant gains in efficiency:

  • Massive Compression: On Mixtral 8x7B-Instruct, EEP reduced the number of experts from 8 to 2—a 72% reduction in total parameters—while maintaining performance comparable to the full model.
  • Memory Savings: Retaining only 2 experts reduced the GPU memory footprint from 88.6 GB to 25.6 GB (a 71% saving).
  • Inference Speedup: By reducing the number of active experts from 2 to 1, the authors achieved a 1.63x prefill acceleration.
Comparison of the original SMoE model with EEP use cases for memory reduction and inference acceleration.

EEP consistently outperformed other pruning methods, such as NAEE or simple frequency-based pruning, particularly at high sparsity levels where other methods often cause model performance to collapse.

Limitations and Future Work

While gradient-free, the evolutionary search process requires multiple inference passes over a validation set, which can be computationally costly. Future research will focus on optimizing search efficiency. Additionally, while the model showed good generalization on MMLU, the optimal pruned version is often task-specific. Further study is needed to determine how these strategies scale to trillion-parameter class models.

Summary updated

BibTeX
@misc{liu2024efficient,
  author = {Enshu Liu and Junyi Zhu and Zinan Lin and Xuefei Ning and Matthew B. Blaschko and Shengen Yan and Guohao Dai and Huazhong Yang and Yu Wang},
  title = {{Efficient Expert Pruning for Sparse Mixture-of-Experts Language Models: Enhancing Performance and Reducing Inference Costs}},
  year = {2024},
  eprint = {2407.00945},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2407.00945},
}
Figure