Diff Diffusion:使用扩散模型预测编辑路径以实现高效代码编辑
研究论文 · 2026/10/15
扩散大语言模型(dLLMs)在代码生成中具有吸引力,因为它们可以并行更新多个标记,但许多模型针对序列合成而非编辑预测进行了优化。这种设置与现代AI辅助IDE不太匹配,因为编辑预测必须从最近的编辑、当前文件和光标局部上下文中推断下一个代码更改。此类更改通常稀疏且保留大部分源标记,因此重新生成整个代码段会浪费计算。我们提出了Diff Diffusion,一种受扩散启发的LLM框架,用于代码编辑,预测从原始代码片段到其修订形式的编辑路径。Diff Diffusion将去噪表示为结构化编辑操作,并将此公式与多阶段训练和高效并行解码相结合。通过将计算集中在更改区域,Diff Diffusion支持准确的低延迟编辑和多位置并行修改。在公共编辑完成基准、编辑预测评估和在线验证中,Diff Diffusion匹配或领先自回归基线,同时在公共编辑完成基准上实现2.78倍的推理速度提升,并在生产环境中将P50模型延迟降低39.0%。这项工作为需要高准确性和低延迟的AI应用提供了新的建模视角。
该工作为需要高准确性和低延迟的AI辅助代码编辑提供了新的建模视角,并在实际生产环境中显著降低了延迟,具有很高的实用价值。
Diffusion large language models (dLLMs) are appealing for code generation because they can update many tokens in parallel, yet many are optimized for sequence synthesis rather than edit prediction. This setting is poorly matched to modern AI-assisted IDEs, where edit prediction must infer the next code change from recent edits, the current file, and cursor-local context. Such changes are usually sparse and preserve most source tokens, so regenerating a full code segment wastes computation. We propose Diff Diffusion, a diffusion-inspired LLM framework for code editing that predicts edit paths from an original snippet to its revised form. Diff Diffusion represents denoising as structured edit operations, and combines this formulation with multi-stage training and efficient parallel decoding. By focusing computation on changed regions, Diff Diffusion supports accurate low-latency edits and multi-position parallel modification. Across public edit-completion benchmarks, edit-prediction evaluations, and online validation, Diff Diffusion matches or leads autoregressive baselines while delivering 2.78 times faster inference on public edit-completion benchmarks and a 39.0% P50 model-latency reduction in production. This work provides a new modeling perspective for AI applications that require high accuracy and low latency.