mlgenerate.comVisual Generative ML
All Models/image/DDPM Diffusion

Denoising Diffusion Probabilistic Models (DDPM)

Diffusion2020 · UC Berkeley (Ho et al.)

Iterative Gaussian score denoising reversing a Markov corruption chain

Execution Paradigm:Iterative Reverse Denoising Sampling (O(K) Forward Passes)
Iterative Denoising Sequence (Full Canvas Parallel per Step)

Intuition & Key Idea

ELI5 Guide

Why this model was invented and how it transforms generation

The 30-Second Core Idea

"Gradually turns static television noise into a crystal-clear photorealistic image by learning to subtract tiny amounts of noise step-by-step."

Real-World Metaphor

A sculptor carving a statue: starting with a rough, amorphous block of marble and chipping away tiny flakes layer-by-layer until a smooth sculpture appears.

Key Superpowers & Values
Training StabilityUltra Stable
100% Convex MSE

No adversarial collapse; predicts added Gaussian noise directly.

Visual DiversityTop Diversity
High Mode Coverage

Captures rare corners of image distributions without mode dropping.

Inference StepsIterative
20 – 50 Steps (DDIM)

Progressively denoises from pure Gaussian white noise to clean pixels.

Core ArchitectureScore Matching
U-Net / Transformer

Predicts noise vector ε_θ(x_t, t) conditioned on timestep t.

1. Sample Pure Gaussian White Noise x_T

Draw initial state x_T ~ 𝒩(0, I) from standard normal distribution. At this point, the canvas contains zero discernible structural signal.

Key Insight:

The generator begins completely unconstrained in the high-dimensional noise space.

Interactive Stage (INFERENCE)Canvas is 100% random Gaussian white noise.
DDPM Reverse Denoising SamplingNoise Factor: 100%

Starting from random Gaussian white noise, the neural network predicts and subtracts the noise component over iterative steps.

Simulated 8×8 Latent Patch (x_t)
Signal √ᾱ_t: 0%Noise √(1 - ᾱ_t): 100%
State Equation & Score Function
x_{t-1} = μ_θ(x_t, t) + σ_t · z
Loss: L_simple = ||ε - ε_θ(x_t, t)||^2
Forward Pass:O(K) Iterative Steps
Network Architecture:U-Net or Diffusion Transformer (DiT)
Hardware & Weights InspectorStep 1: Sample Pure Gaussian White Noise x_T
Execution Bottleneck
Communication-Bound
Calculated via Arithmetic Intensity
Arithmetic Intensity
Dynamic per batch
Ratio of math operations (FLOPs) to memory traffic (Bytes)
Dominant GPU Kernel
FlashAttention-2 / CuBLAS GEMM
Optimized CUDA / Triton kernel launched

GPU Memory Hierarchy & HBM Traffic for this Step

HBM ↔ SRAM on-chip

Weights are loaded from High-Bandwidth Memory (HBM) into Streaming Multiprocessor (SM) registers and SRAM cache for computation.

Active Tensor Dimensions & Memory Shapes

x_T[B, C, H, W]
Initial white noise canvas
sample_ddpm_reverse.py
1
def sample_ddpm(model, shape, T):
2
x = torch.randn(shape) # x_T pure Gaussian white noise
3
for t in reversed(range(1, T + 1)):
4
t_tensor = torch.full((shape[0],), t, dtype=torch.long)
5
eps_pred = model(x, t_tensor)
6
z = torch.randn_like(x) if t > 1 else 0
7
x = compute_x_prev(x, eps_pred, t, z) # Denoise 1 step
8
return x # x_0 clean image
Click code line to jump to corresponding stepPyTorch Reference
Why This Architecture Matters

Overcame the training instability and mode collapse of GANs, serving as the foundational mathematical engine behind Stable Diffusion, Midjourney, and DALL-E 2/3.

Runtime Complexity & Bottlenecks

Training Objective:Simplified L_simple MSE Loss: 𝔼_{t, x_0, ε}[ ||ε - ε_θ(x_t, t)||^2 ]

Inference Bottleneck:O(K) full-image U-Net forward passes (typically 20–1000 steps)