ai papers

Understanding Score-Based Generative Modeling Through Stochastic Differential Equations

Junyoung Park · 2023-04-22 · 16 min

Introduction

Today's paper formulates score-based generative modeling through continuous-time SDEs. Along with DDPM, the best-known diffusion approach, it is often called a foundational diffusion paper—though its difficulty hardly feels foundational. Unlike DDPM and DDIM, which rely on stepwise prediction, its sampler solves differential equations numerically. The paper's strength is that it unifies and varies many score-based approaches, enabling a discussion of more effective generative sampling.

The mathematics is much harder than DDPM, and stochastic differential equations feel more complex because the scope of a solution changes substantially with its constraints. Still, understanding this paper seems necessary to think beyond methods such as DDPM and DDIM that are confined to stepwise sampling.

Score based generative process

Suppose a dataset xXx \sim \mathcal{X} has marginal probability distribution p(X)p(\mathcal{\mathcal{X}}). To start from an easy-to-sample distribution zZz \sim \mathcal{Z} and create data x^q(X^Z)\hat{x} \sim q(\mathcal{\hat{X} \vert \mathcal{Z}}) resembling real observations, we must find the relationship between the two distributions. Deep generative modeling aims to solve this task with deep learning.

One representative method indirectly aligns an intractable probability distribution with the maximum lower bound on likelihood, the ELBO, as in a Variational Autoencoder.

A GAN (Generative Adversarial Network) improves sampling quality through adversarial training between a decoder that creates fake images from randomly sampled noise zz and an encoder that distinguishes real images.

Flow-based modeling instead defines an invertible relationship between distributions as a flow and uses it to connect latent and data distributions.

Unlike these models, a score-based model learns the direction—the gradient—from a given noise sample toward the real data distribution and defines a process that gradually produces data samples from noise.

What is score?

I briefly discussed the score in the DDPM post; to restate it, the score is the gradient of a probability density function. Given a distribution p(x)p(x) over the original data's continuous variables, the direction in which a noisy sample xtx_t at step tt should move to become plausible is the gradient of p(x)p(x). Connecting this to an energy-based approach lets us define the score as the gradient of log-likelihood.

xlogp(x)\nabla_x \log p(x)

Two generative models built from these ideas arrived with dramatic impact: SMLD (Score Matching with Langevin Dynamics) and DDPM (Denoising Diffusion Probabilistic Model). Once generalized, both reduce to the same differential equation with different coefficients, so they can be viewed as solving the same problem. The derivation later makes this explicit.

Score estimation = Solving SDE

How can the mechanism of diffusion models be connected to stochastic differential equations? Consider the figure above. In DDPM or SMLD, data becomes noise simply by adding very small amounts of diffusion. Conventionally this noise is added over discrete states (x0, x1, , xT)(x_0,~x_1,~\cdots,~x_T). If instead the distribution's gradual transformation into noise is defined over continuous time, it can be modeled as a solution to an Itô SDE.

This becomes clearer later when it is derived in relation to the DDPM and SMLD processes, so for now we can simply accept the idea.

dx=f(x, t)dt+g(t)dwdx = f(x,~t)dt + g(t)dw

A stochastic differential equation is one type of differential equation, so the problem is defined through relationships among rates of change (dx,dt,dw)(dx,dt,dw). A solution can be understood as the trajectory traced by those rates for x(t)x(t). An SDE differs in that it adds a stochastic term dwdw to the deterministic solution x(t)x(t), though we can ignore that detail for the moment.

dwdw is a diffusion term that depends only on time, independently of xx's actual trajectory, while dtdt defines the direction along that trajectory. The solution x(t)x(t) is therefore a function that returns the position x(t)x(t) at a given time tt, represented by the functional curve shown as the solid black line above.

Reversing the perspective, a trajectory depends on its direction. We can therefore define a new problem that predicts x(t)x(t) while traveling backward from xTx_T to x0x_0.

dx=(f(x, t)g2(t)xlogpt(x))dt+g(t)dwˉdx = \left(f(x,~t) -g^2(t)\mathbf{\nabla_x \log p_t(x)}\right) dt + g(t) d\bar{w}

In this expression, the diffusion term g(t)dwg(t)dw is identical to the forward SDE. The score term, highlighted in bold, changes the trajectory associated with the drift term dtdt from the forward direction to the reverse direction.

The forward SDE and reverse SDE have different starting and ending points but must trace the same trajectory. If the forward SDE—the trajectory's form—is known, it can provide the solution to the reverse SDE. Predicting the score is thus equivalent to solving the reverse SDE, which generalizes generation to any sampler implemented as an SDE solver. The paper introduces two types: a PC (Predictor–Corrector) sampler and a deterministic sampler. As their names suggest, the PC sampler uses a score-based model to improve sample quality, while the deterministic sampler removes all randomness to support fast sampling and latent manipulation.

Training and sampling with SMLD/DDPM

I have not properly defined SMLD: it is an NCSN (Noise Conditional Score Network). NCSN and DDPM are both score-based generative models, but their papers develop the SDE problem through different methods. Let us examine how SMLD and DDPM train their score estimators and perform sampling.

Denoising score matching with Langevin Dynamics(SMLD)

Suppose a perturbation kernel with variance σ2\sigma^2 is added to xx. This kernel follows noise distribution pσ(x~x):=N(x~;x,σ2I)p_\sigma(\tilde{x} \vert x):=\mathcal{N}(\tilde{x};x,\sigma^2I). Consider increasing noise scales σmin=σ1<σ2<<σN=σmax\sigma_{\min}=\sigma_1<\sigma_2<\cdots<\sigma_N=\sigma_{\max}. The smallest scale σmin\sigma_{\min} is small enough that pσmin(x)pdata(x)p_{\sigma_{\min}}(x)\approx p_\text{data}(x), while the largest σmax\sigma_{\max} is large enough that pσmax(x)N(x;0,σmax2I)p_{\sigma_{\max}}(x)\approx\mathcal{N}(x;0,\sigma_{\max}^2I).

Because the true distribution is intractable, denoising score matching cannot predict xlogpdata(x)\nabla_x\log p_\text{data}(x) directly. Instead, it predicts the conditional score of a noisy sample x~\tilde{x} with a very small amount of added noise, x~logpσi(x~x)\nabla_{\tilde{x}}\log p_{\sigma_i}(\tilde{x}\vert x), which approximates the target. Across many noise levels, from severe corruption down to data nearly identical to the original, score estimator sθ(x,σ)s_\theta(x,\sigma) has the following objective.

θ=argminθi=1Nσi2E_pdata(x)E_pσi(x~x)(sθ(x~,σi)x~logpσi(x~x)22)\theta^\ast = \underset{\theta}{\arg\min} \sum_{i=1}^N \sigma_i^2 \mathbb{E}\_{p_\text{data}(x)} \mathbb{E}\_{p_{\sigma_i}(\tilde{x} \vert x)} \left( \parallel s_\theta(\tilde{x}, \sigma_i) - \nabla_{\tilde{x}} \log p_{\sigma_i}(\tilde{x} \vert x) \parallel_2^2 \right)

With enough data and model capacity, a trained score-based model predicts the scores required for sampling. Sampling is somewhat complex, but because it uses annealed Langevin dynamics, it can be understood as a nested loop. The noise level decreases from NN to 11 across each σi\sigma_i, and MM Langevin MCMC steps run for every noise kernel—a total of N×MN\times M steps. For a distribution corrupted by noise level σi\sigma_i,

xim=xim1+ϵisθ(xim1,σi)+2ϵizimx_i^m = x_i^{m-1} + \epsilon_i s_{\theta^\ast}(x_i^{m-1}, \sigma_i) + \sqrt{2\epsilon_i}z_i^m

run the process above MM times with step size ϵi>0\epsilon_i>0, analogous to a gradient-ascent learning rate, and random standard-normal vector zimN(0,I)z_i^m\sim\mathcal{N}(0,I). After MM sampling steps, lower the noise to σi1\sigma_{i-1} and run another MM MCMC steps, initializing xi10=xiMx_{i-1}^0=x_i^M.

xi1m=xi1m1+ϵi1sθ(xi1m1,σi1)+2ϵi1zi1mx_{i-1}^m = x_{i-1}^{m-1} + \epsilon_{i-1} s_{\theta^\ast}(x_{i-1}^{m-1}, \sigma_{i-1}) + \sqrt{2\epsilon_{i-1}}z_{i-1}^m
for sigma in sigma_N, ..., sigma_1:
	for step in 1, ..., M:
		noise = N(0, I) # Random noise
		x = x + epsilon * model(x, sigma) + sqrt(2*epsilon)*noise

With a sufficiently large number of samples MM and a very small step size ϵ\epsilon, the generated sample x1Mx_1^M follows the original data distribution.

pσmin(x)pdata(x)p_{\sigma_{\min}}(x) \approx p_{\text{data}}(x)

Denoising diffusion probabilistic models(DDPM)

DDPM defines a variance schedule βi\beta_i whose noise scale increases step by step.

0<β1, β2, , βN<10 < \beta_1,~\beta_2,~\cdots,~\beta_N < 1

For each training data point (image) x0pdata(x)x_0\sim p_\text{data}(x), it defines a perturbation kernel under the variance schedule as the following Markov chain.

p(xixi1)=N(xi; 1βixi1, βiI)p(x_i \vert x_{i-1}) = \mathcal{N}(x_i;~\sqrt{1-\beta_i}x_{i-1},~\beta_i I)

Applying this across the full sequence yields the following marginal.

p(xix0)=N(xi;αˉix0, (1αˉ_i)I), αˉ_i:=_j=1i(1βj)p(x_i \vert x_0) = \mathcal{N}(x_i; \sqrt{\bar{\alpha}_i}x_0,~(1-\bar{\alpha}\_i)I),~\bar{\alpha}\_i := \prod\_{j=1}^i (1-\beta_j)

As in the SMLD example, this can also be expressed as a perturbed data distribution, where pαˉi(xˉx)p_{\bar{\alpha}_i}(\bar{x}\vert x) denotes the marginal obtained above.

pαˉ_t(x~)=pdata(x)pαˉi(x~x)dxp_{\bar{\alpha}\_t}(\tilde{x}) = \int p_\text{data}(x)p_{\bar{\alpha}_i}(\tilde{x} \vert x) dx

In DDPM, the variable's variance is fixed at 11 throughout noise addition, so xNN(0,I)x_N\sim\mathcal{N}(0,I). Although DDPM originally expresses the reverse process differently, its variational Markov chain can be written in score-matching form, like SMLD, as follows.

pθ(xi1xi)=N(xi1; 11βi(xi+βisθ(xi, i)),βiI)p_\theta (x_{i-1} \vert x_i) = \mathcal{N}(x_{i-1};~\frac{1}{\sqrt{1-\beta_i}}(x_i + \beta_i s_\theta(x_i,~i)), \beta_iI)

The evidence lower bound consequently has a different weighted sum. The expression below closely resembles the SMLD objective. Its coefficient 1αˉi1-\bar{\alpha}_i is the variance of the iith perturbation kernel pαˉi(x~x)p_{\bar{\alpha}_i}(\tilde{x}\vert x). In SMLD, too, the coefficient σi2\sigma_i^2 was the perturbation kernel's variance, revealing the common structure of the two equations.

More precisely, for noisy score estimate xlogp(x~x)\nabla_x\log p(\tilde{x}\vert x), it is proportional to 1/E[xlogp(x~x)22]1/\mathbb{E}\left[\parallel\nabla_x\log p(\tilde{x}\vert x)\parallel_2^2\right].

θ=argminθi=1N(1αˉ_i)E_pdata(x)E_pαˉ_i(x~x)(sθ(x~,i)x~logpαˉi(x~x)22)\theta^\ast = \underset{\theta}{\arg\min} \sum_{i=1}^N (1-\bar{\alpha}\_i) \mathbb{E}\_{p_\text{data}(x)} \mathbb{E}\_{p_{\bar{\alpha}\_i}(\tilde{x} \vert x)} \left( \parallel s_\theta(\tilde{x}, i) - \nabla_{\tilde{x}} \log p_{\bar{\alpha}_i}(\tilde{x} \vert x) \parallel_2^2 \right)

Given θ\theta^\ast that minimizes this loss, sampling proceeds backward through the Markov chain.

xi1=11βi(xi+βisθ(xi,i))+βizi, i=N, N1, , 1x_{i-1} = \frac{1}{\sqrt{1-\beta_i}} (x_i + \beta_i s_{\theta^\ast}(x_i, i)) + \sqrt{\beta_i}z_i,~i=N,~N-1,~\cdots,~1

The authors call this ancestral sampling, naming the gradual backward sampling through reverse process pθp_\theta. DDPM's original loss has a different structure, shown below, but the reformulation above demonstrates that DDPM is in fact training a score-estimation model.

E_x0,ϵ(βt22σt2αt(1αˉ_t)ϵϵθ(αˉ_tx0+1αˉ_tϵ,t)2)\mathbb{E}\_{x_0,\epsilon} \left( \frac{\beta_t^2}{2\sigma_t^2 \alpha_t(1-\bar{\alpha}\_t)} \parallel \epsilon - \epsilon_\theta(\sqrt{\bar{\alpha}\_t}x_0 + \sqrt{1-\bar{\alpha}\_t}\epsilon, t) \parallel^2\right)

The key point is that in both SMLD and DDPM, just as inference—the forward process—can be expressed as an SDE, the reverse process can likewise be expressed as solving an SDE through score matching.

Extending Diffusion Modeling

Existing methods can be summarized as applying perturbation kernels at several noise scales to the data. This paper seeks to generalize score-based generation from predetermined discrete noise scales to every continuous noise scale,

which amounts to solving the SDE as a continuous-variable equation, as illustrated below.

As stated earlier, both the forward and reverse diffusion processes can be expressed as SDEs.

Corrupting a Dataset Into Noise With a Differential Equation

At its most basic, diffusion modeling takes an arbitrary i.i.d. dataset x(0)p0x(0)\sim p_0 and uses a diffusion process indexed by a continuous or discrete time variable t[0,T]t\in[0,T] to create x(T)pTx(T)\sim p_T, which approaches Gaussian noise. As introduced above, the diffusion process that transforms data distribution p0p_0 into prior distribution pTp_T can be modeled as the solution to a stochastic differential equation.

dx=f(x, t)dt+g(t)dwdx = f(x,~t)dt + g(t) dw

ww is a standard Wiener process, also called Brownian motion. f(x,t)f(x,t) is the drift coefficient over x,tx,t, and g(t)g(t) is the diffusion coefficient. Assuming f(x,t)f(x,t) and g(t)g(t) are both Lipschitz in state and time—that their derivatives are bounded—the SDE has a unique strong solution under bounded rates of change (reference).

x, tf(x, t)ϵ1tg(t)ϵ2\begin{aligned} &\vert \nabla_{x,~t} f(x,~t) \vert \le \epsilon_1 \newline &\vert \nabla_{t} g(t) \vert \le \epsilon_2 \end{aligned}

Sampling by Solving the Differential Equation in Reverse

If the prior is known or predefined, we can sample x(T)pTx(T)\sim p_T. For example, defining the prior as a multivariate Gaussian lets us obtain xTx_T by Gaussian sampling. A derivation shows that the reverse of a diffusion SDE is itself an SDE, written as follows (reference).

dx=(f(x, t)g2(t)xlogpt(x))dt+g(t)dwˉdx = \left(f(x,~t) -g^2(t)\mathbf{\nabla_x \log p_t(x)}\right) dt + g(t) d\bar{w}

wˉ\bar{w} is merely different notation for the same Wiener process ww used in the forward process. Noise generation traces the differential equation's trajectory as tt increases in tiny increments; the reverse equation traces it as tt decreases in tiny increments. If the score of marginal distribution pt(x)p_t(x) is known, an arbitrary noise sample xTx_T can be transformed into x0x_0.

Predicting the Score to Solve the Reverse SDE

Sampling ultimately requires predicting the score. Since the score of the original data distribution's marginal is unavailable, we optimize time-dependent score-matching model sθ(x,t)s_\theta(x,t) with a loss like those of SMLD and DDPM. SMLD and DDPM compute over a discrete perturbation sequence of length NN; generalizing it to continuous variable tt gives

θ=argminθE_t(λ(t)E_x(0)E_x(t)x(0)(sθ(x(t),t)x(t)logp0t(x(t)x(0))22))\theta^\ast = \underset{\theta}{\arg\min} \mathbb{E}\_t\left(\lambda(t) \mathbb{E}\_{x(0)} \mathbb{E}\_{x(t) \vert x(0)} \left( \parallel s_\theta(x(t), t) - \nabla_{x(t)} \log p_{0t}(x(t) \vert x(0)) \parallel_2^2 \right)\right)

As noted earlier, choose λ(t)1/E[x(t)logp0t(x(t)x(0))22]\lambda(t)\propto1/\mathbb{E}\left[\parallel\nabla_{x(t)}\log p_{0t}(x(t)\vert x(0))\parallel_2^2\right]. The score-matching method need not be denoising score matching; alternatives such as sliced score matching or finite-difference score matching also work.

Extending VE and VP SDEs

The noise-perturbation schemes of SMLD and DDPM can be viewed as discretized SDEs. With NN noise scales, SMLD's Markov-chain forward process is

xi=xi1+σi2σi12zi1, i=1, , Nx_i = x_{i-1} + \sqrt{\sigma_i^2 - \sigma_{i-1}^2} z_{i-1},~i = 1,~\cdots,~N

As NN approaches infinity, the noise scale becomes a continuous-time function σ(t)\sigma(t), and standard Gaussian variable zi1z_{i-1} likewise becomes z(t)z(t). Replacing the Markov chain with continuous stochastic process x(t)x(t) gives

x(t+Δ)=x(t)+σ(t+Δ)2σ(t)2z(t)x(t+\Delta) = x(t) + \sqrt{\sigma(t+\Delta)^2 - \sigma(t)^2}z(t)

Assuming Δ\Delta is very small, a first-order Taylor approximation turns this into a differential equation—the ordinary Euler method.

dx=dσ2(t)dtdwdx = \sqrt{\frac{d\sigma^2(t)}{dt}} dw

Likewise, DDPM follows the forward process

xi=1βixi1+βizi1, i=1, , Nx_i = \sqrt{1-\beta_i} x_{i-1} + \sqrt{\beta_i}z_{i-1},~i=1,~\cdots,~N

so as NN approaches infinity,

x(t+Δ)=1β(t+Δ)Δx(t)+β(t+Δ)Δz(t)x(t+\Delta) = \sqrt{1-\beta(t+\Delta) \cdot \Delta}x(t) + \sqrt{\beta(t+\Delta)\cdot \Delta}z(t)

Here β\beta is the noise scheduled at each original Markov step, so the infinitesimal variance change is multiplied by Δ\Delta. Again applying the Euler method yields the differential equation

dx=12β(t)xdt+β(t)dwdx = -\frac{1}{2} \beta(t) x dt + \sqrt{\beta(t)} dw

The paper calls SMLD's differential equation a VE (Variance Exploding) SDE because variance continually increases, and DDPM's a VP (Variance Preserving) SDE because variance is preserved.

Because the coefficients have an affine form, the expression can be developed into a differential equation for variance, using the following equation.

dΣVP(t)dt=β(t)(IΣVP(t))\frac{d\Sigma_{\text{VP}}(t)}{dt} = \beta (t) (I - \Sigma_{\text{VP}}(t))

This derivation is possible because it assumes a Gaussian distribution rather than a nonlinear case. Solving the ODE gives the covariance function of x(t)x(t).

ΣVP(t)=I+exp(0tβ(s)ds)(ΣVP(0)I)\Sigma_\text{VP} (t) = I+\exp\left(\int_0^t -\beta(s) ds\right)(\Sigma_\text{VP}(0) - I)

This shows that variance ΣVP\Sigma_\text{VP} at every tt is bounded relative to ΣVP(0)\Sigma_\text{VP}(0). If ΣVP(0)=I\Sigma_\text{VP}(0)=I, as in DDPM, it remains II for all tt. The authors' new sub-VP SDE is

dx=12β(t)xdt+β(t)(1exp(20tβ(s)ds))dwdx = -\frac{1}{2} \beta(t) x dt + \sqrt{\beta(t) (1 - \exp\left(-2\int_0^t \beta(s) ds\right))}dw

Solving the covariance ODE in the same way gives the covariance of the new differential equation.

Σsub-VP(t)=I+exp(20tβ(s)ds)I+exp(0tβ(s)ds)(Σsub-VP(0)2I)\Sigma_\text{sub-VP}(t) = I+\exp\left(-2\int_0^t \beta(s) ds \right)I + \exp\left(-\int_0^t \beta(s) ds \right) (\Sigma_\text{sub-VP}(0)-2I)

The VP SDE can be viewed as an upper bound on the sub-VP SDE. Since a diffusion process may take any form dx=f(x, t)dt+g(t)dwdx=f(x,~t)dt+g(t)dw, approaching it as a continuous function rather than beginning with discrete diffusion enabled the authors to propose this SDE. Sub-VP reportedly performs well in some likelihood experiments.

Stochastic Differential Equations Used in the Paper

We have introduced three different SDEs. Their perturbation kernels can be written as Gaussian marginal distributions as follows.

p0t(x(t)x(0))={N(x(t);x(0),(σ2(t)σ2(0))I),(VE SDE)N(x(t);x(0)e120tβ(s)ds,IIe0tβ(s)ds),(VP SDE)N(x(t);x(0)e120tβ(s)ds,(1e0tβ(s)ds)2I),(sub-VP SDE)p_{0t}(x(t) \vert x(0)) = \begin{cases} \mathcal{N}(x(t); x(0), (\sigma^2(t)-\sigma^2(0))I),& \text{(VE SDE)} \newline \mathcal{N}(x(t);x(0)e^{-\frac{1}{2}\int_0^t \beta(s)ds}, I-Ie^{-\int_0^t \beta(s) ds}),&\text{(VP SDE)} \newline \mathcal{N}(x(t);x(0)e^{-\frac{1}{2}\int_0^t \beta(s)ds}, \left(1-e^{-\int_0^t \beta(s) ds}\right)^2I),&\text{(sub-VP SDE)} \end{cases}

The sub-VP derivation looks complicated, but it simply changes DDPM's original noise construction from

p(xix0)=N(xi;αˉix0, (1αˉi)I), αˉ_i:=_j=1i(1βj)p(x_i \vert x_0) = \mathcal{N}(x_i; \sqrt{\bar{\alpha}_i}x_0,~(1-\bar{\alpha}_i)I),~\bar{\alpha}\_i := \prod\_{j=1}^i (1-\beta_j)

to a form that squares the variance term:

p(xix0)=N(xi;αˉix0, (1αˉi)2I), αˉ_i:=_j=1i(1βj)p(x_i \vert x_0) = \mathcal{N}(x_i; \sqrt{\bar{\alpha}_i}x_0,~(1-\bar{\alpha}_i)^2I),~\bar{\alpha}\_i := \prod\_{j=1}^i (1-\beta_j)

Solving the reverse SDE

We have repeatedly established that if a score model gives sθ()s_\theta(\cdot) at every time point, the theory lets us construct the reverse SDE. Numerically solving that reverse SDE to find x0x_0 is sampling.

Solving an SDE numerically amounts to predicting the form—the trajectory—of its solution function. Methods include Euler–Maruyama and stochastic Runge–Kutta, among others, though I do not know their details. The important point is that given a score predictor, any SDE solver can generate samples.

Ancestral sampling in DDPM is a special case and cannot be applied when the SDE changes even slightly, making it difficult to generalize. To relax this limitation, the authors propose the reverse-diffusion sampler below, which reportedly performs slightly better than ordinary ancestral sampling in SMLD and DDPM.

xi=xi+1fi+1(xi+1)+Gi+1Gi+1sθ(xi+1,i+1)+Gi+1zi+1x_i = x_{i+1} - f_{i+1}(x_{i+1}) + G_{i+1}G_{i+1}^\top s_{\theta^\ast}(x_{i+1}, i+1) + G_{i+1}z_{i+1}

Defining an infinitesimal time change Δ\Delta ever closer to zero should reduce the gap between ancestral sampling and the true SDE solution. The original ancestral sampler seems weaker because it depends on pθ(xixi+1)p_\theta(x_i\vert x_{i+1}) without accounting for the SDE's original form.

Predictor-corrector samplers

Ordinarily, solving an SDE performs only score prediction. Predictor–Corrector sampling adds an MCMC approach, namely Langevin dynamics. After the numerical SDE predicts the solution at the next time step, correction sampling adjusts that point using the score estimate. The numerical SDE solver acts as the predictor, and the score model acts as the corrector.

For both SMLD and DDPM, combining Predictor and Corrector substantially improves sampling efficiency over using either one alone.

Probability flow and Neural ODE

A score-based model lets us solve the SDE numerically. In fact, every diffusion process has an ODE with the same marginal likelihood p(x0:T)p(x_{0:T}). If the original diffusion SDE is

dx=f(x,t)dt+g(t)dwdx = f(x, t)dt + g(t)dw

then the ODE with the same marginal likelihood is

dx=(f(x,t)12g(t)2xlogpθ(x))dtdx = \left( f(x, t) - \frac{1}{2}g(t)^2 \nabla_x \log p_\theta(x) \right) dt

as shown above. The proof is too complicated for me to understand yet. In any case, define f~(x,t)=f(x,t)12g(t)2xlogpθ(x)\tilde{f}(x,t)=f(x,t)-\frac{1}{2}g(t)^2\nabla_x\log p_\theta(x). The ODE with Wiener-process term dwdw removed,

dx=f~(x,t)dtdx = \tilde{f}(x, t)dt

has the same marginal likelihood as the original SDE, meaning that sampling yields the same result. Rather than forcing an approximation of discrete likelihood as DDPM does below,

pθ(x0x1)=i=1Dδ(x0i)δ+(x0i)N(x;μθi(x1,1),σ12)dxp_\theta(x_0 \vert x_1) = \prod_{i=1}^D \int_{\delta_{-}(x_0^i)}^{\delta_+(x_0^i)} \mathcal{N}(x; \mu_\theta^i (x_1, 1), \sigma_1^2) dx δ+(x)={,if x=1x+1255,if x<1,  δ(x)={,if x=1x1255,if x>1\delta_+(x) = \begin{cases} \infty,&\text{if }x=1 \newline x+\frac{1}{255},&\text{if }x<1 \end{cases},~~\delta_-(x) = \begin{cases} -\infty,&\text{if }x=-1 \newline x-\frac{1}{255},&\text{if }x>-1 \end{cases}

we can calculate the actual likelihood.

logp0(x(t))=logpT(x(T))+0Tf~θ(x(t),t)dt\log p_0(x(t)) = \log p_T(x(T)) + \int_0^T \nabla \cdot \tilde{f}_\theta(x(t),t)dt

Because an ODE can ignore the random term dwdw entirely, it has the advantage of a one-to-one mapping between a specific data point x(0)x(0) and its endpoint x(T)x(T) along the path. This resembles an invertible flow-based model or neural ODE, making image editing and interpolation easy through latent representations. Each image maps to a unique latent, so the forward SDE can also be viewed as an encoder; the forward process is in fact independent of parameter learning.

Finally, removing stochasticity makes sampling with a neural ODE fast.

Conditional sampling

Another benefit of solving the continuous SDE is that it can generate not only unconditional samples but also samples from conditional probability p0(x(0)y)p_0(x(0)\vert y). This requires class probability pt(yx(t))p_t(y\vert x(t)) at each time step.

dx=(f(x,t)g(t)2(xlogpt(x)+xlogpt(yx)))dt+g(t)dwˉdx = \left( f(x, t) - g(t)^2(\nabla_x \log p_t (x) + \nabla_x \log p_t(y \vert x)) \right)dt + g(t)d\bar{w}

The class-conditional probability is learned by training an encoder under supervised learning on noisy samples, just as in the class-guidance paper Diffusion Beats GANs. The remaining methods appear in the appendix; I did not think they needed a detailed discussion here.