CSE-41XX
Course Curriculum

6. Langevin Dynamics, Score-Based SDEs & Generative Diffusion

A comprehensive statistical mechanics and stochastic calculus treatment of Brownian motion, the Fluctuation-Dissipation Theorem, Fokker-Planck evolution, DDPM, Score-SDEs, and Discrete Language Diffusion (SEDD, LLaDA).

Generative modeling in modern machine learning represents a profound computational realization of non-equilibrium statistical mechanics. At its core, the problem of generative modeling asks: How can we transform an uninformative, high-entropy prior distribution (such as isotropic Gaussian noise or a sequence of mask tokens) into a highly structured, low-entropy data distribution (such as natural images, protein conformations, or coherent text)?

In classical physics, this problem is mirrored by the study of thermal relaxation, Brownian motion, and time-reversal symmetry in stochastic systems. In this chapter, we develop the complete mathematical continuum that connects the 1905 Einstein-Langevin theory of Brownian motion to continuous-time score-based Stochastic Differential Equations (Score-SDEs), Denoising Diffusion Probabilistic Models (DDPM), and modern Discrete Diffusion Large Language Models (SEDD, LLaDA).


The Physical Paradigm of Generative Modeling

Before diving into formal stochastic calculus, let us construct the conceptual dictionary bridging Classical Statistical Mechanics and Modern Deep Generative Diffusion.

Statistical Mechanics ConceptMathematical SymbolMachine Learning / Diffusion Concept
Microstate ConfigurationxRdx \in \mathbb{R}^d (or xVNx \in \mathcal{V}^N)Data sample (image pixels, latent vector, token sequence)
Energy FunctionE(x)E(x)Negative unnormalized log-likelihood logp~(x)-\log \tilde{p}(x)
Boltzmann / Gibbs Distributionp(x)=1ZeE(x)/Tp_\infty(x) = \frac{1}{Z} e^{-E(x)/T}Target data density pdata(x)p_{\mathrm{data}}(x)
Thermal Heat Bath Fluctuationsη(t)N(0,2γkBTI)\eta(t) \sim \mathcal{N}(0, 2\gamma k_B T \mathbf{I})Gaussian noise injection / Brownian motion dWtdW_t
Friction / Dissipationγx˙\gamma \dot{x}Drift coefficient / deterministic decay towards prior
Thermodynamic ForceE(x)-\nabla E(x)Stein Score Function xlogpt(x)\nabla_x \log p_t(x)
Thermalization Timett \to \inftyForward diffusion horizon TT (pure isotropic noise)
Time-Reversal (Maxwell's Demon)Time-reversed drift fg2logpf - g^2 \nabla \log pLearned neural denoiser / score network sθ(x,t)s_\theta(x, t)
Entropy ProductionΔStot=DKL(qp)0\Delta S_{\mathrm{tot}} = D_{\mathrm{KL}}(q \,\Vert \, p) \ge 0Variational Loss / Evidence Lower Bound (ELBO) gap

Microscopic Foundations: Brownian Motion & The Classical Langevin Equation

Physical Setup: Pollen Grains and Thermal Solvent

Consider a macroscopic or mesoscopic particle of mass mm and position x(t)Rdx(t) \in \mathbb{R}^d suspended in a fluid solvent at absolute temperature TT. The solvent consists of an astronomical number of fluid molecules (N1023N \sim 10^{23}) undergoing rapid, chaotic thermal motion.

The microscopic collisions exerted by the fluid on the particle can be partitioned into two distinct physical effects across timescales:

  1. Macroscopic Systematic Friction (Dissipation): A mean drag force opposing the velocity x˙(t)=v(t)\dot{x}(t) = v(t), modeled via Stokes' drag law as γv(t)-\gamma v(t), where γ>0\gamma > 0 is the friction coefficient.
  2. Microscopic Random Kicks (Fluctuation): A rapidly fluctuating stochastic force η(t)\eta(t) arising from individual, instantaneous molecular collisions.

Newton's second law yields the Classical Langevin Equation (Paul Langevin, 1908):

md2x(t)dt2=γdx(t)dt+η(t)m \frac{d^2 x(t)}{dt^2} = -\gamma \frac{dx(t)}{dt} + \eta(t)

Equivalently, writing in terms of velocity v(t)=x˙(t)v(t) = \dot{x}(t):

mdv(t)dt=γv(t)+η(t)m \frac{dv(t)}{dt} = -\gamma v(t) + \eta(t)

Statistical Properties of Thermal White Noise

Because molecular collisions occur on a picosecond timescale (τc1013 s\tau_c \sim 10^{-13}\text{ s}), vastly faster than the relaxation timescale of the mesoscopic particle (τr=m/γ107 s\tau_r = m/\gamma \sim 10^{-7}\text{ s}), we model η(t)\eta(t) as a stationary, Gaussian white noise stochastic process:

  1. Zero Mean: E[η(t)]=0\mathbb{E}[\eta(t)] = 0
  2. Delta-Correlated in Time (Markovian Memoryless Limit): E[η(t)η(t)T]=2Dvδ(tt)Id\mathbb{E}\left[\eta(t) \eta(t')^T\right] = 2 D_v \delta(t - t') \mathbf{I}_d where DvD_v is the diffusion constant in velocity space, δ()\delta(\cdot) is the Dirac delta distribution, and Id\mathbf{I}_d is the dd-dimensional identity matrix.

Exact Solution for the Velocity Process

Dividing by mass mm, we obtain the linear stochastic differential equation:

dv(t)dt+γmv(t)=1mη(t)\frac{dv(t)}{dt} + \frac{\gamma}{m} v(t) = \frac{1}{m} \eta(t)

Using the integrating factor eγmte^{\frac{\gamma}{m} t}, we multiply both sides:

ddt[v(t)eγmt]=1mη(t)eγmt\frac{d}{dt}\left[ v(t) e^{\frac{\gamma}{m} t} \right] = \frac{1}{m} \eta(t) e^{\frac{\gamma}{m} t}

Integrating from 00 to tt:

v(t)=v(0)eγmt+1m0teγm(ts)η(s)dsv(t) = v(0) e^{-\frac{\gamma}{m} t} + \frac{1}{m} \int_0^t e^{-\frac{\gamma}{m}(t - s)} \eta(s) \, ds

Taking the expectation conditioned on the initial velocity v(0)v(0):

E[v(t)]=v(0)eγmt\mathbb{E}[v(t)] = v(0) e^{-\frac{\gamma}{m} t}

Thus, the mean velocity decays exponentially to zero on the characteristic relaxation timescale τr=m/γ\tau_r = m/\gamma.

Velocity Autocorrelation Function (VACF)

Let us compute the two-time velocity correlation function E[v(t)v(t)]\mathbb{E}[v(t) v(t')] for ttt' \ge t:

E[v(t)v(t)]=E[(v(0)eγmt+1m0teγm(ts)η(s)ds)(v(0)eγmt+1m0teγm(ts)η(s)ds)]=v(0)2eγm(t+t)+1m20tds0tdseγm(ts)eγm(ts)E[η(s)η(s)]\begin{aligned} \mathbb{E}[v(t) v(t')] &= \mathbb{E}\left[ \left( v(0) e^{-\frac{\gamma}{m} t} + \frac{1}{m} \int_0^t e^{-\frac{\gamma}{m}(t - s)} \eta(s) ds \right) \left( v(0) e^{-\frac{\gamma}{m} t'} + \frac{1}{m} \int_0^{t'} e^{-\frac{\gamma}{m}(t' - s')} \eta(s') ds' \right) \right] \\ &= v(0)^2 e^{-\frac{\gamma}{m}(t + t')} + \frac{1}{m^2} \int_0^t ds \int_0^{t'} ds' e^{-\frac{\gamma}{m}(t - s)} e^{-\frac{\gamma}{m}(t' - s')} \mathbb{E}[\eta(s) \eta(s')] \end{aligned}

Substituting E[η(s)η(s)]=2Dvδ(ss)\mathbb{E}[\eta(s) \eta(s')] = 2 D_v \delta(s - s'):

E[v(t)v(t)]=v(0)2eγm(t+t)+2Dvm2eγm(t+t)0min(t,t)e2γmsds=v(0)2eγm(t+t)+2Dvm2eγm(t+t)[m2γ(e2γmt1)]=v(0)2eγm(t+t)+Dvγm(eγm(tt)eγm(t+t))\begin{aligned} \mathbb{E}[v(t) v(t')] &= v(0)^2 e^{-\frac{\gamma}{m}(t + t')} + \frac{2 D_v}{m^2} e^{-\frac{\gamma}{m}(t + t')} \int_0^{\min(t, t')} e^{\frac{2\gamma}{m} s} \, ds \\ &= v(0)^2 e^{-\frac{\gamma}{m}(t + t')} + \frac{2 D_v}{m^2} e^{-\frac{\gamma}{m}(t + t')} \left[ \frac{m}{2\gamma} \left( e^{\frac{2\gamma}{m} t} - 1 \right) \right] \\ &= v(0)^2 e^{-\frac{\gamma}{m}(t + t')} + \frac{D_v}{\gamma m} \left( e^{-\frac{\gamma}{m}(t' - t)} - e^{-\frac{\gamma}{m}(t + t')} \right) \end{aligned}

In the stationary equilibrium limit (t,tt, t' \to \infty with fixed time separation τ=tt0\tau = t' - t \ge 0):

limtE[v(t)v(t+τ)]=Dvγmeγmτ\lim_{t \to \infty} \mathbb{E}[v(t) v(t + \tau)] = \frac{D_v}{\gamma m} e^{-\frac{\gamma}{m} \tau}

The Fluctuation-Dissipation Theorem (FDT)

In thermal equilibrium at temperature TT, the Equipartition Theorem of classical statistical mechanics requires that each translational degree of freedom possesses an average kinetic energy of 12kBT\frac{1}{2} k_B T:

limt12mE[v(t)2]=12kBT    limtE[v(t)2]=kBTm\lim_{t \to \infty} \frac{1}{2} m \mathbb{E}[v(t)^2] = \frac{1}{2} k_B T \implies \lim_{t \to \infty} \mathbb{E}[v(t)^2] = \frac{k_B T}{m}

Comparing this with our Langevin derivation at τ=0\tau = 0:

limtE[v(t)2]=Dvγm=kBTm    Dv=γkBT\lim_{t \to \infty} \mathbb{E}[v(t)^2] = \frac{D_v}{\gamma m} = \frac{k_B T}{m} \implies D_v = \gamma k_B T

This is the celebrated Einstein Fluctuation-Dissipation Theorem (FDT) (1905).

The Fluctuation-Dissipation Theorem:

The noise covariance amplitude 2Dv2D_v (fluctuation) and the drag coefficient γ\gamma (dissipation) are inextricably tied by the thermal energy scale kBTk_B T:

E[η(t)η(t)T]=2γkBTδ(tt)I\mathbb{E}\left[\eta(t) \eta(t')^T\right] = 2 \gamma k_B T \delta(t - t') \mathbf{I}

You cannot have friction without thermal noise, nor thermal noise without friction; both arise from the exact same microscopic collisions with the heat bath.

Position Diffusion & The Green-Kubo Relation

Integrating velocity to obtain the position trajectory x(t)=x(0)+0tv(s)dsx(t) = x(0) + \int_0^t v(s) ds, the Mean Squared Displacement (MSD) is:

E[(x(t)x(0))2]=0tds10tds2E[v(s1)v(s2)]\mathbb{E}\left[ (x(t) - x(0))^2 \right] = \int_0^t ds_1 \int_0^t ds_2 \, \mathbb{E}[v(s_1) v(s_2)]

Substituting the stationary autocorrelation E[v(s1)v(s2)]=kBTmeγms1s2\mathbb{E}[v(s_1) v(s_2)] = \frac{k_B T}{m} e^{-\frac{\gamma}{m}|s_1 - s_2|}:

E[(x(t)x(0))2]=2kBTγ[tmγ(1eγmt)]\mathbb{E}\left[ (x(t) - x(0))^2 \right] = \frac{2 k_B T}{\gamma} \left[ t - \frac{m}{\gamma}\left( 1 - e^{-\frac{\gamma}{m} t} \right) \right]

Examining the two asymptotic physical regimes:

  1. Short-time Ballistic Regime (tτr=m/γt \ll \tau_r = m/\gamma): Expanding the exponential eγmt1γmt+12(γmt)2e^{-\frac{\gamma}{m} t} \approx 1 - \frac{\gamma}{m} t + \frac{1}{2}\left(\frac{\gamma}{m} t\right)^2:

    E[(x(t)x(0))2]kBTmt2=v2eqt2\mathbb{E}\left[ (x(t) - x(0))^2 \right] \approx \frac{k_B T}{m} t^2 = \langle v^2 \rangle_{\mathrm{eq}} t^2

    The particle moves deterministically with its thermal initial velocity (ballistic motion).

  2. Long-time Diffusive Regime (tτr=m/γt \gg \tau_r = m/\gamma): The exponential vanishes, leaving:

    E[(x(t)x(0))2]2kBTγt=2Dt\mathbb{E}\left[ (x(t) - x(0))^2 \right] \approx \frac{2 k_B T}{\gamma} t = 2 D t

    where DD is the spatial diffusion constant given by the Stokes-Einstein Relation:

    D=kBTγD = \frac{k_B T}{\gamma}

Furthermore, taking the long-time limit yields the fundamental Green-Kubo Formula:

D=0v(0)v(t)eqdtD = \int_0^\infty \langle v(0) v(t) \rangle_{\mathrm{eq}} \, dt

Overdamped Langevin Dynamics & The Fokker-Planck Equation

The High-Friction (Overdamped) Limit

In molecular dynamics, biological fluids, and machine learning optimization, the relaxation time τr=m/γ\tau_r = m/\gamma is negligibly small compared to observation timescales. Setting mdvdt0m \frac{dv}{dt} \to 0 in the full Langevin equation with an external potential energy landscape E(x)E(x):

0=γdxdtE(x)+η(t)0 = -\gamma \frac{dx}{dt} - \nabla E(x) + \eta(t)

Rearranging and defining mobility μ=1/γ\mu = 1/\gamma:

dxdt=μE(x)+μη(t)\frac{dx}{dt} = -\mu \nabla E(x) + \mu \eta(t)

In standard stochastic calculus notation, setting units such that mobility μ=1\mu = 1 and thermal noise intensity 2kBT=2T2 k_B T = 2T, we obtain the Overdamped Langevin Stochastic Differential Equation (SDE):

dxt=E(xt)dt+2TdWtdx_t = -\nabla E(x_t) dt + \sqrt{2T} \, dW_t

where WtW_t is standard dd-dimensional Brownian motion (Wiener process) satisfying E[dWt]=0\mathbb{E}[dW_t] = 0 and E[dWtdWtT]=Idt\mathbb{E}[dW_t dW_t^T] = \mathbf{I} dt.

Overdamped Langevin Dynamics on Multimodal Potential

Derivation of the Fokker-Planck Equation

Let p(x,t)p(x, t) denote the probability density of finding the particle at position xx at time tt. To derive the deterministic PDE governing the time evolution of p(x,t)p(x, t), let g(x):RdRg(x): \mathbb{R}^d \to \mathbb{R} be an arbitrary smooth, compactly supported test function.

By Itô's Lemma, the differential of g(xt)g(x_t) along the trajectory of dxt=E(xt)dt+2TdWtdx_t = -\nabla E(x_t) dt + \sqrt{2T} dW_t is:

dg(xt)=g(xt)Tdxt+12Tr(2g(xt)(dxt)(dxt)T)dg(x_t) = \nabla g(x_t)^T dx_t + \frac{1}{2} \operatorname{Tr}\left( \nabla^2 g(x_t) (dx_t)(dx_t)^T \right)

Since (dWt)(dWt)T=Idt(dW_t)(dW_t)^T = \mathbf{I} dt and dtdWt=0dt \cdot dW_t = 0:

dg(xt)=(g(xt)TE(xt)+TΔg(xt))dt+2Tg(xt)TdWtdg(x_t) = \left( -\nabla g(x_t)^T \nabla E(x_t) + T \Delta g(x_t) \right) dt + \sqrt{2T} \nabla g(x_t)^T dW_t

Taking the expectation E[]\mathbb{E}[\cdot] over all stochastic paths:

ddtE[g(xt)]=Rdg(x)p(x,t)tdx=Rd(g(x)TE(x)+TΔg(x))p(x,t)dx\frac{d}{dt} \mathbb{E}[g(x_t)] = \int_{\mathbb{R}^d} g(x) \frac{\partial p(x, t)}{\partial t} dx = \int_{\mathbb{R}^d} \left( -\nabla g(x)^T \nabla E(x) + T \Delta g(x) \right) p(x, t) dx

Using integration by parts (assuming p(x,t)p(x,t) and its derivatives vanish at infinity):

  1. For the drift term: Rd(gE)pdx=Rdg(x)(p(x,t)E(x))dx-\int_{\mathbb{R}^d} (\nabla g \cdot \nabla E) p \, dx = \int_{\mathbb{R}^d} g(x) \nabla \cdot \left( p(x, t) \nabla E(x) \right) dx
  2. For the diffusion term: TRd(Δg)pdx=TRdg(x)Δp(x,t)dx=TRdg(x)2p(x,t)dxT \int_{\mathbb{R}^d} (\Delta g) p \, dx = T \int_{\mathbb{R}^d} g(x) \Delta p(x, t) dx = T \int_{\mathbb{R}^d} g(x) \nabla^2 p(x, t) dx

Equating the integrals for all arbitrary test functions g(x)g(x):

p(x,t)t=(p(x,t)E(x))+T2p(x,t)\frac{\partial p(x, t)}{\partial t} = \nabla \cdot \left( p(x, t) \nabla E(x) \right) + T \nabla^2 p(x, t)

This is the Fokker-Planck (or Forward Kolmogorov) Equation.

Continuity Equation & Probability Current

We can rewrite the Fokker-Planck equation as a conservation law (continuity equation):

p(x,t)t+J(x,t)=0\frac{\partial p(x, t)}{\partial t} + \nabla \cdot J(x, t) = 0

where the Probability Current Density J(x,t)J(x, t) is defined as:

J(x,t)=p(x,t)E(x)Drift Current JdriftTp(x,t)Diffusion Current JdiffJ(x, t) = \underbrace{-p(x, t) \nabla E(x)}_{\text{Drift Current } J_{\mathrm{drift}}} - \underbrace{T \nabla p(x, t)}_{\text{Diffusion Current } J_{\mathrm{diff}}}

Convergence to Gibbs-Boltzmann Equilibrium

In the stationary state p(x,t)t=0\frac{\partial p(x, t)}{\partial t} = 0, conservation requires J(x)=0\nabla \cdot J_\infty(x) = 0. Under thermal equilibrium, a stronger condition holds: Detailed Balance, which requires the probability current to vanish identically everywhere:

J(x)=p(x)E(x)Tp(x)=0J_\infty(x) = -p_\infty(x) \nabla E(x) - T \nabla p_\infty(x) = 0

Dividing by Tp(x)T p_\infty(x):

p(x)p(x)=logp(x)=1TE(x)\frac{\nabla p_\infty(x)}{p_\infty(x)} = \nabla \log p_\infty(x) = -\frac{1}{T} \nabla E(x)

Integrating both sides with respect to xx:

logp(x)=E(x)TlogZ    p(x)=1ZeE(x)T\log p_\infty(x) = -\frac{E(x)}{T} - \log Z \implies p_\infty(x) = \frac{1}{Z} e^{-\frac{E(x)}{T}}

where Z=RdeE(x)/TdxZ = \int_{\mathbb{R}^d} e^{-E(x)/T} dx is the canonical partition function.

Fokker-Planck Evolution to Equilibrium

Relative Entropy as a Lyapunov Functional

How fast does p(x,t)p(x, t) converge to p(x)p_\infty(x)? Let us consider the Kullback-Leibler divergence (Relative Entropy) as a Lyapunov function:

H(t)=DKL(p(x,t)p(x))=Rdp(x,t)log(p(x,t)p(x))dx\mathcal{H}(t) = D_{\mathrm{KL}}(p(x, t) \,\|\, p_\infty(x)) = \int_{\mathbb{R}^d} p(x, t) \log \left( \frac{p(x, t)}{p_\infty(x)} \right) dx

Differentiating with respect to time tt:

ddtH(t)=pt[log(pp)+1]dx=(J)[log(pp)+1]dx=J(x,t)log(p(x,t)p(x))dx\begin{aligned} \frac{d}{dt} \mathcal{H}(t) &= \int \frac{\partial p}{\partial t} \left[ \log\left(\frac{p}{p_\infty}\right) + 1 \right] dx \\ &= \int (-\nabla \cdot J) \left[ \log\left(\frac{p}{p_\infty}\right) + 1 \right] dx \\ &= \int J(x, t) \cdot \nabla \log\left(\frac{p(x, t)}{p_\infty(x)}\right) dx \end{aligned}

Recalling J(x,t)=Tp(x,t)log(p(x,t)p(x))J(x, t) = -T p(x, t) \nabla \log\left(\frac{p(x, t)}{p_\infty(x)}\right):

ddtDKL(p(x,t)p(x))=TRdp(x,t)logp(x,t)p(x)2dx=TI(p(t)p)0\frac{d}{dt} D_{\mathrm{KL}}(p(x, t) \,\|\, p_\infty(x)) = -T \int_{\mathbb{R}^d} p(x, t) \left\| \nabla \log \frac{p(x, t)}{p_\infty(x)} \right\|^2 dx = -T \, \mathcal{I}(p(t) \,\|\, p_\infty) \le 0

where I(pp)\mathcal{I}(p \,\|\, p_\infty) is the Relative Fisher Information. Thus, DKLD_{\mathrm{KL}} decreases monotonically to zero.

Under the Logarithmic Sobolev Inequality (LSI) with constant ρ>0\rho > 0:

DKL(pp)12ρI(pp)    ddtDKL(t)2ρTDKL(t)D_{\mathrm{KL}}(p \,\|\, p_\infty) \le \frac{1}{2\rho} \mathcal{I}(p \,\|\, p_\infty) \implies \frac{d}{dt} D_{\mathrm{KL}}(t) \le -2\rho T D_{\mathrm{KL}}(t)

Integrating yields exponential convergence in entropy (exponential ergodicity):

DKL(p(x,t)p(x))DKL(p(x,0)p(x))e2ρTtD_{\mathrm{KL}}(p(x, t) \,\|\, p_\infty(x)) \le D_{\mathrm{KL}}(p(x, 0) \,\|\, p_\infty(x)) e^{-2\rho T t}

Discrete Algorithms: ULA and MALA

To sample from a target distribution p(x)eE(x)p(x) \propto e^{-E(x)} on a computer, we discretize the overdamped Langevin SDE with step size γstep>0\gamma_{\text{step}} > 0:

  1. Unadjusted Langevin Algorithm (ULA):

    xk+1=xkγstepE(xk)+2Tγstepzk,zkN(0,I)x_{k+1} = x_k - \gamma_{\text{step}} \nabla E(x_k) + \sqrt{2T \gamma_{\text{step}}} \, z_k, \quad z_k \sim \mathcal{N}(0, \mathbf{I})

    Due to finite step size γstep\gamma_{\text{step}}, the stationary distribution of ULA has an O(γstep)\mathcal{O}(\gamma_{\text{step}}) bias away from the true Gibbs target.

  2. Metropolis-Adjusted Langevin Algorithm (MALA): Propose candidate xx' using ULA step, then accept/reject with Metropolis-Hastings probability:

    α(xk,x)=min(1,p(x)q(xkx)p(xk)q(xxk))\alpha(x_k, x') = \min\left( 1, \frac{p(x') q(x_k | x')}{p(x_k) q(x' | x_k)} \right)

    where q(xxk)=N(x;xkγstepE(xk),2TγstepI)q(x' | x_k) = \mathcal{N}\left( x'; x_k - \gamma_{\text{step}} \nabla E(x_k), 2T\gamma_{\text{step}} \mathbf{I} \right), restoring exact asymptotic convergence without step-size bias.


Denoising Diffusion Probabilistic Models (DDPM)

In 2015, Sohl-Dickstein et al. introduced deep generative modeling via non-equilibrium thermodynamics, which was later refined and popularized by Jonathan Ho, Ajay Jain, and Pieter Abbeel (NeurIPS 2020) into Denoising Diffusion Probabilistic Models (DDPM).

The Forward (Diffusion) Process

Let x0q(x0)x_0 \sim q(x_0) be a clean data sample from the target distribution. The forward process generates a sequence of latent variables x1,x2,,xTx_1, x_2, \dots, x_T by sequentially adding Gaussian noise according to a fixed variance schedule β1,β2,,βT(0,1)\beta_1, \beta_2, \dots, \beta_T \in (0, 1):

q(x1:Tx0)=t=1Tq(xtxt1),q(xtxt1)=N(xt;1βtxt1,βtI)q(x_{1:T} | x_0) = \prod_{t=1}^T q(x_t | x_{t-1}), \quad q(x_t | x_{t-1}) = \mathcal{N}\left( x_t; \sqrt{1 - \beta_t} x_{t-1}, \beta_t \mathbf{I} \right)

Closed-Form Marginal q(xtx0)q(x_t | x_0)

Define αt=1βt\alpha_t = 1 - \beta_t and the cumulative product αˉt=s=1tαs\bar{\alpha}_t = \prod_{s=1}^t \alpha_s.

Using the recursive relation:

xt=αtxt1+1αtϵt1,ϵt1N(0,I)x_t = \sqrt{\alpha_t} x_{t-1} + \sqrt{1 - \alpha_t} \epsilon_{t-1}, \quad \epsilon_{t-1} \sim \mathcal{N}(0, \mathbf{I})

Substituting xt1=αt1xt2+1αt1ϵt2x_{t-1} = \sqrt{\alpha_{t-1}} x_{t-2} + \sqrt{1 - \alpha_{t-1}} \epsilon_{t-2}:

xt=αtαt1xt2+αt(1αt1)ϵt2+1αtϵt1x_t = \sqrt{\alpha_t \alpha_{t-1}} x_{t-2} + \sqrt{\alpha_t(1 - \alpha_{t-1})} \epsilon_{t-2} + \sqrt{1 - \alpha_t} \epsilon_{t-1}

Because the sum of two independent Gaussians N(0,σ12I)\mathcal{N}(0, \sigma_1^2 \mathbf{I}) and N(0,σ22I)\mathcal{N}(0, \sigma_2^2 \mathbf{I}) is Gaussian with variance (σ12+σ22)I(\sigma_1^2 + \sigma_2^2)\mathbf{I}:

αt(1αt1)+(1αt)=1αtαt1\alpha_t(1 - \alpha_{t-1}) + (1 - \alpha_t) = 1 - \alpha_t \alpha_{t-1}

By induction across all tt steps:

q(xtx0)=N(xt;αˉtx0,(1αˉt)I)q(x_t | x_0) = \mathcal{N}\left( x_t; \sqrt{\bar{\alpha}_t} x_0, (1 - \bar{\alpha}_t) \mathbf{I} \right)

Hence, we can sample xtx_t at any arbitrary timestep tt directly in closed form:

xt=αˉtx0+1αˉtϵ,ϵN(0,I)x_t = \sqrt{\bar{\alpha}_t} x_0 + \sqrt{1 - \bar{\alpha}_t} \epsilon, \quad \epsilon \sim \mathcal{N}(0, \mathbf{I})

The Reverse (Generative) Process & The ELBO

The generative model is defined as a Markov chain with learned Gaussian transitions running backward in time from p(xT)=N(xT;0,I)p(x_T) = \mathcal{N}(x_T; 0, \mathbf{I}):

pθ(x0:T)=p(xT)t=1Tpθ(xt1xt),pθ(xt1xt)=N(xt1;μθ(xt,t),Σθ(xt,t))p_\theta(x_{0:T}) = p(x_T) \prod_{t=1}^T p_\theta(x_{t-1} | x_t), \quad p_\theta(x_{t-1} | x_t) = \mathcal{N}\left( x_{t-1}; \mu_\theta(x_t, t), \Sigma_\theta(x_t, t) \right)

To train θ\theta, we maximize the marginal log-likelihood Eq(x0)[logpθ(x0)]\mathbb{E}_{q(x_0)}[\log p_\theta(x_0)] via the Variational Lower Bound (ELBO):

logpθ(x0)Eq(x1:Tx0)[logpθ(x0:T)q(x1:Tx0)]=Eq[logp(xT)t=1Tpθ(xt1xt)t=1Tq(xtxt1)]\begin{aligned} \log p_\theta(x_0) &\ge \mathbb{E}_{q(x_{1:T} | x_0)} \left[ \log \frac{p_\theta(x_{0:T})}{q(x_{1:T} | x_0)} \right] \\ &= \mathbb{E}_q \left[ \log \frac{p(x_T) \prod_{t=1}^T p_\theta(x_{t-1} | x_t)}{\prod_{t=1}^T q(x_t | x_{t-1})} \right] \end{aligned}

Using Bayes' rule on the forward transitions q(xtxt1)=q(xt1xt,x0)q(xtx0)q(xt1x0)q(x_t | x_{t-1}) = \frac{q(x_{t-1} | x_t, x_0) q(x_t | x_0)}{q(x_{t-1} | x_0)}:

pθ(x0:T)q(x1:Tx0)=p(xT)pθ(x0x1)t=2Tpθ(xt1xt)q(x1x0)t=2Tq(xt1xt,x0)q(xtx0)q(xt1x0)=p(xT)q(xTx0)pθ(x0x1)t=2Tpθ(xt1xt)q(xt1xt,x0)\begin{aligned} \frac{p_\theta(x_{0:T})}{q(x_{1:T} | x_0)} &= \frac{p(x_T) p_\theta(x_0 | x_1) \prod_{t=2}^T p_\theta(x_{t-1} | x_t)}{q(x_1 | x_0) \prod_{t=2}^T q(x_{t-1} | x_t, x_0) \frac{q(x_t | x_0)}{q(x_{t-1} | x_0)}} \\ &= \frac{p(x_T)}{q(x_T | x_0)} \cdot p_\theta(x_0 | x_1) \cdot \prod_{t=2}^T \frac{p_\theta(x_{t-1} | x_t)}{q(x_{t-1} | x_t, x_0)} \end{aligned}

Taking the logarithm and expectation yields the canonical three-part decomposition:

LVLB=Eq[DKL(q(xTx0)p(xT))LT (Prior Matching)+t=2TDKL(q(xt1xt,x0)pθ(xt1xt))Lt1 (Denoising Matching)logpθ(x0x1)L0 (Reconstruction)]\mathcal{L}_{\mathrm{VLB}} = \mathbb{E}_q \left[ \underbrace{D_{\mathrm{KL}}(q(x_T | x_0) \,\|\, p(x_T))}_{L_T \text{ (Prior Matching)}} + \sum_{t=2}^T \underbrace{D_{\mathrm{KL}}(q(x_{t-1} | x_t, x_0) \,\|\, p_\theta(x_{t-1} | x_t))}_{L_{t-1} \text{ (Denoising Matching)}} - \underbrace{\log p_\theta(x_0 | x_1)}_{L_0 \text{ (Reconstruction)}} \right]

Tractable Posterior q(xt1xt,x0)q(x_{t-1} | x_t, x_0)

Using Bayes' rule for Gaussians, the forward posterior conditioned on x0x_0 is analytically tractable:

q(xt1xt,x0)=q(xtxt1,x0)q(xt1x0)q(xtx0)=N(xt1;μ~t(xt,x0),β~tI)q(x_{t-1} | x_t, x_0) = \frac{q(x_t | x_{t-1}, x_0) q(x_{t-1} | x_0)}{q(x_t | x_0)} = \mathcal{N}\left( x_{t-1}; \tilde{\mu}_t(x_t, x_0), \tilde{\beta}_t \mathbf{I} \right)

Expanding exponents:

q(xt1xt,x0)exp(12[xtαtxt12βt+xt1αˉt1x021αˉt1xtαˉtx021αˉt])=exp(12[xt1T(αtβt+11αˉt1)xt12xt1T(αtβtxt+αˉt11αˉt1x0)+C(xt,x0)])\begin{aligned} q(x_{t-1} | x_t, x_0) &\propto \exp\left( -\frac{1}{2} \left[ \frac{\|x_t - \sqrt{\alpha_t} x_{t-1}\|^2}{\beta_t} + \frac{\|x_{t-1} - \sqrt{\bar{\alpha}_{t-1}} x_0\|^2}{1 - \bar{\alpha}_{t-1}} - \frac{\|x_t - \sqrt{\bar{\alpha}_t} x_0\|^2}{1 - \bar{\alpha}_t} \right] \right) \\ &= \exp\left( -\frac{1}{2} \left[ x_{t-1}^T \left( \frac{\alpha_t}{\beta_t} + \frac{1}{1 - \bar{\alpha}_{t-1}} \right) x_{t-1} - 2 x_{t-1}^T \left( \frac{\sqrt{\alpha_t}}{\beta_t} x_t + \frac{\sqrt{\bar{\alpha}_{t-1}}}{1 - \bar{\alpha}_{t-1}} x_0 \right) + C(x_t, x_0) \right] \right) \end{aligned}

Matching precision (inverse variance) β~t1\tilde{\beta}_t^{-1}:

β~t1=αt(1αˉt1)+βtβt(1αˉt1)=1αˉtβt(1αˉt1)    β~t=1αˉt11αˉtβt\tilde{\beta}_t^{-1} = \frac{\alpha_t(1 - \bar{\alpha}_{t-1}) + \beta_t}{\beta_t(1 - \bar{\alpha}_{t-1})} = \frac{1 - \bar{\alpha}_t}{\beta_t(1 - \bar{\alpha}_{t-1})} \implies \tilde{\beta}_t = \frac{1 - \bar{\alpha}_{t-1}}{1 - \bar{\alpha}_t} \beta_t

Matching mean μ~t(xt,x0)\tilde{\mu}_t(x_t, x_0):

μ~t(xt,x0)=β~t(αtβtxt+αˉt11αˉt1x0)=αt(1αˉt1)1αˉtxt+αˉt1βt1αˉtx0\tilde{\mu}_t(x_t, x_0) = \tilde{\beta}_t \left( \frac{\sqrt{\alpha_t}}{\beta_t} x_t + \frac{\sqrt{\bar{\alpha}_{t-1}}}{1 - \bar{\alpha}_{t-1}} x_0 \right) = \frac{\sqrt{\alpha_t}(1 - \bar{\alpha}_{t-1})}{1 - \bar{\alpha}_t} x_t + \frac{\sqrt{\bar{\alpha}_{t-1}}\beta_t}{1 - \bar{\alpha}_t} x_0

The ϵ\epsilon-Parameterization & Connection to Score Matching

Since xt=αˉtx0+1αˉtϵx_t = \sqrt{\bar{\alpha}_t} x_0 + \sqrt{1 - \bar{\alpha}_t} \epsilon, we express x0x_0 in terms of xtx_t and noise ϵ\epsilon:

x0=xt1αˉtϵαˉtx_0 = \frac{x_t - \sqrt{1 - \bar{\alpha}_t} \epsilon}{\sqrt{\bar{\alpha}_t}}

Substituting this into μ~t(xt,x0)\tilde{\mu}_t(x_t, x_0):

μ~t(xt,x0)=αt(1αˉt1)1αˉtxt+αˉt1βt1αˉt(xt1αˉtϵαˉt)=1αt(xtβt1αˉtϵ)\begin{aligned} \tilde{\mu}_t(x_t, x_0) &= \frac{\sqrt{\alpha_t}(1 - \bar{\alpha}_{t-1})}{1 - \bar{\alpha}_t} x_t + \frac{\sqrt{\bar{\alpha}_{t-1}}\beta_t}{1 - \bar{\alpha}_t} \left( \frac{x_t - \sqrt{1 - \bar{\alpha}_t} \epsilon}{\sqrt{\bar{\alpha}_t}} \right) \\ &= \frac{1}{\sqrt{\alpha_t}} \left( x_t - \frac{\beta_t}{\sqrt{1 - \bar{\alpha}_t}} \epsilon \right) \end{aligned}

Ho et al. therefore parameterized the neural network μθ(xt,t)\mu_\theta(x_t, t) to predict the injected noise ϵθ(xt,t)\epsilon_\theta(x_t, t):

μθ(xt,t)=1αt(xtβt1αˉtϵθ(xt,t))\mu_\theta(x_t, t) = \frac{1}{\sqrt{\alpha_t}} \left( x_t - \frac{\beta_t}{\sqrt{1 - \bar{\alpha}_t}} \epsilon_\theta(x_t, t) \right)

The KL divergence between two Gaussians with identical variance σt2I\sigma_t^2 \mathbf{I} simplifies to:

Lt1=Eq[12σt2μ~t(xt,x0)μθ(xt,t)2]=Ex0,ϵ[βt22σt2αt(1αˉt)ϵϵθ(αˉtx0+1αˉtϵ,t)2]L_{t-1} = \mathbb{E}_q \left[ \frac{1}{2\sigma_t^2} \|\tilde{\mu}_t(x_t, x_0) - \mu_\theta(x_t, t)\|^2 \right] = \mathbb{E}_{x_0, \epsilon} \left[ \frac{\beta_t^2}{2\sigma_t^2 \alpha_t (1 - \bar{\alpha}_t)} \|\epsilon - \epsilon_\theta(\sqrt{\bar{\alpha}_t} x_0 + \sqrt{1 - \bar{\alpha}_t}\epsilon, t)\|^2 \right]

Dropping the weighting factor yields the celebrated DDPM Simplified Loss Function:

Lsimple(θ)=EtU(1,T),x0q(x0),ϵN(0,I)[ϵϵθ(αˉtx0+1αˉtϵ,t)2]\mathcal{L}_{\mathrm{simple}}(\theta) = \mathbb{E}_{t \sim \mathcal{U}(1, T), x_0 \sim q(x_0), \epsilon \sim \mathcal{N}(0, \mathbf{I})} \left[ \left\| \epsilon - \epsilon_\theta\left( \sqrt{\bar{\alpha}_t} x_0 + \sqrt{1 - \bar{\alpha}_t} \epsilon, \, t \right) \right\|^2 \right]

Equivalence to Score Matching:

From q(xtx0)=N(xt;αˉtx0,(1αˉt)I)q(x_t | x_0) = \mathcal{N}(x_t; \sqrt{\bar{\alpha}_t}x_0, (1-\bar{\alpha}_t)\mathbf{I}), Tweedie's Formula shows that the marginal score is:

xtlogq(xt)=E[ϵxt]1αˉt\nabla_{x_t} \log q(x_t) = -\frac{\mathbb{E}[\epsilon | x_t]}{\sqrt{1 - \bar{\alpha}_t}}

Thus, the noise predictor ϵθ(xt,t)\epsilon_\theta(x_t, t) is mathematically identical to a scaled estimator of the Stein Score Function:

sθ(xt,t)=ϵθ(xt,t)1αˉtxtlogpt(xt)s_\theta(x_t, t) = -\frac{\epsilon_\theta(x_t, t)}{\sqrt{1 - \bar{\alpha}_t}} \approx \nabla_{x_t} \log p_t(x_t)

Score-Based Generative Modeling through SDEs (Score-SDE)

In 2021, Yang Song, Jascha Sohl-Dickstein, Diederik P. Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole unified DDPMs and Score-Based Generative Networks under the continuous-time framework of Stochastic Differential Equations (SDEs).

The Forward SDE Framework

In the continuous-time limit (T,Δt0T \to \infty, \Delta t \to 0), the forward diffusion process is described by an Itô SDE:

dx=f(x,t)dt+g(t)dWt,t[0,T]dx = f(x, t) dt + g(t) dW_t, \quad t \in [0, T]

where f(x,t)Rdf(x, t) \in \mathbb{R}^d is the vector-valued drift coefficient, g(t)Rg(t) \in \mathbb{R} is the scalar diffusion coefficient, and WtRdW_t \in \mathbb{R}^d is standard Brownian motion.

Three prominent continuous SDE families exist in the literature:

  1. Variance Preserving SDE (VP-SDE) (Continuous DDPM): f(x,t)=12β(t)x,g(t)=β(t)f(x, t) = -\frac{1}{2} \beta(t) x, \quad g(t) = \sqrt{\beta(t)}
  2. Variance Exploding SDE (VE-SDE) (Continuous NCSN / Score Matching): f(x,t)=0,g(t)=d[σ2(t)]dtf(x, t) = 0, \quad g(t) = \sqrt{\frac{d[\sigma^2(t)]}{dt}}
  3. sub-VP SDE: f(x,t)=12β(t)x,g(t)=β(t)(1e20tβ(s)ds)f(x, t) = -\frac{1}{2} \beta(t) x, \quad g(t) = \sqrt{\beta(t) \left( 1 - e^{-2 \int_0^t \beta(s) ds} \right)}

Anderson's Reverse-Time SDE Theorem

In a foundational 1982 paper, Brian D. O. Anderson proved that any forward diffusion process governed by Itô SDE dx=f(x,t)dt+g(t)dWtdx = f(x, t) dt + g(t) dW_t possesses an exact reverse-time stochastic trajectory running backward from t=Tt = T to t=0t = 0.

Theorem (Anderson, 1982 - Reverse-Time SDE):

Let x(t)x(t) satisfy dx=f(x,t)dt+g(t)dWtdx = f(x, t) dt + g(t) dW_t with marginal probability density pt(x)p_t(x). Then the time-reversed process xˉ(t)=x(Tt)\bar{x}(t) = x(T - t) satisfies the reverse-time SDE:

dx=[f(x,t)g(t)2xlogpt(x)]dt+g(t)dWˉtdx = \left[ f(x, t) - g(t)^2 \nabla_x \log p_t(x) \right] dt + g(t) d\bar{W}_t

where dtdt is an infinitesimal negative time step running backward from TT to 00, and Wˉt\bar{W}_t is a standard Brownian motion running backward in time.

Complete Mathematical Proof via Fokker-Planck Equivalence

We now provide the rigorous derivation by proving that the forward and reverse SDEs generate identical marginal densities pt(x)p_t(x) at every instant t[0,T]t \in [0, T].

Step 1: Forward Fokker-Planck Equation. The forward SDE dx=f(x,t)dt+g(t)dWtdx = f(x, t) dt + g(t) dW_t has probability current Jf(x,t)=pt(x)f(x,t)12g(t)2xpt(x)J_f(x, t) = p_t(x) f(x, t) - \frac{1}{2} g(t)^2 \nabla_x p_t(x). Its Fokker-Planck equation is:

pt(x)t=x[pt(x)f(x,t)]+12g(t)2x2pt(x)\frac{\partial p_t(x)}{\partial t} = -\nabla_x \cdot \left[ p_t(x) f(x, t) \right] + \frac{1}{2} g(t)^2 \nabla_x^2 p_t(x)

Step 2: Reverse SDE Ansatz. Assume a general reverse-time SDE running backward with drift f~(x,t)\tilde{f}(x, t) and identical diffusion coefficient g(t)g(t):

dx=f~(x,t)dt+g(t)dWˉtdx = \tilde{f}(x, t) dt + g(t) d\bar{W}_t

Reversing time via substitution τ=t\tau = -t, the time derivative satisfies τ=t\frac{\partial}{\partial \tau} = -\frac{\partial}{\partial t}. The Fokker-Planck equation for this reverse process running backward must satisfy:

pt(x)t=x[pt(x)f~(x,t)]+12g(t)2x2pt(x)-\frac{\partial p_t(x)}{\partial t} = -\nabla_x \cdot \left[ p_t(x) \tilde{f}(x, t) \right] + \frac{1}{2} g(t)^2 \nabla_x^2 p_t(x)

Rearranging:

pt(x)t=x[pt(x)f~(x,t)]12g(t)2x2pt(x)\frac{\partial p_t(x)}{\partial t} = \nabla_x \cdot \left[ p_t(x) \tilde{f}(x, t) \right] - \frac{1}{2} g(t)^2 \nabla_x^2 p_t(x)

Step 3: Equating Forward and Reverse Fokker-Planck Equations. For the reverse process to have the exact same marginals pt(x)p_t(x) as the forward process, the two time-derivative expressions must match:

x[pt(x)f(x,t)]+12g(t)2x2pt(x)=x[pt(x)f~(x,t)]12g(t)2x2pt(x)-\nabla_x \cdot \left[ p_t(x) f(x, t) \right] + \frac{1}{2} g(t)^2 \nabla_x^2 p_t(x) = \nabla_x \cdot \left[ p_t(x) \tilde{f}(x, t) \right] - \frac{1}{2} g(t)^2 \nabla_x^2 p_t(x)

Combining terms:

x[pt(x)(f~(x,t)+f(x,t))]=g(t)2x2pt(x)\nabla_x \cdot \left[ p_t(x) \left( \tilde{f}(x, t) + f(x, t) \right) \right] = g(t)^2 \nabla_x^2 p_t(x)

Using the identity x2pt(x)=x(xpt(x))=x(pt(x)xlogpt(x))\nabla_x^2 p_t(x) = \nabla_x \cdot \left( \nabla_x p_t(x) \right) = \nabla_x \cdot \left( p_t(x) \nabla_x \log p_t(x) \right):

x[pt(x)(f~(x,t)+f(x,t))]=x[pt(x)(g(t)2xlogpt(x))]\nabla_x \cdot \left[ p_t(x) \left( \tilde{f}(x, t) + f(x, t) \right) \right] = \nabla_x \cdot \left[ p_t(x) \left( g(t)^2 \nabla_x \log p_t(x) \right) \right]

Equating the vector fields inside the divergence (under zero boundary conditions at infinity):

pt(x)(f~(x,t)+f(x,t))=pt(x)(g(t)2xlogpt(x))p_t(x) \left( \tilde{f}(x, t) + f(x, t) \right) = p_t(x) \left( g(t)^2 \nabla_x \log p_t(x) \right)

Dividing by pt(x)>0p_t(x) > 0:

f~(x,t)=f(x,t)+g(t)2xlogpt(x)\tilde{f}(x, t) = -f(x, t) + g(t)^2 \nabla_x \log p_t(x)

Since time flows backward (dt<0dt < 0), the drift term appearing in dx=f~eff(x,t)dtdx = \tilde{f}_{\text{eff}}(x, t) dt is:

dx=[f(x,t)g(t)2xlogpt(x)]dt+g(t)dWˉtdx = \left[ f(x, t) - g(t)^2 \nabla_x \log p_t(x) \right] dt + g(t) d\bar{W}_t \quad \blacksquare

The Probability Flow ODE

Remarkably, Song et al. (2021) demonstrated that there exists a completely deterministic ordinary differential equation (ODE) whose trajectory shares the exact same marginal probability density pt(x)p_t(x) as the stochastic SDE for all t[0,T]t \in [0, T]:

dxdt=f(x,t)12g(t)2xlogpt(x)\frac{dx}{dt} = f(x, t) - \frac{1}{2} g(t)^2 \nabla_x \log p_t(x)

Exact Log-Likelihood via the Instantaneous Change of Variables

For any sample x0x_0, we can compute its exact likelihood under the model by integrating the divergence of the ODE vector field v(x,t)=f(x,t)12g(t)2sθ(x,t)v(x, t) = f(x, t) - \frac{1}{2} g(t)^2 s_\theta(x, t) using the continuous change-of-variables formula:

logp0(x0)=logpT(xT)+0Tx[f(x(t),t)12g(t)2sθ(x(t),t)]dt\log p_0(x_0) = \log p_T(x_T) + \int_0^T \nabla_x \cdot \left[ f(x(t), t) - \frac{1}{2} g(t)^2 s_\theta(x(t), t) \right] dt

The high-dimensional trace/divergence xv(x,t)=Tr(xv(x,t))\nabla_x \cdot v(x, t) = \operatorname{Tr}(\nabla_x v(x, t)) is computed efficiently via the Hutchinson Trace Estimator:

Tr(xv(x,t))=EϵN(0,I)[ϵTxv(x,t)ϵ]\operatorname{Tr}(\nabla_x v(x, t)) = \mathbb{E}_{\epsilon \sim \mathcal{N}(0, \mathbf{I})} \left[ \epsilon^T \nabla_x v(x, t) \epsilon \right]

which requires only a single vector-Jacobian product (VJP) via reverse-mode automatic differentiation.

Score Matching Objectives

To train a neural network sθ(x,t)s_\theta(x, t) to approximate xlogpt(x)\nabla_x \log p_t(x) without knowing the intractable normalizing partition function of pt(x)p_t(x), we use Score Matching.

1. Explicit Score Matching (ESM)

The ideal Fisher divergence objective:

JESM(θ)=12Epdata(x)[sθ(x)xlogpdata(x)2]\mathcal{J}_{\mathrm{ESM}}(\theta) = \frac{1}{2} \mathbb{E}_{p_{\mathrm{data}}(x)} \left[ \left\| s_\theta(x) - \nabla_x \log p_{\mathrm{data}}(x) \right\|^2 \right]

This is intractable because the ground truth score xlogpdata(x)\nabla_x \log p_{\mathrm{data}}(x) is unknown.

2. Implicit Score Matching (ISM - Aapo Hyvärinen, 2005)

Expanding the square in ESM:

JESM(θ)=Ep(x)[12sθ(x)2sθ(x)xlogp(x)]+const\mathcal{J}_{\mathrm{ESM}}(\theta) = \mathbb{E}_{p(x)} \left[ \frac{1}{2} \|s_\theta(x)\|^2 - s_\theta(x) \cdot \nabla_x \log p(x) \right] + \text{const}

Applying integration by parts on the cross-term:

Rdp(x)sθ(x)p(x)p(x)dx=Rdsθ(x)p(x)dx=Rdp(x)sθ(x)dx=Ep(x)[Tr(xsθ(x))]\int_{\mathbb{R}^d} p(x) s_\theta(x) \cdot \frac{\nabla p(x)}{p(x)} dx = \int_{\mathbb{R}^d} s_\theta(x) \cdot \nabla p(x) dx = -\int_{\mathbb{R}^d} p(x) \nabla \cdot s_\theta(x) dx = -\mathbb{E}_{p(x)}[\operatorname{Tr}(\nabla_x s_\theta(x))]

This yields the Implicit Score Matching Objective:

JISM(θ)=Epdata(x)[Tr(xsθ(x))+12sθ(x)2]\mathcal{J}_{\mathrm{ISM}}(\theta) = \mathbb{E}_{p_{\mathrm{data}}(x)} \left[ \operatorname{Tr}\left( \nabla_x s_\theta(x) \right) + \frac{1}{2} \|s_\theta(x)\|^2 \right]

3. Denoising Score Matching (DSM - Pascal Vincent, 2011)

Perturb data x0q(x0)x_0 \sim q(x_0) with a known transition kernel q(xtx0)=N(xt;μ(x0,t),σ2(t)I)q(x_t | x_0) = \mathcal{N}(x_t; \mu(x_0, t), \sigma^2(t) \mathbf{I}). Vincent proved that:

xtlogq(xt)=Eq(x0xt)[xtlogq(xtx0)]\nabla_{x_t} \log q(x_t) = \mathbb{E}_{q(x_0 | x_t)} \left[ \nabla_{x_t} \log q(x_t | x_0) \right]

The tractable objective optimizes score prediction against the analytic conditional kernel:

JDSM(θ)=EtU(0,T),x0q(x0),xtq(xtx0)[λ(t)sθ(xt,t)xtlogq(xtx0)2]\mathcal{J}_{\mathrm{DSM}}(\theta) = \mathbb{E}_{t \sim \mathcal{U}(0, T), x_0 \sim q(x_0), x_t \sim q(x_t | x_0)} \left[ \lambda(t) \left\| s_\theta(x_t, t) - \nabla_{x_t} \log q(x_t | x_0) \right\|^2 \right]

Since xtlogq(xtx0)=xtμ(x0,t)σ2(t)=ϵσ(t)\nabla_{x_t} \log q(x_t | x_0) = -\frac{x_t - \mu(x_0, t)}{\sigma^2(t)} = -\frac{\epsilon}{\sigma(t)}, DSM reduces exactly to the noise regression loss used in DDPM.

Predictor-Corrector (PC) Sampling

Song et al. introduced Predictor-Corrector (PC) Samplers, which combine numerical integration of the reverse SDE with intermediate Langevin MCMC corrections:

The Corrector uses the learned score sθ(xt,t)s_\theta(x_t, t) to actively suppress accumulated numerical drift and discretization error, guaranteeing high sampling fidelity.


Discrete Diffusion Models for Language & Symbolic Spaces

While continuous diffusion operates in Euclidean spaces Rd\mathbb{R}^d, language models, symbolic mathematics, and biological sequences exist on discrete vocabularies V={1,2,,V}N\mathcal{V} = \{1, 2, \dots, V\}^N. On a discrete lattice, the gradient operator xlogp(x)\nabla_x \log p(x) is undefined.

AspectContinuous Diffusion (Images, Audio, Latents)Discrete Diffusion / Masking (LLaDA, Language)
State SpaceContinuous vector space xRDx \in \mathbb{R}^DDiscrete token vocabulary xVLx \in \mathcal{V}^L
Corruption MechanismAdditive Gaussian noise (xt=αˉtx0+1αˉtϵx_t = \sqrt{\bar{\alpha}_t} x_0 + \sqrt{1-\bar{\alpha}_t} \epsilon)Absorbing [MASK] token substitution (q(xtx0)q(x_t \mid x_0))
Forward Stationary StateStandard Normal prior N(0,I)\mathcal{N}(0, I)Pure masked sequence ([MASK],,[MASK])([\text{MASK}], \dots, [\text{MASK}])
Model OutputContinuous Score Vector sθ(xt,t)RDs_\theta(x_t, t) \in \mathbb{R}^DLogit distribution over vocabulary pθ(x0ixt)ΔVp_\theta(x_0^i \mid x_t) \in \Delta^{\lvert\mathcal{V}\rvert}
Reverse StepLangevin / SDE drift updateSemi-autoregressive parallel re-masking / unmasking

Paradigm 1: Continuous Embedding Diffusion (Diffusion-LM)

In Diffusion-LM (Li et al., 2022), discrete token sequences w=(w1,,wN)w = (w_1, \dots, w_N) are mapped into continuous embedding space x0=Embed(w)RN×dx_0 = \operatorname{Embed}(w) \in \mathbb{R}^{N \times d}. Gaussian diffusion is performed in continuous space, and at step t=0t=0, tokens are recovered via categorical rounding:

pθ(wx0)=i=1Nsoftmax(E(wi)Tx0(i))p_\theta(w | x_0) = \prod_{i=1}^N \operatorname{softmax}\left( E(w_i)^T x_0^{(i)} \right)

Fundamental Bottleneck: Continuous embeddings suffer from rounding collapse and out-of-vocabulary drift during intermediate timesteps, where continuous latents wander into regions of embedding space that do not correspond to any valid grammatical token sequence.

Paradigm 2: Continuous-Time Markov Chains & Score Entropy (SEDD)

To overcome the embedding bottleneck, Lou et al. (ICML 2024) formulated Score Entropy Discrete Diffusion (SEDD) directly on the discrete state space VN\mathcal{V}^N using Continuous-Time Markov Chains (CTMC).

The Master Equation of Discrete Diffusion

Let xtVNx_t \in \mathcal{V}^N evolve according to a transition rate matrix QtRV×VQ_t \in \mathbb{R}^{V \times V}, where Qt(x,y)0Q_t(x, y) \ge 0 (xyx \neq y) is the instantaneous jump rate from state xx to state yy, with diagonal Qt(x,x)=yxQt(x,y)Q_t(x, x) = -\sum_{y \neq x} Q_t(x, y).

The probability distribution pt(x)p_t(x) obeys the continuous-time Master Equation:

dpt(x)dt=yVpt(y)Qt(y,x)=yx[pt(y)Qt(y,x)pt(x)Qt(x,y)]\frac{d p_t(x)}{dt} = \sum_{y \in \mathcal{V}} p_t(y) Q_t(y, x) = \sum_{y \neq x} \left[ p_t(y) Q_t(y, x) - p_t(x) Q_t(x, y) \right]

Time-Reversal of Discrete CTMC (Kelly's Lemma)

By Kolmogorov's time-reversal theorem for jump processes, the reverse-time process running from t=Tt = T back to t=0t = 0 is itself a continuous-time Markov chain with reverse transition rate matrix Qˉt(x,y)\bar{Q}_t(x, y):

Qˉt(x,y)=Qt(y,x)pt(y)pt(x)\bar{Q}_t(x, y) = Q_t(y, x) \frac{p_t(y)}{p_t(x)}

The Discrete Score Function:

The discrete analog of the continuous score xlogpt(x)\nabla_x \log p_t(x) is the Concrete Probability Ratio:

st(x,y)=pt(y)pt(x)for yxs_t(x, y) = \frac{p_t(y)}{p_t(x)} \quad \text{for } y \neq x

While the continuous score measures the directional gradient of log-density, the discrete score measures the relative probability mass between adjacent discrete states xx and y.

Score Entropy Loss

SEDD replaces Euclidean score matching with the Score Entropy Objective:

LSEDD(θ)=Et,x0,xt[yxtQt(xt,y)(sθ(xt,y,t)q(yx0)q(xtx0)logsθ(xt,y,t))]\mathcal{L}_{\mathrm{SEDD}}(\theta) = \mathbb{E}_{t, x_0, x_t} \left[ \sum_{y \neq x_t} Q_t(x_t, y) \left( s_\theta(x_t, y, t) - \frac{q(y | x_0)}{q(x_t | x_0)} \log s_\theta(x_t, y, t) \right) \right]

Minimizing LSEDD\mathcal{L}_{\mathrm{SEDD}} forces the neural network sθ(xt,y,t)s_\theta(x_t, y, t) to converge to the exact time-reversal transition rates Qˉt(xt,y)\bar{Q}_t(x_t, y), enabling rigorous discrete generation without continuous relaxation.

Paradigm 3: Masking-Based Discrete Diffusion & LLaDA 8B

In late 2024 and 2025, Large Language Diffusion Models underwent a major breakthrough with LLaDA (Large Language Diffusion with Masking) (Nie et al., NeurIPS 2025 / 2024), scaling discrete diffusion to an 8-billion parameter foundational model competitive with LLaMA3.

The Absorbing State (Masking) Kernel

Instead of uniform substitution across the vocabulary V\mathcal{V}, LLaDA employs an absorbing state transition with a dedicated [MASK] token:

q(xtix0i)={x0iwith probability αt[MASK]with probability 1αtq(x_t^i | x_0^i) = \begin{cases} x_0^i & \text{with probability } \alpha_t \\ \text{[MASK]} & \text{with probability } 1 - \alpha_t \end{cases}

where αt=1t/T\alpha_t = 1 - t/T is a monotonic unmasking schedule (t[0,T]t \in [0, T]).

Training Objective

At training time, given a sequence x0=(x01,,x0N)x_0 = (x_0^1, \dots, x_0^N), a time tU(0,T)t \sim \mathcal{U}(0, T) is sampled, masking a subset of tokens Mt{1,,N}\mathcal{M}_t \subseteq \{1, \dots, N\}. The Transformer network pθ(x0ixt)p_\theta(x_0^i | x_t) is trained via bidirectional cross-entropy loss only on the masked positions:

LLLaDA(θ)=Et,x0,Mt[iMtlogpθ(x0ixt)]\mathcal{L}_{\mathrm{LLaDA}}(\theta) = \mathbb{E}_{t, x_0, \mathcal{M}_t} \left[ \sum_{i \in \mathcal{M}_t} -\log p_\theta\left( x_0^i \,\Big|\, x_t \right) \right]

Re-masking and Semi-Autoregressive Sampling

During inference, LLaDA generates an entire document non-autoregressively or semi-autoregressively via iterative unmasking:

def llada_reverse_generation(sequence_length, total_steps, temperature):
    """
    LLaDA Masked Diffusion Reverse Sampling Algorithm
    """
    # 1. Initialize full masked sequence
    x = [MASK] * sequence_length
    
    for k in range(total_steps, 0, -1):
        # Predict token probabilities for masked positions
        p_theta = model.predict_logits(x) / temperature
        sampled_tokens = categorical_sample(p_theta)
        
        # Calculate confidence scores
        confidence = compute_confidence(p_theta, sampled_tokens)
        
        # Determine number of tokens to unmask at this step
        num_unmasked = schedule(k, total_steps, sequence_length)
        top_indices = get_top_k_indices(confidence, k=num_unmasked)
        
        for idx in top_indices:
            x[idx] = sampled_tokens[idx]
            
    return x

Comparative Analysis: Autoregressive LLMs vs. Discrete Diffusion LLMs

Feature / DimensionAutoregressive (AR) LLMs (e.g. GPT-4, LLaMA-3)Discrete Diffusion LLMs (e.g. SEDD, LLaDA-8B)
Factorization of Joint DistributionLeft-to-right causal: p(x)=i=1Np(xix<i)p(x) = \prod_{i=1}^N p(x_i \Vert x_{\lt i})Joint ensemble: p(x)=ip(x0ixt)dtp(x) = \int \prod_i p(x_0^i \Vert x_t) dt
Attention MechanismStrictly causal (triangular lower-masked)Fully bidirectional (all tokens attend to all tokens)
Generation ComplexityO(N)\mathcal{O}(N) sequential steps (NN forward passes)O(K)\mathcal{O}(K) iterative refinement steps (KNK \ll N)
Infilling & Arbitrary EditingExtremely difficult (requires special prompt formatting)Native capability (mask arbitrary spans anywhere)
KV Caching OptimizationHighly optimized O(1)\mathcal{O}(1) step cache updatesRequires full bidirectional forward passes per step
Controllability / GuidancePrompt prefixing / logit steeringDirect classifier-free and gradient-based guidance
Thermodynamic ReversibilityIrreversible sequential branchingReversible relaxation along entropy gradient

Thermodynamic Entropy Production & The Direction of Time

We conclude by tying all generative diffusion frameworks back to fundamental Non-Equilibrium Thermodynamics.

ΔStot=lnP[x(t)]Prev[x(Tt)]=ΔSsys+ΔSmedium0\Delta S_{\text{tot}} = \ln \frac{\mathcal{P}[x(t)]}{\mathcal{P}^{\text{rev}}[x(T-t)]} = \Delta S_{\text{sys}} + \Delta S_{\text{medium}} \ge 0

Consider the path probability measure P[x(t)]t=0T\mathcal{P}[x(t)]_{t=0}^T of the forward diffusion process and the time-reversed path measure PR[xˉ(t)]t=0T\mathcal{P}_R[\bar{x}(t)]_{t=0}^T. By the Crooks Fluctuation Theorem and the Second Law of Thermodynamics, the total entropy production along the stochastic trajectory is:

ΔStot=DKL(P[x(t)]PR[xˉ(t)])0\Delta S_{\mathrm{tot}} = D_{\mathrm{KL}}\left( \mathcal{P}[x(t)] \,\|\, \mathcal{P}_R[\bar{x}(t)] \right) \ge 0

Expanding the path integral under the forward SDE dx=fdt+gdWtdx = f dt + g dW_t and parameterized reverse model dx=[fg2sθ]dt+gdWˉtdx = [f - g^2 s_\theta] dt + g d\bar{W}_t via Girsanov's Theorem:

ΔStot=120Tg(t)2Ept(x)[sθ(x,t)xlogpt(x)2]dt=0TJESM(θ,t)dt\Delta S_{\mathrm{tot}} = \frac{1}{2} \int_0^T g(t)^2 \, \mathbb{E}_{p_t(x)} \left[ \left\| s_\theta(x, t) - \nabla_x \log p_t(x) \right\|^2 \right] dt = \int_0^T \mathcal{J}_{\mathrm{ESM}}(\theta, t) \, dt

[!IMPORTANT] The Thermodynamic Nature of Diffusion Training: Minimizing the score-matching loss JESM(θ)\mathcal{J}_{\mathrm{ESM}}(\theta) is mathematically identical to minimizing the total thermodynamic entropy production of the time-reversal process.

When the neural score network achieves zero loss (sθ(x,t)=xlogpt(x)s_\theta(x, t) = \nabla_x \log p_t(x)), total entropy production vanishes (ΔStot=0\Delta S_{\mathrm{tot}} = 0), meaning the artificial generative process operates as an ideal, microscopically reversible thermodynamic engine running backwards in time.


Summary of Key Theoretical Results

Brownian Motion & FDT

The Langevin equation mx¨=γx˙+η(t)m\ddot{x} = -\gamma \dot{x} + \eta(t) balances dissipative drag against thermal fluctuations η(t)η(t)=2γkBTδ(tt)\langle \eta(t)\eta(t')\rangle = 2\gamma k_B T \delta(t-t'), giving rise to the Stokes-Einstein relation D=kBT/γD = k_B T / \gamma.

Fokker-Planck & Gibbs Convergence

Overdamped Langevin dynamics dx=E(x)dt+2TdWdx = -\nabla E(x)dt + \sqrt{2T}dW drives any initial probability distribution to the Gibbs-Boltzmann stationary state p(x)eE(x)/Tp_\infty(x) \propto e^{-E(x)/T} with zero probability current at detailed balance.

DDPM & Score Duality

DDPM optimizes a variational lower bound (ELBO) over a discrete Markov chain whose ϵ\epsilon-prediction objective is equivalent to Tweedie's scaled score estimator xtlogq(xt)=ϵ/1αˉt\nabla_{x_t}\log q(x_t) = -\epsilon / \sqrt{1-\bar{\alpha}_t}.

Score-SDE & Reverse Time

Anderson's reverse SDE dx=[fg2logpt]dt+gdWˉdx = [f - g^2 \nabla \log p_t]dt + g d\bar{W} and the Probability Flow ODE provide a unified continuum for stochastic and deterministic generative sampling with exact likelihood computation.

Discrete Diffusion & LLaDA

Discrete diffusion via Continuous-Time Markov Chains (SEDD) and Masking (LLaDA 8B) replaces Euclidean gradients with concrete score ratios and bidirectional contextual infilling for state-of-the-art language generation.


References & Foundational Literature

  1. Langevin, P. (1908). Sur la théorie du mouvement brownien. C. R. Acad. Sci. (Paris), 146, 530–533.
  2. Einstein, A. (1905). Über die von der molekularkinetischen Theorie der Wärme geforderte Bewegung von in ruhenden Flüssigkeiten suspendierten Teilchen. Annalen der Physik, 322(8), 549–560.
  3. Anderson, B. D. O. (1982). Reverse-time diffusion equation models. Stochastic Processes and their Applications, 12(3), 313–326.
  4. Hyvärinen, A. (2005). Estimation of non-normalized statistical models by score matching. Journal of Machine Learning Research, 6(4), 695–709.
  5. Vincent, P. (2011). A connection between score matching and denoising autoencoders. Neural Computation, 23(7), 1661–1674.
  6. Sohl-Dickstein, J., Weiss, E., Khanshali, N., & Sompolinsky, H. (2015). Deep unsupervised learning using nonequilibrium thermodynamics. ICML 2015.
  7. Song, Y., & Ermon, S. (2019). Generative modeling by estimating gradients of the data distribution. NeurIPS 2019.
  8. Ho, J., Jain, A., & Abbeel, P. (2020). Denoising diffusion probabilistic models. NeurIPS 2020.
  9. Song, Y., Sohl-Dickstein, J., Kingma, D. P., Kumar, A., Ermon, S., & Poole, B. (2021). Score-based generative modeling through stochastic differential equations. ICLR 2021.
  10. Li, X. L., Thickstun, J., Gulrajani, I., Liang, P., & Hashimoto, T. B. (2022). Diffusion-LM improves controllable text generation. NeurIPS 2022.
  11. Lou, A., Meng, C., & Ermon, S. (2024). Discrete diffusion modeling by estimating the score of the continuous-time Markov chain. ICML 2024.
  12. Nie, S., et al. (2025). Large Language Diffusion Models (LLaDA). NeurIPS 2025 / arXiv:2410.02416.

On this page

The Physical Paradigm of Generative ModelingMicroscopic Foundations: Brownian Motion & The Classical Langevin EquationPhysical Setup: Pollen Grains and Thermal SolventStatistical Properties of Thermal White NoiseExact Solution for the Velocity ProcessVelocity Autocorrelation Function (VACF)The Fluctuation-Dissipation Theorem (FDT)Position Diffusion & The Green-Kubo RelationOverdamped Langevin Dynamics & The Fokker-Planck EquationThe High-Friction (Overdamped) LimitDerivation of the Fokker-Planck EquationContinuity Equation & Probability CurrentConvergence to Gibbs-Boltzmann EquilibriumRelative Entropy as a Lyapunov FunctionalDiscrete Algorithms: ULA and MALADenoising Diffusion Probabilistic Models (DDPM)The Forward (Diffusion) ProcessClosed-Form Marginal q(xtx0)q(x_t | x_0)The Reverse (Generative) Process & The ELBOTractable Posterior q(xt1xt,x0)q(x_{t-1} | x_t, x_0)The ϵ\epsilon-Parameterization & Connection to Score MatchingScore-Based Generative Modeling through SDEs (Score-SDE)The Forward SDE FrameworkAnderson's Reverse-Time SDE TheoremComplete Mathematical Proof via Fokker-Planck EquivalenceThe Probability Flow ODEExact Log-Likelihood via the Instantaneous Change of VariablesScore Matching Objectives1. Explicit Score Matching (ESM)2. Implicit Score Matching (ISM - Aapo Hyvärinen, 2005)3. Denoising Score Matching (DSM - Pascal Vincent, 2011)Predictor-Corrector (PC) SamplingDiscrete Diffusion Models for Language & Symbolic SpacesParadigm 1: Continuous Embedding Diffusion (Diffusion-LM)Paradigm 2: Continuous-Time Markov Chains & Score Entropy (SEDD)The Master Equation of Discrete DiffusionTime-Reversal of Discrete CTMC (Kelly's Lemma)Score Entropy LossParadigm 3: Masking-Based Discrete Diffusion & LLaDA 8BThe Absorbing State (Masking) KernelTraining ObjectiveRe-masking and Semi-Autoregressive SamplingComparative Analysis: Autoregressive LLMs vs. Discrete Diffusion LLMsThermodynamic Entropy Production & The Direction of TimeSummary of Key Theoretical ResultsReferences & Foundational Literature