betaFeedback

WorksComputer Science

Correcting Flows with Marginal Matching

Abstract

Flow matching models, ODE-based generative models, generate samples by gradually morphing a simple source distribution into a target distribution. However, these models still face challenges in optimally balancing computational efficiency with generation fidelity. While predictor-corrector schemes have been proven to help address this issue in diffusion models effectively, their application to flow matching models remains under-explored. In this work we present a novel training-based predictor-corrector framework for flow matching, which exploits the fact that the ODE can be easily reversed. Our key idea, termed Marginal Matching, is to correct samples at a particular time step in the forward ODE towards a matching marginal distribution of the backward ODE. This scheme proves to reduce a bound on the distance between the data distribution and the learned distribution, motivating two different implementations for the correction function. We show that our proposed method improves sample quality on CIFAR-10 and ImageNet-64, with minimal overhead in computation time.

Introduction

Flow-based generative models have emerged as a promising alternative to diffusion models, offering faster sampling while maintaining high generation quality [27, 28, 47]. While these models require fewer sampling steps than diffusion probabilistic models (DPMs), they still face challenges in balancing computational efficiency with generation quality. This trade-off is crucial, as applications like image synthesis and audio generation require real-time performance, while protein design and robotics demand efficient resource utilization for complex tasks [55, 29, 16] (Le et al. 2024; Hu et al. 2023).

In DPMs, predictor-corrector schemes have proven effective at improving sample quality. These schemes combine prediction steps, which estimate the next time step’s sample, with correction steps that refine samples to better match the current time-step distribution. Previous work include both training-free methods [44, 57, 58], which do not require additional model training, and training-based techniques [26], which involve training a model specifically tailored to the task. However, applying these schemes to flow matching models remained relatively unexplored until recently. Song & Lai [42] demonstrated the viability of implementing a predictor-corrector scheme for flow matching models without requiring additional training.

Traditional predictor-corrector frameworks aim to refine a sample at time step tt of the generation towards the marginal distribution of the learned diffusion process at time tt. For flow matching, the marginal distribution at time tt is the push-forward of the initial Gaussian distribution by the ODE up to time tt. However, due to limitations of the neural network training, a learned flow does not exactly map Gaussian noise to perfect images, even with perfect integration. Here, we introduce a novel training-based predictor-corrector approach specifically tailored for flow matching models that leverages known marginal distributions to provably yield the exact data distribution. Our method exploits time reversibility, which has been explored in diffusion models [51, 33], but is arguably less involved in flow matching models as it only requires solving the ODE in reverse time [28].

Consider a reverse ODE, starting from the data samples and flowing back in time according to the learned flow model. Our main insight is that starting the generation from samples on this trajectory will generate perfect images. Building on this, we enhance generation quality through a predictor-corrector scheme that alternates between ODE solver steps (predictor) and learned correction steps, reducing the discrepancy between generated samples and the time-reversal ODE solution. We provide theoretical guarantees that such a correction function minimizes a bound on the Wasserstein distance [17] between the target approximation and the true target distribution, as a function of the error reduction of the corrections at different time steps. We hypothesize that for practical flow models, the forward and backward ODEs will be relatively aligned, making the correction easy to learn and apply with minimal overhead.

We examine two practical implementations for the correction function. The first implementation minimizes a theoretical bound, but has access to only subset of the data during training. The second has access to the full dataset, but makes no theoretical guarantee. We examine these correction models empirically and perform an extensive ablation study for our design choices. Our results show significant improvement with minimal additional steps.

In summary, our main contributions are as follows:

  • A novel corrector model for predictor-corrector sampling of flow matching models based on time reversal.

  • A theoretical analysis of this general framework, and two practical implementations.

  • We empirically show that our proposed correction models improve results on CIFAR-10 and ImageNet-64 datasets, achieving lower FID scores with fewer sampling steps.

Background

Flow Models

Given a source distribution π0\pi_0 and a target distribution π1\pi_1, both over Rd\mathbb{R}^d, flow matching (Lipman et al., [27]; Liu et al., [28]; Tong et al., [47]) models their mapping. This is done with a smooth time-dependent vector field u:[0,1]×Rd→Rdu : [0, 1] \times\mathbb{R}^d \to\mathbb{R}^d which defines an ODE dϕt(x)=ut(ϕt(x))dt\mathrm{d}\phi_t(x) = u_t(\phi_t(x))\mathrm{d}t, where x∈Rdx \in\mathbb{R}^d, t∈[0,1]t \in[0, 1] and ϕt\phi_t is the flow map with the initial condition ϕ0(x)=x\phi_0(x) = x. A time-varying density function p:[0,1]×Rd→R>0p : [0, 1] \times\mathbb{R}^d \to\mathbb{R}_{>0} that satisfies the continuity equation:

∂pt∂t+div⁡(pt(x)ut(x))=0,(1)\frac{\partial p_t}{\partial t} + \operatorname{div}(p_t(x)u_t(x)) = 0, \tag*{(1)}

with the initial density p0p_0 over Rd\mathbb{R}^d is called the marginal probability path generated by the vector field uu, and uu is said to be the probability flow ODE for the density function pp.

The flow matching (FM) objective regresses vθ:[0,1]×Rd→Rdv_\theta: [0, 1] \times\mathbb{R}^d \to\mathbb{R}^d, a time-dependent vector field parametrized as a neural network with weights θ\theta, to a target vector field utu_t via the following mean squared error (MSE) loss function:

LFM(θ)=Et∼[0,1],x∼pt(x)∥vθ(t,x)−ut(x)∥2.(2)\mathcal{L}_{FM}(\theta) = \mathbb{E}_{t \sim[0,1],x \sim p_t(x)} \lVert v_\theta(t,x) - u_t(x) \rVert^2. \tag*{(2)}

Numerous mappings exist between probability distributions π0\pi_0 and π1\pi_1. The distributions pt(x)p_t(x) and ut(x)u_t(x) are not unique and typically impossible to compute directly. To address this, Lipman et al. [27] introduced the conditional flow matching (CFM) loss, which provides equivalent gradients to Eq. (2) with respect to θ\theta.

LCFM(θ)=Et∼[0,1],z∼q(z),x∼pt(x∣z)∥vθ(t,x)−ut(x∣z)∥2(3)\mathcal{L}_{CFM}(\theta) = \mathbb{E}_{t \sim[0,1],z \sim q(z),x \sim p_t(x \mid z)} \lVert v_\theta(t,x) - u_t(x \mid z) \rVert^2 \tag*{(3)}

where zz is some conditional variable sampled from a distribution q(z)q(z). The full derivation is available in Lipman et al. [27]; Tong et al. [47]. Many efficient parameterizations exist for ut(x∣z)u_t(x \mid z) and pt(x∣z)p_t(x \mid z), in this work we focus on the parametrization described in Tong et al. [47]:

z=(x0,x1);ut(x∣z)=x1−x0;z = (x_0,x_1) \quad; \quad u_t(x \mid z) = x_1 - x_0 \quad;
pt(x∣z)=N(x∣t⋅x1+(1−t)⋅x0,σ2I),p_t(x \mid z) = \mathcal{N}(x \mid t \cdot x_1 + (1-t) \cdot x_0,\sigma^2 I),

where z∼q(z)z \sim q(z) and t∈[0,1]t \in[0,1] is the interpolation coefficient. The conditional density pt(x∣z)p_t(x \mid z) specifies one of the possible ptp_t distributions and is easy to sample from and learn. The vector field utu_t and its corresponding marginal distribution ptp_t can be obtained in terms of the conditional ones:

pt(x)=∫pt(x∣z)q(z) dz,ut(x)=∫pt(x∣z)ut(x∣z)pt(x)q(z) dz.p_t(x) = \int p_t(x \mid z)q(z)\,\mathrm{d}z,\quad u_t(x) = \int\frac{p_t(x \mid z)u_t(x \mid z)}{p_t(x)}q(z)\,\mathrm{d}z.

We examine two recently studied flow models by Tong et al. [47], one with independent coupling (I-CFM) q(z)=π0(x0)×π1(x1)q(z) = \pi_0(x_0) \times\pi_1(x_1) and another with optimal transport coupling (OT-CFM) q(z)=OT(x0,x1)q(z) = OT(x_0,x_1). The optimal transport (OT) problem maps x0x_0 to x1x_1 such that a displacement cost, (typically the squared Euclidean distance), is minimized, for more details see Appendix § 11. The OT coupling is calculated on batches during training and results in straighter trajectories, (Pooladian et al., [37]; Tong et al., [47]).

Score Models

In score-based generative models (Song et al., [44]; Song & Ermon, [43]) the forward and reverse processes are modeled using standard diffusion and reverse-time stochastic differential equations (SDEs). The forward process is described by dx=f(x,t)dt+g(t)dw\mathrm{d}x = f(x,t)\mathrm{d}t + g(t)\mathrm{d}w, while the reverse-time SDE is given by dx=[f(x,t)−g(t)2∇log⁡π1]dt+g(t)dwˉ\mathrm{d}x = [f(x,t) - g(t)^2 \nabla\log\pi_1]\mathrm{d}t + g(t)\mathrm{d}\bar{w}. In these equations, ww represent standard Wiener processes, ff is the drift coefficient, gg is the diffusion coefficient, and tt ranges from 0 to TsT_s. The reverse SDE is used for generating samples, evolving from t=Tst = T_s to t=0t = 0, for example by using a numerical SDE solver.

The score model estimates the score function ∇xlog⁡π1(x)\nabla_x \log\pi_1(x), where π1(x)\pi_1(x) is the target distribution defined above. The training process typically involves denoising score matching (DSM):

LDSM(θ)=Eπ1(x)pσ(x~∣x)∥sθ(x~)−∇x~log⁡pσ(x~∣x)∥2(4)\mathcal{L}_{DSM}(\theta) = \mathbb{E}_{\pi_1(x)p_\sigma(\tilde{x} \mid x)} \lVert s_\theta(\tilde{x}) - \nabla_{\tilde{x}}\log p_\sigma(\tilde{x}\mid x) \rVert^2 \tag*{(4)}

Here, sθs_\theta denotes a neural network parameterized by θ\theta, and pσ(x~∣x)=N(x,σ2I)p_\sigma(\tilde{x}\mid x) = \mathcal{N}(x,\sigma^2 I) represents the probability of a noisy sample from the target distribution. Vincent [50] demonstrated that the optimal score network sθ∗(x)s_{\theta^*}(x), which minimizes Eq. (4), satisfies sθ∗(x)=∇xlog⁡pσ(x)s_{\theta^*}(x) = \nabla_x \log p_\sigma(x) almost surely. This result shows that the network learns to estimate the score function of pσ(x)p_\sigma(x), which is crucial for effectively denoising it. However, the approximation sθ∗(x)=∇xlog⁡pσ(x)≈∇xlog⁡π1(x)s_{\theta^*}(x) = \nabla_x \log p_\sigma(x) \approx\nabla_x \log\pi_1(x) holds true only when the noise level is sufficiently small, such that pσ(x)≈π1(x)p_\sigma(x) \approx\pi_1(x).

Predictor-Corrector Methods

Algorithm 1 General Predictor-Corrector Inference

Require: number of prediction discretization steps NN, number of correction steps MM

  1. x0∼N(0,I)x_0 \sim\mathcal{N}(0, I)

  2. for n=0n = 0 to N−1N - 1 do

  3. xtn+1=Predictor⁡(xtn)x_{t_{n+1}} = \operatorname{Predictor}(x_{t_n})

  4. for m=1m = 1 to MM do

  5. xtn+1=Corrector⁡(xtn+1)x_{t_{n+1}} = \operatorname{Corrector}(x_{t_{n+1}})

  6. end for

  7. end for

  8. return xtNx_{t_N}

Predictor-corrector approaches, as shown in {(citep)}(Zhao et al., 2023; Lezama et al., 2022; Song et al., 2021b), are common in DPMs, where a corrector is intermittently applied during inference to improve performance (Algorithm 1). Previous work often employs the same pre-trained model for both prediction and correction, differing only in whether the model predicts the next step or refines the current one. For instance, Song et al. [44] use a score model with an ODE solver for prediction and Langevin Dynamics for correction. Meanwhile, Song & Lai [42] store flow model outputs in a buffer for use during correction. Unlike previous approaches, we propose using a dedicated correction model and investigate its design.

Method

Motivation and Problem Formulation

Given a frozen pre-trained flow model vθv_\theta, our goal is to improve the sampling of vθv_\theta. In this paper, we focus on the correction phase of the predictor-corrector framework and propose training an auxiliary correction model to enhance the approximation of the marginal distributions along the inference trajectory. We term our predictor-corrector method Marginal Matching (MM).

Langevin Dynamics (Song et al. [44]) is a common correction method, but its implementation becomes challenging with flow models that do not inherently represent a score function. A potential solution is to train an auxiliary score model to capture every intermediate marginal distribution. During prediction, the flow model advances to the next time-step, while the correction phase leverages the score model to more accurately approximate the marginal distributions. The key challenge lies in defining these marginals. An initial approach would be to use the marginal distributions the flow model was originally trained on— an interpolation between the target distribution and Gaussian noise. In the subsequent discussion, we will explore an alternative choice for these marginal distributions.

The flow model vθv_\theta is trained to map a source distribution π0\pi_0 to a target distribution π1\pi_11, but in practice it maps to an approximation of π1\pi_1. Let π^1\hat{\pi}_1 denote the distribution of samples generated by vθv_\theta, which does not exactly match π1\pi_1.

If the vector field represented by vθv_\theta is invertible, a well defined “reverse flow” exists from the target distribution according to the reverse of the vector field, −vθ-v_\theta. The key observation is that starting a forward flow using vθv_\theta from any point on the reverse flow will converge to the target distribution π1\pi_1. That is, we have found a trajectory of densities that works perfectly with our imperfect model vθv_\theta. We assume that the flow is invertible, implying cycle consistency between forward and backward vector field mappings ([59]). A similar assumption is used in Liu et al. [28] in experiments on image translation. While we cannot verify that this assumption holds in practice, we empirically validate our method on popular datasets.

We next formally define the forward and backward marginals, representing the time-evolving probability distributions generated by the vector field.

Definition 3.1. Forward and Backward Marginals: Let uu be a continuously globally Lipschitz time-dependent function u:[0,1]×Rd→Rdu : [0, 1] \times\mathbb{R}^d \to\mathbb{R}^d. Let u−1u^{-1} be the reverse vector field defined as: u−1(t,x):=−u(t,x)u^{-1}(t, x) := -u(t, x). The discretization of the time-interval [0,1][0, 1] into NN steps is tn=n/Nt_n = n/N.

  • Forward Marginals are the probability path generated by ∂ptf∂t+div⁡(ptf(x)ut(x))=0\frac{\partial p_t^f}{\partial t} + \operatorname{div}(p_t^f(x)u_t(x)) = 0 from time 0 to 1, with initial distribution p0f=π0p_0^f = \pi_0. The final distribution is p1f=π^1p_1^f = \hat{\pi}_1. Their NN steps discretization is defined as {ptnf}n=0N\{p_{t_n}^f\}_{n=0}^N.

  • Backward Marginals are the probability path generated by ∂ptb∂t+div⁡(ptb(x)ut−1(x))=0\frac{\partial p_t^b}{\partial t} + \operatorname{div}(p_t^b(x)u_t^{-1}(x)) = 0 from time 1 to 0, with initial distribution p1b=π1p_1^b = \pi_1. The final distribution is p0b=π^0p_0^b = \hat{\pi}_0. Their NN steps discretization is defined as {ptnb}n=0N\{p_{t_n}^b\}_{n=0}^N.2

We refer to p0bp_0^b as the approximate source distribution to distinguish it from π0\pi_0, the source distribution, and p1fp_1^f as the approximate target distribution to distinguish it from π1\pi_1, the target distribution. Figure 1 illustrates the forward and backward marginals of a flow model sampled with 10-steps Euler integration. It demonstrates the probability marginals trajectory and that ptnb≠ptnfp_{t_n}^{b} \ne p_{t_n}^{f} for every nn. Additionally, there is a substantial intersection between the forward and backward marginals, and their symmetric difference represents the outliers that do not reach the target distribution, for more details see Appendix. F. Therefore, we predict that refining samples towards the marginals vθv_\theta was trained on will be beneficial, though less so than backward marginals, as supported by the experiments.

Illustration of Marginals

Figure 1. Illustration of Marginals (a) Gaussian source distribution π0\pi_0 (red), and target distribution π1\pi_1 (blue). (b) Discrete forward marginals {ptnf}n=0N\{p_{t_n}^{f}\}_{n=0}^{N}. (c) Discrete backward marginals {ptnb}n=0N\{p_{t_n}^{b}\}_{n=0}^{N}. Note that ptnb≠ptnfp_{t_n}^{b} \ne p_{t_n}^{f} for every nn, specifically p0b(=π^0p_0^{b}(=\hat{\pi}_0, black) differs from p0f(=π0p_0^{f}(=\pi_0, red).

Our next observation is that if the forward marginals trajectory reaches the target distribution, then it aligns with the backward trajectory for every time-step. This is formally stated in Lemma. 3.2

Lemma 3.2. Let u:[0,1]×Rd→Rdu : [0,1] \times\mathbb{R}^d \to\mathbb{R}^d be a continuous time-dependent vector field, satisfying: ∣ut(x)−ut(y)∣≤L∣x−y∣|u_t(x) - u_t(y)| \le L|x-y|, ∀t∈[0,1]\forall t \in[0,1], x,y∈Rdx,y \in\mathbb{R}^d. Then, p1f=p1b=π1p_1^f = p_1^b = \pi_1 if and only if ptf=ptbp_t^f = p_t^b ∀t∈[0,1]\forall t \in[0,1].

Based on this observation, we suggest refining the generated samples to better align with the backward marginals, ensuring that the final sample distribution more effectively matches the target distribution. Figure 2 illustrates this idea.

Marginals in Vector Field

Figure 2. Marginals in Vector Field The black lines show two key trajectories in a vector field. The lower is the forward trajectory, starts at π0\pi_0 and ends at p1f=π^1p_1^f = \hat{\pi}_1. The upper is the backward trajectory, begins at p0bp_0^b and ends at the data distribution π1\pi_1. Both are discretized at time-steps tt and t′t'. Our objective is to transition from forward to backward marginals trajectory.

Practically, the backward marginals can be obtained by running an ODE-solver in reverse (from time 1 to time 0) on the frozen pre-trained model vθv_\theta starting at the data samples, (see Appendix. D.1). Then, a correction model can be trained to bridge between the forward and backward marginals.

Correction Steps Prioritization

In the prediction-correction scheme, correction steps are typically performed after each prediction step. While these steps can enhance performance, they also increase computational cost. The following theorem indicates that not all correction steps are equally significant, suggesting that to balance performance and computation time, we should prioritize the correction steps that offer the greatest benefit.

Theorem 3.3. (Informal) Let uu be a well-behaved vector field with Lipshitz constant LL, ptfp_t^f and ptbp_t^b be two time-dependent probability density functions satisfying the continuity equation Eq. (1) with respect to uu. Suppose that

the initial Wasserstein distance is d0=W2(p0b,p0f)d_0 = W_2(p_0^b,p_0^f). At each time step tnt_n, a correction function hh is applied to ptnfp_{t_n}^f and the flow function continues from h(tn,ptnf)h(t_n,p_{t_n}^f). Assuming hh reduces the W2W_2 distance to ptnbp_{t_n}^b by ϵn\epsilon_n, the reduction on the bound of the final distance is: W2(p1b,p1f)≤d0exp⁡{L}−∑i=0n−1ϵiexp⁡{L(1−ti)}W_2(p_1^b,p_1^f) \le d_0 \exp\{L\} - \sum_{i=0}^{n-1}\epsilon_i \exp\{L(1-t_i)\}.

A formal theorem statement and proofs are available in Appendix. B, which also includes calculations for two specific error reduction functions—additive and multiplicative. The following examples demonstrate that in each case the total error reduction is spread differently across the time steps, illustrating an important idea – we should prioritize the corrections applied in particular steps based on the error reduction model. We will revisit this idea in our experiments.

Example 3.4. Linear Reduction This corresponds to the case of linear error reduction in Thm. 3.3. For N=2N = 2, the bound is: d0exp⁡{L}−ϵ0exp⁡{L}−ϵ1exp⁡{L⋅0.5}d_0 \exp\{L\} - \epsilon_0 \exp\{L\} - \epsilon_1 \exp\{L \cdot0.5\}. Assuming ϵ0=ϵ1\epsilon_0 = \epsilon_1, the reduction term at step 0 has a greater impact on the final bound due to the larger exponential factor. This highlights the importance of prioritizing corrections at earlier steps in the sequence.

Example 3.5. Multiplicative Reduction This corresponds to the case of multiplicative error reduction in Thm. 3.3. For N=2N = 2, the bound is: d0exp⁡{L}(1−ϵ0)(1−ϵ1)d_0 \exp\{L\}(1-\epsilon_0)(1-\epsilon_1). Here, the reduction terms (1−ϵ0)(1-\epsilon_0) and (1−ϵ1)(1-\epsilon_1) contribute equally to the final bound, irrespective of their position in the sequence. Thus, the optimal strategy is to prioritize improvements at steps with the largest ϵi\epsilon_i.

Thm.3.3 states that the transport map hh can be utilized to reduce the distance between the forward ptfp_t^f and backward marginals ptbp_t^b. In the following, slightly abusing notation, we assume that hh is the push-forward of x∈Rdx \in\mathbb{R}^d with a mapping h(x)h(x). In practice, the specific error reduction is unknown and we can only require that the bound on the Wasserstein distance will decrease after hh is applied.

Let hψh_\psi be a neural network with weights ψ\psi that approximates the correction function hh. We consider two models for implementing the correction model hψh_\psi.

Correction Models Implementation

Score Model

Algorithm 2 Score Model Training

Require: flow model vθv_\theta, score model hψh_\psi, σ\sigma, backward marginals {ptnb(x)}n=0N\{p_{t_n}^b(x)\}_{n=0}^{N}

  1. repeat

  2. ϵ∼N(0,I)\epsilon\sim\mathcal{N}(0,I)

  3. n∼U({0,1,…,N})n \sim\mathcal{U}(\{0,1,\ldots,N\})

  4. xtn∼ptnb(x)x_{t_n} \sim p_{t_n}^b(x)

  5. Take gradient descent step on

  6. ∇ψ∥hψ(tn,xtn+σ⋅ϵ)+ϵ∥2\nabla_\psi\lVert h_\psi(t_n,x_{t_n}+\sigma\cdot\epsilon)+\epsilon\rVert^2

  7. until converged

Our first proposed approach is a time-dependent score model hψ(t,xt)=sψ(t,xt)h_\psi(t,x_t)=s_\psi(t,x_t), presented in Algorithm 2, to approximate the backward marginals ∇xtlog⁡ptb(xt)\nabla_{x_t}\log p_t^b(x_t). We assume this score function is well-defined when evaluated on samples from the forward marginal distributions (i.e. xt∼ptfx_t \sim p_t^f), which allows us to use it to move between these distributions (our experiments provide empirical support for this assumption). Motivated by the bound of Kwon et al. [24] (Thm. 2) for score models generation, the following lemma bounds the final Wasserstein distance after applying the score correction on a single time-step marginal:

Lemma 3.6. (Informal) Applying sψs_\psi from ptnfp_{t_n}^f to approximate ptnbp_{t_n}^b as described in § 2.2 bounds the final distance W2(p1b,p1f)W_2(p_1^b,p_1^f) as follows:

W2(p1b,p1f)≤C(sψ)exp⁡{L(1−tn)},W_2(p_1^b,p_1^f) \le C(s_\psi)\exp\{L(1-t_n)\},

where C(sψ)C(s_\psi) depends on the score model’s loss LDSMψL_{DSM}^{\psi} as defined in § 2.2. For small enough LDSMψL_{DSM}^{\psi}, this bound improves upon using no correction. For more details and a bound on the general case—applying score correction on multiple marginals, see Appendix. § 12.

In practice, we noticed that a single correction step is enough, and sampling with Langevin Dynamics is unnecessary. This correction step can be done with any gradient that points in the direction of the backward marginals.

Robust Classifier

In the score model, we did not use data from the forward marginals during training. We next propose a method that explicitly transitions between samples from the forward and backward marginals. This approach utilizes a time-dependent classifier cψ(t,xt)c_\psi(t,x_t) that distinguishes between forward and backward marginals (ptfp_t^f and ptbp_t^b), evaluating each sample independently. By learning to categorize samples as belonging to either the forward or backward marginal at each time step, the classifier’s gradients hψ(t,xt)=∇xtlog⁡cψ(t,xt)h_\psi(t,x_t)=\nabla_{x_t}\log c_\psi(t,x_t) provide corrective guidance, effectively steering samples toward the backward marginals. The gradients will be zero upon reaching the correct class.

To enhance the classifier’s gradient performance, we implement two key improvements: Adversarial Training (AT) and Gradient Alignment (GA). These keep the classifier’s gradients stable and meaningful, for more details and the complete algorithm for training see Appendix. § 14.§ 6.

Usage for Class Conditioning Classifier guidance is used in diffusion models and more recently in flow models (Sun et al., [46]) in order to generate conditional images. While MM generates data samples, it can also extend to conditional data generation. For this purpose, our classifier can be conditioned cψ(t,xt,l)c_\psi(t,x_t,l) where ll is a class label, and trained to categorize different classes in the backward trajectory. For an illustration see Appendix. § 17.§ 2.

Related Work

Diffusion predictor-corrector methods – Predictor-corrector methods have gained significant attention for balancing computational efficiency and sampling accuracy in diffusion processes. First introduced by Song et al. [44], this approach uses a score model for both prediction and correction, employing an SDE/ODE solver for prediction and Langevin dynamics to refine marginal distributions for correction. UniPC (Zhao et al., [57]) improved upon Lu et al. (2022) by leveraging a unified predictor-corrector framework that incorporates previous time-step predictions. Subsequently, Zhao et al. [58] introduced further refinements with a dynamic compensation strategy. These methods are all training-free, as they utilize the same model for both prediction and correction. For discrete data, Lezama et al. [26] proposed a method that uses pre-trained base models in conjunction with a learned corrector to enhance synthesis performance. Similarly, we adopt an approach that trains a correction model based on a pre-trained base model. However, it is important to note that while these methods are designed for DPMs, our work focuses on flow models, which operate under a different framework.

Acceleration methods for flow models – Acceleration methods for flow-based models have focused on improving ODE-solving efficiency. Concurrent with our work, Song & Lai [42] introduced a predictor-corrector method based on a training-free flow solver that minimized function evaluations by caching prior results and leveraging Taylor expansions to approximate ODE solutions efficiently. Rectified flow Liu et al. [28], demonstrated an acceleration approach through reflow operations to straighten probabilistic paths and further refined this process by training a distillation model over the final result. Moreover, Shaul et al. [39] proposed a training-based acceleration technique that adapts flow-based models into DPMs for faster computation. Despite these advancements, the exploration of ODE-based acceleration techniques specifically tailored for flow matching models remains underdeveloped compared to their DPMs counterparts due to their unique probabilistic path representation. For extended related work see Appendix. E.

Experiments

In this section, we empirically analyze the performance of MM’s image generation under varying marginals, comparing score correction model and classifier correction model. We then investigate the performance under interpolated and backward distributions, followed by an examination of the effects of sampling a score correction model using Langevin Dynamics versus a single-step approach. The score model is trained with a constant noise σ\sigma. We conduct experiments on two datasets: unconditional CIFAR-10 (Krizhevsky et al. [23]) and ImageNet-64 (Chrabaszcz et al. [3]; Deng et al. [6]). To assess the quality of generated images, we employ Fréchet Inception Distance (FID) (Heusel et al. [13]) score as our evaluation metric.

A key factor in diffusion and flow models is inference compute time, measured by number of function evaluations (NFE). In all tables, NFE represents the total number of sampling steps, and C-NFE denotes the steps taken with our correction model (out of the NFE). We note that a classifier correction step require two NFEs, due to input derivative calculations, while score correction requires only one NFE.

For the flow model we use the UNet architecture with the same hyper-parameters as Tong et al. [47]. For the score and classifier models, we use UNet with half the number of parameters used for the flow model. Additionally, these correction models undergo significantly fewer training iterations compared to the flow model. Unless otherwise specified, the correction models were trained on trajectories consisting of N=11N = 11 marginals with OT-CFM (Tong et al., [47]) as the flow model, and the flow model was sampled with 10-step RK4, which is 40 NFEs. For more implementation details, please refer to the Appendix § 18. The code will be available upon publication.

CIFAR-10 Sample Quality

Score Correction vs. Classifier Correction Model To showcase the improvement of MM we implement our score and classifier correction models with OT-CFM and I-CFM base flow models on CIFAR-10. Table 1 shows comparison of our results to (Ho et al., 2020; Song et al., [44]; Lipman et al., [27]; Tong et al., [47]).

ModelSamplerNFE ↓FID ↓
DDPMAdaptive2747.48
Score MatchingAdaptive24219.94
OT-FMAdaptive1426.35
OT-CFMRK4404.34
Adaptive133.943.58
I-CFMRK4404.29
Adaptive146.423.66
OursNFE ↓C-NFE ↓
Score411 (n=10n = 10)OT-CFM FID ↓ 3.45; I-CFM FID ↓ 3.47
433 (n=0,5,10n = 0, 5, 10)OT-CFM FID ↓ 3.38; I-CFM FID ↓ 3.39
5111 (n=0…10n = 0 \ldots10)OT-CFM FID ↓ 3.37; I-CFM FID ↓ 3.38
Classifier421 (n=8n = 8)OT-CFM FID ↓ 3.57; I-CFM FID ↓ 3.77
463 (n=8,9,10n = 8, 9, 10)OT-CFM FID ↓ 3.48; I-CFM FID ↓ 3.67
505 (n=6,7,8,9,10n = 6, 7, 8, 9, 10)OT-CFM FID ↓ 3.47; I-CFM FID ↓ 3.62
6211 (n=0…10n = 0 \ldots10)OT-CFM FID ↓ 3.48; I-CFM FID ↓ 3.63

Table 1. CIFAR-10 performance. (Top) Leading baseline models. (Bottom) Our correction models (score and classifier) with OT-CFM and I-CFM base flow models. The base flow models are sampled with 10-step RK4 (40 NFE). Correction steps improve performance with minimal additional NFEs, and generally, increasing the number of applied corrections (C-NFE) enhances overall results. Additional comparisons are available in Appendix. G.6.

Previous works employ an adaptive sampler (DOPRI5, dor (1980)), while we use RK4 as the ODE-sampler to ease the integration of the correction steps. We compare with results reported in Lipman et al. [27], implemented using the same UNet (Dhariwal & Nichol, [7]), and those in Tong et al. [47]. As Tong et al. [47] did not report RK4 sampling results, we conduct these experiments and report baseline results using the models’ checkpoints as our foundational flow models. Following the results of § 4, we investigate applying the correction on various time steps (C-NFE > 1)3. We examine several options: for the score model the correction steps were taken on n={[10],[0,5,10],[0…10]}n = \{[10], [0, 5, 10], [0 \ldots10]\} and for the classifier on n={[8],[8,9,10],[6,7,8,9,10],[0…10]}n = \{[8], [8, 9, 10], [6, 7, 8, 9, 10], [0 \ldots10]\}.

We significantly outperform the baselines with minimal additional NFEs. The score model slightly outperforms the classifier in FID score, despite not being exposed to forward marginals during training. It also demonstrates consistent performance regardless of whether it is applied to OT-CFM or I-CFM, indicating a robust denoising ability from forward to backward marginals. Whereas, the robust classifier is sensitive to the model choice, showing superior performance with OT-CFM. We did not observe any benefit from applying both the score and classifier correction models together.

Figure 4 (Left) presents a qualitative comparison of the correction performed by each algorithm, (additional images are available in Appendix § 19). The correction models improve clarity and sometimes make significant changes to the image. The score and classifier corrections show varying levels of effectiveness depending on the specific image. In some cases, one method outperforms the other, while in other instances, they surprisingly produce similar results.

Correction model outputs on CIFAR-10 and ImageNet-64

Figure 4. Correction models with OT-CFM as the base flow model on CIFAR-10 (Left) and ImageNet-64 (Right). The ”-Diff” shows the difference between corrected and uncorrected images. Corrected images show improved sharpness and better alignment with the dataset.

Interpolated Marginals vs. Backward Marginals Figure 3 compares two correction approaches: refining toward interpolated versus backward marginals using the score model. Both corrections improve results, but correcting toward backward marginals performs better as they guide the process toward the true target distribution π1\pi_1. Using all correction steps for marginal interpolation steered the flow off course, resulting in degraded performance.

Line plot comparing backward score and interpolated marginals score across C-NFE

Figure 3. CIFAR-10 sample quality comparison of score correction trained on the interpolated (π1\pi_1 and π0\pi_0) vs. backward marginals πtb\pi_t^b. The base flow is sampled with 10-step RK4.

Langevin Dynamics vs. One-Step Sampling

Figure 5 compares two approaches for the correction score model trained on backward marginals: using multi-step Langevin Dynamics (with 50 and 100 steps) versus applying a single correction step at the 10th time-step marginal (as used in Table. Table 1). The multi-step Langevin Dynamics approach exhibited limitations - small step sizes resulted in minimal image changes, while larger steps introduced noise. The single correction step proved both computationally more efficient and produced better results.

CIFAR-10 sample quality of score correction

Figure 5. CIFAR-10 sample quality of score correction sampled with 50 and 100 step Langevin Dynamics versus a single correction step at the 10th time-step marginal. The base flow is sampled with 10-step RK4.

ImageNet-64 Sample Quality

We perform an experiment on ImageNet-64 to examine MM in a higher-dimensional settings. Given a pre-trained OT-CFM flow model trained on ImageNet-64, we train a score correction model to improve its sample quality, as the score model outperform the classifier on CIFAR, we chose to perform these resource-intensive experiments with it. The score model was trained on trajectories consisting of N=6N = 6 marginals. Table 2 presents the improvement in FID of a correction model trained on the backward marginals trajectory compared to Ho et al., 2020; Song et al., [44]; Lipman et al., [27]; Tong et al., [47]. Similarly to the CIFAR-10 results, we observe that MM improves FID with minimal addition of NFEs. The correction is qualitatively demonstrated in Figure 4 (Right), (for more illustrations see Appendix § 19). The correction model removes the residual noise in the model’s approximation and changes the images structure to better align with the ImageNet dataset photos.

ModelNFE ↓SampleFID ↓
DDPM264Adaptive17.36
Score Matching441Adaptive19.74
OT-FM138Adaptive14.45
OT-CFM20RK417.99
24RK416.60
28RK415.71
OursNFE ↓C-NFE ↓FID
Score211 (n=5n = 5)15.91
222 (n=0,5n = 0, 5)15.53
266 (n=0…5n = 0 \ldots5)15.57

Table 2. ImageNet-64 results for top generative models (Top) vs. score correction with OT-CFM base flow (Bottom), which is sampled with 5-step RK4 (20 NFE).

Ablation Study

Marginals Ablation

In this ablation we study the effect of applying correction on different time-steps. Figure 6 (Left) demonstrates the cumulative effect of correcting all time-step marginals (from 0 to 10). The score model demonstrates significant improvements primarily during the middle and final steps, with minimal contributions from early stages. In contrast, the classifier exhibits a more uniform pattern of enhancement. Figure 6 (Middle) presents the improvement in FID when applying a single correction step on different time-step marginals. The classifier model’s correction consistently improves more than the score model at every time-step, except the final one. As predicted by the theoretical analysis in § 4, we observe that different correction algorithms yield varying levels of improvement when applied at different time steps.

CIFAR-10 sample quality plots

Figure 6. CIFAR-10 sample quality. The base flow model is OT-CFM sampled with 10-step RK4. Left: FID vs accumulative correction time-steps. Middle: FID vs single correction time-step. Right: Ablation study on classifier loss components sampled across different marginals.

Notably, early-stage corrections mainly affect low-frequency components, shaping overall image structure. In contrast, later-stage corrections primarily impact high-frequency details, addressing noise-like elements (Kim et al., [19]). The striking impact of executing the last time step with the score model suggests residual noise in the model’s predictions (see Appendix § 19 for illustrations).

Classifier Loss Ablation

To assess the significance of each improvement to the classifier, namely Adversarial Training (AT) and Gradient Alignment (GA), we conduct an ablation study by removing these components. The results are presented in Figure 6 (Right). Without AT, the gradients become unstable, as seen from the inconsistent improvement with additional steps. Without GA, the gradients are small, and adding steps does not improve performance.

For additional results, see Appendix. § 17 and Appendix. § 14.§ 3.

Conclusion and Limitations

This paper introduces a novel predictor-corrector framework for flow matching models, featuring a dedicated correction model. Our main insight is that given an imperfect flow model, a trajectory that exactly reaches the data distribution can be computed by reversing its vector field. Based on this insight, we propose Marginal Matching, a simple algorithm that steers the inference-time trajectory to better align with the path that accurately reaches the data. Unlike conventional predictor-corrector, which typically refine samples by aligning with the interpolated marginal distribution at each step, our approach directs samples toward a marginal distribution that steers toward the true data distribution. We demonstrate superior performance on CIFAR-10 and ImageNet-64, along with an extensive ablation study.

Ideally, all generative models could potentially improve with a correction phase where refinement targets a marginal distribution that leads to the data distribution. A major limitation of our work is the assumption on the reversibility of the vector field, constraining our method from generalizing to non-reversible models. This limitation may be relaxed for approximately reversible models such as diffusion models [51]. In general, extending our approach to non-reversible models is an interesting future direction.

Another aspect is the practical implementation of our theory. In Thm. 3.3 we assumed knowledge of error reductions. In practice, we do not have access to the model’s error reduction (see § 4). However, we can bound that reduction in the case of score correction (Lemma. 3.6) and propose a bound on the final Wasserstein distance. Future work could explore theoretical bounds also for our classifier-based correction model.

Finally, our method requires training an additional model after a flow model has been pre-trained, adding extra compute and parameters. It is worth noting that in all our experiments, this auxiliary model is smaller than the original flow model, and training it takes significantly less time. An alternative approach could involve training the flow and correction models together, either as a single model with both flow and correction outputs or as two models trained simultaneously.

Impact Statement

This paper presents work whose goal is to advance the field of Machine Learning. There are many potential societal consequences of our work, none which we feel must be specifically highlighted here.

Optimal Transport

Optimal Transport (OT) is a mathematical framework that addresses the problem of efficiently moving probability mass from one distribution to another while minimizing a certain cost. The central idea is to find the optimal way to transform one probability distribution into another, considering the ”cost” of moving each unit of mass.

In the context of flow matching, before learning the flow, an optimal transport map is computed between batches of samples from π0\pi_0 and π1\pi_1. This OT step uses the 2-Wasserstein distance as its metric, with a cost function defined as the Euclidean distance ∥x−y∥\lVert x-y\rVert between points. The flow is then learned based on these optimally transported samples, resulting in straighter trajectories [37, 47].

Theoretical Proofs

Proof of Lemma 3.2. If ptf=ptbp_t^f=p_t^b for every tt then p1f=p1b=π1p_1^f=p_1^b=\pi_1 is trivial.

Assume p1f=p1b=π1p_1^f=p_1^b=\pi_1. We need to show that ptf=ptbp_t^f=p_t^b for every t∈[0,1]t\in[0,1].

The flow ϕt\phi_t is a diffeomorphism for each t∈[0,1]t\in[0,1] due to the properties of the vector field uu (continuous and globally Lipschitz).

For any t∈[0,1]t\in[0,1], we can write:

ptf=[ϕt]#p0f=[ϕt∘ϕ1−1]#p1f,ptb=[ϕt]#p0b=[ϕt∘ϕ1−1]#p1b.\begin{aligned} p_t^f&=[\phi_t]_{\#}p_0^f=[\phi_t\circ\phi_1^{-1}]_{\#}p_1^f,\\ p_t^b&=[\phi_t]_{\#}p_0^b=[\phi_t\circ\phi_1^{-1}]_{\#}p_1^b. \end{aligned}

where ϕ1−1\phi_1^{-1} is the inverse map of ϕ1\phi_1 flowing from t=1t=1 to t=0t=0. Since the following equality holds: p1f=p1b=π1p_1^f=p_1^b=\pi_1, we can replace p1fp_1^f and p1bp_1^b with π1\pi_1 in the above equations: ptf=[ϕt∘ϕ1−1]#π1p_t^f=[\phi_t\circ\phi_1^{-1}]_{\#}\pi_1 ptb=[ϕt∘ϕ1−1]#π1p_t^b=[\phi_t\circ\phi_1^{-1}]_{\#}\pi_1.

Lemma B.1. Let ϕt\phi_t be the flow map of the vector field uu that induces the push-forward qt1:=[ϕt]#q01q_t^1:=[\phi_t]_{\#}q_0^1, qt2:=[ϕt]#q02q_t^2:=[\phi_t]_{\#}q_0^2 for any two probability density distributions q01q_0^1 and q02q_0^2 over Rd\mathbb{R}^d, where t∈[0,1]t\in[0,1]. The 2-Wasserstein distance between qt1q_t^1 and qt2q_t^2 satisfies:

W2(qt1,qt2)≤W2(q01,q02)exp⁡{Lt}.W_2(q_t^1,q_t^2)\le W_2(q_0^1,q_0^2)\exp\{Lt\}.

Corollary B.2. Assume t′>tt'>t: W2(qt′1,qt′2)≤W2(qt1,qt2)exp⁡{L(t′−t)}W_2(q_{t'}^1,q_{t'}^2)\le W_2(q_t^1,q_t^2)\exp\{L(t'-t)\}.

Proof. Let o~04\tilde{o}_0^4 be the optimal coupling between q01q_0^1 and q02q_0^2. Denote the push-forward of o~0\tilde{o}_0 as o~t:=[ϕt]#o~0\tilde{o}_t:=[\phi_t]_{\#}\tilde{o}_0. Then:

ddt∫Rd×Rd∥x−y∥2do~t(x,y)=ddt∫Rd×Rd∥ϕt(x)−ϕt(y)∥2do~0(x,y)(5)\frac{d}{dt}\int_{\mathbb{R}^d\times\mathbb{R}^d}\lVert x-y\rVert^2d\tilde{o}_t(x,y)=\frac{d}{dt}\int_{\mathbb{R}^d\times\mathbb{R}^d}\lVert\phi_t(x)-\phi_t(y)\rVert^2d\tilde{o}_0(x,y) \tag*{(5)}
=∫Rd×Rdddt∥ϕt(x)−ϕt(y)∥2do~0(x,y)(6)=\int_{\mathbb{R}^d\times\mathbb{R}^d}\frac{d}{dt}\lVert\phi_t(x)-\phi_t(y)\rVert^2d\tilde{o}_0(x,y) \tag*{(6)}
=∫Rd×Rd2(ϕt(x)−ϕt(y))⋅(ddtϕt(x)−ddtϕt(y))do~0(x,y)(7)=\int_{\mathbb{R}^d\times\mathbb{R}^d}2(\phi_t(x)-\phi_t(y))\cdot\left(\frac{d}{dt}\phi_t(x)-\frac{d}{dt}\phi_t(y)\right)d\tilde{o}_0(x,y) \tag*{(7)}
=2∫Rd×Rd(ϕt(x)−ϕt(y))⋅(u(t,ϕt(x))−u(t,ϕt(y)))do~0(x,y)(8)=2\int_{\mathbb{R}^d\times\mathbb{R}^d}(\phi_t(x)-\phi_t(y))\cdot\left(u(t,\phi_t(x))-u(t,\phi_t(y))\right)d\tilde{o}_0(x,y) \tag*{(8)}
≤2L⋅∫Rd×Rd∥ϕt(x)−ϕt(y)∥2do~0(x,y)(9)\le2L\cdot\int_{\mathbb{R}^d\times\mathbb{R}^d}\lVert\phi_t(x)-\phi_t(y)\rVert^2d\tilde{o}_0(x,y) \tag*{(9)}
=2L⋅∫Rd×Rd∥x−y∥2do~t(x,y).(10)=2L\cdot\int_{\mathbb{R}^d\times\mathbb{R}^d}\lVert x-y\rVert^2d\tilde{o}_t(x,y). \tag*{(10)}

where in (5) we changed variables, in (6) we used Leibniz’s rule and in (8) the Lipschitz constraint.

Using Grönwall’s inequality, we have:

∫Rd×Rd∥x−y∥2d~0#(x,y)≤∫Rd×Rd∥x−y∥2d~0(x,y)exp⁡{2Lt}(11)\int_{\mathbb{R}^{d}\times\mathbb{R}^{d}} \lVert x-y\rVert^{2}\tilde{d}^{\#}_{0}(x,y) \le\int_{\mathbb{R}^{d}\times\mathbb{R}^{d}} \lVert x-y\rVert^{2}\tilde{d}_{0}(x,y)\exp\{2Lt\} \tag*{(11)}
=W22(q01,q02)exp⁡{2Lt}.(12)= W_{2}^{2}(q_{0}^{1},q_{0}^{2})\exp\{2Lt\}. \tag*{(12)}

By the definition of Wasserstein distance:

W22(qt1,qt2)≤∫Rd×Rd∥x−y∥2d~t#(x,y).(13)W_{2}^{2}(q_{t}^{1},q_{t}^{2}) \le\int_{\mathbb{R}^{d}\times\mathbb{R}^{d}} \lVert x-y\rVert^{2}\tilde{d}^{\#}_{t}(x,y). \tag*{(13)}

Substituting the bound:

W22(qt1,qt2)≤W22(q01,q02)exp⁡{2Lt}.(14)W_{2}^{2}(q_{t}^{1},q_{t}^{2}) \le W_{2}^{2}(q_{0}^{1},q_{0}^{2})\exp\{2Lt\}. \tag*{(14)}

Taking the square root of both sides yields the result:

W2(qt1,qt2)≤W2(q01,q02)exp⁡{Lt}.W_{2}(q_{t}^{1},q_{t}^{2}) \le W_{2}(q_{0}^{1},q_{0}^{2})\exp\{Lt\}.

Theorem B.3. [Thm.3.3 in the main paper] Let P2(Rd)\mathcal{P}_{2}(\mathbb{R}^{d}) be the space of probability densities on Rd\mathbb{R}^{d} with finite second moments. Let uu be defined as in Lemma. 3.2. Let μt\mu_{t} and νt\nu_{t} be two time-dependent probability density functions in Rd\mathbb{R}^{d} satisfying the continuity equation Eq. (1) with initial densities μ0\mu_{0}, ν0\nu_{0} and terminal densities μ1\mu_{1}, ν1\nu_{1}. Suppose that the initial 2-Wasserstein distance between them is d0=W2(μ0,ν0)d_{0}=W_{2}(\mu_{0},\nu_{0}). The time interval [0,1][0,1] is discretized into NN equal steps: tn=n/Nt_{n}=n/N, where n=0,1,…,Nn=0,1,\ldots,N. At each time step tnt_{n}, a time-dependent transport map h:[0,1]×P2(Rd)→P2(Rd)h:[0,1]\times\mathcal{P}_{2}(\mathbb{R}^{d})\to\mathcal{P}_{2}(\mathbb{R}^{d}) is applied to νtn\nu_{t_{n}}. After applying hh, the flow function at time tn+1t_{n+1} continues from the probability density of h(tn,νtn)h(t_{n},\nu_{t_{n}}). We consider two variations for hh:

A If hh reduces the 2-Wasserstein distance by a constant amount ϵn>0\epsilon_{n}>0 at each step: W2(μtn,h(tn,νtn))=W2(μtn,νtn)−ϵnW_{2}(\mu_{t_{n}},h(t_{n},\nu_{t_{n}}))=W_{2}(\mu_{t_{n}},\nu_{t_{n}})-\epsilon_{n}. Then, the following bound hold for n=0,1,…,Nn=0,1,\ldots,N: W2(μtn,νtn)≤d0exp⁡{L⋅tn}−∑i=0n−1ϵiexp⁡{L(tn−ti)}W_{2}(\mu_{t_{n}},\nu_{t_{n}})\le d_{0}\exp\{L\cdot t_{n}\}-\sum_{i=0}^{n-1}\epsilon_{i}\exp\{L(t_{n}-t_{i})\},

B If hh reduces the 2-Wasserstein distance to a proportion of the current distance: W2(μtn,h(tn,νtn))=(1−ϵn)⋅W2(μtn,νtn)W_{2}(\mu_{t_{n}},h(t_{n},\nu_{t_{n}}))=(1-\epsilon_{n})\cdot W_{2}(\mu_{t_{n}},\nu_{t_{n}}) where 0<ϵn<10<\epsilon_{n}<1 for all nn. Then, the following bound hold for n=0,1,…,Nn=0,1,\ldots,N: W2(μtn,νtn)≤d0⋅∏i=0n−1(1−ϵi)⋅exp⁡{L⋅tn}W_{2}(\mu_{t_{n}},\nu_{t_{n}})\le d_{0}\cdot\prod_{i=0}^{n-1}(1-\epsilon_{i})\cdot\exp\{L\cdot t_{n}\}.

Proof of Theorem B.3. We will prove parts A and B of the theorem separately.

Part A:

Let dn=W2(μtn,νtn)d_{n}=W_{2}(\mu_{t_{n}},\nu_{t_{n}}). We will prove by induction that:

dn≤d0exp⁡{L⋅tn}−∑i=0n−1ϵiexp⁡{L(tn−ti)}.d_{n}\le d_{0}\exp\{L\cdot t_{n}\}-\sum_{i=0}^{n-1}\epsilon_{i}\exp\{L(t_{n}-t_{i})\}.

Base case (n=0n=0): Trivially true as d0=W2(μ0,ν0)d_{0}=W_{2}(\mu_{0},\nu_{0}).

Inductive step: Assume the inequality holds for nn. We’ll prove it for n+1n+1.

After applying hh at tnt_{n}, we have:

W2(μtn,h(tn,νtn))=dn−ϵn.W_{2}(\mu_{t_{n}},h(t_{n},\nu_{t_{n}}))=d_{n}-\epsilon_{n}.

By Lemma. B.1 over the interval [tn,tn+1][t_{n},t_{n+1}], we have:

dn+1≤(dn−ϵn)exp⁡{L(tn+1−tn)}.d_{n+1}\le(d_{n}-\epsilon_{n})\exp\{L(t_{n+1}-t_{n})\}.

Substituting the inductive hypothesis:

dn+1≤(d0exp⁡{L⋅tn}−∑i=0n−1ϵiexp⁡{L(tn−ti)}−ϵn)exp⁡{L(tn+1−tn)}=d0exp⁡{L⋅tn+1}−∑i=0n−1ϵiexp⁡{L(tn+1−ti)}−ϵnexp⁡{L(tn+1−tn)}=d0exp⁡{L⋅tn+1}−∑i=0nϵiexp⁡{L(tn+1−ti)}.\begin{aligned} d_{n+1} &\le\left(d_0\exp\{L\cdot t_n\}-\sum_{i=0}^{n-1}\epsilon_i\exp\{L(t_n-t_i)\}-\epsilon_n\right)\exp\{L(t_{n+1}-t_n)\}\\ &=d_0\exp\{L\cdot t_{n+1}\}-\sum_{i=0}^{n-1}\epsilon_i\exp\{L(t_{n+1}-t_i)\}-\epsilon_n\exp\{L(t_{n+1}-t_n)\}\\ &=d_0\exp\{L\cdot t_{n+1}\}-\sum_{i=0}^{n}\epsilon_i\exp\{L(t_{n+1}-t_i)\}. \end{aligned}

This completes the induction. The final bound at t=1t=1 follows by setting n=Nn=N.

Part B:

Again, let dn=W2(μtn,νtn)d_n=W_2(\mu_{t_n},\nu_{t_n}). We will prove by induction that:

dn≤d0⋅∏i=0n−1(1−ϵi)⋅exp⁡{L⋅n/N}.d_n\le d_0\cdot\prod_{i=0}^{n-1}(1-\epsilon_i)\cdot\exp\{L\cdot n/N\}.

Base case (n=0n=0): Trivially true.

Inductive step: Assume the inequality holds for nn. We’ll prove it for n+1n+1.

After applying hh at tnt_n, we have:

W2(μtn,h(tn,νtn))=(1−ϵn)⋅dn.W_2(\mu_{t_n},h(t_n,\nu_{t_n}))=(1-\epsilon_n)\cdot d_n.

By Lemma. B.1, over the interval [tn,tn+1][t_n,t_{n+1}] we have:

dn+1≤(1−ϵn)⋅dn⋅exp⁡{L(tn+1−tn)}=(1−ϵn)⋅dn⋅exp⁡{L/N}.d_{n+1}\le(1-\epsilon_n)\cdot d_n\cdot\exp\{L(t_{n+1}-t_n)\}=(1-\epsilon_n)\cdot d_n\cdot\exp\{L/N\}.

Substituting the inductive hypothesis:

dn+1≤(1−ϵn)⋅exp⁡{L/N}⋅d0⋅∏i=0n−1(1−ϵi)⋅exp⁡{L⋅n/N}=d0⋅∏i=0n(1−ϵi)⋅exp⁡{L⋅(n+1)/N}.\begin{aligned} d_{n+1}&\le(1-\epsilon_n)\cdot\exp\{L/N\}\cdot d_0\cdot\prod_{i=0}^{n-1}(1-\epsilon_i)\cdot\exp\{L\cdot n/N\}\\ &=d_0\cdot\prod_{i=0}^{n}(1-\epsilon_i)\cdot\exp\{L\cdot(n+1)/N\}. \end{aligned}

This completes the induction. The final bound at t=1t=1 follows by setting n=Nn=N.

Score Wasserstein Bound:

The score-based models losses are:

LSM(θ,λ):=12∫0Tsλ(τ)Epτ[∥∇log⁡pτ(x)−sθ(x,τ)∥2]dτ,L_{SM}(\theta,\lambda):=\frac{1}{2}\int_{0}^{T_s}\lambda(\tau)\mathbb{E}_{p_\tau}\left[\left\|\nabla\log p_\tau(x)-s_\theta(x,\tau)\right\|^2\right]\mathrm{d}\tau,
LDSM(θ,λ):=12∫0Tsλ(τ)Ep0(x(0))p0τ(x∣x(0))[∥sθ(x,τ)−∇xlog⁡p0τ(x∣x(0))∥2]dτ,L_{DSM}(\theta,\lambda):=\frac{1}{2}\int_{0}^{T_s}\lambda(\tau)\mathbb{E}_{p_0(x(0))p_{0\tau}(x\mid x(0))}\left[\left\|s_\theta(x,\tau)-\nabla_x\log p_{0\tau}(x\mid x(0))\right\|^2\right]\mathrm{d}\tau,

where λ:[0,Ts]→(0,∞)\lambda:[0,T_s]\to(0,\infty) is a positive weighting function. The score model is typically trained using the widely adopted loss function known as LDSML_{DSM}.

Definition B.4. Noisy Backward Marginal: Let pn,σbp^b_{n,\sigma} be the noisy nthn^{\mathrm{th}} backward marginal. Then, pn,σb(y~n∣yn)=N(yn,σ2I)p^b_{n,\sigma}(\widetilde{y}_n \mid y_n) = \mathcal{N}(y_n,\sigma^2 I), y∼pnby \sim p^b_n.

Theorem B.5 (Kwon et al., [24]). If p0τp_{0\tau} satisfies:

Var⁡[E[(∇xlog⁡p0τ(x∣x(0)))T∣x(0)]]=0,(15)\operatorname{Var}\left[\mathbb{E}\left[\left(\nabla_x \log p_{0\tau}(x \mid x^{(0)})\right)^{\mathsf{T}} \mid x^{(0)}\right]\right] = 0, \tag*{(15)}

then we have:

LSM≤LDSMandW2(p0,q0)≤2(∫0Tsg(τ)2I(τ)2 dτ)LDSM+I(Ts)W2(pTs,qTs),(16)L_{SM} \leq L_{DSM} \quad\text{and} \quad W_2(p_0,q_0) \leq\sqrt{2\left(\int_0^{T_s} g(\tau)^2 I(\tau)^2\,d\tau\right)L_{DSM} + I(T_s)W_2(p_{T_s},q_{T_s})}, \tag*{(16)}

were I(τ):=exp⁡{∫0τ(Lf(r)+Ls(r)g(r)2) dr}I(\tau) := \exp\{\int_0^\tau(L_f(r)+L_s(r)g(r)^2)\,dr\}. Additionally, LfL_f and LsL_s are defined as follows:

(A1) The drift coefficient f:Rd×[0,Ts]→Rdf:\mathbb{R}^d \times[0,T_s] \to\mathbb{R}^d is Lipschitz continuous in the space variable xx: there exists a positive constant Lf(τ)∈(0,∞)L_f(\tau) \in(0,\infty), depending on τ∈[0,Ts]\tau\in[0,T_s], such that for all x,y∈Rdx,y \in\mathbb{R}^d

∥f(x,τ)−f(y,τ)∥≤Lf(τ)∥x−y∥.(17)\lVert f(x,\tau)-f(y,\tau)\rVert\leq L_f(\tau)\lVert x-y\rVert. \tag*{(17)}

(A2) sψ:Rd×[0,Ts]→Rds_\psi:\mathbb{R}^d \times[0,T_s] \to\mathbb{R}^d satisfies the one-sided Lipschitz condition [14, Definition 2.1]: there exists a constant Ls(τ)∈RL_s(\tau) \in\mathbb{R}, depending on τ∈[0,Ts]\tau\in[0,T_s], satisfying for all x,y∈Rdx,y \in\mathbb{R}^d

(sψ(x,τ)−sψ(y,τ))⋅(x−y)≤Ls(τ)∥x−y∥2.(18)(s_\psi(x,\tau)-s_\psi(y,\tau))\cdot(x-y) \leq L_s(\tau)\lVert x-y\rVert^2. \tag*{(18)}

For more details, see Kwon et al., [24]. In our case p0=pnbp_0=p^b_n and qTs=pnfq_{T_s}=p^f_n, the nthn^{\mathrm{th}} backward and forward marginals respectively. We assume the forward marginals are a ”noisy” version of the backward marginals (Def. B.4) with a small σ\sigma. Thus, pTs=qTsp_{T_s}=q_{T_s} and W2(pTs,qTs)=0W_2(p_{T_s},q_{T_s})=0 the first time the score model is applied, (the starting point is on the forward marginal). Consequently, as the LDSML_{DSM} loss converges to zero, so is the bound on the Wasserstein distance.

Conditions: Var⁡[E[(∇xlog⁡p0τ(x∣x(0)))T∣x(0)]]=0\operatorname{Var}[\mathbb{E}[(\nabla_x \log p_{0\tau}(x|x^{(0)}))^{\mathsf{T}}|x^{(0)}]]=0 under the following sufficient conditions: (1) Lipschitz continuity of the drift function for the forward diffusion process, and (2) boundedness of the noise schedule. Our scenario satisfies these conditions as follows:

  • The drift function ff is zero, which is Lipschitz continuous.

  • The noise schedule gg is between σmin\sigma_{min} and σmax\sigma_{max}, thus it is bounded above and below.

Therefore, we meet these sufficient conditions and adopt the additional assumptions from Kwon et al. [24], enabling us to apply Thm. B.5.

Lemma B.6. Let u:[0,1]×Rd→Rdu:[0,1]\times\mathbb{R}^d \to\mathbb{R}^d be a continuous time-dependent vector field, satisfying the Lipschitz condition: for any t∈[0,1]t \in[0,1] and x,y∈Rdx,y \in\mathbb{R}^d, ∥ut(x)−ut(y)∥≤L∥x−y∥\lVert u_t(x)-u_t(y)\rVert\leq L\lVert x-y\rVert. Let pnbp^b_n and pnfp^f_n represent the nthn^{\mathrm{th}} backward and forward marginals respectively, where the corresponding marginals continuous time is tn=n/Nt_n=n/N. Let sψs_\psi denote the trained score model. Then, applying sψs_\psi from pnfp^f_n to pnbp^b_n as described in § 2.2 lowers the final bound on W2(pNb,pNf)W_2(p^b_N,p^f_N):

W2(pNb,pNf)≤(2(∫0Tsg(τ)2I(τ)2 dτ)LDSMψ)exp⁡{L(1−tn)}.W_2(p^b_N,p^f_N) \leq\left(\sqrt{2\left(\int_0^{T_s} g(\tau)^2 I(\tau)^2\,d\tau\right)L^\psi_{DSM}}\right)\exp\{L(1-t_n)\}.

Proof of Lemma 3.6. Denote dn=W2(pnb,pnf)d_n=W_2(p^b_n,p^f_n). After applying the score models sψs_\psi:

d^n,ψ=W2(pnb,p^nb)≤2(∫0Tsg(τ)2I(τ)2 dτ)LDSMψ+I(Ts)W2(pn,σb,pnf).(19)\widehat{d}_{n,\psi}=W_2(p^b_n,\widehat{p}^b_n)\leq\sqrt{2\left(\int_0^{T_s} g(\tau)^2 I(\tau)^2\,d\tau\right)L^\psi_{DSM}}+I(T_s)W_2(p^b_{n,\sigma},p^f_n). \tag*{(19)}

where p^b\hat{p}^{b} is the score model’s approximation and 00, TsT_s are the integration times of the score model and Ts→∞T_s \to\infty. According to Lemma. B.1:

W2(pNb,pNf)≤d^n,ψexp⁡{L(1−tn)},(20)W_2(p_N^b,p_N^f) \le\hat{d}_{n,\psi}\exp\{L(1-t_n)\}, \tag*{(20)}
W2(pNb,pNf)≤W2(pnb,pnf)exp⁡{L(1−tn)}=W2(pnb,pn,σb)exp⁡{L(1−tn)},(21)W_2(p_N^b,p_N^f) \le W_2(p_n^b,p_n^f)\exp\{L(1-t_n)\}=W_2(p_n^b,p_{n,\sigma}^b)\exp\{L(1-t_n)\}, \tag*{(21)}

where the second inequality is the bound without applying the correction step.

The final bound can be obtained by substituting the bound on d^n,ψ\hat{d}_{n,\psi}:

W2(pNb,pNf)≤(2(∫0Tsg(τ)2I(τ)2dτ)LDSMψ+I(Ts)W2(pn,σb,pnf))exp⁡{L(1−tn)}.(22)W_2(p_N^b,p_N^f) \le\left(\sqrt{2\left(\int_0^{T_s}g(\tau)^2I(\tau)^2d\tau\right)L_{DSM}^{\psi}}+I(T_s)W_2(p_{n,\sigma}^b,p_n^f)\right)\exp\{L(1-t_n)\}. \tag*{(22)}

Assuming the score model is trained, LDSMψL_{DSM}^{\psi} is negligible: 2(∫0Tsg(τ)2I(τ)2dτ)LDSMψ<W2(pnb,pn,σb)\sqrt{2\left(\int_0^{T_s}g(\tau)^2I(\tau)^2d\tau\right)L_{DSM}^{\psi}}<W_2(p_n^b,p_{n,\sigma}^b). Since the forward marginals are a noisy version of the backward marginals W2(pnf,pn,σb)=0W_2(p_n^f,p_{n,\sigma}^b)=0. In total, the final bound after applying a correction step is lower than the bound when applying no correction steps:

(2(∫0Tsg(τ)2I(τ)2dτ)LDSMψ)exp⁡{L(1−tn)}<W2(pnb,pn,σb)exp⁡{L(1−tn)}.(23)\left(\sqrt{2\left(\int_0^{T_s}g(\tau)^2I(\tau)^2d\tau\right)L_{DSM}^{\psi}}\right)\exp\{L(1-t_n)\}<W_2(p_n^b,p_{n,\sigma}^b)\exp\{L(1-t_n)\}. \tag*{(23)}

Theorem B.7. Let u:[0,1]×Rd→Rdu:[0,1]\times\mathbb{R}^{d}\to\mathbb{R}^{d} be a continuous time-dependent vector field, satisfying the Lipschitz condition: for any t∈[0,1]t\in[0,1] and x,y∈Rdx,y\in\mathbb{R}^{d}, ∥ut(x)−ut(y)∥≤L⋅∥x−y∥\|u_t(x)-u_t(y)\|\le L\cdot\|x-y\|. Denote lψ,n=2(∫0Tsg(τ)2I(τ)2dτ)LDSMψ,nl^{\psi,n}=\sqrt{2\left(\int_0^{T_s}g(\tau)^2I(\tau)^2d\tau\right)L_{DSM}^{\psi,n}}, where LDSMψ,nL_{DSM}^{\psi,n} refers to the loss of sψs_{\psi} on the nthn^{\mathrm{th}} marginal. Following Lemma. 3.6 and assuming that W2(pn,σnb,qTs,n)≤W2(pnb,qTs,n)W_2(p_{n,\sigma_n}^b,q_{T_s,n})\le W_2(p_n^b,q_{T_s,n}) for every nn where qTs,nq_{T_s,n} is the initial distribution of the nthn^{\mathrm{th}} correction of the score model, then the application of sψs_{\psi} to multiple marginals upper bounds the final Wasserstein distance. This can be expressed as:

W2(pNb,pNf)≤∑i=0N−1lψ,iexp⁡{(N−i)⋅L/N}IN−1−i(Ts)+d0IN(Ts)exp⁡{L}.W_2(p_N^b,p_N^f)\le\sum_{i=0}^{N-1}l^{\psi,i}\exp\{(N-i)\cdot L/N\}I^{N-1-i}(T_s)+d_0I^N(T_s)\exp\{L\}.

Under the assumption that the forward marginals are a noisy version of the backward marginals when qTs,n=pnfq_{T_s,n}=p_n^f, the inequality: W2(pn,σnb,pnf)≤W2(pnb,pnf)W_2(p_{n,\sigma_n}^b,p_n^f)\le W_2(p_n^b,p_n^f) is trivial. After applying a correction step and continuing the flow, the trajectory at the next time-step lies between the forward and backward marginal paths, rather than strictly on the forward marginals path (qTs,n≠pnfq_{T_s,n}\ne p_n^f). This inequality holds true provided that σn\sigma_n decreases at a rate corresponding to this intermediate positioning.

Corollary B.8. Assuming the score model is well-trained, lψ,il^{\psi,i} becomes negligible. In our case, the drift is 00, resulting in a negligible Lf(r)L_f(r). Furthermore, [24] showed that with a DDPM schedule and qTs,n=N(0,I)q_{T_s,n}=\mathcal{N}(0,I), the one-sided Lipschitz constant is lim⁡τ→∞σ2Ls(τ)=−1\lim_{\tau\to\infty}\sigma^2L_s(\tau)=-1. This can be generalized to a VE schedule. We employ such a schedule, but lack a closed form for qTs,nq_{T_s,n}. Assuming lim⁡τ→∞σ2Ls(τ)=−1\lim_{\tau\to\infty}\sigma^2L_s(\tau)=-1 holds in our case as well, ∃τ′\exists\tau' such that ∀τ>τ′\forall\tau>\tau' I(τ)<1I(\tau)<1, specifically lim⁡τ→∞I(τ)<1\lim_{\tau\to\infty}I(\tau)<1. Applying more correction score steps decreases the upper bound of the final Wasserstein distance by I(Ts)I(T_s), similarly to the multiplicative case (B) in Thm. B.3.

Proof of Theorem B.7. Denote as dn=W2(pnb,qTs,n)d_n=W_2(p_n^b,q_{T_s,n}). We will prove by induction that:

dn≤∑i=0n−1lψ,iexp⁡{(n−i)⋅L/N}In−i−1(Ts)+d0In(Ts)exp⁡{n⋅L/N}.(24)d_n\le\sum_{i=0}^{n-1}l^{\psi,i}\exp\{(n-i)\cdot L/N\}I^{n-i-1}(T_s)+d_0I^n(T_s)\exp\{n\cdot L/N\}. \tag*{(24)}

Base case (n=0n = 0): Trivially true.

Inductive step: Assume the inequality holds for nn. We’ll prove it for n+1n + 1.

By Lemma. 3.6, after applying the score function:

d^n,ψ=W2(pnb,p^nb)≤2(∫0Tsg(τ)2I(τ)2dτ)LDSMψ,n+I(Ts)W2(pn,σnb,qTs,n)(25)\hat{d}_{n,\psi} = W_2(p_n^b,\hat{p}_n^b) \le\sqrt{2\left(\int_0^{T_s}g(\tau)^2 I(\tau)^2d\tau\right)L_{DSM}^{\psi,n} + I(T_s)W_2(p_{n,\sigma_n}^b,q_{T_s,n})} \tag*{(25)}
≤2(∫0Tsg(τ)2I(τ)2dτ)LDSMψ,n+I(Ts)W2(pnb,qTs,n)(26)\le\sqrt{2\left(\int_0^{T_s}g(\tau)^2 I(\tau)^2d\tau\right)L_{DSM}^{\psi,n} + I(T_s)W_2(p_n^b,q_{T_s,n})} \tag*{(26)}
=2(∫0Tsg(τ)2I(τ)2dτ)LDSMψ,n+I(Ts)dn,(27)= \sqrt{2\left(\int_0^{T_s}g(\tau)^2 I(\tau)^2d\tau\right)L_{DSM}^{\psi,n} + I(T_s)d_n}, \tag*{(27)}

in the second inequality we used the assumption that W2(pn,σnb,qTs,n)≤W2(pnb,qTs,n)W_2(p_{n,\sigma_n}^b,q_{T_s,n}) \le W_2(p_n^b,q_{T_s,n}). By Lemma. B.1 over the interval [tn,tn+1][t_n,t_{n+1}], we have:

dn+1≤d^n,ψexp⁡{L(tn+1−tn)}(28)d_{n+1} \le\hat{d}_{n,\psi}\exp\{L(t_{n+1}-t_n)\} \tag*{(28)}
≤(2(∫0Tsg(τ)2I(τ)2dτ)LDSMψ,n+I(Ts)dn)exp⁡{L(tn+1−tn)}(29)\le\left(\sqrt{2\left(\int_0^{T_s}g(\tau)^2I(\tau)^2d\tau\right)L_{DSM}^{\psi,n} + I(T_s)d_n}\right)\exp\{L(t_{n+1}-t_n)\} \tag*{(29)}
=(2(∫0Tsg(τ)2I(τ)2dτ)LDSMψ,n)exp⁡{L/N}+dnI(Ts)exp⁡{L/N},(30)= \left(\sqrt{2\left(\int_0^{T_s}g(\tau)^2I(\tau)^2d\tau\right)L_{DSM}^{\psi,n}}\right)\exp\{L/N\} + d_nI(T_s)\exp\{L/N\}, \tag*{(30)}

Substituting the inductive hypothesis:

dn+1≤lψ,nexp⁡{L/N}+dnI(Ts)exp⁡{L/N}(31)d_{n+1} \le l^{\psi,n}\exp\{L/N\} + d_nI(T_s)\exp\{L/N\} \tag*{(31)}
≤lψ,nexp⁡{L/N}(32)\le l^{\psi,n}\exp\{L/N\} \tag*{(32)}
+(∑i=0n−1lψ,iexp⁡{(n−i)⋅L/N}In−i−1(Ts)+d0In(Ts)exp⁡{n⋅L/N})I(Ts)exp⁡{L/N}(33)+ \left(\sum_{i=0}^{n-1}l^{\psi,i}\exp\{(n-i)\cdot L/N\}I^{n-i-1}(T_s) + d_0I^n(T_s)\exp\{n\cdot L/N\}\right)I(T_s)\exp\{L/N\} \tag*{(33)}
=∑i=0nlψ,iexp⁡{(n−i+1)⋅L/N}In−i(Ts)+d0In+1(Ts)exp⁡{(n+1)⋅L/N}.(34)= \sum_{i=0}^{n}l^{\psi,i}\exp\{(n-i+1)\cdot L/N\}I^{n-i}(T_s) + d_0I^{n+1}(T_s)\exp\{(n+1)\cdot L/N\}. \tag*{(34)}

This completes the induction. The final bound at t=1t = 1 follows by setting n=Nn = N.

Marginal Matching Inference

Algorithm 3 presents our proposed approach. The correction steps using hψh_\psi are taken before each step of the flow model vθv_\theta and at the end. For clarity, the algorithm assumes Euler integration for sampling vθv_\theta and single correction steps, though multiple corrections per time-step are possible. Adding Gaussian perturbation before each correction step, except the last one, improves performance. Algorithm 3 Marginal Matching

Require: flow model vθv_\theta, correction model hψh_\psi, number of iterations NN, step size of corrector steps {αi}i=0N\{\alpha_i\}_{i=0}^{N}, scale added noise {βi}i=0N\{\beta_i\}_{i=0}^{N}

  1. x0∼N(0,I)x_0 \sim\mathcal{N}(0, I)

  2. for n=0,…,N−1n = 0, \ldots, N - 1 do

  3. ϵ∼N(0,I)\epsilon\sim\mathcal{N}(0, I)

  4. x~tn=xtn+βn⋅ϵ\widetilde{x}_{t_n} = x_{t_n} + \beta_n \cdot\epsilon

  5. xtn=xtn+αn⋅hψ(tn,x~tn)x_{t_n} = x_{t_n} + \alpha_n \cdot h_\psi(t_n, \widetilde{x}_{t_n}) {Correction}

  6. xtn+1=xtn+1Nvθ(tn,xtn)x_{t_{n+1}} = x_{t_n} + \frac{1}{N}v_\theta(t_n, x_{t_n}) {Flow}

  7. end for

  8. xtN=xtN+αN⋅hψ(tN,xtN)x_{t_N} = x_{t_N} + \alpha_N \cdot h_\psi(t_N, x_{t_N}) {Correction}

  9. return xtNx_{t_N}

Practical Considerations

Backward Marginals Generation

Once a flow model is defined, we can generate samples from the backward marginal distributions using any ODE solver to integrate from time t=1t=1 to t=0t=0. We present two example implementations in Algorithm 4 and Algorithm 5, using RK4 and Euler integration methods respectively. The intermediate states at each time-step correspond to samples from the backward marginal distributions at those times (e.g., at t=1t=1 we sample from pt1bp^b_{t_1}, and at t=0t=0 we sample from pt0bp^b_{t_0}).

Algorithm 4 Backward Marginal Generation with RK4 Integration

Require: Initial condition y(1)y(1), number of steps NN, flow model vθv_\theta

  1. h←−1/Nh \leftarrow-1/N {Negative step size for backward integration}

  2. t←1t \leftarrow1 {Start time}

  3. y←y(1)y \leftarrow y(1) {Initial value}

  4. for i=1i = 1 to NN do

  5. k1←h⋅vθ(t,y)k_1 \leftarrow h \cdot v_\theta(t, y)

  6. k2←h⋅vθ(t+h2,y+k12)k_2 \leftarrow h \cdot v_\theta\left(t + \frac{h}{2}, y + \frac{k_1}{2}\right)

  7. k3←h⋅vθ(t+h2,y+k22)k_3 \leftarrow h \cdot v_\theta\left(t + \frac{h}{2}, y + \frac{k_2}{2}\right)

  8. k4←h⋅vθ(t+h,y+k3)k_4 \leftarrow h \cdot v_\theta(t + h, y + k_3)

  9. y←y+16(k1+2k2+2k3+k4)y \leftarrow y + \frac{1}{6}(k_1 + 2k_2 + 2k_3 + k_4)

  10. t←t+ht \leftarrow t + h

  11. end for

  12. return yy {Solution at t=0t=0}

Algorithm 5 Backward Marginal Generation with Euler Integration

Require: Initial condition y(1)y(1), number of steps NN, flow model vθv_\theta

  1. h←−1/Nh \leftarrow-1/N {Negative step size for backward integration}

  2. t←1t \leftarrow1 {Start time}

  3. y←y(1)y \leftarrow y(1) {Initial value}

  4. for i=1i = 1 to NN do

  5. y←y+h⋅vθ(t,y)y \leftarrow y + h \cdot v_\theta(t, y) {Euler step}

  6. t←t+ht \leftarrow t + h

  7. end for

  8. return yy {Solution at t=0t=0}

Practical Considerations of hψh_\psi

When designing the learning objective for hψh_\psi an important issue should be taken into consideration. The pre-trained flow model has established a matching between each distribution on the forward trajectory ptnfp^f_{t_n} and between each distribution on the backward trajectory ptnbp^b_{t_n} across different time-steps. Additionally, there exists a matching between π^1\hat{\pi}_1 and π1\pi_1. Through transitivity, this implies a pairing between ptnfp^f_{t_n} and ptnbp^b_{t_n} for every time step tnt_n. During the training process, samples from ptnfp^f_{t_n} and ptnbp^b_{t_n} are accessible. Models that try to establish pairing between these distributions will yield sub-optimal results, since the correct pairing is unknown. Thus, we opt for different generative models such as score and classifier.

Alternative Correction Models: Alternative correction models include the more sophisticated score models for traversing between forward and backward marginals, provided the noise level for the forward marginal is known. A supplementary model can be trained to predict the noise level, thereby assisting the score model. Additionally, Energy-Based Models (EBMs) (Du et al., 2021), could also be a good fit to explore the alignment of the sampling trajectory with the backward trajectory.

Approximations

Interpolating p0bp^b_0 and π1\pi_1

The correction model hψ(t,xt)h_\psi(t, x_t) is trained on different time-step marginals. The marginals are generated and stored in advance to avoid running the ODE-solver multiple times while training hψ(t,xt)h_\psi(t, x_t). Assuming the flow model’s trajectories are sufficiently straight, we can save this extra storage by approximating the backward trajectory through interpolation between p0bp^b_0, the approximate source distribution, and p1bp^b_1, the target distribution: p^tnb=tn⋅p1b+(1−tn)⋅p0b\hat{p}^b_{t_n} = t_n \cdot p^b_1 + (1 - t_n) \cdot p^b_0. This reduces storage requirements to just the data and approximate source distribution, making the dataset size twice rather than NN times the original size. Table 3 presents the results of the interpolated backward trajectory on CIFAR-10. The score model’s performance remains steady, while the classifier exhibits degradation in its performance. Table 4 compares the results of a score correction model on ImageNet-64 trained on the backward marginals ptbp^b_t versus the approximated marginals. The model trained on approximated marginals shows improved results, albeit not as significantly as the non-approximated version.

Correction ModelNFE ↓\downarrowC-NFE ↓\downarrowOT-CFM FID ↓\downarrowI-CFM FID ↓\downarrow
No Correction4004.344.29
Classifier421 (n=8n = 8)3.573.77
Classifier463 (n=8,9,10n = 8, 9, 10)3.483.67
Classifier505 (n=6,7,8,9,10n = 6, 7, 8, 9, 10)3.473.62
Classifier6211 (∀n\forall n)3.483.63
P-Classifier401 (n=7n = 7)3.653.75
P-Classifier403 (n=7,8,9n = 7, 8, 9)3.603.73
P-Classifier405 (n=5,6,7,8,9n = 5, 6, 7, 8, 9)3.593.67
P-Classifier4010 (n=0,1,2,3,4,5,6,7,8,9n = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)3.743.80
Classifier (Backward Marginals Interpolation)421 (n=8n = 8)3.773.74
Classifier (Backward Marginals Interpolation)463 (n=8,9,10n = 8, 9, 10)3.723.62
Classifier (Backward Marginals Interpolation)505 (n=6,7,8,9,10n = 6, 7, 8, 9, 10)3.673.69
Classifier (Backward Marginals Interpolation)6211 (∀n\forall n)3.683.67
Score411 (n=10n = 10)3.453.47
Score433 (n=0,5,10n = 0, 5, 10)3.383.39
Score5111 (∀n\forall n)3.373.38
P-Score401 (n=9n = 9)4.294.27
P-Score403 (n=0,5,9n = 0, 5, 9)4.083.99
P-Score4010 (n=0,1,2,3,4,5,6,7,8,9n = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)4.083.99
Score (Backward Marginals Interpolation)411 (n=10n = 10)3.463.47
Score (Backward Marginals Interpolation)433 (n=0,5,10n = 0, 5, 10)3.383.40
Score (Backward Marginals Interpolation)5111 (∀n\forall n)3.413.41

Table 3. Comparison of two variants of classifier and score correction models on CIFAR-10. First, a correction model that runs in parallel with (“P-”) the flow model. Second, a correction model that learns an interpolation of the data and approximate source distribution. The base flow models are sampled with 10-step RK4 (40 NFE). The classifier succeeds in improving the FID even with the parallel approximation, while the score shows less improvement. Training with interpolated backward marginals improves the FID score, though less than using their exact version.

Correction ModelNFE ↓\downarrowC-NFE ↓\downarrowFID ↓\downarrow
Score211 (n=5n = 5)15.91
Score222 (n=0,5n = 0, 5)15.53
Score266 (n=0…5n = 0 \ldots5)15.57
Score (Backward Marginals Interpolation)211 (n=5n = 5)15.89
Score (Backward Marginals Interpolation)222 (n=0,5n = 0, 5)15.62
Score (Backward Marginals Interpolation)266 (n=0…5n = 0 \ldots5)15.69

Table 4. Comparison of backward marginals ptbp_t^b and approximated marginals results on ImageNet-64 using OT-CFM as the base flow model, sampled with 5-step RK4 (20 NFE). Both versions improve the original score, though the approximation’s benefit is smaller.

Parallel Sampling

The corrected inference process, as described in Algorithm 3, introduces additional sampling time for each correction step. To reduce the overhead, we propose a correction algorithm that is parallelizable in principle, by running the correction and the flow model in parallel. The correction and the flow model both operate on the same input at the same time, then the correction hψh_\psi and the flow model’s vθv_\theta direction are summed, approximating the full correction process. While this is an approximation, the effectiveness of this approximation relies on the assumption that hψh_\psi and vθv_\theta do not change too rapidly.

Figure 7 presents the approximation of parallel sampling the correction and flow model. The algorithm for parallel sampling is presented in Alg. 6. For clarity, the algorithm assumes Euler integration as the ODE-solver. To maintain computational efficiency, a single correction step is implemented, ensuring that the total computation time remains equivalent to that of the uncorrected method.

Parallel Sampling diagram

Figure 7. Parallel Sampling The black arrows denote the path of first flowing with vθv_\theta and only then taking a correction step with hψh_\psi. In contrast, the dashed green arrow shows the approximation obtained by summing the direction of the flow model vθv_\theta (black arrow), and the correction model hψh_\psi (green arrow) on the current step.

This algorithm is parallel in principle. Cuda has a queue, where the CPU sends tasks to be run on the GPU. The GPU may execute tasks in parallel that are independent of one another, such as our parallel sampling. The CPU may wait when the queue is full or during synchronization events, (i.e. item(), synchronize(), etc.). Given a powerful enough Cuda machine, the models could be run in parallel on different GPUs or using advanced parallelism techniques. Parallel calculation on separate devices could be useful when the correction calculation takes more time than the overhead of moving between devices, as is the case for large models. The extent of parallel processing viability will depend on the specific hardware and infrastructure available.

Table 3 presents the complete results on CIFAR-10 of applying the correction models (score and classifier) in parallel with the flow model, (to save computation time), and with an approximation of the backward marginals (to save storage during training).

Score Model Training

Score models are generative AI systems that transform random noise into meaningful data through iterative denoising. At their core is the score function - the gradient of the log probability density - which guides samples toward higher likelihood regions of a target distribution.

These models utilize varying noise levels (σ\sigma) during generation. At high noise levels, samples differ significantly from the target distribution, but the score function provides stable gradients far from the data manifold. At low noise levels, as samples approach the target distribution, the score function enables detailed refinement. During generation, the model progressively reduces noise levels while following each corresponding score function, establishing a path between random noise and complex data distributions.

By assuming the forward marginals are a noisy version of the backward marginals (with a small σ\sigma), a score model can be used to transverse between them.

While sophisticated approaches like annealing score models with time-varying σ\sigma are widely used for generation, they proved unsuitable for our needs. This is due to our inference process that begins at a forward marginal (or an intermediate point), where we lack information about the current noise level, precluding the effective use of such models.

Robust Classifier Training

Adversarial Training (AT): Srinivas & Fleuret [45] demonstrated that the gradients of standard classifiers can be arbitrarily altered without impacting their cross-entropy loss or accuracy. Building on this insight, Kawar et al. [18] proposed using gradients from a robust classifier for guidance, rather than those from a conventional classifier. The gradients of robust classifiers are resistant to arbitrary manipulation as a results of the adversarial attack used in their loss computation is directly dependent on the model’s gradients. An intriguing characteristic of robust classifiers is that their gradients have been shown to align well with human perception, as noted by Tsipras et al. [48]. When robust classifiers are employed to guide xx towards a specific class cc, they are anticipated to produce significant features that correspond well with the target class. As a result, the modifications applied to xx are likely to be visually convincing and aligned with human perception of the class characteristics. Inspired by these works we enhance the classifier with Projected Gradient Descent (PGD) attack and Adversarial Training (AT) robustification method (Madry et al. [32]), with the PGD pseudo-algorithm detailed in

Algorithm 6 Parallel Marginal Matching

Require: flow model vθv_\theta, correction model hψh_\psi, number of iterations NN, step size of corrector steps {αi}i=0N−1\{\alpha_i\}_{i=0}^{N-1}, scale added noise {βi}i=0N−1\{\beta_i\}_{i=0}^{N-1}

  1. x0∼N(0,I)x_0 \sim\mathcal{N}(0,I)

  2. for n=0,…,N−1n = 0,\ldots,N-1 do

  3. ϵ∼N(0,I)\epsilon\sim\mathcal{N}(0,I)

  4. x~tn=xtn+βn⋅ϵ\tilde{x}_{t_n}=x_{t_n}+\beta_n\cdot\epsilon

  5. htn=hψ(tn,x~tn)h_{t_n}=h_\psi(t_n,\tilde{x}_{t_n}) {Correction}

  6. vtn=vθ(tn,xtn)v_{t_n}=v_\theta(t_n,x_{t_n}) {Flow}

  7. xtn+1=xtn+1Nvtn+αn⋅htnx_{t_{n+1}}=x_{t_n}+\frac{1}{N}v_{t_n}+\alpha_n\cdot h_{t_n}

  8. end for

  9. return xtNx_{t_N}

Alg. 7. Our findings indicate that adversarial training stabilizes gradients and enhances their meaningfulness.

Algorithm 7 Targeted Projected Gradient Descent

Require: classifier fϕf_{\phi}, input xx, class cc, number of iterations NN, step size α\alpha, radius ϵ\epsilon, loss function ℓ\ell,

  1. δ0=0\delta_{0} = 0

  2. for n=0,…,Nn = 0, \ldots, N do

  3. δn+1=Πϵ(δn−α∇δℓ(fϕ(x+δn),c))\delta_{n+1} = \Pi_{\epsilon}(\delta_n - \alpha\nabla_{\delta}\ell(f_{\phi}(x + \delta_n), c))

  4. end for

  5. xADV=x+δNx_{ADV} = x + \delta_N

  6. Return xADVx_{ADV}

Where Πϵ\Pi_{\epsilon} is a projection operator that keeps δ\delta’s norm below ϵ\epsilon so the adversarial example will not stray too far from the input; and the loss function in our case is cross entropy.

Gradient Alignment (GA): Inspired by Yadin et al. [54] and Song et al. [44], we incorporate a cosine-similarity loss term for the gradient. This aims to align the classifier’s gradient direction with the backward marginals when in close proximity. We artificially move away from the backward marginals by introducing small Gaussian perturbations to sampled points, and training the classifier gradient to point towards the original samples by aligning them with the negative direction of the noise.

The class for the forward marginals is represented by 0 and for the backward marginals by 1.

Algorithm 8 Robust Classifier Training

Require: classifier hψh_\psi, forwards marginals {ptn(x)f}n=0N\{p_{t_n}(x)^f\}_{n=0}^{N}, backward marginals {ptn(x)b}n=0N\{p_{t_n}(x)^b\}_{n=0}^{N}, loss weights {βi}i=13\{\beta_i\}_{i=1}^{3}, σ\sigma scale of noise, adversarial step size α\alpha, adversarial number of steps KK, adversarial radius ϵADV\epsilon_{ADV}

  1. repeat

  2. ϵ∼N(0,I)\epsilon\sim\mathcal{N}(0,I)

  3. n∼U({0,1,…,N})n \sim U(\{0,1,\ldots,N\})

  4. s=U(0,1)⋅σs = U(0,1)\cdot\sigma

  5. xf∼ptnf, xb∼ptnbx_f \sim p_{t_n}^f,\ x_b \sim p_{t_n}^b

  6. ℓCE=CE(hψ(xf,tn),0)+CE(hψ(xb,tn),1)\ell_{CE} = CE(h_\psi(x_f,t_n),0) + CE(h_\psi(x_b,t_n),1)

  7. cn=∇ψhψ(xb+s⋅ϵ,tn)c_n = \nabla_\psi h_\psi(x_b+s\cdot\epsilon,t_n)

  8. \ell_{CS} = cosine\mathchar`-similarity(c_n,-\epsilon)

  9. ℓADV=PGD(hψ,xf,0,K,α,ϵADV,CE)+PGD(hψ,xb,1,K,α,ϵADV,CE)\ell_{ADV} = PGD(h_\psi,x_f,0,K,\alpha,\epsilon_{ADV},CE) + PGD(h_\psi,x_b,1,K,\alpha,\epsilon_{ADV},CE)

  10. ℓ=β1⋅ℓCE+β2⋅ℓCS+β3⋅ℓADV\ell= \beta_1\cdot\ell_{CE}+\beta_2\cdot\ell_{CS}+\beta_3\cdot\ell_{ADV}

  11. Take gradient descent step on ∇ψℓ\nabla_\psi\ell

  12. until converged

Extended Related Work

Different sampling trajectories – Previous work explored different sampling trajectories primarily by studying various source distributions. In Denoising Diffusion Probabilistic Models [40] (Ho et al. 2020), various source distributions proved to decrease inference time while maintaining quality. gil Lee et al. [11] proposed using a Gaussian prior distribution with parameters derived from data statistics. Lyu et al. [31]; ); Popov et al. [38] trained a model for prior distribution using an encoder or VAE [22] and incorporated it into the standard diffusion process by adding noise. Other studies have shown that the prior distribution need not be Gaussian [2, 12]. Flow based models [27, 47, 28], a new family of generative models, generalized the mapping to include general source distributions.

A work aligned with ours is that of Xu et al. (2024) as they consider the learned errors throughout the whole sampling trajectory. They use a sequence of NF blocks to learn a sequential transformation from Gaussian noise to data, where each block represents a different time-step. This requires training the blocks sequentially, as the learned error in each block is accounted for in the next block, slowing the training process. The sampling process initiates from Gaussian noise, where the model’s error is not accounted for. In contrast, our work differs in that we focus on correcting the inference-time trajectory rather than the training trajectory, and we enhance flow matching models instead of NF.

Training and inference mismatch – Previous work recognized training and inference mismatch in different settings. In score models [44, 43], the source distribution during inference is N(0,I)\mathcal{N}(0,I), which is intended to approximate the ”noisiest” training distribution (pTp_T). However, as these distributions are not identical, starting from N(0,I)\mathcal{N}(0,I) will yield sub-optimal results. Two different solutions were proposed to minimize this gap as a pre-sampling procedure: Franzese et al. [10] suggested an auxiliary model that learns the mapping from N(0,I)\mathcal{N}(0,I) to pTp_T. Alternatively, Pedrotti et al. [36] proposed to use Langevin dynamics [52], leveraging the score function ∇xlog⁡pT(x)\nabla_x \log p_T(x).

Even if the source distribution during training and inference is the same, practically, the actual distribution that reaches the data is different. Coeurdoux et al. [4] leveraged the invertibility property of normalizing flow (NF) models (Kingma & Dhariwal [21]; Dinh et al. [8]) to reach higher probability samples in π^1\hat{\pi}_1, which are more likely to belong to π1\pi_1. They achieved this by employing MCMC algorithm, where the score is computed using the Jacobian of the inverse mapping. This discrepancy between the learned and actual source distribution is common in generative models like VAEs (Kingma et al., [20]), which assume a Gaussian prior during inference. (Dai & Wipf, [5]) addressed this by learning an additional VAE model to predict the actual prior distribution, thereby removing the Gaussian assumption, which lead to improved results.

Inverse diffusion – Previous work researched inversion of diffusion models, which are ”approximately invertible” models, particularly in the context of image editing. DDIM inversion (Song et al., [41]) method laid the groundwork for this approach, enabling the reversal of the diffusion process to obtain latent representations of images by utilizing a deterministic forward process. Building upon this foundation, Wallace et al. [51] improved the efficiency of the inversion by training an encoder network to directly map images to their corresponding noise representations in the diffusion process. Furthermore, Mokady et al. [33] enabled precise edits on real images through a text-guided approach, using a null-text optimization to find an optimal noise that, when denoised, produces the target image. Zhang & Kleijn [56] improved the accuracy of the inversion process by combining forward and backward trajectories to minimize approximation errors, while Pan et al. [35] focused on enhancing both the speed and quality of image editing operations by iteratively refining the inverted latent code.

Forward and Backward Trajectory Comparison

We illustrate the distinction between the forward and backward marginals of OT-CFM flow model (Tong et al., [47]) trained on the CIFAR-10 dataset and sampled with 10-step RK4. Figure 10 presents a visual representation of these marginals at each time-step tnt_n, created with t-SNE (Van der Maaten & Hinton [49]) in order to reduce the marginals’ dimensionality to two. Figure 9 offers an alternative visualization, where the t-SNE is applied to the classifier correction model’s features of the marginals at each time-step. The visualizations demonstrate that as nn increases there is a trend of growing similarity between the forward and backward marginals. However, this pattern of convergence does not extend to the final time step (n=10n = 10), where the comparison is between the actual data and the flow model’s approximation of it.

TSNE of Classifier Features

Figure 9. TSNE of Classifier Features Red represents the forward marginals, while blue denotes the backward marginals. The classifier’s features can differentiate between the forward and backward marginals in most cases. However, in some instances, these marginals are indistinguishable from one another.

TSNE of Forward and Backward Marginals

Figure 10. TSNE of Forward and Backward Marginals Red represents the forward marginals, while blue denotes the backward marginals. As time progresses, we observe a convergence between these two sets of marginals. However, it’s important to note that despite this increasing proximity, they never achieve perfect alignment or identity. n=0n=0 compares the approximate source distribution distribution (p0bp^{b}_{0}) and Gaussian noise while n=10n=10 compares the model’s data approximation (p1fp^{f}_{1}) and the real data.

Reinforcing this observation, Figure 8 examines the intersection of forward and backward marginals by presenting a histogram of the L2L_2 differences in VGG5 features between uncorrected and corrected samples. The distribution reveals that for both the classifier and score models, the majority of images exhibit minimal changes. This pattern indicates that corrections are primarily applied to images requiring adjustment, suggesting a close alignment between the forward and backward marginals. The selective nature of these corrections implies that the models effectively identify and address outliers, refining the overall distribution while leaving well-formed samples largely unchanged.

Histogram of L2 differences

Figure 8. Percentage vs L2L_2 difference. Histogram showing L2L_2 differences of VGG features between samples generated using a flow model alone versus with a correction model. The samples are generated from identical Gaussian noise. The percentage indicates the proportion of images with the corresponding difference. The score and classifier correction models leave most images largely unchanged, with differences concentrated in a small range, while significantly altering only outliers. This suggests that there is an intersection between the forward and backward marginals.

Additional Experiments

Score Ablation Study

An ablation study on different σ\sigma values for the score model trained on CIFAR-10 is presented in Table 5. The correction step-sizes for different sigmas were multiplied by a constant value, as the score function is multiplied by sigma during evaluation. For all other evaluations, we employed the score model trained using σ=0.005\sigma= 0.005, as it yielded superior performance compared to other values.

Correction ModelNFE ↓\downarrowC-NFE ↓\downarrowFID ↓\downarrow
0.001-Score4113.83
4333.75
51113.77
0.003-Score4113.51
4333.44
51113.45
0.005-Score4113.45
4333.38
51113.37
0.01-Score4113.49
4333.42
51113.38

Table 5. Ablation study on the sigma value of score correction model sampled on n={[10],[0,5,10],∀n}n = \{[10], [0, 5, 10], \forall n\} marginals on CIFAR-10. The σ\sigma-Score represents the value of σ\sigma the score model was trained with. The base flow model is OT-CFM sampled with 10-step RK4 (40 NFE). The results demonstrate that the optimal performance is achieved when σ=0.005\sigma= 0.005 (the value used in the main paper).

CIFAR-10 Classifier Guidance

We implement classifier guidance as described in § 4.1.2 on CIFAR-10 dataset. Figure 11 presents images produced with our corrected inference algorithm that use the class-condition classifier, where the trajectory is steered toward the correct class in the backward marginals. On the left, the original images of the flow model are presented (with no correction), and on the right the images from the same source noise, but with correction steps toward the matching classes. Even when the classifier’s class matches the original class of the source noise it produces a different image of the same class, more closely aligned with the backward trajectory.

CIFAR-10 images generated by OT-CFM

Figure 11. CIFAR-10 images generated by OT-CFM sampled with 10-step RK4, shown alongside their counterparts produced with class conditioned classifier correction. The classifier successfully directs the noise to the correct class.

Flow as Correction Model

In this experiment we perform MM with a flow model (OT-CFM) as the correction model. The correction is performed only on the first and last marginals with a different number of correction steps, see Table. Table 6. The correction of the first marginal is done between Gaussian noise (p0fp_0^f) to the approximate source distribution (p0bp_0^b), and on the last marginal from the approximate target distribution (p1fp_1^f) to the target distribution (p1b=π1p_1^b = \pi_1). The first row in the table presents the FID result with no correction model, but only 10-step RK4 sampling of the OT-CFM base flow model.

Correction ModelNFE↓\downarrowC-NFE↓\downarrowFID↓\downarrow
No Correction4004.34
OT-CFM – 1st1^{st} Marginal4829.74
OT-CFM – 1st1^{st} Marginal6466.31
OT-CFM – 1st1^{st} Marginal120206.33
OT-CFM – NthN^{th} Marginal4827.43
OT-CFM – NthN^{th} Marginal6464.39
OT-CFM – NthN^{th} Marginal120204.41

Table 6. CIFAR-10 FID comparison of OT-CFM correction and flow model trained on first and last marginals. The correction score model was sampled with C-NFE RK4 steps, while the base flow model was sampled with 10-step RK4 (40 NFE). The correction flow model degrades the results.

The flow model only degrades the results. We hypothesize that this is due to the pairing problem, for more details refer to Appendix. § 14. That led us to explore other correction models - score and robust classifier.

CIFAR-10 Test Sample Quality

The performance of OT-CFM flow model with and without correction on CIFAR-10 test set is presented in Table 7. The correction model helps the generation quality, even though it was trained to match the training data marginals. Where the C-NFE is greater than one, the correction steps were taken on different time-step marginals; we examine several options: for the score model the correction steps were taken on n=[10],[0,5,10],∀nn = [10], [0, 5, 10], \forall n and for the classifier on n=[8],[8,9,10],[6,7,8,9,10],∀nn = [8], [8, 9, 10], [6, 7, 8, 9, 10], \forall n, same as Table 1.

Flow ModelNFE ↓FID ↓
OT-CFM406.43
446.04
485.80
525.70
Correction ModelNFE ↓C-NFE ↓FID ↓
Score411 (n=10n = 10)5.52
433 (n=0,5,10n = 0, 5, 10)5.46
Classifier421 (n=8n = 8)5.66
463 (n=8,9,10n = 8, 9, 10)5.57
505 (n=6,7,8,9,10n = 6, 7, 8, 9, 10)5.56

Table 7. CIFAR-10 test set FID performance of OT-CFM flow model with and without our correction models (score and classifier). OT-CFM is sampled without correction using 10,20, and 50-step RK4. Our correction models use OT-CFM with 10-step RK4 (40 NFE). In general, adding correction steps (C-NFE) improves the results.

Residual Model

Another baseline we measure against is a straightforward approach to enhance sampling, assuming we have access to the data. This involves training a residual flow matching network using the standard flow matching objective. This leverages an increase in model size effectively. The training process involves using the frozen network vθv_\theta, adding the output of the residual network (vθ(t,x)+hψ(t,x)v_\theta(t, x) + h_\psi(t, x)), and aiming to predict the vector field (refer to § 2.1). Table 8 shows the results of this approach. While it degrades the original performance, our method demonstrates improvements. We hypothesize that the residual flow matching objective is more challenging to optimize than our approach, leading to worse performance under equivalent training conditions and model sizes.

NFEFID ↓
404.44
444.09
483.79
523.56

Table 8. Results of residual networks combined with both the base flow model and the residual network OT-CFM flow models.

Flow Models RK4 Results

ModelNFEFID ↓
OT-CFM ([47])404.34
443.96
483.73
523.59
563.52
603.47
I-CFM ([47])404.29
443.96
483.74
523.60
563.52
603.47

Table 9. CIFAR-10 FID scores for OT-CFM and I-CFM flow models sampled with RK4. The number of RK4 steps is 1/4 of the number of the NFEs.

Implementation Details

Flow Models Architecture

Our flow models architecture is based on the UNet design from [34] that was employed in [47] and Lipman et al. [27].

CIFAR-10ImageNet-64
Channels128192
Depth23
Channels multiple1,2,2,21,2,3,4
Heads44
Heads Channels6464
Attention resolution1632,16,8
Dropout0.10.0
Batch size128512
Iterations400K600k
Learning Rate5e-41e-4
Learning Rate SchedulerPolynomial DecayConstant
Warmup Steps50000

Table 10. Hyper-parameters used for CIFAR-10 and ImageNet-64 flow models.

Corrections Models Architecture

The correction models utilized the same UNet architecture with different hyper-parameters than the flow models. The classifier model required an additional convolution layer and two linear layers to reduce the output dimension to a single scalar. The correction models were trained for 100, 000 optimization steps, however we observed convergence within 30, 000 to 40, 000 steps. The models sizes are half the number of trainable parameters of the original flow models, requiring significantly less time to converge.

ClassifierScore
CIFAR-10CIFAR-10ImageNet-64
Channels128128192
Depth112
Channels multiple1,2,1,21, 2, 1, 21, 2, 3, 2
Heads444
Heads Channels323264
Attention resolution161632, 16, 8
Dropout0.10.10.0
Batch size128128512
Iterations100K100K100K
Learning Rate0.00010.00020.0001
σ\sigma0.010.0050.05
Linear Layers Output64, 1--

Table 11. Correction models hyper-parameters.

Losses

Score Model: Our score model was trained using the denoising score matching loss (DSM) over the backward marginals {ptnb}n=0N\{p_{t_n}^{b}\}_{n=0}^{N} with a constant noise scale σ\sigma:

LDSM=E[Eytn∼ptnb,ϵ∼N(0,σ2I)[∥sψ(tn,ytn+ϵ)+ϵ∥22]]L_{DSM} = \mathbb{E}\left[\mathbb{E}_{y_{t_n}\sim p_{t_n}^{b},\epsilon\sim\mathcal{N}(0,\sigma^{2}I)}\left[\left\|s_{\psi}(t_n,y_{t_n}+\epsilon)+\epsilon\right\|_{2}^{2}\right]\right]

where sψ(tn,ytn)s_{\psi}(t_n,y_{t_n}) is the score model parameterized by ψ\psi. For more details see § 2.2.

Classifier Model: Our robust classifier was trained using LclassifierL_{\mathrm{classifier}} which is comprised of 3 terms:

Lclassifier=LBCE+LAT+LGAL_{\mathrm{classifier}} = L_{BCE} + L_{AT} + L_{GA}

Binary Cross-Entropy: The binary cross-entropy (BCE) is used to distinguish between the backward marginals ptnbp_{t_n}^{b} and the forward marginals ptnfp_{t_n}^{f}:

LBCE=E[Eytn∼ptnb,xtn∼ptnf[BCE(cψ(tn,ytn),1)+BCE(cψ(tn,xtn),0)]]L_{BCE} = \mathbb{E}\left[\mathbb{E}_{y_{t_n}\sim p_{t_n}^{b},x_{t_n}\sim p_{t_n}^{f}}\left[BCE(c_{\psi}(t_n,y_{t_n}),1)+BCE(c_{\psi}(t_n,x_{t_n}),0)\right]\right]

where cψ(tn,y)c_{\psi}(t_n,y) is the classifier output for input yy at time tnt_n, parameterized by ψ\psi.

Adversarial Training (AT): To enhance its robustness, the classifier was also trained on adversarial examples. This process involves:

  1. Sampling ytn∼ptnby_{t_n}\sim p_{t_n}^{b} and xtn∼ptnfx_{t_n}\sim p_{t_n}^{f}.

  2. Optimizing norm-clipped additive perturbations ηy\eta_y and ηx\eta_x to:

    • Decrease the classifier value for yy: cψ(tn,ytn+ηy)c_{\psi}(t_n,y_{t_n}+\eta_y)

    • Increase the classifier value for xx: cψ(tn,xtn+ηx)c_{\psi}(t_n,x_{t_n}+\eta_x)

For a more detailed explanation see Sec. D.5.

LAT=E[Eytn∼ptnb,xtn∼ptnf[BCE(cψ(tn,ytn+ηy),1)+BCE(cψ(tn,xtn+ηx),0)]]L_{AT} = \mathbb{E}\left[\mathbb{E}_{y_{t_n}\sim p_{t_n}^{b},x_{t_n}\sim p_{t_n}^{f}}\left[BCE(c_{\psi}(t_n,y_{t_n}+\eta_y),1)+BCE(c_{\psi}(t_n,x_{t_n}+\eta_x),0)\right]\right]

Gradient Alignment (GA): To align the classifier’s gradient near the backward marginals, we introduce a small amount of Gaussian noise and use cosine similarity to adjust the classifier’s gradient in the direction opposite to the noise (towards the backward marginal).

LGA=E[Eytn∼ptnb,ϵ∼N(0,σ2I)[1−⟨∇ytncψ(tn,xtn+ϵ),ϵ⟩∥∇ytncψ(tn,xtn+ϵ)∥2∥ϵ∥2]]L_{GA} = \mathbb{E}\left[\mathbb{E}_{y_{t_n}\sim p_{t_n}^{b},\epsilon\sim\mathcal{N}(0,\sigma^{2}I)}\left[1-\frac{\langle\nabla_{y_{t_n}}c_{\psi}(t_n,x_{t_n}+\epsilon),\epsilon\rangle}{\left\|\nabla_{y_{t_n}}c_{\psi}(t_n,x_{t_n}+\epsilon)\right\|_{2}\left\|\epsilon\right\|_{2}}\right]\right]

Evaluation Parameters

Hyper-parameters:

Step size α\alpha: The configuration with the best FID was selected from a grid search over the interval [0,2][0,2] with a step size of 0.050.05. For the classifier’s final step, the grid search was conducted over the interval [0,0.1][0,0.1] with a step size of 0.010.01.

Noise β\beta: The configuration with the best FID was selected from a grid search over the interval [0,0.1][0,0.1] with a step size of 0.010.01.

Sampling:

The hyper-parameters for all evaluations are described below, except for parallel sampling, where the time-steps are shifted by 1 (10 → 9, 9 → 8, etc). Additionally, for parallel classifier the final step-size is 0.02 instead of 0.06.

The score model’s Langevin Dynamics sampling used 50 and 100 steps with step sizes of 0.1 and 0.05, respectively, yielding the best results among step sizes [0.01,0.05,0.1][0.01,0.05,0.1].

Corr. StepClassifier
10 Steps5 Steps3 Steps1 Step
Step SizeNoiseStep SizeNoiseStep SizeNoiseStep SizeNoise
01.50.05------
11.50.0------
21.50.0------
31.50.0------
41.50.0------
51.50.0------
61.50.081.50.08----
71.50.01.50.0----
81.50.01.50.01.00.051.00.05
91.50.01.50.00.40.0--
100.060.00.060.00.060.0--

Table 12. CIFAR-10 evaluation hyper-parameters for the classifier correction model.

Corr. StepScore
10 Steps3 Steps1 Step
Step SizeNoiseStep SizeNoiseStep SizeNoise
00.40.030.350.03--
10.30.0----
20.30.0----
30.30.0----
40.30.01----
50.350.050.450.05--
60.30.0----
70.30.0----
80.30.01----
90.30.00----
102.00.02.00.02.00.0

Table 13. CIFAR-10 evaluation hyper-parameters for score correction model.

Corr. StepScore
5 Steps2 Steps1 Step
Step SizeNoiseStep SizeNoiseStep SizeNoise
00.40.10.40.01--
10.20.05----
20.20.0----
30.20.0----
40.20.05----
50.40.00.40.00.40.0

Table 14. ImageNet-64 evaluation hyper-parameters for score correction model.

Qualitative Examples

ImageNet-64 image generation using OT-CFM alone and with score correction model

Figure 12. ImageNet-64 image generation using OT-CFM alone and with score correction model. The corrected images demonstrate enhanced sharpness and definition compared to their uncorrected counterparts.

CIFAR-10 image generation using OT-CFM alone and with score correction and classifier correction models

Figure 13. (a) OT-CFM; (b) Score Correction Model; (c) Classifier Correction Model. CIFAR-10 image generation using OT-CFM alone and with score correction and classifier correction models. Despite the distinct nature of these correction models, their suggested improvements often exhibit remarkable similarity. The corrected images demonstrate enhanced sharpness and definition compared to their uncorrected counterparts.

OT-CFM

(a) OT-CFM

Last Marginal Score Correction Model

(b) Last Marginal Score Correction Model

Correction Difference

(c) Correction Difference

Figure 14. ImageNet-64 images generated by OT-CFM alone and with score correction model applied solely to the final step, accompanied by their difference (amplified for visibility). The noise-like appearance of the difference suggests the presence of residual noise in the model’s predictions.

CIFAR-10 images generated by OT-CFM, with last marginal score correction, and their correction difference

Figure 15. CIFAR-10 images generated by OT-CFM alone and with score correction model applied solely to the final step, accompanied by their difference (amplified for visibility). The noise-like appearance of the difference suggests the presence of residual noise in the model’s predictions.

References

  1. [2]Bansal, A., Borgnia, E., Chu, H.-M., Li, J., Kazemi, H., Huang, F., Goldblum, M., Geiping, J., and Goldstein, T. Cold diffusion: Inverting arbitrary image transforms without noise. Advances in Neural Information Processing Systems, 36, 2024.arxiv.org/abs/2208.09392
  2. [3]Chrabaszcz, P., Loshchilov, I., and Hutter, F. A downsampled variant of imagenet as an alternative to the cifar datasets. arXiv preprint arXiv:1707.08819, 2017.arxiv.org/abs/1707.08819
  3. [4]Coeurdoux, F., Dobigeon, N., and Chainais, P. Normalizing flow sampling with langevin dynamics in the latent space, 2023. URL https://arxiv.org/abs/2305.12149.
  4. [5]Dai, B. and Wipf, D. Diagnosing and enhancing VAE models. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id=B1e0X3C9tQ.arxiv.org/abs/1903.05789
  5. [6]Deng, J., Dong, W., Socher, R., Li, L.-J., Li, K., and Fei-Fei, L. Imagenet: A large-scale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pp. 248–255. Ieee, 2009.
  6. [7]Dhariwal, P. and Nichol, A. Diffusion models beat gans on image synthesis. Advances in neural information processing systems, 34:8780–8794, 2021.
  7. [8]Dinh, L., Krueger, D., and Bengio, Y. Nice: Non-linear independent components estimation. arXiv preprint arXiv:1410.8516, 2014.DOI
  8. [10]Franzese, G., Rossi, S., Yang, L., Finamore, A., Rossi, D., Filippone, M., and Michiardi, P. How much is enough? a study on diffusion times in score-based generative models. Entropy, 25(4):633, 2023.DOI
  9. [11]gil Lee, S., Kim, H., Shin, C., Tan, X., Liu, C., Meng, Q., Qin, T., Chen, W., Yoon, S., and Liu, T.-Y. Priorgrad: Improving conditional denoising diffusion models with data-dependent adaptive prior. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id=_BNiN4IjC5.arxiv.org/abs/2106.06406
  10. [12]Heitz, E., Belcour, L., and Chambon, T. Iterative α-(de)blending: A minimalist deterministic diffusion model. In ACM SIGGRAPH 2023 Conference Proceedings, pp. 1–8, 2023.DOI
  11. [13]Heusel, M., Ramsauer, H., Unterthiner, T., Nessler, B., and Hochreiter, S. Gans trained by a two time-scale update rule converge to a local nash equilibrium. Advances in neural information processing systems, 30, 2017.
  12. [16]Irwin, R., Tibo, A., Janet, J.-P., and Olsson, S. Efficient 3d molecular generation with flow matching and scale optimal transport. arXiv preprint arXiv:2406.07266, 2024.
  13. [17]Kantorovich, L. V. On the translocation of masses. In Dokl. Akad. Nauk. USSR (NS), volume 37, pp. 199–201, 1942.
  14. [18]Kawar, B., Ganz, R., and Elad, M. Enhancing diffusion-based image synthesis with robust classifier guidance. Transactions on Machine Learning Research, 2023. ISSN 2835-8856. URL https://openreview.net/forum?id=tEVpz2xJWX.arxiv.org/abs/2208.08664
  15. [19]Kim, Y., Jo, D., Jeon, H., Kim, T., Ahn, D., Kim, H., et al. Leveraging early-stage robustness in diffusion models for efficient and high-quality image synthesis. Advances in Neural Information Processing Systems, 36, 2024.DOI
  16. [20]Kingma, D., Salimans, T., Poole, B., and Ho, J. Variational diffusion models. Advances in neural information processing systems, 34:21696–21707, 2021.arxiv.org/abs/2107.00630
  17. [21]Kingma, D. P. and Dhariwal, P. Glow: Generative flow with invertible 1x1 convolutions. Advances in neural information processing systems, 31, 2018.arxiv.org/abs/1807.03039
  18. [22]Kingma, D. P. and Welling, M. Auto-encoding variational bayes. arXiv preprint arXiv:1312.6114, 2013.arxiv.org/abs/1312.6114
  19. [23]Krizhevsky, A., Hinton, G., et al. Learning multiple layers of features from tiny images. 2009.
  20. [24]Kwon, D., Fan, Y., and Lee, K. Score-based generative modeling secretly minimizes the wasserstein distance. Advances in Neural Information Processing Systems, 35: 20205–20217, 2022.arxiv.org/abs/2212.06359
  21. [26]Lezama, J., Salimans, T., Jiang, L., Chang, H., Ho, J., and Essa, I. Discrete predictor-corrector diffusion models for image synthesis. In The Eleventh International Conference on Learning Representations, 2022.
  22. [27]Lipman, Y., Chen, R. T. Q., Ben-Hamu, H., Nickel, M., and Le, M. Flow matching for generative modeling. In The Eleventh International Conference on Learning Representations, 2023. URL https://openreview.net/forum?id=PqvMRDCJT9t.arxiv.org/abs/2210.02747
  23. [28]Liu, X., Gong, C., and qiang liu. Flow straight and fast: Learning to generate and transfer data with rectified flow. In The Eleventh International Conference on Learning Representations, 2023a. URL https://openreview.net/forum?id=XVjTT1nw5z.arxiv.org/abs/2209.03003
  24. [29]Liu, X., Zhang, X., Ma, J., Peng, J., et al. Instaflow: One step is enough for high-quality diffusion-based text-to-image generation. In The Twelfth International Conference on Learning Representations, 2023b.arxiv.org/abs/2309.06380
  25. [31]Lyu, Z., XU, X., Yang, C., Lin, D., and Dai, B. Accelerating diffusion models via early stop of the diffusion process, 2022.arxiv.org/abs/2205.12524
  26. [32]Madry, A., Makelov, A., Schmidt, L., Tsipras, D., and Vladu, A. Towards deep learning models resistant to adversarial attacks. In International Conference on Learning Representations, 2018. URL https://openreview.net/forum?id=rJzIBfZAb.arxiv.org/abs/1706.06083
  27. [33]Mokady, R., Hertz, A., Aberman, K., Pritch, Y., and Cohen-Or, D. Null-text inversion for editing real images using guided diffusion models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 6038–6047, 2023.arxiv.org/abs/2211.09794
  28. [34]Nichol, A. Q. and Dhariwal, P. Improved denoising diffusion probabilistic models. In International conference on machine learning, pp. 8162–8171. PMLR, 2021.arxiv.org/abs/2102.09672
  29. [35]Pan, Z., Gherardi, R., Xie, X., and Huang, S. Effective real image editing with accelerated iterative diffusion inversion. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 15912–15921, 2023.arxiv.org/abs/2309.04907
  30. [36]Pedrotti, F., Maas, J., and Mondelli, M. Improved convergence of score-based diffusion models via prediction-correction. Transactions on Machine Learning Research, 2024. ISSN 2835-8856. URL https://openreview.net/forum?id=0zKvH7YiAq.arxiv.org/abs/2305.14164
  31. [37]Pooladian, A. A., Ben-Hamu, H., Domingo-Enrich, C., Amos, B., Lipman, Y., and Chen, R. T. Multisample flow matching: Straightening flows with minibatch couplings. Proceedings of Machine Learning Research, 202: 28100–28127, 2023.arxiv.org/abs/2304.14772
  32. [38]Popov, V., Vovk, I., Gogoryan, V., Sadekova, T., and Kudinov, M. Grad-tts: A diffusion probabilistic model for text-to-speech. In International Conference on Machine Learning, pp. 8599–8608. PMLR, 2021.arxiv.org/abs/2105.06337
  33. [39]Shaul, N., Perez, J., Chen, R. T., Thabet, A., Pumarola, A., and Lipman, Y. Bespoke solvers for generative flow models. In The Twelfth International Conference on Learning Representations, 2024.arxiv.org/abs/2310.19075
  34. [40]Sohl-Dickstein, J., Weiss, E., Maheswaranathan, N., and Ganguli, S. Deep unsupervised learning using nonequilibrium thermodynamics. In International conference on machine learning, pp. 2256–2265. PMLR, 2015.
  35. [41]Song, J., Meng, C., and Ermon, S. Denoising diffusion implicit models. In International Conference on Learning Representations, 2021a. URL https://openreview.net/forum?id=St1giarCHLP.arxiv.org/abs/2010.02502
  36. [42]Song, K. and Lai, H. Leveraging previous steps: A training-free fast solver for flow diffusion. arXiv preprint arXiv:2411.07627, 2024.arxiv.org/abs/2411.07627
  37. [43]Song, Y. and Ermon, S. Generative modeling by estimating gradients of the data distribution. Advances in neural information processing systems, 32, 2019.arxiv.org/abs/1907.05600
  38. [44]Song, Y., Sohl-Dickstein, J., Kingma, D. P., Kumar, A., Ermon, S., and Poole, B. Score-based generative modeling through stochastic differential equations. In International Conference on Learning Representations, 2021b. URL https://openreview.net/forum?id=PxTIG12RRHS.
  39. [45]Srinivas, S. and Fleuret, F. Rethinking the role of gradient-based attribution methods for model interpretability. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id=dYeAHXnpwJ4.arxiv.org/abs/2006.09128
  40. [46]Sun, Z., Yang, Z., Jin, Y., Chi, H., Xu, K., Xu, K., Chen, L., Jiang, H., Zhang, D., Song, Y., Gai, K., and Mu, Y. Rectif: Personalizing rectified flow with anchored classifier guidance. arXiv preprint arXiv:2405.14677, 2024.arxiv.org/abs/2405.14677
  41. [47]Tong, A., FATRAS, K., Malkin, N., Huguet, G., Zhang, Y., Rector-Brooks, J., Wolf, G., and Bengio, Y. Improving and generalizing flow-based generative models with minibatch optimal transport. Transactions on Machine Learning Research, 2024. ISSN 2835-8856. URL https://openreview.net/forum?id=CD9Snc73AW. Expert Certification.arxiv.org/abs/2302.00482
  42. [48]Tsipras, D., Santurkar, S., Engstrom, L., Turner, A., and Madry, A. Robustness may be at odds with accuracy. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id=SyxAb30cY7.arxiv.org/abs/1805.12152
  43. [49]Van der Maaten, L. and Hinton, G. Visualizing data using t-sne. Journal of machine learning research, 9(11), 2008.
  44. [50]Vincent, P. A connection between score matching and denoising autoencoders. Neural computation, 23(7):1661–1674, 2011.DOI
  45. [51]Wallace, B., Gokul, A., and Naik, N. Edict: Exact diffusion inversion via coupled transformations. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 22532–22541, 2023.arxiv.org/abs/2211.12446
  46. [52]Welling, M. and Teh, Y. W. Bayesian learning via stochastic gradient langevin dynamics. In Proceedings of the 28th international conference on machine learning (ICML-11), pp. 681–688. Citeseer, 2011.
  47. [54]Yadin, S., Elata, N., and Michaeli, T. Classification diffusion models. arXiv preprint arXiv:2402.10095, 2024.arxiv.org/abs/2402.10095
  48. [55]Yan, H., Liu, X., Pan, J., Liew, J. H., Liu, Q., and Feng, J. Perflow: Accelerating diffusion models via piecewise rectified flow. 2024.
  49. [56]Zhang, G. and Kleijn, W. B. Exact diffusion inversion via bi-directional integration approximation. arXiv preprint arXiv:2307.10829, 2023.arxiv.org/abs/2307.10829
  50. [57]Zhao, W., Bai, L., Rao, Y., Zhou, J., and Lu, J. Unipc: A unified predictor-corrector framework for fast sampling of diffusion models. arXiv preprint arXiv:2302.04867, 2023.arxiv.org/abs/2302.04867
  51. [58]Zhao, W., Wang, H., Zhou, J., and Lu, J. Dc-solver: Improving predictor-corrector diffusion sampler via dynamic compensation. arXiv preprint arXiv:2409.03755, 2024.arxiv.org/abs/2409.03755
  52. [59]Zhu, J.-Y., Park, T., Isola, P., and Efros, A. A. Unpaired image-to-image translation using cycle-consistent adversarial networks. In Proceedings of the IEEE international conference on computer vision, pp. 2223–2232, 2017.arxiv.org/abs/1703.10593

Paper details

vlnc:W_hfy6gxpu
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 4

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

Not recorded for this paper

View statement
Looking for related papers…
Contents