Chance-Constrained Flow Optimization

Zifan Wang, Riccardo De Santi, Michael M. Zavlanos, Andreas Krause, Karl H. JohanssonarXiv 2026

TL;DR

When fine-tuning diffusion and flow models, optimizing for average safety or quality can still leave you with plenty of bad samples—high scores on some outputs simply mask failures on others. Chance-Constrained Flow Optimization (CCFO) solves this by maximizing reward while guaranteeing that at least a prescribed fraction of generated samples meet a target criterion. Best of all, it reduces this tricky constrained problem to a simple two-step recipe: estimate a single number from pre-trained samples, then run standard fine-tuning once.

What Problem Does This Paper Address?

Pre-trained diffusion and flow models are great at mimicking training data, but real-world deployment usually requires steering them toward specific goals—like rendering legible text in images or designing high-fitness proteins. The standard way to do this is KL-regularized fine-tuning: maximize expected reward while staying close to the pre-trained distribution.

Recently, researchers have added constraints to this setup, typically by capping the expected value of some constraint function ($\mathbb{E}[g(X)] \le c$). The catch? Averages can be deceptive. A model can easily satisfy a constraint on average while still producing a large fraction of invalid samples, because very safe samples offset the violating ones. In many applications—like ensuring 90% of generated proteins are sufficiently novel—you care about the probability of success, not the average.

Methods

CCFO formulates this directly as a chance-constrained optimization problem: maximize expected reward (with KL regularization) subject to $\mathbb{P}[g(X) \le 0] \ge 1 - \beta$, where $\beta$ is your allowable failure rate.

Rewriting the probability as the expectation of a binary indicator $s(x) = \mathbf{1}\{g(x) \le 0\}$ unlocks a neat mathematical shortcut. The authors prove (Theorem 1) that the dual of this problem is a 1D convex optimization over a single Lagrange multiplier $\lambda \ge 0$, which admits a closed-form solution:

$$\lambda^* = \alpha \left[ \log \frac{(1-\beta)A}{\beta B} \right]_+$$

Here, $A$ and $B$ are simply the reward-weighted probability masses that the pre-trained model assigns to the infeasible and feasible regions, respectively, and $\alpha$ is the KL regularization weight.

This leads to a lightweight, two-stage algorithm:

  1. Multiplier estimation: Draw $N$ samples from the pre-trained model, evaluate their rewards and constraint satisfaction, and compute the empirical estimate $\hat{\lambda}$.
  2. Single fine-tuning run: Plug $\hat{\lambda}$ into a modified pseudo-reward $r(x) + \hat{\lambda} s(x)$ and run any off-the-shelf entropy-regularized fine-tuning solver (such as DiffusionNFT for non-differentiable rewards, or Adjoint Matching with a smooth sigmoid surrogate).

Unlike prior constrained methods (such as CFO) that require alternating updates between the model and the dual variable, CCFO decouples them completely—making it roughly as fast as standard unconstrained fine-tuning.

Datasets

The authors evaluate CCFO across three settings:

  • 2D "Striped Tunnel" (Illustrative): A synthetic 4-component Gaussian mixture where the feasible region is a corridor with circular exclusions, and rewards increase in regions that overlap the exclusions.
  • Text-to-Image Generation: Stable-Diffusion 3.5, optimizing OCR (text-rendering) accuracy while imposing a chance constraint on the Aesthetic score ($\ge 5.3$, the pre-trained median). Evaluated on 4,096 generated images over 3 seeds.
  • Protein Sequence Design: A continuous ESM diffusion model on the TrpB enzyme dataset (389 residues, 15 designable). The goal is to maximize catalytic fitness while requiring novelty (mutation distance $d \ge 8$ from wild-type). Evaluated on 4,096 samples over 3 runs.

Key Insights and Ideas

  • Reallocating mass without distorting preferences: Because the indicator $s(x)$ only takes two values, the optimal distribution is a mixture of two fixed conditional distributions—one on the feasible set, one on the infeasible set. Varying $\lambda$ only changes how often feasible samples are drawn, leaving the reward-driven ranking within each region untouched.
  • Why expected constraints fail: In the 2D example, an expected-value constraint ($\mathbb{E}[g(X)] \le 0$) is satisfied even when only 38.3% of samples are actually feasible. CCFO directly targets the feasibility rate, hitting 90% at $\beta = 0.1$ and 100% at $\beta = 0$.
2D striped tunnel example comparing Pre-trained, CFO, and CCFO
  • Sensitivity guarantees: The authors show that the ideal target distribution is Lipschitz-continuous in $\hat{\lambda}$ (with estimation error scaling as $O(N^{-1/2})$) and bounded under imperfect constraint oracles, where errors on high-reward samples matter most.

Key Results

Across all three domains, CCFO achieves a better reward–feasibility Pareto frontier than baselines (Reward FT, Gated Reward FT, Augmented CGM-relax, and CFO):

  • 2D Example: At a matched 90% feasibility, CCFO achieves an expected reward of 0.733, compared to 0.480 for CFO.
  • Text-to-Image: CCFO reaches the highest Mean OCR score (0.789) at 90.67% feasibility (vs. CFO's 0.782 OCR at 89.26% feasibility, and Gated Reward FT's 0.617 OCR at 93.20% feasibility). It also leads on ImageReward (0.431) and HPSv2 (0.244).
  • Protein Design: CCFO achieves both the highest mean fitness (0.392) and highest feasibility (82.30%), discovering 142 distinct feasible, high-fitness ($f > 1$) designs—well ahead of Augmented CGM-relax (94) and CFO (84).

Limitations and Future Work

The closed-form multiplier relies on the binary structure of a single chance constraint. Extending CCFO to multiple simultaneous chance constraints—where dual variables become coupled—remains an open direction. Additionally, in discrete, high-dimensional settings like protein design, the binary indicator provides a sparse training signal; in practice, the authors periodically refine $\hat{\lambda}$ and partially smooth the indicator at high feasibility targets.

Summary updated

BibTeX
@misc{wang2026chance,
  author = {Zifan Wang and Riccardo De Santi and Michael M. Zavlanos and Andreas Krause and Karl H. Johansson},
  title = {{Chance-Constrained Flow Optimization}},
  year = {2026},
  eprint = {2612.05770},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2612.05770},
}
Figure