Constraints Are Graphs, Not Chains: Exact Decoding for Diffusion Language Models
Organizations: University of Connecticut
Abstract
Diffusion language models (dLLMs) predict masked positions in arbitrary order, but their exact constrained decoders still encode constraints as sequential languages, whose state must track every unresolved dependency between positions. For relational constraints this encoding grows exponentially: for same-order copy, every finite automaton needs states, deterministic or nondeterministic, and every context-free grammar has size , while the factor graph of the same relation has size and a 16-entry peak table. We introduce FactorDLM, a training-free decoder that represents finite-domain relations as a factor graph and, at each denoising step, conditions the model's mean-field prediction on that graph exactly by variable elimination. Decoding cost then grows exponentially with the induced width of the constraint graph, which replaces automaton size as the governing parameter. Because a finite automaton is a chain-shaped factor graph, one compiler enforces syntax and nonlocal relations together: on JSON records with cross-field references, a schema automaton alone leaves references dangling, relational factors alone produce malformed JSON, and the combined plan is valid on both counts, including on records of variable length. Across nine relational benchmarks and three backbones, every output satisfies every declared constraint at 0.4-6.9% projection overhead, where unconstrained decoding is 0-79% valid, and compiled projection answers repeated queries 13.6x faster than CP-SAT with eight parallel workers. Because model-free rules solve three of five standard benchmarks, we construct benchmarks with exact chance and fixed-template floors, on which selecting among exact constrained samples beats greedy projection. Which encoding is cheaper, sequential state or direct factors, depends on the constraint and is computable before decoding begins.
Figures & tables
| Dream-7B | LLaDA-8B | LLaDA-1.5 | |||||||||
| Task | Metric | Base | Ours | +Sel | Base | Ours | +Sel | Base | Ours | +Sel | |
| PLAN | Meeting (3 people) | norm. objective | 42.8 | 55.8 | 75.3 | 62.0 | 83.5 | 99.0 | 65.0 | 87.7 | 98.8 |
| Trip | exact match | 19.9 | 92.1 | 82.9 | 0.0 | 84.7 | 72.2 | 0.0 | 78.7 | 72.2 | |
| MATH | Countdown ‡ | success | 0.0 | 1.4 | 3.0 | 0.0 | 1.0 | 9.4 | 0.0 | 0.8 | 8.6 |
| JSON | JSON § | instructed record | 0.0 | 0.0 | 0.0 | 0.0 | 41.4 | 92.0 | 0.0 | 43.4 | 96.4 |
| Var-JSON § | instructed record | 0.0 | 0.0 | 0.8 | 0.0 | 38.3 | 41.7 | 0.0 | 37.9 | 35.4 | |
| Exact-optimum rate | |||||||
|---|---|---|---|---|---|---|---|
| Backbone | People | Greedy | PLL | Judge | Top-8 | Oracle | Normalized objective |
| Dream | 3 | 0.120 | 0.490 | 0.320 | 0.920 | 0.500 | |
| Dream | 4 | 0.040 | 0.290 | 0.270 | 0.640 | 0.400 | |
| Dream | 5 | 0.051 | 0.173 | 0.143 | 0.286 | 0.276 | |
| LLaDA | 3 | 0.530 | 0.970 | 0.970 | 0.980 | 0.970 | |
| LLaDA | 4 | 0.410 | 0.570 | 0.730 | 0.450 | 0.750 | |
Appendix figures & tables26 assets
Supplementary material from the paper’s appendix.
Appendix
| Dream-7B | LLaDA-8B | LLaDA-1.5 | |
| Method | syntax / references / instructed record | ||
| Chance floor (analytic) | 0.0009 | ||
| Best fixed template | 0.016 | ||
| Independent | 0.000 / 0.000 / 0.000 | 0.000 / 0.000 / 0.000 | 0.000 / 0.000 / 0.000 |
| Automaton only | 1.000 / 0.474 / 0.000 | 1.000 / 0.480 / 0.186 | 1.000 / 0.516 / 0.224 |
| Relations only | 0.000 / 1.000 / 0.000 | 0.000 / 1.000 / 0.000 | 0.000 / 1.000 / 0.000 |
| Work | Constraint/tasks | Quality evidence | System evidence |
|---|---|---|---|
| DINGO | Regular; GSM-Symbolic, JSON | accuracy, parse and schema validity | wall time, automaton precomputation |
| CFG | Context-free; C++, JSON, SMILES | syntax, exact match, pass@1 | inference and completion behavior |
| LAVE | Context-free; C++, JSON, SMILES | syntactic@k, functional@k | mean time, lookahead ablations |
| EPIC | Context-free; C++, JSON, SMILES | syntax and functional correctness | normalized time, breakdown, steps, ablations |
| Finite automata | Automata; function calls, Sudoku, planning, SQL, math | accuracy and constraint satisfaction; greedy and sample | latency, throughput, automaton size, step sweep |
| FactorDLM | Factor graphs; Sudoku, coloring, copy, meetings | validity, exact match, task success, agreement, paired inference | latency decomposition, memory, steps, width, CPU/CUDA, failure boundary |
| Question | Metric and direction | Denominator / paired unit | Evidence |
|---|---|---|---|
| Direct system quality | complete valid output without repair | 900 Sudoku per model–mode cell | Fig. 11 |
| Constraint coverage | validity; higher is better | all 900 Sudoku or all 100 plans | Fig. 6 |
| Model utility | normalized objective; invalid is zero | all 100 planning records | Fig. 6 c |
| Schedule quality | semantic-score effect; positive favors dispersed | generated groups within 40 subjects | Fig. 13 |
| Workflow selection | execution-success effect | all 124 development records | Fig. 13 |
| Exact-system win | CP-SAT/FactorDLM; above one favors FactorDLM | eight optimal cells, 20 queries each | Fig. 3 a |
| Cell | Greedy | Best-of- oracle | Oracle gap | Realised gain |
|---|---|---|---|---|
| Dream trip | 0.921 | 0.963 | 0.042 | |
| LLaDA trip | 0.847 | 0.954 | 0.106 | |
| Dream meeting 5p | 0.051 | 0.276 | 0.224 | |
| LLaDA meeting 5p | 0.133 | 0.367 | 0.235 | |
| LLaDA meeting 4p | 0.410 | 0.750 | 0.340 | |
| Dream meeting 4p | 0.040 | 0.400 | 0.360 |
| People | Backbone | model uniform (sampling) | model shuffled (MAP) | Records |
|---|---|---|---|---|
| 4 | Dream | [ , ] | [ , ] | 100 |
| 4 | LLaDA | [ , ] | [ , ] | 100 |
| 5 | Dream | [ , ] | [ , ] | 98 |
| 5 | LLaDA | [ , ] | [ , ] | 98 |
| Backbone | People | Agreement | Judge, sorted | Judge, permuted | Judge, symmetrized | PLL |
|---|---|---|---|---|---|---|
| Dream | 3 | 0.627 | 0.320 | 0.267 | 0.310 | 0.490 |
| Dream | 4 | 0.487 | 0.270 | 0.235 | 0.290 | 0.290 |
| Dream | 5 | 0.430 | 0.143 | 0.146 | 0.184 | 0.173 |
| LLaDA | 3 | 0.729 | 0.970 | 0.850 | 0.970 | 0.970 |
| LLaDA | 4 | 0.642 | 0.730 | 0.643 | 0.710 | 0.570 |
| LLaDA | 5 | 0.543 | 0.296 | 0.276 | 0.357 | 0.214 |
| Dream-7B | LLaDA-8B | LLaDA-1.5 | ||||
|---|---|---|---|---|---|---|
| Budget | Rerank | Oracle | Rerank | Oracle | Rerank | Oracle |
| greedy | 0.120 | 0.530 | 0.650 | |||
| 0.240 | 0.250 | 0.790 | 0.790 | 0.840 | 0.840 | |
| 0.360 | 0.370 | 0.930 | 0.940 | 0.930 | 0.940 | |
| 0.490 | 0.500 | 0.970 | 0.970 | 0.970 | 0.980 | |
| Benchmark | Metric | What determines it | Shortcut result |
|---|---|---|---|
| Official Sudoku (900) | exact match | unique feasible completion | model-free uniform unary potentials reach 900/900 in 36.22 ms |
| Same-order copy | validity | constraint, by construction | second block is a function of the first |
| GRAM N-Queens | target agreement | canonical labeling | target is the lexicographic minimum in 405/405 multi-solution instances |
| GRAM coloring | target partition | canonical labeling | vertex-order greedy reproduces the target on 309/309 graphs; every dLLM method scores below chance |
| NATURAL PLAN | normalized objective | a degenerate control | uniform-MAP scores zero by tie-break; against random unary potentials LLaDA gains 21 points and Dream loses |
| Model | Method | Valid (%) | Partition (%) | Agreement (%) | ms/output |
|---|---|---|---|---|---|
| Dream | Independent | 2.68 | 0.00 | 55.47 | 69.03 |
| Finite support | 100.00 | 13.87 | 76.02 | 71.71 | |
| Factor separator | 100.00 | 16.78 | 76.92 | 71.16 | |
| LLaDA | Independent | 0.89 | 0.00 | 54.88 | 76.57 |
| Finite support | 100.00 | 15.88 | 77.52 | 79.18 | |
| Factor separator | 100.00 | 16.78 | 77.82 | 78.66 |
| Model | Method (MAP unless noted) | Valid (%) | Objective (%) | skip rate | Optimum (%) |
|---|---|---|---|---|---|
| Dream | Independent model | 79.00 | 42.83 | — | 6.00 |
| Uniform factor | 100.00 | 0.00 | 1.000 | 0.00 | |
| Uniform factor, sampling | 100.00 | 57.94 | 0.450 | 22.30 | |
| Random factor | 100.00 | 62.61 | 0.401 | 24.30 | |
| Shuffled-position factor | 100.00 | 52.78 | 0.497 | 12.30 | |
| Factor model | 100.00 | 55.83 | 0.467 | 12.00 |
| Model | BFCL-derived method | Execution (%) | Exact plan (%) | ms/output |
|---|---|---|---|---|
| Dream | Format-only (typed slots) | 1.61 | 1.61 | 118.20 |
| One-shot CP-SAT | 15.32 | 15.32 | 136.96 | |
| Component factor | 16.13 | 15.32 | 593.44 | |
| Global verifier | 10.48 | 9.68 | 3,443.28 | |
| Factorized verifier | 16.13 | 16.13 | 3,333.92 | |
| LLaDA | Format-only (typed slots) | 0.81 | 0.81 | 130.55 |
| Finite-state lower bound | Factor peak | Finite support | FactorDLM | |
|---|---|---|---|---|
| 4 | 256 | 16 | runs | 100% valid |
| 8 | 65,536 | 16 | runs | 100% valid |
| 16 | 4,294,967,296 | 16 | state cap | 100% valid |
| 32 | 18,446,744,073,709,551,616 | 16 | state cap | 100% valid |
| Alternatives | Grammar MB | Compile ms | Query ms | RSS MiB | |
|---|---|---|---|---|---|
| 2 | 16 | 0.0002 | 0.06 | 0.04 | 80.0 |
| 4 | 256 | 0.0046 | 0.57 | 0.43 | 80.0 |
| 6 | 4,096 | 0.1065 | 14.18 | 11.70 | 80.0 |
| 8 | 65,536 | 2.2282 | 278.48 | 377.01 | 206.9 |
| 10 | 1,048,576 | 44.0402 | 4,764.55 | 8,238.87 | 4,114.6 |
| Method | Cells | vs. 1-worker CP-SAT | 95% CI | vs. 8-worker CP-SAT |
|---|---|---|---|---|
| Factor CPU | 8 | 61.06 | [19.43, 201.84] | 43.11 |
| Factor CUDA | 8 | 19.33 | [5.82, 64.73] | 13.64 |
Constrained Decoding
Constrained decoding steers language model outputs to satisfy formal or task-specific rules while balancing validity, quality, and faithful probabilities.
See all 67 papers