Course contents 26 / 34

26 / 34 · Diffusion Models

DDPM: the forward process

How a diffusion model destroys data on purpose: a noising chain whose rescaled steps keep the variance at one, a closed-form jump to any step, and the noise schedules used in practice.

On this page 6

Take a photo and add a faint layer of Gaussian noise. Add another, and another. After a thousand layers nothing of the photo is left, and the result looks like any other draw from N(0,I)\mathcal N(0, I). Destroying an image this way needs no learning. Played backwards, the same film would turn noise into a photo, one small denoising step per frame.

That reversed film is a diffusion model. Unlike the energy-based models before it, it never runs a sampler during training: the noising process is fixed, and a network learns only the way back. DDPM, Denoising Diffusion Probabilistic Models (Ho, Jain and Abbeel, 2020), made this work at image quality competitive with GANs, building on the diffusion models of Sohl-Dickstein et al. (2015).

Before any network appears, the noising process has to be designed. Two properties make it useful. Wherever the image starts, the process must end at one fixed distribution that we can sample, because generation will start there. And it must be possible to jump from the image to any intermediate step in one draw, because training will need noisy images at random steps millions of times.

Running a photo into noise#

Write x0x_0 for a data point, an image whose pixels are scaled to [−1,1][-1, 1], and xtx_t for its noised version after tt steps, t=1,…,Tt = 1, \dots, T. One noising step is a conditional distribution q(xt∣xt−1)q(x_t \mid x_{t-1}), and the steps form a Markov chain: xtx_t depends on the past only through xt−1x_{t-1}. The data distribution is written q(x0)q(x_0), since the chain starts there. The learned reverse step, from xtx_t back to xt−1x_{t-1}, is written pθ(xt−1∣xt)p_\theta(x_{t-1} \mid x_t), with θ\theta the parameters of a network.

x0image  ⟶  x1  ⟶  ⋯  ⟶  xTnoise,xt−1  ←  pθ(xt−1∣xt)    xt.\begin{gathered} \underset{\text{image}}{x_0} \;\longrightarrow\; x_1 \;\longrightarrow\; \cdots \;\longrightarrow\; \underset{\text{noise}}{x_T}, \\ x_{t-1} \;\xleftarrow{\;p_\theta(x_{t-1} \mid x_t)\;}\; x_t . \end{gathered}
Figure

The forward chain adds noise; the model walks back

Diffusion chain from an original photo to pure noiseFour pixel tiles in a row: x0 the original photo of a sun and a hill, x1 with some noise, x2 with more noise, then an ellipsis, then xT which is pure noise. Straight arrows labelled add noise go left to right. Curved arrows above go right to left, labelled p theta of x0 given x1, p theta of x1 given x2 and p theta of xT minus 1 given xT: the learned reverse step. A long arrow below says forward process q of xt given xt minus 1, fixed; a long arrow at the top says reverse process, learned model.reverse: learned model pθ (goes back one step)x0originalphotox1addnoisex2morenoisexTpurenoise…add noiseadd noisepθ(x0 | x1)pθ(x1 | x2)pθ(xT−1 | xT)forward process q(xt | xt−1): fixed, just adds noiseDiffusion chain from an original photo to pure noiseFour pixel tiles in a column: x0 the original photo of a sun and a hill, x1 with some noise, x2 with more noise, an ellipsis, then xT, pure noise. Arrows labelled add noise point down. Curved blue arrows on the right point up, labelled p theta of x0 given x1, p theta of x1 given x2 and p theta of xT minus 1 given xT: the learned reverse step going one step back.x0original photox1add noisex2more noisexTpure noise⋮add noiseadd noisepθ(x0 | x1)pθ(x1 | x2)pθ(xT−1 | xT)blue: learned model, one step back
Forward arrows: the fixed noising step q(xₜ | xₜ₋₁). Curved arrows: the learned reverse step pθ(xₜ₋₁ | xₜ). Tiles are samples xₜ = √α̅ₜ x₀ + √(1 − α̅ₜ) ε for α̅ = 1, 0.8, 0.5 and 4 × 10⁻⁵ (the end of DDPM's schedule), with one fixed noise draw ε.

We work in one dimension, a single pixel. Every pixel of an image is noised independently with the same rule, so for images 11 becomes the identity matrix II. Throughout, ε∼N(0,1)\varepsilon \sim \mathcal N(0, 1) is standard Gaussian noise, drawn fresh at every step, and the second argument of N(μ,σ2)\mathcal N(\mu, \sigma^2) is the variance.

A first attempt: just add noise#

The simplest step adds noise of variance β\beta:

xt=xt−1+β ε,q(xt∣xt−1)=N(xt−1,β).\begin{aligned} x_t &= x_{t-1} + \sqrt{\beta}\,\varepsilon, \\ q(x_t \mid x_{t-1}) &= \mathcal N(x_{t-1}, \beta) . \end{aligned}

The square root is there because c εc\,\varepsilon has variance c2c^2. Two steps add two independent noises, and the variances of independent Gaussians add:

x2=x1+β ε2=x0+β ε1+β ε2,q(x2∣x0)=N(x0,2β).\begin{aligned} x_2 &= x_1 + \sqrt\beta\,\varepsilon_2 \\ &= x_0 + \sqrt\beta\,\varepsilon_1 + \sqrt\beta\,\varepsilon_2 , \\ q(x_2 \mid x_0) &= \mathcal N(x_0, 2\beta) . \end{aligned}

After tt steps, q(xt∣x0)=N(x0,tβ)q(x_t \mid x_0) = \mathcal N(x_0, t\beta). The jump from x0x_0 to any xtx_t is one Gaussian draw, so the second property holds. The first does not. The mean stays at x0x_0 forever, and the variance tβt\beta grows without bound, so there is no fixed distribution at the end of the chain to start generation from. This is the variance-exploding process (Isachenko, 2025, lecture 11). Models built on it stop at a large finite noise level and start sampling from a wide Gaussian of that size; the score matching note works with one.

The objective, and the rescaled step#

We want the chain to forget its start:

q(xt∣x0)→t→∞N(0,1)q(x_t \mid x_0) \xrightarrow[t \to \infty]{} \mathcal N(0, 1)

for every image x0x_0. Adding noise alone cannot do it, because the mean never moves. So each step also shrinks the previous point by a factor aa, pulling the mean towards 00:

xt=a xt−1+βt ε.x_t = a\, x_{t-1} + \sqrt{\beta_t}\,\varepsilon .

The noise variance βt∈(0,1)\beta_t \in (0, 1) may now change from step to step. Which aa? The fresh noise is independent of xt−1x_{t-1}, so the variance of a sum is the sum of the variances, and scaling by aa multiplies a variance by a2a^2:

Var⁡(xt)=a2Var⁡(xt−1)+βt.\operatorname{Var}(x_t) = a^2 \operatorname{Var}(x_{t-1}) + \beta_t .

The target N(0,1)\mathcal N(0, 1) has variance 11, and a point already at the target must stay there. Setting both variances to 11:

1=a2+βt,a=1−βt.\begin{aligned} 1 &= a^2 + \beta_t , \\ a &= \sqrt{1 - \beta_t} . \end{aligned}

This is DDPM’s step (Ho, Jain and Abbeel, 2020, Eq. 2):

xt=1−βt  xt−1+βt  ε,q(xt∣xt−1)=N(1−βt  xt−1,  βt).\begin{aligned} x_t &= \sqrt{1 - \beta_t}\; x_{t-1} + \sqrt{\beta_t}\;\varepsilon, \\ q(x_t \mid x_{t-1}) &= \mathcal N\big(\sqrt{1 - \beta_t}\; x_{t-1},\; \beta_t\big) . \end{aligned}
Figure

One step at a time, or straight from x₀ to xₜ

Naive and DDPM noising chains with their one-jump shortcutsTwo rows of circled nodes x0, x1, x2, an ellipsis and xt joined by step arrows. Top row, naive: each step adds square root of beta times epsilon; a long arc from x0 to xt is labelled q of xt given x0 equals N of x0 and t beta, with a red warning that the mean stays x0 and the variance t beta goes to infinity, so the chain never reaches N(0, 1). Bottom row, DDPM: each step multiplies by the square root of 1 minus beta and adds square root of beta times epsilon; the long arc is labelled q of xt given x0 equals N of square root of alpha bar t times x0 and 1 minus alpha bar t, with a green note that alpha bar t equals 1 minus beta to the power t, which goes to zero, so the chain approaches N(0, 1).Naive: xₜ = xₜ₋₁ + √β εx0x1x2xt…+ √β ε+ √β εq(xₜ | x₀) = N(x₀, tβ)mean stays x₀, variance tβ → ∞: never N(0, 1)DDPM: xₜ = √(1 − β) xₜ₋₁ + √β εx0x1x2xt…× √(1 − β)+ √β ε× √(1 − β)+ √β εq(xₜ | x₀) = N(√α̅ₜ x₀, 1 − α̅ₜ)α̅ₜ = (1 − β)ᵗ → 0, so → N(0, 1)Naive and DDPM noising chains with their one-jump shortcutsTwo rows of circled nodes x0, x1, x2, an ellipsis and xt joined by step arrows. Top row, naive: each step adds square root of beta times epsilon; a long arc from x0 to xt is labelled q of xt given x0 equals N of x0 and t beta, with a red warning that the mean stays x0 and the variance t beta goes to infinity, so the chain never reaches N(0, 1). Bottom row, DDPM: each step multiplies by the square root of 1 minus beta and adds square root of beta times epsilon; the long arc is labelled q of xt given x0 equals N of square root of alpha bar t times x0 and 1 minus alpha bar t, with a green note that alpha bar t equals 1 minus beta to the power t, which goes to zero, so the chain approaches N(0, 1).Naive: xₜ = xₜ₋₁ + √β εx0x1x2xt…q(xₜ | x₀) = N(x₀, tβ)mean stays x₀, variance tβ → ∞: never N(0, 1)DDPM: xₜ = √(1 − β) xₜ₋₁ + √β εx0x1x2xt…q(xₜ | x₀) = N(√α̅ₜ x₀, 1 − α̅ₜ)α̅ₜ = (1 − β)ᵗ → 0, so → N(0, 1)
Single steps and one-jump shortcuts for two chains; in both, t steps collapse into one Gaussian jump q(xₜ | x₀). Without rescaling (top) the mean stays at x₀ and the variance grows without bound. Scaling by √(1 − β) (bottom) shrinks the mean and keeps the variance 1 − α̅ₜ below 1.

The step leaves N(0,1)\mathcal N(0, 1) exactly unchanged. If xt−1∼N(0,1)x_{t-1} \sim \mathcal N(0, 1), then xtx_t is a linear combination of two independent standard normals, hence Gaussian (affine maps of Gaussians), with mean 00 and variance (1−βt)+βt=1(1 - \beta_t) + \beta_t = 1. A process whose step keeps unit variance is called variance-preserving.

There is also a reason the step pulls towards N(0,1)\mathcal N(0, 1) in particular. For small βt\beta_t a Taylor expansion gives 1−βt≈1−βt/2\sqrt{1 - \beta_t} \approx 1 - \beta_t/2; at βt=0.02\beta_t = 0.02 the two are 0.989950.98995 and 0.990.99. So

xt≈xt−1+βt2 (−xt−1)+βt ε.x_t \approx x_{t-1} + \frac{\beta_t}{2}\,(-x_{t-1}) + \sqrt{\beta_t}\,\varepsilon .

The score of N(0,1)\mathcal N(0, 1), the gradient of its log-density, is −x-x. The step is therefore one step of unadjusted Langevin dynamics with step size βt\beta_t towards the standard normal: a sampler for N(0,1)\mathcal N(0, 1), run from the image (Isachenko, 2025, lecture 7).

The jump from x₀ to any step#

Write

αt=1−βt,αˉt=∏s=1tαs,\begin{aligned} \alpha_t &= 1 - \beta_t , \\ \bar\alpha_t &= \prod_{s=1}^{t} \alpha_s , \end{aligned}

with αˉ0=1\bar\alpha_0 = 1. Two steps first, as in the lecture notes (lecture 5). Substitute the first step into the second, then expand:

x2=α2 x1+β2 ε2=α2(α1 x0+β1 ε1)+β2 ε2=α2α1 x0+α2β1 ε1+β2 ε2.\begin{aligned} x_2 &= \sqrt{\alpha_2}\, x_1 + \sqrt{\beta_2}\,\varepsilon_2 \\ &= \sqrt{\alpha_2}\big(\sqrt{\alpha_1}\, x_0 + \sqrt{\beta_1}\,\varepsilon_1\big) + \sqrt{\beta_2}\,\varepsilon_2 \\ &= \sqrt{\alpha_2 \alpha_1}\, x_0 + \sqrt{\alpha_2 \beta_1}\,\varepsilon_1 + \sqrt{\beta_2}\,\varepsilon_2 . \end{aligned}

Given x0x_0, this is x0x_0 times a constant plus two independent Gaussians, so it is Gaussian. Linearity of expectation gives its mean, and independence of ε1\varepsilon_1 and ε2\varepsilon_2 gives its variance as a sum:

E[x2∣x0]=α2α1 x0=αˉ2 x0,Var⁡(x2∣x0)=α2β1+β2.\begin{aligned} \mathbb E[x_2 \mid x_0] &= \sqrt{\alpha_2 \alpha_1}\, x_0 = \sqrt{\bar\alpha_2}\, x_0 , \\ \operatorname{Var}(x_2 \mid x_0) &= \alpha_2 \beta_1 + \beta_2 . \end{aligned}

The variance simplifies once we subtract it from 11 and use β=1−α\beta = 1 - \alpha:

1−α2β1−β2=α2−α2β1=α2α1=αˉ2.\begin{aligned} 1 - \alpha_2 \beta_1 - \beta_2 &= \alpha_2 - \alpha_2 \beta_1 \\ &= \alpha_2 \alpha_1 = \bar\alpha_2 . \end{aligned}

So q(x2∣x0)=N(αˉ2 x0, 1−αˉ2)q(x_2 \mid x_0) = \mathcal N\big(\sqrt{\bar\alpha_2}\, x_0,\ 1 - \bar\alpha_2\big). With toy values β1=0.1\beta_1 = 0.1 and β2=0.2\beta_2 = 0.2: αˉ2=0.72\bar\alpha_2 = 0.72, the mean coefficient is 0.72=0.849\sqrt{0.72} = 0.849, and the variance is 0.8⋅0.1+0.2=0.28=1−0.720.8 \cdot 0.1 + 0.2 = 0.28 = 1 - 0.72.

The same argument, repeated, is an induction on tt. Suppose xt−1=αˉt−1 x0+1−αˉt−1 ε′x_{t-1} = \sqrt{\bar\alpha_{t-1}}\, x_0 + \sqrt{1 - \bar\alpha_{t-1}}\,\varepsilon', where ε′\varepsilon' is a standard normal built from the noises of steps 1,…,t−11, \dots, t-1, so it is independent of the fresh ε\varepsilon. Substituting into the step:

xt=αt xt−1+βt ε=αtαˉt−1 x0+αt(1−αˉt−1) ε′+βt ε.\begin{aligned} x_t &= \sqrt{\alpha_t}\, x_{t-1} + \sqrt{\beta_t}\,\varepsilon \\ &= \sqrt{\alpha_t \bar\alpha_{t-1}}\, x_0 + \sqrt{\alpha_t (1 - \bar\alpha_{t-1})}\,\varepsilon' + \sqrt{\beta_t}\,\varepsilon . \end{aligned}

The mean coefficient is αˉt\sqrt{\bar\alpha_t} by the definition of αˉt\bar\alpha_t. The two independent noises merge into one Gaussian whose variance is the sum:

αt(1−αˉt−1)+βt=αt−αˉt+1−αt=1−αˉt.\begin{aligned} \alpha_t (1 - \bar\alpha_{t-1}) + \beta_t &= \alpha_t - \bar\alpha_t + 1 - \alpha_t \\ &= 1 - \bar\alpha_t . \end{aligned}

The base case t=1t = 1 is the step itself. Hence, for every tt,

  q(xt∣x0)=N(αˉt x0,  1−αˉt)  \boxed{\;q(x_t \mid x_0) = \mathcal N\big(\sqrt{\bar\alpha_t}\, x_0,\; 1 - \bar\alpha_t\big)\;}

or, as a recipe, xt=αˉt x0+1−αˉt εx_t = \sqrt{\bar\alpha_t}\, x_0 + \sqrt{1 - \bar\alpha_t}\,\varepsilon (Ho, Jain and Abbeel, 2020, Eq. 4). Here ε\varepsilon is the merged standard normal, so the equality holds in distribution. The two squared coefficients always add up to 11, the variance-preserving property again.

Why this reaches N(0, 1)#

If every βt\beta_t lies in some interval [βmin⁡,1)[\beta_{\min}, 1) with βmin⁡>0\beta_{\min} > 0, then αˉt≤(1−βmin⁡)t→0\bar\alpha_t \le (1 - \beta_{\min})^t \to 0. The image term αˉt x0\sqrt{\bar\alpha_t}\, x_0 goes to 00 and the noise coefficient 1−αˉt\sqrt{1 - \bar\alpha_t} goes to 11. A Gaussian density is a continuous function of its mean and variance, so it converges pointwise to N(0,1)\mathcal N(0, 1): q(xt∣x0)→N(0,1)q(x_t \mid x_0) \to \mathcal N(0, 1) for every x0x_0. For a constant β=0.02\beta = 0.02, so that αˉt=0.98t\bar\alpha_t = 0.98^t, the two chains compare as follows:

ttαˉt\bar\alpha_tmean coefficient αˉt\sqrt{\bar\alpha_t}noise std 1−αˉt\sqrt{1-\bar\alpha_t}naive noise std tβ\sqrt{t\beta}
10.9800.9900.1410.141
100.8170.9040.4280.447
500.3640.6030.7971.000
1000.1330.3640.9311.414
2000.01760.1330.9912.000

For small tt the two chains almost agree. Then the naive noise passes the target spread and keeps growing, while DDPM’s approaches 11 from below as the image fades.

Figure

Variance exploding versus variance preserving

Mean coefficient and noise standard deviation of q(xt | x0) over tTwo plots over t from 0 to 200 with beta equal to 0.02. A dashed green line at height 1 marks the target standard deviation of N(0, 1). Left or top, the naive variance-exploding chain: the red mean coefficient is flat at 1, so the mean does not change, while the blue noise standard deviation, the square root of t beta, crosses 1 at t equals 50 and keeps growing to 2. Right or bottom, the DDPM variance-preserving chain: the red mean coefficient, square root of alpha bar t, decays from 1 to about 0.13, and the blue noise standard deviation, square root of 1 minus alpha bar t, rises towards 1 and levels off there.Naive: variance exploding00.511.52050100150200tDDPM: variance preserving00.511.52050100150200tnoise std √(tβ)variance increasesindefinitelymean doesn't changetarget std 1mean shrinks: √α̅ₜ → 0noise std √(1 − α̅ₜ) → 1Mean coefficient and noise standard deviation of q(xt | x0) over tTwo plots over t from 0 to 200 with beta equal to 0.02. A dashed green line at height 1 marks the target standard deviation of N(0, 1). Left or top, the naive variance-exploding chain: the red mean coefficient is flat at 1, so the mean does not change, while the blue noise standard deviation, the square root of t beta, crosses 1 at t equals 50 and keeps growing to 2. Right or bottom, the DDPM variance-preserving chain: the red mean coefficient, square root of alpha bar t, decays from 1 to about 0.13, and the blue noise standard deviation, square root of 1 minus alpha bar t, rises towards 1 and levels off there.Naive: variance exploding00.511.52050100150200tDDPM: variance preserving00.511.52050100150200tnoise std √(tβ)variance increasesindefinitelymean doesn't changetarget std 1mean shrinks: √α̅ₜ → 0noise std √(1 − α̅ₜ) → 1
Coefficients of xₜ = (mean coefficient)·x₀ + (noise std)·ε for a constant β = 0.02. Naive chain: the mean coefficient stays 1 and the noise std √(tβ) reaches 2.0 at t = 200. DDPM chain: √α̅ₜ falls to 0.13 and √(1 − α̅ₜ) rises to 0.991. Dashed: the target std 1.

The whole data distribution follows. Its marginal at step tt is q(xt)=∫q(xt∣x0) q(x0) dx0q(x_t) = \int q(x_t \mid x_0)\, q(x_0)\, dx_0. The variance recursion above, with a2=αta^2 = \alpha_t and βt=1−αt\beta_t = 1 - \alpha_t, moves the distance of the variance from 11 by a factor αt\alpha_t at each step:

Var⁡(xt)−1=αtVar⁡(xt−1)+1−αt−1=αt(Var⁡(xt−1)−1)=αˉt(Var⁡(x0)−1),\begin{aligned} \operatorname{Var}(x_t) - 1 &= \alpha_t \operatorname{Var}(x_{t-1}) + 1 - \alpha_t - 1 \\ &= \alpha_t \big(\operatorname{Var}(x_{t-1}) - 1\big) \\ &= \bar\alpha_t \big(\operatorname{Var}(x_0) - 1\big) , \end{aligned}

where the last line repeats the step down to x0x_0. Hence Var⁡(xt)=αˉtVar⁡(x0)+1−αˉt\operatorname{Var}(x_t) = \bar\alpha_t \operatorname{Var}(x_0) + 1 - \bar\alpha_t, a weighted average of the data’s variance and 11. For a mixture of Gaussians the marginal stays a mixture. The integral over x0x_0 is linear, so each component can be pushed through separately, and a component N(μk,σk2)\mathcal N(\mu_k, \sigma_k^2) scaled by αˉt\sqrt{\bar\alpha_t} plus independent noise of variance 1−αˉt1 - \bar\alpha_t is again Gaussian (affine maps):

q(x0)=∑kπk N(μk,σk2),q(xt)=∑kπk N(αˉt μk,  sk,t2),sk,t2=αˉtσk2+1−αˉt.\begin{aligned} q(x_0) &= \textstyle\sum_k \pi_k\, \mathcal N(\mu_k, \sigma_k^2) , \\ q(x_t) &= \textstyle\sum_k \pi_k\, \mathcal N\big(\sqrt{\bar\alpha_t}\,\mu_k,\; s_{k,t}^2\big) , \\ s_{k,t}^2 &= \bar\alpha_t \sigma_k^2 + 1 - \bar\alpha_t . \end{aligned}

Every component is pulled towards mean 00 and variance 11. The figure below takes q(x0)=0.45 N(−1.3, 0.422)+0.55 N(1.25, 0.452)q(x_0) = 0.45\, \mathcal N(-1.3,\ 0.42^2) + 0.55\, \mathcal N(1.25,\ 0.45^2) and DDPM’s linear schedule. The two humps move together; counting the local maxima of the exact q(xt)q(x_t) on a fine grid, the density has two up to t=266t = 266 and one from t=267t = 267, where αˉt=0.48\bar\alpha_t = 0.48. It ends as a single bell curve.

Figure

The data distribution dissolves into N(0, 1)

Marginal density of xt at t = 0, 100, 300 and 1000Four small density plots joined by arrows. At t = 0 the red data density has two humps, at about minus 1.3 and plus 1.25. At t = 100, alpha bar 0.90, the humps are lower, wider and closer together. At t = 300, alpha bar 0.40, they have merged into one lopsided bump. At t = 1000, alpha bar about 0, the green density is the standard normal N(0, 1). Each panel also shows a jagged histogram of 600 noised samples.t = 0 (data)α̅ = 1q(x₀)t = 100α̅ = 0.90t = 300α̅ = 0.40t = 1000α̅ ≈ 4.0 × 10⁻⁵N(0, 1)Marginal density of xt at t = 0, 100, 300 and 1000Four small density plots joined by arrows. At t = 0 the red data density has two humps, at about minus 1.3 and plus 1.25. At t = 100, alpha bar 0.90, the humps are lower, wider and closer together. At t = 300, alpha bar 0.40, they have merged into one lopsided bump. At t = 1000, alpha bar about 0, the green density is the standard normal N(0, 1). Each panel also shows a jagged histogram of 600 noised samples.t = 0 (data)α̅ = 1q(x₀)t = 100α̅ = 0.90t = 300α̅ = 0.40t = 1000α̅ ≈ 4.0 × 10⁻⁵N(0, 1)
A 1-D mixture of two Gaussians, noised with DDPM's linear schedule (T = 1000). Curves: the exact marginals q(xₜ) = Σₖ πₖ N(√α̅ₜ μₖ, α̅ₜσₖ² + 1 − α̅ₜ). Bars: a histogram of 600 samples pushed through the same steps. The two humps merge and end as N(0, 1).

In practice: a β schedule#

The sequence β1,…,βT\beta_1, \dots, \beta_T is the schedule. DDPM uses T=1000T = 1000 steps and a linear schedule from β1=10−4\beta_1 = 10^{-4} to βT=0.02\beta_T = 0.02 (Ho, Jain and Abbeel, 2020, §4). Small steps at the start keep the early xtx_t close to the image; larger steps later finish the job. With this schedule αˉt\bar\alpha_t falls below 0.50.5 at t=260t = 260 and below 0.010.01 at t=674t = 674, and it ends at αˉ1000=4.0×10−5\bar\alpha_{1000} = 4.0 \times 10^{-5}: the image term of x1000x_{1000} is scaled by αˉ1000=0.0064\sqrt{\bar\alpha_{1000}} = 0.0064.

Figure

A linear β schedule and the resulting α̅ₜ

Linear beta schedule and alpha bar over 1000 stepsTwo plots sharing the time axis t from 0 to 1000. The upper plot shows beta t as a straight amber line rising from 0.0001 to 0.02. The lower plot shows alpha bar t, the running product of 1 minus beta, as a falling curve that starts at 1, decreases slowly at first, crosses 0.5 at about t equals 259, falls below 0.01 at t equals 674, and is about 4 times 10 to the minus 5 at t equals 1000.00.010.02βtlinear, 10⁻⁴ → 0.0200.250.50.75102004006008001000tα̅t = ∏ (1 − βi)α̅ₜ ≈ 0.5 at t ≈ 259α̅ₜ < 0.01 from t = 674:x₀ is almost gone, xₜ ≈ εLinear beta schedule and alpha bar over 1000 stepsTwo plots sharing the time axis t from 0 to 1000. The upper plot shows beta t as a straight amber line rising from 0.0001 to 0.02. The lower plot shows alpha bar t, the running product of 1 minus beta, as a falling curve that starts at 1, decreases slowly at first, crosses 0.5 at about t equals 259, falls below 0.01 at t equals 674, and is about 4 times 10 to the minus 5 at t equals 1000.00.010.02βtlinear, 10⁻⁴ → 0.0200.250.50.75102505007501000tα̅t = ∏ (1 − βi)α̅ₜ ≈ 0.5 at t ≈ 259α̅ₜ < 0.01 from t = 674:x₀ is almost gone, xₜ ≈ ε
Top: βₜ grows linearly from 10⁻⁴ to 0.02. Bottom: α̅ₜ = ∏ (1 − βᵢ) falls slowly at first, is ≈ 0.5 at t ≈ 259, drops below 0.01 at t = 674 and ends at 4.0 × 10⁻⁵.

A schedule can also be read as a signal-to-noise ratio,

SNRt=αˉt1−αˉt,\mathrm{SNR}_t = \frac{\bar\alpha_t}{1 - \bar\alpha_t} ,

the squared coefficient of the image over the variance of the noise. For the linear schedule it falls from 10410^4 at t=1t = 1 to 4.0×10−54.0 \times 10^{-5} at t=Tt = T. Continuous-time diffusion models parameterize the schedule by this ratio directly (Murphy, 2023, §25.2.4).

Linear, quadratic, sigmoid and cosine schedules#

Write ut=(t−1)/(T−1)∈[0,1]u_t = (t - 1)/(T - 1) \in [0, 1] for the position in the chain. With the same endpoints β1=10−4\beta_1 = 10^{-4} and βT=0.02\beta_T = 0.02, three common shapes are defined through βt\beta_t:

linear:βt=β1+(βT−β1) ut,quadratic:βt=(β1+(βT−β1) ut)2,sigmoid:βt=β1+(βT−β1) st,st=sigmoid⁡(12 ut−6).\begin{aligned} \text{linear:}\quad & \beta_t = \beta_1 + (\beta_T - \beta_1)\, u_t , \\ \text{quadratic:}\quad & \beta_t = \big(\sqrt{\beta_1} + (\sqrt{\beta_T} - \sqrt{\beta_1})\, u_t\big)^2 , \\ \text{sigmoid:}\quad & \beta_t = \beta_1 + (\beta_T - \beta_1)\, s_t , \\ & s_t = \operatorname{sigmoid}(12\, u_t - 6) . \end{aligned}

The quadratic schedule interpolates the noise amplitude βt\sqrt{\beta_t} linearly, so its steps stay small for longer. The sigmoid schedule is flat at both ends and makes its change in the middle; since sigmoid⁡(±6)\operatorname{sigmoid}(\pm 6) is not exactly 00 or 11, its βt\beta_t actually run from 1.5×10−41.5 \times 10^{-4} to 0.019950.01995.

The cosine schedule prescribes αˉt\bar\alpha_t instead and derives the steps from it, using αˉt=αtαˉt−1\bar\alpha_t = \alpha_t \bar\alpha_{t-1} (Nichol and Dhariwal, 2021, Eq. 17):

f(t)=cos⁡2 ⁣(t/T+s1+s⋅π2),αˉt=f(t)f(0),βt=1−αˉtαˉt−1.\begin{aligned} f(t) &= \cos^2\!\Big(\frac{t/T + s}{1 + s} \cdot \frac{\pi}{2}\Big) , \\ \bar\alpha_t &= \frac{f(t)}{f(0)} , \\ \beta_t &= 1 - \frac{\bar\alpha_t}{\bar\alpha_{t-1}} . \end{aligned}

The offset s=0.008s = 0.008 keeps the first step’s noise amplitude just below the width 1/127.51/127.5 of one pixel level, and βt\beta_t is clipped at 0.9990.999: without the clip, f(T)=0f(T) = 0 would give βT=1\beta_T = 1.

Figure

Four noise schedules: how α̅ₜ falls

Alpha bar for linear, quadratic, sigmoid and cosine schedulesFour falling curves of alpha bar t over steps 0 to 1000, all starting at 1. The linear one falls first and crosses 0.5 at t equals 260; the quadratic crosses 0.5 at 419, the sigmoid at 440, and the cosine at 497, staying clearly above zero the longest.00.250.50.75102004006008001000tα̅tlinearquadraticsigmoidcosineAlpha bar for linear, quadratic, sigmoid and cosine schedulesFour falling curves of alpha bar t over steps 0 to 1000, all starting at 1. The linear one falls first and crosses 0.5 at t equals 260; the quadratic crosses 0.5 at 419, the sigmoid at 440, and the cosine at 497, staying clearly above zero the longest.00.250.50.75102505007501000tα̅tlinearquadraticsigmoidcosine
α̅ₜ for four schedules with T = 1000: linear, quadratic and sigmoid with β from 10⁻⁴ to 0.02, and cosine with s = 0.008. Dots mark where α̅ₜ first drops below 0.5: t = 260, 419, 440 and 497. Compare how long each stays at medium noise.

With T=1000T = 1000:

scheduleαˉt<0.5\bar\alpha_t < 0.5 fromαˉt<0.01\bar\alpha_t < 0.01 fromαˉ1000\bar\alpha_{1000}
lineart=260t = 260t=674t = 6744.0×10−54.0 \times 10^{-5}
quadratict=419t = 419t=851t = 8517.3×10−47.3 \times 10^{-4}
sigmoidt=440t = 440t=721t = 7214.0×10−54.0 \times 10^{-5}
cosinet=497t = 497t=936t = 9362.4×10−92.4 \times 10^{-9}

The linear schedule destroys the image fastest: from t=674t = 674 on less than 1%1\% of the signal variance is left, so its last third works on almost pure noise. Nichol and Dhariwal observed on ImageNet 64×6464 \times 64 that a model trained with it barely loses FID when up to 20%20\% of the reverse process, the noisiest end, is skipped. Their cosine schedule falls almost linearly through the middle and crosses 0.50.5 near T/2T/2; with T=4000T = 4000 it improved FID from 31.331.3 to 27.027.0 on that dataset (their Table 1).

Where it breaks: a chain too short to forget#

Generation starts from N(0,1)\mathcal N(0, 1), but the chain ends at q(xT∣x0)q(x_T \mid x_0). The mismatch is the KL divergence between the two, which the next note meets as the term LTL_T of the training bound. For one pixel, the KL divergence between two 1-D Gaussians (derived here) with μP=αˉT x0\mu_P = \sqrt{\bar\alpha_T}\, x_0, σP2=1−αˉT\sigma_P^2 = 1 - \bar\alpha_T and Q=N(0,1)Q = \mathcal N(0, 1) is

LT=DKL(q(xT∣x0) ∥ N(0,1))=12(1−αˉT+αˉTx02−1−ln⁡(1−αˉT)).\begin{aligned} L_T &= D_{\mathrm{KL}}\big(q(x_T \mid x_0) \,\|\, \mathcal N(0, 1)\big) \\ &= \tfrac12\big(1 - \bar\alpha_T + \bar\alpha_T x_0^2 - 1 - \ln(1 - \bar\alpha_T)\big) . \end{aligned}

Compare two chains on a pixel at x0=1x_0 = 1, the brightest value:

chainαˉT\bar\alpha_Tq(xT∣x0=1)q(x_T \mid x_0 = 1)LTL_T, bits
DDPM, T=1000T = 1000, linear4.0×10−54.0 \times 10^{-5}N(0.0064, 1.0000)\mathcal N(0.0064,\ 1.0000)2.9×10−52.9 \times 10^{-5}
toy, T=100T = 100, sigmoid from 10−510^{-5} to 10−210^{-2}0.6050.605N(0.78, 0.40)\mathcal N(0.78,\ 0.40)0.670.67

For pixels spread uniformly over [−1,1][-1, 1], E[x02]=1/3\mathbb E[x_0^2] = 1/3 and DDPM’s chain gives LT=9.7×10−6L_T = 9.7 \times 10^{-6} bits per pixel, in line with the ”≈10−5\approx 10^{-5} bits per dimension” that Ho, Jain and Abbeel report (§4). The toy chain keeps 78%78\% of the image’s amplitude at its last step. A sampler that starts from N(0,1)\mathcal N(0, 1) then starts from the wrong distribution: its first reverse steps are trained on inputs that still show the image, and they are handed pure noise.

Scale matters for the same reason. The image term αˉT x0\sqrt{\bar\alpha_T}\, x_0 is small only relative to x0x_0. DDPM maps pixel values 0,…,2550, \dots, 255 to [−1,1][-1, 1]; on the raw scale the leftover image at T=1000T = 1000 would reach 255⋅0.0064=1.6255 \cdot 0.0064 = 1.6, larger than the noise.

What you should remember#

  • One step: xt=1−βt xt−1+βt εx_t = \sqrt{1 - \beta_t}\, x_{t-1} + \sqrt{\beta_t}\,\varepsilon; the factor 1−βt\sqrt{1 - \beta_t} keeps unit variance fixed.
  • Any step in one draw: xt=αˉt x0+1−αˉt εx_t = \sqrt{\bar\alpha_t}\, x_0 + \sqrt{1 - \bar\alpha_t}\,\varepsilon with αˉt=∏s≤t(1−βs)\bar\alpha_t = \prod_{s \le t}(1 - \beta_s).
  • Without rescaling, the variance tβt\beta explodes and the mean never moves.
  • For small βt\beta_t the step is a Langevin step towards N(0,1)\mathcal N(0, 1).
  • DDPM: T=1000T = 1000, linear β\beta from 10−410^{-4} to 0.020.02, αˉT=4×10−5\bar\alpha_T = 4 \times 10^{-5}; the cosine schedule spends more steps at medium noise.
  • A chain that ends far from N(0,1)\mathcal N(0, 1) makes sampling start from the wrong distribution.

Notebook#

The diffusion notebook of the HSE-LAMBDA Deep Generative Models repository works on a 2-D Swiss roll of 10,000 points with T=100T = 100 steps. The notebook has no saved outputs, so it documents procedures rather than results. Its forward part:

  • The step-by-step chain with a constant β=0.0005\beta = 0.0005, for which αˉ100=0.951\bar\alpha_{100} = 0.951: after 100 steps the roll is still almost intact.
  • make_beta_schedule with the linear, quadratic and sigmoid shapes above, called with the sigmoid shape from 10−510^{-5} to 10−210^{-2}; the actual βt\beta_t run from 3.5×10−53.5 \times 10^{-5} to 0.01000.0100, and αˉ100=0.605\bar\alpha_{100} = 0.605.
  • q_sample, the one-draw jump xt=αˉt x0+1−αˉt εx_t = \sqrt{\bar\alpha_t}\, x_0 + \sqrt{1 - \bar\alpha_t}\,\varepsilon, plotted for several tt: independent draws for each tt, not one trajectory.

The schedule is the toy chain of the failure above: the reverse samplers later in the notebook start from N(0,I)\mathcal N(0, I), although q(x100∣x0)=N(0.78 x0, 0.40 I)q(x_{100} \mid x_0) = \mathcal N(0.78\, x_0,\ 0.40\, I). The reverse part is described in the next note.

Next#

We now have a process that turns any image into noise indistinguishable from N(0,I)\mathcal N(0, I), and a formula for every intermediate step. Running it backwards needs the reverse step q(xt−1∣xt)q(x_{t-1} \mid x_t), which depends on the unknown data distribution. DDPM: reverse process and training objective trains a network to imitate it, starting from a bound on the likelihood.

References#