CoCoMoE: Towards Efficient Code Completion with Sparse Mixture-of-Experts Architectures
Abstract
Code completion is an important feature in modern integrated development environments (IDEs), aiming to improve developer’s productivity by predicting relevant code snippets. Recently, large language models (LLMs) have improved code completion quality significantly. However, the ever-growing size of LLMs imposes substantial computational overheads, making just-in-time inference costly and hindering their practical deployment. In this paper, we propose CoCoMoE (Code Completion based on Mixture-of-Experts), a sparse Mixture-of-Experts (MoE) framework tailored for efficient code completion. CoCoMoE incorporates a noisy gating mechanism to balance expert utilization and introduces a hybrid expert clustering architecture consisting of shared experts and language-specific experts to improve multi-language adaptability. We adapt CoCoMoE to state-of-the-art code completion large code models (LCMs) and evaluate it with regard to both generative and infilling code completion tasks, using Java and Python benchmarks from CodeXGLUE at the token-, line-, and block-level. Our experiments show that CoCoMoE achieves a reduction of up to around 31% in FLOPs and 16% in inference latency, while incurring only a degradation of 0.24%–1.19% in token-level completion accuracy. These results demonstrate that CoCoMoE can effectively reduce the computational overheads required by large code completion models with minimal degradation in completion quality.