← Back to Multimodal Mind Map
👁️ MultimodalID: latent-diffusion

Latent Diffusion (LDM)

潜空间扩散 (LDM)
🎯Core Definition
Latent Diffusion Models (LDM) run the DDPM process in a VAE latent space instead of pixel space, then decode back. An image x∈RH×W×3x \in \mathbb{R}^{H \times W \times 3} is compressed by the VAE encoder into z∈Rh×w×cz \in \mathbb{R}^{h \times w \times c}; Stable Diffusion uses 8×8\times spatial downsampling: a 512×512512\times 512 image becomes a 64×64×464\times 64\times 4 latent (c=4c=4). Denoising happens entirely on zz:
📌Overview
zt=αˉt z0+1−αˉt ϵ,L=E[∥ϵ−ϵθ(zt,t,c)∥2]z_t = \sqrt{\bar\alpha_t}\,z_0 + \sqrt{1-\bar\alpha_t}\,\epsilon,\qquad \mathcal{L} = \mathbb{E}\left[\Vert \epsilon - \epsilon_\theta(z_t, t, c)\Vert^2\right]
📌Overview
The condition cc (e.g. CLIP text embeddings) is injected into the U-Net/DiT middle layers via cross-attention; after sampling, z0z_0 is mapped back by VAEdec\mathrm{VAE}_{dec}. The full training loss combines three terms: latent diffusion reconstruction + perceptual loss (LPIPS) + adversarial/GAN loss, with mild KL regularization, balancing pixel fidelity and perceptual quality. Architecture evolution: SD1/2 use U-Net (self-attention + cross-attention + timestep embedding); SD3/Flux use MMDiT (a mixed text-image DiT with patchify and AdaLN-zero for timestep/text conditioning).
💡Use Cases
the backbone of the Stable Diffusion family and most text-to-image/text-to-video models; interview favorites — “why diffuse in latent space instead of pixel space?” and “how much compute does 8× downsampling save?”.
⚡Key Problems Solved
pixel-space diffusion is computationally intractable above 256×256256\times256 — attention and feature maps grow quadratically with resolution; the 8×8\times spatial reduction cuts feature-map area to 1/641/64, lowering training/sampling compute by roughly two orders of magnitude, while the decoder restores visual detail, the encoder absorbs semantic compression, and conditions (text, ControlNet) plug into the latent space uniformly.
🎯Core Interview Exam Points
Fundamentals · Production Scenarios · Deep Dive
Core Def
Explain the core definition, underlying mechanism/math, and key principles of Latent Diffusion (LDM).
Use Cases
In production engineering, what are the primary use cases for Latent Diffusion (LDM) and what core pain points does it solve?
🔥 High-Frequency Deep-Dive Questions
1
Why does Stable Diffusion diffuse in VAE latent space instead of pixel space; how much compute does 8× downsampling save?
2
Which terms make up the LDM training loss, and why add perceptual and adversarial losses?
3
How is text conditioning injected into the latent diffusion network; where does cross-attention sit in U-Net/DiT?
4
Key structural differences between SD1/2 U-Net and SD3/Flux MMDiT?
5
Tradeoffs of latent vs pixel-space diffusion in training speed, memory and image quality?
📖 In-depth Guide:📄 diffusion-models →
Updated 2026-08-12
🎯
Verify Mastery: Practice Exam Questions for "Latent Diffusion (LDM)"
Take pitfall multiple-choice questions with derivation options; mistakes are automatically logged.
🚀 Start Card Practice ➔
← Previous CardClassifier-Free GuidanceNext Card →Sampler Acceleration (DDIM/DPM-Solver/LCM)

🔗 More Multimodal Knowledge Cards

引用出处: TalentMe 450+ 工业级 AI 架构考点知识库 (Tech Vault) · 遵循 CC-BY-4.0 知识共享协议
URL: https://talentme.airsota.com/resources/tech/roadmap/mindmap/Multimodal/card/latent-diffusion
中文速览与面试要点

潜空间扩散 (LDM) (Latent Diffusion (LDM))

定义: Latent Diffusion Model (LDM, 潜空间扩散) 不在像素空间而是在 VAE 的潜空间里做 DDPM, 最后解码回像素。图像 x R^H W 3 由 VAE 编码器压缩为 z R^h w c,Stable Diffusion 的空间降维 8 : 512 512 图像 → 64 64 4 潜变量(c=4)。扩散去噪全程在 z 上进行: z_t = _t\,z_0 + 1- _t\, , L = E [ - _ (z_t, t, c) ^2 ] 条件 c (如 CLIP 文本嵌入) 通过交叉注意力注入 U-Net/DiT 的中间层; 采样完成后的 z_0 经 VAE_dec 还原高分辨率图像。整体训练损失含三项: 潜空间扩散重建 + 感知损失 (LPIPS) + 对抗/GAN 项, 并施加轻微 KL 正则, 兼顾像素级逼真与感知质量。架构演进: SD1/2 用 U-Net (自注意力 + 交叉注意力 + 时间嵌入), SD3/Flux 用 MMDiT (混合文本-图像 DiT, patchify + AdaLN-zero 注入时间步与文本条件)。 使用场景: Stable Diffusion 全系与多数文生图/文生视频模型的底座; 面试常问 “为什么在潜空间而不是像素空间扩散?”、“8× 降维省多少算力?”。 解决的问题: 像素空间扩散在 256 256 以上计算与显存不可承受——注意力与特征图随分辨率平方级增长; 潜空间 8 空间降维使特征图面积降为 1/64, 训练与采样计算量约降两个数量级, 同时视觉细节由解码器补齐、语义压缩由编码器完成, 且文本/ControlNet 等条件都能在潜空间统一插拔。

核心要点

  • 为什么 Stable Diffusion 在 VAE 潜空间而不是像素空间扩散? 8× 降维省多少算力?
  • LDM 的总体训练损失由哪几部分组成? 为什么加感知损失和对抗项?
  • 文本条件如何注入潜空间扩散网络? 交叉注意力在 U-Net/DiT 中的位置?
  • SD1/2 的 U-Net 与 SD3/Flux 的 MMDiT 在结构上的关键差异?
  • 潜空间扩散相比像素空间扩散在训练速度、显存、图像质量上的权衡?