potentialpaper

Constrained Code Generation with Diffusion Language Models

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

NeurIPS 2026

Edit this page

Or clone it with git

Run in a terminal:

Needs Git LFS. To push, use an API key from your profile as the password.

Or let your agent set it up

It checks and sets up everything: signing in, git, the clone, credentials and an SSH key.

Abstract. Diffusion language models (DLMs) are a powerful, emerging paradigm for code generation. They construct programs through iterative refinement of partially corrupted token sequences and enable parallel token refinement. Importantly, this paradigm exposes a global program state at each denoising step, which provides a natural intervention point for enforcing program-level functionality and security constraints, guiding the generation before the final code is committed. Building on this observation, the paper introduces Constrained Diffusion for Code(CDC), an inference-time neurosymbolic framework that integrates constraint satisfaction directly into the reverse denoising process without retraining the base diffusion model. CDC augments the base diffusion sampler with constraint-aware denoising operators that combine mathematical optimization with program analysis to identify constraint-relevant regions of the intermediate program state and locally adjust the denoising trajectory, steering generation toward feasible programs while remaining close to the base model. Across code generation benchmarks, CDC consistently improves constraint satisfaction in functional correctness, security, and even syntax, outperforming diffusion and autoregressive baselines with less corrective computation and more localized edits.

Are you an author? Claim this paper to see who's reading it, with views and other statistics, and to write about it here.

Claim this paper
How does this paper connect to your work? Write how you built on it, compared with it or reproduced it, or add a summary, a critique or errata.
Or make it interactive:
Start writing

edit · history

DateVersionSubmitted toPDFEvidence
3 May 2026NeurIPS 2026submittedNeurIPS 2026Accept (poster)reviews ↓[1]PDF[1]
Missing a version?

NeurIPS 2026

Accept (poster) · 3 reviews · OpenReview

Updated 25 Nov 2026, 03:50 UTC.

Program Chairs · DecisionOpenReview ↗
Decision
Accept (poster)
Read decision
Meta-review

This paper proposes Constrained Diffusion for Code (CDC), an inference-time framework that uses intermediate program states in discrete diffusion to enforce functional and security constraints. CDC combines localized correction with either a learned surrogate (GradGuide) or static analysis (MDFI). Reviewers agree that the problem is important, the diffusion-based intervention point is well motivated, and the reported gains are promising.

The main concern is that the strongest functional-correctness results depend on the GradGuide surrogate, which is insufficiently characterized. It is unclear how accurately it predicts correctness, how robust CDC is when the surrogate is wrong, and how much of the gain comes from the surrogate rather than the proposed diffusion intervention. Relatedly, the paper should rule out benchmark-specific supervision or train/evaluation overlap in the surrogate data.

The paper also overstates two claims. First, “training-free” is only accurate with respect to the frozen base generator, since GradGuide requires auxiliary model training. Second, edit locality alone does not establish computational efficiency: the method incurs surrogate forward/backward passes, optimization, static-analysis calls, and additional denoising interventions.

For the rebuttal, consider prioritizing:

  1. Provide details and evaluation of the GradGuide surrogate, including training data, accuracy/calibration, and failure behavior when its scores or localization are incorrect.
  2. Clarify whether surrogate training is task-disjoint from HumanEval-X and MBPP and rule out data leakage or benchmark-specific verifier learning.
  3. Report or clarify the actual inference cost, including denoising steps, intervention frequency, latency, memory, and auxiliary-model/analyzer overhead.
  4. Qualify the “training-free” and efficiency claims accordingly.

A convincing response on surrogate validity, data separation, and actual computational cost would significantly improve the case for acceptance.

Final justification

After the rebuttal, all reviewers are positive about the paper. The AC therefore recommends acceptance and encourages the authors to incorporate the additional clarifications and content provided during the rebuttal into the revised version.

Area Chair BLnY · Meta-reviewOpenReview ↗
Read meta-review
Meta-review

This paper proposes Constrained Diffusion for Code (CDC), an inference-time framework that uses intermediate program states in discrete diffusion to enforce functional and security constraints. CDC combines localized correction with either a learned surrogate (GradGuide) or static analysis (MDFI). Reviewers agree that the problem is important, the diffusion-based intervention point is well motivated, and the reported gains are promising.

The main concern is that the strongest functional-correctness results depend on the GradGuide surrogate, which is insufficiently characterized. It is unclear how accurately it predicts correctness, how robust CDC is when the surrogate is wrong, and how much of the gain comes from the surrogate rather than the proposed diffusion intervention. Relatedly, the paper should rule out benchmark-specific supervision or train/evaluation overlap in the surrogate data.

The paper also overstates two claims. First, “training-free” is only accurate with respect to the frozen base generator, since GradGuide requires auxiliary model training. Second, edit locality alone does not establish computational efficiency: the method incurs surrogate forward/backward passes, optimization, static-analysis calls, and additional denoising interventions.

For the rebuttal, consider prioritizing:

  1. Provide details and evaluation of the GradGuide surrogate, including training data, accuracy/calibration, and failure behavior when its scores or localization are incorrect.
  2. Clarify whether surrogate training is task-disjoint from HumanEval-X and MBPP and rule out data leakage or benchmark-specific verifier learning.
  3. Report or clarify the actual inference cost, including denoising steps, intervention frequency, latency, memory, and auxiliary-model/analyzer overhead.
  4. Qualify the “training-free” and efficiency claims accordingly.

A convincing response on surrogate validity, data separation, and actual computational cost would significantly improve the case for acceptance.

Final justification

After the rebuttal, all reviewers are positive about the paper. The AC therefore recommends acceptance and encourages the authors to incorporate the additional clarifications and content provided during the rebuttal into the revised version.

3 comments
Authors · CommentOpenReview ↗

Thank you for the careful and constructive meta-review. We are encouraged that the reviewers recognize the importance of constrained code generation, the motivation for intervening in intermediate diffusion states, the potential impact, and the strong empirical results. We agree that GradGuide and the end-to-end inference pipeline could be described more clearly. To strengthen our response, we conducted a new independent evaluation of the GradGuide surrogate and a complete end-to-end cost analysis for both CDC instantiations. We address all comments below.

1. Provide details and evaluation of the GradGuide surrogate, including training data, accuracy/calibration, and failure behavior when its scores or localization are incorrect.

The surrogate is a Qwen2.5-Coder-1.5B with a frozen backbone, LoRA adapters on the final 12 of 28 layers, and a 4-layer MLP regression head on the last-token hidden state, trained with a soft-label BCE on 59K execution-labeled programs with y=1[compiles]⋅(test-pass ratio)y=\mathbf{1}[\text{compiles}]\cdot(\text{test-pass ratio}), constructed from CodeContests problems. Candidates are generated by Dream, Dream-Coder, and DiffuCoder; GPT-5 is used only when these models fail to produce any correct solution for a problem. All labels are determined by executing them against the corresponding CodeContests tests. The one-time training cost is 1.8 GPU-hours with a single NVIDIA RTX PRO 6000 Blackwell GPU.

Evaluated independently of CDC on frozen base-model candidates, GradGuide is accurate and well-calibrated: Spearman, AUPRC, and ECE scores are 0.848, 0.946, and 0.024, respectively on HumanEval-X and 0.837, 0.960, and 0.030, respectively on MBPP-C++; on held-out problem-disjoint CodeContests data they are 0.921, 0.995, and 0.030. Here, AUPRC and ECE evaluate prediction of complete execution success, while Spearman evaluate ranking by continuous test-pass ratio.

We additionally test failure behavior by replacing the trained surrogate with the non-fine-tuned backbone, whose Spearman correlations are only 0.056/0.117. Within the otherwise identical GradGuide pipeline, this inaccurate surrogate decreases pass@1 by 8.5 and 5.3 percentage points, whereas the trained surrogate increases it by 31.1 and 31.5 percentage points. Thus, downstream performance tracks the independently measured surrogate quality rather than arising from the pipeline regardless of its feedback.

We also isolate localization and intervention quality. As reported in Appendix B.3.2, on HumanEval-X, random editing obtains 34.0%, essentially matching vanilla diffusion (34.1%); the ALM proposal correction alone obtains 40.2%, surrogate-localized adaptive editing alone obtains 50.6%, and their combination obtains 65.2%. Thus, an arbitrary intervention does not help in general: the gains require both informative localization and the proposed diffusion-time correction.

2. Clarify whether surrogate training is task-disjoint from HumanEval-X and MBPP and rule out data leakage or benchmark-specific verifier learning.

The surrogate is trained exclusively on CodeContests, whereas GradGuide is evaluated on HumanEval-X and MBPP, which are not used for surrogate training or model selection. No evaluation prompt, program, unit test, or execution outcome enters surrogate training; labels are produced by executing candidates against CodeContests' own tests. Because this separate dataset provenance alone does not exclude duplicate problems, we also performed overlap checks between CodeContests and both HumanEval-X and MBPP-C++. These checks confirmed that the surrogate-training problems are disjoint from both evaluation benchmarks. The strong results reported above on the two unseen benchmark distributions (Spearman 0.848 and 0.837) provides additional evidence against benchmark-specific verifier learning. We will appropriately present this as evidence of cross-benchmark generalization.

3. Report or clarify the actual inference cost, including denoising steps, intervention frequency, latency, memory, and auxiliary-model/analyzer overhead.

All measurements use the same number and type of GPUs,, numerical precision, and batch size. Both instantiations retain the same 256-step base schedule as their vanilla baselines, so the gains do not come from extra reverse steps. GradGuide adds one surrogate forward-backward pass (48–53 ms) and it performs at least one intervention on 66–84% of samples. It incurs 1.72-2.01× mean latency and 1.41-1.47× median latency, with 53–61% additional peak memory.

MDFI, which performs no gradient optimization, invokes a CPU analyzer at 7 checkpoints (46 ms total), adding only 2.3-6.1% latency and 2.6-4.2% peak memory, while improving successful-output throughput by 1.58-2.79×. The final version will report these scheduled checks, analyzer calls, latency, and memory in a separate table, so it will be easier to find and parse.

Authors · CommentOpenReview ↗

[Part 2/2 (see below)]

4. Qualify the "training-free" and efficiency claims accordingly.

We agree and will qualify both claims throughout. In both instantiations, the base diffusion generator remains frozen. GradGuide nevertheless requires a separately trained surrogate. We will therefore describe it as inference-time guidance without base-generator fine-tuning, rather than broadly characterizing it as training-free. MDFI, instead uses a non-learned analyzer and requires no auxiliary training, thus is indeed qualifies as training-free method.

We will similarly distinguish edit locality. generated-token cost, per-sample latency and memory, and success-normalized cost. Localized editing established that CDC rewrites substantially less code than whole-program regeneration, but does not by itself establish lower end-to-end computation. These claims will be clarified further in the paper.

Authors · CommentOpenReview ↗

Thank you again for the thoughtful meta-review. We worked diligently during the rebuttal period to address every point raised and conducted several new experiments. We believe our responses and additional evidence directly address the key questions highlighted in the meta-review, including surrogate validity and failure behavior, data leakage, component ablations, actual system cost, and appropriate qualification of the training-free and efficiency claims. If any decision-relevant point remains unclear, we would be grateful for the opportunity to clarify it. As we have not yet received further feedback on these results, we hope this new evidence can be fully considered in the final assessment.

Reviewer mDEwOpenReview ↗
Rating
4/6
Confidence
4/5
Quality
3/4
Clarity
3/4
Significance
3/4
Originality
3/4
Contribution type
general
Ethical concerns
NO or VERY MINOR ethics concerns only
Read review
Summary

This paper proposes CDC: Constrained Diffusion for Code, aiming to incorporate constraint feedback into the reverse denoising process of discrete diffusion-based code generation models, thereby improving the generated code's functional correctness, syntactic validity, and security compliance.

The core mechanism works as follows: at each denoising step, the base diffusion denoiser first predicts a clean-state proposal, denoted as x0(t)x_0^{(t)}. CDC then decodes this proposal into an intermediate program, evaluates it using constraint checkers to identify violations, and localizes the corresponding problematic token regions StS_t. Next, a constraint-aware correction operator produces a corrected proposal yty_t. Finally, a constrained reverse kernel is applied to update the noisy state from xtx_t to xt−1x_{t-1}.

The paper instantiates two main correction operators:

  1. GradGuide: Designed for functional correctness and syntactic validity. It trains a surrogate model gϕg_\phi using execution-derived labels to predict a program correctness score. The surrogate gradient is then used to identify high-saliency tokens, followed by KL-anchored proposal correction and constraint-triggered remasking.
  2. MDFI: Designed for security constraints. It employs static program analysis to construct a partial program graph, detects data-flow and structural vulnerability witnesses, and performs localized remasking, mask insertion, and feedback buffer injection on suspicious regions.
Strengths and weaknesses

Strengths:

1. The problem setting is valuable.

Functional correctness and security constraints are critical in code generation. Compared to post-generation repair approaches, the paper proposes intervening directly within the diffusion denoising trajectory, which is a well-motivated perspective. Intermediate states in discrete diffusion naturally provide a global program draft that is more suitable for program-level constraint checking than autoregressive generation.

2. The overall framework is well-structured.

CDC decomposes the process into several stages: clean proposal generation, constraint evaluation, violation localization, proposal correction, and constrained reverse updating. This abstraction is clean and provides a unified framework for incorporating different types of feedback sources, including both GradGuide and MDFI.

3. The idea of localized correction is well justified.

Rather than performing whole-program rewrites, the method first identifies problematic regions StS_t and then applies localized corrections. The use of KL anchoring helps preserve proximity to the original denoiser's prediction, reducing unnecessary modifications and maintaining generation stability.

Weaknesses:

1. The reliability of the surrogate model is the biggest concern.

GradGuide relies on an auxiliary model (gϕg_\phi) to predict a program correctness score. This surrogate is trained on CodeContest-derived C++ execution labels and is then used to guide generation on benchmarks such as HumanEval-X and MBPP. The paper should provide stronger evidence that:

  • The surrogate has learned a notion of general program correctness, rather than merely capturing dataset-specific heuristics.
  • When the surrogate is wrong, its gradient-based saliency signals may steer the model toward incorrect regions, potentially harming generation quality.

2. The "training-free" claim is somewhat misleading.

It is true that CDC does not update the diffusion model parameters (θ\theta). However, GradGuide requires pretraining the surrogate model (gϕg_\phi). Therefore, strictly speaking, the functional-correctness operator is not completely training-free. A more precise characterization would be that CDC is training-free with respect to the base diffusion model or that it performs inference-time intervention without updating (θ\theta). The paper should more carefully distinguish between the genuinely training-free nature of MDFI and the surrogate-trained nature of GradGuide.

3. The method introduces substantial system complexity.

Although the CDC framework is conceptually clear, the actual system includes numerous components, such as surrogate training, gradient-based localization, inner-loop ALM optimization, remasking budgets, checkpoint schedules, static analysis, prompt buffers, and mask insertion mechanisms. Stronger ablation studies are needed to justify the necessity of each component. Otherwise, reviewers may question whether the reported gains primarily stem from extensive task-specific engineering rather than the core methodological contribution.

4. Handling partial or invalid programs may remain fragile.

The paper evaluates constraints on intermediate clean proposals during the denoising process. However, these intermediate programs are often syntactically incomplete or semantically non-executable. GradGuide mitigates this issue through surrogate evaluation, while MDFI constructs partial program graphs using placeholder-based parsing. Nevertheless, it remains unclear whether these mechanisms are robust when applied to more complex programming languages, longer programs, or multi-file codebases.

Questions
  1. If the surrogate score is inconsistent with the true execution outcome, could CDC's correction mechanism significantly degrade performance? Does the paper provide any surrogate calibration or error analysis to evaluate this issue?
  2. How much of CDC's performance improvement comes from the localized gradient-based proposal update, and how much comes from the constraint-triggered remasking mechanism? An ablation study isolating Mode A and Mode B is crucial for understanding their individual contributions.
  3. Is the static analyzer used in MDFI based on hand-crafted rules or a general-purpose analysis framework? Do different CWE categories require different sets of rules? If the analyzer relies heavily on hand-crafted rules, the generality and scalability of the proposed method may be significantly reduced.
Limitations

yes

Final justification

The authors' rebuttal addressed my concern very well, so I’ve decided to raise my rating from 3 to 4.

Formatting concerns

none

4 comments
Authors · CommentOpenReview ↗

We appreciate the reviewer’s constructive feedback, particularly their recognition of the importance of the problem and the benefits of CDC’s targeted corrections during denoising. We respond to their questions below.

W1/Q1. The reliability of the surrogate model is the biggest concern.

We agree that surrogate reliability is important to GradGuide, and we now support it with an independent evaluation of the surrogate. The reviewer raises two specific concerns, which we address in turn: (1) whether the surrogate has learned a general notion of program correctness rather than dataset-specific heuristics, and (2) whether, when the surrogate is wrong, its gradient-based saliency steers generation toward incorrect regions and harms quality. To answer both, we evaluate the surrogate as a standalone predictor of execution outcome, before and after fine-tuning:

Vanilla backbone (Qwen2.5-Coder-1.5B, no fine-tuning):

Dataset MAE ↓ MSE ↓ Spearman ρ\rho ↑ AUPRC ↑ ECE ↓ Guidance Utility ↑ Net Δ\Deltapass@1
HumanEval-X 0.533 0.342 0.056 0.277 0.377 N/A −8.5
MBPP-C++ 0.472 0.262 0.117 0.533 0.163 N/A −5.3
Held-out CodeContests 0.254 0.086 0.581 0.827 0.092 0.723 N/A

Trained GradGuide surrogate:

Dataset MAE ↓ MSE ↓ Spearman ρ\rho ↑ AUPRC ↑ ECE ↓ Guidance Utility ↑ Net Δ\Deltapass@1
HumanEval-X 0.074 0.022 0.848 0.946 0.024 N/A +31.1
MBPP-C++ 0.111 0.051 0.837 0.960 0.030 N/A +31.5
Held-out CodeContests 0.042 0.010 0.921 0.995 0.030 0.933 N/A

(1) Cross-benchmark generalization. The surrogate is trained only on CodeContests [1], yet it predicts execution outcomes accurately on independently generated HumanEval-X [6] and MBPP-C++ [7] programs, different task sources and distributions, with strong ranking and calibration (Spearman 0.848/0.837, AUPRC 0.946/0.960, ECE 0.024/0.030). On held-out CodeContests it reaches Spearman 0.921 / AUPRC 0.995 with Guidance Utility 0.933 where it ranks the better-executing program higher in 93.3% of same-problem, unequal-outcome pairs. This cross-benchmark transfer indicates that the surrogate captures a general notion of functional correctness rather than dataset-specific patterns. Two aspects of the training data reinforce this generality: the labels are ground-truth execution outcomes, i.e. direct supervision on the property of interest; and the candidates come from three different diffusion generators: Dream [2], Dream-Coder [3], and DiffuCoder [4] across four denoising-step settings and four temperatures, plus programs generated from GPT-5 [5], rather than a single generator.

(2) Harm from inaccurate guidance. We directly test this risk by replacing the trained surrogate with the unfine-tuned Qwen2.5-Coder-1.5B backbone in the otherwise identical GradGuide pipeline. This weak evaluator has poor ranking and calibration and decreases pass@1 by 8.5 points on HumanEval-X and 5.3 points on MBPP-C++. In contrast, the trained surrogate increases pass@1 by 31.1 and 31.5 points. This confirms that inaccurate surrogate gradients can harm generation and that the gains are not explained merely by adding an auxiliary model or additional computation. Rather, GradGuide depends on a reliable surrogate together with its gradient-based localization and mid-diffusion correction mechanism. We will add this standalone evaluation and weak-surrogate ablation to the revised manuscript.

W2. The "training-free" claim is somewhat misleading.

We agree with this distinction and will revise the terminology accordingly. We will no longer describe GradGuide as fully training-free, instead, we will state that it performs inference-time constraint intervention without updating the base diffusion model, while relying on a separately trained surrogate. We will also explicitly distinguish this from MDFI, which requires no auxiliary model training.

W3. The method introduces substantial system complexity.

We appreciate the reviewer raising this concern, and want to take the opportunity to clarify that CDC is a modular framework designed to accommodate different classes of constraint signals. The listed components are not all used in every setting: GradGuide uses a learned surrogate, gradient-based localization, and proposal optimization, whereas MDFI uses static analysis, prompt feedback, remasking, and mask insertion. Thus, the apparent complexity reflects two distinct operator instantiations rather than a single pipeline requiring every component. We will revise the presentation to make this modularity clearer.

Authors · CommentOpenReview ↗

[Part 2/2 (see below)]

W4. Handling partial or invalid programs may remain fragile. The paper evaluates constraints on intermediate clean proposals during the denoising process. However, these intermediate programs are often syntactically incomplete or semantically non-executable.

This work evaluates MDFI across five programming languages in CWEval: C, C++, Go, JavaScript, and Python. GradGuide is additionally evaluated on two independently sourced C++ benchmarks, HumanEval-X and MBPP-C++. Together, these results provide evidence that the proposed intermediate-program mechanisms are not limited to a single benchmark, language, or parser. We agree, however, that substantially longer programs and multi-file or repository-level code introduce additional challenges, including incomplete cross-file context and longer-range dataflow dependencies. We will clarify that these settings remain outside the scope of the current evaluation.

Q2. What are the individual contributions of Mode A and Mode B?

We ablate the two correction modes on the same Dream-Coder-7B backbone, evaluation setting, and decoding configuration, holding the surrogate and gradient-based localization fixed and varying the correction operation: Mode A (localized KL-anchored gradient proposal correction), Mode B (constraint-triggered localized remasking), both, or neither.

Benchmark Mode A Mode B pass@1 (%) Δ (pp) vs. base
HumanEval-X ✗ ✗ 34.1 —
✓ ✗ 40.2 +6.1
✗ ✓ 50.6 +16.5
✓ ✓ 65.2 +31.1
MBPP-C++ ✗ ✗ 27.7 —
✓ ✗ 35.5 +7.8
✗ ✓ 47.9 +20.2
✓ ✓ 59.2 +31.5

Each mode produces a gain individually, and enabling both yields the largest improvement. On HumanEval-X / MBPP-C++, Mode A alone improves pass@1 by +6.1 / +7.8 pp, Mode B alone by +16.5 / +20.2 pp, and the full operator by +31.1 / +31.5 pp. Mode B is thus the larger single contributor and Mode A the smaller. The full operator (65.2% / 59.2%) also exceeds the sum of the two individual gains (56.7% / 55.7%) by +8.5 / +3.5 pp.

Q3. Is the static analyzer used in MDFI based on hand-crafted rules or a general-purpose analysis framework?

Thank you for raising this important question. The static-analysis pipeline used by MDFI combines existing semantic detection rules, referred to as declarative rules, from three general-purpose static analyzers: CodeQL, Semgrep, and Bandit. We did not introduce any additional hand-crafted rules. Its generality and scalability therefore derive from these established analyzers, and it can be further extended by incorporating rules from other general-purpose frameworks. We will clarify this in the revised paper.

[1] Competition-Level Code Generation with AlphaCode.Science, vol. 378, 2022. [2] Dream 7B: Diffusion Large Language Models, 2025. [3] Dream-Coder 7B: An Open Diffusion Language Model for Code.” arXiv:2509.01142, 2025. [4] DiffuCoder: Understanding and Improving Masked Diffusion Models for Code Generation.” arXiv:2506.20639, 2025. [5] Singh, A., Fry, A., Perelman, A., et al. (2026). OpenAI GPT-5 System Card. arXiv preprint arXiv:2601.03267 [6] CodeGeeX: A Pre-Trained Model for Code Generation with Multilingual Benchmarking on HumanEval-X.” ACM SIGKDD 2023. [7] Program Synthesis with Large Language Models. arXiv:2108.07732, 2021.

Authors · CommentOpenReview ↗

Thank you again for your thoughtful review. As the discussion period enters its final days, we would appreciate your feedback on whether our additional experimental results and analysis, including the surrogate evaluation and component ablations, address your main concerns. We would be happy to clarify any remaining points.

Reviewer mDEw · CommentOpenReview ↗

I really appreciate your response. Your answer addressed my concern very well, so I’ve decided to raise my rating from 3 to 4.

Reviewer Bw1DOpenReview ↗
Rating
5/6
Confidence
3/5
Quality
2/4
Clarity
2/4
Significance
3/4
Originality
3/4
Contribution type
general
Ethical concerns
NO or VERY MINOR ethics concerns only
Read review
Summary

This paper proposes Constrained Diffusion for Code (CDC), an inference-time framework for steering discrete diffusion code models toward outputs that satisfy program-level constraints. The key observation is that discrete diffusion models expose intermediate full-program denoising states, which can be inspected and modified before the final code is produced. CDC uses this property to decode intermediate clean-state proposals, evaluate them against constraints, localize likely violation-relevant regions, and apply targeted corrections during the reverse denoising process. Then, the paper instantiates CDC with two operators. GradGuide targets functional correctness by using an auxiliary surrogate model trained from execution-driven labels to provide soft correctness signals and gradient-based localization. MDFI targets security constraints by using static-analysis feedback to identify vulnerable code regions and then applying localized remasking, mask insertion, and feedback injection. The paper evaluates these methods on HumanEval-X C++, MBPP-C++, CWEval, and LLMSecEval, reporting improvements over vanilla diffusion decoding, grammar-constrained diffusion decoding, security prompting, and some autoregressive baselines. The paper also reports edit-locality statistics to support the claim that CDC performs more focused corrections than whole-program re-generation.

Strengths and weaknesses

The paper studies an important problem: generated code should satisfy global functional and security constraints, not merely local token-level plausibility. The motivation for using discrete diffusion models is reasonable, since their intermediate states provide a natural opportunity for constraint-guided intervention before generation is complete. I also appreciate that the paper considers both functional correctness and security, rather than only syntax or grammar constraints. The reported improvements are substantial in several settings, especially on HumanEval-X C++ and MBPP-C++ for functional correctness, and on CWEval/LLMSecEval for security-aware generation. The comparison with grammar-constrained diffusion is useful, as it shows that syntax-level constraints alone are insufficient for improving functional correctness.

However, I have several important concerns about the current version.

1. The auxiliary surrogate model used by GradGuide is not described in enough detail to fully assess the main functional-correctness results.
A central concern is that GradGuide relies on an auxiliary surrogate trained ahead of time with execution-driven labels, such as test-pass outcomes. The appendix gives some high-level information about this surrogate, but several details remain unclear, including how the training examples are constructed, what labels are used, what objective and hyperparameters are used for training, how large the training set is, and how well the surrogate itself performs. Since GradGuide appears to be responsible for the strongest functional-correctness gains, these details are important for assessing reproducibility and validity. Without a clearer description and evaluation of the surrogate, it is difficult to know how much of the improvement comes from the proposed mid-diffusion intervention mechanism versus from a strong learned verifier.

2. The surrogate training protocol raises a potential data leakage or task-specific supervision concern.
Because the surrogate is trained from execution outcomes, the paper should clearly explain whether its training data is disjoint from the evaluation tasks. If the surrogate is trained on candidate programs, prompts, or test outcomes from the same HumanEval-X/MBPP tasks used for evaluation, then the reported gains may partly reflect benchmark-specific verifier learning rather than a general mid-diffusion constraint mechanism. The paper should clarify whether public or hidden evaluation tests are used to generate labels, whether the split is performed at the task level rather than the sample level, and whether the surrogate generalizes to unseen tasks or benchmarks. A task-disjoint or cross-benchmark evaluation would be important to rule out this concern.

3. The "training-free" claim should be qualified.
The method appears to be training-free with respect to the base diffusion generator, since the diffusion model parameters are kept fixed. However, the GradGuide instantiation still relies on an auxiliary surrogate trained from execution feedback. This distinction matters because the surrogate introduces additional training data, training cost, and generalization concerns. The paper should state more explicitly that CDC is training-free only with respect to the base generator, not necessarily with respect to the full system.

4. The computational cost and latency of the method are not fully characterized.
The paper reports edited/generated token counts and emphasizes that CDC performs more localized corrections than autoregressive re-prompting. However, GradGuide requires surrogate forward/backward passes and possibly optimization during denoising, while MDFI invokes static analysis at denoising checkpoints. These costs may be substantial and are not captured by token-count metrics alone. The paper should report wall-clock latency, GPU/CPU overhead, number of surrogate calls, number of analyzer calls, and end-to-end compute under comparable success targets. Fewer edited or generated tokens do not necessarily imply lower inference cost when gradient-based guidance and static-analysis interventions are added.

5. The functionality evaluation is somewhat narrow and mainly limited to C++ function-level benchmarks.
The main functional-correctness experiments are conducted on HumanEval-X C++ and MBPP-C++, both of which are relatively small function-level synthesis benchmarks. Since CDC is presented as a general constrained code generation framework, it would be useful to evaluate GradGuide on additional languages such as Python, Java, JavaScript, or Rust, and ideally on longer or more realistic code-generation tasks. This is especially important because the surrogate-guided mechanism may be language- and benchmark-specific. The current results support the usefulness of CDC for benchmark-style C++ function generation, but they do not yet fully establish the generality of the framework.

6. The relation between the abstract CDC framework and the concrete operator implementations could be clearer.
Section 5.1 presents a representative fixed-length reverse diffusion transition in which non-mask tokens are preserved and the correction is expressed through a corrected clean-token proposal. In the concrete operators, however, GradGuide may reopen already committed tokens by remasking them, and MDFI can also insert fresh mask tokens. The appendix provides additional details about these modes, but the main framework would be easier to follow if it explained more explicitly how such state-editing operations fit into the formal CDC formulation, especially with respect to fixed sequence length, position handling, and the reverse diffusion schedule.

Overall, the idea of this paper is interesting and potentially valuable. However, the current paper leaves key questions unanswered about the surrogate model, the training/evaluation protocol, and the computational cost. Since GradGuide appears central to the strongest functional-correctness results, these issues directly affect the validity and reproducibility of the main empirical claims.

Questions
  1. Could the authors provide more details about the GradGuide surrogate?
    The surrogate model is an important component of the functional-correctness results, so it would be helpful to know more about its input representation, training objective, execution labels, training data size, and training procedure. These details would make the method easier to reproduce and would also help readers understand how much of the improvement comes from the mid-diffusion guidance mechanism versus the learned surrogate itself.

  2. Could the authors clarify the data split used for surrogate training?
    Since the surrogate is trained using execution-derived labels, it would be useful to know whether its training data is task-disjoint from the HumanEval-X/MBPP evaluation tasks. In particular, are candidate programs or execution outcomes from the same benchmark tasks used during surrogate training? Are public tests, hidden tests, or generated tests used to produce labels? Clarifying whether the split is task-level rather than only sample-level would help rule out benchmark-specific verifier learning.

  3. Could the authors include a more complete inference-cost analysis?
    The edited-token statistics are useful for supporting the locality claim, but they do not fully capture the cost of surrogate forward/backward passes, static-analysis calls, and denoising-time interventions. It would be helpful to report wall-clock latency, GPU/CPU overhead, the number of surrogate/analyzer calls, and cost under comparable success rates, so that readers can better assess the efficiency tradeoff relative to reprompting or repair-based baselines.

  4. Could the authors discuss or evaluate how well GradGuide generalizes beyond C++ function-level benchmarks?
    The current functional-correctness experiments are mainly on HumanEval-X C++ and MBPP-C++. Since the surrogate-guided mechanism may be language- or benchmark-dependent, additional results on another language, a cross-benchmark setting, or longer code-generation tasks would strengthen the generality claim. If such experiments are not feasible, a discussion of the expected language dependence of the surrogate would still be valuable.

Limitations

The authors include a limitations section, but several important caveats deserve more explicit discussion. First, GradGuide depends on an auxiliary surrogate trained from execution-derived labels, so its data requirements, task split, possible benchmark-specific supervision, and cross-task/language generalization are central limitations of the current method. Second, the reported edit-locality metrics do not fully characterize inference overhead, since GradGuide requires surrogate forward/backward passes and MDFI invokes static analysis during denoising. Finally, the evaluation is mostly on short function-level benchmarks and analyzer-supported security constraints, so the paper should more explicitly acknowledge that the conclusions may not directly extend to longer programs, repository-level settings, or constraints without reliable localized feedback.

Final justification

Thank you for the detailed clarifications and additional experiments. I am satisfied that my main concerns have been adequately addressed, and I increased my score from 4 to 5.

Formatting concerns

No

4 comments
Authors · CommentOpenReview ↗

[Part 1/3]

We thank the reviewer for their thoughtful comments and, in particular, for recognizing the importance of enforcing program-level constraints, and the substantial empirical improvements achieved by CDC. Below, we address the reviewer’s questions.

W1/Q1. The auxiliary surrogate model used by GradGuide is not described in enough detail to fully assess the main functional-correctness results.

Auxiliary surrogate model: The surrogate is built on Qwen2.5-Coder-1.5B. We freeze the backbone and train only LoRA adapters inserted into the final 12 of its 28 decoder layers, together with a four-layer MLP head with dropout 0.1 on the last-token hidden state. Last-token pooling is deliberate because, in a causal decoder, the final position attends to the entire sequence, whereas mean pooling is dominated by the long fixed judge prefix. The input is a fixed unit-test judge prompt followed by the problem statement and candidate program, truncated to 2,048 tokens. Labels are execution-derived scores y=1[compiles]⋅(test-pass ratio)∈[0,1]y=\mathbf{1}[\text{compiles}]\cdot(\text{test-pass ratio})\in[0,1] from real C++ execution, and we train the surrogate using soft-label BCE, providing a smooth correctness score suitable for gradient guidance.

Surrogate training and dataset: The 59K training examples are built exclusively from CodeContests [1]: for each problem, candidates are generated by Dream [2], Dream-Coder [3], and DiffuCoder [4] across denoising steps s∈{32,64,128,256}s\in\{32,64,128,256\} and temperatures T∈{0,0.2,0.6,1.0}T\in\{0,0.2,0.6,1.0\}, then compiled and unit-tested, and for problems where the diffusion models never produce a passing solution we add GPT-5 [5] candidates verified to compile and pass, ensuring positive coverage. Training uses AdamW (lr 2×10−52\times10^{-5}, cosine decay, 10% warmup), weight decay 0.01, effective batch size 16 (per-device 8 × grad-accum 2), bf16, and max length 2,048, for up to 5 epochs with per-epoch validation on a held-out problem split and best-validation-Pearson checkpoint selection (epoch 3); the one-time cost is ≈1.8 GPU-hours on a single NVIDIA RTX PRO 6000 Blackwell with the best checkpoint at obtained after 63 min.

We also evaluate the surrogate independently, both before and after fine-tuning. We report prediction error (MAE and MSE), ranking quality (Spearman ρ\rho), discrimination between fully correct and failing programs (AUPRC), calibration (ECE), and the resulting change in GradGuide pass@1. We additionally report Guidance Utility, which measures whether the surrogate selects the better candidate within a problem; this metric is available only on held-out CodeContests, where multiple candidates are available per problem.

Vanilla backbone (Qwen2.5-Coder-1.5B, no fine-tuning):

Dataset MAE ↓ MSE ↓ Spearman ρ\rho ↑ AUPRC ↑ ECE ↓ Guidance Utility ↑ Net Δ\Deltapass@1
HumanEval-X 0.533 0.342 0.056 0.277 0.377 N/A −8.5
MBPP-C++ 0.472 0.262 0.117 0.533 0.163 N/A −5.3
Held-out CodeContests 0.254 0.086 0.581 0.827 0.092 0.723 N/A

Trained GradGuide surrogate:

Dataset MAE ↓ MSE ↓ Spearman ρ\rho ↑ AUPRC ↑ ECE ↓ Guidance Utility ↑ Net Δ\Deltapass@1
HumanEval-X 0.074 0.022 0.848 0.946 0.024 N/A +31.1
MBPP-C++ 0.111 0.051 0.837 0.960 0.030 N/A +31.5
Held-out CodeContests 0.042 0.010 0.921 0.995 0.030 0.933 N/A

The backbone without fine-tuning performs poorly at ranking programs by execution quality (Spearman (0.056/0.117)) and is weakly calibrated (ECE (0.377/0.163)). In contrast, the trained surrogate is substantially more accurate, better ranked, and better calibrated on both HumanEval-X and MBPP-C++, despite being trained only on CodeContests.

This same comparison answers how much of the gain comes from the mechanism versus a strong verifier. The improvement is not explained by merely adding an auxiliary model or extra computation to denoising: placing the un-fine-tuned backbone in the identical GradGuide pipeline decreases pass@1 by 8.5 (HumanEval-X) and 5.3 (MBPP-C++), whereas the accurate, calibrated surrogate increases it by +31.1/+31.5. Downstream pass@1 therefore tracks the independently measured surrogate quality, because the method follows the surrogate's score and its gradient toward correct regions of program space. We will add the details, this standalone evaluation, and the analysis above to the revised paper.

Authors · CommentOpenReview ↗

[Part 2/3 (see below)]

W2/Q2. The surrogate training protocol raises a potential data leakage or task-specific supervision concern.

We thank the reviewer for raising this concern. The surrogate is trained exclusively on CodeContests [1], while GradGuide is evaluated on HumanEval-X [6] and MBPP-C++ [7]. No evaluation prompts, candidate programs, public or hidden tests, or execution outcomes are used during training; all labels come solely from executing candidates against CodeContests’ own tests. Because separate dataset provenance alone does not exclude duplicate tasks, we also performed duplicate-overlap checks between CodeContests and the evaluation benchmarks, confirming that the training problems are cleanly disjoint from both HumanEval-X and MBPP-C++. The surrogate further generalizes strongly to these unseen benchmarks, achieving Spearman (0.848/0.837), AUPRC (0.946/0.960), and ECE (0.024/0.030) on HumanEval-X/MBPP-C++. We will state this data-separation protocol explicitly in the revised manuscript.

W3. The "training-free" claim should be qualified.

We agree that this claim should be qualified. We will remove the broad “training-free” claim and clarify that CDC does not require training or modifying the base diffusion model. However, GradGuide requires one-time fine-tuning of an auxiliary surrogate, whereas MDFI requires no auxiliary model training.

W4/Q3 The computational cost and latency of the method are not fully characterized.

We agree this is important, and report here wall-clock latency (mean/p50/p95/max), peak GPU memory, the per-call cost and firing frequency of surrogate calls, the number and cost of analyzer calls, and cost under comparable success under matched backbone and decoding settings, with all times including the complete pipeline. The GradGuide measurements over all 164 HumanEval-X tasks are:

Backbone Method Total time Mean / p50 / p95 / max (s) ×vanilla Peak GPU Surrogate pass Interv. freq
Dream-Coder-7B Vanilla 693 s 4.23 / 4.26 / 4.62 / 5.38 1.00× 15.1 GB — —
GradGuide 1,310 s 7.99 / 6.10 / 17.46 / 20.07 1.89× 23.1 GB 49.5 ms 0.66
Dream-7B Vanilla 685 s 4.18 / 4.21 / 4.57 / 5.34 1.00× 14.7 GB — —
GradGuide 1,181 s 7.20 / 5.93 / 15.55 / 19.41 1.72× 23.2 GB 52.6 ms 0.84
DiffuCoder-7B Vanilla 682 s 4.16 / 4.19 / 4.54 / 5.32 1.00× 14.7 GB — —
GradGuide 1,372 s 8.37 / 6.16 / 16.84 / 21.31 2.01× 23.6 GB 48.3 ms 0.66

A single surrogate pass costs ~48–53 ms, and over the full benchmark wall-clock rises from 682–693 s (vanilla) to 1,181–1,372 s (GradGuide). Per sample, mean latency is 1.72–2.01× vanilla against a median of only 1.41–1.47× (p95 up to 15.55–17.46 s). Here, intervention frequency denotes the percentage of samples that CDC intervenes in.

For cost under comparable success, the most informative comparison is with other test-time-compute methods, specifically Best-of-N and autoregressive re-prompting, which also use additional inference to improve quality. The table reports the pass@1 gain each method achieves over its own vanilla baseline:

Method HumanEval-X Δpass@1(%) MBPP-C++ Δpass@1(%)
Best-of-N(N=2) +3.1 +3.5
AR+Reprompt +4.2 +1.0
CDC (Ours) +31.1 +31.5

CDC delivers roughly seven-to-nine times the improvement of the strongest baseline on each benchmark (+31.1 vs. +4.2 on HumanEval-X, +31.5 vs. +3.5 on MBPP-C++), so its 1.7–2.0× per-sample cost converts into gains that neither Best-of-N nor re-prompting approaches.

MDFI.

Metric CWEval (vanilla→MDFI) LLMSecEval (vanilla→MDFI)
Mean latency 12.98→13.28 s (+2.3%) 10.12→10.73 s (+6.1%)
p50 / p95 latency 12.85→12.97 / 16.73→16.87 s 9.62→11.00 / 11.82→12.72 s
Total benchmark time 23.4→23.9 min 25.3→26.8 min
Peak GPU 64.2→66.9 GiB (+4.2%) 30.4→31.2 GiB (+2.6%)
Analyzer calls / CPU time 7 / 46 ms (1 core) 7 / 46 ms (1 core)
func-sec@1(%) 12.0→34.3 14.7→24.7
sec@1(%) 18.5→41.7 54.7→80.7
Successful-output throughput (×vanilla) 2.79× 1.58×

MDFI adds only 2.3–6.1% latency and 2.6–4.2% peak memory, yet it reduces the expected wall-clock time per jointly functional-and-secure solution by 64.2% on CWEval and 36.9% on LLMSecEval, equivalently, 1.58–2.79× the successful-output throughput of vanilla generation. Under the throughput framing the reviewer requests, MDFI is therefore more efficient than vanilla diffusion, and markedly more cost-effective than AR re-prompting, attaining 86–95% of its joint success rate (34.3 vs. 39.8 on CWEval, 24.7 vs. 26.0 on LLMSecEval) at this small latency overhead, rather than the full second generation re-prompting requires. We will add these measurements to supplement the locality results for efficiency.

Authors · CommentOpenReview ↗

[Part 3/3 (see below)]

W5/Q4. The functionality evaluation is somewhat narrow and mainly limited to C++ function-level benchmarks.

We selected HumanEval-X C++ and MBPP-C++ because they are standard benchmarks and because C++ presents a demanding setting in which generated programs must satisfy both complex language constraints and functional tests. GradGuide substantially improves both compilation and test-pass rates, indicating that its gains extend beyond superficial syntax correction to program semantics. Our multilingual CWEval results provide broader evidence for the CDC framework through MDFI, but evaluating GradGuide on additional languages and repository-level tasks remains important future work.

W6. The relation between the abstract CDC framework and the concrete operator implementations could be clearer.

Thank you for highlighting this point. Equation 9 presents the representative fixed-length proposal-correction case, while GradGuide and MDFI may also edit the current state through remasking or mask insertion before continuing under the remaining reverse schedule. These operations are described further in Appendices C and D, but we agree that their relation to the abstract framework—particularly sequence-length and position handling—should be made explicit in Section 5.1, and we will revise it accordingly.

Authors · CommentOpenReview ↗

Thank you again for your detailed feedback. As the discussion period enters its final days, we would appreciate your feedback on whether our additional experimental results and analysis, including surrogate validity, data separation, and inference cost, address your main concerns. We would be happy to clarify any remaining points.

Reviewer onM7OpenReview ↗
Rating
5/6
Confidence
3/5
Quality
3/4
Clarity
2/4
Significance
3/4
Originality
3/4
Contribution type
general
Ethical concerns
NO or VERY MINOR ethics concerns only
Read review
Summary

The paper proposes constraint-based denoising during inference through a novel framework, Constrained Diffusion for Code (CDC). CDC decodes and evaluates code against program-level constraints, then localises feedback to relevant regions of code, ensuring that only necessary parts of the program are modified. This approach reduces the number of tokens that need to be changed. CDC accommodates both soft feedback (GradGuide for functional correctness) and hard feedback (MDFI for security). After identifying states requiring modification, CDC applies constraint-aware correction by remasking, to reduce violations while maintaining proximity to the base denoiser, before proceeding to the next denoising step. The framework outperforms other diffusion methods and requires fewer token edits compared to reprompting in autoregressive models.

Strengths and weaknesses

Strengths: 

  1. Well motivated : The paper explains in detail why constraints are important and why post-hoc methods are insufficient.
  2. Well-described experimental setup : The experimental setup is clearly described.
  3. Significant gain in performance : The framework shows significant improvement in performance compared to other diffusion baselines and is competitive with AR baselines
  4. Security and Correctness : It shows improvements in security without compromising the functional correctness; providing solution to a very difficult problem.

Weaknesses:

  1. Efficiency claims are questionable: Measuring efficiency by the number of edited tokens is questionable because it does not indicate the overhead caused by CDC in GradGuide and MDFI in terms of memory or time. Efficiency in this case should be measured through throughput and the overhead to the diffusion process.
  2. Number of denoising steps : The authors did not report the number of denoising steps required to achieve the gains in performance, and compared with the steps required in other diffusion models. They should report denoising steps clearly.
  3. The claim of "training-free" is not completely true: Although the authors claim this is a training-free method, they have trained a Qwen 1.5B model for GradGuide.
  4. Training and inference overhead : The overhead of training the Qwen model is also not considered. Similarly, the overhead from using a trained model for functional correctness detection and using static analysis tools have not been described. 
  5. Lack of clarity : Some equations, like equation 1, need more description of terms like alpha, M, cat function, etc. The order in which some sections are described reduces clarity (eg, 5.2 after 5.1)
Questions
  1. What could be the reason behind the lag in performance compared to CFG-CD on Syntactic validity?
  2. Why is a causal model (and not a bi-directional model) used in GradGuide for detection and localization? 
  3. Why is a trained model not used for security vulnerability detection, given the false positives in security analyzers? Which security analysis tool has been used in the paper and why was it chosen?
  4. Line 22 - "íterative refinement of partially corrupted token sequences." What are partially corrupted sequences? All the tokens are masked during inference time; only the prompt is unmasked.
  5. Line 46 - "Reverse denoising process." What do authors mean by "reverse denoising"? Usually, constraints are integrated into the denoising process. Is it related to remasking?
  6. Line 50 - How is localized sampling done? This part needs more explanation in both correctness and security. How is constraint violation reduced?
  7. Equation 17 - What is the anchor function and what value of K is used for insertion?
Limitations

The limitations are not discussed by the authors. The overhead incurred by the training and inference of the Qwen model and the impact of false positives in security analyzers should be discussed in Limitations. The impact of using different static analysis tools and overhead from them should also be included.

Final justification

I thank the authors for detailed clarifications and additional results. The authors address some of the major concerns during the rebuttal. They provide memory and throughput comparison, although their method adds memory overhead and latency but the performance gains are significant. Also, they provide comparison with autoregressive models at a comparable inference budget and the gains are significant. I would appreciate if a similar comparison is provided with the diffusion baseline at a comparable inference budget.

I also appreciate the details about the program-analyser. I increase my score from 4 to 5.

Formatting concerns

None.

4 comments
Authors · CommentOpenReview ↗

[Part 1/3]

Thank you for the thoughtful and constructive review. We appreciate the recognition of our significant gains over diffusion baselines and our method’s ability to improve security without sacrificing functional correctness. We address the reviewer’s questions below.

W1. Missing efficiency analysis in terms of runtime, throughput, and memory.

We thank the reviewer for raising this point, and we agree that our original edited-token statistics quantify correction locality rather than computational efficiency. To measure efficiency directly, we now report end-to-end runtime, throughput, and memory under a matched backbone and decoding configuration for both vanilla generation and CDC. We present per-sample computational cost (latency and memory) and cost-effectiveness, defined as the successful outputs produced per unit of inference cost. We report both instantiations, GradGuide and MDFI, separately below.

GradGuide.

Backbone Method Total time Mean / p50 / p95 / max Time(s) ×vanilla Peak GPU One surrogate pass Interv. freq
Dream-Coder-7B Vanilla 693 s 4.23 / 4.26 / 4.62 / 5.38 1.00× 15.1 GB — —
GradGuide 1,310 s 7.99 / 6.10 / 17.46 / 20.07 1.89× 23.1 GB 49.5 ms (med 47.0) 0.66
Dream-7B Vanilla 685 s 4.18 / 4.21 / 4.57 / 5.34 1.00× 14.7 GB — —
GradGuide 1,181 s 7.20 / 5.93 / 15.55 / 19.41 1.72× 23.2 GB 52.6 ms (med 48.5) 0.84
DiffuCoder-7B Vanilla 682 s 4.16 / 4.19 / 4.54 / 5.32 1.00× 14.7 GB — —
GradGuide 1,372 s 8.37 / 6.16 / 16.84 / 21.31 2.01× 23.6 GB 48.3 ms (med 45.0) 0.66

Over the full HumanEval-X benchmark, wall-clock time rises from 682–693 s for vanilla generation to 1,181–1,372 s for GradGuide. On a per-sample basis this corresponds to a mean latency of 1.72–2.01× vanilla, but the median is only 1.41–1.47× and a single surrogate pass costs just 48–53 ms. This gap between the median and the mean, reinforced by the larger p95 values, which reach 15.55–17.46 s, shows that the added cost is not incurred uniformly by every sample, but is concentrated in the trajectories that require stronger or repeated correction. Alongside latency, peak memory rises by 53–61%.

At a comparable inference budget, the more informative question is how much improvement this compute delivers relative to the other test-time-compute methods, Best-of-N sampling and autoregressive re-prompting. The table reports the pass@1 gain each method adds over its own vanilla baseline:

Method HumanEval-X Δpass@1(%) MBPP-C++ Δpass@1(%)
Best-of-N +3.1 +3.5
AR+Reprompt +4.2 +1.0
CDC (Ours) +31.1 +31.5

CDC delivers roughly seven-to-nine times the improvement of the strongest baseline on each benchmark (+31.1 vs. +4.2 on HumanEval-X, +31.5 vs. +3.5 on MBPP-C++), so its 1.7–2.0× per-sample cost converts into gains that neither Best-of-N nor re-prompting approaches.

MDFI.

Metric CWEval (vanilla→MDFI) LLMSecEval (vanilla→MDFI)
Mean latency 12.98→13.28 s (+2.3%) 10.12→10.73 s (+6.1%)
p50 / p95 latency 12.85→12.97 / 16.73→16.87 s 9.62→11.00 / 11.82→12.72 s
Total benchmark time 23.4→23.9 min 25.3→26.8 min
Peak GPU 64.2→66.9 GiB (+4.2%) 30.4→31.2 GiB (+2.6%)
Analyzer calls / CPU time 7 / 46 ms (1 core) 7 / 46 ms (1 core)
func-sec@1 12.0→34.3% 14.7→24.7%
sec@1 18.5→41.7% 54.7→80.7%
Successful-output throughput (×vanilla) 2.79× 1.58×

MDFI adds only 2.3–6.1% latency and 2.6–4.2% peak memory, yet it reduces the expected wall-clock time per jointly functional and secure solution by 64.2% on CWEval and 36.9% on LLMSecEval. Equivalently, it achieves 1.58–2.79× the successful-output throughput of vanilla generation. Under the throughput framing requested by the reviewer, MDFI is therefore strictly more efficient than vanilla diffusion and markedly more cost-effective than AR re-prompting. It attains 86–95% of the joint success rate of AR re-prompting (34.3 vs. 39.8 on CWEval and 24.7 vs. 26.0 on LLMSecEval) with only this small latency overhead, rather than requiring the full second generation needed for re-prompting.

These additional evaluations supplement the locality-only results with a direct account of runtime, throughput, and memory. These results show that CDC’s computational overhead is justified by substantially greater constraint-satisfaction gains and improved successful-output throughput.

W2. Missing denoising-step counts.

We thank the reviewer for highlighting this omission. CDC and all vanilla diffusion baselines use the same fixed base denoising schedule of 256 steps across all experiments. We will state this explicitly in the revised experimental setup.

Authors · CommentOpenReview ↗

[Part 2/3 (see below)]

W3. The "training-free" claim is not completely true.

We agree that describing the entire framework as “training-free” is imprecise, as GradGuide does require fine-tuning an auxiliary surrogate. We will update the claim to state more accurately that CDC does not train, fine-tune, or modify the underlying diffusion model, while MDFI itself requires no learned auxiliary model.

W4. Unreported training and inference overhead for the Qwen surrogate.

Our efficiency analysis has so far focused on inference because the surrogate is fine-tuned only once. We agree, however, that a complete accounting should include this one-time training cost. The surrogate is fine-tuned once on 59K execution-labeled programs drawn exclusively from CodeContests [2], a benchmark separate from the HumanEval-X and MBPP-C++ evaluation sets. The training data is fully disjoint from every evaluation task. This fine-tuning takes 1 h 46 min (≈1.8 GPU-hours) on a single NVIDIA RTX PRO 6000 Blackwell (96 GB, bf16), including model loading and per-epoch validation. We will add these measurements to the experimental section. The corresponding inference overhead, including latency, memory, per-surrogate-pass cost, and intervention frequency, is reported in our response to W1.

W5. Unclear notation and section organization.

We thank the reviewer for this feedback and agree that paper clarity can be improved. For eq 1, terms including MM, α\alpha, and Cat()\mathrm{Cat}() are defined immediately following the equation (lines 125–127). Specifically, Cat()\mathrm{Cat}() is the categorical distribution, MM is the one-hot [MASK][MASK] token, and α\alpha is the decreasing noise schedule.

In regards to section ordering, section 5.1 first introduces the general CDC framework and the relevant components including the evaluator, localization map, correction operator, and constrained reverse update, while Section 5.2 then instantiates these components as GradGuide and MDFI. We agree that this relationship could be signposted more clearly. We will revise the transition and add an explicit indication at the beginning of Section 5 to clarify that Section 5.1 presents the unified framework and Section 5.2 provides its concrete functionality and security instantiations.

Q1. What could be the reason behind the lag in performance compared to CFG-CD on Syntactic validity?

CDC achieves higher syntactic validity than CFG-CD [1] in five of the six evaluated settings; the only exception is Dream-7B on HumanEval-X C++. CFG-CD’s operates with a direct enforcement of grammar constraints, whereas CDC targets functional correctness and improves syntax only indirectly. Importantly, CDC delivers substantially larger and more consistent gains in functional correctness in all settings.

Q2. Why is a causal model (and not a bi-directional model) used in GradGuide for detection and localization?

In this work, we use a causal model for practicality, specifically, it lets us reuse a strong pretrained code language model rather than training a bidirectional scorer from scratch. Causal attention still gives the last-token score full context over the program, and gradients with respect to earlier positions provide a valid signal for localization. Indeed, a bidirectional variant is a reasonable alternative to be explored in future work.

Authors · CommentOpenReview ↗

[Part 3/3 (see below)]

Q3. Why use static analysis despite false positives, and which analyzer is used and why?

We use static analysis rather than a trained vulnerability detector because the available labeled benchmarks are too small to train a reliable multilingual detector without compromising evaluation independence. CWEval contains 108 prompts and LLMSecEval contains 150, resulting in only 258 examples distributed across multiple languages and CWE categories. Training on these benchmarks would therefore provide very few examples per category and introduce evaluation leakage.

We agree that static analyzers may produce false positives and therefore localize vulnerabilities conservatively. However, a trained model would face the same risk while also potentially missing true vulnerabilities. In MDFI, a false positive may trigger an unnecessary correction, primarily increasing generation overhead. In the revised paper, we will add a thorough empirical analysis of how analyzer false positives affect MDFI.

Our analyzer combines complementary detection rules and intermediate representations derived from CodeQL, Semgrep, and Bandit. These tools provide broad, complementary vulnerability coverage. However, their standard pipelines are not designed for the masked and incomplete programs encountered during diffusion. We therefore develop a partial-program analysis layer that tolerates incomplete states, consolidates vulnerability findings, and maps detected witnesses to editable token regions—an important component of MDFI.

Our partial-program analyzer provides stronger security guidance at much lower overhead than the off-the-shelf tools. We will clarify the analyzer design, tool selection, and these results in the revised manuscript.

Analyzer sec@1 fs@1 Δfs vs. vanilla Latency vs. vanilla
— (vanilla, no MDFI) 54.7 14.7 — —
Bandit 62.7 17.3 +2.6 +36%
Semgrep 62.7 17.3 +2.6 +288%
CodeQL 54.7 14.7 0.0 Timed out
Our partial-program analyzer 80.7 24.7 +10.0 +6.1%

Q4. What are “partially corrupted sequences” if inference begins with all output tokens masked?

In the context of this work, "Partially corrupted" refers to the intermediate denoising states xtx_t for 0 < tt < TT along the trajectory, not the initial state xTx_T. At tt = TT the sequence is fully masked aside from the unmasked prefix which consists of the prompt. As the sample is denoised, tokens are progressively unmasked. Therefore intermediate states xtx_t are a partial mix of masked and unmasked tokens. This is the "partially corrupted" sequence the denoiser operates on at each step (Eq. 2). We will add additional clarification in the updated manuscript version.

Q5. What does “reverse denoising” mean, how are constraints integrated, and is it related to remasking?

“Reverse denoising process”is standard diffusion terminology referring to the reverse Markov chain (Eq. 2), which runs from (t=T) to (t=0) and reverses the forward corruption process in Eq. 1. It does not specifically refer to remasking; remasking is an optional constraint-aware intervention applied within this reverse process to mask selected tokens for further denoising.

Q6. How is localized sampling performed for correctness and security, and how does it reduce constraint violations?

In CDC, localization first identifies the token regions most responsible for a constraint violation, and corrections are then restricted primarily to those regions while the remaining tokens stay close to the base denoiser’s prediction. For functional correctness, GradGuide uses gradients from the surrogate correctness score to identify high-saliency spans, then reduces the predicted violation through a KL-anchored update of the token distributions and selectively remasks those spans for regeneration. For security, MDFI uses static-analysis witnesses to identify vulnerable AST or dataflow regions, then remasks or inserts mask tokens at those locations and injects remediation feedback so that subsequent denoising revises the affected code. These mechanisms are described in detail in Section 5.2; we will expand Line 50 and add an explicit pointer to that section.

Q7. Equation 17 - What is the anchor function and what value of K is used for insertion?

The anchor function selects a syntactically valid insertion point near the vulnerability identified by the partial code-property-graph analysis. This provides an appropriate location for the model to generate the missing corrective code. We use (K=12) inserted mask tokens in all experiments (Line 845) and ablate this choice in Appendix B.3.2, Figure 8(a).

[1] Niels Mundler, Jasper Dekoninck, and Martin Vechev. Constrained decoding of diffusion llms with context-free grammars, 2025 [2] Competition-Level Code Generation with AlphaCode.Science, vol. 378, 2022.

Authors · CommentOpenReview ↗

Thank you again for your constructive review. As the discussion period approaches its end, we would appreciate your feedback on whether our additional experimental results and analysis, including computational overhead, denoising steps, and analyzer design, address your main concerns. We would be happy to answer any remaining questions.

From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.

Missing a submission?

Loading the discussion…