← Back to Computation and Language
cs.CL

Steering code generation toward working programs with constraints

Lize Shao, Michael Cardei, Zichen Xie, Ferdinando Fioretto, Wenxi Wang

May 16, 2026

Code generation via discrete diffusion iteratively refines token sequences, exposing intermediate program states where constraints can be enforced. This paper introduces Constrained Diffusion for Code (CDC), a training-free framework that integrates constraint satisfaction into the denoising process using mathematical optimization and program analysis. CDC identifies constraint-relevant regions in intermediate programs and locally adjusts the generation trajectory to steer toward feasible outputs. On code generation benchmarks, CDC improves constraint satisfaction across functional correctness, security, and syntax metrics, outperforming both discrete diffusion and autoregressive baselines with fewer corrective edits.
Published as Constrained Code Generation with Discrete Diffusion arXiv:2605.16829
Read the original paper →