← All models

MODEL EXPLORER / GENERATIVE MODELS

Move denoising into a compressed space

Why denoise a latent, and where does text enter?

Curated by TensorVizLatent diffusion · 4-step tour
Static architecture
Why denoise a latent, and where does text enter?
Opening the interactive graph…
Architecture snapshot · No Python requiredDownload graph ↓

RECORDED NUMERICAL EXAMPLE

Denoise in latent space; decode once.

Recorded 4 × 4 latent diffusion with text conditioning. A frozen random autoencoder illustrates compression; it does not reproduce a trained KL/VQ first stage.

The same encoded image and Gaussian noise are reused. Queries come from four coarse spatial locations; keys and values come from three text tokens. The changed-text case keeps t = 6 fixed. The one-step clean estimate is decoded only for inspection and is not a complete generation.

Clean latent · channel 0

Min -0.3494 · Max 0.1664

Recorded cell values
Row / col0123
0-0.01799-0.19270.0066960.1036
1-0.1283-0.007116-0.2452-0.03957
20.1039-0.16850.06713-0.3494
3-0.2950.16640.1037-0.03892
Noisy latent · channel 0

Min -0.3919 · Max 0.4293

Recorded cell values
Row / col0123
0-0.06686-0.2416-0.1640.4293
1-0.18190.10580.13730.1472
20.2587-0.11990.1773-0.2533
3-0.39190.2280.25730.04446
Spatial query × text attention

Min 0.2955 · Max 0.3904

Recorded cell values
Row / col012
00.30990.38820.3019
10.30.38430.3156
20.30590.39040.3037
30.29550.38790.3165
Decoded estimate · red channel

Min -0.05877 · Max -0.006321

Recorded cell values
Row / col01234567
0-0.05269-0.02281-0.01215-0.02285-0.0152-0.03749-0.03887-0.01458
1-0.04946-0.01401-0.02372-0.02333-0.02603-0.0427-0.03264-0.03954
2-0.05012-0.01744-0.02701-0.02702-0.03242-0.02919-0.02769-0.03763
3-0.05227-0.03523-0.02504-0.0257-0.02831-0.03636-0.02489-0.03661
4-0.05847-0.01627-0.02903-0.02612-0.02416-0.01879-0.01889-0.02789
5-0.04628-0.01143-0.01798-0.04468-0.03449-0.01033-0.0254-0.0342
6-0.02392-0.03331-0.03494-0.02296-0.04407-0.006321-0.01713-0.04538
7-0.03947-0.03791-0.03623-0.02846-0.032-0.02576-0.02718-0.05877

Each heatmap uses its own scale. Mint is positive, rust is negative, and the lightest color is zero. Table values are rounded to four significant digits.

Text IDs
1
3
5

Bars share one scale within this example. Values are rounded to four significant digits.

Latent values
32
Pixel-space values
192
Noise-prediction MSE
1.507
Verified by the local recipe
  • The 192-value image is compressed to 32 latent values and decoded back to its original shape
  • Text changes epsilon predictions while the cached image latent remains independent of text
  • Cross-attention rows normalize over text tokens and are invariant to joint K/V ordering
  • Known epsilon recovers the clean latent; diffusion-loss gradients reach the conditioner and denoiser while the first stage stays frozen

Download the source and run.py to reproduce these checks. Choosing an example here replays recorded values.

ABOUT THIS EXAMPLE

Separate the image encoder, text conditioning, latent U-Net and decoder; compare spatial-to-text attention and a complete short sampling loop.

Architecture · 2021

Latent diffusion

An 8 × 8 RGB image becomes a 2 × 4 × 4 latent. A width-eight U-Net attends from four coarse spatial queries to three text tokens. The canonical graph includes a decoded one-step estimate; the source also implements repeated latent sampling.

Source, capture & limitations +

Untrained subsystem, not Stable Diffusion. A deterministic convolutional autoencoder stands in for the trained KL/VQ first stage; perceptual/adversarial autoencoder losses and latent scaling are omitted. The conditioner is an embedding lookup with positions, without a tokenizer or text Transformer. No classifier-free guidance. The 12-step schedule is illustrative; decoded heatmaps do not establish image quality. Paper preprint 2021, CVPR 2022.

Original TensorViz teaching example. PyTorch provides the underlying operators.

No separate redistribution license has been declared for these project examples.

Content revision
f4674756eaef7a3b
Source SHA-256
831516c404f51ad026de2e74ee368424d1f1ea3ce8702d5c6aff27cd31caa19a
Captured
2026-09-17 · Python 3.13.13 / Torch 2.7.1

Reduced latent diffusion subsystem with a frozen deterministic autoencoder, 12-step noise schedule, conditional U-Net, cross-attention and CPU sampling. Checks compression, conditioning, posterior reconstruction and frozen first-stage gradients.

Read the model manifest ↗