arXiv:2610.27600cs.CLOct 2026

Manuscript Offprint

arXiv:2610.27600

Self-Decomposing Diffusion for Code Generation

Lize Shao, Zichen Xie, Zhizhen Chen, Zhe Zeng, Wenxi Wang

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Lize Shao

University of Virginia

zgr3et@virginia.edu

Zichen Xie

University of Virginia

graysonxie@virginia.edu

Zhizhen Chen

University of Virginia

bpm6gu@virginia.edu

Zhe Zeng

University of Virginia

zhez@virginia.edu

Wenxi Wang

University of Virginia

wenxiw@virginia.edu

ABSTRACT

Diffusion language models (DLMs) are emerging as a promising paradigm for code generation, offering the potential for fast, parallel decoding. However, generating complex programs remains challenging, as their interdependent components must maintain consistent interfaces, data flows, and shared assumptions. Aggressive parallel decoding can compromise these dependencies and undermine program correctness, while conservative decoding sacrifices efficiency. To address this trade-off, we propose planning program decomposition before implementation to coordinate interdependent units during parallel generation. We introduce Self-Decomposing Diffusion for Code (SDDC), a novel framework that decomposes complex programs and implements their units in parallel, entirely through diffusion. SDDC first generates a contract specifying the program's decomposition and inter-unit dependencies, then uses it to guide coordinated parallel implementation. Across five benchmarks and two 7B diffusion backbones, SDDC substantially improves the accuracy–latency trade-off, raising pass@1 by up to 31.1 percentage points while decoding 7.5–13.7× faster than the base models, and outperforming a fine-tuning baseline by up to 23.5 points with lower latency.

(a) Accuracy ↑\uparrow

(b) Latency ↓\downarrow

Figure

Figure 1: SDDC is more accurate and faster. Dream-Coder 7B on the program-level benchmarks of Table 1: (a) pass@1 (test pass rate on ClassEval and ClassEval-Pro); (b) latency per problem and speedup over Vanilla.

1 Introduction

Language models are proficient at function-level programming, yet generating complete programs remains difficult: the methods, helper functions, and class headers of a program must be mutually consistent in their identifiers, interfaces, and shared state, and an error in any single unit invalidates the entire program. Models therefore perform far worse on

Figure

Figure 2: Overview of SDDC on a held-out KodCode task (abridged and adapted from the model's output). (1) Contract synthesis denoises entries that give a budget, an index, a role, and the identifiers that each unit defines (def) and requires (use). (2) Canvas instantiation fixes each entry's header hkh_k at the start of its canvas. (3) Coupled unit decoding denoises all canvases jointly; they also coordinate a decision that the contract leaves open, nesting both helpers inside sudoku_solver, whose final return the third canvas writes (highlighted). (4) Program assembly removes headers and padding and concatenates the units.

class-level than on function-level benchmarks [1, 2, 3], and the strongest model evaluated on ClassEval-Pro completes fewer than half of its classes [4].

A standard approach to such tasks, analogous to human software development, is to decompose a problem into subproblems and to plan their implementation before writing code. Planning has accordingly been widely adopted for code generation with autoregressive models, which outline solution steps or subfunctions before implementing them [5, 6, 7, 8, 9] or plan dependent edits across a repository [10]. Diffusion language models can commit multiple tokens in a single forward pass [11, 12, 13, 14], yet planning with them remains largely unexplored. Such planning by diffusion language models is especially valuable for code, whose units interact through explicit interfaces. A plan that specifies these interfaces in advance guides the reasoning about decomposition, improves consistency across units, and enables their parallel generation. Current diffusion code models decode programs without such a plan, so committing many tokens at once introduces inconsistencies across units [15, 16].

Recent work combines planning and diffusion with autoregressive decoding to accelerate generation. Building on parallel generation of semantically independent text spans with autoregressive models [17, 18], Planned Diffusion [19] autoregressively generates a plan of chunk topics and lengths, then denoises the planned chunks in parallel, whereas ReFusion [20] selects slots by diffusion and fills them autoregressively. However, these methods are not designed to coordinate interdependent program units, and both retain an autoregressive stage that limits end-to-end parallelism.

We introduce Self-Decomposing Diffusion for Code (SDDC), which aims to improve both accuracy and decoding latency in complex code generation (Figure 2). Our approach combines two complementary ideas: decomposition enables parallel implementation by dividing a program into interacting units, while a contract promotes consistency by specifying these units and the interfaces between them. SDDC first denoises the contract, then implements all units in parallel, binding each unit to its contract entry and coordinating them through cross-unit attention. Both stages are performed entirely by diffusion; to our knowledge, SDDC is the first approach that plans the generation of complex, multi-unit programs with a diffusion model.

Across five program-level and self-invoking benchmarks and two 7B diffusion backbones, SDDC improves pass@1 over Vanilla by up to 31.1 points while decoding 7.5–13.7×7.5–13.7\times faster (Figure 1), and outperforms the Diffusion SFT baseline by up to 23.5 points. Our contributions are as follows:

• Self-decomposing diffusion. We formulate complex code generation as diffusion over an explicit program decomposition: a contract specifying program units and their interfaces, which the model learns to generate from static-analysis supervision.

• Contract-bound coupled decoding. We use the generated contract to guide joint denoising of interdependent program units, enabling parallel implementation while improving accuracy and cross-unit consistency.

• Improved latency–quality trade-off. SDDC advances the latency–quality frontier of diffusion code generation, and ablations confirm the contribution of each of its components.

References (46)