cs.SESep 29, 2026

How Should Diffusion Language Models Edit Code?

Authors: Xijia Tao, Ziru Liu, Shansan Gong, Jiacheng Ye, Kecheng Chen, Zirui Wu, Lin Zheng, Xinyu Fu, +2 more

Organizations: The University of Hong Kong · Huawei Technologies Ltd. · City University of Hong Kong · Peking University

Abstract

Code editing requires a model to decide where to make changes, generate the new content, and preserve everything else. We study how masked diffusion language models divide these responsibilities across four editing interfaces: whole-file rewriting, search-and-replace, locate-then-infill, and token-level editing. Experiments on CanItEdit reveal a composition gap: diffusion models can generate coordinated changes when the correct edit locations are supplied, but much of this capability is lost when those locations must be predicted. Access to the intact original code helps the model fill multiple edit regions, yet does not resolve the difficulty of selecting those regions. By varying the editable regions while holding the generation model and decoding procedure fixed, we identify two distinct requirements for successful editing: covering every required change and placing precise boundaries around it. Missing a required region prevents the corresponding change, while widening regions to ensure coverage can sharply reduce success by requiring unchanged code to be regenerated. A sentence-level Wiki editing probe shows the same qualitative gap between supplied and predicted locations beyond code. These findings show why strong infilling capability alone does not ensure reliable editing: the interface must expose all required changes while limiting regeneration of unchanged code.

Figures & tables

Appendix figures & tables50 assets

Supplementary material from the paper’s appendix.

Appendix

Explore similar work

CardsList
  1. Knowledge Editing for Masked Diffusion Language Models

    Jun 2, 2026Haewon Park, Yohan JoMultimodal Knowledge EditingMasked Diffusion Language Models

  2. CROCODIL: Cross-Model Code Editing with LLMs

    Sep 3, 2026Linghan Zhong, Aditya Thimmaiah, Jayanth Srinivasa +2Strong Large Language Model

  3. When Models Edit Too Much: On the Fidelity of Minimal Code Edits

    Sep 3, 2026Tongyao Zhu, Wei Hern Lim, Min-Yen KanCode QualityEdit