A robot path can be almost excellent and still hit a person. An image edit can preserve nearly every feature and still change the identity that was meant to remain fixed. In safety-critical or tightly specified work, “close” and “valid” are different outcomes. HardFlow is a new method for steering a pretrained generative model so its final output obeys a hard requirement while the model continues searching for a high-quality solution.[1][2][3]
The method is designed for flow-matching models, a family that generates an output by moving a sample from simple noise through a learned continuous trajectory. HardFlow operates at deployment time. It does not retrain the foundation model; it modifies the path taken during this particular generation.[1][2]
Why constraining every intermediate step can make the result worse
A common approach repeatedly projects intermediate samples back onto the feasible set. That sounds safe, but the intermediate states are algorithmic scaffolding rather than delivered answers. Forcing every temporary state to obey the final rule can prune promising routes before the model reaches them. The paper argues that only the terminal state needs to satisfy the hard constraint.[2]
Imagine planning around an obstacle. A conventional route optimiser may need every provisional path to be collision-free. HardFlow can explore less literal intermediate representations while steering the final trajectory into the safe region. The freedom belongs to the internal search, not to the physical robot after a route is chosen.
Hard constraints and quality objectives in four applications
| Application | Hard requirement | Quality objective |
|---|---|---|
| Robot manipulation | The arm’s delivered path does not intersect an obstacle | Reach the object quickly or with a shorter trajectorySource 1Source 2 |
| Maze navigation | The final route remains inside permitted space and reaches the goal | Reduce travel distance or control effortSource 1Source 2 |
| Physical-system control | The terminal state obeys boundary and system requirements | Reach the desired state with less interventionSource 2 |
| Text-guided image editing | Specified attributes remain within the constraint | Make the requested edit while preserving visual quality and distribution fitSource 1Source 2 |
The generation becomes an optimal-control problem
HardFlow treats small changes to the model’s learned velocity field as control inputs. It then asks which sequence of changes will carry the sample to a valid terminal state while minimising unnecessary deviation and, where desired, improving another objective. This is trajectory optimisation applied to the generation process.[2]
Solving that optimisation directly around a deep neural network would be prohibitively difficult. The decision space grows with both the data dimension and the number of integration steps, while a final constraint must influence earlier moves through the model’s dynamics. The researchers exploit the structure of flow matching and ideas from model-predictive control to break the long problem into smaller single-step subproblems.[1][2]
What HardFlow changes
| Measure | Value | Context |
|---|---|---|
| Training | None required for the base model | The method is applied to a pretrained flow-matching generator at deployment time.Source 2 |
| Constraint timing | Terminal output | Intermediate algorithmic states receive more freedom than in per-step projection.Source 2 |
| Optimisation form | Trajectory control | Corrections steer the generation path rather than replace the model’s learned distribution.Source 2 |
| Additional goals | Integral and terminal costs | The method can minimise control effort or improve a desired quality alongside feasibility.Source 2 |
| Reported domains | Robotics, PDE control and vision | The evaluation spans planning, boundary control and text-guided image editing.Source 2 |
| Reported compute | Comparable to or lower than most baselines | MIT’s summary describes the tested computation time, not a universal serving guarantee.Source 1 |
Perfect constraint satisfaction is a measured result with a defined test
MIT reports that HardFlow achieved perfect constraint satisfaction across the published experiments and consistently improved solution quality relative to the tested methods. In robot manipulation, it found collision-free paths that reached the target faster; in other tasks, the relevant quality measure differed. “Perfect” refers to those experimental constraint checks, not proof that every future real-world deployment is fail-safe.[1][2]
That boundary is important without weakening the achievement. A constraint checker can verify whether the generated route intersects the modelled obstacle. It cannot guarantee that a camera detected every person, that the obstacle model is current, or that the robot follows the commanded route exactly. HardFlow improves one layer: generating a feasible plan under the specified representation.
The method separates exploration from acceptance
This distinction could improve many AI systems. Let a generator propose widely, then make the delivered object pass a non-negotiable mathematical or physical check. The hard constraint supplies an acceptance gate; the quality objective decides which accepted result is worth using. That is a more useful division than asking a model to “be safe” inside a prompt and hoping every internal step remains sensible.
Generative AI is valuable because it can search a rich space of possibilities. Safety-critical engineering is demanding because some possibilities are unacceptable. HardFlow connects those facts: preserve the search, define the boundary precisely and make validity a property of the delivered result rather than a tone the model is asked to imitate.
Sources & further reading
- New method enables AI for safety-critical situations MIT News · 14 Sep 2026 · Accessed 9 Oct 2026
- HardFlow: Hard-Constrained Sampling for Flow-Matching Models via Trajectory Optimization Zeyang Li, Kaveh Alim and Navid Azizan / arXiv · 11 Nov 2025 · Accessed 9 Oct 2026
- HardFlow: Hard-Constrained Sampling for Flow-Matching Models via Trajectory Optimization IEEE Transactions on Pattern Analysis and Machine Intelligence · 14 Sep 2026 · Accessed 9 Oct 2026