M6-075M6: Multimodal & Generative ModelsFlow Matching & Rectified FlowHard
⚡Flashcard Drill➔Mastery:

Unified Framework of Continuous Diffusion SDEs, Probability Flow ODEs, and Flow Matching

📐 Mathematical Definition
unified: dx=vθ(x,t)dt (ODE);v=f−12g2∇log⁡p (link)\text{unified}:\ dx=v_\theta(x,t)dt\ (\text{ODE});\qquad v=f-\tfrac12g^2\nabla\log p\ (\text{link})
⚡ One-Sentence Core Answer
Continuous diffusion SDEs, deterministic Probability Flow ODEs, and Flow Matching form a unified mathematical continuum of continuous-time generative transport, differing only in trajectory curvature and stochastic noise injection.

📌 Key Takeaways

  • •
    The unifying differential equation: all three paradigms transport a prior noise distribution to the data distribution via continuous vector fields governed by the Fokker-Planck continuity equation
  • •
    Stochastic vs deterministic duality: SDEs inject continuous Brownian perturbations during reverse sampling, while ODEs and Flow Matching follow deterministic paths with identical marginals
  • •
    Trajectory geometry evolution: progresses from curved stochastic trajectories (DDPM SDE) to curved deterministic trajectories (DDIM / Probability Flow ODE) to straight optimal transport trajectories (Flow Matching)

📐 Mathematical Derivations

Mathematical Mechanism: 1. The Master SDE Formulation (Song et al., 2021): Forward transport: dx=f(x,t)dt+g(t)dwdx = f(x, t) dt + g(t) dw Generative reverse transport: dx=[f(x,t)−g(t)2∇xlog⁡pt(x)]dt+g(t)dwˉdx = \left[ f(x, t) - g(t)^2 \nabla_x \log p_t(x) \right] dt + g(t) d\bar{w} 2. The Generalized Probability Flow ODE Family: Parameterize sampling via stochasticity parameter η∈[0,1]\eta \in [0, 1]: dx=[f(x,t)−1+η22g(t)2∇xlog⁡pt(x)]dt+ηg(t)dwˉdx = \left[ f(x, t) - \frac{1 + \eta^2}{2} g(t)^2 \nabla_x \log p_t(x) \right] dt + \eta g(t) d\bar{w} (a) η=1  ⟹  \eta = 1 \implies Standard Reverse SDE (DDPM). (b) η=0  ⟹  \eta = 0 \implies Deterministic Probability Flow ODE (DDIM): dxdt=f(x,t)−12g(t)2∇xlog⁡pt(x)\frac{dx}{dt} = f(x, t) - \frac{1}{2} g(t)^2 \nabla_x \log p_t(x) 3. The Flow Matching Generalization: Flow Matching replaces the diffusion drift and score terms with a direct velocity vector field vt(x)v_t(x): dxdt=vt(x)\frac{dx}{dt} = v_t(x) Under linear displacement interpolation xt=(1−t)x0+tx1x_t = (1-t) x_0 + t x_1: Drift: f(x,t)=0,Diffusion: g(t)=0,vt(x)=E[x1−x0∣xt=x]\text{Drift: } f(x, t) = 0, \quad \text{Diffusion: } g(t) = 0, \quad v_t(x) = \mathbb{E}[x_1 - x_0 \mid x_t = x] Transforming curved Brownian diffusion paths into straight-line optimal transport flows. 4. Paradigm Comparison Matrix: \begin{array}{l|c|c|c} \textbf{Feature} & \textbf{Diffusion SDE (DDPM)} & \textbf{Probability Flow ODE (DDIM)} & \textbf{Flow Matching (SD3/Flux)} \\ \hline \text{Trajectory Type} & \text{Stochastic / Curved} & \text{Deterministic / Curved} & \textbf{Deterministic / Straight} \\ \text{Target Variable} & \text{Noise } \epsilon_\theta \text{ or Score } s_\theta & \text{Noise } \epsilon_\theta & \textbf{Velocity } v_\theta = x_1 - x_0 \\ \text{Optimal Solvers} & \text{Ancestral SDE (Euler-a)} & \text{Semi-linear ODE (DPM-Solver)} & \textbf{Standard Euler / Midpoint} \\ \text{Exact Likelihood} & \text{Intractable (variational bound)} & \textbf{Exact (change of variables)} & \textbf{Exact (change of variables)} \\ \text{Inversion Ability} & \text{No (stochastic noise)} & \textbf{Yes (deterministic ODE)} & \textbf{Yes (deterministic ODE)} \end{array}

🏭 Production Trade-offs

Deep Dive & Engineering Trade-offs: ① The Trajectory Curvature Continuum: The fundamental evolutionary progression in generative modeling has been straightening the transport path. DDPM's path is highly curved and noisy, requiring 1,000 steps. DDIM straightens the path into a deterministic curve, reducing steps to 50. Flow Matching straightens the trajectory into Euclidean lines, enabling sampling in 15-20 steps. Reflow straightens paths further, enabling 1-2 step generation. ② Likelihood Computation and Inversion: Both Probability Flow ODEs and Flow Matching allow exact continuous log-likelihood computation via the instantaneous change-of-variables formula: log⁡p(x1)=log⁡p(x0)−∫01Tr(Jv)dt\log p(x_1) = \log p(x_0) - \int_0^1 \text{Tr}(\mathcal{J}_v) dt, where the Jacobian trace Tr(Jv)=∇x⋅vt(x)\text{Tr}(\mathcal{J}_v) = \nabla_x \cdot v_t(x) is computed using the Hutchinson estimator. ③ Stochastic Self-Correction vs Speed: Stochastic SDEs retain an advantage in noisy, imperfect models: injecting Gaussian noise acts as a Langevin MCMC stabilizer that knocks drifting samples back into high-probability manifolds. Deterministic ODEs and Flow Matching lack this noise cushion; model approximation errors accumulate monotonically along the trajectory. ⑤ Interview Strategy: Write the master SDE equation with parameter η\eta, show how η=1\eta=1 gives DDPM and η=0\eta=0 gives the Probability Flow ODE, show how Flow Matching sets g(t)=0g(t)=0 with straight velocity v=x1−x0v=x_1-x_0, and articulate the historical trajectory straightening progression.
⚠️ Common Interview Pitfalls
  • ✕
    Viewing diffusion models and flow matching as competing mutually exclusive paradigms rather than continuous-time siblings
  • ✕
    Assuming stochastic SDEs have no advantages; SDE noise injection provides valuable trajectory error-correction in low-capacity models
  • ✕
    Forgetting that Probability Flow ODEs and Flow Matching both support exact data log-likelihood computation via Jacobian trace integration
🎯 Interviewer Follow-up Inquiries
  • ?
    How does the stochasticity parameter η\eta continuously interpolate between the deterministic Probability Flow ODE and the stochastic reverse SDE?
  • ?
    What mathematical progression connects DDPM's 1000-step diffusion to Flow Matching's 20-step straight transport?
⚡
Test muscle memory on this topic via 3-Layer Flashcards
Active Recall: Mentally formulate Prompt ➔ Math Derivation ➔ Benchmark Implementation in 3 minutes.
🎯 Drill This Card Now➔
📚

Associated Knowledge Base Guides & Mindmaps

Explore the comprehensive technical article, exam cards, and global architecture tree.

← PreviousM6-074: Consistency Models and Latent Consistency Models (LCM): Foundations and Distillation📋Back to BankNext →M6-076: Latent Space Geometry, Semantic Disentanglement, and Vector Interpolation Feasibility
中文速览与面试要点

解释 Flow Matching 与 Diffusion 的统一视角。

两者都是'学一个把噪声输运到数据的场':扩散用加噪路径 + score,FM 用任意路径 + 速度场;可互相转换。

核心要点

  • 数学机理: 统一框架 ——(1) 共同的数学结构 ——两者都定义'把噪声分布输运到数据分布'的过程,可用 ODE (确定性)或 SDE (随机)描述:dx=v(x,t)dt(ODE)或 dx=f(x,t)dt+g(t)dW(SDE);生成即'从噪声积分到数据'。(2) 两个场的对应 ——(a) 扩散 学 score ∇log p_t(x)(通过 ε/v/x_0-prediction);(b) FM 学 速度场 v(x,t);(c) 关系 :v=f(x,t)−½g²(t)·∇log p_t(来自 SDE/ODE 的转换),即'速度 = 漂移 − ½扩散系数² × score'。(3) 路径的差异 ——(a) 扩散 的路径由'加噪调度'决定(x_t=√ᾱ_t x_0+√(1−ᾱ_t)ε)—— 弯曲 (非直线);(b) FM 可定义 任意路径 (含直线、OT 路径)——故可优化'路径直度'(→ 少步)。(4) 目标参数化的差异 ——(a) 扩散需选 ε/v/x_0-prediction(因为不同 SNR 区间难度不同);(b) FM 的直线路径目标是常数(x_1−x_0)—— 更简单 。(5) 训练损失的等价性 ——对同一路径,'score matching 损失'与'FM 损失' 等价 (因为两个场有线性关系);故两者的'训练'本质相同。 统一视角的实用价值 ——(a) 理论统一 ——不必区分'扩散派'与'FM 派'(它们是同一框架的特例);(b) 技术迁移 ——采样器(SDE/ODE 求解器)、引导(CFG)、参数化、量化都可在两者间迁移;(c) 路径设计空间 ——统一视角下,'选路径'成为明确的设计维度(直线/OT/扩散/VP/VE);(d) 模型互转 ——可从扩散模型转 FM(或反之),便于复用预训练权重。 为什么现代模型倾向 FM ——(a) 训练目标更简单 (常数目标、无参数化难题);(b) 路径可设计 (直线/OT → 少步采样);(c) 与扩散等价 (无功能损失);(d) 实证 ——SD3、Flux、以及多数新模型用 FM(rectified flow)。 更一般的框架 ——(a) 随机插值(Stochastic Interpolants) ——用'插值 + 噪声'统一描述(包含扩散与 FM);(b) 基于流的生成模型(Flow-based) ——连续归一化流(CNF)的一般理论。 实践建议 ——(a) 新项目 → FM(rectified flow,训练简单 + 少步友好);(b) 复用已有扩散模型 → 用扩散路径的 FM(等价);(c) 理解理论 → 用统一视角(SDE/ODE + 场)。 度量 ——(a) 步数 vs 质量;(b) 训练稳定性;(c) 与已有生态的兼容性。
  • 深度剖析与工程权衡:① '两者是同一框架的特例'是核心认知 ——面试中能给出 v=f−½g²∇log p 的关系式并说明'差异在路径与参数化'是深度理解的标志。② '技术可迁移'是统一视角的实用价值 ——采样器、引导、量化等都通用;这降低了'换框架'的成本。③ 'FM 训练更简单'是它流行的直接原因 ——常数目标、无参数化难题;这减少了调参负担。④ '路径可设计'是 FM 的独特优势 ——扩散的路径被'加噪调度'固定;FM 可选(直线/OT),从而优化少步采样。⑤ '等价性'避免'派系之争' ——不必争论'扩散 vs FM'(同一框架);应根据'路径设计与工程便利'选择。⑥ 面试要点 ——被问'FM 与扩散的关系',应给出' 统一为 ODE/SDE + 场(扩散学 score、FM 学速度)+ v=f−½g²∇log p 互相转换 + 差异在路径与参数化 '与' FM 训练更简单、路径可设计 ';能写出统一的关系式是深度理解的标志。
  • 统一为'ODE/SDE + 场':扩散学 score、FM 学速度
  • 两者通过 v=f−½g²∇log p 互相转换
  • 差异在'路径选择'与'目标参数化',而非框架

常见陷阱

  • 把 FM 与扩散当作互斥的两种方法
  • 忽略'路径设计'是 FM 的独特优势