Search-Augmented Masked Diffusion Models for Constrained Generation

Huu Binh Ta, Michael Cardei, Alvaro Velasquez, Ferdinando FiorettoNeurIPS 2026

TL;DR

Generative models are great at mimicking what they’ve seen, but notoriously bad at following strict, brittle rules—like designing a chemically valid drug or solving a Boolean logic puzzle. SearchDiff fixes this without any model retraining by embedding a classic discrete search directly inside the iterative "unmasking" steps of a discrete diffusion model. The result is a plug-and-play inference framework that marries neural intuition with hard symbolic evaluators, drastically improving rule-following and discovering novel solutions outside the training distribution.

What Problem Does This Paper Address?

If you ask a standard autoregressive language model (like GPT) to generate a molecule or solve a Sudoku board left-to-right, early token choices can trap it in a dead end before it ever sees the whole picture. Masked discrete diffusion models offer an appealing alternative: they start with a sequence of [MASK] tokens and reveal the whole structure iteratively in parallel, giving the model a global view of the sequence at every step.

However, diffusion models are trained simply to match the statistical likelihood of their training data. They have no built-in way to enforce hard rules (like "zero duplicate numbers in a Sudoku row") or optimize non-differentiable, black-box simulators (like chemical synthesizability). Existing workarounds require retraining the model for every new rule or relying on smooth, differentiable approximations that introduce bias and degrade quality. We need a way to enforce strict, arbitrary rules at inference time without touching the base model's weights.

Methods

SearchDiff hijacks the standard reverse-diffusion loop. Normally, at each step $t$, a masked diffusion model looks at a partially masked sequence, guesses a probability distribution over clean tokens, and randomly unmasks a few positions. SearchDiff inserts a neurosymbolic search step right into the middle of that transition:

Overview of a single SearchDiff denoising step, showing clean-state proposal, CSS, local refinement, and token commitment.
  1. Clean-State Proposal (Standard): The pretrained denoiser network predicts token probabilities for the entire sequence.
  2. Constraint-Aware Search (Novel): Instead of immediately sampling from those raw probabilities, SearchDiff treats them as an informed prior for a two-part discrete search evaluated by a black-box constraint checker:
  3. Candidate Search Sampling (CSS): Draw $M$ full, clean candidate sequences from the denoiser’s proposal distribution and pick the one with the lowest constraint violation.
  4. Local Search Refinement (LS): Take that winning candidate and test single-token edits (a Hamming-1 neighborhood), greedily stepping toward the neighbor that best reduces rule violations.
  5. Modified Reverse Kernel (Novel): Advance to step $t-1$. Already unmasked tokens are updated deterministically, while masked positions stochastically decide whether to stay [MASK] or commit to the token found by the refined search candidate.

Because the search only queries constraint violations, it requires zero gradients and works with any off-the-shelf simulator or solver.

Datasets

The authors evaluate SearchDiff across five existing scientific and symbolic benchmarks (no new datasets are introduced, following prior setups):

  • Small Molecules: QM9 dataset (SMILES strings), evaluated with RDKit for validity, drug-likeness (QED), and Synthetic Accessibility (SA).
  • Peptides: Antimicrobial/host-defense amino-acid sequences evaluated with Biopython for length, net charge, and hydrophobicity.
  • Transfer RNA (tRNA): Sequences evaluated with ViennaRNA for tightly coupled secondary-structure folding motifs.
  • Symbolic Logic: $9\times 9$ Sudoku boards and random 7-variable, 45-clause 3-SAT Boolean formulas.

Key Insights and Ideas

  • Local search unlocks Out-of-Distribution (OOD) discovery: Sampling-only methods are prisoner to what the base model already thinks is likely. Because Local Search tests single-token neighbor edits directly against the evaluator, it actively walks into feasible, high-reward regions the model never saw during training.
Figure 3: Number of generated molecules with higher QED compared to the highest QED value in the training dataset for different methods.
  • Trajectory-level steering beats post-hoc repair: What happens if you just run normal diffusion and apply local search at the very last step? On 3-SAT, accuracy crawls from 9.6% to 11.4%. Interleaving search throughout the denoising trajectory jumps accuracy to 76.0%, proving that early, iterative nudges prevent the model from drifting into unrecoverable regions.
  • Neural priors and search need each other: Running greedy local search from a random start gets 0% on Sudoku and 45.8% on SAT. The diffusion model provides the global intuition; the search provides the exactness.

Key Results

  • Molecules: Setting a constraint of $\text{QED} \ge 0.7$ yields 833.4 valid, novel, unique molecules (out of 1024), more than doubling vanilla MDLM (397.8) while boosting mean QED from 0.48 to 0.72. Under strict synthesizability ($\text{SA} \le 4$), SearchDiff produces 470.2 qualifying molecules (~4$\times$ vanilla MDLM's 119.2). It also discovers an average of 332.4 molecules with higher QED than the best molecule in the entire training set (vanilla MDLM and classifier-based guidance find 0.0).
  • Peptides & tRNA: Achieves a 0% violation rate on peptides (1024/1024 valid, unique, novel sequences satisfying all biophysical rules). On the much harder, long-range tRNA folding task, it achieves a 27$\times$ increase in joint constraint satisfaction over the best baseline (719.0 vs. 25.8).
Figure 4: tRNAs generated by SearchDiff (left) and MDLM (right).
  • Symbolic Reasoning: Using just a tiny 6M-parameter diffusion backbone, SearchDiff hits 96.5% on Sudoku (beating a 303M GPT-2 model at 23.21%) and boosts 3-SAT accuracy nearly 8$\times$ over vanilla diffusion (from 9.6% to 76.0%).

Limitations and Future Work

While the authors do not include a dedicated limitations section in the main text, one practical trade-off is noted in the molecular experiments: purely greedy property maximization in SearchDiff can cause the search to collapse onto repeated samples, reducing uniqueness (which the authors mitigate by switching from pure maximization to a threshold constraint like $\text{QED} \ge 0.7$). Additionally, local search is restricted to single-token (Hamming-1) edits per step to keep computational complexity manageable. Looking forward, the authors suggest that trajectory-level, inference-time optimization offers a broader, principled route for making discrete generative models reliable across scientific discovery and symbolic reasoning workflows.

Summary updated

Abstract

Discrete diffusion models generate sequences by iteratively denoising samples corrupted by categorical noise, offering an appealing alternative to autoregressive decoding for structured and symbolic generation. However, standard training targets a likelihood-based objective that primarily matches the data distribution and provides no native mechanism for enforcing hard constraints or optimizing non-differentiable properties at inference time. This work addresses this limitation and introduces Search-Augmented Masked Diffusion (SearchDiff), a training-free neurosymbolic inference framework that integrates informed search directly into the reverse denoising process. At each denoising step, the model predictions define a proposal set that is optimized under a user-specified property satisfaction, yielding a modified reverse transition that steers sampling toward probable and feasible solutions. Experiments in biological design and symbolic reasoning illustrate that SearchDiff substantially improves constraint satisfaction and property adherence, while consistently outperforming discrete diffusion and autoregressive baselines.
BibTeX
@inproceedings{ta2026search,
  author = {Huu Binh Ta and Michael Cardei and Alvaro Velasquez and Ferdinando Fioretto},
  title = {{Search-Augmented Masked Diffusion Models for Constrained Generation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=HpIle7vItG},
}
Figure