CMoE: Converting Mixture-of-Experts from Dense to Accelerate LLM Inference

📄 arXiv: 2502.04416v2 📥 PDF

作者: Zehua Pei, Lancheng Zou, Hui-Ling Zhen, Xianzhi Yu, Wulong Liu, Sinno Jialin Pan, Mingxuan Yuan, Bei Yu

分类: cs.LG, cs.AI

发布日期: 2025-02-06 (更新: 2025-05-24)

🔗 代码/项目: GITHUB


💡 一句话要点

提出CMoE框架以加速大语言模型推理

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 大语言模型 混合专家 推理加速 激活稀疏性 轻量级微调

📋 核心要点

  1. 现有大语言模型在推理时面临高计算成本,尤其是在大批量场景中,前馈网络成为主要瓶颈。
  2. CMoE框架通过分析FFN神经元激活,快速将稠密模型转化为混合专家架构,无需额外训练。
  3. 实验结果显示,CMoE在激活25%参数的情况下,端到端延迟降低1.5倍,同时保持可用的困惑度,且轻量微调后恢复76%的下游准确率。

📝 摘要(中文)

随着大语言模型(LLMs)的规模扩大,性能提升的同时推理成本也显著增加。前馈网络(FFN)占据了约70%的推理计算,成为关键瓶颈。尽管混合专家(MoE)架构利用激活稀疏性提高效率,但将现有的稠密模型转换为MoE通常需要资源密集的持续预训练。本文提出CMoE框架,快速将稠密LLMs转化为MoE而无需训练。关键创新在于分析FFN神经元激活,将其划分为共享(始终激活)和路由专家。路由神经元通过平衡分配算法进行聚类,并从激活统计中分析构建可微分路由器,支持立即部署或可选的轻量级微调。实验表明,在75%的激活比率下,CMoE在保持无损精度的同时实现了5%的加速。

🔬 方法详解

问题定义:本文旨在解决大语言模型推理中的高计算成本问题,尤其是前馈网络在大批量场景下的瓶颈。现有的稠密模型转换为混合专家架构通常需要耗时的持续预训练,限制了其应用。

核心思路:CMoE框架的核心思路是通过分析FFN神经元的激活情况,将神经元划分为共享和路由专家,从而实现高效的模型转换。该方法避免了传统的训练过程,能够快速部署。

技术框架:CMoE的整体架构包括激活分析、神经元聚类和可微分路由器的构建。首先,通过激活统计分析神经元的使用情况,然后使用平衡分配算法对路由神经元进行聚类,最后构建可微分路由器以支持模型的灵活性。

关键创新:CMoE的主要创新在于无需训练即可将稠密模型转化为MoE架构,利用激活稀疏性显著提高推理效率。这一方法与传统的MoE转换方法本质上不同,后者通常需要大量的计算资源和时间。

关键设计:在参数设置上,CMoE通过分析激活比率(如75%)来优化模型性能,并通过轻量级的LoRA微调过程(仅需1小时和2000个样本)来恢复模型的下游准确率。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

实验结果显示,CMoE在激活75%参数的情况下,实现了5%的推理加速,并在激活仅25%参数时,端到端延迟降低了1.5倍,同时保持了可用的困惑度。此外,经过短时间的LoRA微调,模型恢复了超过76%的下游准确率。

🎯 应用场景

CMoE框架在大语言模型的实际应用中具有重要价值,尤其是在计算资源有限的场景下。其高效的推理能力使得在边缘设备或实时应用中部署大语言模型成为可能,推动了自然语言处理技术的普及和应用。

📄 摘要(原文)

Scaling large language models (LLMs) improves performance but dramatically increases inference costs. The feed-forward network (FFN), consuming approximately 70\% of inference compute, represents a critical bottleneck, particularly in large batch size scenarios. While mixture-of-experts (MoE) architectures leverage activation sparsity for efficiency, converting existing dense models to MoEs traditionally requires resource-intensive continual pre-training. We present CMoE, a framework that rapidly transforms dense LLMs into MoEs without training. The key innovation lies in analyzing FFN neuron activations to partition them into shared (always active) and routed experts. Routed neurons are clustered using a balanced assignment algorithm, and a differentiable router is constructed analytically from activation statistics, enabling immediate deployment or optional lightweight fine-tuning. Experiments demonstrate that, with activation ratio of 75\%, it achieves remarkable results, delivering lossless precision in terms of perplexity while still maintaining a 5\% acceleration. Further experiments reveal that a CMoE configuration activating just 25\% of parameters reduces end-to-end latency by 1.5x while preserving usable perplexity without additional training. Moreover, a brief LoRA fine-tuning process (requiring only 1 hour and 2,000 samples) successfully recovers over 76\% of the dense model's downstream accuracy. By effectively balancing performance and efficiency, CMoE offers a viable path forward for deploying LLMs in real-world scenarios where computational resources are limited. We make our code publicly available at https://github.com/JarvisPei/CMoE.