Constrained generative modeling is fundamental to applications such as robotic control and autonomous driving, where models must respect physical laws and safety-critical constraints. In real-world settings, these constraints rarely take the form of simple linear inequalities, but instead complex feasible regions that resemble road maps or other structured spatial domains. We propose a constrained generation framework that generates samples directly within such feasible regions while preserving realism. Our method fine-tunes a pretrained generative model to enforce constraints while maintaining generative fidelity. Experimentally, our method exhibits characteristics distinct from existing fine-tuning and training-free constrained baselines, revealing a new compromise between constraint satisfaction and sampling quality.
Figures & tables
Figure 1: Qualitative comparison of constrained trajectory generation. We visualize samples from the same traffic intersection scene and timestep, where gray dot trajectories indicate ground-truth agent motion and orange trajectories denote model predictions. Panel 1(a) shows an unconstrained diffusion baseline, which exhibits both offroad and collision violations while executing a left turn. Panel 1(b) shows a training-free guided method, MPGD without projection ( He et al., 2024 ) that reduces violations but introduces noticeable trajectory distortion, including persistent offroad behavior and an abrupt acceleration during a right-turn maneuver toward the northeast, leading to a near-collision. Panel 1(c) shows our MBM++, which exhibits no offroad or collision violations while preserving realistic and coherent motion. All samples are generated from the same initial conditions.
Method
Collision ( % ) ↓
Boundary ( % ) ↓
r-ELBO( ×10−2 ) ↑
HDH ( ×10−2 ) ↓
Standard diffusion
38.12±0.36
6.29±0.06
−21.7±0.1
28.9±1.23
MPGD w/o projection
0.00±0.00
0.00±0.00
−27.1±0.1
\uline27.7±0.5
MBM
2.86±0.04
1.91±0.03
\uline−22.2±0.1
28.4±0.6
DM-MBM++ (Ours)
\uline0.01±0.00
\uline0.03±0.00
−22.8±0.1
27.5±1.3
Standard FM
29.17±0.31
3.80±0.08
−37.3±0.1
28.5±2.0
TF-Guided FM
1.03±0.03
0.19±0.02
−52.9±0.3
30.4±1.4
Table 1: Bouncing balls experiment results. Best results are in bold . Second best results are \ulineunderlined .
Figure 2: Visualization of the bouncing balls task. Panel 2(a) and panel 2(b) show two consecutive steps before and after a bounce between the balls 3 and 8. In each step, each ball is represented by a 4-dimensional vector representing its location and velocity, shown by the red arrows. Panel 2(c) presents a Pareto comparison for diffusion-based models in terms of ELBO and infraction rate. Higher ELBO and lower infraction rate indicate better performance, with preferable methods located toward the upper-left region. Our method lies near the Pareto frontier, achieving a favorable trade off between these two metrics.
Method
Collision ( % ) ↓
Offroad ( % ) ↓
minADE6↓
minFDE6↓
MFD6↑
DJINN
0.39
8.12
0.194
0.459
2.483
CriticSMC
1.03
–
0.345
–
2.201
MPGD w/o projection
0.32
0.29
0.195
0.467
2.372
MBM++ (Ours)
0.27
0.44
0.180
0.452
2.352
Table 2: Trajectory Prediction on INTERACTION ( Zhan et al., 2019 ) : DR_DEU_Merging_MT. Offroad rate and FDE are not reported for criticSMC, and we leave them blank. Our MBM++ achieves significantly lower collision and offroad rate compared to prior baselines while having the lowest minADE6 and minFDE6 .
Figure 3: Comparisons on DR_DEU_Merging validation dataset (merging into single-lane scenario). In panel 3(a) , the unconstrained baseline produces an offroad trajectory for the vehicle near the bottom-right, deviating beyond the right road boundary. In panel 3(b) , MPGD without projection applies an overly strong correction that pushes the same vehicle toward the left boundary, while the middle vehicle exhibits noticeable trajectory distortion. In contrast, panel 3(c) maintains all predicted trajectories within the single drivable lane, preserving realistic motion without violations.
Appendix figures & tables9 assets
Supplementary material from the paper’s appendix.
Appendix
Method
Collision ( % ) ↓
Offroad ( % ) ↓
minADE6↓
minFDE6↓
MFD6↑
DJINN
1.48
22.03
0.324
1.043
5.266
CriticSMC
0.08
–
0.445
–
3.425
MPGD w/o projection
1.62
1.78
0.338
1.000
4.787
MBM++ (Ours)
1.57
2.49
0.327
1.005
4.684
Appendix
Table 3: Trajectory Prediction on INTERACTION ( Zhan et al., 2019 ) : DR_DEU_Roundabout_OF.
Method
Collision ( % ) ↓
Offroad ( % ) ↓
minADE6↓
minFDE6↓
MFD6↑
DJINN
1.24
1.25
0.231
0.637
3.990
CriticSMC
0.09
–
0.448
–
2.871
MPGD w/o projection
1.13
0.04
0.229
0.635
3.882
MBM++ (Ours)
0.92
0.06
0.211
0.629
3.834
Appendix
Table 4: Trajectory Prediction on INTERACTION ( Zhan et al., 2019 ) : DR_USA_Intersection_MA.
Method
Collision ( % ) ↓
Offroad ( % ) ↓
minADE6↓
minFDE6↓
MFD6↑
DJINN
1.10
8.50
0.236
0.704
3.757
CriticSMC
0.07
–
0.444
–
2.974
MPGD w/o projection
1.13
0.26
0.233
0.685
3.594
MBM++ (Ours)
1.12
0.35
0.219
0.676
3.544
Appendix
Table 5: Trajectory Prediction on INTERACTION ( Zhan et al., 2019 ) : DR_USA_Roundabout_FT.
Deep generative models provide state-of-the-art performance across a wide array of applications, with recent studies showing increasing applicability for science and engineering. Despite a growing corpus of literature focused on the integration of physics-based constraints into the generation process, existing approaches fail to enforce strict constraint satisfaction while maintaining sample quality. In particular, training-free constrained sampling methods, while providing per-sample feasibility guarantees, introduce a fundamental mismatch between the training objective and the constrained sampling procedure, often leading to performance degradation. Identifying this training-sampling misalignment as a central limitation of current constrained generative modeling approaches, this paper proposes Constraint-Aware Flow Matching, a novel end-to-end framework that explicitly incorporates constraint projections into the training objective. By aligning the model's learned dynamics with the constrained sampling process, the proposed method mitigates distributional shift induced by projection-based corrections, enabling high-quality constrained generation. The proposed approach is evaluated on three challenging real-world benchmarks, illustrating the generality and efficacy of the method.
Jacob K. Christopher, James E. Warner, Ferdinando Fioretto
University of Virginia · NASA Langley Research Center
Flow-based generative models, such as diffusion models and flow matching models, have achieved remarkable success in learning complex data distributions. However, a critical gap remains for their deployment in safety-critical domains: the lack of formal guarantees that generated samples will satisfy hard constraints. We propose a safety filtering framework that acts as an online shield for any pre-trained generative model. Our key insight is to cooperate with the generative process rather than override it. We define a constricting safety tube that is relaxed at the initial noise distribution and progressively tightens to the target safe set at the final data distribution, mirroring the coarse-to-fine structure of the generative process itself. By characterizing this tube via Control Barrier Functions (CBFs), we synthesize a feedback control input through a convex Quadratic Program (QP) at each sampling step. As the tube is loosest when noise is high and intervention is cheapest in terms of control energy, most constraint enforcement occurs when it least disrupts the model's learned structure. We prove that this mechanism guarantees safe sampling in discrete-time. The minimum-norm control synthesized at each step minimizes the per-step contribution to the KL divergence between the safe and original distributions. Across all experiments, we observe 100% constraint satisfaction. Our framework applies to any pre-trained flow-based sampling scheme requiring no retraining or architectural modifications. We validate the approach across constrained image generation, physically-consistent trajectory sampling, and safe robotic manipulation policies, achieving 100% constraint satisfaction while preserving semantic fidelity.
Darshan Gadginmath, Ahmed Allibhoy, Fabio Pasqualetti
Mitsubishi Electric Research Laboratories Cambridge, Massachusetts · Electrical Engineering and Computer Science University of California, Irvine
Constrained generative models aim to produce samples that satisfy complex feasibility constraints while remaining faithful to the data distribution. Existing constrained generation methods typically enforce constraints either through training-time optimization or sampling-time correction. Training-time optimization approaches optimize on states induced by the training distribution, which can differ substantially from those encountered during sampling. Sampling-time correction methods instead modify the sampling process at inference, introducing distribution shift and requiring expensive tuning, particularly for few-step sampling. We propose a fine-tuning framework that incorporates constraint guidance obtained through online rollout into the training process, which aligns training with sampling by differentiating through the fixed noise schedule used to numerically integrate the denoising process. This exposes the model to violations that arise along the denoising trajectory and aligns diffusion learning with the sampling process. Experiments across multiple tasks show that our method improves constraint satisfaction while maintaining competitive sampling quality compared to prior methods.