Diffusion models intro¶
Initial version: 2026-02-21 · First published: 2026-02-24 · Last content update: 2026-10-21
Chapter 1 — Sample trajectories and probability transport¶
A continuous normalizing flow (CNF) defines a generative model by transporting samples from a base distribution through an ODE. Flow matching provides one way to train its velocity field. Conditional flow matching makes that training practical by constructing intermediate states and velocity targets from sampled data, without evaluating the unknown data density. Section 1.1 introduces the CNF model and its flow map; Chapter 2 develops the flow-matching objectives and the conditions under which conditional supervision recovers a field generating the intended probability path.
To relate sample motion to the resulting distribution, we use two descriptions: the Lagrangian view follows sample trajectories, while the Eulerian view describes fields and probability evolution at fixed states. Here \(x\in\mathbb R^D\) represents a data state, and \(t\in[0,1]\) indexes progression from the base distribution at \(t=0\) to the model distribution at \(t=1\). The velocity field \(v_t(x)\) specifies how the state changes along this progression; \(t\) is not elapsed computation time. For ODE transport, the continuity equation connects these descriptions. This mathematical connection does not require a physical interpretation of the trajectories or the fluid-dynamical constraints discussed in the Flow Matching comparison. The manifold hypothesis introduced later concerns possible data geometry; it is not required for this transport construction.
1.1 Continuous normalizing flows (CNFs)¶
We begin from the Lagrangian (particle) view: model a velocity field and move samples by an ODE. The corresponding Eulerian (density) view will appear in Section 1.2.
Let
be a time-dependent vector field (velocity). We will work in the Euclidean data space \(\mathbb{R}^D\), with data points \(x=(x_1,\dots,x_D)\in\mathbb{R}^D\).
Two fundamental objects in flow-based generative modeling are:
- a probability density path \(p:[0,1]\times\mathbb{R}^D\to\mathbb{R}_{\ge 0}\), written as \(p_t(x):=p(t,x)\), such that \(\int_{\mathbb{R}^D} p_t(x)\,dx=1\) for every \(t\in[0,1]\);
- a time-dependent vector field \(v_t(\cdot):=v(t,\cdot)\) that transports particles (and hence pushes densities forward).
Given \(v_t\), define its flow map \(\phi_t:\mathbb{R}^D\to\mathbb{R}^D\) as the solution of the ODE
with initial condition
A sufficient setting is continuity in time, local Lipschitz continuity in space uniformly on compact time-space sets, and a uniform linear-growth bound \(\|v_t(x)\|\le C(1+\|x\|)\). Local uniqueness selects a trajectory, and the growth bound prevents finite-time escape. Applying these conditions to the reversed field also gives a trajectory from every terminal state, so \(\phi_t\) is an invertible homeomorphism on \(\mathbb R^D\). If \(D_xv_t(x)\) is jointly continuous, the flow is a diffeomorphism. These are sufficient mathematical conditions, not constraints enforced by the FM loss. Singular endpoints and finite-step numerical maps require separate analysis.
Spatial Lipschitz continuity bounds how much the velocity can change between two states at the same time. In the local, time-uniform setting used above, for every radius \(R>0\) there is a finite constant \(L_R\ge0\) such that
Here \(\|\cdot\|\) is the Euclidean norm. The constant may grow with \(R\); a global Lipschitz bound would use one constant for the entire space. This condition controls spatial variation, not the magnitude of the velocity or its variation in time. It does not require \(v_t\) to be constant or differentiable: in one dimension, \(v_t(x)=a(t)|x|\), with continuous \(a\), is globally Lipschitz in \(x\), although it can vary with time and need not be differentiable at zero.
The connection to trajectory uniqueness follows from the ODE's integral form. If two solutions \(x_t\) and \(y_t\) remain in the radius-\(R\) ball for \(0\le t\le T\le1\), then
Grönwall's inequality therefore gives
Identical initial states give zero separation: two solutions cannot branch from the same initial condition. Nearby initial states also have a controlled separation over this interval, although the bound allows expansion rather than requiring contraction. Together with continuity in time, local Lipschitz continuity supplies a sufficient condition for local existence and uniqueness; it is not a necessary condition for every uniquely solvable ODE. The separate linear-growth bound above ensures that solutions extend across the full interval without escaping to infinity. Neither property follows merely from minimizing a flow-matching regression loss.
The defining modeling choice of a Continuous Normalizing Flow (CNF) (Chen et al., 2018) is to parameterize the vector field by a neural network \(v_t(x;\theta)\). This induces a learnable family of flow maps \(\phi_t(\cdot;\theta)\) via (1)–(2).
Push-forward: how a CNF transports densities¶
Let \(p_0\) be a simple base density (e.g., \(\mathcal{N}(0,I)\)) and define \(X_t:=\phi_t(X_0)\) with \(X_0\sim p_0\). Writing \(\mu_0(dx)=p_0(x)\,dx\), the time-\(t\) law is the push-forward of \(\mu_0\) by \(\phi_t\):
When \(\phi_t\) is a diffeomorphism, the push-forward has the familiar change-of-variables form:
Equivalently, \(p_0(x)=p_t(\phi_t(x))\big|\det(\partial_x\phi_t(x))\big|\).
We say that a vector field \(v_t\) generates a density path \((p_t)\) if its flow \(\phi_t\) satisfies (3). One practical way to check whether a candidate \((p_t,v_t)\) is consistent is the continuity equation, which we introduce next.
For the full classical fluid-mechanics PDE system (beyond this kinematic ODE viewpoint), see Interlude \(\alpha\) — Year 1757.
For a more detailed treatment of first-order ODEs and the viewpoint of an ODE with a random initial condition (random initial value problem) \(X_t=\phi_t(X_0)\), see Mathematics Foundation.
Probability conservation, density change, and diffusion
ODEs and SDEs preserve total probability through the same principle. Work on \(\mathbb R^D\) over a finite time interval, with well-defined dynamics that neither explode nor kill samples. Let \(K_{s,t}(x,A)\) denote the probability of reaching a measurable set \(A\) at time \(t\), starting from \(x\) at time \(s\). A normalized transition kernel transports a probability law by
An ODE flow is the deterministic case: \(K_{s,t}(x,dy)=\delta_{\phi_{s\to t}(x)}(dy)\), where \(\delta_z\) concentrates unit probability at \(z\), and \(\phi_{s\to t}\) maps a state at time \(s\) to its state at time \(t\). A Markov SDE generally gives a non-degenerate transition instead. For DDPM, this transition has a normalized Gaussian density \(q_k(y\mid x)\), giving
Thus neither ODE transport nor stochastic diffusion requires a separate correction to restore total probability. Their density formulas describe how that conserved probability is redistributed.
The determinant converts an ODE's volume change into density change. For a \(C^1\) diffeomorphic flow \(\phi_t=\phi_{0\to t}\), write \(a\) for the initial position and \(x=\phi_t(a)\). If the initial law has density \(p_0\), change of variables gives
The determinant is a local volume multiplier, not a density. For example, \(\phi(a)=2a\) expands volume by \(2^D\), so \(p_{\mathrm{out}}(x)=2^{-D}p_0(x/2)\). Generating samples requires integrating the ODE, without evaluating this determinant.
Divergence is the instantaneous counterpart of accumulated volume change. For a sufficiently regular ODE field, divergence is the trace of the velocity Jacobian, whereas the volume multiplier is the determinant of the flow-map Jacobian:
Since \(\phi_0\) is the identity, the determinant's absolute value is the exponential of the time integral on the right. Where the transported density is positive and sufficiently regular, probability conservation therefore gives
Diffusion's probability-flow ODE uses this same density calculation. For this comparison, use the forward-noising time convention of Chapter 3. Consider \(dZ_t=f(Z_t,t)\,dt+g(t)\,dW_t\), where \(W_t\) is standard \(D\)-dimensional Brownian motion and \(g(t)\) is a scalar independent of state. Let \(p_t\) now denote this SDE's smooth positive marginal density, and \(s_t(x)=\nabla_x\log p_t(x)\) its score. The associated ODE is
With matching initial laws and sufficient regularity, well-posedness, and boundary or decay conditions ensuring uniqueness of the marginal evolution, this ODE shares the SDE's marginals \(p_t\). Along its trajectories,
This is an ODE density identity, not a pathwise identity along the noisy SDE. The score contributes to the velocity; it is neither a determinant nor a normalization factor. Score matching aims to recover the score needed for the intended distribution evolution, just as flow matching aims to recover an appropriate velocity field. An approximate field may still preserve total probability while producing the wrong distribution. Neither training objective alone guarantees well-posedness or exact distribution matching.
1.2 Density conservation (Eulerian view): the continuity equation¶
Switch from particles to distributions. Let \(\mu_t\) be the law of a random variable \(X_t\in\mathbb{R}^D\). If \(\mu_t\) admits a density \(p_t\) with respect to Lebesgue measure, we write \(\mu_t(dx)=p_t(x)\,dx\).
Lebesgue measure, probability, and density
Lebesgue measure is the usual notion of volume in \(\mathbb R^D\): length in one dimension, area in two, and volume in three. Write it as \(\lambda_D\). A probability measure \(\mu_t\) assigns probability to a region, whereas \(\lambda_D\) assigns its geometric volume. A density \(p_t\) connects them: for every measurable region \(A\subseteq\mathbb R^D\),
Thus \(dx\) denotes integration with respect to ordinary volume, and \(\mu_t(dx)=p_t(x)\,dx\) is shorthand for this integral relation. For example, the uniform distribution on \([0,2]\) has density \(1/2\) on that interval. The interval \([0,1]\) has length \(\lambda_1([0,1])=1\), but probability \(\mu([0,1])=1/2\). Volume and probability are different quantities.
The qualification “admits a density” matters. A probability law has a density with respect to \(\lambda_D\) precisely when it is absolutely continuous with respect to \(\lambda_D\): every set of zero volume must also have zero probability. A law concentrated on a circle in \(\mathbb R^2\) fails this condition, because the circle has zero area but probability one. The uniform law on that circle instead has density \(1/(2\pi r)\) with respect to arc length, where \(r>0\) is its radius. This distinction will matter when discussing distributions supported on lower-dimensional manifolds.
The probability conservation statement for transport by the vector field \(v_t\) is the continuity equation
For any fixed smooth bounded region \(A\subset\mathbb R^D\), the divergence theorem gives
Probability inside a fixed region can change through boundary flux. Total probability remains \(\int_{\mathbb R^D}p_t\,dx=1\), provided there is no flux loss at infinity; equivalently, a measurable sampling map preserves the total mass of its input law. The value of \(p_t(x)\) at a point need not remain constant, and probability conservation does not imply \(\nabla\cdot v_t=0\). For physical mass density the conserved total would be a mass \(M\), with physical units, rather than the dimensionless number 1.
Two equivalent “bookkeeping” forms (assuming enough smoothness) are useful:
1) Along trajectories (material derivative). If \(x(t)\) solves \(\dot x(t)=v(t,x(t))\), then
Here \(\partial_t p_t(x(t))\) means \(\left.\partial_t p_t(x)\right|_{x=x(t)}\): differentiate at fixed position, then evaluate on the trajectory. The total derivative also includes the change caused by the moving position. The first equality is the chain rule; the second follows by expanding \(\nabla\cdot(p_tv)=v\cdot\nabla p_t+p_t\nabla\cdot v\) in the continuity equation. Positive divergence means local volume expansion and decreasing density along the trajectory; negative divergence means compression and increasing density. This does not determine the sign of the density change at a fixed position.
2) Jacobian form (probability in a moving volume element). For a \(C^1\) diffeomorphic ODE flow, if the flow map \(\phi_{s\to t}\) is differentiable in \(a\) and \(J_{s\to t}(a):=\det(\nabla_a\phi_{s\to t}(a))\), then
This is the precise version of “mass in a moving infinitesimal volume element is conserved”.
Here \(\phi_{s\to t}\) denotes the flow map generated by \(v\) from time \(s\) to time \(t\).
Derivation: from local volume change to density change
Assume \(v\) is continuous in time and continuously differentiable in space, with a flow defined on the interval under consideration, and \(p_t(x)\) is a \(C^1\) solution of the continuity equation. Fix \(s\) and \(a\in\mathbb R^D\), and write
1. Differentiate the trajectory with respect to its starting position. The matrix \(F\) describes how nearby initial positions separate; its determinant is their local volume multiplier. Differentiating the flow ODE with respect to the initial position gives the variational equation
2. Convert the matrix change into a volume change. Since the flow is a diffeomorphism, \(F\) is invertible. Jacobi's determinant formula and the cyclic property of the trace give
Because \(J(s)=1\),
Thus divergence is the instantaneous relative rate of volume change, while \(J\) is the accumulated volume multiplier. Positivity explains why no absolute-value sign is needed here; a general change-of-variables formula uses \(|\det F|\).
3. Combine volume change with density change. To keep the calculation readable, write \(r(t):=p_t(x(t))\) for the density evaluated along this trajectory and \(b(t):=\nabla\cdot v(t,x(t))\) for its local divergence. The two evolution equations are
The product rule now shows the cancellation explicitly:
Evaluating the constant at \(t=s\) proves
Where the density is positive, the same calculation gives \(\frac{d}{dt}\log p_t(x(t))=-\nabla\cdot v(t,x(t))\), used for CNF likelihood evaluation in Chapter 2. Ordinary conditional flow-matching regression and ODE sampling do not require computing this divergence or determinant.
Remark: in measure-theoretic terms, transport by the flow map means \(\mu_t=(\phi_{s\to t})_\#\mu_s\). The PDE above is the density-level expression of this push-forward relation.
1.3 The manifold hypothesis (a precise formulation)¶
Let \(\mu_\text{data}\) be the data distribution on \(\mathbb{R}^D\) (a probability measure; it may or may not have a density).
An idealized, mathematically clean version of the manifold hypothesis is:
- There exists a \(d\)-dimensional embedded \(C^1\) submanifold \(\mathcal{M}\subset\mathbb{R}^D\) with \(d\ll D\) such that
A more realistic (noise-thickened) version is:
- There exists \(\sigma>0\) such that most mass lies in a tubular neighborhood of \(\mathcal{M}\):
for a small \(\varepsilon\in[0,1)\).
Important technical point: if \(\mathrm{supp}(\mu_\text{data})\subseteq\mathcal{M}\) with \(d<D\), then \(\mu_\text{data}\) is typically singular with respect to Lebesgue measure on \(\mathbb{R}^D\); in particular, an ambient-space density \(p_\text{data}(x)\) may not exist.
1.4 How flow models relate to (but do not equal) manifold learning¶
A (continuous-time) flow model in \(\mathbb{R}^D\) typically chooses a base distribution \(\mu_0\) (often \(\mathcal{N}(0,I)\)) and a diffeomorphic map \(\psi_{0\to 1}\) (generated by an ODE), then defines the model distribution by push-forward:
This connects to the manifold hypothesis in a specific way:
- A diffeomorphism \(\psi_{0\to 1}:\mathbb{R}^D\to\mathbb{R}^D\) maps absolutely continuous measures to absolutely continuous measures. Therefore, starting from \(\mu_0\) with a smooth, full-dimensional density (e.g., Gaussian), an invertible flow model cannot represent an exactly low-dimensional, manifold-supported \(\mu_\text{data}\) in the idealized sense above.
- What a flow can do is concentrate mass near low-dimensional structure (a thin neighborhood of \(\mathcal{M}\)) while remaining a full-dimensional density in \(\mathbb{R}^D\). This is a transport statement, not an explicit reconstruction of \(\mathcal{M}\) (no charts/atlas are learned).
Adding nondegenerate Gaussian noise gives intermediate laws smooth positive densities even when the data law is singular. This makes an intermediate score available, but it does not by itself guarantee a globally well-posed reverse process or regularity at a zero-noise endpoint.
1.4.1 How the manifold viewpoint helps, and what diffusion is actually doing¶
For structured data, a “manifold” is a modeling hypothesis that typical states concentrate near a set with fewer degrees of freedom than the ambient dimension \(D\). In an idealized form, one writes \(\mathrm{supp}(\mu_\text{data})\subseteq\mathcal{M}\) for a low-dimensional \(\mathcal{M}\subset\mathbb{R}^D\); in a realistic form, \(\mu_\text{data}\) concentrates in a small neighborhood of \(\mathcal{M}\).
The manifold viewpoint clarifies why diffusion adds noise. If data are extremely “thin” (close to a low-dimensional set), then objects like an ambient-space density \(p_\text{data}(x)\) or an ambient score \(\nabla_x\log p_\text{data}(x)\) may be ill-behaved or not even well-defined. Diffusion constructs a Gaussian-perturbation path (schematically \(x_t=\alpha(t)x_0+\sigma(t)\epsilon\)), which “thickens” the distribution so that for \(t>0\) the marginal \(p_t\) is typically a regular, full-dimensional density on \(\mathbb{R}^D\). The learned score/velocity field then tells you how to move samples from noise back toward the high-density region near the data, but it does not explicitly recover a geometric object \(\mathcal{M}\) (no charts, projections, or tangent structure are output).
1.4.2 Which models explicitly learn a low-dimensional representation?¶
Models are closer to “manifold learning” when they explicitly posit (and learn) a low-dimensional parameterization of data, i.e., a map \(g:\mathbb{R}^d\to\mathbb{R}^D\) with \(d\ll D\) such that typical data states satisfy \(x\approx g(z)\).
- Autoencoders (AE/DAE) and VAEs: learn an encoder/decoder pair and a low-dimensional latent \(z\). This makes the “data live near a low-dimensional set” idea explicit (though VAEs add stochasticity and optimize a likelihood bound rather than directly estimating \(\mathcal{M}\)).
- GANs / implicit generative models: a generator \(x=g_\theta(z)\) with \(z\in\mathbb{R}^d\) defines (in the idealized deterministic case) a distribution supported on a \(d\)-dimensional set \(\mathrm{Im}(g_\theta)\). This is geometrically close to learning a manifold-like image set, even if the learned set is only approximate and the notion of “manifold” may fail globally.
- Latent generative models (e.g., latent diffusion): learn a low-dimensional representation via an autoencoder, then run diffusion (or another density model) in latent space. This is often a practical middle ground: “manifold-like” structure is delegated to the autoencoder, while diffusion handles distribution modeling in the latent.
In particular, a VAE makes the low-dimensional structure explicit via a latent variable \(z\in\mathbb{R}^d\) (with \(d\ll D\)) and a decoder distribution \(p_\theta(x\mid z)\) on \(x\in\mathbb{R}^D\). With a prior \(p(z)\) (often \(\mathcal{N}(0,I_d)\)) and an encoder \(q_\phi(z\mid x)\), it is trained by maximizing the ELBO:
Geometrically, the mean decoder map \(g_\theta(z):=\mathbb{E}[x\mid z]\) can be viewed as a learned low-dimensional “surface”, while the decoder noise determines how thick the model distribution is around that surface; this is why VAEs feel “manifold-flavored” but are not necessarily learning a strict manifold-supported distribution in \(\mathbb{R}^D\).
These approaches make the low-dimensional structure explicit via \(z\mapsto x\). By contrast, standard diffusion/score/flow-matching methods are usually framed as learning dynamics in the ambient Euclidean space \(\mathbb{R}^D\) (or in a learned latent space), rather than directly estimating the manifold \(\mathcal{M}\) itself.
1.5 Bridge to the rest of the intro¶
We will reuse the same transport backbone:
- Choose a probability path \((\mu_t)_{t\in[0,1]}\) (or densities \((p_t)\) when they exist).
- Learn dynamics (ODE or SDE) that generate that path.
- Sample by numerically integrating the learned dynamics from the simple source toward data. Chapters 1–2 use \(t=0\) for the source and \(t=1\) for data. The diffusion formulas in Chapters 3–5 use the forward-diffusion convention \(t=0\) for data and \(t=1\) for noise, so generative sampling there runs backward. These clocks are related by \(t\mapsto1-t\).
Correction (2026-10-14). The previous bridge described all sampling as backward integration and Section 1.4 used the opposite endpoints from Chapter 2. The direction follows the chosen clock; an ODE sampler for the flow-matching convention below runs forward from noise to data.
Chapter 2 — Flow matching¶
Before introducing flow matching, distinguish the equations defining a CNF from the numerical work required to evaluate its trajectories and densities.
Consider a CNF defined by the ODE
Even when the solution is not available analytically, it always admits the integral form
which is what numerical ODE solvers approximate.
If the flow map \(\phi_t\) is a diffeomorphism and the density \(p_t\) exists, then along trajectories \(t\mapsto X_t\) the log-density obeys the instantaneous change-of-variables formula
hence
This provides a principled likelihood bookkeeping rule for CNFs, but it is often computationally heavy in high dimension because it couples an ODE solve with repeated divergence (trace) evaluations.
Flow matching constructs a probability path and a velocity target whose continuity equation yields that path. It then fits the field by regression on sampled states and conditional labels. The continuity equation justifies the construction; ordinary CFM does not solve a PDE or minimize its residual during training.
2.1 Constructing marginal densities and velocities from conditional paths¶
Let \(X_1\sim q(x_1)\) denote the (unknown) data distribution; we only have sample access to \(q\). We would like a probability path \((p_t)_{t\in[0,1]}\) such that \(p_0=p\) is simple (e.g., \(\mathcal{N}(0,I)\)) and \(p_1\approx q\), together with a vector field \(u_t\) that generates this path (so that \((p_t,u_t)\) satisfy the continuity equation).
Two distinct difficulties motivate the conditional construction: the computational cost of likelihood-based CNF training, and the lack of directly available marginal targets \(p_t\) and \(u_t\) for velocity regression.
-
CNF computation: expensive, not inherently “incalculable”. Given a sufficiently regular model velocity field, trajectories can be approximated by numerical ODE integration. Evaluating model log-densities additionally requires integrating the divergence along those trajectories, and likelihood-based training requires gradients of that computation. Repeated field evaluations and divergence calculations or estimates can make training expensive; the existence of these formulas does not make their evaluation cheap.
-
Marginal supervision: the target path and velocity are not directly given. The dataset supplies endpoint samples, not intermediate states paired with target velocities. Even after choosing a conditional path construction, the marginal density \(p_t(x)\) and velocity \(u_t(x)\) generally involve integrals over the unknown data distribution and are not available in closed form. Lack of a closed-form density does not imply that sampling is impossible: drawing a data sample and then a conditional intermediate state samples the marginal path without evaluating \(p_t\). The remaining obstacle to direct marginal velocity regression is evaluating \(u_t(x)\); conditional flow matching supplies computable conditional velocity labels instead.
A key idea in flow matching is to construct the marginal path and vector field by mixing conditional paths that are defined per data sample.
Theorem 1 (marginalizing conditional paths and vector fields). Fix a family of conditional probability paths \(\{p_t(\cdot\mid x_1)\}_{x_1}\) such that
- \(p_0(x\mid x_1)=p(x)\) for all \(x_1\), and
- \(p_1(x\mid x_1)\) is concentrated around \(x_1\) (e.g., \(p_1(x\mid x_1)=\mathcal{N}(x\mid x_1,\sigma^2 I)\) for a small \(\sigma>0\)).
Limiting case: a Dirac endpoint. The conditional endpoint can instead be specified as \(\mu_1(\cdot\mid x_1)=\delta_{x_1}\): given the data sample \(x_1\), the endpoint equals \(x_1\) with probability one. This is the weak limit of \(\mathcal N(x_1,\sigma^2I)\) as \(\sigma\to0\). For example, \(X_t=(1-t)Z+t x_1\), with \(Z\sim p\), gives \(X_1=x_1\). When \(x_1\) is drawn from the data distribution, mixing these point-mass endpoints recovers that distribution; the overall endpoint is not a single fixed point. A Dirac measure has no density with respect to ordinary spatial volume, so this is a limiting extension, not a literal substitution into the density formulas below at \(t=1\). The conditional map also loses invertibility at that endpoint. Keeping \(\sigma>0\) avoids this conditional endpoint collapse.
Define the marginal (mixture) path
In particular,
Assume \(p_t(x)>0\) for all \(t\in[0,1]\) and \(x\in\mathbb{R}^D\). Let \(u_t(x\mid x_1)\) be conditional vector fields that generate the conditional paths \(p_t(\cdot\mid x_1)\). Define the marginal vector field
At a fixed time and position, conditional paths that contribute more to the density there receive greater weight in this velocity average.
With sufficient integrability and regularity to interchange derivatives and the mixture integral, the pair \((p_t,u_t)\) satisfies the continuity equation. Specifically, this is the continuity equation introduced in Section 1.2, with \(v_t\) replaced by \(u_t\): \(\partial_t p_t(x)+\nabla_x\cdot(p_t(x)u_t(x))=0\), where \(p_t\) is defined by (5) and \(u_t\) by (7). Identifying this path with the law generated by the ODE additionally requires well-posed dynamics and uniqueness of the corresponding measure evolution. The continuity identity alone is not an ODE existence theorem.
Explanation (what this buys us). Theorem 1 gives a mathematically clean bridge between:
- a per-sample design \(\big(p_t(\cdot\mid x_1),u_t(\cdot\mid x_1)\big)\), where \(x_1\sim q\) is available from the dataset, and
- a global (marginal) density path \(p_t\) and its generator \(u_t\), which are guaranteed to be consistent through the continuity equation.
This resolves the practical bottleneck in the marginal formulation: we do not need closed-form access to \(p_t\) or \(u_t\). Instead, we can sample \(x_1\sim q\), sample \(x\sim p_t(\cdot\mid x_1)\), and compute \(u_t(x\mid x_1)\) to build a tractable training objective (developed next via conditional flow matching).
In words: since for each fixed \(x_1\) the conditional pair \(\big(p_t(\cdot\mid x_1),u_t(\cdot\mid x_1)\big)\) satisfies the conditional continuity equation, Theorem 1 shows that the induced marginal pair \((p_t,u_t)\) (via the mixture constructions (5)–(7)) satisfies the marginal continuity equation as well.
The proof of Theorem 1 can be found in the appendix of Flow Matching for Generative Modeling (see References). For an additional exposition, see introduction-B-flow-matching.
2.2 Conditional flow matching¶
Operationally, CFM makes training possible by working with per-sample training pairs: sample \(x_1\sim q\), sample \(x\sim p_t(\cdot\mid x_1)\), compute the conditional target \(u_t(x\mid x_1)\), and regress \(v(t,x;\theta)\) toward it.
The mixture constructions (5)–(7) show that a marginal path \(p_t\) and a marginal vector field \(u_t\) exist and satisfy the continuity equation. However, because \(q\) is only accessible through samples, the integrals in (5)–(7) are typically intractable.
- Sample access is not density access. We can obtain data samples \(X_1\sim q\), but cannot directly evaluate the unknown density \(q(x_1)\) at an arbitrary point.
- Sampling still permits Monte Carlo estimation. If the conditional density and velocity are evaluable, the integrals can be estimated by sample averages without evaluating \(q\). Thus “intractable” here does not mean that numerical estimation is impossible.
- The marginal velocity requires a ratio of expectations. Equation (7) divides \(\mathbb E_q[p_t(x\mid X_1)u_t(x\mid X_1)]\) by \(\mathbb E_q[p_t(x\mid X_1)]\). Estimating both for every training state can require many data samples, especially when only a few have appreciable conditional density at that state. Dividing finite-sample estimates generally introduces bias, even if each estimate is unbiased. CFM avoids constructing this ratio as a training label.
Consequently, simply substituting a Monte Carlo estimate of \(u_t(x)\) does not generally give an unbiased estimator of the marginal flow-matching regression loss
Instead, conditional flow matching replaces the marginal target \(u_t(x)\) by the per-sample conditional target \(u_t(x\mid x_1)\), yielding the CFM objective
This objective is tractable as long as we can (i) sample \(x\sim p_t(\cdot\mid x_1)\) and (ii) evaluate \(u_t(x\mid x_1)\), both of which can be arranged by design since they are defined on a per-sample basis.
Theorem 2 (FM and CFM are equivalent up to a constant). Assume \(p_t(x)>0\) for all \(x\in\mathbb{R}^D\) and \(t\in[0,1]\), that the constructions in (5)–(7) are well-defined, and that the conditional velocity target and model output have finite second moments under the sampling law in (9). Then
where \(C\) does not depend on \(\theta\). If the model is differentiable in \(\theta\) and differentiation can be interchanged with the expectations,
Explanation (why the gradients match). Intuitively, (7) says that the marginal target is a posterior average: \(u_t(x)=\mathbb{E}[u_t(x\mid X_1)\mid X_t=x]\). Expanding the square and applying the law of total expectation shows that the only difference between (8) and (9) is a conditional-variance term \(\mathbb{E}\big[\|u_t(X_t\mid X_1)\|^2-\|u_t(X_t)\|^2\big]\), which is independent of \(\theta\). Therefore, optimizing the tractable conditional objective (9) is equivalent (in expectation) to optimizing the intractable marginal objective (8).
The proof of Theorem 2 can be found in Flow Matching for Generative Modeling and in Flow Matching Guide and Code (see References). For an additional exposition, see introduction-B-flow-matching.
2.2.1 What the regression preserves, and what it changes¶
For independent \(Z\sim\mathcal N(0,I_D)\) and \(Y\sim\mu_{\mathrm{data}}\) with finite second moments, construct \(R_t=(1-t)Z+tY\) and the label \(U=Y-Z\). At each fixed interior time, squared regression selects
Why does averaging these labels preserve the chosen probability evolution? For any smooth compactly supported test function \(\varphi\), differentiating under the expectation gives
The last expression is the weak continuity equation for the law of \(R_t\). Under the transport well-posedness conditions above, integrating \(u_t\) reproduces these one-time laws. It need not reproduce the straight training paths or their noise–data endpoint assignments. Conditional paths can demand conflicting velocities at a common state and time; regression supplies their conditional mean rather than executing every assignment.
The population MSE optimum is unique almost everywhere under the fixed training law, not uniquely determined by the endpoint distributions alone. Different couplings or path designs can select different targets. Different finite training runs can also yield different approximations to the same target. Neither statement asserts optimal transport, which needs an additional cost criterion. The ideal interpolation at \(t=1\) may be singular, so a regular flow on the full closed interval is not automatic.
2.3 Conditional probability paths and vector fields¶
The CFM construction applies to conditional probability paths \(p_t(\cdot\mid x_1)\) and vector fields \(u_t(\cdot\mid x_1)\) that generate those paths, subject to the regularity and integrability conditions above. Practical training additionally requires sampling the conditional paths and evaluating their velocity labels. A particularly convenient family is given by Gaussian conditional paths, because both sampling and closed-form conditional targets can be obtained.
Gaussian conditional paths¶
Fix \(x_1\in\mathbb{R}^D\). Consider a conditional probability path of the form
where \(\mu:[0,1]\times\mathbb{R}^D\to\mathbb{R}^D\) is a time-dependent mean and \(\sigma:[0,1]\times\mathbb{R}^D\to\mathbb{R}_{>0}\) is a time-dependent scalar standard deviation. We typically set
so that \(p_0(x\mid x_1)=\mathcal{N}(0,I)=:p(x)\) for all \(x_1\), and
so that \(p_1(\cdot\mid x_1)\) is concentrated near \(x_1\) when \(\sigma_{\min}\) is small.
Two-endpoint conditioning (Tong et al.). Here only the target \(x_1\) is conditioned on; the source remains random. An alternative conditions on a pair \((x_0,x_1)\). Tong et al. construct, for constant \(\sigma>0\),
\[ \begin{aligned} p_t(x\mid x_0,x_1) &=\mathcal N\!\left(x;(1-t)x_0+tx_1,\sigma^2I\right),\\ u_t(x\mid x_0,x_1)&=x_1-x_0. \end{aligned} \]The conditional endpoints are small Gaussians centered at \(x_0\) and \(x_1\), rather than exact points; they converge to point masses as \(\sigma\to0\). Endpoint pairs may be sampled independently (I-CFM) or using a coupling obtained from minibatch optimal transport (OT-CFM). See Tong et al., Sections 3.2.2–3.2.3, equations (14)–(17).
Exact endpoint interpolation (Rectified Flow). Liu, Gong, and Liu construct \(X_t=(1-t)X_0+tX_1\) from an endpoint pair and regress the velocity toward \(X_1-X_0\). Once both endpoints are fixed, this training path is a deterministic straight line with those exact endpoints. The learned ODE generally induces a new endpoint coupling; it need not reproduce each original training pair. Thus conditioning on two endpoints does not itself establish a permanent one-to-one assignment between the source and target distributions. See Flow Straight and Fast: Learning to Generate and Transfer Data with Rectified Flow.
A canonical conditional flow (affine map)¶
Many vector fields can generate the same density path (e.g., one can add a component \(w_t\) such that \(\nabla\!\cdot(p_t w_t)=0\)), but for Gaussian paths it is natural to choose the simplest canonical transport: an affine map that turns standard Gaussian noise into the desired Gaussian.
Define the conditional (affine) flow map
If \(x_0\sim \mathcal{N}(0,I)\), then \(\psi_t(x_0;x_1)\sim \mathcal{N}(\mu_t(x_1),\sigma_t(x_1)^2 I)\). In push-forward notation,
This flow induces a conditional vector field \(u_t(\cdot\mid x_1)\) defined implicitly by
Reparameterizing \(x\sim p_t(\cdot\mid x_1)\) via \(x=\psi_t(x_0;x_1)\) with \(x_0\sim p(x_0)=\mathcal{N}(0,I)\), the CFM objective (9) can be written as
Theorem 3 (closed-form conditional vector field for Gaussian paths). Let \(p_t(x\mid x_1)\) be the Gaussian conditional path in (10) and \(\psi_t(\cdot;x_1)\) be the affine flow map in (11). Then the (unique) vector field that realizes (13) is
Consequently, \(u_t(\cdot\mid x_1)\) generates the Gaussian path \(p_t(\cdot\mid x_1)\) (equivalently, \((p_t(\cdot\mid x_1),u_t(\cdot\mid x_1))\) satisfy the conditional continuity equation).
Derivation (one line). Differentiate (11) in time: \(\frac{d}{dt}\psi_t(x_0;x_1)=\partial_t\sigma_t(x_1)\,x_0+\partial_t\mu_t(x_1)\). Since \(x=\psi_t(x_0;x_1)=\sigma_t(x_1)x_0+\mu_t(x_1)\), we have \(x_0=(x-\mu_t(x_1))/\sigma_t(x_1)\), which substituted back yields (15).
For the Gaussian conditional velocity construction, see Lipman et al., Section 4, Theorem 3; the VE/VP and OT-inspired examples below correspond to Section 4.1. Further exposition is available in Flow Matching Guide and Code.
2.4 Examples: special instances of Gaussian conditional probability paths¶
Within this isotropic Gaussian family, differentiable choices of \(\mu_t(x_1)\) and \(\sigma_t(x_1)\) give the conditional target in Theorem 3 wherever \(\sigma_t(x_1)>0\). Endpoint limits with zero standard deviation require separate treatment. Below are two illustrative design choices.
Example I: diffusion-inspired conditional paths (VE / VP)¶
Many diffusion models induce Gaussian conditionals \(p_t(x\mid x_1)\) at arbitrary times \(t\), with specific \(\mu_t(x_1)\) and \(\sigma_t(x_1)\). In the flow-matching setting, we can simply take these conditionals as a probability-path design choice and obtain a deterministic conditional vector field by plugging them into (15).
(a) Reversed VE (noise \(\to\) data). A variance-exploding (VE) conditional path can be written as
where \(\sigma_s\) is increasing with \(\sigma_0=0\) and \(\sigma_1\) large. Here \(t=1\) corresponds to a distribution concentrated at \(x_1\), while \(t=0\) is a very wide Gaussian (an approximation to “noise” in practice). In this case \(\mu_t(x_1)=x_1\) and \(\sigma_t(x_1)=\sigma_{1-t}\), so (15) gives
where \(\sigma'_s=\frac{d}{ds}\sigma_s\).
(b) Reversed VP (noise \(\to\) data). A variance-preserving (VP) conditional path can be written as
where
and \(\beta\) is a nonnegative noise-rate schedule. When \(T(1)\) is large, \(p_0(\cdot\mid x_1)\approx \mathcal{N}(0,I)\) and \(p_1(\cdot\mid x_1)\) concentrates at \(x_1\). Here \(\mu_t(x_1)=\alpha_{1-t}x_1\) and \(\sigma_t(x_1)=\sqrt{1-\alpha_{1-t}^2}\), and (15) yields
where \(\alpha'_s=\frac{d}{ds}\alpha_s\). The minus sign from the reversed clock is already included in (19); the affine conditional trajectory approaches \(x_1\) as \(t\to1\).
Remark: these diffusion-inspired paths are typically derived from stochastic diffusion processes and may only approach an idealized “pure noise” distribution asymptotically; in practice one works with a finite terminal time and an approximate Gaussian endpoint.
Example II: optimal-transport-inspired conditional paths (linear mean/std)¶
An arguably simpler design is to let the mean and standard deviation evolve linearly in time:
Plugging (20) into (15) gives the conditional vector field
The corresponding affine flow is
In this case the CFM loss (14) becomes
For a fixed sampled pair \(x_0,x_1\), the label in (23) is constant in time, so the conditional trajectory is straight. This simplifies label construction; it does not imply that the marginal velocity is constant or that learned generation trajectories are straight.
For practical experimental-design details (e.g., path/schedule choices, loss weighting, and numerical solvers), see introduction-B-flow-matching.
Summary: three choices of conditional training path¶
All three constructions below use the noise-to-data clock \(t\in[0,1]\). Fix a target \(x_1\) and one draw \(z\sim\mathcal N(0,I)\); keep that same \(z\) along the conditional trajectory \(x_t=\mu_t+\sigma_t z\). The label is \(U_t=\dot\mu_t+\dot\sigma_t z\). For the diffusion schedules, write \(s=1-t\); primes below denote derivatives with respect to \(s\), not \(t\).
| Quantity | Reversed VE | Reversed VP | OT-inspired linear mean/std |
|---|---|---|---|
| Conditional mean \(\mu_t\) | \(x_1\) | \(\alpha_s x_1\) | \(t x_1\) |
| Conditional standard deviation \(\sigma_t\) | \(\sigma_s\) | \(\sqrt{1-\alpha_s^2}\) | \(1-(1-\sigma_{\min})t\) |
| Sampled velocity label \(U_t\) | \(-\sigma'_s z\) | \(-\alpha'_s x_1+\dfrac{\alpha_s\alpha'_s}{\sqrt{1-\alpha_s^2}}z\) | \(x_1-(1-\sigma_{\min})z\) |
| Conditional start, \(t=0\) | \(\mathcal N(x_1,\sigma_1^2I)\); still depends on the target | \(\mathcal N(\alpha_1x_1,(1-\alpha_1^2)I)\); approximately standard normal when \(\alpha_1\) is small | Exactly \(\mathcal N(0,I)\), independent of the target |
| Conditional end, \(t=1\) | \(\delta_{x_1}\) if \(\sigma_0=0\) | \(\delta_{x_1}\) if \(\alpha_0=1\) | \(\mathcal N(x_1,\sigma_{\min}^2I)\) for \(\sigma_{\min}>0\); a point mass if \(\sigma_{\min}=0\) |
| What the design changes | Shrinks noise around a fixed target-centered mean | Moves the mean and shrinks the noise | Produces straight conditional trajectories with constant sampled velocity labels |
The VE and VP labels apply where their schedules are differentiable and the displayed denominators are nonzero; singular endpoints require limits or truncation. At finite noise time, replacing the VE or VP start by a simple target-independent Gaussian is an approximation. These rows describe training constructions, not three different neural-network architectures: each supplies intermediate states and labels for the same velocity-regression framework. Borrowing diffusion marginals does not add SDE noise to these conditional trajectories. Likewise, the OT-inspired conditional construction alone does not establish globally optimal transport or straight trajectories for the learned marginal ODE.
2.5 Practical notes (implementation “gotchas”)¶
This chapter intentionally focuses on the modeling algebra. In practice, a few design choices matter disproportionately:
- Endpoints and numerical stability. Many choices make \(u_t(x\mid x_1)\) contain factors like \(1/\sigma_t(x_1)\) or \(1/(1-\alpha_t^2)\); avoid singular endpoints by using \(\sigma_{\min}>0\), clipping \(t\) away from \(\{0,1\}\), or using a schedule that keeps denominators bounded.
- How to sample time \(t\). Uniform \(t\sim U[0,1]\) is the default in the theory, but non-uniform sampling or explicit weights \(w(t)\) in the regression loss can improve conditioning (e.g., not over-emphasizing near-singular regions).
- Parameterization of the learned field. Even when the target is a conditional vector field, different parameterizations of \(v(t,x;\theta)\) (predicting a velocity vs. predicting an equivalent noise-like quantity) can change optimization behavior while representing the same underlying solution.
- Choice of conditional path family. Diffusion-inspired and OT-inspired schedules change conditional flow geometry, regression conditioning, and the induced marginal trajectories. The affine conditional maps used here are deterministic once the endpoint and source sample are fixed. A Gaussian conditional density alone does not imply a noisy sample path, and straight conditional interpolants need not produce straight marginal ODE trajectories.
- Sampling solver and error. Training uses exact conditional targets, but generation still integrates an ODE induced by the learned \(v_\theta\); solver choice and step count (and whether to use adaptive stepping) can materially affect sample quality and speed.
For a more hands-on discussion of these choices (including code-level details), see introduction-B-flow-matching.
Chapter 3 — Diffusion models: a noising path and a learnable reverse process¶
In ODE-based flow models, the dynamics are deterministic: under standard regularity, the flow map is (locally) invertible and the Eulerian density evolution obeys the continuity equation. In diffusion models, the forward dynamics are stochastic (a Markov kernel rather than a bijection), so density evolution must account for diffusion and is governed by the Fokker–Planck equation.
The key design choice in diffusion models is to pick a probability path that connects data \(\mu_0=\mu_\text{data}\) to a simple distribution \(\mu_1\) (usually close to \(\mathcal{N}(0,I)\)), by injecting Gaussian noise according to a schedule. This makes intermediate marginals “thick” (typically admitting nice ambient-space densities), and it gives a principled way to define a reverse-time generative dynamics.
We present both the discrete-time (DDPM-style) and continuous-time (SDE-style) viewpoints. Detailed derivations about SDEs and the Fokker–Planck equation are collected separately in Mathematics Foundation.
3.1 Eulerian view: density evolution by Fokker–Planck¶
To mirror the Eulerian viewpoint of Section 1.2, we start from density evolution rather than from a discrete Markov chain.
Let \(t\in[0,1]\). Consider a forward Itô SDE
where \(W_t\) is standard \(D\)-dimensional Brownian motion and \(g(t)\) is a scalar depending only on time. If the time-\(t\) law \(\mu_t=\mathcal{L}(X_t)\) admits a density \(\mu_t(dx)=p_t(x)\,dx\), then \(p_t\) satisfies the Fokker–Planck equation
Continuity equation vs. Fokker–Planck equation
Using the same drift field \(f_t(x)=f(x,t)\), compare an ODE with an SDE that adds spatially uniform Brownian noise. Write \(p_t^{\mathrm{ODE}}\) and \(p_t^{\mathrm{SDE}}\) for their respective densities; these generally differ.
\[ \begin{aligned} \text{ODE (CE):}\qquad \partial_t p_t^{\mathrm{ODE}} &=-\nabla_x\cdot\bigl(p_t^{\mathrm{ODE}}f_t\bigr),\\[6pt] \text{SDE (FP):}\qquad \partial_t p_t^{\mathrm{SDE}} &=-\nabla_x\cdot\bigl(p_t^{\mathrm{SDE}}f_t\bigr) +\boxed{\tfrac12 g(t)^2\Delta_x p_t^{\mathrm{SDE}}}. \end{aligned} \]The transport term has the same form; the boxed term describes Brownian diffusion. Here \(g(t)\) is scalar and independent of position. Setting \(g=0\) removes the diffusion term and recovers the CE from Section 1.2, with \(v=f\). Matching the full probability paths additionally requires matching initial laws and uniqueness of the evolution.
The “schedule” viewpoint appears here as the choice of coefficients \((f,g)\), which determines the entire marginal path \((p_t)\). In diffusion modeling we choose \((f,g)\) so that \(p_1\) is simple (approximately \(\mathcal{N}(0,I)\)) and \(p_0\) matches the data distribution.
3.2 Reverse-time generation: score enters the dynamics¶
The key generative fact is that the reverse-time dynamics involve the score \(\nabla_x\log p_t(x)\). Informally, if we run time backward from \(t=1\) to \(t=0\), the reverse-time SDE has the form (here written for the common case where \(g(t)\) is a scalar diffusion coefficient, i.e., isotropic noise depending only on time)
where \(\bar W_t\) is a Brownian motion in reverse time. The reverse-time result originates in Anderson (1982); this score-based form and decreasing-time convention are presented in Song et al., Section 3.2, equation (6).
For background on SDEs, Itô interpretation, and the Fokker–Planck equation (including derivations), see Mathematics Foundation.
Under sufficient regularity, matching initial laws and uniqueness of the probability evolution, the exact score also defines a probability-flow ODE with the same one-time marginals \((p_t)\):
Once we can approximate the score, we can sample either by integrating the reverse SDE (stochastic sampler) or the probability flow ODE (deterministic sampler). See Song et al., Section 4.3 and Appendix D.1 for the probability-flow ODE and its derivation from the Fokker–Planck equation.
3.3 Learning the score from computable conditional labels¶
Sampling noisy inputs is only half the construction: we also need a label whose regression recovers the unknown marginal score. Let \(Y\sim\mu_{\mathrm{data}}\), \(\varepsilon\sim\mathcal N(0,I_D)\) independently, and for a fixed noising time set
A training example can therefore be constructed directly: draw a data sample \(Y\), a time \(t\) (for example, uniformly over a positive-noise interval), and independent noise \(\varepsilon\); compute \(X_t\) with the formula above; then use \((t,X_t)\) as input and \(\varepsilon\) as the noise-prediction label. This samples the conditional marginal at the chosen time without simulating the preceding SDE steps. The network does not receive the clean target \(Y\). The score identity below explains why this supervision is useful.
The Gaussian conditional density has a computable score:
At the sampled state this equals \(-\varepsilon/\sigma(t)\). Marginalizing the derivative of the Gaussian mixture, with justified differentiation under the integral, gives
Thus the population optimum of noise MSE is \(\varepsilon^*(x,t)=\mathbb E[\varepsilon\mid X_t=x]\), and scaling it by \(-1/\sigma(t)\) gives the score. No evaluation of the data density or the noisy marginal density is required. As in CFM, the computational simplification is regression on an accessible conditional label whose conditional mean is the desired marginal field. Finite models and optimization only approximate this ideal result. This conditional-label construction is the denoising score-matching principle of Vincent (2011), used for time-dependent perturbations in Song et al., Section 3.3.
3.4 Discrete-time DDPM as a practical discretization¶
After fixing the continuous-time (Eulerian) picture, we can introduce DDPM as a convenient discrete-time construction of the same “design a noising path, learn a reverse process” idea.
Fix an integer \(T\). The forward process is a Markov chain
where \(q(x_0)\) denotes the data density when it exists (otherwise use \(\mu_\text{data}(dx_0)\)) and
with noise schedule \(0<\beta_k<1\). Define \(\alpha_k:=1-\beta_k\) and \(\bar\alpha_k:=\prod_{s=1}^k \alpha_s\). Then
equivalently
Generation runs the chain backward, sampling \(p_\theta(x_{k-1}\mid x_k)\). A common parameterization predicts \(\varepsilon_\theta(x_k,k)\), which can be converted to an estimate \(\hat x_0(x_k,k)\) and hence to a reverse mean. The ELBO view and its reduction to a denoising regression loss are given in Chapter 4. The discrete forward kernel, direct noising formula, and noise-prediction parameterization follow Ho et al., Sections 2–3.
Chapter 4 — Diffusion dynamics and the DDPM variational objective¶
An SDE specifies stochastic sample dynamics, and its Fokker–Planck equation describes the resulting marginal laws. This relation follows from Itô calculus under the stated conditions, not from assuming that data obey fluid mechanics. DDPM uses a discrete noising chain and a variational objective to train reverse transition kernels.
4.1 From stochastic trajectories (Lagrangian) to Fokker–Planck (Eulerian)¶
Consider the forward SDE on \(\mathbb{R}^D\)
If the marginal law \(\mu_t=\mathcal{L}(X_t)\) admits a density \(p_t\) and regularity is sufficient, then \(p_t\) evolves by the Fokker–Planck equation
In other words, the SDE induces a deterministic evolution of marginal laws \((\mu_t)\) from the specified initial law, and Fokker–Planck is its Eulerian “mass conservation + diffusion” statement. (A step-by-step derivation is in Mathematics Foundation, Appendix B.)
Reverse-time generation is another stochastic flow. To move probability mass from a simple \(\mu_1\) back to \(\mu_0\), we run a reverse-time dynamics whose drift depends on the score \(\nabla_x\log p_t\). This is the origin of “learn the score/velocity field, then integrate backward”.
4.2 The VP diffusion as a canonical forward SDE (a continuous scheduler)¶
A widely used forward process is the variance-preserving (VP) SDE, parameterized by a scalar noise-rate schedule \(\beta(t)\ge 0\):
It is a linear SDE, and (conditionally on \(X_0=x_0\)) its marginal at any fixed time is Gaussian. The following is an equality in distribution at that time, not a construction of the whole SDE trajectory using one fixed noise draw:
for explicit \(\alpha(t)\in(0,1]\) and \(\sigma(t)\ge 0\) determined by \(\beta(t)\). One common convention is
so that \(X_t\mid X_0=x_0\sim \mathcal{N}(\alpha(t)x_0,\sigma(t)^2 I)\). This is the continuous-time analog of the discrete identity \(x_t=\sqrt{\bar\alpha_t}x_0+\sqrt{1-\bar\alpha_t}\varepsilon\) from Chapter 3.
4.3 DDPM as a time discretization of a stochastic flow¶
DDPM’s forward Markov chain
can be viewed as a time discretization of a VP-type SDE (with a suitable mapping between \(\{\beta_t\}\) and \(\beta(t)\)). From the flow viewpoint:
- the schedule \(\{\beta_t\}\) (or \(\beta(t)\)) specifies how the stochastic flow gradually destroys information,
- the model learns a reverse-time flow that restores structure from noise.
4.4 DDPM ELBO: fitting reverse transition kernels¶
Let the learned reverse process be
Using the conditional forward chain \(q(x_{1:T}\mid x_0)=\prod_{t=1}^T q(x_t\mid x_{t-1})\) as a variational distribution over latents \(x_{1:T}\), we get a variational lower bound:
After algebra, this ELBO decomposes into KL terms at each step:
Here \(q(x_{t-1}\mid x_t,x_0)\) is the true reverse posterior induced by the forward Gaussian chain; it has a closed-form Gaussian expression, so these KL terms are tractable once \(p_\theta(x_{t-1}\mid x_t)\) is Gaussian.
4.5 From Gaussian KL terms to weighted noise regression¶
In the common DDPM parameterization, one chooses \(p_\theta(x_{t-1}\mid x_t)\) to be Gaussian with a variance schedule fixed in advance, and a mean that is expressed via a network \(\varepsilon_\theta(x_t,t)\) (or equivalently \(x_{0,\theta}(x_t,t)\)). Under this choice, each intermediate reverse-transition KL term reduces (up to an additive constant and a time-dependent weight) to an \(\ell_2\) regression loss:
For the intermediate Gaussian KL terms, this is a weighted noise-regression objective. The terminal prior term and data reconstruction term remain separate. The frequently used unweighted noise MSE changes the time weighting and is generally not the exact ELBO. Matching these reverse transition distributions is distinct from the velocity regression called Flow Matching.
Remark: the exact weight \(w(t)\) depends on the schedule \(\beta_t\) and the variance parameterization in \(p_\theta(x_{t-1}\mid x_t)\); different “predict \(\varepsilon\)” vs “predict \(x_0\)” parameterizations correspond to the same ELBO written in different coordinates.
Chapter 5 — Training objectives and sampling dynamics¶
5.1 ODE and SDE describe different sampling processes¶
Fix the trained model and the numerical settings. A deterministic ODE sampler uses the random initial state as its random input. Under the existence and uniqueness conditions in Section 1.1, the continuous trajectory is then fixed. A stochastic sampler also uses subsequent random increments. This is a distinction between sampling processes, not an exclusive division between flow matching and diffusion training. A diffusion score model can supply both a reverse SDE and a probability-flow ODE.
Continuous invertibility concerns complete data states, not separate coordinates. It does not guarantee that discrete solver steps, floating-point rounding or a decoder are invertible.
5.2 Why different paths can have the same marginals¶
For the forward noising convention of Chapter 3, assume scalar state-independent \(g(t)\), a sufficiently smooth positive density \(p_t\), and define
Using \(p_t\nabla\log p_t=\nabla p_t\),
The right side is exactly the SDE's Fokker–Planck equation. With matching initial laws, well-defined processes and uniqueness of the probability evolution under appropriate boundary or decay conditions, the SDE and ODE share \(p_t\) at each time. They need not share sample trajectories, endpoint couplings or path-space laws. Generating from noise uses the corresponding backward-time dynamics. Simply removing the SDE noise while retaining its drift does not produce this equivalence.
Even within ODE models, the same density path need not specify one velocity. If \(u_t\) generates \(p_t\), a regular field \(w_t\) satisfying
leaves the continuity equation unchanged when we replace \(u_t\) by \(u_t+w_t\). For example, in two dimensions, a radial density \(p_t(x)=h_t(\|x\|)\) has \(\nabla\cdot(p_tJx)=0\), where \(Jx=(-x_2,x_1)\). Adding angular velocity can therefore change trajectories while preserving the density evolution. Appropriate existence, uniqueness and boundary conditions still apply. The ring experiment makes this distinction concrete.
5.3 Why the two regression constructions are related¶
Fix a differentiable Gaussian interpolation \(X_t=a_tY+b_t\varepsilon\), with independent data \(Y\) and standard Gaussian \(\varepsilon\). Work on an interval where \(a_t\ne0\), \(b_t>0\), and the relevant moments and derivatives exist. Holding the sampled pair fixed gives the conditional velocity label \(\dot a_tY+\dot b_t\varepsilon\). Its conditional mean is
Section 3.3 relates that noise predictor to the score. For the same path, ideal noise and velocity regression are thus related by an explicit transformation. Reverse conversion requires a nonzero coefficient of the conditional noise mean. This does not assert equality of arbitrary FM and diffusion objectives, nor identical finite-network optimization. Different path designs and time weights change the training problem.
Training equivalence and sampling equivalence are different claims: conditional expectation connects supervision targets; the continuity and Fokker–Planck equations connect marginal evolution.
5.4 Why a learned field still needs integration¶
An instantaneous velocity does not directly give a finite-time displacement:
The integrand depends on the evolving state. Even the exact scalar field \(v(t,x)=x\), with \(X_0=1\), gives \(X_1=e\), while one Euler step gives 2. Multiple steps approximate the accumulated changes in velocity; they are not needed to introduce extra randomness into an ODE.
A more accurate solver approximates the learned ODE more closely. If that field differs from the population target, the solver still integrates an imperfect model. Numerical integration error, field estimation error and final distribution mismatch are related but different quantities. A direct map or an interval-displacement predictor changes the learned object rather than making a generic instantaneous velocity an exact one-step sampler.
References¶
- Ricky T. Q. Chen, Yulia Rubanova, Jesse Bettencourt, David Duvenaud. Neural Ordinary Differential Equations. NeurIPS (2018). arXiv:1806.07366 (DOI:
https://doi.org/10.48550/arXiv.1806.07366).https://arxiv.org/abs/1806.07366 - Flow Matching (blog post). Cambridge Machine Learning Group (Jan 20, 2024).
https://mlg.eng.cam.ac.uk/blog/2024/01/20/flow-matching.html#mjx-eqn%3Aeq%3Ag2g - Yaron Lipman, Ricky T. Q. Chen, Heli Ben-Hamu, Maximilian Nickel, Matt Le. Flow Matching for Generative Modeling. arXiv:2210.02747 (DOI:
https://doi.org/10.48550/arXiv.2210.02747).https://arxiv.org/abs/2210.02747 - Lagrangian and Eulerian specification of the flow field. Wikipedia.
https://en.wikipedia.org/wiki/Lagrangian_and_Eulerian_specification_of_the_flow_field - Yaron Lipman, Marton Havasi, Peter Holderrieth, Neta Shaul, Matt Le, Brian Karrer, Ricky T. Q. Chen, David Lopez-Paz, Heli Ben-Hamu, Itai Gat. Flow Matching Guide and Code. arXiv:2412.06264 (DOI:
https://doi.org/10.48550/arXiv.2412.06264).https://arxiv.org/abs/2412.06264 - Jascha Sohl-Dickstein, Eric Weiss, Niru Maheswaranathan, Surya Ganguli. Deep Unsupervised Learning using Nonequilibrium Thermodynamics. ICML (2015). arXiv:1503.03585 (DOI:
https://doi.org/10.48550/arXiv.1503.03585).https://arxiv.org/abs/1503.03585 - Jonathan Ho, Ajay Jain, Pieter Abbeel. Denoising Diffusion Probabilistic Models. NeurIPS (2020). arXiv:2006.11239 (DOI:
https://doi.org/10.48550/arXiv.2006.11239).https://arxiv.org/abs/2006.11239 - Yang Song, Jascha Sohl-Dickstein, Diederik P. Kingma, Abhishek Kumar, Stefano Ermon, Ben Poole. Score-Based Generative Modeling through Stochastic Differential Equations. ICLR (2021). arXiv:2011.13456 (DOI:
https://doi.org/10.48550/arXiv.2011.13456).https://arxiv.org/abs/2011.13456 - CVPR 2026 Tutorial: Principles of Diffusion (website).
https://sites.google.com/view/cvpr26-principles-of-diffusion/home?authuser=0 - Alexander Tong et al. Improving and Generalizing Flow-Based Generative Models with Minibatch Optimal Transport. arXiv:2302.00482. Paper.
- Xingchao Liu, Chengyue Gong, Qiang Liu. Flow Straight and Fast: Learning to Generate and Transfer Data with Rectified Flow. arXiv:2209.03003. Paper.
- Brian D. O. Anderson. Reverse-time diffusion equation models. Stochastic Processes and their Applications, 12(3):313–326 (1982). Paper.
- Pascal Vincent. A Connection Between Score Matching and Denoising Autoencoders. Neural Computation, 23(7):1661–1674 (2011). Paper.