- Year of appearance
- 2022
- Researchers
- Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, Björn Ommer (CompVis) with Stability AI and Runway
- Organisation
- CompVis (LMU Munich), Stability AI, Runway
- Architecture type
- Text-conditioned latent diffusion model
- Learning mechanism
- self-supervised
- Tasks
- Text-to-image generation, Image editing, Image inpainting
An open-weights latent diffusion model that generates 512×512 images from a text description, with a frozen CLIP text encoder, a latent U-Net and a VAE.
Architecture diagram
Displayed configuration: Stable Diffusion v1 (512×512, latent 4×64×64) — U-Net: 859,520,964; VAE: 83,653,863; text encoder: 123,060,480.
Layer table (19 nodes)
| Layer | Type | Input | Output | Repetition | Parameters | Formula | MACs |
|---|---|---|---|---|---|---|---|
| Text (up to 77 tokens) | input | 77 | 1 | 0 | — | ||
| CLIP ViT-L/14 text encoder (frozen) | encoder | 77 | 77 × 768 | 1 | 123,060,480 | From the reference PyTorch implementation | 6,649,251,840 |
| Random latent z_T | noise | 4 × 64 × 64 | 1 | 0 | — | ||
| Step embedding t (sinusoidal + MLP) | embed | 1280 | 1 | 2,050,560 | From the reference PyTorch implementation | 2,048,000 | |
| conv_in 3×3 | conv | 4 × 64 × 64 | 320 × 64 × 64 | 1 | 11,840 | From the reference PyTorch implementation | 47,185,920 |
| 64×64: residual + spatial Transformer (320) | block | 320 × 64 × 64 | 320 × 32 × 32 | 1 | 10,524,480 | From the reference PyTorch implementation | 54,775,480,320 |
| 32×32: residual + spatial Transformer (640) | block | 320 × 32 × 32 | 640 × 16 × 16 | 1 | 36,818,560 | From the reference PyTorch implementation | 34,181,939,200 |
| 16×16: residual + spatial Transformer (1280) | block | 640 × 16 × 16 | 1280 × 8 × 8 | 1 | 139,992,320 | From the reference PyTorch implementation | 31,885,230,080 |
| 8×8: two residual blocks (1280) | block | 1280 × 8 × 8 | 1280 × 8 × 8 | 1 | 62,277,120 | From the reference PyTorch implementation | 3,778,150,400 |
| Middle: residual + spatial Transformer + residual | block | 1280 × 8 × 8 | 1280 × 8 × 8 | 1 | 97,038,080 | From the reference PyTorch implementation | 6,049,792,000 |
| 8×8: three residual blocks | upsample | 1280 × 8 × 8 | 1280 × 16 × 16 | 1 | 162,241,280 | From the reference PyTorch implementation | 12,902,400,000 |
| 16×16: + spatial Transformer | upsample | 1280 × 16 × 16 | 1280 × 32 × 32 | 1 | 258,330,880 | From the reference PyTorch implementation | 75,772,395,520 |
| 32×32: + spatial Transformer | upsample | 1280 × 32 × 32 | 640 × 64 × 64 | 1 | 71,413,120 | From the reference PyTorch implementation | 83,411,763,200 |
| 64×64: + spatial Transformer | upsample | 640 × 64 × 64 | 320 × 64 × 64 | 1 | 18,810,560 | From the reference PyTorch implementation | 98,783,150,080 |
| GroupNorm + SiLU + conv_out | conv | 320 × 64 × 64 | 4 × 64 × 64 | 1 | 12,164 | From the reference PyTorch implementation | 47,185,920 |
| Scheduler (for example PNDM or DDIM, 50 steps) + classifier-free guidance | process | ε̂_cond, ε̂_uncond | z_{t−1} | 1 | 0 | — | |
| VAE decoder (64×64×4 → 512×512×3) | decoder | 4 × 64 × 64 | 3 × 512 × 512 | 1 | 49,490,199 | From the reference PyTorch implementation | 1,257,259,466,752 |
| 512×512 image | output | 3 × 512 × 512 | 3 × 512 × 512 | 1 | 0 | — | |
| VAE encoder (for training and img2img) | encoder | 3 × 512 × 512 | 8 × 64 × 64 | 1 | 34,163,664 | encoder + quant_conv in AutoencoderKL | — |
Configuration figures: Stable Diffusion v1 (512×512, latent 4×64×64)
- Input shape
- Text + z_T ∈ ℝ^{4×64×64}
- Output shape
- 3×512×512
- Depth
- U-Net with four resolutions (320, 640, 1280, 1280)
- Complexity
- 50 × 2 × U-Net + VAE decoder per image.
- Parameters note
- Model card: a U-Net of about 860M parameters and a 123M text encoder.
- MACs note
- For a single U-Net pass (401.6 billion). Classifier-free guidance doubles it, and 50 steps multiply it by 50; the VAE decoder once ≈ 1257 billion; the text encoder ≈ 6.6 billion.
MAC = a multiplication followed by an addition. The figures are for one forward pass of one sample with the stated dimensions; they are an analytical calculation, not a measurement of run time.
Scientific explanation
Historical background
Its weights were released publicly in August 2022, which spread text-to-image generation to personal machines; it was followed by versions 2.x, XL and 3.
The problem it addresses
Making high-quality text-to-image generation available on consumer hardware instead of closed services.
Core idea
Applying LDM to huge image-text pairs (LAION), with a CLIP condition through cross-attention, and classifier-free guidance.
Architecture description
CLIP ViT-L/14 (text) → a latent U-Net with four resolutions and spatial Transformers → VAE (f = 8, 4 latent channels).
Data flow
Text → CLIP → 77×768; z_T → (U-Net + cross-attention + scheduler) × 50 → z₀ → VAE decoder → 512×512 image.
Inputs
A text description (and an optional image in img2img).
Outputs
A 512×512 image.
Training procedure
Training the U-Net on LAION-5B subsets at resolution 256 then 512, dropping the text condition 10% of the time to enable classifier-free guidance.
Loss functions
Latent diffusion loss (squared error of the noise).
Computational complexity
About 0.4 trillion multiply-adds per U-Net pass (computed here).
Computational requirements
The original training used hundreds of A100 GPUs; inference runs on a single GPU.
Advantages
- Open weights
- Runs on a consumer GPU (about 10GB)
- A broad ecosystem (ControlNet and LoRA)
Limitations
- Biases and controversial training data
- Weak with text inside images and with hands
- Needs dozens of steps
Equations
Classifier-free guidance Classifier-free guidance
\hat{\boldsymbol\epsilon} = \boldsymbol\epsilon_\theta(\mathbf{z}_t, t, \varnothing) + s \cdot \big(\boldsymbol\epsilon_\theta(\mathbf{z}_t, t, \mathbf{c}) - \boldsymbol\epsilon_\theta(\mathbf{z}_t, t, \varnothing)\big)Combining a conditional and an unconditional prediction with a guidance scale s (for example 7.5).
Symbols: c: text representation, ∅: empty text
Latent-space dimensions Latent size
512 \times 512 \times 3 \;\xrightarrow{\;\mathcal{E},\, f = 8\;}\; 64 \times 64 \times 4A reduction by a factor of 48 in the number of values.
Simplified loss Simplified objective
L_{simple} = \mathbb{E}_{t, \mathbf{x}_0, \boldsymbol\epsilon}\left[\left\lVert \boldsymbol\epsilon - \boldsymbol\epsilon_\theta\!\left(\sqrt{\bar\alpha_t}\mathbf{x}_0 + \sqrt{1 - \bar\alpha_t}\,\boldsymbol\epsilon,\; t\right) \right\rVert^2\right]The network predicts the added noise.
Symbols: ε_θ: denoising network
Applications
Related models
- Built on Latent Diffusion Model — A direct application of LDM. Compare
- Predecessor of Latent Diffusion Model — Stable Diffusion is a large-scale application of LDM. Compare
- U-Net — Stable Diffusion uses a conditional U-Net. Compare
- Uses a component of CLIP (Contrastive Language–Image Pre-training) — The text encoder from CLIP. Compare
- CLIP (Contrastive Language–Image Pre-training) — The text encoder in Stable Diffusion comes from CLIP. Compare
- Uses a component of U-Net — The latent U-Net. Compare
- Denoising Diffusion Implicit Models — A common sampling scheduler. Compare
- Alternative StyleGAN (Style-Based Generator) — Image generation with GAN. Compare
- Conditional GAN — Text-conditioned generation in diffusion. Compare
References
- Original paper Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, Björn Ommer. (2022). High-resolution image synthesis with latent diffusion models. CVPR 2022, 10674–10685. doi:10.1109/CVPR52688.2022.01042 Verified
- Configuration source CompVis, Stability AI, Runway. (2022). Stable Diffusion (CompVis/stable-diffusion repository and model card). GitHub repository. Link Needs review
- Related reference Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, Gretchen Krueger, Ilya Sutskever. (2021). Learning transferable visual models from natural language supervision. ICML 2021 (PMLR 139). arXiv:2103.00020 Verified
Version 1 — last updated 2026-11-15.
