{"id": "http://arxiv.org/abs/2506.20639v2", "title": "DiffuCoder: Understanding and Improving Masked Diffusion Models for Code Generation", "abstract": "Diffusion large language models (dLLMs) are compelling alternatives to autoregressive (AR) models because their denoising models operate over the entire sequence. The global planning and iterative refinement features of dLLMs are particularly useful for code generation. However, current training and inference mechanisms for dLLMs in coding are still under-explored. To demystify the decoding behavior of dLLMs and unlock their potential for coding, we systematically investigate their denoising processes and reinforcement learning (RL) methods. We train a 7B dLLM, \\textbf{DiffuCoder}, on 130B tokens of code. Using this model as a testbed, we analyze its decoding behavior, revealing how it differs from that of AR models: (1) dLLMs can decide how causal their generation should be without relying on semi-AR decoding, and (2) increasing the sampling temperature diversifies not only token choices but also their generation order. This diversity creates a rich search space for RL rollouts. For RL training, to reduce the variance of token log-likelihood estimates and maintain training efficiency, we propose \\textbf{coupled-GRPO}, a novel sampling scheme that constructs complementary mask noise for completions used in training. In our experiments, coupled-GRPO significantly improves DiffuCoder's performance on code generation benchmarks (+4.4\\% on EvalPlus) and reduces reliance on AR bias during decoding. Our work provides deeper insight into the machinery of dLLM generation and offers an effective, diffusion-native RL training framework. https://github.com/apple/ml-diffucoder.", "published_at": "2025-06-25T17:35:47+00:00", "source_updated_at": null, "source_url": "https://arxiv.org/abs/2506.20639v2", "source_hash": "f9a4a800c7325516567c46336471af7cca9394ec2995a0190a2f812910edd45f", "source_version": "v2", "full_text_available": true, "evidence_kind": "full_text_excerpt", "analysis_scope": "full_text_excerpt", "scope": "core", "topics": ["discrete-diffusion", "post-training", "code-generation"], "code_url": "https://github.com/apple/ml-diffucoder", "has_code": true, "indexable": true, "authors": [], "related_ids": ["http://arxiv.org/abs/2609.00495v1", "http://arxiv.org/abs/2608.30922v1", "http://arxiv.org/abs/2608.20123v1"], "related_work": {"version": "related-work-v1", "status": "not_assessed", "reason": "missing_context", "items": []}, "review": null, "full_text_brief": null, "explanations": {}, "resources": {"version": "paper-resources-v1", "source_hash": "f9a4a800c7325516567c46336471af7cca9394ec2995a0190a2f812910edd45f", "evidence_kind": "full_text_excerpt", "availability": "not_checked", "limited": true, "items": [{"origin": "source_excerpt", "evidence": "nts, coupled-GRPO significantly improves\nDiffuCoder’s performance on code generation benchmarks (+4.4% on EvalPlus)\nand reduces reliance on AR bias during decoding. Our work provides deeper insight\ninto the machinery of dLLM generation and offers an effective, diffusion-native\nRL training framework. https://github.com/apple/ml-diffucoder\n\n(start)\n(middle)\n(end)\n\nGeneration order\n\n### Base Models\n\n### Instruct Models\n\n(a)\n(b)\n(c)\n\nFigure 1: (a) A real example of DiffuCoder-Instruct’s decoding process with sampling temperature\n1.2. (b) Results on coding benchmarks. (c) When decoding steps are halved, DiffuCoder-Instruct\ntrained with c", "url": "https://github.com/apple/ml-diffucoder", "kind": "code", "span": [1668, 2308], "evidence_hash": "e6e8b948d50aff05dbe7d55b0f41094725a7c8e8a8a7ee9ef6740940ff5cffb5"}, {"origin": "source_excerpt", "evidence": "ared to Qwen2.5-Coder+SFT, which achieves large improvements from being\ninstruct-tuned on the same data.\n\nThis improvement gap between AR and dLLMs at the instruction-tuning stage motivates us to explore\nRL-based post-training methods (§5). Previous RL approaches for diffusion models (Zhao et al.,\n\n1https://github.com/huggingface/open-r1\n2https://openai.com/index/gpt-4o-system-card/\n3https://chat.inceptionlabs.ai/\n4https://deepmind.google/models/gemini-diffusion/\n\n4\n\n## Page 5\n\nTable 1: Benchmark coding capacities of LLMs and dLLMs in 7/8B scale. Different shaded colors\nindicates different generation paradigms (pink for AR, yellow f", "url": "https://github.com/huggingface/open-r1", "kind": "code", "span": [15411, 16051], "evidence_hash": "489b60010d8196e9372d71fb56f57c1cd9d9d82818736720e03ef576170d43fd"}]}, "slug": "2506.20639-diffucoder-understanding-and-improving-masked-diffusion-models-for-code-generation"}