Physics-Constrained Flow Matching: Sampling Generative Models with Hard Constraints

Utkarsh Utkarsh, Pengfei Cai, Alan Edelman, Rafael Gomez-Bombarelli, Christopher Vincent Rackauckas
6/4/2025
cs.LGcs.AIcs.CE

No official code found. Best implementation: cpfpengfei/PCFM (31 stars, last commit 2025-12-02). 1 more below.

Abstract

Deep generative models have recently been applied to physical systems governed by partial differential equations (PDEs), offering scalable simulation and uncertainty-aware inference. However, enforcing physical constraints, such as conservation laws (linear and nonlinear) and physical consistencies, remains challenging. Existing methods often rely on soft penalties or architectural biases that fail to guarantee hard constraints. In this work, we propose Physics-Constrained Flow Matching (PCFM), a zero-shot inference framework that enforces arbitrary nonlinear constraints in pretrained flow-based generative models. PCFM continuously guides the sampling process through physics-based corrections applied to intermediate solution states, while remaining aligned with the learned flow and satisfying physical constraints. Empirically, PCFM outperforms both unconstrained and constrained baselines on a range of PDEs, including those with shocks, discontinuities, and sharp features, while ensuring exact constraint satisfaction at the final solution. Our method provides a flexible framework for enforcing hard constraints in both scientific and general-purpose generative models, especially in applications where constraint satisfaction is essential.

View on arXivView PDF

Code Implementations(2)

cpfpengfei/PCFMCommunity73%

Physics-Constrained Flow Matching: Sampling Generative Models with Hard Constraints (NeurIPS 2025)

310PythonSep 18, 202510 months agoNOASSERTION
utkarsh530/PCFM.jlCommunity72%
MIT

Physics-Constrained Flow Matching: Sampling Generative Models with Hard Constraints

52JuliaOct 23, 202512 months agoMIT

Similar Papers

Cite this paper

@article{utkarsh2025physicsconstrained,
  title  = {Physics-Constrained Flow Matching: Sampling Generative Models with Hard Constraints},
  author = {Utkarsh Utkarsh and Pengfei Cai and Alan Edelman and Rafael Gomez-Bombarelli and Christopher Vincent Rackauckas},
  year   = {2025},
  eprint = {2506.04171},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2506.04171v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2506.04171.svg)](https://codeofpaper.com/paper/2506.04171)

Discussion