Search

Search papers and lessons

Cascaded Diffusion Model

Level 4 · 12 min read

A cascaded diffusion model makes an image in stages: a small model draws the layout at low resolution, then super-resolution diffusion models add detail, each trained to fix the last stage's errors.

On this page

  • Colour = topic mix
  • Probability
  • Calculus
  • Discrete math
  • Linear algebra
  • Architectures
  • Neural network basics
  • ReadReady to readNot yet

TL;DR

A diffusion model that tries to produce a large, sharp image in one go spends most of its effort on fine texture and has trouble with global layout. A cascaded diffusion model splits the job into stages. A base model generates a small image, and one or more super-resolution diffusion models each upsample the previous result and add detail. Each stage is trained on a corrupted version of its input, so it learns to correct the mistakes of the stage before it.

Builds on: Diffusion Model, Super-Resolution, U-Net · Leads to: text-to-image systems such as Imagen, which use this pipeline to reach 1024 by 1024 pixels

Where it's used

Text-to-image generation. Imagen, described by Saharia and colleagues in 2022, generates a 64 by 64 image from a text prompt with a base diffusion model, then uses two text-conditional super-resolution models to reach 256 by 256 and then 1024 by 1024. The paper reports that noise conditioning augmentation, described below, is critical for high-fidelity output.

High-resolution class-conditional images. The original cascaded paper by Ho and colleagues applies the same idea to class-conditional image generation, such as producing a specific kind of object, and reports high-fidelity samples at resolutions higher than a single diffusion model could reliably produce.

Any image pipeline where a cheap model proposes and a second model refines. A low-resolution draft can be checked and corrected at higher resolution. The stages can be trained separately, which lets a team reuse a super-resolution model with a new base model.

How it works

Trace one tiny instance with a two-stage cascade. The base model makes a 2 by 2 image, and the super-resolution model turns it into a 4 by 4 image. Brightness values are between 0 and 1.

  1. The base model draws the layout. It samples a 2 by 2 image with pixel values [[0.80,0.20],[0.60,0.40]][[0.80, 0.20], [0.60, 0.40]]. These four numbers are all the detail it has, and the bright pixel sits at the top left. Check: four values, one per base pixel.

  2. Enlarge the draft with a fixed rule. Bilinear interpolation gives a 4 by 4 image that is smooth but blurry. Its top row is a smooth ramp that starts at the bright value 0.800.80 and falls toward the dark value 0.200.20. Check: the blur is a ramp, not a sharp edge.

  3. Corrupt the draft on purpose. Before the super-resolution model sees the draft, the pipeline mixes it with Gaussian noise and records the noise level, which is the augmentation level. With level coefficient 0.640.64 and a noise draw of 0.50.5, the pixel 0.800.80 becomes 0.940.94 (the math section works this out). The model is told the level 0.640.64. Check: the model now sees a draft whose errors look like the ones a real base model would make.

  4. Denoise and add detail. The super-resolution model is a U-Net diffusion model, conditioned on the corrupted draft and the augmentation level. Starting from noise, it denoises toward a sharp 4 by 4 image that agrees with the draft. Suppose it outputs 0.820.82 for the corrected pixel. Check: the output is close to the draft but not identical to it, because the model has added detail.

  5. Train, then check. The stage is trained on many such pairs. At each step it is penalised for predicting the wrong noise, so the layout from the base model is kept and the texture is filled in.

The key idea is in step 3. Without the corruption, the super-resolution model learns to trust its input perfectly. At test time the input is an imperfect draft, so the model would copy its errors. Training it on corrupted drafts teaches it to fix them.

flowchart LR
    T["Text prompt"] --> B["Base diffusion model, 64 by 64"]
    B --> E1["Bilinear enlarge to 256 by 256"]
    E1 --> N1["Noise augmentation, level recorded"]
    N1 --> S1["Super-resolution model, 256 by 256"]
    S1 --> E2["Bilinear enlarge to 1024 by 1024"]
    E2 --> N2["Noise augmentation, level recorded"]
    N2 --> S2["Super-resolution model, 1024 by 1024"]

The math

Definition: Cascaded diffusion model

A cascaded diffusion model is a sequence of conditional diffusion models pθ1(x(1)∣c), pθ2(x(2)∣xaug(1),c), …p_{\theta_1}(x^{(1)} \mid c), \, p_{\theta_2}(x^{(2)} \mid x^{(1)}_{\mathrm{aug}}, c), \, \ldots, where x(k)x^{(k)} is the image at resolution level kk, cc is the condition such as a class or a text embedding, and xaug(k)x^{(k)}_{\mathrm{aug}} is the image from the previous level after noise augmentation at a level ss that is sampled during training and given to the model.

Step 1 in symbols: the base stage

The first model is an ordinary Diffusion Model trained on low-resolution images. It learns pθ1(x(1)∣c)p_{\theta_1}(x^{(1)} \mid c), and at test time we sample from it once.

Step 2 in symbols: the enlargement

The previous image is enlarged with a fixed operator UU, usually bilinear interpolation, so the conditioning signal is U(x(k−1))U(x^{(k-1)}). The operator adds no information, which is why the next stage has to add detail.

Step 3 in symbols: noise augmentation

For a conditioning image zz and a sampled level ss with cumulative noise coefficient αˉs\bar\alpha_s, the augmented input is

z~=αˉs z+1−αˉs ε′,ε′∼N(0,I),\tilde z = \sqrt{\bar\alpha_s}\, z + \sqrt{1 - \bar\alpha_s}\, \varepsilon', \qquad \varepsilon' \sim \mathcal{N}(0, I),

where ε′\varepsilon' is a draw of Gaussian noise with mean 0 and identity covariance, and z~\tilde z is the augmented input the model sees.

This is the same forward-noising formula as in Diffusion Model, applied to the conditioning image instead of the target. The level ss is passed to the model, so it knows how much to trust its input. In the example, αˉs=0.64\bar\alpha_s = 0.64 gives 0.64=0.8\sqrt{0.64} = 0.8 and 1−0.64=0.6\sqrt{1 - 0.64} = 0.6, so with z=0.8z = 0.8 and ε′=0.5\varepsilon' = 0.5 the augmented value is 0.8⋅0.8+0.6⋅0.5=0.940.8 \cdot 0.8 + 0.6 \cdot 0.5 = 0.94.

Step 4 in symbols: the stage loss

Each stage is trained with the noise-prediction loss of a diffusion model, now conditioned on the augmented input and the level:

Lk=Ex,ε,t,s[∥ε−εθk ⁣(xt(k), t, c, z~, s)∥2],L_k = \mathbb{E}_{x, \varepsilon, t, s} \left[ \left\| \varepsilon - \varepsilon_{\theta_k}\!\left(x^{(k)}_t,\ t,\ c,\ \tilde z,\ s\right) \right\|^2 \right],

where xt(k)x^{(k)}_t is the target at noise step tt. The loss is a Mean Squared Error between the true noise and the predicted noise, computed per stage.

Step 5 in symbols: sampling

Sampling chains the stages: draw x(1)x^{(1)} from the base model, enlarge and augment it, draw x(2)x^{(2)} from the next stage, and so on. The approximation is that each stage only has to model the conditional distribution of detail given the layout, which is much simpler than the full joint distribution over all pixels.

Worked examples

Example
Example 1: how many values each stage makes (tiny)

A cascade has a base model at 64×6464 \times 64, one super-resolution model at 256×256256 \times 256, and another at 1024×10241024 \times 1024.

  1. The base model outputs 64⋅64=409664 \cdot 64 = 4096 values.
  2. The first super-resolution model outputs 256⋅256=65,536256 \cdot 256 = 65{,}536 values.
  3. The second outputs 1024⋅1024=1,048,5761024 \cdot 1024 = 1{,}048{,}576 values.
  4. The final stage therefore produces 1,048,576/4096=2561{,}048{,}576 / 4096 = 256 times as many values as the base model. Each step up multiplies the pixel count by 16.

Interpretation: the expensive, high-detail work is done by the later stages, but each of them only has to add detail to a layout that is already fixed.

Example
Example 2: noise augmentation by hand (standard)

The conditioning value is z=0.8z = 0.8 and the level gives αˉs=0.64\bar\alpha_s = 0.64. Consider two draws of the augmentation noise.

  1. For draw one, ε′=0.5\varepsilon' = 0.5. The coefficients are 0.64=0.8\sqrt{0.64} = 0.8 for the signal and 0.36=0.6\sqrt{0.36} = 0.6 for the noise.
  2. The augmented value is 0.8⋅0.8+0.6⋅0.5=0.64+0.30=0.940.8 \cdot 0.8 + 0.6 \cdot 0.5 = 0.64 + 0.30 = 0.94.
  3. For draw two, ε′=−1.0\varepsilon' = -1.0. The augmented value is 0.64−0.60=0.040.64 - 0.60 = 0.04.
  4. The same clean value 0.80.8 can therefore reach the model as 0.940.94 or 0.040.04, depending on the draw.
  5. The model is also told ss, so it knows the input is noisy and how noisy. It learns to predict the true detail from the noisy input and that level together.

Interpretation: a higher augmentation level makes the input less trustworthy, and the model learns to lean more on the text and the layout. That is what lets it correct a real base model's errors, which look like noise in its input.

Example
Example 3: where the layout is decided (realistic)

A designer asks for a 1024 by 1024 picture of a lighthouse on a cliff at dusk, with the lighthouse on the left third.

  1. The base model draws the whole scene at 64 by 64, which is 40964096 values. The lighthouse's position, the cliff and the sky colours are decided here.
  2. The 256 stage has 65,53665{,}536 values to fill. It adds the lighthouse's edges and the cliff's rock texture, and it must keep the layout the base model chose.
  3. The 1024 stage fills in fine texture, such as the wet stone and the light on the glass, while again keeping the layout.
  4. If the base draft put the lighthouse on the right, later stages in practice cannot move it, because each stage is conditioned on the previous image and trained to refine it, not to redraw it.
  5. The base model is the largest of the three networks in Imagen, so most of the capacity sits in the stage that decides the composition.

Try it: a base model's draft has a lighthouse at the wrong size, and the 256 stage must fix it. Is that a problem for a cascade? Answer: yes, in principle, because the super-resolution stages are trained to add detail to the layout they receive. A size error made at the base stage is usually carried through, so the base model is where the composition must be right.

Common mistakes and tradeoffs

It is tempting to think a cascade is only faster than one large model. In fact the main reason is quality. Splitting the task lets each stage model one scale of detail, which the papers report is needed for high-fidelity samples. Speed is a side effect of working at small resolution for most of the steps.

It is tempting to think the super-resolution stage can repair any base-model error. In fact it is trained on drafts whose errors look like noise, so it fixes local texture and edges well, but it has little power to change the layout the base model chose.

It is tempting to think that noise augmentation is an optional tweak. In fact the Imagen paper calls it critical, and the original cascaded paper shows that conditioning on the augmentation level improves sample quality. Without it, the stages copy the base model's artefacts.

When to use it: when a single diffusion model is too hard to train at the target resolution, and when the image can be built from a coarse layout and refined. When not to use it: when the output is small enough for one model, or when the whole picture must be coherent at every scale and a cascade's fixed layout would be a constraint. Alternatives include training one large model at full resolution, and latent diffusion, which runs the process in a compressed space.

History

Diffusion models became strong image generators from 2020, and they could make good samples at low resolution, but making sharp high-resolution images with one model was hard to train and expensive. The cascade idea answered this by splitting the task into scales.

Ho, Saharia, Chan, Fleet, Norouzi and Salimans showed in 2021 that cascaded diffusion models with noise conditioning augmentation could generate high-fidelity class-conditional images. Imagen in 2022 applied the same pipeline to text-to-image generation with a large frozen text encoder, and reported 1024 by 1024 samples. The idea caught on because it gave a clear way to scale quality without one enormous model, and because each stage could be trained and studied separately.

Recap

  • A diffusion model at full resolution is hard to train, so the task is split across scales.
  • A base model draws the layout at low resolution, and super-resolution diffusion models add detail stage by stage.
  • Each stage is conditioned on the previous image after noise augmentation at a recorded level, so it learns to correct the previous stage's errors.
  • The augmentation is the trick that makes the cascade work, because test-time drafts are imperfect.
  • Layout is decided early, so the base model carries most of the composition, and later stages refine what it chose.

Read next: Classifier-Free Guidance, which steers the base model toward a text condition, and Score Matching, the view of diffusion models that the noise predictions connect to.

Check yourself

QuestionRecall: what does the cascade do with the output of one stage before it reaches the next?Show answer

It enlarges the output with a fixed operator, such as bilinear interpolation, then adds noise at a random augmentation level and records that level. The next stage is conditioned on this augmented image and the level.

QuestionComputation: a cascade produces a 256×256256 \times 256 image from a 64×6464 \times 64 base. How many times as many values does the final image have compared with the base image?Show answer

The base has 64⋅64=409664 \cdot 64 = 4096 values and the final image has 256⋅256=65,536256 \cdot 256 = 65{,}536. The ratio is 65,536/4096=1665{,}536 / 4096 = 16.

QuestionWhy: why is noise augmentation needed, given that the super-resolution model could just be trained on clean low-resolution images?Show answer

At test time the super-resolution model receives the base model's output, which contains errors. A model trained only on clean drafts would learn to trust its input and copy those errors. Training on corrupted drafts, with the level given, teaches it to correct them.

QuestionApplied: a team wants to speed up a cascade by replacing the 64 by 64 base model with a smaller, faster model, and keeping the super-resolution stages. What is the main risk, and how would you check it?Show answer

The main risk is that the smaller base model makes worse layouts, which the super-resolution stages cannot fix, since they refine rather than redraw. You would check by generating many samples from both bases, looking at composition and prompt agreement at 64 by 64, before judging the final 1024 images.

Sources