Related Experiment Video
Updated: Jul 3, 2026

Human Fetal Blood Flow Quantification with Magnetic Resonance Imaging and Motion Compensation
Published on: January 7, 2021
HardFlow: Hard-Constrained Sampling for Flow-Matching Models Via Trajectory Optimization
None:
Diffusion and flow-matching have emerged as powerful methodologies for generative modeling, with remarkable success in capturing complex data distributions and enabling flexible guidance at inference time. Many downstream applications, however, demand enforcing hard constraints on generated samples-for example, robot trajectories must avoid obstacles-a requirement that goes beyond simple guidance. Prevailing projection-based approaches constrain the entire sampling path to the constraint manifold, which is overly restrictive and degrades sample quality. In this paper, we introduce a novel framework that reformulates hard-constrained sampling as a trajectory optimization problem. Our key insight is to leverage numerical optimal control to steer the sampling trajectory so that constraints are satisfied precisely at the terminal time. By exploiting the underlying structure of flow-matching models and adopting techniques from model predictive control, we transform this otherwise complex constrained optimization problem into a tractable surrogate that can be solved efficiently and effectively. Furthermore, this trajectory optimization perspective offers significant flexibility beyond mere constraint satisfaction, allowing for the inclusion of integral costs to minimize distribution shift and terminal objectives to further enhance sample quality, all within a unified framework. We provide a control-theoretic analysis of our method, establishing bounds on the approximation error between our tractable surrogate and the ideal formulation. Extensive experiments across diverse domains, including robotics (planning), partial differential equations (boundary control), and vision (text-guided image editing), demonstrate that our algorithm, which we name HardFlow, substantially outperforms existing methods in both constraint satisfaction and sample quality.
Related Concept Videos
Rapidly Varying Flow
Uniform Depth Channel Flow: Problem Solving
Turbulent Flow: Problem Solving
Temperature is a key factor in CO2 solubility. In this case, the CO2 gas and the liquid are cooled to 20°C. Lower temperatures enhance...
Gradually Varying Flow
Steady Flow of a Fluid Stream
During this process, the momentum of the fluid within the control volume remains constant over the time interval dt. By applying the...
Turbulent Flow

