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
| Field | Value |
|---|---|
| Paper | High-Resolution Image Synthesis with Latent Diffusion Models |
| Authors | Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, Bjorn Ommer |
| Year | 2021 preprint; 2022 conference |
| Venue | CVPR 2022 |
| arXiv | 2112.10752 |
| CVF | CVPR 2022 paper |
| Code | CompVis/latent-diffusion |
| Status | full 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
| Item | Contract |
|---|---|
| Input image | |
| Encoder | |
| Latent | |
| Compression factor | |
| Generator | denoising diffusion model in latent space |
| Backbone | U-Net-style denoiser |
| Conditioning | cross-attention over text, layout, masks, boxes, or other context |
| Decoder | |
| Output | image or image-like prediction |
| Main benefit | lower 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 :
| Compression | Effect |
|---|---|
| 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:
- start from latent noise:
- run iterative denoising:
- 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:
| Axis | Pixel Diffusion | Latent Diffusion |
|---|---|---|
| denoising space | pixels | autoencoder latent |
| compute | high at large resolution | lower due to spatial compression |
| output detail | directly modeled in pixels | depends on decoder |
| conditioning | possible | cross-attention emphasized |
| high-resolution synthesis | expensive | more 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:
| Model | Latent Role |
|---|---|
| [[papers/architectures/auto-encoding-variational-bayes | VAE]] |
| VQGAN-like autoencoder | compress image into perceptual latent or code representation |
| LDM | trains 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 Choice | Why It Matters |
|---|---|
| pretrained autoencoder | separates compression from generative prior |
| latent denoising | reduces compute and memory |
| U-Net denoiser | preserves spatial inductive bias |
| cross-attention | flexible conditioning interface |
| decoder | converts latent samples to pixels |
| compression factor | quality/compute bottleneck |
This note connects DDPM, cross-attention, and modern text-to-image systems.
Evidence Pattern
The paper supports the architecture with:
| Evidence | What It Supports |
|---|---|
| autoencoder compression studies | useful compute/fidelity tradeoff exists |
| image generation benchmarks | latent diffusion can remain competitive with pixel models |
| inpainting and super-resolution | latent diffusion works beyond unconditional generation |
| conditioning experiments | cross-attention supports flexible inputs |
| compute comparison | latent-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
| Question | Why |
|---|---|
| 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.