arXiv:2610.12699cs.LGOct 2026

Manuscript Offprint

arXiv:2610.12699

Primal-Dual Flow Matching for Sample-Wise Constrained Generation

Zhengyan Huan, Peter Y. Lu, Shuchin Aeron

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

We consider the problem of learning to generate data while satisfying a prescribed sample-wise constraint with a user-specified probability of constraint satisfaction. Starting with a population-level constrained negative log-likelihood minimization and using a flow-matching (FM) parameterization, under regularity assumptions and sufficient expressivity of the velocity field family, we derive guarantees on the probability of constraint satisfaction for the corresponding primal-dual optimization algorithm. We provide a practical implementation of this approach, called Primal-Dual Flow Matching (PDFM), which has direct control over constraint satisfaction rate and requires only binary membership oracle feedback for constraint satisfaction, avoiding the need for differentiable distances, projections, or special structure of the constraint set, such as convexity. We show that PDFM improves constraint satisfaction over vanilla FM and achieves competitive performance against constraint-aware baselines while maintaining distributional fidelity. Our code is available at https://github.com/ZhengyanHuan/PDFM.

1 Introduction

The utility of generative models for scientific applications highly depends on their ability to generate samples that obey scientific laws or satisfy an application-specific criterion, modeled via constraints that can be validated numerically. For example, flow- and diffusion-based generative models are increasingly used to emulate chaotic spatiotemporal systems [Lienen et al., 2024, Du et al., 2024, Price et al., 2025], where the chaotic dynamics result in high sensitivity to initial conditions and therefore unpredictable trajectories that can be interpreted and modeled probabilistically [Medio and Lines, 2001]. However, in these settings, distributional fidelity alone is rarely sufficient: a generated sample is useful only if it is also physically consistent, e.g., satisfying boundary conditions, respecting conservation laws, or following a governing PDE [Beucler et al., 2021, Utkarsh et al., 2025]. Another important example comes from molecular generation [Hoogeboom et al., 2022, Song et al., 2023], where one wants to generate new molecules such that they conform to structures with chemically useful properties [Bickerton et al., 2012, Giaginis et al., 2018] that are numerically quantifiable.

Related work: For constrained generation, one may divide existing literature into (a) Type of constraints, e.g., distributional constraints [Khalafi et al., 2024] or sample-wise constraints [this work]. Among sample-wise constraints, one may have constraints with topological specification, such as convexity [Liu et al., 2023]; constraints with known boundaries [Lou and Ermon, 2023, Fishman et al., 2023]; constraints with differentiable distances to them [Feng et al., 2025, Utkarsh et al., 2025]; or constraints that are known only via a membership oracle [Huan et al., 2026]; and (b) Methods used – whether it is inference-time [Christopher et al., 2024] [Utkarsh et al., 2025] [Li et al., 2026] [Zhu et al., 2026] or training-time [this work], [Lou and Ermon, 2023, Fishman et al., 2023] [Xie et al., 2024] [Feng et al., 2025] [Giannone et al., 2023] [Huan et al., 2026]. A more detailed review

40th Conference on Neural Information Processing Systems (NeurIPS 2026).

of these related works is provided in Appendix A and throughout the exposition we will highlight other closely related works.

For sample-wise constrained generation when the constraints are accessible via a membership oracle, we make the following main contributions:

  1. We develop a theoretically grounded approach, with provable guarantees on the probability of constraint satisfaction. In particular, leveraging an FM parameterization of a constrained negative log-likelihood minimization (Sections 2, 3), in Theorem 3.5 we show that under mild assumptions the Total Variation (TV) norm between the optimal solution and the FM parameterized solution can be controlled in terms of approximation error between the flows due to parametric modeling, which in turn leads to overall control on constraint satisfaction. We then show that a theoretical Primal-Dual Flow Matching (PDFM) Alg. 1 achieves this bound.

  2. We then propose a practical implementation of PDFM in Alg. 2, with theoretical guarantees discussed in Sec. 4.3. Key innovations in this algorithm are motivated by deterministic policy gradient methods, where we build differentiable surrogates for constraint satisfaction probability under the FM parameterization. This enables the method to work with only membership oracle access to the constraint set. We note that this type of access to the constraint is the most flexible when the constraints are complex.

  3. We provide an extensive evaluation of PDFM and show that compared to existing methods, it achieves competitive constraint satisfaction rates and distribution fidelity. For scientific applications, we consider the problem of learning to generate PDE-constrained spatiotemporal dynamics of chaotic systems and show that our method achieves superior performance while requiring only binary feedback. In a molecule generation task, PDFM improves molecule stability and distributional fidelity over FM over FM, without task-specific designs.