AI, machine learning and deep learning · Advanced

Diffusion model noising schedule

Written by SignalsLab

Early edition: these lessons are being reviewed.

Content

Summary

A diffusion model gradually corrupts data with Gaussian noise over T steps according to a noising schedule that sets how much signal survives at each step. The schedule, defined by βt or α‾t, determines the signal-to-noise ratio trajectory and strongly affects training and sample quality.

Intuition

Imagine slowly turning a photo into static. The forward process adds a small amount of noise at each step, and because Gaussians compose, you can jump directly to any step t in closed form. The schedule is the pace of this destruction. A linear beta schedule destroys information quickly in the later steps, so many steps are wasted on nearly pure noise. A cosine schedule keeps α‾ changing smoothly, so signal-to-noise ratio falls more evenly and the model learns useful denoising at all noise levels. Thinking in terms of log signal-to-noise ratio makes schedules comparable: a schedule is just a monotone curve of SNR against time, and the sampler walks that curve backwards.

Key equations

q(xt∣xt−1)=𝒩(1−βtxt−1,βtI)
(1)

One forward noising step with variance beta_t.

α‾t=∏s=1t(1−βs)
(2)

Cumulative signal retention after t steps.

xt=α‾tx0+1−α‾tϵ,ϵ∼𝒩(0,I)
(3)

Closed-form sampling of x_t directly from x_0.

SNR(t)=α‾t1−α‾t
(4)

Signal-to-noise ratio at step t; schedules are curves of this quantity.

α‾t=f(t)f(0),f(t)=cos2⁡(t/T+s1+s⋅π2)
(5)

Cosine schedule (Nichol and Dhariwal), with small offset s.

Derivation

  1. Define a single step: xt=αtxt−1+1−αtεt−1, with αt=1−βt.
  2. Substitute xt−1=αt−1xt−2+1−αt−1εt−2.
  3. The two noise terms are independent Gaussians with variances alpha_t(1-alpha_{t-1}) and 1-alpha_t; their sum has variance 1 - alpha_t alpha_{t-1}.
  4. So xt=αtαt−1xt−2+1−αtαt−1ε.
  5. Repeat by induction to get xt=α‾tx0+1−α‾tε.
  6. Variance is preserved when x0 has unit variance: α‾t+(1−α‾t)=1.
  7. Hence the schedule is fully captured by α‾t, or equivalently log⁡SNR(t)=log⁡(α‾t1−α‾t).

Worked example

Problem

Linear schedule with T=1000, beta from 1e-4 to 0.02. Approximate alpha-bar at t=500 and the SNR.

  1. Beta at step s is about 1e-4 + (0.02-1e-4)(s/1000) ≈ 1e-4 + 0.0199 s/1000.
  2. log⁡(α‾t)≈−∑βs for small β (more precisely ∑log⁡(1−βs)≈−∑βs−∑βs2/2).
  3. Sum of beta over 500 steps ≈ 500·1e-4 + 0.0199·(500²/2)/1000 = 0.05 + 2.4875 = 2.5375.
  4. Second-order correction: sum beta²/2 is about 0.0199²/(2·10⁶)·(500³/3)=0.0199²·41.7/2·... ≈ 0.008 (small), so log alpha-bar ≈ -2.546.
  5. α-bar ≈e−2.546≈0.078.
  6. SNR = 0.078/(1-0.078) ≈ 0.085.

Answer alpha-bar_500 ≈ 0.08 and SNR ≈ 0.085 (log SNR ≈ -2.5): by the midpoint the signal is already mostly destroyed.

Common mistakes

  • Confusing βt (per-step noise) with α‾t (cumulative signal retention).
  • Summing betas instead of multiplying (1−β) for α‾; the sum is only a small-β approximation.
  • Assuming a schedule tuned for 64x64 images works unchanged at higher resolution; higher resolution needs more noise to reach the same SNR.
  • Believing the final step reaches exactly zero SNR; with a non-zero terminal SNR, train-sampling mismatch leaks signal (fixed by zero-terminal-SNR rescaling).
  • Using too many steps at near-pure-noise levels, wasting model capacity.

Animation

Animation coming soon

The animated version of this lesson is being prepared for the web. In the Signals AI app, lessons are drawn step by step.

Code

scene.py(79 lines)
import sys
from manim import *
from blocks import *
import numpy as np

T = 50


def make_schedule(T=T, b0=1e-4, b1=0.15):
    """Linear beta schedule and cumulative alpha-bar."""
    betas = np.linspace(b0, b1, T)
    abar = np.cumprod(1.0 - betas)
    return betas, abar


def noise_trace(abar, n=24, seed=0):
    """Forward process x_t = sqrt(abar)x0 + sqrt(1-abar) eps, with fixed eps."""
    rng = np.random.default_rng(seed)
    xs = np.linspace(-1, 1, n)
    x0 = np.sin(np.pi * xs)
    eps = rng.standard_normal(n)
    snaps = {}
    for t in (0, 10, 25, T - 1):
        snaps[t] = np.sqrt(abar[t]) * x0 + np.sqrt(1 - abar[t]) * eps
    return xs, x0, eps, snaps


betas, abar = make_schedule()
XS, X0, EPS, SNAPS = noise_trace(abar)


class Main(Scene):
    def construct(self):
        self.camera.background_color = "#111118"
        TitleCard(self, "Diffusion noising schedule", "Forward process")
        # left: alpha-bar curve
        cp = CurvePlot(lambda t: float(np.interp(t, np.arange(T), abar)),
                       x_range=(0, T - 1, 10), y_range=(0, 1, 0.5),
                       x_label="t", y_label="abar", color=C_ACCENT,
                       x_length=5.0, y_length=3.3)
        cp.to_edge(LEFT, buff=0.7).shift(0.1 * UP)
        self.play(Create(cp.axes), FadeIn(cp.labels), Create(cp.curve), run_time=2)
        eq = MathTex(r"x_t=\sqrt{\bar\alpha_t}\,x_0+\sqrt{1-\bar\alpha_t}\,\epsilon",
                     font_size=30).to_edge(UP, buff=1.1).shift(3 * RIGHT)
        self.play(Write(eq))
        # right: signal axes
        ax = Axes(x_range=[-1, 1, 1], y_range=[-3, 3, 1], x_length=5.5, y_length=3.0,
                  axis_config={"color": C_DIM, "include_tip": False})
        ax.next_to(eq, DOWN, buff=0.4).align_to(eq, RIGHT)
        self.play(Create(ax))
        dot = Dot(cp.axes.c2p(0, abar[0]), color=C_BAD, radius=0.08)
        self.add(dot)
        prev = None
        for t in (0, 10, 25, T - 1):
            y = SNAPS[t]
            pts = VGroup(*[Dot(ax.c2p(a, b), radius=0.05, color=C_MAIN)
                           for a, b in zip(XS, y)])
            lab = Text(f"t={t}", font_size=24, color=C_GOOD).next_to(ax, UP, buff=0.05).align_to(ax, LEFT)
            new = VGroup(pts, lab)
            tgt = cp.axes.c2p(t, abar[t])
            if prev is None:
                self.play(FadeIn(new), dot.animate.move_to(tgt), run_time=0.8)
            else:
                self.play(FadeOut(prev), FadeIn(new), dot.animate.move_to(tgt), run_time=0.8)
            prev = new
            self.wait(0.6)
        StepCaption(self, "Signal fades as abar goes to 0; the data becomes pure noise.")
        self.wait(1.5)


if __name__ == "__main__" and "--selftest" in sys.argv:
    b, a = make_schedule()
    assert len(a) == T and np.all(np.diff(a) < 0)
    assert abs(a[0] - (1 - b[0])) < 1e-12
    assert a[-1] < 0.2, a[-1]
    xs, x0, eps, sn = noise_trace(a)
    assert np.allclose(sn[T - 1], np.sqrt(a[-1]) * x0 + np.sqrt(1 - a[-1]) * eps)
    assert np.std(sn[T - 1] - x0) > np.std(sn[0] - x0)
    print("ok")

The Manim scene code that draws this lesson's animation in the Signals AI app (Python, Manim Community).

ccBYNC© 2026 SignalsLab. Lesson text shared as is under CC BY-NC 4.0.