Introduction
Large Language Models (LLMs) have transformed software development, yet they face a significant "speed vs. scale" dilemma. In real-world repository-level code generation, models must navigate complex webs of dependencies, often leading to high latency. The primary bottleneck is autoregressive decoding, where the LLM generates code one token at a time. While speculative decoding exists for natural language, it often fails to account for the unique structural properties of code, such as strict syntax and high local repetition.
FASTCODER (the framework behind CodeSwift) addresses this by introducing a new inference acceleration paradigm that speeds up repository-level generation by up to 2.54x without compromising code quality. By combining project-specific retrieval with a preference-aware cache, it allows LLMs to verify long sequences of "draft" code in a single step.
Methodology
FASTCODER adopts a draft-verification paradigm. Instead of laboriously generating every token, the system "drafts" potential sequences from a datastore and asks the LLM to verify them in a single batch forward pass.
Key components include:
- Multi-source Datastore: Combines a massive general-purpose code corpus with a lightweight, project-specific datastore to capture both general syntax and unique local function names.
- Context- and LLM Preference-aware Cache: Static datastores may provide "correct" code that conflicts with an LLM's specific stylistic preferences. This cache learns the LLM's output style to improve future drafting accuracy.
- Dynamic Retrieval Strategy: The system intelligently skips retrieval at high-entropy positions (like the first non-whitespace character of a line) and maintains a "Missing Table" to avoid redundant failed searches.
- Weighted Trie & Tree Attention: Drafts are organized into a tree structure, allowing the LLM to verify multiple branching paths simultaneously.
Key Results
The researchers evaluated FASTCODER across major benchmarks including DevEval, RepoEval, and HumanEval.
- Significant Speedups: FASTCODER achieved up to 2.54x speedup compared to standard decoding and outperformed state-of-the-art methods like REST by up to 88%.
- Zero Quality Loss: Because the target LLM verifies every token, the functional correctness (Pass@1) remains identical to the original model.
- Resource Efficiency: The system is remarkably lightweight, using less than 1/10th the memory of previous retrieval-based methods and requiring no additional training or draft models.
Discussion and Insights
A core insight of this work is the "Localness" Advantage. Code is highly repetitive; variable names and internal APIs used recently are likely to reappear. By caching these local successes, FASTCODER achieves higher "acceptance lengths" than general-purpose accelerators. Furthermore, by recognizing the "rhythm" of code—specifically that indentation and line starts are difficult to predict—the system avoids wasted computation at low-probability retrieval points.
While highly effective for models in the 1B to 13B parameter range, future work will explore scaling to 70B+ parameter models and implementing real-time datastore updates for fast-moving development environments.
Summary updated