Abstract
Diffusion-based language models (DLLMs) offer non-sequential, block-wise generation and richer data reuse compared to autoregressive (AR) models, but existing code DLLMs still lag behind strong AR baselines under comparable budgets. We revisit this setting in a controlled study and introduce Stable-DiffCoder, a block diffusion code model that reuses the Seed-Coder architecture, data, and training pipeline. To enable efficient knowledge learning and stable training, we incorporate a block diffusion continual pretraining (CPT) stage enhanced by a tailored warmup and block-wise clipped noise schedule. Under the same data and architecture, Stable-DiffCoder overall outperforms its AR counterpart on a broad suite of code benchmarks. Moreover, relying only on the CPT and supervised fine-tuning stages, Stable-DiffCoder achieves stronger performance than a wide range of ~8B ARs and DLLMs, demonstrating that diffusion-based training can improve code modeling quality beyond AR training alone. Moreover, diffusion-based any-order modeling improves structured code modeling for editing and reasoning, and through data augmentation, benefits low-resource coding languages.
Introduction
Most contemporary Large Language Models (LLMs) are autoregressive, predicting code tokens sequentially from left to right. However, human programming is inherently non-linear, involving frequent jumps, infilling, and logic adjustments based on subsequent context. Diffusion-based language models (DLLMs) are theoretically better suited for these tasks as they can generate text in any order and "denoise" entire blocks of code simultaneously. Despite this potential, previous code DLLMs have consistently lagged behind standard AR models when constrained by similar data and compute budgets. Stable-DiffCoder addresses these challenges by introducing a stable training pipeline that bridges the performance gap.
Methodology
Stable-DiffCoder utilizes the architecture and data pipeline of the Seed-Coder AR model but adopts a novel training paradigm centered on stability and knowledge transfer.
The AR-to-Diffusion Pipeline
A key innovation is the "AR-to-Diffusion" training curriculum. Research indicates that AR training is highly efficient at capturing initial linguistic and structural knowledge. Stable-DiffCoder begins with an AR checkpoint and transitions to block diffusion. This approach leverages the strengths of both paradigms: AR for initial knowledge compression and diffusion for refining non-linear structures and enabling any-order generation.
Block Diffusion and Noise Scheduling
The model employs block diffusion (typically with a size of 4), focusing on diffusing contiguous blocks of tokens to maintain local context. To ensure training stability, a tailored warmup phase starts with low corruption and gradually increases task difficulty. Furthermore, a block-wise clipped noise schedule ensures that at least one token is masked in every block, maximizing training efficiency and preventing wasted computation steps.
Experimental Results
Stable-DiffCoder underwent Continual Pretraining (CPT) on 1.3 trillion tokens of code data and was evaluated across a comprehensive suite of benchmarks covering generation, reasoning, multilingual capabilities, and editing.
Performance Comparison
Stable-DiffCoder-8B demonstrates superior performance compared to its AR ancestor and other competitive models. On HumanEval+, the instruct version achieved a score of 82.3, surpassing Seed-Coder-8B's 78.7. It also shows significant gains in complex benchmarks like BigCodeBench (Hard), scoring 31.8, which is remarkably high for an 8B-parameter model.
Multilingual and Editing Advantages
Diffusion training acts as a powerful form of data augmentation. This is particularly beneficial for low-resource languages like C# and PHP, where Stable-DiffCoder showed a nearly 4% average improvement over AR baselines. Its any-order modeling capability also provides a natural advantage in code editing and structured reasoning tasks, where the logic required to solve a problem may appear both before and after the target code segment.
Conclusion
Stable-DiffCoder establishes diffusion models as a competitive alternative to the autoregressive standard for code generation. By combining an AR-first curriculum with stable block diffusion techniques, it achieves state-of-the-art results for its scale. Future work will explore scaling this curriculum to larger models and broader domains beyond programming.
Summary updated