Derivation of the Flow-SDE step from the flow-matching ODE
about 3 minutes
Setting. Fast-WAM's forward process is xσ=(1−σ)x0+σε with ε∼N(0,I) and σ∈[0,1], and the network is trained to predict v=ε−x0 (training_target in the scheduler). Differentiating the forward process in σ gives dx/dσ=ε−x0=v, so the deterministic sampler xk+1=xk+vΔk is the Euler discretisation of the ODE dx=vdσ, integrated from σ = 1 (noise) down to σ = 0 (data). This is the same convention as π₀ and πRL, whose τ plays the role of σ.
Step 1 — the score in terms of the velocity. Write m=E[x0∣xσ] and e=E[ε∣xσ] for the posterior means. The learned velocity is the posterior mean of ε−x0, so v=e−m, and taking the posterior mean of the forward process gives xσ=(1−σ)m+σe. Solving these two linear equations for e:
Tweedie's formula for a Gaussian perturbation of scale σ states E[ε∣xσ]=−σ∇logpσ(xσ), hence
∇xlogpσ(x)=−e/σ=−(x+(1−σ)v)/σ=−x/σ−((1−σ)/σ)v.
This matches the expression πRL prints, ∇logqτ(Aτ)=−Aτ/τ−((1−τ)/τ)vτ.
Step 2 — the equal-marginal SDE. Song et al. (2021) show that if a forward-in-σ diffusion dx=fdσ+gdw has marginals pσ, then the reverse-direction SDE dx=[f−g2∇logpσ]dσ+gdwˉ and the probability-flow ODE dx=[f−(g2/2)∇logpσ]dσ share those same marginals. Given the ODE drift v=f−(g2/2)∇logp, the reverse SDE drift is therefore v−(g2/2)∇logp, for any non-negative g(σ):
dx=[v−(g(σ)2/2)∇logpσ(x)]dσ+g(σ)dwˉ.
Substituting the score from Step 1:
dx=[v+(g(σ)2/(2σ))(x+(1−σ)v)]dσ+g(σ)dwˉ.
This is precisely the SDE both πRL (dAτ=[vτ+στ2/(2τ)(Aτ+(1−τ)vτ)]dτ+στdwτ) and Flow-GRPO state, with their στ equal to g(σ) here.
Step 3 — the noise schedule. πRL and Flow-GRPO choose g(σ)=aσ/(1−σ). With that choice the drift coefficient simplifies: g2/(2σ)=a2/(2(1−σ)). The choice is a convention rather than a necessity; any g preserves the marginals. It diverges at σ = 1, which is why the first denoising step must be deterministic.
Step 4 — discretisation. Euler–Maruyama with Fast-WAM's step Δk=σk+1−σk<0 gives
which is the update in Chapter 5. Setting a=0 recovers the deterministic step. The Gaussian transition is what makes the log-probability tractable; the parameters enter only through v_k, so ∂logN/∂φ=((xk+1−μk)/stdk2)⋅∂μk/∂φ, and ∂μk/∂vk=[1+(gk2/(2σk))(1−σk)]Δk.
Closed-form KL used in Chapter 9. For diagonal Gaussians, per dimension,