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[x0xσ]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=emv = 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σ)=(exσ)/(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σ]=σlogpσ(xσ)\mathbb{E}[\varepsilon \mid x_\sigma ] = -\sigma \nabla \log p_\sigma (x_\sigma ), hence

xlogpσ(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, logqτ(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=[fg2logpσ]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)logpσ]dσdx = [\,f - (g^2/2)\, \nabla \log p_\sigma\,]\, d\sigma share those same marginals. Given the ODE drift v=f(g2/2)logpv = f - (g^2/2)\, \nabla \log p, the reverse SDE drift is therefore v(g2/2)logpv - (g^2/2)\, \nabla \log p, for any non-negative g(σ)g(\sigma):

dx=[v(g(σ)2/2)logpσ(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Δkxk+1N(μ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 logN/φ=((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)/s221],\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.