NOAH XIE Visual Study Notes · Observatory & Archive
Noah Xie
Nunc

t = 0.00Origin · Home

Noah Xie

This article is currently available in English only. Browse the Chinese section

ODE vs. SDE in Generative Paths

2 min read Completed

Deterministic Transport vs. Stochastic Error Healing

Both Probability Flow ODEs and Reverse-Time SDEs share identical time-marginal distributions $p_t(x)$ in the exact-score limit, yet they behave very differently once $v_\theta$ or $s_\theta$ carries approximation error and sampling budgets shrink to 4–16 function evaluations (NFE).

$$ \text{ODE: } dx_t = v_\theta(x_t, t)\,dt \qquad \text{vs.} \qquad \text{SDE: } dx_t = \left[f(x_t,t) - g(t)^2 s_\theta(x_t,t)\right]dt + g(t)\,d\bar{w}_t $$

Regime Trade-Off Table

Property Optimal-Transport ODE (OT-CFM / Reflow) Reverse-Time SDE (VP-SDE)
Low-NFE fidelity (4–16) Strong; straight lines keep Euler/Heun error tiny Degrades rapidly due to Brownian variance
Error healing at high NFE None — local score errors accumulate deterministically Contracts marginal mismatch via noise injection
Invertibility / Editing Exact bijective encoding $x_1 \leftrightarrow x_0$ Non-unique stochastic paths
Inverse-problem guidance Clean proximal projection without noise blowup Sensitive to likelihood step-size $\zeta_t$

Minimal Heun ODE vs. Euler-Maruyama SDE Stepper

import torch

@torch.no_grad()
def heun_ode_step(v_net, x, t, dt):
    v0 = v_net(x, t)
    x_euler = x + dt * v0
    v1 = v_net(x_euler, t + dt)
    return x + 0.5 * dt * (v0 + v1)

@torch.no_grad()
def euler_maruyama_step(drift_fn, g_t, x, t, dt):
    noise = torch.randn_like(x)
    return x + drift_fn(x, t) * dt + g_t * (abs(dt) ** 0.5) * noise

Decision Flow

For the formal derivations behind both paths, read Score-Based Generative Modeling through SDEs and Flow Matching for Generative Modeling.