A diffusion model is one network, the denoiser, trained to undo a known amount of Gaussian noise at every noise level; generating is starting from pure noise and calling that network again and again. Four choices around the network decide whether it works: how noise is added (the schedule), what the network is asked to output (the target and its loss), how its answers are chained into a path (the sampler and its step count), and how hard each step is pushed toward the prompt (guidance).
Fig. 1, step by step: the page's two-moons toy, a distribution you can see
The same on images. The card beside does it with the tiny image model on a Fashion-MNIST dress.
Running example. The root's tiny diffusion model (TinyUNet, 1,040,353 parameters, 4,000 training steps on Fashion-MNIST, 28 × 28 grey clothing in 10 classes, on an Apple M1 Pro) with the checkpoint, noise and scoring of the topic's diffusion runs (root src/diff), so the tiny-model numbers agree across the topic's pages; Stable Diffusion v1.5 at real scale. FD is the Fréchet distance between 1,000 samples and the test set in a Fashion-MNIST classifier's feature space (lower is better; 1,000 real images score 18.9); accuracy is how often that classifier recognises the requested class (real 94.2%); diversity, the mean feature distance within a class (real 28.87).
Top: the first Fashion-MNIST test dress noised with the tiny model's linear schedule, computed in your browser from one seeded noise draw. Bottom: a recorded run of the topic's tiny diffusion model (root Diffusion lab recordings) asked for a dress (DDIM, 20 network calls, no guidance), showing after each call the model's current guess of the clean image: the outline is there after a few calls, the detail comes last.
| Decision | What it sets | Stable Diffusion 1.5's choice | What goes wrong |
|---|---|---|---|
| Noise schedule (section 2) | How much signal is left at each of the 1,000 training steps | scaled-linear, β 0.00085 to 0.012; 6.8% of each value's amplitude survives the last step | The average brightness survives too, so the model can never make very dark or very bright images |
| Target and loss weighting (section 3) | Whether the network outputs the noise, the clean image or a mix (v), and how much each noise level counts in the loss | noise (ε), plain mean squared error, timesteps drawn uniformly | ε cannot work where no signal is left; the loss spends most of its weight on nearly clean images |
| Sampler (section 5) | The rule that turns predictions into a path from noise to image, and how many network calls it takes | PNDM in the repo config; DPM-Solver++ 2M at 20 to 25 steps in practice | The wrong timesteps, the wrong starting noise scale, or a deterministic sampler on a model whose errors need noise to wash out |
| Guidance (section 6) | How hard each step is pushed toward the prompt | classifier-free guidance, scale 7.5, two network calls per step | Oversaturated colours and lost variety at high scale; fixes: rescale, a guidance interval, autoguidance |
| Step reduction (section 7; the methods on Latent diffusion, section 10) | Whether a second, distilled model replaces many steps by one to four | none (LCM-LoRA is an add-on, run in section 7) | Distilled models lose guidance control and some diversity; each method needs its own scheduler |
The problem. Nobody can write down the distribution of real images, so nobody can sample it directly. The other direction is easy: take a real image and add noise until nothing is left. A diffusion model learns to reverse that destruction in small steps; then it can start from pure noise, which anyone can sample, and walk back to an image.
Concretely. DDPM's schedule, which the tiny model uses, destroys an image over T = 1,000 steps: step t shrinks the image slightly and adds Gaussian noise of variance βt, rising linearly from 10−4 to 0.02, so the total variance stays 1.
Half way, at t = 500, about a quarter of the amplitude is left: √ā500 = 0.28 under the linear schedule, against 0.70 under the cosine one derived. Set the slider to 500: the image is mostly noise half way, which is the cosine schedule's whole motivation (section 2).
The formula. Gaussians add up to a Gaussian, so the steps never have to be simulated one by one: the noisy image at any step has a closed form,
where x0 is the clean image with pixels in [−1, 1], αt = 1 − βt is the share of variance one step keeps, and āt = α1 α2 … αt is the share of the original signal's variance that survives to step t, falling from about 1 to about 0. This one line is the whole data pipeline of training: pick an image, a random t and random noise, and the noisy input is ready (diffusers' add_noise, scheduling_ddpm.py line 608). The derivation of the closed form is on the math page, derivation D3.
The first Fashion-MNIST test image of each class, one fixed noise draw (the same ε at every t), so only āt changes as you drag. Schedule formulas as in diffusers v0.41.0 (scheduling_ddpm.py lines 214 to 229).
The problem. The schedule (the list of βt, or equivalently āt) fixes two things at once: how the 1,000 training timesteps are spread over noise levels, and what the model sees at the very last one. Both quietly limit what the model can generate.
One axis for all schedules. Write the noise level as the log signal-to-noise ratio λ = ln(ā / (1 − ā)); SNR = 1 (λ = 0) is where signal and noise are equal. A schedule is a way of spending timesteps along λ: the linear schedule spends 74% of its timesteps where noise dominates (SNR < 1 from t = 259); the cosine schedule (Nichol and Dhariwal 2021) falls slowly at both ends and crosses at t = 496, about half; Stable Diffusion 1.5's scaled-linear (β from 0.00085 to 0.012, linear in √β) crosses at t = 354, spending 65% derived. Two schedules that cover the same λ range differ only in how densely they sample it, which is why EDM (section 3) drops the timestep and samples noise levels directly.
Fig. 2, step by step: each column is one timestep's variance, which always totals 1
Two fixes, one hack and one cure.
--noise_offset, train_text_to_image.py lines 973 to 976). The averaged noise now has variance (1 − ā)(1/n + k²), so the brightness SNR at the last step falls from 19.2 to 0.46 at k = 0.1 derived. It works, but it trains on a noise distribution the sampler never starts from, and it reduces the brightness signal rather than removing it.rescale_betas_zero_snr=True.alphas_bar_sqrt -= alphas_bar_sqrt_T # shift so the last timestep is zero alphas_bar_sqrt *= alphas_bar_sqrt_0 / (alphas_bar_sqrt_0 - alphas_bar_sqrt_T) # scale so the first is unchanged
The averaging argument applies to any patch, not just the whole image: at 4 × the pixels, every 2 × 2 block's average has 4 × the SNR of a single value, so coarse structure survives more noise, and a schedule tuned at 32 × 32 destroys too little of a 512 × 512 image's layout at its noisiest steps. Hoogeboom, Heek and Salimans (2023) make it a rule: take a schedule designed at 64 × 64 and, at d × d, multiply its SNR by (64/d)², a shift of log SNR by 2 log(64/d); on ImageNet 256 that moved their training FID from 7.65 to 3.76 published. Stable Diffusion 3 does the same for flow matching with a timestep shift (Esser et al. 2024); that belongs to the flow-matching page.
Chart: ln SNR against timestep for your schedule; dashed, the three presets. Computed in your browser from diffusers v0.41.0's formulas (scheduling_ddpm.py lines 214 to 229; scheduling_ddim.py line 103) derived; the presets reproduce √ā at the last step of 0.0064 and 0.068 and SNR below 1 from t = 259, 496 and 354 (runs/check_toy.mjs against runs/recompute.py). The shift follows Hoogeboom et al. (2023): SNR times (design side / d)² at side d.
The cost of the cure. At SNR exactly 0 the input is the noise, so an ε-predicting network has nothing to learn there, and the clean-image guess x̂0 = (xt − √(1 − ā) ε̂) / √ā divides by zero. The paper therefore pairs it with v-prediction (section 3), fine-tuning, sampling that starts at the last timestep ("trailing", section 5) and CFG rescale (section 6). Flipping only the flag on SD 1.5:
measured: the last timestep's ā is exactly 0, the first step divides by zero, the latents become NaN, and the decoded image is a black square (mean 0.00, standard deviation 0.00; numpy warns about invalid values when casting to bytes). The same scheduler with SD 1.5's own schedule gives the normal image. The flag is only half of the recipe.
The network. The denoiser takes the noisy image xt, the timestep t and (here) the class label, and returns a tensor of the image's shape. The tiny model is the shared TinyUNet, 1,040,353 parameters: a convolutional U-Net that shrinks the image from 32 to 16 to 8 pixels and grows it back, with skip connections between matching sizes and self-attention at 8 × 8; t enters as a sinusoidal embedding and the label as a learned embedding with an 11th "no label" row, both added inside every residual block. Production denoisers (SD's U-Net, diffusion transformers) are the latent-diffusion page's subject.
Three things it can be asked for. Given xt and t, the clean image and the noise determine each other, so the network can be trained to output either, or a mix, and the sampler converts. The choice does not change what a perfect network knows; it changes which noise levels the loss cares about and how errors are amplified at sampling time:
| Target | Definition | Clean image from the output |
|---|---|---|
| ε (noise) | the noise that was added | x̂0 = (xt − √(1 − ā) ε̂) / √ā |
| x0 (clean image) | the image itself | the output (flow models predict a close cousin) |
| v (velocity) | √ā ε − √(1 − ā) x0 (Salimans and Ho 2022) | x̂0 = √ā xt − √(1 − ā) v̂ |
The training step, as it ran in the root lab (src/diff/train_ddpm.py): a random t, fresh noise, the closed form of section 1, mean squared error against the target. The label is replaced by the null class 10% of the time, so one network also learns the unconditional model that guidance needs (section 6).
def loss_fn(model, b):
x0, y = b
t = torch.randint(0, sched.T, (x0.shape[0],), device=dev)
eps = torch.randn_like(x0)
pred = model(sched.q_sample(x0, t, eps), t.float() / sched.T, drop_labels(y, 0.1))
loss = F.mse_loss(pred, target(x0, eps, t)) # target: eps, or v = sqrt(abar) eps - sqrt(1 - abar) x0
return loss, {"loss": loss.item()}
Recipe: batch 128, AdamW at 5 × 10−4 after 200 warm-up steps, gradient clipping at 1, an exponential moving average (EMA) of the weights with decay 0.999 used for all sampling, 4,000 steps in 15.1 minutes (4.41 steps per second on the M1 Pro's GPU) measured. Two models were trained this way, one per target: ε and v. Why predicting noise is the right loss for DDPM, from the ELBO, is on the DDPM paper page and the math page, derivations D4 and D5.
Validation error by timestep, EMA weights, 2,048 validation images, both models converted to each quantity measured (root lab recordings). ε-model: noise error 0.419 at t = 0 against 0.00027 at t = 999 (near pure noise, "predict the input" is almost right); clean-image error 0.00004 at t = 0 against 0.603 at t = 999, where the v-model's is 0.161. With no image left the best guess is a blurred average, which the v-model outputs; the ε-model's guess goes through a division by √ā and is mostly amplified noise.
Where that bites: one step. At t = 999 the linear schedule leaves √ā = 0.0064, so any error in ε̂ is multiplied by 157 on its way to x̂0; the v row has no division. Invisible at 50 steps, decisive at one:
One sample per class, the same ten noise images, DDIM, no guidance measured (root lab recordings, 1,000 samples per row): ε-model at 1 step FD 1,493.9 (accuracy 19.0%); v-model at 1 step FD 1,352.7 (accuracy 49.1%); v-model at 50 steps FD 104.4 (the ε-model: 112.7); the v-model sampled as if it predicted ε, FD 1,779.9. The last row is a real bug: nothing in the code fails, the images are just wrong.
Every target is a weighting of one loss. Write every loss as a weight times the clean-image error ||x̂0 − x0||². Because ε̂ − ε = √(ā/(1 − ā)) (x0 − x̂0), the ε loss is the x0 loss times SNR, and the v loss is it times SNR + 1 derived. Multiply by how often training draws each noise level and you have where the optimiser spends its effort:
| Target and recipe | Weight on the clean-image error | Noise levels drawn | Used by |
|---|---|---|---|
| ε (noise) | SNR | t uniform on 1,000 steps | DDPM, SD 1.x, SDXL |
| x0 (clean image) | 1 | t uniform | some cascades; distillation targets |
| v | SNR + 1 | t uniform | SD 2 768-v, progressive distillation, zero-terminal-SNR models |
| Min-SNR-γ (any target, reweighted) | min(SNR, γ), γ = 5 | t uniform | Hang et al. 2023; diffusers' --snr_gamma |
| EDM preconditioned denoiser | (σ² + σdata²) / (σ σdata)², with output scaling that keeps the effective target well scaled at every σ | ln σ ~ N(−1.2, 1.2²) | Karras et al. 2022, EDM2 |
Weight × how often each noise level is drawn, on the λ axis, each curve normalised to a total of 1 (shape, not scale); x0 piles up at low λ, near pure noise, where its target is a blurry average. Computed in your browser from the formulas in the table derived. Not run here: one 15-minute training run per weighting on the tiny model would differ by less than one seed's run-to-run noise, so the published ablations are the evidence. Hang et al. (2023) report that Min-SNR-5 reaches FID 10 on ImageNet 256 3.4 times faster than the plain loss published; EDM's weighting with its log-normal noise sampling is part of their CIFAR-10 FID 1.79 at 35 calls published. To check your own model, log the loss in timestep buckets (the chart above); a flat average hides which noise levels are still bad.
Karras et al. wrap the raw network F so that its input and its target have unit variance at every σ, and so that at low noise it mostly copies its input: D(x; σ) = cskip(σ) x + cout(σ) F(cin(σ) x; cnoise(σ)).
c_noise = 0.25 * torch.log(sigma) # line 210
c_skip = sigma_data**2 / (sigma**2 + sigma_data**2) # line 236
c_out = sigma * sigma_data / (sigma**2 + sigma_data**2) ** 0.5 # line 239 (default branch)
c_in = 1 / ((sigma**2 + self.config.sigma_data**2) ** 0.5) # line 596
At high σ cskip → 0 and the network predicts the image (an x0-style target, no division by a vanishing √ā); at low σ cskip → 1 and it predicts a small correction (an ε-style target). It is v-prediction's idea made exact, and the reason EDM-family models handle both ends without special cases. The same cskip and cout reappear in consistency models (section 7), where they make the model return its input at σ = 0 (diffusers' scheduling_lcm.py lines 565 to 566).
Min-SNR on an ε model divides the weight by SNR, to turn "weight on x0 error" into "weight on ε error":
snr = compute_snr(noise_scheduler, timesteps)
mse_loss_weights = torch.stack([snr, args.snr_gamma * torch.ones_like(timesteps)], dim=1).min(
dim=1
)[0]
if noise_scheduler.config.prediction_type == "epsilon":
mse_loss_weights = mse_loss_weights / snr
EMA of the weights. An exponential moving average keeps a second copy of the weights, updated as wema ← d wema + (1 − d) w after every step; with d = 0.999 it averages roughly the last 1,000 steps, and sampling uses it. Diffusion training is noisy (every step sees a random noise level), and the average sits closer to the bottom of the loss valley than any single iterate. measured: the lab's raw weights at step 4,000 score FD 141.9 with DDIM 50 and 87.0 with DDPM 50, against 112.7 and 62.3 for the EMA copy of the same run. diffusers' EMAModel defaults to d = 0.9999 with optional warm-up (training_utils.py line 632); EDM2 (Karras et al. 2023) stores snapshots so the EMA length can be chosen after training. EDM2 reports ImageNet-512 FID 1.81 with this machinery and guidance (EDM2-XXL), 1.91 without published.
Condition dropout. Guidance needs the unconditional model, so 10% of training labels (or prompts) are replaced by a null label. Ho and Salimans found dropping 10% or 20% of conditions about equally good and 50% worse published; the tiny model uses 10%. SD 1.5 used 10% text dropout (the model card).
Training length. Doubling the tiny model's training (4,000 to 8,000 steps, 14.8 more minutes) moved DDIM at 50 steps from FD 112.7 to 41.6 and DDPM at 1,000 steps from 34.9 to 20.1 measured; the model was far from converged, which is the context for every sampler result here.
What transfers from the tiny model. Mechanisms transfer: how targets weight noise levels, what each sampler does with a model's errors, how guidance trades fidelity for variety, what each bug looks like. Absolute numbers do not: a 1M-parameter model trained for 15 minutes on 28 × 28 grey images is far less accurate than a production model, which is exactly why the deterministic sampler loses here (section 5); well-trained models favour DPM-Solver-class ODE samplers at 20 to 30 steps.
The problem. Papers describe the same trained network in three vocabularies: it "predicts the noise", it "estimates the score", it "defines an ODE". Samplers, guidance and distillation are each written in one of them. The translation is two lines of algebra; with it, DDIM, Euler, DPM-Solver and Karras' samplers stop being separate inventions.
Why it matters in practice. One Euler step of that ODE from σ to a smaller σ′ is x̃′ = x̃ + (σ′ − σ) ε̂ = D + σ′ ε̂. Multiply back by √ā′ and it is DDIM's update, line for line. That is why diffusers' EulerDiscreteScheduler and DDIM give the same samples on the tiny model (FD within 0.2 at every step count in the lab) measured: one method in two coordinate systems. Every "Karras" or "k-diffusion" sampler works in σ; every "DDIM-style" one in xt. The σ range is the schedule seen from the ODE's side: the tiny model's linear schedule runs from σ = 0.01 to 157, Stable Diffusion 1.5's from 0.029 to 14.6 derived. A σ-space sampler must start from noise of that size, not unit noise (a real bug, section 8).
Fig. 3, step by step: the toy's trained network (9,858 weights), asked live in your browser
Shaded background: pt(x) at each moment (three bumps on the right merge into one Gaussian on the left). Coarse structure is decided at high noise, detail at low noise, as in the image trajectories of section 5. The ODE paths never cross (a deterministic flow cannot send two points through one place at one time); the stochastic paths jitter, and some switch bumps late.
Images are too big to see a distribution, so the page uses a one-dimensional stand-in for the running example: three "garment classes" as three narrow bumps on a line (weights 0.5, 0.3, 0.2 at −1.5, 0.6 and 2.0). For a mixture of Gaussians the noisy density pt and the denoiser D are known in closed form, so this toy has a perfect network, with the tiny model's linear schedule and trailing timesteps. The code is src/runs/gmm_toy.py; the page runs its JavaScript port, checked against it to 3 × 10−15.
Which sampler ends closer to the true density, with this exact denoiser and 50 steps? DDIM, slightly, and both converge. Total-variation distance to the true density (0 is perfect, 1 is disjoint; 20,000 samples): at 50 steps 0.079 for DDIM against 0.111 for DDPM; at 1,000 steps 0.020 and 0.019, the histogram's own noise floor measured (gmm_toy.py). With a perfect model the only error is the step size, and a smooth ODE path has smaller step error than a path with noise injected; that is the DDIM paper's result too. The tiny Fashion-MNIST model reverses it, and section 5 shows why.
The animation in five stretches (each plays its steps)
The problem. The trained network answers one question: "at this noise level, what is the clean image (or the noise)?". A sampler turns those answers into a path from noise to an image. Every sampler below uses the same trained weights; only the rule changes, and one network evaluation (NFE) is the unit of cost.
Fig. 4, step by step: 40 of the measured table's 600 noise draws on the two-moons toy; height is the timestep
The same on images. The card beside replays the tiny image model's recorded calls: pick a step count and scrub through them.
What a call costs. Every step is one network evaluation, two with guidance: one tiny U-Net call takes 6.0 ms for one image and 332 ms for a batch of 1,000 on the M1 Pro's GPU; one SD 1.5 U-Net pass at 512 × 512 takes 0.319 s measured (root lab recordings). Samplers differ in three ways only: which coordinates they step in (xt, σ or λ, section 4), how many calls each step costs and how they combine them (the solver's order), and whether they add fresh noise.
Three classes (dress, sandal, bag), the same three noise images in every mode; DDIM unless marked DDPM; no guidance. Recorded frames from the root lab's sample_tiny.py, shown at 16 grey levels measured. Switch to the model's guess at 20 steps: over the first third of the calls x̂0 turns from amplified noise into a rough outline, and the rest add edges and texture; 20 and 50 steps give almost the same image, because DDIM follows one deterministic path from a given noise. The DDPM mode starts from the same noise and ends somewhere else.
| Sampler | Steps in | Network calls per step | Fresh noise | diffusers class |
|---|---|---|---|---|
| DDPM, ancestral | xt | 1 | yes, the posterior's | DDPMScheduler |
| DDIM, η = 0 | xt (= Euler in σ) | 1 | no | DDIMScheduler |
| DDIM, 0 < η ≤ 1 | xt | 1 | a fraction η of DDPM's (η = 1 is DDPM) | DDIMScheduler(eta=...) |
| Euler / Euler ancestral | σ | 1 | no / yes | EulerDiscreteScheduler / EulerAncestralDiscreteScheduler |
| Heun (EDM's second-order method) | σ | 2 (the last step 1) | no | HeunDiscreteScheduler |
| DPM-Solver++ 2M | λ, exact in the linear part | 1 (reuses the previous call) | no | DPMSolverMultistepScheduler (the default) |
| DPM-Solver++ 2M SDE | λ | 1 | yes | DPMSolverMultistepScheduler(algorithm_type="sde-dpmsolver++") |
| UniPC | λ, predictor plus corrector | 1 (the corrector reuses the next call) | no | UniPCMultistepScheduler |
One family, one knob: DDIM's η. DDIM's general update interpolates between the deterministic path and DDPM: keep a share of the predicted noise as the direction and replace the rest by fresh noise; η = 0 is DDIM, η = 1 is DDPM.
for i, t in enumerate(ts): # trailing timesteps, e.g. 999, 899, ... for 10 steps
ab = abar[t]
ab_prev = abar[ts[i + 1]] if i + 1 < n else torch.ones_like(ab)
eps = eps_fn(x, t)
x0 = (x - (1 - ab).sqrt() * eps) / ab.sqrt()
sigma = eta * ((1 - ab_prev) / (1 - ab) * (1 - ab / ab_prev)).sqrt() if i + 1 < n else 0 * ab
x = ab_prev.sqrt() * x0 + (1 - ab_prev - sigma ** 2).clamp(min=0).sqrt() * eps
if i + 1 < n and eta > 0:
x = x + sigma * torch.randn(x.shape, generator=gen).to(x.device)
src/runs/dz_samplers.py, the code behind every η number on this page. diffusers computes the same σ as std_dev_t = eta * variance ** (0.5) (scheduling_ddim.py lines 286 and 481 to 488); the lab's own DDIM matched diffusers' DDIMScheduler (trailing) to 4.9e-06 on 16 images.DPM-Solver++: solve the easy part exactly. In λ coordinates the ODE has a linear part, which can be integrated exactly, and a nonlinear part that is just the network's clean-image guess. DPM-Solver++ integrates the first exactly and approximates the second: first order (the guess held constant over the step) is exactly DDIM, and "2M" fits a line through this step's and the previous step's guesses, a second-order step for one network call. DPM-Solver++ 2M is what diffusers’ DPMSolverMultistepScheduler does by default (algorithm_type="dpmsolver++", solver_order=2; scheduling_dpmsolver_multistep.py line 227, v0.41.0): it reuses the previous step’s prediction to take second-order steps at no extra network cost.
h, h_0 = lambda_t - lambda_s0, lambda_s0 - lambda_s1
r0 = h_0 / h
D0, D1 = m0, (1.0 / r0) * (m0 - m1) # m0, m1: this and the previous x0 guess
x_t = (
(sigma_t / sigma_s0) * sample
- (alpha_t * (torch.exp(-h) - 1.0)) * D0
- 0.5 * (alpha_t * (torch.exp(-h) - 1.0)) * D1
)
Where the steps land. At few steps the spacing matters as much as the solver. "Trailing" spaces timesteps evenly from 999; SD 1.5's scheduler config makes diffusers' DDIM fall back to "leading", which never calls the network at 999, so its first step treats pure noise as a partly clean image: at 4 steps the root lab's recorded run got a pale, foggy scene with no lighthouse where trailing spacing gave a dark but recognisable one, same model, same noise, same number of calls measured. Karras et al.'s spacing crowds steps at low noise instead.
SD 1.5's config (steps_offset 1, no timestep_spacing) sends DDIM to its default "leading" (scheduling_ddim.py lines 365 to 370): with 4 steps it calls the network at 751, 501, 251 and 1; "trailing" (lines 371 to 376, the fix Lin et al. recommend) calls it at 999, 749, 499 and 249; DPM-Solver's default "linspace" also starts at 999. At 25 or 50 steps the difference is small. Karras et al.'s spacing (ρ = 7, scheduling_euler_discrete.py line 551) spaces σ1/7 evenly: on SD 1.5's σ range, ten Karras σs are 14.6146, 9.1029, 5.4784, 3.1686, 1.7494, 0.9141, 0.4469, 0.2014, 0.0819, 0.0292 derived.
Same model, same noise, 10 steps each: DDPM or DDIM? Here, DDPM: FD 130.5 against 181.3 for DDIM measured. The textbook answer is DDIM: Table 1 of the DDIM paper on CIFAR-10: FID 13.36 for η = 0 against 41.07 for η = 1 at 10 steps, 4.67 against 8.01 at 50; the two meet only near 1,000 steps (4.04 and 4.73) published, and that is why DDIM exists. The difference is the model; the rest of this section shows why.
What it shows measured. Three groups. The deterministic ODE solvers (DDIM, Euler, UniPC, DPM-Solver++ 2M, Heun) all flatten out between FD 100 and 110: UniPC 106.6, DPM-Solver++ 105.8, Heun 106.2 at 50 steps against DDIM's 112.7. Better solvers only get there sooner (UniPC 109.2 at 10 calls against DDIM's 181.3). The stochastic samplers keep improving: DDPM and Euler ancestral are the same algorithm (FD 62.3 and 62.3 at 50 steps), and the second-order stochastic DPM-Solver++ 2M SDE is the best sampler here from 20 to 50 calls (42.2 at 20, 44.2 at 50). Two schedulers fail at very few steps: Heun at 2 and 4 steps (FD 1,652.8 and 1,003.0, saturated blobs) and DPM-Solver++ with Karras sigmas at 4 steps (1,568.3): on the tiny model's schedule σ runs up to 157, and ρ = 7 spacing then puts almost all of a short walk at very high noise. Karras spacing is the best deterministic choice at exactly 10 steps (58.0), then rises back to the ODE plateau. Clipping the clean-image guess does not help this model (DDPM 50 steps 70.7 with clipping, 62.3 without). Every sample and number is in the workbench above.
Pick a sampler and a step count: one sample per class (the same ten noise images everywhere) and the scores over 1,000 samples; the chart has every sampler against network calls, the selected one highlighted measured on Apple M1 Pro (MPS). DDPM, DDIM, DPM-Solver++ and Euler at 1 and 4 to 1,000 steps are the root lab's own recordings, the rest this page's runs.
Timesteps (on the 0 to 999 training scale) at which each scheduler calls the network, from scheduler.timesteps after set_timesteps(10) with trailing spacing. Heun calls the network twice per step except the last, so it lists 19 entries.
Ancestral DDPM beats DDIM from 4 steps up on this model, the opposite of the DDIM paper's CIFAR-10 result. The lab's explanation was that fresh noise lets later steps correct earlier errors (Karras et al. 2022, section 4, make the same argument). Three tests of that explanation:
Test 2: add noise back in steps. If fresh noise is what helps, FD should improve steadily as DDIM's η goes from 0 to 1. It does, and half the noise gets most of the way measured: at 50 steps FD 112.7 (η = 0), 59.8 (η = 0.5), 62.3 (η = 1); at 250 steps 108.2, 59.2, 39.7. Class accuracy follows (77.8%, 85.1%, 88.7% at 50 steps): the deterministic samples are the ones stranded between classes, exactly as in the toy.
Test 3: train longer. If the gap comes from the model's error, it should shrink as the model improves. This page resumed the lab's 4,000-step model for 4,000 more with the same recipe (src/runs/dz_train.py more; optimiser state and EMA restarted, so not identical to an uninterrupted 8,000-step run). Its noise-prediction error at t = 999 fell from the bad model's 0.00204 to 0.00013 (validation MSE). Results measured: at 10 steps DDIM now wins, FD 76.0 against DDPM's 105.8 (at 4,000 steps it lost, 181.3 against 130.5); at 50 steps they are level (41.6 and 44.3); with many steps the stochastic sampler still pulls ahead (22.6 against 40.4 at 250, and DDPM at 1,000 steps reaches 20.1, near the real-image floor of 18.9). A better model moves the crossover towards the DDIM paper's picture.
The rule that transfers. A deterministic sampler is exact for the model you have, errors included; a stochastic one partly corrects them, at the price of needing more steps. With a well-trained model and a budget of 10 to 30 calls, use an ODE solver (DPM-Solver++ 2M, UniPC); with an under-trained, small or out-of-distribution model, or a large budget, try a stochastic one (DPM-Solver++ 2M SDE, ancestral, EDM's churn). EDM measured the same on ImageNet-64: the pretrained ADM model went from FID 2.64 with their best deterministic sampler (79 calls) to 1.55 with tuned stochasticity (511 calls) published. Re-measure after every training run that matters.
6,000 samples computed in your browser for each setting (the 20,000-sample numbers in the text come from gmm_toy.py and differ by sampling noise only). τ flattens the denoiser's belief about which bump a point came from: τ = 1 is the exact posterior.
The tiny image model above shows the sampler results; this toy lets you run them. The models were trained for the Math page and moved here (src/moons/diffusion.py): a 3-hidden-layer network of width 64 (9,858 weights, shipped as 8-bit integers with one scale per row), trained for 30,000 Adam steps on two-moons data with Lsimple. Two choices differ from Ho et al. and are said here: the network is told the noise level as the log-SNR λt instead of the step index, so one network serves both schedules; and it also gets the moon label, dropped 15% of the time, for guidance (section 6). A second network of the same size is trained with flow matching (Flow matching and rectified flow). Both samplers clip their guess of the clean point to the data range, as Ho et al.'s released code does (the "dividing by √ā" mistake on the Math page, section 9, shows why). Everything below runs live in your browser.
What to notice. With DDPM the forward process is a random walk and the reverse process draws fresh noise at every step, so the points come back to the moons but not to their own places: the colours end up mixed across both moons. The model learned the distribution, not a code for each point. With DDIM (σt = 0) and with flow matching, both directions are deterministic ODE steps, so running the encoder and then the decoder returns each point close to where it started: these samplers define an invertible map between noise and data, which is what image editing by inversion relies on.
| Unconditional | 1,000 steps | 100 | 20 | 5 |
|---|---|---|---|---|
| DDPM (stochastic), linear schedule | 94.0% | 94.5% | 84.3% | n/a |
| DDIM (σ = 0), linear schedule | n/a | 90.0% | 83.8% | 27.0% |
| DDIM (σ = 0), cosine schedule | n/a | n/a | 95.3% | 78.7% |
| Flow matching (Euler, uniform in t) | n/a | 88.0% | 86.7% | 75.5% |
"n/a": not run. The same trained network gives 27% or 79% at 5 steps depending only on which noise levels the steps visit. Five evenly spaced t on the linear schedule sit at log-SNR λ = 9.2, 0.1, −2.5, −5.7, −10.1: three of the five network calls see almost pure noise, and the last call has to jump from λ = 0.1 (half signal, half noise) straight to clean data. The cosine schedule and the flow model's uniform t (λ = 2 log((1 − t)/t): ±2.8, ±0.8) spend their steps in the middle, where the picture is decided. Change steps, sampler and schedule yourself in the sampler lab below; its bottom strip draws where each step lands.
What the measurement says. On the 40 paths drawn, the flow-matching paths are less straight than DDIM's (0.55 against 0.73; recomputed in src/runs/check_moons.mjs). Each training line is straight, but lines from different (data, noise) pairs cross, and the network learns their average direction, which bends as a path has to commit to one moon; on two well-separated modes that bend is large. So the claim "flow matching gives straight paths" holds for each conditional path, not automatically for the learned ones (the same finding as Flow matching's exact field, its section 2). The flow model's good 5-step result in the table above comes from where its steps fall in noise level, not from straightness. Rectified flow's reflow step retrains on the model's own (noise, sample) pairs, which no longer cross, to straighten the learned paths (Liu et al. 2022, section 2.1: "This reflow procedure not only decreases transport cost, but also has the important effect of straightening paths"); distillation then needs very few steps.
Sample from the two networks above: a noise-prediction (DDPM) network and a flow-matching network, each 9,858 weights, on 2-D two-moons data. Every sample is computed in your browser; the same seed gives the same points as the NumPy reference sampler (src/moons/sampler.py, checked to 10−9).
Bottom strip: where the chosen steps sit on the log-SNR axis λ = log(ā/(1 − ā)) (for flow matching, λ = 2 log((1 − t)/t)). Steps spent at very negative λ see almost pure noise; a large jump near the data end is where few-step samplers lose quality. "On data": within 0.2 of a moon's centre line (98% of real points are). Both diffusion samplers clip the predicted x0 to [−3, 3] (the data range), as Ho et al.'s code does with [−1, 1] for images: DDPM then takes the posterior mean μ̃t(xt, x̂0), and DDIM re-derives the noise from the clipped x̂0, as GLIDE and diffusers do. Without the clip, large w or the end of the cosine schedule throws samples far off (20-step DDIM on the cosine schedule: 1.2% of 600 samples on the data without it, 95.3% with it).
The problem. A conditional model asked for "sandal" produces something sandal-like, but its samples drift: some are ambiguous, some look like another class. We want a knob that trades variety for adherence to the condition. Its predecessor, classifier guidance (Dhariwal and Nichol 2021), pushed along the gradient of a separate classifier trained on noisy images; classifier-free guidance (CFG, Ho and Salimans 2022) removes the classifier by letting the model be its own.
How it works. Train one network both with and without the label (the 10% dropout of section 3). At sampling, evaluate it both ways and extrapolate from the unconditional prediction past the conditional one:
where εc and εu are the predictions with the label (or prompt) and with the null label (or empty prompt), and s is diffusers' guidance_scale: 0 is the unconditional model, 1 the plain conditional model, above 1 pushes further in the direction the condition points (pipeline_stable_diffusion.py line 1055). Two traps: the pipeline runs the unconditional branch only when the scale is above 1 (line 764), so guidance_scale=0 there is the plain conditional model, not the unconditional one; and papers often write εc + w (εc − εu) with w = s − 1. The cost: two evaluations per step, run as one batch of two (line 1037). The derivation is on the math page, derivation D7.
Fig. 5, step by step: the toy's network asked for the upper moon (its label input; dropped 15% of the time in training)
Why high scales oversaturate. Extrapolating past the conditional prediction does not preserve a probability distribution: the guided ε̂ can imply a clean-image guess far outside the range real images occupy, and each step feeds that back in. On the tiny model the share of pixels whose guessed value lies beyond [−1, 1] rises from 27% at s = 1 to 75% at s = 15 measured; on SD 1.5 colour saturation climbs from 0.35 at s = 1 to 0.47 at 7.5 and 0.61 at 20 measured (root lab recordings): blown highlights and neon colours. Five fixes are in use:
One sample per class, the same ten noise images, DDIM 50 steps, scores over 1,000 samples measured. Plain CFG is the root lab's recorded sweep (s = 1 to 15); the other kinds are this section's fixes, each changing one thing.
| Fix | What it changes | Cost | Measured here |
|---|---|---|---|
| Thresholding | Clip the clean-image guess to the data range at each step; Imagen's dynamic thresholding clips to a high percentile of |x̂0| and rescales (Saharia et al. 2022) | Free; only for pixel-space models (a latent has no fixed range); diffusers: thresholding=True on DDPM, DDIM and DPM-Solver schedulers | static clipping inside DDPM on the tiny model (section 8) |
| CFG rescale | Rescale the guided prediction to the standard deviation of the conditional one, then mix with weight φ = 0.7 (Lin et al. 2023, section 3.4) | Free; one line | SD 1.5 and the tiny model |
| Guidance interval | Guide only at middle noise levels; plain conditional model at the noisiest and cleanest steps (Kynkäänniemi et al. 2024) | Saves the second network call on the unguided steps | SD 1.5 and the tiny model |
| Negative prompt | Put a prompt in the unconditional branch: ε̂ = εneg + s (εc − εneg), so the push is away from what you name | Free (the second call exists anyway) | SD 1.5 |
| Autoguidance | Replace the unconditional model by a smaller, less-trained version of the same conditional model (Karras et al. 2024) | A second model to train and run | the tiny model |
CFG rescale sets the guided prediction's standard deviation (per image, over all values) back to the conditional prediction's, removing the overall "too much" while keeping the direction. What it shows measured: on SD 1.5, an ε-model with a non-zero terminal SNR, rescale at 0.7 barely changes the image: saturation at scale 20 goes from 0.608 to 0.602 and the share of clipped pixels even rises (9.5% to 10.9%). On the tiny pixel model it does no better (saturated pixels at s = 7.5: 25.9% plain, 26.3% rescaled; FD 187.1 and 179.3). Lin et al. introduced it for a zero-terminal-SNR v-model, where guided predictions overshoot much more; it is not a general fix for saturation, which is why the next fix exists.
std_text = noise_pred_text.std(dim=list(range(1, noise_pred_text.ndim)), keepdim=True) std_cfg = noise_cfg.std(dim=list(range(1, noise_cfg.ndim)), keepdim=True) # rescale the results from guidance (fixes overexposure) noise_pred_rescaled = noise_cfg * (std_text / std_cfg) # mix with the original results from guidance by factor guidance_rescale to avoid "plain looking" images noise_cfg = guidance_rescale * noise_pred_rescaled + (1 - guidance_rescale) * noise_cfg
guidance_rescale > 0). The page's own dz_samplers.cfg(..., phi=0.7) does the same on the tiny model.Guidance interval. Kynkäänniemi et al. found guidance harmful at the noisiest steps (it collapses variety while the layout is being chosen) and nearly useless at the cleanest (the image is decided). Measured on SD 1.5 with the interval the paper used for SD-XL, σ in (0.28, 5.42], which guides 19 of the 25 steps measured: saturation at scale 20 falls from 0.61 to 0.43, at scale 12 from 0.53 to 0.39, the scene keeps its lighthouse, and the image takes 14.1 s instead of 15.8 s (6 fewer U-Net passes of 50). On the tiny model, mapped to timesteps 82 to 578 (24 of 50 DDIM steps), it gives the best FD of any CFG setting, 29.1 at s = 3 with 92.5% accuracy and diversity 26.8, against plain CFG's best 35.5 at s = 2. Published: EDM2-XXL on ImageNet-512 FID 1.81 to 1.40, guiding 6 of 32 steps with (0.19, 1.61] published.
Stable Diffusion v1.5, the root lab's prompt and seed ("a photograph of a lighthouse on a cliff at sunset", seed 0, 512 × 512, 25 DPM-Solver++ steps, fp16) measured on Apple M1 Pro (MPS); 256-pixel WebP thumbnails, metrics on the full 512-pixel images.
Autoguidance. CFG's unconditional model differs from the conditional one in what it models (all images, not this class), so extrapolating away from it changes the content, which is where the lost diversity comes from. Autoguidance extrapolates away from a worse model of the same thing, so the push is towards "better", not "more class-like". Tested here with the weak model trained for this page (TinyUNet base 16, 262,385 parameters, 1,000 steps; alone it scores FD 985.3) measured: at w = 1.5 autoguidance gives FD 24.1, the best tiny-model score on this page at 50 steps, with diversity 28.2 (real images 28.87, plain CFG at its best 25.8) and accuracy 86.2%. Larger w overshoots (FD 81.7 at w = 3). The published claim reproduces in kind: better fidelity without CFG's loss of variety. Published: ImageNet-512 EDM2-S FID 2.23 with CFG to 1.34, guided by an XS model trained 1/16 as long; EDM2-XXL 1.81 to 1.25 published.
Tiny model, class accuracy against FD, one point per scale in order of scale (upper left is better: accurate and close to real; hover a point for its numbers) measured. Each curve changes one thing from plain CFG: rescale φ = 0.7; guidance only inside the noise interval; DDPM instead of DDIM; autoguidance with the weak model (scale w).
| Sampler | w | on data | on the upper moon | horizontal spread (sd) |
|---|---|---|---|---|
| DDPM, 100 steps | 0 | 99.8% | 100% | 1.00 |
| DDPM, 100 steps | 1 | 100% | 100% | 0.88 |
| DDPM, 100 steps | 4 | 99.3% | 100% | 0.70 |
| DDIM, 100 steps | 4 | 91.3% | 100% | 0.55 |
| DDIM, 5 steps | 0 | 37.5% | 88.3% | 0.66 |
| DDIM, 5 steps | 1 | 98.0% | 100% | 0.56 |
Real upper-moon data has a horizontal spread of about 1.0. Guidance trades diversity for fidelity: with DDPM, w = 4 keeps every sample on the right moon but squeezes them towards its middle (spread 0.70); the deterministic DDIM sampler squeezes harder (0.55) and starts to push samples off the data (91% on it), the toy version of the over-saturated, low-variety images that large guidance scales produce. And a little guidance rescues a too-short sampler (DDIM, 5 steps: 37.5% to 98%), by pulling every sample towards one mode. Here w is the paper's weight; libraries use s = 1 + w. Try any w in the sampler lab of section 5's two-moons block.
The price of an image is network calls (steps × 2 with guidance: SD 1.5 at 25 guided steps is 50 U-Net passes, 15.8 s per 512 × 512 image here measured, root lab recordings), and below about 8 steps no sampler of section 5 is enough, since one straight step from pure noise lands on the blurry average guess of section 4; the fix is a second, distilled student model trained to jump, and its methods, published results and costs are taught on Latent diffusion and diffusion transformers, section 10 (flow-based shortcuts, reflow and one-step distillation of a flow, on Flow matching, sections 8 and 9). This page keeps one measured run of one such student.
LCM-LoRA (Luo et al. 2023) is a latent consistency model distilled into a LoRA (a small low-rank weight update) that plugs into an unchanged SD 1.5. Loaded here at revision cf2fced (openrail++, 134.6 MB), with its own LCMScheduler and guidance off (scale 1), same prompt and seed:
What it shows measured: at 2 and 4 steps DPM-Solver++ gives a blur and a soft scene, LCM-LoRA a sharp, finished-looking coast at every step count, even 1, and fast (2.05 s at 4 steps against 2.95 s, since it makes one call per step). But look at the lighthouse: LCM-LoRA drops it at every step count, where DPM-Solver++ keeps it from 4 steps. With guidance off the student follows the prompt less closely, and turning guidance up to 2 oversaturates (mean saturation 0.81 against 0.61). Few-step students trade prompt adherence and control for speed, which is why the papers report CLIP score and human preference beside FID.
Each bug below was run on the tiny ε-model (DDIM, 50 steps, the lab's noise and scoring) or on SD 1.5, so the symptom is what you would actually see. Three more are shown where they belong: a v-model sampled as ε (section 3), "leading" timestep spacing at few steps (section 5) and guidance_scale ≤ 1 meaning no guidance in diffusers (section 6).
Cause. Euler, Heun, DPM-Solver with Karras sigmas and the other k-diffusion-style schedulers work on x̃ = xt / √ā, whose starting noise has standard deviation σmax (157.4 for the tiny model's schedule with trailing spacing, about 14.6 for SD 1.5). A hand-written loop that skips x = x * scheduler.init_noise_sigma starts with noise 157.4 times too small, and scale_model_input then shrinks it again. Check: print scheduler.init_noise_sigma; the pipeline does the multiplication at pipeline_stable_diffusion.py line 713. measured: FD 1,339.5, diversity 0.69 (real images 28.87): every sample collapses to nearly the same faint shape.
Cause. The network was trained with t / T in [0, 1) (the shared TinyUNet) and is fed the integer t, or a diffusers U-Net trained on integer t is fed a fraction. The time embedding then describes a noise level the network never saw. Check: compare the range of t in the training loop with the sampler's call. measured: FD 1,065.6, accuracy 19.4% (chance is 10%).
Cause. Sampling with ā from a different schedule than the model was trained with (a cosine scheduler config on a linear-schedule model, or SD 1.5's scaled-linear on a model fine-tuned with something else). Each step's conversion from ε̂ to x̂0 then uses the wrong noise level. Check: diff the scheduler config against the training config (beta_schedule, beta_start, beta_end, num_train_timesteps, rescale_betas_zero_snr). In diffusers the scheduler's prediction_type and schedule come from the checkpoint's scheduler/scheduler_config.json; swap samplers with from_config so they inherit it. measured: FD 1,284.8, accuracy 21.0%: the cosine schedule claims far more signal at middle timesteps than the model was trained with, so each step removes the wrong amount of noise.
Cause. rescale_betas_zero_snr=True makes ā at the last step exactly 0, and turning ε̂ into x̂0 divides by √ā. Zero terminal SNR is for v-prediction models fine-tuned on that schedule (section 2). On SD 1.5 it produced an all-black image (section 2) measured.
clip_sampleCause. diffusers' DDPMScheduler and DDIMScheduler default to clip_sample=True, clamping x̂0 to [−1, 1] at every step. That suits pixel models trained on [−1, 1] images; a latent model's latents are not bounded that way, which is why SD 1.5's scheduler config sets clip_sample false. On the tiny pixel model clipping did not help measured: DDPM 50 steps FD 70.7 with it, 62.3 without (250 steps: 44.7 and 39.7).
Cause. The training loop's own weights are noisier than their EMA; checkpoints often hold both. measured: DDIM 50 steps FD 141.9 raw against 112.7 EMA.
True for a well-trained model at 10 to 100 steps (DDIM Table 1), false for an under-trained one (section 5). A sampler ranking measured on one checkpoint does not transfer to another; re-run the sampler sweep after each training run that matters.
| Symptom | Likely cause | How to check |
|---|---|---|
| Pure noise or saturated blotches at every step count | Prediction type in the sampler differs from training (a v-model sampled as ε), or the timestep in the wrong units | Compare prediction_type and the range of t with the training code (sections 3 and 8) |
| Fine at 50 steps, noise at 1 to 4 | Timestep spacing that never starts at the last step ("leading"); or an ε-model asked for one step | Print scheduler.timesteps; the first entry should be the last training step (section 5) |
| More steps stop helping | The deterministic sampler has converged; the model's own error is now the limit (DDIM here: FD 112.7 at 50 steps, 108.2 at 250) | Try a stochastic sampler at many steps (DDPM 1,000: 34.9), guidance, or more training |
| Oversaturated colours, harsh contrast, repeated motifs | Guidance scale too high | Sweep the scale at a fixed seed; watch saturation and diversity (section 6) |
| Samples ignore the class or prompt | Guidance off (scale ≤ 1 in diffusers), or the null condition never seen in training | Check the condition dropout rate in training and do_classifier_free_guidance at sampling |
| Washed out, never very dark or very bright | Non-zero terminal SNR (SD 1.5 leaves 6.8% of the signal at the last step) | Compute ā at the last training step; zero terminal SNR with v-prediction, or offset noise (section 2) |
| Loss falls but samples stay blobs | Too little training, or sampling the raw weights instead of the EMA | Sample from both; plot the loss by timestep (section 3) |
| Loss looks flat and tiny | The ε loss is dominated by easy, high-noise timesteps (its error at t = 999 is 0.00027) | Log the loss in timestep buckets, not one average |
The forward process is a chain of Gaussians, so xt given x0 is Gaussian in closed form: xt = √āt x0 + √(1 − āt) ε. One line makes the training input for any t.
Tweedie's formula: the posterior mean is E[x0|xt] = (xt + (1 − ā) ∇ log pt) / √ā. Rearranging the noise model gives ε̂ = −√(1 − ā) ∇ log pt(xt). So minimising the ε loss is denoising score matching with a per-level scale; the sampler can use the network as a score in an SDE or an ODE.
They are interchangeable given xt; what differs is the loss weighting across noise levels and the numerical behaviour at high noise. ε is the DDPM default and fine at many steps; v avoids dividing by √ā near pure noise, which matters for few-step sampling, distillation and zero-terminal-SNR schedules.
In clean-image units the ε loss weights each level by its SNR, so nearly clean timesteps dominate the gradient; x0 does the opposite. Min-SNR caps the weight at γ = 5, which takes effort away from easy low-noise steps and conflicting gradients; Hang et al. report 3.4 × faster convergence on ImageNet 256 (published).
Its schedule leaves √ā = 0.068 at the last step; per value that is little, but the per-channel average over 4,096 values keeps an SNR of about 19, so the model learns to read brightness off its input even at t = 999, and pure noise at sampling has average 0. Fine-tune with zero terminal SNR plus v-prediction, sample from the last timestep (trailing) and use CFG rescale (Lin et al.); the cheap patch is offset noise (about 0.1) in the fine-tune.
At SNR 0 the input equals the noise, so ε is trivially the input (nothing to learn) and the clean-image guess divides by √ā = 0. v = √ā ε − √(1 − ā) x0 becomes −x0 there: a well-posed target (predict the average image), and no division.
Same training for all; DDIM drops the fresh noise and follows the probability-flow path, so it works at 10 to 50 steps and a seed reproduces an image. For a well-trained text-to-image model: DPM-Solver++ 2M (or UniPC) at 20 to 30 steps with trailing or Karras spacing. Pick a stochastic sampler (ancestral, SDE variants, EDM churn) when the model's errors dominate (under-trained, small, or out of distribution) and you can afford more steps; measure both, since the ranking depends on the checkpoint (here DDPM won).
The timesteps the scheduler actually walks (scheduler.timesteps): with "leading" spacing the first step is far below the last training step. Then the prediction type, and whether the model was trained for few steps at all.
Two denoiser evaluations per step (usually one batch of two) and 10 to 20% of training steps with the condition dropped. It buys adherence to the condition and cleaner samples at the cost of diversity; too high a scale oversaturates. On the tiny model class accuracy rose from 77.8% at s = 1 to 96.4% at s = 5 while diversity fell.
CFG rescale (free, φ = 0.7; slightly flatter images, and little effect on an ε-model like SD 1.5), a guidance interval (free, saves calls; needs the interval tuned), a lower scale (loses prompt adherence). For pixel models, dynamic thresholding. If you can train a second model, autoguidance avoids the trade-off between diversity and quality that CFG makes.
They train a student to map any point on a teacher's ODE trajectory straight to its end point (self-consistency along the trajectory), with cskip/cout so the map is the identity at σ = 0; sampling is one jump, optionally re-noise and jump again. They lose some diversity and fine detail, and classifier-free guidance becomes a training-time setting (LCM bakes in a guidance range; run at scale 1 to 2).
Count calls: 30 × 2 = 60 denoiser passes plus a VAE decode. Steps: switch to DPM-Solver++ 2M at 20 to 25 steps (no training). Guidance: distil it into the model (one call per step) or guide only within an interval (fewer double calls). Then distil steps: LCM/LCM-LoRA or adversarial distillation (ADD, DMD2) to 4 steps, which is 4 calls; check prompt adherence and diversity against the teacher on a fixed prompt set (CLIPScore, a preference model, FID on a held-out set). Then per-call cost: bf16, compiled graphs, a fast VAE decoder, batching. Trade-offs to state: distillation loses some diversity and editability; keep the base model for high-quality modes.
Runs (all measured on Apple M1 Pro, MPS, one GPU job at a time under the topic's shared lock; torch 2.14.1, diffusers 0.41.0; code in this page's src/runs/, recorded outputs in src/out/):
src/diff/ of the root page): train_ddpm.py trained the ε- and v-models (4,000 steps, 15.1 min each); sample_tiny.py recorded the trajectories, the four samplers at 1 to 1,000 steps and the guidance sweep; sd_lab.py the SD 1.5 timings and the spacing comparison. This page reads those recordings (runs/make_data_more.py) and never recomputes them.gmm_toy.py (CPU, seconds): the exact-score toy, 20,000 samples per setting; check_toy.mjs proves the page's JavaScript port equal to it.dz_train.py: the lab's ε-model resumed for 4,000 more steps (14.8 min), and the weak model for autoguidance (TinyUNet base 16, 262,385 parameters, 1,000 steps, 2.3 min).dz_sample.py: every sampler, the η sweep, EMA against raw weights, the bugs, the 8,000-step model, and the guidance variants on the tiny model, 1,000 samples each with the lab's noise and scoring; it first reproduces two of the lab's numbers (DDIM 10 steps FD 181.3 and DDPM 10 steps 130.5, the lab's 181.34 and 130.5).dz_sd.py: SD 1.5 (fp16, attention slicing, peak 4.43 GiB of MPS memory): CFG rescale, negative prompts, the guidance interval with a hand-written loop (identical to the pipeline's image, largest pixel difference 0), zero terminal SNR on the ε-model, LCM-LoRA. 23 images in all.recompute.py: every derived number (schedules, the brightness leak, σ ranges, Karras spacing).Models. The root's checkpoints df_ddpm_eps_4000 (TinyUNet, 1,040,353 parameters, Fashion-MNIST, MIT licence); stable-diffusion-v1-5/stable-diffusion-v1-5 at revision 451f4fe (CreativeML OpenRAIL-M; safety checker not loaded); latent-consistency/lcm-lora-sdv1-5 at revision cf2fced (openrail++). Scores: the shared Fashion-MNIST classifier's feature space (Fréchet distance "FD", class accuracy, within-class diversity), the same as the topic's diffusion and flow runs (root src/diff, src/flow), so the pages' numbers compare directly.
Source read at diffusers v0.41.0 (commit 086bf9578c0f): schedulers/scheduling_ddpm.py (214 to 229 schedules, 388 and 534 to 535 the posterior, 569 and 608 add_noise), scheduling_ddim.py (103 to 137 zero terminal SNR, 286 and 481 to 488 η, 357 to 376 spacing), scheduling_dpmsolver_multistep.py (222 to 228 defaults, 982 to 992 the 2M update), scheduling_euler_discrete.py (278 init_noise_sigma, 345 input scaling, 551 Karras ρ, 772 to 786 the Euler step), scheduling_edm_euler.py (92, 210, 236 to 239, 596 preconditioning), scheduling_lcm.py (565 to 566), pipelines/stable_diffusion/pipeline_stable_diffusion.py (86 to 91 and 1057 CFG rescale, 713 initial noise, 764, 1037 and 1055 guidance), training_utils.py (82 compute_snr, 632 EMA decay), examples/text_to_image/train_text_to_image.py (973 to 976 offset noise, 1028 to 1034 Min-SNR).
Papers (numbers transcribed with table and page in src/inputs/published.json, read 2026-10-17): Ho, Jain, Abbeel 2020 (DDPM); Song, Meng, Ermon 2020 (DDIM); Song et al. 2021 (score SDE); Dhariwal, Nichol 2021 (classifier guidance); Ho, Salimans 2022 (classifier-free guidance); Saharia et al. 2022 (Imagen); Salimans, Ho 2022 (progressive distillation, v); Karras et al. 2022 (EDM); Meng et al. 2023 (guidance distillation); Lu et al. 2022 (DPM-Solver++); Hoogeboom, Heek, Salimans 2023 (simple diffusion); Zhao et al. 2023 (UniPC); Song et al. 2023 (consistency models); Hang et al. 2023 (Min-SNR); Kingma, Gao 2023 (diffusion objectives); Lin et al. 2023 (flawed schedules); Luo et al. 2023 (LCM); Luo et al. 2023 (LCM-LoRA); Sauer et al. 2023 (ADD); Yin et al. 2023 (DMD); Yin et al. 2024 (DMD2); Karras et al. 2023 (EDM2); Kynkaanniemi et al. 2024 (guidance interval); Karras et al. 2024 (autoguidance).
Old Notion page: not compared (Notion disconnected on 2026-10-17); see src/coverage.md.
src/runs/ and src/out/ in this page's folder; runs/make_data.py and runs/make_data_more.py build the page data, runs/check_data.py proves the page embeds exactly it.The map: diffusion next to VAEs, flow matching and autoregressive generation, and which page owns what. The tiny-model recordings this page reads are the topic's diffusion runs (root src/diff/out). see the page
The same tiny network trained with flow matching (it beats DDIM at every step count from 1 to 50, and plain Heun fails at the data end); reflow, timestep sampling, SD3's shift. about 36 min
The U-Net and DiT that this page's samplers call, and few-step distillation (section 10). about 39 min
The latent space SD 1.5 diffuses in. about 40 min
Why FD and FID need large samples. about 27 min
The paper page: forward and reverse chains animated on a 2-D toy, four toy DDPMs from Table 2, the learned score field, the paper's tables and a "then and now" recipe card. about 18 min
The derivations this page uses: the diffusion forward process and ELBO down to "predict the noise" (derivations D3 and D4 in section 7), score matching (D5), DDIM (D6), classifier-free guidance (D7). 20 min, plus 26 in closed details
The paper behind Stable Diffusion: why diffuse in a latent space. about 24 min
Diffusion language models: the same denoise-from-noise idea over tokens, owned there. see the page
Diffusion applied to text: what changes when the data are tokens. see the page
The language-model counterpart: temperature, top-p and their trade-off between fidelity and variety, the same tension guidance controls here. see the page
The paper that separates schedule, preconditioning, sampler and stochasticity; sections 2 to 5 are this page's spine. about 90 min
Zero terminal SNR, trailing timesteps and CFG rescale; eight pages. about 30 min
Every weighting and noise distribution of section 3 on one λ axis. about 60 min
The exponential-integrator view and why guided sampling needs the data-prediction form. about 45 min
Autoguidance, with a 2-D toy that explains why CFG loses diversity. about 45 min
The idea behind LCM and most one-to-four-step models. about 60 min
A clear essay on what guidance does geometrically; his blog's "noise schedules considered harmful" and "perspectives on diffusion" posts are worth the same time. about 25 min
Every scheduler class used here, with its options (spacing, Karras sigmas, thresholding, zero terminal SNR). about 20 min