Source-linked AI summary

Improving Flow Matching by Aligning Flow Divergence

Yuhao Huang, Taos Transue, Shih-Hsin Wang, William Feldman, Hong Zhang, Bao Wang

arXiv:2602.00869v1cs.LGcs.AImath.NA

TL;DR

CFM efficiently trains flow-based generative models, but matching vector fields alone may not accurately learn probability paths because divergence mismatch remains uncontrolled. The paper characterizes this error with a PDE and TV bound, then introduces FDM, which combines CFM with conditional divergence matching; experiments report significant improvements across challenging tasks, while efficient KL-divergence control remains future work.

  • Problem

    CFM can approximate the marginal vector field while leaving a substantial divergence gap that causes errors in probability-path learning and sample-likelihood estimation.

  • Method

    The paper derives a PDE and TV error bound, then combines CFM with a conditional divergence-gap upper bound in the FDM objective.

  • Results

    FDM significantly improves flow matching across dynamical-system trajectories, DNA sequence design, and video prediction without sacrificing generation efficiency.

  • Takeaways & Limitations

    Accurate probability-path learning requires controlling divergence alongside vector-field discrepancy, and FDM provides a computationally efficient way to do so.

  • Takeaways & Limitations

    Efficient control of the KL divergence remains an open direction, and integrating FDM into a strong existing video-generation framework is left for future work.

Abstract

from arXiv · show

Conditional flow matching (CFM) stands out as an efficient, simulation-free approach for training flow-based generative models, achieving remarkable performance for data generation. However, CFM is insufficient to ensure accuracy in learning probability paths. In this paper, we introduce a new partial differential equation characterization for the error between the learned and exact probability paths, along with its solution. We show that the total variation gap between the two probability paths is bounded above by a combination of the CFM loss and an associated divergence loss. This theoretical insight leads to the design of a new objective function that simultaneously matches the flow and its divergence. Our new approach improves the performance of the flow-based generative model by a noticeable margin without sacrificing generation efficiency. We showcase the advantages of this enhanced training approach over CFM on several important benchmark tasks, including generative modeling for dynamical systems, DNA sequences, and videos. Code is available at \href{https://github.com/Utah-Math-Data-Science/Flow_Div_Matching}{Utah-Math-Data-Science}.

1. Introduction

The paper identifies a gap in conditional flow matching: matching vector fields does not ensure accurate probability paths because divergence mismatch can remain substantial. It characterizes this error theoretically and proposes flow and divergence matching (FDM) to improve training across several generative tasks.

  • Motivation and setup: Flow matching learns a neural vector field that transports a prior noise distribution toward the data distribution without simulation.The target probability path satisfies p0 = q and p1 ≈ p.
  • Motivation and setup: Conditional flow matching makes training tractable by regressing against predefined conditional vector fields when the marginal field is unavailable.The conditional paths begin at q and end near a point mass at each data sample.
  • The limitation of CFM: CFM can leave a substantial divergence gap, causing errors in learned probability paths and sample-likelihood estimation despite approximating the vector field.Figure 1 reports a conditional divergence loss much larger than the CFM loss and a significant distributional gap.
  • Contributions: The paper characterizes probability-path error with a PDE and derives a total-variation bound involving vector-field and divergence discrepancies.The analysis motivates controlling divergence to improve the accuracy of the learned path.
  • Contributions: FDM combines CFM with a conditional divergence-gap loss that upper-bounds the unavailable unconditional divergence gap.The resulting objective is designed from the theoretical TV error bound.
  • Empirical validation: Experiments evaluate FDM on density estimation, dynamical systems, video generation, and DNA sequence generation, reporting improved likelihood estimation and sample generation over CFM.The paper also notes that controlling KL divergence efficiently remains future work.

2. Flow Matching

Flow matching defines a probability path from noise to data and trains a neural vector field to follow it. Conditional paths make this regression simulation-free and support common Gaussian, diffusion, and optimal-transport constructions.

  • Flow formulation: A vector field induces a flow that maps the prior noise distribution p0 = q to the data distribution p1 ≈ p.The flow is specified through an ODE with an initial condition.
  • Conditional flow matching: For each data sample, CFM defines a conditional path from q to a distribution near δ(x − x1) and regresses an unconditional neural vector field against its conditional field.This avoids directly regressing against the unavailable marginal vector field.
  • Conditional path designs: Gaussian conditional paths use endpoint means and variances chosen so the path starts at noise and approaches the data sample.The construction includes µ0(x1) = 0, σ0(x1) = 1, µ1(x1) = x1, and small σ1(x1).
  • Conditional path designs: Diffusion-model paths, including VE and VP SDE constructions, can be represented as conditional flow-matching paths.The VE construction uses an increasing noise scale, while the VP construction uses a noise-scale function β(s).
  • Conditional path designs: Optimal transport provides another conditional probability-path choice alongside diffusion paths.The paper identifies OT paths as a notable alternative design.

3. Error Analysis for Probability Paths

The paper derives how discrepancies between exact and learned vector fields propagate into probability-path error. The resulting analysis shows that divergence matching is as important as vector-field matching for controlling total variation.

  • Error PDE: The exact and learned probability paths satisfy continuity equations with the same initial condition, while their difference satisfies a PDE with an additional forcing term.The forcing term reflects discrepancies between the exact and learned vector fields.
  • Error propagation: Duhamel’s formula expresses the path error through the learned flow, its Jacobian determinant, and the forcing term.This solution identifies how the forcing term governs the magnitude of the error.
  • Error propagation: The error dynamics depend on both the vector-field difference and the divergence of that difference, not on vector-field mismatch alone.Both contributions enter the forcing term in the error PDE.
  • Error bound: Minimizing the divergence gap is as important as reducing vector-field discrepancy for learning an accurate probability path.This conclusion follows from the error representation and its dependence on divergence.
  • Error bound: The paper bounds TV(pt, ˆpt) using a divergence-related loss, and the learned and exact paths coincide when LDM is zero.The bound is stated under common mild assumptions.

4. Conditional Divergence Matching

The paper replaces the unavailable unconditional divergence loss with a conditional divergence loss that upper-bounds both divergence error and the total variation gap. Combining this loss with CFM yields FDM, which improves probability-path accuracy while retaining computational efficiency.

  • Conditional divergence matching: Because the divergence of the exact unconditional vector field is intractable, the method derives a conditional formulation using conditional continuity equations and their connection to unconditional divergence.The conditional construction parallels the simulation-free strategy used in conditional flow matching.
  • Conditional divergence matching: The conditional divergence loss provides an upper bound for both the divergence loss and the total variation gap between exact and learned probability paths.This connects a tractable conditional objective to the probability-path accuracy analyzed by the paper.
  • Flow and divergence matching: The proposed FDM objective combines CFM and conditional divergence matching, directly controlling gaps in both vector fields and their divergences.The weights λ1 and λ2 are positive hyperparameters selected by hyperparameter search.
  • Flow and divergence matching: Minimizing conditional divergence matching alone can fail because positive and negative terms may cancel, preventing the loss from reaching zero and offering no guarantee of vector-field proximity.The combined objective avoids relying on divergence matching alone to control the learned vector field.
  • Efficient implementation: The efficient implementation uses stop-gradient and Hutchinson trace estimation, adding only one extra backward pass relative to baseline flow matching.The paper presents this as computationally cheaper than controlling higher-order quantities such as the gradient of the divergence.
  • Synthetic experiment: In the Gaussian-mixture experiment, the total variation gaps are 0.0945 for FM and 0.0587 for FDM, with FDM learning the mixture more accurately.The comparison uses a three-layer MLP and FDM weights λ1 = 1 and λ2 = 0.2, while FM uses λ1 = 1 and λ2 = 0.

5. Experimental Results

The experiments evaluate FDM against FM across density estimation, DNA sequence generation, dynamical-system trajectories, and video prediction. FDM improves flow-based generation and likelihood-related metrics across these benchmark settings, with additional overhead described as acceptable for BAIR video prediction.

  • Synthetic density estimation: FDM consistently outperforms FM across different probability paths for checkerboard likelihood estimation.The comparison includes optimal transport and variance-preserving paths.
  • Simplex generation without guidance: FDM improves FM for non-guided categorical generation, reducing the gap between generated and target distributions on the simplex.The evaluation compares total variation distance and KL divergence for sequences with length 4 and 40 categories.
  • Promoter DNA sequence design: FDM improves guided promoter DNA sequence generation when evaluated by mean-squared error against predicted regulatory activity.The task uses 100,000 human promoter sequences of 1,024 base pairs and compares FM with discrete diffusion and language-model baselines.
  • Trajectory sampling: FDM achieves the lowest TV distance for every evaluated trajectory distribution and also attains the lowest negative log-likelihood estimates.The reported gains remain comparable across models for estimating the event probability p(E).
  • Video prediction: FDM enhances latent FM for video prediction, maintaining visual quality later in KTH sequences while FM shows degradation in fine motion and body details.KTH uses the first 10 frames to predict the next 30, and BAIR uses one initial frame to predict 15 future frames with acceptable additional computational overhead.

6. Concluding Remarks

The paper derives an upper bound on the gap between learned and ground-truth probability paths and uses it to motivate flow and divergence matching. The approach significantly improves flow matching across challenging tasks, while KL-divergence control and Schrödinger-bridge extensions remain open directions.

  • The paper develops an upper bound for the gap between learned and ground-truth probability paths using flow matching.
  • The bound motivates matching the divergences of learned and target vector fields through a computationally efficient conditional divergence loss.
  • Flow and divergence matching significantly improves flow matching on various challenging tasks.
  • Efficiently controlling KL divergence and extending the approach to Schrödinger-bridge settings remain future research directions.

Impact Statement

The work contributes a new theoretical understanding of probability-path error and an efficient objective for improving flow matching. It targets flow-based generative modeling, an area with applications including climate and molecular modeling.

  • The paper introduces a theoretical bound on the gap between exact and learned probability paths using flow matching.
  • The bound informs a new efficient training objective designed to improve flow matching.
  • The work advances flow-based generative modeling, which has shown results in climate and molecular modeling.

A. Missing Proofs

The missing-proof passages characterize the probability-path error through a PDE, derive its flow-based solution, and establish a total-variation bound. They also state that zero divergence-matching loss yields exact agreement between the learned and target paths.

  • The error ϵ_t := p_t − ˆp_t satisfies a partial differential equation with initial condition ϵ_0 = 0.
  • The PDE solution is expressed using the flow induced by v_t, its Jacobian determinant, and Duhamel’s formula.
  • Under common mild assumptions, Theorem 3.3 establishes an inequality for the probability-path error at any t ∈ [0, 1].
  • When L_DM is zero, the exact and learned probability paths coincide: p_t(x) = ˆp_t(x).
  • The proof connects the error bound to total variation distance and derives it through successive algebraic substitutions and changes of variables.

B. Experiments Details

The experiments use numerical dynamical-system, DNA-promoter, and human-motion or robot-pushing datasets with specified solvers, architectures, training procedures, and divergence estimation. Dynamical-system likelihoods are evaluated over 32,000 generated test trajectories.

  • Dynamical systems: The experiments study Lorenz and FitzHugh–Nagumo dynamical systems, using scaled Lorenz parameters and specified FitzHugh–Nagumo coefficients.
  • Dynamical systems: Each dynamical-system trajectory contains 60 evenly spaced time steps after burn-in, with initial conditions sampled from Gaussian distributions.
  • Training: All models use the same UNet architecture and variance-exploding schedule, trained for 2,000 epochs with Adam on 32,000 trajectories.
  • Divergence estimation: The divergence is estimated with Hutchinson’s trace estimator using noise sampled from N(0, I).
  • Evaluation: Likelihoods are computed for 32,000 test trajectories using the continuous change-of-variables formula and an ODE solver.

B.2. DNA Sequence Generation

This section develops classifier-based divergence matching for DNA sequence generation, avoiding direct divergence computation while retaining the flow-matching formulation. It also describes promoter-sequence data and training settings for evaluating the approach.

  • Method: Classifier-based construction replaces direct vector-field approximation with a classifier-derived vector field and an associated divergence term.
  • Computational consideration: Directly learning the vector-field divergence can be expensive because it requires computing derivatives across all K categories.
  • Computational consideration: The conditional vector fields and their divergences are predefined and parameter-independent, so the model need not learn them.
  • Classifier regularization: The ideal classifier is discontinuous across the domain, while its input gradient is zero on differentiable sub-domains.
  • Classifier regularization: Training therefore penalizes classifier-input gradients near perturbed data points assumed to share the same class label.
  • Data and training: The promoter dataset contains 100,000 sequences of 1,024 base pairs, with chromosomes 8 and 9 reserved for testing.
  • Data and training: Models use 100 inference steps for promoter design, while the simplex toy experiment trains for 450,000 steps with batch size 512.

C.2. Flow Matching for User-defined Events

This section evaluates flow matching on user-defined event constraints using unguided and guided sampling. It compares histogram-based KL divergence across diffusion, FM, and FDM models and notes a practical modification to the divergence objective.

  • Unguided sampling: Unguided sampling compares model-generated event-constraint histograms with data and trajectory distributions.
  • KL divergence results: For Lorenz, FDM has the lowest unguided KL divergence, while FM performs better than FDM in guided sampling by about 0.05.
  • KL divergence results: For FitzHugh-Nagumo, the diffusion model has lower unguided KL divergence than FM and FDM by 0.002.
  • Objective modification: The conditional divergence loss is replaced in practice by a squared loss because the absolute-value objective is nonsmooth at zero and can be less efficient.
  • Objective modification: The squared conditional divergence loss provides an upper bound for the original conditional divergence-matching loss.

D.1. Efficient Squared Loss for High-dimensional Data

This section makes squared divergence matching practical for high-dimensional data by estimating Jacobian traces with Hutchinson’s method and using stop-gradient optimization. The resulting objective adds only one extra backward pass over CFM.

  • Trace estimation: Hutchinson’s estimator uses a d-dimensional standard Gaussian to obtain an unbiased estimate of a matrix trace.
  • Trace estimation: The conditional vector-field derivatives are predefined, while the learned-field Jacobian-vector product is computed efficiently through automatic differentiation.
  • Efficient optimization: Stop-gradient prevents gradients from propagating through the learned vector field in the efficient squared objective.
  • Efficient optimization: Optimizing flow and divergence matching requires only one extra backward pass compared with the baseline CFM loss.
Loading 2602.00869v1…