12.1 The Forward Process

DATA 443/643 · Week 12 · PDF · Slides

Jump to x_t in one shot. α-bar from 1 to 0. The kernel is not learned.

These notes match the lecture slides. Use (slides) on the course hub for the deck.

A diffusion model learns to denoise. The forward process is not learned. You add Gaussian noise on a schedule until the sample is almost prior noise. Training later asks a net to predict that noise. By the end you should be able to write αt and α¯t, jump to any t in one line, and say why that jump is nicer to train than a GAN min-max.


1. What the diffusion forward process is

Diffusion (DDPM) destroys a sample with Gaussian noise on a schedule, then later learns to reverse it. Start from data x0. A variance schedule 0<βt<1 (small at first, larger later) defines a Markov chain x0→x1→⋯→xT. At t=0 you still have the data. At t=T you have nearly isotropic noise.

The forward kernel is fixed. There is no θ in q. You do not have to simulate every hop. The marginal q(xt∣x0) is a closed-form Gaussian that interpolates from data to noise, so you can jump to any t in one shot.

In code that jump is one line: sample ε~𝒩(0,𝐈) and mix it with x0 using α¯t. Training (note 12.2) samples a random t, draws ε, forms xt in one shot, and asks a net to guess ε. You never need to walk 1,2,…,t unless you want a picture of the path.


2. Why we use it

GANs fight a min-max. Diffusion trains a denoiser with MSE. The kernel is not learned, so there is no discriminator to race. The training signal at each t is a denoising regression against a known ε.

Coverage is not automatic, but you are not playing an adversarial game. That is the trade this week is for. You still have to pick {βt} and T. Sampling will be a reverse chain (note 12.2), which is slower than one GAN forward pass.

Likelihood-related bounds exist for this family in a way they do not for a vanilla GAN. You do not need the ELBO on the board today. You need: the forward process is a fixed noising schedule, and that is why the loss can be ordinary regression.


3. Architecture

The architecture of this note is a Markov chain, not a U-Net. (The net arrives in note 12.2.) A variance schedule βt or, equivalently, α¯t falling from near 1 to near 0, defines

αt=1−βt,α¯t=∏s=1tαs.

The Markov step is q(xt∣xt−1)=𝒩(xt;αtxt−1,βt𝐈). The marginal is closed form, so training never has to unroll the chain.

A clean point becoming isotropic noise over t

α¯t starts near 1 (the point is still itself) and falls toward 0 (the point is almost ε). Linear, cosine, and learned βt are all ways to spend more steps where structure dies. Too fast a schedule and early t is already junk; too slow and you waste capacity on near-copies of x0.

T (often 1000 in image papers) is a discretization. Lab 12 uses a small T in 2-D so you can plot the path. Print α¯1, α¯T/2, α¯T: they should fall.


4. How it works, step by step

The whole point of this note is that you can skip the chain at train time.

  1. Choose a schedule {βt} and precompute αt=1−βt and α¯t=∏s=1tαs.
  2. Take a clean sample x0 (Lab 12: a 2-D point).
  3. Draw a timestep t (training will draw it at random) and a noise ε~𝒩(0,𝐈).
  4. Form xt=α¯tx0+1−α¯tε in one shot. Do not loop s=1,…,t.
  5. Hold xt and ε for the reverse note: the net will be asked to guess ε.

If α¯t=1, then xt=x0. If α¯t=0, then xt=ε. Mid-range α¯t is a mix: more noise than signal once α¯t is no longer close to 1. Same arithmetic in Lab 12 with a vector x0=(1.5,−0.8) and a vector ε. The square roots are scalar; they multiply every coordinate.


5. Mathematical formulas

The one-step kernel and the closed-form marginal are

q(xt∣xt−1)=𝒩(xt;αtxt−1,βt𝐈), q(xt∣x0)=𝒩(xt;α¯tx0,(1−α¯t)𝐈).

The reparameterization you type in code is

xt=α¯tx0+1−α¯tε,ε~𝒩(0,𝐈).

That one-liner is why the loss never walks 1,…,t.


6. Positive points and negative points

Positive.

  • The forward kernel is fixed, so the training target is a known ε rather than a moving adversary.
  • You can jump to any t with one Gaussian draw, which makes training a single MSE later.
  • The schedule is inspectable: print α¯1, α¯T/2, α¯T and watch them fall.
  • The same algebra runs in Lab 12’s 2-D points and in image DDPMs.

Negative.

  • The forward process is the easy half. Reverse sampling (note 12.2) is slow: you pay many network calls.
  • A too-fast {βt} crashes α¯t in a few steps and the net never sees a lightly noised x0.
  • A too-slow schedule wastes capacity on near-copies of the data.
  • This is not a GAN: you gave up one-pass sampling in exchange for a stable regression.

When not to. If you need a sample in one forward pass and you can live with coverage bugs, that is still a GAN (Week 11).


7. Teaching this note

About 35 minutes at the board, then ~6 minutes of video. First of three Week-12 notes.

  • 0–12 min. Markov step vs closed-form marginal. Write αt and α¯t.
  • 12–22 min. The one-line reparameterization. Draw x0 mixing with ε.
  • 22–33 min. Worked scalar step. Change α¯t from 1 to 0 and watch xt.
  • Then play Umar Jamil 7:35–13:00 (forward/reverse cartoon, then the math of q). Pause on the closed-form q(xt∣x0).

8. Worked example

Take a 1-D point x0=1.0 and a draw ε=2.0. Then

xt=α¯tx0+1−α¯tε.
α¯t α¯tx0 1−α¯tε xt
1 1.0 0 1.0
0.64 0.8 0.6×2.0=1.2 2.0
0 0 2.0 2.0

At α¯t=0.64 you already sit at 2.0: more noise than signal. At α¯t=0 you have thrown x0 away; xt is just ε.

Same arithmetic in Lab 12 with a vector x0=(1.5,−0.8) and a vector ε. The square roots are scalar; they multiply every coordinate.

You can jump to any t without simulating q(xs∣xs−1) for s=1,…,t. That is why training is a single Gaussian draw, not a loop of length t.

Three <math xmlns=α¯t values on x0=1, ε=2" src="files/graphics/12.1-diffusion-forward/alphabar.png" />

Pick a noise level, corrupt x, then learn to undo a bit. The closed-form jump is why the loss never walks 1,…,t.


9. Where students get stuck

  • Simulating all T Markov steps at train time. You sample t and use q(xt∣x0).
  • Mixing up βt, αt, and α¯t. Write the three definitions every time.
  • Setting every βt huge. Then α¯t crashes in a few steps and the net never sees a lightly noised x0.

10. Video

Watch Umar Jamil, How diffusion models work, 7:35–13:00.

Pause on the forward process q (no θ) and the closed-form jump to xt. Skip the U-Net coding (after ~16:30) in this class. Note 12.2 continues the same video at the training/sampling chapters.


11. Practice

  1. If α¯t=1, what is xt? If α¯t=0, what is xt?

  2. Why can you sample xt in one line instead of looping t steps of q(xs∣xs−1)?

  3. A classmate sets every βt=0.9. What goes wrong in the first few t?

  4. x0=4, α¯t=0.25, ε=−1. Compute xt. (0.25=0.5, 0.75≈0.866.)

  5. β1=0.1, β2=0.2. Compute α1,α2,α¯2.