All models

stable_diffusion_unet

The cross-attention UNet that denoises in a pretrained autoencoder's latent space, as in Stable Diffusion.

Diffusion and generative · 1,209 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (28 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Parameters
859.5M
Operations
1,209
Framework
PyTorch
Recurrent
No
Published
CVPR 2022
Cited by
734 (as of 19 October 2026)
Authors
Robin Rombach, Andreas Blattmann, Dominik Lorenz and others
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m10251
Graph hash
866adea5ae533a6ec824bd7f4f82d9d53ab451a31ad1beb00c2b9bf576be9100
Skeleton hash
7ce92bd1d62674a6dcc3078e9eeffd21b032b4ecd81f610f6cb1d3c922dc2d35
Architecture hash
82e82cc3af7e123b40b78ca8b77607993c990b218b6f5d2b2bdef49eb74c6657
Diagram SHA-256
1cf0430978b213171049096f2248104006b9ff4e46734091869ff3349ed4d2f2
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

What it is

Latent diffusion models (LDMs) start from a cost problem: because diffusion models typically operate directly in pixel space, optimization of powerful DMs often consumes hundreds of GPU days and inference is expensive due to sequential evaluations. The fix is to apply them in the latent space of powerful pretrained autoencoders. Training is split into two distinct phases, where first an autoencoder is trained that provides a lower-dimensional representational space which is perceptually equivalent to the data space. That autoencoder comes in two regularized variants: the KL variant imposes a slight KL-penalty towards a standard normal on the learned latent, whereas the VQ variant uses a vector quantization layer within the decoder.

The neural backbone of the model is realized as a time-conditional UNet. To accept conditioning beyond class labels, the authors augment the underlying UNet backbone with the cross-attention mechanism. A domain specific encoder projects the conditioning input to an intermediate representation, which is then mapped to the intermediate layers of the UNet via cross-attention. This turns diffusion models into flexible generators for general conditioning inputs such as text or bounding boxes, and high-resolution synthesis becomes possible in a convolutional manner. Comparing downsampling factors, LDM-4 and -8 offer the best conditions for achieving high-quality synthesis results. On CelebA-HQ the paper reports a new state-of-the-art FID of 5.11, outperforming previous likelihood-based models as well as GANs.

The captured member is the UNet in the Stable Diffusion configuration. Stable Diffusion v1 is a specific configuration that uses a downsampling-factor 8 autoencoder with an 860M UNet and a CLIP ViT-L/14 text encoder. It is conditioned on the non-pooled text embeddings of that text encoder, and the model was pretrained on 256x256 images and then finetuned on 512x512 images. The diffusion codebase builds heavily on OpenAI's ADM codebase.

Key idea. LDMs train diffusion models on a pretrained autoencoder's latent representation, which the paper says allows for the first time to reach a near-optimal point between complexity reduction and detail preservation. Cross-attention layers in the UNet make the same backbone a general conditional generator for inputs such as text or bounding boxes.

  • latent diffusion
  • LDM
  • Latent Diffusion Models
  • Stable Diffusion
  • UNet2DConditionModel
  • stable_diffusion_unet
  • denoising UNet
  • cross-attention conditioning
  • text-to-image
  • CompVis
  • High-Resolution Image Synthesis with Latent Diffusion Models
  • diffusers

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{rombach2022highresolutionimagesynthesislatent,
      title={High-Resolution Image Synthesis with Latent Diffusion Models}, 
      author={Robin Rombach and Andreas Blattmann and Dominik Lorenz and Patrick Esser and Björn Ommer},
      year={2022},
      eprint={2112.10752},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2112.10752}, 
}