TL;DR
Alex Nichol and Prafulla Dhariwal show that a diffusion model trained with the 2020 DDPM recipe can be made much better at two things it was weak on: log-likelihood, which measures how well the model covers the data, and sampling speed. Three changes do most of the work: the model learns the variance of each reverse step, the noise schedule is changed to a cosine curve, and the likelihood term is estimated with importance sampling. The result is competitive likelihood, near-optimal samples with about 100 sampling steps instead of the 4,000 used in training, and higher recall than the GAN BigGAN-deep at comparable sample quality.
Builds on: Denoising Diffusion Probabilistic Models (DDPM), Importance Sampling, Cosine Noise Schedule · Leads to: DDIM Sampler as the other fast-sampling method the paper compares against
Why it mattered
The paper turned DDPMs from a striking image generator into a serious likelihood model. Before it, diffusion models had excellent FID and Inception scores but poor log-likelihood, and the field believed that a weak likelihood meant the model missed parts of the data distribution. The paper's experiments show the gap can be closed on ImageNet 64 by 64 and CIFAR-10 without changing the core idea of the model.
Its sampling result is what made diffusion practical. The authors trained with 4,000 diffusion steps, and a single sample took several minutes at that length. They show that a trained model reaches near-optimal FID with 100 sampling steps. The abstract describes the saving as an order of magnitude fewer forward passes, with a negligible difference in sample quality. The cosine schedule, learned variance and strided sampler from this paper are used widely in later image-diffusion systems, and the paper's code is public.
The problem
Ho and colleagues' DDPM trained a network to predict the noise in an image at a random step, and that objective gives good samples measured by FID. But the same model was poor on log-likelihood. The paper asks three questions. Can DDPMs match the likelihood of autoregressive models and VAEs? Do they cover the modes of a diverse dataset such as ImageNet? And can they sample in far fewer steps?
Each question has a concrete obstacle. The likelihood is a sum of terms, and optimising it directly was noisy in practice. The variance of each reverse step was fixed, not learned. The linear noise schedule destroyed information too fast at the end of the process, which wasted steps. And sampling used the full chain of steps, which is slow. The paper addresses each in turn.
How it works
Take a toy process with training steps and ask for a sampler with steps. The pipeline has four changes, and each is traced below on the toy numbers.
- Choose the noise schedule. The cosine schedule defines the fraction of signal that survives at each step through , and it drops smoothly in the middle of the process. The paper's schedule is designed so that very little changes at the two ends of the chain.
- Predict the noise and the variance together. The network outputs the noise estimate and a vector that sets the variance of each reverse step. The variance is an interpolation, in the log domain, between two bounds, so it is always in the right range. Check: with and , the variance is when , when , and when .
- Train on a hybrid loss. The objective adds the simple noise loss to a small multiple of the full likelihood bound, with a stop-gradient on the mean, so that the bound only moves the variance. Check: the simple term sets the samples, and the bound term only adds a small correction.
- Sample with fewer steps. Choose evenly spaced steps from the original steps, round them, and run the reverse chain on that subsequence. For and the steps are , which are already integers. Check: the variance formula is recomputed for the shorter gap between steps, so the learned variance keeps its range.
The likelihood bound in step 3 is estimated by sampling a random step for each training example. Importance sampling, in section 3.3 of the paper, samples the steps in proportion to the root mean square of their loss terms, which removes most of the gradient noise.
flowchart LR A[Cosine schedule] --> B[Predict noise and variance] B --> C[Hybrid loss: simple plus small VLB term] C --> D[Importance-sampled VLB for likelihood] D --> E[Trained model] E --> F[Strided sampling with K steps] F --> G[Image]
The math
The forward and reverse chains (step 2 in symbols)
The forward process adds Gaussian noise with variance at each step, and and . The noisy image at step has a closed form:
The reverse step is . The variational lower bound is a sum of KL terms, , each a KL divergence between two Gaussians.
The learned variance (step 2 in symbols)
The paper parameterises the variance by an interpolation between the two bounds and , where is the variance of the true posterior:
Here is the network's output, with one value per dimension. Working in the log domain keeps the variance positive, and the bounds keep it in a range that a network can learn easily.
The hybrid loss (step 3 in symbols)
where is the noise-prediction loss from DDPM. A stop-gradient on inside means that the bound trains while trains the mean.
The cosine schedule (step 1 in symbols)
The offset keeps from being too small at the start, and is clipped at near the end.
Importance sampling (step 3 in symbols)
The second moments are estimated from the last 10 values of each term, which the paper updates during training. Sampling steps in proportion to gives a much lower-variance estimate of the bound.
Strided sampling (step 4 in symbols)
For a subsequence of the original steps, the sampling schedule is , and the variance is computed from it in the same way. The learned then interpolates inside the new, wider gaps.
Results
Likelihood and FID on ImageNet 64 by 64. Table 1 of the paper ablates the changes. With 4,000 steps and the linear schedule, the simple loss gives NLL 3.77 bits per dimension and FID 31.3. Switching to the cosine schedule with the simple loss gives NLL 3.68 and FID 27.0. Adding the hybrid loss and learned variance at the same schedule gives NLL 3.62 and FID 28.0. Optimising the bound directly with importance sampling gives the best likelihood, NLL 3.57 at 200,000 iterations, but a worse FID of 56.7. At 1.5 million iterations, the hybrid model reaches NLL 3.57 with FID 19.2. The paper says that the hybrid objective is generally preferred because it gives a likelihood gain without losing sample quality.
CIFAR-10. The same pattern holds. The linear schedule with the simple loss gives NLL 3.37 and FID 2.90 at 4,000 steps. The cosine bound-only model reaches NLL 2.94, which is the best of the table, but its FID is 11.47.
Comparison with other likelihood models. In Table 3 the improved model reaches 3.53 bits per dimension on ImageNet 64 and 2.94 on CIFAR-10. The original DDPM had 3.77 and 3.70. The paper says this makes it competitive with the best convolutional models on ImageNet 64, though fully transformer-based models were still better.
Sampling speed. Figure 8 and the text report that the hybrid model keeps its sample quality as steps are removed, while fixed-variance models degrade. At 100 steps it reaches near-optimal FID on the fully trained models. DDIM is better with fewer than 50 steps, and the hybrid model is better at 50 or more.
GAN comparison. On class-conditional ImageNet 64 with 250 steps, the large diffusion model has FID 2.92, precision 0.82 and recall 0.71. BigGAN-deep has FID 4.06, precision 0.86 and recall 0.59. The paper reads the recall gap as evidence that diffusion models cover more of the target distribution, even though the GAN has the higher precision.
Limits. The scaling study uses four model sizes and is labelled preliminary. Validation NLL does not fit a power law as cleanly as FID does, and the paper names a possible irreducible loss or overfitting as causes. The two-stage ImageNet 256 result, FID 12.3, is still well behind BigGAN at 7.7 in the paper's table.
Reading guide
- §1 Introduction: the three questions and the claimed results. Needs Denoising Diffusion Probabilistic Models (DDPM) and Score Matching for the background.
- §2 DDPM review: the forward chain, the reverse chain, the variational bound and the simple loss. Needs Variational Lower Bound (ELBO), Kullback–Leibler Divergence, Gaussian (Normal) Distribution and Reparameterization Trick.
- §3.1 Learned variance: the log-domain interpolation and the hybrid objective. Needs Denoising Diffusion Probabilistic Models (DDPM) and Maximum Likelihood Estimation.
- §3.2 Noise schedule: the cosine schedule and the reason the linear one destroys information too quickly. Needs Cosine Noise Schedule.
- §3.3 Gradient noise: importance sampling over steps. Needs Importance Sampling.
- §3.4 and Tables 1–3: the ablations and the comparison with other likelihood models. Needs U-Net for the backbone and Autoregressive Model and Variational Autoencoder as the comparison families.
- §4 Sampling speed: strided sampling and DDIM. Needs DDIM Sampler.
- §5 Comparison to GANs: precision, recall and FID. Needs Precision and Recall, Fréchet Inception Distance and Generative Adversarial Network.
- §6 Scaling: the training-compute study. Read for the trend; no new prerequisite.
- Appendices: hyperparameters, LSUN 256 sampling and the ImageNet 256 two-stage model. Needs Adam Optimizer for the optimiser.
Check yourself
QuestionWith training steps, a sampler uses evenly spaced steps. Which steps does it run, and by what factor is the number of network evaluations reduced?Show answer
The steps are , since they are evenly spaced with gap 3 and are already integers. The model runs 4 evaluations instead of 10, a reduction by a factor of . For the paper's and a 100-step sampler, the same arithmetic gives a factor of , which is consistent with the order-of-magnitude speed-up the abstract claims.
QuestionWith and , what variance does the learned interpolation give at ?Show answer
The log-domain interpolation gives . Compute the exponent: and , so the exponent is . The variance is . This lies between the two bounds, as it must, and is closer to because is closer to .
QuestionWhy does the paper use with instead of optimising directly, given that the bound is the quantity that measures likelihood?Show answer
Optimising directly gives the best likelihood but a much worse FID, 56.7 against 28.0 for the hybrid at 200,000 iterations, so sample quality suffers. The simple loss is what trains the mean and gives good samples. The small weight stops the bound from overwhelming it, while still letting the bound train the variance. The paper says the hybrid gives a likelihood gain without sacrificing sample quality.
QuestionA team says their diffusion model has FID close to a GAN's, so their samples cover the data as well as the GAN's. What does the paper's precision and recall comparison say about that claim?Show answer
FID alone does not establish coverage. The paper finds that its large diffusion model has FID 2.92 against BigGAN-deep's 4.06, but recall 0.71 against 0.59 and precision 0.82 against 0.86. Precision measures how many samples look like the data, and recall measures how much of the data the samples cover. So the diffusion model covers more of the distribution, with slightly lower precision. The team should report precision and recall, not FID alone, before claiming equal coverage.
Sources
- Nichol and Dhariwal, Improved Denoising Diffusion Probabilistic Models, arXiv:2102.09672 (2021). https://arxiv.org/abs/2102.09672
- Ho, Jain and Abbeel, Denoising Diffusion Probabilistic Models, arXiv:2006.11239 (2020). https://arxiv.org/abs/2006.11239
- Song, Meng and Ermon, Denoising Diffusion Implicit Models, arXiv:2010.02502 (2020). https://arxiv.org/abs/2010.02502
- Code released with the paper: https://github.com/openai/improved-diffusion