Robohouse ’26 Library
Contents

Appendix A

Derivation of the Flow-SDE step from the flow-matching ODE

about 3 minutes

Setting. Fast-WAM's forward process is xσ=(1−σ)x0+σεx_\sigma = (1-\sigma ) x_0 + \sigma \varepsilon with ε∼N(0,I)\varepsilon \sim \mathcal{N}(0, I) and σ∈[0,1]\sigma \in [0, 1], and the network is trained to predict v=ε−x0v = \varepsilon - x_0 (training_target in the scheduler). Differentiating the forward process in σ gives dx/dσ=ε−x0=vdx/d\sigma = \varepsilon - x_0 = v, so the deterministic sampler xk+1=xk+vΔkx_{k+1} = x_k + v \Delta _k is the Euler discretisation of the ODE dx=vdσdx = v d\sigma, integrated from σ = 1 (noise) down to σ = 0 (data). This is the same convention as π₀ and πRL, whose τ\tau plays the role of σ.

Step 1 — the score in terms of the velocity. Write m=E[x0∣xσ]m = \mathbb{E}[x_0 \mid x_\sigma ] and e=E[ε∣xσ]e = \mathbb{E}[\varepsilon \mid x_\sigma ] for the posterior means. The learned velocity is the posterior mean of ε−x0\varepsilon - x_0, so v=e−mv = e - m, and taking the posterior mean of the forward process gives xσ=(1−σ)m+σex_\sigma = (1-\sigma ) m + \sigma e. Solving these two linear equations for ee:

m=(xσ−σe)/(1−σ)v=e−(xσ−σe)/(1−σ)=(e−xσ)/(1−σ)⇒e=xσ+(1−σ)v.\begin{aligned} m &= (x_\sigma - \sigma e) / (1-\sigma) \\ v &= e - (x_\sigma - \sigma e)/(1-\sigma) = (e - x_\sigma)/(1-\sigma) \quad \Rightarrow \quad e = x_\sigma + (1-\sigma) v . \end{aligned}

Tweedie's formula for a Gaussian perturbation of scale σ states E[ε∣xσ]=−σ∇log⁡pσ(xσ)\mathbb{E}[\varepsilon \mid x_\sigma ] = -\sigma \nabla \log p_\sigma (x_\sigma ), hence

∇xlog⁡pσ(x)=− e/σ=−(x+(1−σ)v)/σ=− x/σ−((1−σ)/σ)v.\nabla_x \log p_\sigma(x) = -\,e / \sigma = -\big( x + (1-\sigma) v \big) / \sigma = -\,x/\sigma - \big((1-\sigma)/\sigma\big) v .

This matches the expression πRL prints, ∇log⁡qτ(Aτ)=−Aτ/τ−((1−τ)/τ) vτ\nabla \log q_\tau(A^\tau) = -A^\tau/\tau - ((1-\tau)/\tau)\, v^\tau.

Step 2 — the equal-marginal SDE. Song et al. (2021) show that if a forward-in-σ diffusion dx=fdσ+gdwdx = f d\sigma + g dw has marginals pσp_\sigma, then the reverse-direction SDE dx=[f−g2∇log⁡pσ]dσ+gdwˉdx = [f - g^2 \nabla \log p_\sigma ] d\sigma + g d\bar{w} and the probability-flow ODE dx=[ f−(g2/2) ∇log⁡pσ ] dσdx = [\,f - (g^2/2)\, \nabla \log p_\sigma\,]\, d\sigma share those same marginals. Given the ODE drift v=f−(g2/2) ∇log⁡pv = f - (g^2/2)\, \nabla \log p, the reverse SDE drift is therefore v−(g2/2) ∇log⁡pv - (g^2/2)\, \nabla \log p, for any non-negative g(σ)g(\sigma):

dx=[ v−(g(σ)2/2) ∇log⁡pσ(x) ] dσ+g(σ) dwˉ.dx = \big[\, v - (g(\sigma)^2/2)\, \nabla \log p_\sigma(x) \,\big]\, d\sigma + g(\sigma)\, d\bar{w} .

Substituting the score from Step 1:

dx=[ v+(g(σ)2/(2σ))(x+(1−σ)v) ] dσ+g(σ) dwˉ.dx = \big[\, v + \big(g(\sigma)^2 / (2\sigma)\big) \big( x + (1-\sigma) v \big) \,\big]\, d\sigma + g(\sigma)\, d\bar{w} .

This is precisely the SDE both πRL (dAτ=[ vτ+στ2/(2τ)(Aτ+(1−τ)vτ) ] dτ+στ dwτdA^\tau = [\,v^\tau + \sigma_\tau^2/(2\tau)(A^\tau + (1-\tau)v^\tau)\,]\, d\tau + \sigma_\tau\, dw_\tau) and Flow-GRPO state, with their στ\sigma_\tau equal to g(σ)g(\sigma) here.

Step 3 — the noise schedule. πRL and Flow-GRPO choose g(σ)=aσ/(1−σ)g(\sigma) = a \sqrt{\sigma/(1-\sigma)}. With that choice the drift coefficient simplifies: g2/(2σ)=a2/(2(1−σ))g^2/(2\sigma) = a^2/(2(1-\sigma)). The choice is a convention rather than a necessity; any gg 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\Delta _k = \sigma _{k+1} - \sigma _k < 0 gives

μk=xk+[ vk+(gk2/(2σk))(xk+(1−σk)vk) ]Δkstdk=gk∣Δk∣xk+1∼N(μk,stdk2I),\begin{aligned} \mu_k &= x_k + \big[\, v_k + \big(g_k^2 / (2\sigma_k)\big) \big( x_k + (1-\sigma_k) v_k \big) \,\big] \Delta_k \\ \mathrm{std}_k &= g_k \sqrt{|\Delta_k|} \\ x_{k+1} &\sim \mathcal{N}\big( \mu_k, \mathrm{std}_k^2 I \big) , \end{aligned}

which is the update in Chapter 5. Setting a=0a = 0 recovers the deterministic step. The Gaussian transition is what makes the log-probability tractable; the parameters enter only through v_k, so ∂log⁡N/∂φ=((xk+1−μk)/stdk2)⋅∂μk/∂φ\partial \log \mathcal{N} / \partial \varphi = \big((x_{k+1} - \mu_k)/\mathrm{std}_k^2\big) \cdot \partial \mu_k / \partial \varphi, and ∂μk/∂vk=[ 1+(gk2/(2σk))(1−σk) ] Δk\partial \mu_k / \partial v_k = [\,1 + (g_k^2/(2\sigma_k))(1-\sigma_k)\,]\, \Delta_k.

Closed-form KL used in Chapter 9. For diagonal Gaussians, per dimension,

KL(N(μ1,s12) ∥ N(μ2,s22))=12[log⁡(s22/s12)+(s12+(μ1−μ2)2)/s22−1],\mathrm{KL}\big( \mathcal{N}(\mu_1, s_1^2) \,\|\, \mathcal{N}(\mu_2, s_2^2) \big) = \tfrac{1}{2} \big[ \log(s_2^2/s_1^2) + (s_1^2 + (\mu_1-\mu_2)^2)/s_2^2 - 1 \big] ,

and substituting μ1=zθ,s12=Σθ,μ2=zold,s22=Σold\mu _1 = z^\theta , s_1^2 = \Sigma _\theta , \mu _2 = z^{\mathrm{old}}, s_2^2 = \Sigma _{\mathrm{old}} gives the expression in §9.4.