Latent Diffusion Models

The paper moves diffusion modeling from pixel space into the latent space of a pretrained autoencoder and adds cross-attention conditioning for flexible high-resolution generation.

Metadata

FieldValue
PaperHigh-Resolution Image Synthesis with Latent Diffusion Models
AuthorsRobin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, Bjorn Ommer
Year2021 preprint; 2022 conference
VenueCVPR 2022
arXiv2112.10752
CVFCVPR 2022 paper
CodeCompVis/latent-diffusion
Statusfull note started

One-Line Takeaway

Latent Diffusion Models split image generation into:

where and are a pretrained image autoencoder, and the diffusion model operates on compressed latent rather than pixels .

Question

Pixel-space diffusion models are high quality, but expensive. For an image:

the denoising U-Net must run repeatedly over a large spatial tensor.

The architecture question is:

LDM answers by choosing a perceptual latent space:

The diffusion model works in -space, then a decoder maps back to pixels.

Main Claim

Diffusion in a learned latent space gives a better compute-quality tradeoff than diffusion directly in pixels, while cross-attention turns the denoiser into a flexible conditional generator.

The compact claim:

This is an architecture claim because it changes where the generative process happens and how conditioning enters the denoising network.

Architecture Contract

ItemContract
Input image
Encoder
Latent
Compression factor
Generatordenoising diffusion model in latent space
BackboneU-Net-style denoiser
Conditioningcross-attention over text, layout, masks, boxes, or other context
Decoder
Outputimage or image-like prediction
Main benefitlower compute and memory than pixel diffusion

Autoencoder Stage

The first stage learns an image autoencoder:

The autoencoder should compress spatial resolution while preserving perceptual detail:

The key architecture choice is the compression factor :

CompressionEffect
small high fidelity, more diffusion compute
large cheaper diffusion, more reconstruction loss
moderate target tradeoff in LDM

If compression is too weak, latent diffusion remains expensive. If compression is too aggressive, the decoder cannot reconstruct high-quality images.

Latent Diffusion Objective

After training the autoencoder, diffusion is applied to the latent representation:

The forward noising process is:

Equivalently:

The denoiser predicts noise:

where is optional conditioning.

The simplified training loss is:

This is the DDPM objective moved from to .

Why Latent Space Helps

If the autoencoder downsamples by factor , the spatial area shrinks by:

For example, pixels with becomes:

latent spatial resolution.

The denoising U-Net therefore runs on a much smaller tensor:

The exact compute does not shrink only by because channel count, attention blocks, and decoder cost matter. But the dominant spatial denoising workload is greatly reduced.

Cross-Attention Conditioning

LDM adds conditioning through cross-attention layers inside the denoising U-Net.

Let be an intermediate latent feature map flattened into spatial tokens, and:

be conditioning tokens from a condition encoder, such as text embeddings.

Cross-attention computes:

Then:

This lets each spatial latent location attend to condition tokens.

The important contract:

This is why LDM can support text, class labels, segmentation maps, bounding boxes, masks, and other conditioning forms under a shared architecture pattern.

Sampling Path

At sampling time:

  1. start from latent noise:
  1. run iterative denoising:
  1. decode:

The generated image is only as good as both parts:

Relation To DDPM

DDPM gives the core denoising diffusion framework:

LDM keeps the diffusion idea but changes the data space:

AxisPixel DiffusionLatent Diffusion
denoising spacepixelsautoencoder latent
computehigh at large resolutionlower due to spatial compression
output detaildirectly modeled in pixelsdepends on decoder
conditioningpossiblecross-attention emphasized
high-resolution synthesisexpensivemore practical

LDM should not be read as replacing diffusion. It is a better architectural placement for the diffusion process.

Relation To VAE And Autoencoders

The autoencoder in LDM is not the whole generative model. It provides a latent space where the diffusion prior operates.

Compare:

ModelLatent Role
[[papers/architectures/auto-encoding-variational-bayesVAE]]
VQGAN-like autoencodercompress image into perceptual latent or code representation
LDMtrains diffusion prior over a pretrained perceptual latent

The key difference:

LDM samples by an iterative denoising process in latent space.

Relation To Stable Diffusion

Stable Diffusion is a prominent text-to-image system built from the LDM architecture family:

The paper note should not be reduced to one product. The reusable architecture idea is:

Later systems modify text encoders, U-Net sizes, guidance, data curation, conditioning, samplers, and training recipes, but the LDM decomposition remains a durable pattern.

Why It Belongs In Architecture Papers

LDM is a canonical architecture paper because it changes the location of the generative model:

It also makes cross-attention conditioning a central design pattern for image generation.

Design ChoiceWhy It Matters
pretrained autoencoderseparates compression from generative prior
latent denoisingreduces compute and memory
U-Net denoiserpreserves spatial inductive bias
cross-attentionflexible conditioning interface
decoderconverts latent samples to pixels
compression factorquality/compute bottleneck

This note connects DDPM, cross-attention, and modern text-to-image systems.

Evidence Pattern

The paper supports the architecture with:

EvidenceWhat It Supports
autoencoder compression studiesuseful compute/fidelity tradeoff exists
image generation benchmarkslatent diffusion can remain competitive with pixel models
inpainting and super-resolutionlatent diffusion works beyond unconditional generation
conditioning experimentscross-attention supports flexible inputs
compute comparisonlatent-space denoising reduces cost

For reading, the key ablation is not only sample quality. It is the tradeoff curve between reconstruction fidelity, latent compression, and diffusion compute.

Practical Reading Checks

QuestionWhy
What is the latent downsampling factor ?controls compute and reconstruction quality
Is the autoencoder frozen during diffusion training?separates representation from prior
What loss trained the autoencoder?perceptual quality affects final samples
Where does cross-attention enter the U-Net?controls conditioning capacity
What condition encoder is used?text/layout/mask quality depends on it
What sampler and guidance are used?sample quality may not be architecture alone
Are metrics pixel, perceptual, CLIP-based, or human preference?evaluation target changes conclusions

Limits

  • The decoder can cap final visual detail.
  • Compression can remove information that diffusion cannot recover.
  • The denoiser still requires iterative sampling.
  • Conditioning quality depends on the condition encoder and training data.
  • Cross-attention can bind prompts imperfectly.
  • Compute is reduced, not eliminated.
  • Benchmark gains can depend on sampler, guidance, data, and metric choice.

The concise limitation:

What To Remember

  • LDM moves diffusion from pixels to a pretrained autoencoder latent.
  • The core generation path is encode, denoise in latent space, decode.
  • The denoising objective is DDPM-style but applied to .
  • Cross-attention makes conditioning flexible and reusable.
  • The compression factor is an architecture bottleneck.
  • Stable Diffusion is a major descendant, but the paper’s durable idea is broader than one system.