Source-linked AI summary

Diff Diffusion: Predicting Edit Paths with Diffusion Models for Efficient Code Editing

Xiaolong Xu, Hao Jiang, Bo Jiang, Zhiwen Deng, Ningyuan Sun, Bingzhou Chen, Jin Chen, Chenxing Wei

arXiv:2610.17831v1cs.SEcs.AIcs.CL

TL;DR

IDE edit prediction must anticipate sparse, context-dependent code changes, a mismatch for diffusion models that regenerate sequences. Diff Diffusion predicts structured edit paths and combines multi-stage training with parallel decoding; evaluations report accuracy and latency improvements, including a 39.0% reduction in production P50 model inference latency.

  • Problem

    Current diffusion LMs mainly regenerate sequences, whereas real-time IDE edit prediction requires sparse, context-dependent changes based on edit history, the current file, and cursor-local context.

    Source: §1 · p. 2
  • Method

    Diff Diffusion models source-conditioned edit paths as structured operations and combines multi-stage training with parallel decoding for IDE code edits.

    Source: §1 · p. 2
  • Results

    Across public benchmarks, edit-prediction evaluations, and production validation, Diff Diffusion improves accuracy and latency; production P50 model inference latency is reduced by 39.0%.

    Source: §1 · p. 2, §4.5 · p. 8
  • Takeaways & Limitations

    For IDE edit prediction, aligning diffusion with locality, incrementality, and context dependence offers advantages over autoregressive methods in skipping unchanged tokens, parallel edits, and inference latency.

    Source: §5 · pp. 8–9

    The evaluation focuses on latency-critical IDE edit prediction, and the paper does not yet provide a deeper theoretical analysis of edit-path diffusion.

    Source: §5 · p. 9

Abstract

from arXiv · show

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.

1 Introduction

Diffusion LMs offer parallel code generation, but sequence-regeneration objectives mismatch sparse, context-dependent IDE edits. Diff Diffusion predicts structured edit paths from source to revision and is evaluated on public and production settings.

1 Introduction

  • IDE edit prediction requires changes inferred in real time from edit history, the current file, and cursor-local context, while existing approaches regenerate unchanged sequences or serialize them.Prior discrete-diffusion and flow-matching work discusses insertion, modification, and deletion, but not source-conditioned edit-path diffusion for latency-critical editing.Source: §1 · p. 2
  • Diff Diffusion predicts the edit operations that transform an original code snippet into its revision, focusing computation on local updates instead of regenerating unchanged code.The framework models edit paths within diffusion and targets low-latency inference.Source: §1 · p. 2
  • The IDE formulation uses same, delete, insert, replace, and mask-to-token actions to skip unchanged code and support modifications at multiple positions in parallel.Source: §1 · p. 2
  • A multi-stage training paradigm and efficient parallel decoding strategy are designed to support accurate, fast inference.Source: §1 · p. 2
  • Evaluations on public benchmarks, edit-prediction tasks, and production validation demonstrate improvements in accuracy and latency.Source: §1 · p. 2

2 Diff Diffusion

Diff Diffusion replaces full-sequence reconstruction with source-conditioned edit-path prediction for IDE code changes. Its multi-stage training moves from commit-level edits to interactive edit prediction and post-training over denoising transitions.

2 Diff Diffusion

  • Diff Diffusion initializes from a masked-diffusion backbone, then changes the denoising target from full-sequence reconstruction to an edit path.The backbone transfers denoising ability before specialization for edit-path prediction.Source: §2 · p. 2, §2.2 · p. 4

2.1 Diff-Based Diffusion Process

  • The diff-based process predicts keep, delete, insert, replace, and mask-filling actions, applying them iteratively to transform source code into a revised snippet.The process supports parallel edits at multiple positions and variable-length output, with fewer steps when edits preserve most source tokens.Source: §2.1 · p. 3
  • Training weights edit-action labels to address their rarity and samples initial, target, and intermediate states with different probabilities.Intermediate states are constructed using LCS alignment.Source: §2.1 · p. 3

2.2 Multi-Stage Diffusion Learning

  • Training progresses from multi-language commit diffs to IDE-format supervised fine-tuning, then preference and reinforcement learning over denoising transitions.Stage III includes Diff-DPO and AGRPO; Diff-DPO compares ground-truth targets with erroneous model-sampled edits, while AGRPO optimizes over sampled diffusion steps using trajectory-level reward.Source: §2.2 · pp. 4–5

3 Inference and Infrastructure

The inference system targets high-volume IDE edit prediction by reducing edit iterations and translating that reduction into end-to-end latency gains. It combines block-wise parallel editing with cache reuse for stable context and unchanged suffixes.

3 Inference and Infrastructure

  • The dedicated inference engine targets high-volume IDE requests by reducing edit iterations and translating that reduction into end-to-end latency gains.Its system design combines block-wise parallel decoding, approximate KV-cache reuse, and system-level optimization.Source: §3 · p. 5

3.1 Block-wise Parallel Edit Decoding

  • Block-wise decoding applies high-confidence edits in parallel within local blocks, using unchanged source tokens as anchors for edit boundaries.Adaptive insertion length lets a confident insertion emit several consecutive tokens in one action.Source: §3.1 · p. 5

3.2 Approximate KV-Cache in Editing Scenarios

  • Approximate KV-cache reuse preserves stable request prefixes and converged blocks, and reuses suffix states after RoPE position correction for long-sequence edits.The suffix strategy targets local edits with long unchanged suffixes and is reported to preserve accuracy while providing latency gains.Source: §3.2 · p. 6

4 Experiments

The experiments test public edit completion, IDE-specific edit prediction, inference latency, and production transfer against autoregressive and diffusion baselines. Diff Diffusion preserves comparable recommendation quality while reducing latency, including in online validation.

4 Experiments

  • The experiments assess public edit-completion patterns, post-training effects on IDE metrics, parallel-decoding latency, and transfer to production traffic, using a production AR baseline and Mercury-Coder for IDE comparisons.The AR baseline receives the same recent-edit history, file context, and edit range, then generates left to right.Source: §4 · p. 6

4.1 Data and Evaluation Setup

  • The evaluation data includes CommitPack for Stage I pretraining, edit-prediction data for Stage II and III post-training, C3PO for open edit completion, and an IDE-behavior evaluation set.The edit-prediction set covers five behaviors: Act, Stay, Multi-line, Roll-back, and Delete.Source: §4.1 · p. 6, §4.3 · p. 7

4.2 Open Edit-Completion Benchmark

  • C3PO tests prediction of the remaining edit from contextual edits and reports result accuracy, average decoding steps, and average inference time per sample.This benchmark targets structured edit patterns rather than token-level continuation alone.Source: §4.2 · p. 6
  • Diff Diffusion achieves 81.33% result accuracy, close to AR, while cutting decoding steps from 14.62 to 3.90 and inference time from 403 ms to 145 ms per sample, a 2.78× speedup.The C3PO training set is relatively small, which the authors note in discussing the accuracy gap.Source: §4.2 · p. 6, Table 1 · p. 6

4.3 IDE Edit-Prediction Evaluation

  • The base model after CT improves over Mercury-Coder on all five IDE metrics, matches AR on Multi-line, and reduces Roll-back and Delete; AGRPO reaches 50.00% Act and 96.40% Stay while keeping Delete at 0.5%.SFT raises Act to 49.18% and Multi-line to 73.68%, while DPO improves Stay and keeps Roll-back low.Source: §4.3 · p. 7, Table 2 · p. 7

4.4 Inference Latency

  • For a 140-token rewrite range, diffusion decoding reduces generation from 126 AR steps to about five edit steps and total time from 3964 ms to about 415–420 ms.On the 1024-token long-rewrite setting, approximate suffix-cache reuse through PIE lowers total time from 784 ms to 676 ms; it does not help the short case.Source: §4.4 · p. 7, Table 3 · p. 8

4.5 Online Validation

  • Diff Diffusion keeps acceptance rate and CPO comparable to AR, increases accepted lines per user by 9.6%, and reduces P50 model inference latency by 39.0%.The latency advantage holds across different edit sizes.Source: §4.5 · p. 8, Table 4 · p. 8

5 Discussion

Diff Diffusion’s discussion attributes its advantages to aligning with edit prediction’s locality, incrementality, and context dependence, while identifying theoretical analysis and broader editing settings as open work.

5 Discussion

  • Figure 3 presents latency by edit-distance bucket.Source: Figure 3 · p. 8
  • The discussion links Diff Diffusion’s advantages over autoregressive methods to aligning with edit prediction’s locality, incrementality, and context dependence.The cited discussion describes those advantages as skipping unchanged tokens, modifying multiple positions in parallel, and reducing inference latency.Source: §5 · pp. 8–9
  • The study has not yet developed a deeper theoretical analysis, and its evaluation focuses on latency-critical IDE edit prediction.Future work would extend the framework to instruction-guided editing, repository-level changes, and agent workflows.Source: §5 · p. 9

A Related Work

Related work covers diffusion language models, code models, and code-editing benchmarks; Diff Diffusion focuses on edit-path modeling and its system-level benefits for low-latency tasks.

A Related Work

  • Diffusion language models support parallel token updates, and insertion and deletion operations have become an important modeling direction.Diff Diffusion focuses on edit paths from original to target snippets; Table 5 presents representative dLLMs with edit operations.Source: A Related Work · p. 13, Table 5 · p. 13
  • Diffusion-based code models have emerged alongside autoregressive code LLMs, with proprietary and open-source systems showing competitive code-task performance [18] [38] [12] [45].Source: A Related Work · pp. 13–14
  • Code-editing evaluations span function- and file-level benchmarks as well as repository-level evaluations.Examples include C3PO, APEval, CanItEdit, CodeEditorBench, Aider, HumanEvalFix, CoEditor, and SWE-bench.Source: A Related Work · p. 14

B Data Statistics

The section identifies a table of training and evaluation data and documents licenses or service terms for several assets.

B Data Statistics

  • Table 6 presents training and evaluation data.Source: Table 6 · p. 14
  • Asset terms include MIT licenses for CommitPack, C3PO, and the AR baseline; Dream-Coder uses Apache-2.0, while Mercury-Coder is accessed via hosted API terms.Source: B Data Statistics · p. 14

C Training and Inference Hyperparameters

Training uses weighted edit-label cross-entropy and shared optimization settings, followed by Diff-DPO or AGRPO post-training; inference uses fixed context, generation, and iteration limits.

C Training and Inference Hyperparameters

D Online A/B Experiment Setup

The online A/B experiment compared the AR baseline with Diff Diffusion in an existing IDE edit-prediction feature. Users were assigned to persistent groups under the same user-facing configuration, and aggregate metrics were computed over valid impressions and successful requests.

D Online A/B Experiment Setup

Loading 2610.17831v1…