In one line: Runs DDPM in a mildly compressed autoencoder latent space with cross-attention conditioning, matching pixel-space quality at a fraction of the compute; became Stable Diffusion and made latent diffusion the default generative recipe.
How far to trust it: Believe the idea and the efficiency: the compute ratios recompute from the paper's own tables, and every large image and video model since generates in a latent. Read the individual FIDs as single runs, several printed inconsistently between tables and figures, and "on par" in text-to-image as slightly behind GLIDE and Make-A-Scene. The evidence, point by point.
Train an autoencoder once to squeeze away the detail you cannot see (a 256² image becomes a 64 × 64 × 3 or 32 × 32 × 4 grid), run ordinary diffusion in that small latent with cross-attention to a text or other condition, and decode once at the end: about the same quality as pixel-space diffusion for a few times less compute, which is what made Stable Diffusion run on a consumer GPU.
The denoiser never sees a pixel: encode once, diffuse the small tensor, decode once. Fig. 1 is the paper's Figure 3 run by this page's toy models: every grid is drawn one tile per number at one cell size, so the image and its latent are to scale. Drag it to turn it.
ℰ and 𝒟 are the stage-1 autoencoder, trained once and frozen; εθ is the stage-2 UNet; τθ encodes the condition y into the keys and values of every cross-attention layer, while spatially aligned inputs are concatenated to the latent instead (§3). The arXiv paper is not CC BY, so no copy of the original figure. Toy models: the f = 4 autoencoder and the latent model of the Generate tab (seed 3, guidance 3, the chain the Idea animation replays), counted live in your browser; the pixel-space figure is the toy pixel model's measured multiply-adds per evaluation times 40.
You need how a diffusion model trains and samples (DDPM, Diffusion from zero: DDPM, samplers and guidance). How today's latent models are built (DiT, MMDiT, text encoders) is on Latent diffusion and diffusion transformers.
New terms. Perceptual compression: removing imperceptible high-frequency detail (the autoencoder's job). Semantic compression: learning what the image is (the diffusion model's job). f: the autoencoder's downsampling factor per side; LDM-f is a model in that latent, LDM-1 is pixel space. KL-reg. and VQ-reg.: the two mild regularisers of the latent. τθ: the condition encoder.
By late 2021 diffusion models led image synthesis, class-conditional ImageNet and super-resolution among them, but they ran in pixel space and were very expensive: "training the most powerful DMs often takes hundreds of GPU days (e.g. 150 - 1000 V100 days)", and because the same network runs "sequentially for a large number of steps (e.g. 25 - 1000 steps)", "producing 50k samples takes approximately 5 days on a single A100" (§1, both citing ADM). That last figure checks out: Table 18 gives pixel-space ADM 0.12 samples per second, and 50,000 / 0.12 s is days (Table 18, recomputed independently).
The root cause, the authors argue, is where a likelihood model spends its effort. Being mode-covering, such models "spend excessive amounts of capacity (and thus compute resources) on modeling imperceptible details" (§1). A rate-distortion plot of a trained pixel-space DDPM makes it visible: most bits of an image encode details you cannot see, and the semantic composition costs few. Learning splits into a perceptual compression stage that removes high-frequency detail and a semantic compression stage that learns what the image is (Figure 2, with data from DDPM). The DDPM page rebuilds that rate-distortion curve from DDPM's own table: more than half of the 3.75 bits per dimension describe imperceptible distortion. Yet the network and its gradients "still need to be evaluated on all pixels" (Figure 2).
Earlier two-stage models already worked on a compressed space, but for autoregressive transformers, which force heavy compression into a 1-D token sequence: VQ-VAE-2, VQGAN with a transformer, DALL-E. "The high compression rates required for feasible ARM training ... limit the overall performance" (§2). Figure 1 puts numbers on the cost of that compression, reconstructing ImageNet images: this paper's f = 4 autoencoder reaches PSNR 27.4 and reconstruction FID 0.58; DALL-E's f = 8 tokenizer 22.8 and 32.01; VQGAN's f = 16 19.9 and 4.98 (Figure 1, Table 8).
The question: can a diffusion model skip the imperceptible bits, keep the fidelity, and train and sample on a budget an ordinary lab can afford?
Figure 1's numbers as printed in Table 8 (VQ-reg. f = 4 with an 8,192-entry codebook; DALL-E's f = 8 tokenizer; VQGAN f = 16, 16,384 entries). Every autoencoder of the table is in the f sweep chart below.
Each step of the chain is computed live by the toy network (DDIM, η = 0, as the paper samples; classifier-free guidance doubles the network evaluations). At the paper's scale the same picture is 256 × 256 × 3 = 196,608 numbers against 64 × 64 × 3 = 12,288 for LDM-4 or 32 × 32 × 4 = 4,096 for LDM-8; Stable Diffusion's 512 × 512 × 3 image is a 64 × 64 × 4 latent, 48 times fewer numbers (Table 13, SD config).
Separate the two kinds of compression and give each to the model that is good at it. First train an autoencoder once, so its latent space is "perceptually equivalent" to the image space but much smaller; then run ordinary diffusion in that latent, and decode once at the end (§3). Because a UNet is built for 2-D grids, the latent can stay a 2-D grid and the compression can be mild (a factor f of 4 or 8 per side, not 16 to 32), which keeps the details the earlier token models lost (§3). The authors call the result Latent Diffusion Models, LDMs.
In the animation, two real toy models trained for this page (the Generate tab has the details) generate the same prompt: one diffuses 32 × 32 × 3 pixels, the other the 8 × 8 × 3 latent of an f = 4 autoencoder, both with about 50,000 parameters, the same training steps and the same sampler. Every number is drawn as one cell at the same size, so the two chains are to scale; the counters are the actual multiply-adds the JavaScript performs. It plays once when scrolled into view; the toggle switches chains and any control stops it.
Table 6 measures 3.7 times at 256² and 4.9 times at 512² (sampling), 2.9 times in training throughput (Table 6). Not 16, because the latent models spend their parameter budget differently: with the totals matched (391M to 396M), LDM-4's UNet has channel multipliers 1, 2, 3, 5 on four levels against LDM-1's 1, 1, 2, 2, 4, 4 on six (Table 13), so each latent position carries more channels; the decoder pass and the conditioning also cost time. The toy below has the same property: 16 times fewer positions, but the networks it times in your browser differ by the ratio shown.
The autoencoder follows VQGAN: an encoder ℰ maps an RGB image x ∈ ℝH×W×3 to z = ℰ(x) ∈ ℝh×w×c, a decoder 𝒟 reconstructs x̃ = 𝒟(ℰ(x)), and the downsampling factor is f = H/h = W/w = 2m (§3.1). It is trained with a perceptual loss (LPIPS) plus a patch-based adversarial loss, which keeps reconstructions "confined to the image manifold by enforcing local realism and avoids bluriness introduced by relying solely on pixel-space losses such as L2 or L1" (§3.1).
To avoid "arbitrarily high-variance latent spaces" the latent gets one of two mild regularisers (§3.1, Appendix G):
kl_weight: 0.000001, autoencoder config).Two choices make this different from earlier tokenizers. The latent keeps its 2-D layout, where VQGAN and DALL-E impose "an arbitrary 1D ordering" for an autoregressive model; and the compression is mild, f = 4 to 8 (a 256² image becomes 64 × 64 × 3 or 32 × 32 × 4), so reconstructions stay faithful (§3.1, Table 8). The autoencoder is "trained only once" and reused for every diffusion model and task (§1). The paper's own autoencoders are on the Tables tab; here is the toy's.
Try: build an image in the explorer, then see what the toy f = 4 autoencoder keeps. The latent is three 8 × 8 maps, 16 times fewer numbers; the decoder turns it back into 32 × 32 × 3. Note what is lost: the faint grain of the background, the "imperceptible detail" the second stage never has to model.
A KL-reg. latent is not unit-variance, and its scale sets the signal-to-noise ratio the diffusion model sees. The paper divides z by its component-wise standard deviation σ̂, estimated from the first batch (Appendix G); without it the ratio is "very high, such that the model allocates a lot of semantic detail early on in the reverse denoising process", which shows up in convolutional sampling (D.1, Figure 15). VQ latents have variance close to 1 and need no rescaling. This is the scale_factor: 0.18215 in every Stable Diffusion v1 config (config); FLUX's 16-channel autoencoder uses 0.3611 (FLUX code, beyond the paper). The toy's encoder needed 1 / σ̂ = .
The diffusion part is DDPM unchanged (DDPM page, which runs it and explains the chain). A diffusion model is "an equally weighted sequence of denoising autoencoders" εθ(xt, t), trained to predict the noise in a noised input, with the reweighted bound (§3.2):
The only change is the space:
"Since the forward process is fixed, zt can be efficiently obtained from ℰ during training, and samples from p(z) can be decoded to image space with a single pass through 𝒟" (§3.2). For a KL latent, training draws z = ℰμ(x) + ℰσ(x) · ε, then rescales it (Appendix G). Why it is cheap: every one of the tens to hundreds of denoising steps runs on f² fewer spatial positions (16 times for f = 4, 64 for f = 8), while the latent stays a grid, so the UNet keeps its 2-D convolutional inductive bias (§3.2). Unlike earlier two-stage work, the prior is learned separately from a frozen first stage, so there is no "delicate weighting of reconstruction and generative abilities" as in LSGM, which trains both jointly (§1, §4.2).
To make the model conditional on arbitrary inputs y (text, semantic maps, layouts), a domain-specific encoder τθ turns y into a sequence τθ(y) ∈ ℝM×dτ, and cross-attention layers inside the UNet let every position of a flattened feature map look at that sequence (§3.3):
These layers sit inside εθ in Fig. 1 at the top (its step 5 shows the toy's three of them reading the prompt). What τθ is depends on the condition:
The best numbers also use classifier-free guidance at a scale s (Ho and Salimans, the paper's [32]; how it works and what it costs: Diffusion from zero). The v2 changelog says both the text-to-image and ImageNet models were updated to use it (Appendix A).
The central experiment trains class-conditional ImageNet LDMs at f ∈ {1, 2, 4, 8, 16, 32} (LDM-1 is pixel space) with the computational resources fixed: "a single NVIDIA A100 for all experiments in this section", the same number of steps and the same number of parameters (§4.1). Fig. 4 draws the tensor each model diffuses, to scale: one length per number on every axis, so a box's volume is its count of numbers. Shapes from Table 13; reconstruction FIDs (rFID, lower is better) are the range over Table 8's autoencoders with that f; the verdicts are Figure 6's, after 2M steps (Figure 6).
Against sampling speed (DDIM with 10 to 200 steps), LDM-4 and LDM-8 give the best trade-off on CelebA-HQ and ImageNet, and "complex datasets such as ImageNet require reduced compression rates" (Figure 7). The summary: "LDM-4 and -8 offer the best conditions for achieving high-quality synthesis results" (§4.1). Figures 6 and 7 exist only as images, so their curves are not rebuilt here; the chart uses what is printed: the reconstruction quality of every autoencoder (Table 8) and, as a measure of cost, the batch size each LDM could afford on the same A100 (Table 13).
271 V100-days against 962 (916 for the diffusion model plus 46 for ADM's noisy-image classifier): 3.5 times less (Table 18). The LDM's A100-days were converted at the paper's assumed 2.2× A100 speed-up, so this ratio carries that assumption.
The Tables tab has Tables 1 to 11 and 18 as printed, with distances from the best row, the Table 6 ratios and the Table 18 compute converted to A100-days, plus 18 checks of the paper's own numbers against each other.
The authors' own caveats: sampling is still sequential and "slower than that of GANs", and the autoencoder's reconstruction "can become a bottleneck for tasks that require fine-grained accuracy in pixel space"; they assume the super-resolution models are "already somewhat limited in this respect" (§5). On impact, cheaper training "democratize[s]" the technology and also makes it easier "to create and disseminate manipulated data or spread misinformation and spam", deep fakes disproportionately affect women, generative models can reveal their training data, and the two-stage approach may misrepresent the data in ways that remain "an important research question" (§5).
What holds up.
Weaknesses.
The tables also disagree with each other in a handful of copied details (step counts, parameter counts, one compute row); none changes a conclusion.
Verdict. Believe the idea and the efficiency: they are measured, they recompute, and the field adopted them wholesale. Treat individual FIDs as single runs good to about ±0.5, the cross-table details as carelessly copied, and the text-to-image comparison as "close", not "better". The toy on this page agrees in direction at small scale and says where it cannot test the claim (Generate tab).
"What it takes to use this" is left out: the method is the standard recipe of every open image model, and Then and now covers what replaced each part. Code: CompVis/latent-diffusion (MIT); Stable Diffusion weights: CreativeML OpenRAIL-M, a licence "which contains specific use-based restrictions" (SD README).
This is the paper that became Stable Diffusion. The CompVis README describes it as "a Latent Diffusion Model on 512x512 images from a subset of the LAION-5B database", with "a frozen CLIP ViT-L/14 text encoder", "its 860M UNet and 123M text encoder", running "on a GPU with at least 10GB VRAM"; v1 uses "a downsampling-factor 8 autoencoder" and "was pretrained on 256x256 images and then finetuned on 512x512 images" (SD README); its licence is dated August 22, 2022. The config is this paper's: an f = 8 KL autoencoder with 4 latent channels, a cross-attention UNet with context dimension 768, the same 0.18215 scale factor (v1 config). Open weights put a text-to-image model on consumer GPUs.
The deeper contribution is the recipe: generate in a perceptually compressed latent and let a cheap decoder handle the last octave of detail. SD 2 and SDXL kept the latent UNet (SDXL's is 2.6B parameters with two text encoders, SDXL Table 1). DiT replaced the UNet with a Transformer on latent patches, using "an off-the-shelf pre-trained variational autoencoder (VAE) model from Stable Diffusion" (DiT §5). Stable Diffusion 3 moved to a rectified-flow objective and a Transformer but still denoises an f = 8 latent, now with 16 channels because "increasing the number of latent channels d significantly boosts reconstruction performance" (SD3 §5.2.1); FLUX.1 is "a 12 billion parameter rectified flow transformer" on a 16-channel latent (model card). How those successors are built is taught on Latent diffusion and diffusion transformers.
Video and audio followed: Sora is "trained on and subsequently generates videos within this compressed latent space" (Sora report); Stable Video Diffusion (arXiv 2311.15127), AudioLDM (arXiv 2301.12503) and Stable Audio (arXiv 2402.04825) are latent diffusion models by name. The old version of this page also counted Veo and many 3D and molecule systems; those are not checked against a source here (unconfirmed).
The cross-attention interface became the standard plug for conditions: ControlNet adds spatial control by copying the encoder of a "locked" Stable Diffusion (ControlNet), and IP-Adapter adds image prompts through a "decoupled cross-attention mechanism" (IP-Adapter). And the democratisation the paper aimed at happened: hobbyists fine-tune Stable Diffusion with low-rank adapters on its attention layers (Hugging Face, LoRA for Stable Diffusion).
Two text-conditioned diffusion models trained for this page the paper's way, running in your browser. The data are 32 × 32 images of one shape (circle, square or triangle) in one of four colours at one of nine positions, on a light background with faint grain; the prompt is three tokens, such as "red circle, top left". Stage 1 is a KL-regularised autoencoder with f = 4 (32 × 32 × 3 to 8 × 8 × 3, §3.1); stage 2 is a UNet with cross-attention to a one-block transformer τθ over the prompt (§3.3), trained with Eq. 3 and 10% empty prompts for classifier-free guidance. The pixel-space model is the same design on 32 × 32 × 3 with two more resolution levels, at a matched parameter count, trained for the same steps on the same data (§4.1's protocol). Every sample is graded by a fixed rule that reads shape, colour and position from the pixels.
A widget, not an animation: it samples once when the tab opens and again each time you press Generate. Pick a prompt (a held-out one is marked), a guidance scale and a seed; both models sample the same prompt with the same sampler.
Cross-attention gives every position of a feature map one weight per prompt token (the softmax over keys from τθ(y), §3.3). Below are those weights in the first latent sample of the last run, overlaid on the decoded image, at any step and layer. Weights over the three tokens sum to one at each position.
Every results table of the paper as printed in the arXiv HTML v2 (transcribed by script, src/mk_tables.py), bold cells as in the paper, the paper's own rows highlighted. Click a column header to sort. Derived columns (ratios, A100-days) are computed in src/recompute.py and marked as derived.
Each claim recomputed from the printed tables, or compared across the tables, figures and text where the paper reports the same model twice. "Holds" means the arithmetic agrees; the others say what differs.
The LDM recipe as a card, changed one system at a time from 2021 to 2024, in eight stretches (the two video systems share one). Highlighted lines are what that stretch changed; the rest is carried over. It plays once when scrolled into view; any control stops it. Each change is quoted or paraphrased from the system's own paper, model card, config or report (src/inputs/later_extracts.txt, src/inputs/code/).
Generating in the latent of a separately trained, mildly compressing autoencoder with f = 8 (every system on the card), a rescaled KL latent, conditioning on a text encoder's token sequence, and classifier-free guidance. What did not: the UNet (Transformers in DiT, SD3, FLUX and Sora), noise prediction (velocity and rectified flow), 4 latent channels (16 in SD3 and FLUX), and a text encoder trained from scratch (frozen CLIP, OpenCLIP and T5 encoders instead).
The plug-ins built on the cross-attention interface, ControlNet and IP-Adapter, and the latent models for audio, are in the paper tab's Why it matters.
Every link opens in a new tab. Reading time of the resources below: 3h 55m.
CVPR 2022 (oral), the paper itself; the HTML version has the anchors this page links to. abstract page, PDF.
(45 min)
the authors' PyTorch code and checkpoints, MIT licence (repo, about 20 minutes for the README and entry path); Stable Diffusion's code is CompVis/stable-diffusion (about 15 minutes for the README), weights under the CreativeML OpenRAIL-M licence.
(20 min)
Jay Alammar: the best visual walkthrough of the full pipeline (text encoder, UNet in latent space, VAE decoder); a good first read before the paper.
(25 min)
labml.ai: line-by-line PyTorch of the CompVis code, including the autoencoder, the cross-attention UNet and the samplers.
(1h)
Hugging Face: the practical component-level breakdown (VAE, UNet, scheduler, CLIP text encoder) with runnable code.
(30 min)
Sander Dieleman: the modern retrospective on why two-stage latent generative models won, how autoencoder design trades reconstruction against modelability, and where the paradigm is heading.
(35 min)
Polo Club, Georgia Tech: an interactive walk through Stable Diffusion's denoising loop on real prompts, including the guidance scale; the full-size version of this page's toy.
(20 min)
2020-06: supplies the whole diffusion objective and the noise-predicting UNet; this paper changes only where the chain runs. Its page runs a toy DDPM and rebuilds the rate-distortion figure this paper's Figure 2 comes from.
2021-02: this paper trains its own BERT-tokenised text transformer; Stable Diffusion swapped in CLIP's frozen ViT-L/14 text encoder as τθ.
2020-10: DiT and its successors replace this paper's UNet with a Transformer on latent patches while keeping the latent space.
2017-06: cross-attention conditioning is the Transformer's encoder-decoder attention grafted into a UNet.
2021-06: the low-rank adapter that became the usual way hobbyists fine-tune Stable Diffusion's cross-attention layers.
diffusion, VAEs and text-to-image in context.
This page is one row of the Papers database; its properties (Paper, Takeaway, Topics, Year) live there.