NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Dream-Coder 7B: An Open Diffusion Language Model for Code

Zhihui Xie, Jiacheng Ye, Lin Zheng, Jiahui Gao, Jingwei Dong, Zirui Wu, Xueliang Zhao, Shansan Gong, Xin Jiang, Zhenguo Li, Lingpeng KongarXiv 2025 · OpenReview

Abstract

We present Dream-Coder 7B, an open-source discrete diffusion language model for code generation that exhibits emergent any-order generation capabilities. Unlike traditional autoregressive (AR) models that decode strictly left-to-right, Dream-Coder 7B adaptively determines its decoding strategy based on the coding task: sketch-first generation for complex algorithms, left-to-right generation for straightforward completions, and interleaved reasoning generation for code understanding tasks. We adapt a pretrained AR checkpoint to a discrete diffusion framework with a continuous-time weighted cross-entropy objective. Our post-training recipe comprises (i) supervised fine-tuning, where we mitigate padding pathologies via random truncation and a padding penalty to improve sample efficiency and stabilize generation; and (ii) reinforcement learning with verifiable rewards over a curated high-quality prompt set drawn from open-source datasets, using a tailored reinforcement learning recipe for diffusion language models. The resulting Dream-Coder 7B Instruct attains 21.4% pass@1 on LiveCodeBench (2410–2505) and demonstrates competitive performance on HumanEval, MBPP, BigCodeBench, and CRUXEval.

Introduction

The current landscape of Large Language Models (LLMs) for code is dominated by autoregressive (AR) architectures. While highly effective, AR models are constrained by a unidirectional, left-to-right decoding process. This constraint is fundamentally different from human programming behavior, which often involves iterative refinement, jumping between different parts of a file, and filling in templates.

Dream-Coder 7B addresses this gap by utilizing a discrete diffusion framework. By treating code generation as a denoising process—starting from a sequence of mask tokens and iteratively refining them—the model enables "any-order" generation. This flexibility allows the model to naturally handle tasks like refactoring, debugging, and global structural planning that are challenging for traditional AR models.

Methodology

Dream-Coder 7B is initialized from the Qwen2.5-Coder 7B autoregressive model. Using a "shift operation" strategy, the model is adapted into a discrete diffusion framework, allowing it to leverage massive pre-trained knowledge while gaining bidirectional context capabilities.

Training Objectives

The model employs a continuous-time diffusion framework with a weighted cross-entropy objective. This approach provides a more flexible noise schedule compared to discrete-step diffusion, facilitating better learning of the denoising process.

Post-Training Refinements

To optimize the model for code generation, two key post-training stages were implemented:

  1. Supervised Fine-Tuning (SFT): The authors identified "padding pathologies" where models struggle with empty spaces in batches. To mitigate this, they introduced Random Truncation of inputs and a Padding Penalty during training. These techniques significantly improve sample efficiency and stabilize the generation process.
  2. Reinforcement Learning (RL): The model underwent RL using Group Relative Policy Optimization (GRPO). The reward signal is derived from verifiable unit tests, ensuring the model prioritizes functional correctness.
Data augmentation via random truncation and the resulting performance gains from the padding penalty.

Inference Acceleration

To address the latency typically associated with iterative diffusion decoding, the authors integrated Fast-dLLM, an acceleration technique that optimizes the denoising steps during inference.

Data and Evaluation

The model's training data consists of a 322B token mixture including:

  • Code & Math: High-quality datasets like OpenCoder, Stack-Edu, and curated RL prompts (17k) with unit tests.
  • General Language: DCLM-Baseline data to preserve natural language reasoning capabilities.

Evaluation was conducted on standard benchmarks including HumanEval, MBPP, EvalPlus, and BigCodeBench. Crucially, the model was tested on LiveCodeBench (2410–2505) to assess performance on recent, uncontaminated problems.

Emergent Generation Patterns

A significant finding of Dream-Coder 7B is the emergence of distinct generation strategies without explicit programming:

  • Sketch-First Scaffolding: For complex algorithms, the model often generates high-level structures (e.g., function signatures, loop headers) before filling in the internal logic.
  • Left-to-Right: For simple, linear tasks, it naturally defaults to standard sequential generation.
  • Interleaved Reasoning: For logic-heavy problems, it generates critical conditions and reasoning steps first, then fills in the supporting code.

Results

Dream-Coder 7B Instruct demonstrates state-of-the-art performance among open-source diffusion models:

  • LiveCodeBench: Achieved 21.4% pass@1, matching or exceeding several established AR models.
  • HumanEval: Reached 82.9%, a substantial improvement over previous diffusion baselines like Dream-7B (63.4%).
  • Mathematical Reasoning: Showed a significant leap on GSM8K, reaching 71.1% (up from 51.8% in prior versions).

Conclusion and Future Work

Dream-Coder 7B proves that discrete diffusion models can achieve performance parity with top-tier autoregressive models in the coding domain while offering superior flexibility. Future research will focus on extending the context window for multi-file projects, further refining RL data curation, and enhancing the model's high-level planning and agentic capabilities.

Summary updated

BibTeX
@misc{xie2025dream,
  author = {Zhihui Xie and Jiacheng Ye and Lin Zheng and Jiahui Gao and Jingwei Dong and Zirui Wu and Xueliang Zhao and Shansan Gong and Xin Jiang and Zhenguo Li and Lingpeng Kong},
  title = {{Dream-Coder 7B: An Open Diffusion Language Model for Code}},
  year = {2025},
  eprint = {2509.01142},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.01142},
}
Figure