CodeSwift: Accelerating LLM Inference for Efficient Code Generation

📅 2025-02-24
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
To address the high autoregressive decoding latency of large language models (LLMs) in code generation and the neglect of code-specific syntactic and semantic characteristics by existing inference acceleration methods, this paper proposes the first lightweight, code-oriented inference acceleration framework. Our approach innovatively integrates three key components: (1) a multi-source structured knowledge base grounded in abstract syntax trees (ASTs) and semantic analysis; (2) a timing-aware dynamic retrieval mechanism; and (3) a context- and LLM-preference-aware caching strategy. Evaluated on repository-level and function-level code generation tasks, the framework achieves end-to-end speedups of 2.53× and 2.54×, respectively—outperforming state-of-the-art methods by up to 88%. Crucially, these gains are attained without compromising generation quality, thereby effectively balancing inference efficiency and functional correctness.

Technology Category

Application Category

📝 Abstract
Code generation is a latency-sensitive task that demands high timeliness, but the autoregressive decoding mechanism of Large Language Models (LLMs) leads to poor inference efficiency. Existing LLM inference acceleration methods mainly focus on standalone functions using only built-in components. Moreover, they treat code like natural language sequences, ignoring its unique syntax and semantic characteristics. As a result, the effectiveness of these approaches in code generation tasks remains limited and fails to align with real-world programming scenarios. To alleviate this issue, we propose CodeSwift, a simple yet highly efficient inference acceleration approach specifically designed for code generation, without comprising the quality of the output. CodeSwift constructs a multi-source datastore, providing access to both general and project-specific knowledge, facilitating the retrieval of high-quality draft sequences. Moreover, CodeSwift reduces retrieval cost by controlling retrieval timing, and enhances efficiency through parallel retrieval and a context- and LLM preference-aware cache. Experimental results show that CodeSwift can reach up to 2.53x and 2.54x speedup compared to autoregressive decoding in repository-level and standalone code generation tasks, respectively, outperforming state-of-the-art inference acceleration approaches by up to 88%.
Problem

Research questions and friction points this paper is trying to address.

Improves LLM inference efficiency
Addresses code generation latency
Incorporates syntax and semantics
Innovation

Methods, ideas, or system contributions that make the work stand out.

Multi-source datastore for knowledge retrieval
Parallel retrieval to enhance efficiency
Context-aware cache for speed optimization
🔎 Similar Papers
No similar papers found.
Q
Qianhui Zhao
School of Computer Science and Engineering, State Key Laboratory of Complex & Critical Software Environment, Beihang University
L
Li Zhang
School of Computer Science and Engineering, State Key Laboratory of Complex & Critical Software Environment, Beihang University
F
Fang Liu
School of Computer Science and Engineering, State Key Laboratory of Complex & Critical Software Environment, Beihang University
X
Xiaoli Lian
School of Computer Science and Engineering, State Key Laboratory of Complex & Critical Software Environment, Beihang University
Q
Qiaoyuanhe Meng
School of Computer Science and Engineering, State Key Laboratory of Complex & Critical Software Environment, Beihang University
Z
Ziqian Jiao
School of Computer Science and Engineering, State Key Laboratory of Complex & Critical Software Environment, Beihang University
Z
Zetong Zhou
School of Computer Science and Engineering, State Key Laboratory of Complex & Critical Software Environment, Beihang University
Borui Zhang
Borui Zhang
Ph.D. student, Tsinghua University
Computer VisionMachine LearningMetric LearningExplainable AI
R
Runlin Guo
School of Computer Science and Engineering, State Key Laboratory of Complex & Critical Software Environment, Beihang University
J
Jia Li
Key Lab of High Confidence Software Technology (Peking University)