It is December 2021. Diffusion models have spent seven months proving they can beat generative adversarial networks on image fidelity, but that win came at pixel-space prices: a guided diffusion model trains and samples every one of up to a thousand steps across the full resolution of the image, a compute bill only a handful of labs can pay. A team at LMU Munich’s Computer Vision and Learning group — several of them the same authors who, a year earlier, had taught a generative adversarial network to compress images into a small discrete codebook — publishes a paper that puts the two ideas together: stop running the diffusion process on pixels, and run it instead inside a much smaller, pre-learned compressed space.
Where We Were
By late 2021, diffusion had won the argument on quality. Denoising Diffusion Probabilistic Models, or DDPM (Diffusion Foundations), had matched GAN-level fidelity on small images in June 2020 with a training objective that needed no adversarial network at all, and in May 2021 Diffusion Models Beat GANs on Image Synthesis, or ADM, pushed that lead onto ImageNet-scale, high-resolution generation using classifier guidance (Guidance). Both results shared the same structural cost: the forward-noising and reverse-denoising process ran directly on pixels, at the image’s full spatial resolution, and it ran that way at every single one of the model’s diffusion steps. A U-Net large enough to denoise a 256×256 image competitively had to do that work up to a thousand times to produce one sample, and training a model of that size on that objective was, by the field’s own account, a project measured in hundreds of GPU-days on institutional hardware — out of reach for anyone without a research lab’s compute budget.
A second, separate lineage had spent the same years attacking a different problem: not how to generate an image, but how to represent one compactly enough that a much smaller model could work with it at all. Neural Discrete Representation Learning, or VQ-VAE, had shown in November 2017 that an image could be compressed into a small spatial grid of discrete codes drawn from a learned vocabulary, and that an autoregressive prior trained over that short grid needed far fewer sequential steps than one trained over raw pixels (Pixels One at a Time). In December 2020, Esser, Rombach, and Ommer refined that recipe substantially. “Taming Transformers for High-Resolution Image Synthesis” (Esser et al., 2020) — the paper that named the result VQGAN — kept VQ-VAE’s codebook mechanism but replaced its plain pixel-reconstruction loss with a perceptual loss and a patch-based adversarial objective, and replaced its PixelCNN prior with a GPT-2-style transformer. The result was a compressed latent space whose decoded images looked sharp and detailed rather than smoothed-over, at compression factors aggressive enough — a downsampling factor of 16 was typical for face datasets, with the paper exploring a range from 2 to 64 depending on the target resolution — that the transformer prior, run in a sliding-window fashion across overlapping patches, could synthesize images in the megapixel range.
By the end of 2021, both lineages were mature on their own terms, but nobody had asked the question that connects them: VQGAN’s compressed latent space had been built to host an autoregressive transformer — could it host a diffusion model instead, and inherit diffusion’s training stability and sample diversity without inheriting pixel-space diffusion’s compute bill? Text-guided diffusion was also just arriving that same month with GLIDE (DALL-E and GLIDE), but GLIDE ran its guided diffusion process directly in pixel space, at the same full-resolution cost ADM had already established. The gap between “diffusion is the better generative model” and “diffusion is a generative model most teams can actually afford to train and run” was still wide open.
The Breakthrough
Rombach, Blattmann, Lorenz, Esser, and Ommer’s “High-Resolution Image Synthesis with Latent Diffusion Models” (Rombach et al., 2021) answered that question by splitting image generation into two stages trained separately. The first stage is a perceptual-compression autoencoder, trained once, using essentially the same recipe VQGAN had introduced a year earlier: an encoder and decoder trained jointly with a perceptual loss and a patch-based adversarial loss, so that the compressed representation discards only the pixel-level detail a human viewer would not miss, not the semantic content of the image. The second stage is a diffusion model — the same forward-noising, learned-reverse-process machinery taught in full in the DDPM chapter — but trained entirely inside the small spatial grid the first stage produces, never touching a raw pixel.
The paper reports an ablation across downsampling factors and finds and the best trade-off: aggressive enough compression to make the diffusion U-Net’s job cheap at every one of its sampling steps, without compressing away enough detail to visibly hurt reconstruction quality. For a 512×512 image, an autoencoder produces a latent grid — a reduction in the number of spatial positions the diffusion U-Net’s convolutions and attention layers have to process, at every one of the (up to) thousand steps a sampler runs, not just once. Because the autoencoder is trained once and reused for every downstream diffusion model, that compute saving compounds: the same latent space can host an unconditional model, a class-conditional model, or a text-conditional model, and each one pays the pixel-space cost only twice, at encode and decode, rather than at every diffusion step.
That reuse depended on a second contribution: a general mechanism for injecting an arbitrary conditioning signal into the latent U-Net via cross-attention, rather than building a separate architecture for each conditioning type. A domain-specific encoder — a text transformer, a semantic-layout encoder, anything appropriate to the modality — maps the conditioning input into an intermediate representation, and the U-Net’s own intermediate features attend to that representation using the same scaled dot-product attention mechanism taught in full in The Transformer; what changes is only where the keys and values come from. That single mechanism is what let one architecture serve class-conditional generation, layout-to-image, super-resolution, inpainting, and text-to-image without a bespoke redesign for each task.
The paper’s own text-to-image demonstration, trained on LAION-400M with a from-scratch BERT-tokenized transformer as the domain encoder, was a research artifact rather than a product. The product arrived eight months later. On August 22, 2022, Stability AI, in collaboration with the original CompVis group, RunwayML, and LAION, released Stable Diffusion’s weights publicly under the Creative ML OpenRAIL-M license — a permissive license allowing commercial and non-commercial use — following a beta that had already run through more than 10,000 Discord testers and a researcher-only release of the preceding checkpoint. Stable Diffusion kept the LDM recipe’s downsampling and cross-attention conditioning, but swapped the paper’s from-scratch text transformer for a frozen CLIP ViT-L/14 text encoder (CLIP: Bridging Text and Image), giving the model a ready-made, already-aligned text-image embedding space rather than one it had to learn from scratch. The released v1.4 checkpoint paired an 860M-parameter U-Net with that 123M-parameter text encoder and an autoencoder decoder of roughly 84M parameters, and Stability AI’s own announcement stated the model would run on consumer GPU hardware using about 6.9 GB of VRAM — a machine an individual developer could own, not a datacenter allocation.
Eleven months later, the same core team returned with a scaled-up successor. “SDXL: Improving Latent Diffusion Models for High-Resolution Image Synthesis” (Podell et al., 2023) kept the latent-diffusion architecture but roughly tripled the U-Net to 2.6B parameters, added a second text encoder (OpenCLIP ViT-bigG alongside CLIP ViT-L, concatenating their outputs into a 2048-dimensional conditioning context against Stable Diffusion 1.x’s 768), introduced explicit conditioning on image size and crop parameters so the model could be trained on images of varying aspect ratio without wasted padding, and added an optional refiner model that applies a short noise-and-denoise pass to a base model’s output latents to sharpen fine detail in faces and backgrounds.
The Mathematics
The autoencoder’s training objective builds directly on VQ-VAE’s codebook mechanism — the quantization lookup and straight-through estimator taught in full in Pixels One at a Time — but adds the two terms that make VQGAN’s reconstructions look sharp rather than smoothed:
| Symbol | Meaning |
|---|---|
| , | the original image and its reconstruction from the quantized latent |
| perceptual loss, compared in a pretrained classifier’s feature space | |
| codebook and commitment loss from VQ-VAE, Chapter 5 | |
| patch-based discriminator, real versus reconstructed | |
| weight on the adversarial term |
With the autoencoder trained and frozen, the diffusion model’s training objective is the same simple noise-prediction regression taught in full in Diffusion Foundations, with one substitution: the data the diffusion process noises and denoises is the encoder’s latent, not the image itself.
| Symbol | Meaning |
|---|---|
| , | the frozen perceptual encoder and its output latent for image |
| the latent after steps of forward noising | |
| the U-Net’s predicted noise, given the noisy latent and timestep | |
| the trainable parameters of the latent-space U-Net |
Conditioning is added through cross-attention layers spliced into the U-Net at several of its internal resolutions:
| Symbol | Meaning |
|---|---|
| query, key, and value matrices for one cross-attention layer | |
| the U-Net’s intermediate feature map at layer | |
| a domain-specific encoder’s embedding of the conditioning input | |
| learned projection matrices at layer | |
| the dimensionality of the key vectors, used to scale the dot product |
What It Enabled
Latent diffusion’s immediate effect was to collapse the gap between “state-of-the-art image fidelity” and “a model an individual can train and run,” a gap the field had been widening since ADM.
| Pixel-space guided diffusion, ADM, 2021 | Latent diffusion, LDM, 2021 | Stable Diffusion, public release, 2022 | |
|---|---|---|---|
| Where diffusion runs | full-resolution pixel grid, every step | / compressed latent, every step | latent, for a image |
| ImageNet 256 class-conditional FID | 4.59, with classifier guidance | 3.60, LDM-4-G, with classifier-free guidance (Guidance) | not the target task; general text-to-image model |
| Denoising network size | large pixel-space U-Net, institutional-scale training | 400M-parameter latent U-Net | 860M-parameter latent U-Net, plus a 123M-parameter frozen text encoder |
| Weights publicly downloadable | no | research code, not the trained weights | yes, Creative ML OpenRAIL-M license |
| Typical hardware to run inference | multi-accelerator, datacenter-class | a single high-end GPU | a single consumer GPU, about 6.9 GB VRAM |
The CelebA-HQ result told the same story from the unconditional side: an LDM-4 model reported a new state-of-the-art FID of 5.11 on that benchmark at the time, ahead of prior likelihood-based models and GANs alike, using a fraction of the training compute pixel-space diffusion required. And the framework’s generality showed up immediately in its own paper: the same architecture, retrained on LAION-400M with a 1.45B-parameter text-conditioning branch, reached an FID of 12.63 on MS-COCO — evidence that one perceptual-compression-plus-cross-attention recipe, not a bespoke architecture per task, was enough to cover class-conditional generation, unconditional faces, and free-form text-to-image together.
Stable Diffusion’s release changed who could act on that recipe. Where OpenAI’s DALL-E 2 API, opened to developers that November, billed $0.02 per 1024×1024 image generated through a hosted endpoint, Stable Diffusion’s open weights let any team with a single GPU generate, fine-tune, or embed the model into a product at the marginal cost of their own electricity — a difference in kind, not just price, for anyone building a product around image generation rather than calling one.
Every one of those downstream lines runs through the same open checkpoint. ControlNet’s spatial conditioning and the broader adapter ecosystem (Control) inject new conditioning signals into Stable Diffusion’s frozen U-Net through the exact cross-attention pathway this chapter derived. Textual Inversion and DreamBooth teach the same frozen model new subjects and styles from a handful of images (Personalization and LoRA). Consistency models, LCMs, and adversarial distillation cut Stable Diffusion’s sampling steps from the dozens down toward one (Few-Step Generation). SDXL’s larger backbone is itself the launch point for the rectified-flow, transformer-backboned models that follow it (Flow Matching and Transformer Backbones). And bolting a temporal dimension onto this same latent U-Net, rather than building a video model from scratch, is the foundation under Stable Video Diffusion and the rest of the video-generation lineage that opens with it (Latent Video Diffusion). A comparison of the two Stable Diffusion generations released under this architecture shows how much of that later growth came from scaling the same recipe rather than replacing it:
| Stable Diffusion 1.4/1.5, Aug 2022 | Stable Diffusion 2.0/2.1, late 2022 | SDXL, Jul 2023 | |
|---|---|---|---|
| U-Net parameters | 860M | 865M | 2.6B |
| Text encoder(s) | CLIP ViT-L/14 | OpenCLIP ViT-H/14, trained from scratch | CLIP ViT-L/14 + OpenCLIP ViT-bigG |
| Cross-attention context dimension | 768 | 1024 | 2048 |
| Native resolution | multi-aspect, around | ||
| Human-preference win rate vs. SD 1.5 | — | — | 48.44%, with the refiner stage |
Key Papers
| Paper | Authors | Year | Link | Why it matters |
|---|---|---|---|---|
| Taming Transformers for High-Resolution Image Synthesis | Esser, Rombach, Ommer | 2020 | arXiv:2012.09841 | VQGAN’s perceptual-plus-adversarial autoencoder and transformer prior supplied the exact compression recipe latent diffusion reuses |
| High-Resolution Image Synthesis with Latent Diffusion Models | Rombach, Blattmann, Lorenz, Esser, Ommer | 2021 | arXiv:2112.10752 | Moved the diffusion process into a frozen perceptual-compression latent space and introduced cross-attention conditioning; the direct architecture behind Stable Diffusion |
| SDXL: Improving Latent Diffusion Models for High-Resolution Image Synthesis | Podell et al. | 2023 | arXiv:2307.01952 | Scaled the same latent-diffusion recipe to a 2.6B-parameter U-Net with dual text encoders and a refinement stage |
PM Lens
Papers referenced
- Taming Transformers for High-Resolution Image Synthesis Esser, Rombach & Ommer · 2020 · arXiv:2012.09841
- High-Resolution Image Synthesis with Latent Diffusion Models Rombach, Blattmann, Lorenz, Esser & Ommer · 2021 · arXiv:2112.10752
- SDXL: Improving Latent Diffusion Models for High-Resolution Image Synthesis Podell et al. · 2023 · arXiv:2307.01952