MODEL EXPLORER / GENERATIVE MODELS
Move denoising into a compressed space
Why denoise a latent, and where does text enter?
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.
Min -0.3494 · Max 0.1664
Recorded cell values
| Row / col | 0 | 1 | 2 | 3 |
|---|---|---|---|---|
| 0 | -0.01799 | -0.1927 | 0.006696 | 0.1036 |
| 1 | -0.1283 | -0.007116 | -0.2452 | -0.03957 |
| 2 | 0.1039 | -0.1685 | 0.06713 | -0.3494 |
| 3 | -0.295 | 0.1664 | 0.1037 | -0.03892 |
Min -0.3919 · Max 0.4293
Recorded cell values
| Row / col | 0 | 1 | 2 | 3 |
|---|---|---|---|---|
| 0 | -0.06686 | -0.2416 | -0.164 | 0.4293 |
| 1 | -0.1819 | 0.1058 | 0.1373 | 0.1472 |
| 2 | 0.2587 | -0.1199 | 0.1773 | -0.2533 |
| 3 | -0.3919 | 0.228 | 0.2573 | 0.04446 |
Min 0.2955 · Max 0.3904
Recorded cell values
| Row / col | 0 | 1 | 2 |
|---|---|---|---|
| 0 | 0.3099 | 0.3882 | 0.3019 |
| 1 | 0.3 | 0.3843 | 0.3156 |
| 2 | 0.3059 | 0.3904 | 0.3037 |
| 3 | 0.2955 | 0.3879 | 0.3165 |
Min -0.05877 · Max -0.006321
Recorded cell values
| Row / col | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|---|
| 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.
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.
THE SAME MODEL, ON YOUR MACHINE
Pick up where
the graph leaves off.
Separate the image encoder, text conditioning, latent U-Net and decoder; compare spatial-to-text attention and a complete short sampling loop.
Use in VS Code ↗1. Save these files in one folder
2. Reproduce the example
Use Python 3.13 in a dedicated environment, matching the tested recipe. These commands are for macOS / Linux shells.
python3.13 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
python run.pyExpected output: [1,3,8,8]
Input 1: [1,3,8,8] · float32 randn
Input 2: [1,3] · int64 ones
Input 3: [1,2,4,4] · float32 randn
Input 4: [1] · int64 ones · CPU / eval · seed 0
3. Open the source in TensorViz
Install the preview, open this folder in local VS Code, and choose Open as Graph above TinyLatentDiffusion in model.py. Select your Python environment. Save before choosing Validate.
Installation and supported setup ↗
The recipe was run with Python 3.13.13 and Torch 2.7.1. This is an untrained example; a successful shape check does not measure accuracy.
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 ↗