Skip to content
QFT.org

Search QFT.org

Enter a word or phrase.

    You can also browse the main navigation and chapter contents.

    Diffusion and Score-Based Field Models

    Can adding noise make a field easier to sample? For a finite Gaussian field the answer can be demonstrated exactly: noise gradually removes its correlations, and a known score reverses that process. For an interacting field, however, a small denoising loss does not establish that the generated configurations have the right distribution. The score must be learned, the reverse equation must be integrated, and the terminal noise distribution must be specified.

    We will keep those errors separate. A two-site Euclidean scalar provides an exact Gaussian control and an interacting target with independent reference integrals. One fitted score produces useful but visibly biased samples. Refining its deterministic transport almost eliminates the integration error while leaving the observable bias.

    Preparation: Multivariate Gaussian conditioning, Itô diffusion, and the finite scalar measure in learning a field observable. All times below parameterize a sampling procedure; they are not physical real or Euclidean time.

    A finite field with an independent reference

    Take two periodic sites, lattice spacing one, and the positive Euclidean action

    S(ϕ)=∑i=01[(ϕi+1−ϕi)22+r2ϕi2+λ24ϕi4],ϕ2=ϕ0.(1)S(\phi)=\sum_{i=0}^{1}\left[ \frac{(\phi_{i+1}-\phi_i)^2}{2} +\frac r2\phi_i^2+\frac{\lambda}{24}\phi_i^4 \right], \qquad \phi_2=\phi_0. \tag{1}

    Both kinetic summands are present. The orthonormal coordinates Q=(ϕ0+ϕ1)/2Q=(\phi_0+\phi_1)/\sqrt2 and R=(ϕ0−ϕ1)/2R=(\phi_0-\phi_1)/\sqrt2 have unit absolute Jacobian. For x=(Q,R)x=(Q,R),

    S(x)=r2Q2+r+42R2+λ48(Q4+6Q2R2+R4).(2)S(x)=\frac r2Q^2+\frac{r+4}{2}R^2 +\frac{\lambda}{48}(Q^4+6Q^2R^2+R^4). \tag{2}

    The normalized measure is π(x) d2x=Z−1e−S(x) dQ dR\pi(x)\,\mathrm d^2x=Z^{-1}e^{-S(x)}\,\mathrm dQ\,\mathrm dR. We fix r=2r=2 and λ=4\lambda=4. These are finite-regulator inputs, with no continuum or volume extrapolation. Setting λ=0\lambda=0 gives the Gaussian control

    C0=(1/2001/6).(3)C_0=\begin{pmatrix}1/2&0\\0&1/6\end{pmatrix}. \tag{3}

    The interacting target also has a simple exact reference sampler. Draw xx from q0=N(0,C0)q_0=\mathcal N(0,C_0) and accept with probability

    e−V(x),V(x)=Q4+6Q2R2+R412≥0.(4)e^{-V(x)},\qquad V(x)=\frac{Q^4+6Q^2R^2+R^4}{12}\geq0. \tag{4}

    Then q0(x)e−V(x)q_0(x)e^{-V(x)} is proportional to e−S(x)e^{-S(x)}. The acceptance is Z/Z0Z/Z_0, where Z0=2π/12Z_0=2\pi/\sqrt{12}. Moreover, Gaussian moments give Eq0V=1/9\mathbb E_{q_0}V=1/9, so Jensen's inequality gives acceptance at least e−1/9e^{-1/9}. The normalizing constant is unnecessary for accepting samples.

    The numerical example reuses checked quadrature from the preceding chapter:

    ⟨Q2⟩π=0.3985562156,⟨R2⟩π=0.1535075516.(5)\langle Q^2\rangle_\pi=0.3985562156,\qquad \langle R^2\rangle_\pi=0.1535075516. \tag{5}

    Orders 128128 through 320320, an adaptive integration and an omitted-tail bound were already checked for this same action. New rejection draws supply training and testing fields. They are independent target draws, not configurations from a chain whose mixing must be assumed.

    Noising and the score

    Use the Ornstein–Uhlenbeck process

    dXt=−Xt dt+2 dWt,Xt=atX0+vt Z,at=e−t,vt=1−e−2t,(6)\mathrm dX_t=-X_t\,\mathrm dt+\sqrt2\,\mathrm dW_t, \qquad X_t=a_tX_0+\sqrt{v_t}\,Z, \quad a_t=e^{-t},\quad v_t=1-e^{-2t}, \tag{6}

    where Z∼N(0,I)Z\sim\mathcal N(0,I) is independent of X0X_0. The marginal ptp_t tends to the standard Gaussian as t→∞t\to\infty. At a finite terminal time TT, it generally is not exactly that Gaussian.

    The score is s∗(x,t)=∇xlog⁡pt(x)s_*(x,t)=\nabla_x\log p_t(x). Differentiating the convolution defining ptp_t yields

    s∗(x,t)=E[−Xt−atX0vt | Xt=x]=atE[X0∣Xt=x]−xvt.(7)s_*(x,t)= \mathbb E\left[ -\frac{X_t-a_tX_0}{v_t}\,\middle|\,X_t=x \right] =\frac{a_t\mathbb E[X_0\mid X_t=x]-x}{v_t}. \tag{7}

    The Gaussian conditional score inside the expectation is known for each noisy training pair. It is not itself the marginal score: many clean fields can produce the same noisy field. Conditional expectation is the reason denoising score matching works.

    For the free field, the convolution remains Gaussian:

    Ct=I+at2(C0−I),s∗(x,t)=−Ct−1x.(8)C_t=I+a_t^2(C_0-I),\qquad s_*(x,t)=-C_t^{-1}x. \tag{8}

    No training is needed to test a reverse solver against this control. The general noising and denoising-score construction is developed by Song et al., §§3.1–3.3, Eqs. (5)–(7).

    Reverse stochastic evolution and probability flow

    Write τ=T−t\tau=T-t, so τ\tau increases while noise is removed. The reverse stochastic equation and the deterministic probability-flow equation are

    dYτ=[Yτ+2s∗(Yτ,T−τ)] dτ+2 dW‾τ,dYτdτ=Yτ+s∗(Yτ,T−τ).(9)\begin{aligned} \mathrm dY_\tau &=\bigl[Y_\tau+2s_*(Y_\tau,T-\tau)\bigr]\, \mathrm d\tau+\sqrt2\,\mathrm d\overline W_\tau,\\ \frac{\mathrm dY_\tau}{\mathrm d\tau} &=Y_\tau+s_*(Y_\tau,T-\tau). \end{aligned} \tag{9}

    The different coefficients of the score are essential. The forward Fokker–Planck equation is

    ∂tp=∇ ⁣⋅(xp)+Δp=−∇ ⁣⋅[(−x−∇log⁡p)p].(10)\partial_t p=\nabla\!\cdot(xp)+\Delta p =-\nabla\!\cdot\bigl[(-x-\nabla\log p)p\bigr]. \tag{10}

    Thus the forward deterministic velocity is −x−s∗-x-s_*; changing to τ\tau gives the second line of (9). The reverse diffusion retains a noise term and requires twice that score contribution. With the exact compatible score and the actual terminal law pTp_T, the two equations have the same time marginals, although their individual trajectories differ. See Song et al., §3.2 and Appendix D.1, Eqs. (35)–(37).

    For the diagonal Gaussian control, the deterministic map is explicit:

    Yτ=CT−τ1/2CT−1/2Y0.(11)Y_\tau=C_{T-\tau}^{1/2}C_T^{-1/2}Y_0. \tag{11}

    If Y0∼N(0,CT)Y_0\sim\mathcal N(0,C_T), the output has covariance C0C_0. If we initialize with N(0,I)\mathcal N(0,I) instead, its covariance is C0CT−1C_0C_T^{-1}. The stochastic process responds differently. Its linear propagation of initial conditions is F=e−TC0CT−1F=e^{-T}C_0C_T^{-1}, giving

    CSDE,0=C0+F(I−CT)FT.(12)C_{\mathrm{SDE},0} =C_0+F(I-C_T)F^T. \tag{12}

    For T=1T=1, the wrong-terminal deterministic output has variances (0.536289,0.187853)(0.536289,0.187853); the stochastic output has (0.502634,0.167205)(0.502634,0.167205). Both differ from (0.5,1/6)(0.5,1/6) despite using the exact score. At T=4T=4 those errors are much smaller. This is a terminal-law effect, not a discretization or fitting error.

    The companion checks the exact conditional Gaussian reverse kernels, Euler covariance recursion and RK4 propagation over fixed refinements. It also removes the noise while retaining the stochastic drift as a negative control. That incorrect ODE compresses the distribution toward zero; reducing its step size cannot repair the missing factor of one half.

    A trained score that remains globally well defined

    For the interacting example fix T=4T=4 and use

    sc(x,t)=−x+e−2t∑0≤a,b≤3(a,b)≠(0,0)∑ℓ=03cabℓPℓ(2t/T−1)∇Φab(x),Φab(x)=cos⁡(aQ/2)cos⁡(bR).(13)\begin{aligned} s_c(x,t)&=-x+e^{-2t} \sum_{\substack{0\leq a,b\leq3\\(a,b)\ne(0,0)}} \sum_{\ell=0}^{3} c_{ab\ell}P_\ell(2t/T-1)\nabla\Phi_{ab}(x),\\ \Phi_{ab}(x)&=\cos(aQ/2)\cos(bR). \end{aligned} \tag{13}

    The PℓP_\ell are Legendre polynomials. There are 6060 real fitted coefficients. This is a finite feature model, not a neural network. Its potential is even separately in QQ and RR, so its score respects those symmetries.

    The bounded nonlinear features have another purpose. Their gradients and Hessians are bounded, making the learned ODE globally Lipschitz and its drift bounded; the learned SDE has a linear confining part plus a bounded correction. Both evolutions are globally well posed on the finite interval. An unrestricted polynomial score could instead produce finite-time escape in a reverse ODE, invalidating a claimed global density map.

    At every time, (13) is the gradient of a normalizable Gaussian potential plus a bounded correction. That fact does not make its time-dependent potentials compatible with the OU equation. Consequently its learned stochastic and deterministic samplers need not have the same marginals. Its bounded correction also cannot reproduce the cubic clean-field score throughout all tails.

    Train once on n=32768n=32768 independent clean fields, independent uniform times in [0,4][0,4], and independent Gaussian noises. Minimize

    L(c)=12n∑j=1nvtj∥sc(Xtj,tj)+Zjvtj∥2+10−42 cTc.(14)\mathcal L(c)= \frac1{2n}\sum_{j=1}^{n} v_{t_j}\left\lVert s_c(X_{t_j},t_j)+\frac{Z_j}{\sqrt{v_{t_j}}} \right\rVert^2 +\frac{10^{-4}}2\,c^Tc. \tag{14}

    This objective is quadratic in cc. The implementation forms the weighted response vtXt−Z\sqrt{v_t}X_t-Z, avoiding division by a small noise scale, and solves the augmented ridge problem by an SVD. The fit uses no exact interacting score values. A separate 81928192-pair set measures held-out denoising loss.

    The unregularized design has condition number 1.70×1051.70\times10^5; the augmented design has condition number 82.582.5. The recomputed scaled gradient is 5.76×10−165.76\times10^{-16}, below the prescribed 10−1010^{-10} target. Nevertheless, the held-out weighted loss 0.058550.05855 hides a substantial clean-field error. Independent conditional Gaussian quadrature gives componentwise score RMSE 0.2960.296 at t=0.05t=0.05, 0.07970.0797 at t=0.2t=0.2, and 0.01370.0137 at t=1t=1. Comparing with the exact −∇S-\nabla S at t=0t=0 gives RMSE 0.7650.765. The fixed quadrature refinement changes the reference scores by at most 4.3×10−124.3\times10^{-12} on the tested points.

    Near t=0t=0, the weight vtv_t becomes small. A well-solved weighted regression therefore need not give a highly accurate endpoint score. This numerical fit illustrates that distinction without changing the model after inspecting its error.

    Measure the generated fields

    The frozen model generates 81928192 independent trajectories per setting from a standard Gaussian terminal law. Euler uses 128,256,512128,256,512 reverse steps. RK4 uses 32,64,12832,64,128 steps, matching the three budgets of 128,256,512128,256,512 score evaluations per trajectory. Initial Gaussian vectors are shared, and nested Brownian increments couple the stochastic refinements. The errors below are iid standard errors conditional on this one fitted model, not uncertainty from repeated training.

    TransportScore evaluations⟨Q2⟩\langle Q^2\rangle⟨R2⟩\langle R^2\rangle
    Exact target—0.3985560.3985560.1535080.153508
    Euler SDE1281280.44867±0.007290.44867\pm0.007290.23909±0.004780.23909\pm0.00478
    Euler SDE2562560.43504±0.007060.43504\pm0.007060.22443±0.004550.22443\pm0.00455
    Euler SDE5125120.42857±0.006950.42857\pm0.006950.21761±0.004440.21761\pm0.00444
    RK4 ODE1281280.42220±0.007750.42220\pm0.007750.22111±0.009610.22111\pm0.00961
    RK4 ODE5125120.42220±0.007750.42220\pm0.007750.22111±0.009610.22111\pm0.00961

    The deterministic sample means are stable under refinement, but their bias remains. The stochastic means still move with the step size and also remain above the target. Neither observation licenses an extrapolation that all remaining bias is purely score error.

    The prespecified fourth moment makes the tail limitation more visible. At the finest grids, ⟨R4⟩\langle R^4\rangle is 0.8061±0.19070.8061\pm0.1907 for the ODE and 0.2086±0.03010.2086\pm0.0301 for the SDE, against the reference 0.06996010.0699601. These are finite-sample diagnostics, not precision determinations of the far-tail density. They nevertheless expose a failure that the low weighted denoising loss and the small ODE integration error did not detect.

    Exact Gaussian terminal-law errors and the interacting second-moment biases of reverse stochastic and deterministic samplers across fixed score-call budgets.

    The Gaussian panel isolates a terminal-law error without sampling or fitting. The interacting panels show uncorrected bias with one standard error from 81928192 generated fields, conditional on the frozen score fit. Small deterministic step error does not remove the model's observable bias.

    A final paired control starts the finest transports with the actual interacting terminal law, generated as e−4X0+1−e−8Ze^{-4}X_0+\sqrt{1-e^{-8}}Z from independent exact target fields. Its shifts in ⟨Q2⟩,⟨R2⟩\langle Q^2\rangle,\langle R^2\rangle are (2.2,−2.3)×10−7(2.2,-2.3)\times10^{-7} for the SDE and (1.4,5.6)×10−5(1.4,5.6)\times10^{-5} for the ODE, all unresolved against their paired standard errors. Initialization is not the dominant resolved problem at this TT.

    These are uncorrected samples. A continuous ODE can supply its own density through a Jacobian equation, but numerical density error must be assessed. A stochastic trajectory supplies transition densities; multiplying them gives a path density, not its endpoint marginal. The next page, continuous and stochastic normalizing flows, derives these distinctions and a valid extended-path ratio.

    The companion files under examples/computational-qft/generative-models/ retain the fitted coefficients in score-model.json, fit checks in score-training-results.json, and endpoint comparisons in diffusion-results.json. They include fixed seeds, moment covariance matrices, rejection counts and all prescribed refinements. Exact rejection is already efficient for this teaching target; no high-dimensional speed or continuum claim follows.

    Summary

    Noising provides a tractable conditional distribution and hence a trainable score objective. Exact reverse recovery additionally needs a compatible score, the correct terminal law and adequate integration. The Gaussian control separates these requirements. The interacting calculation shows why optimizer convergence and a small weighted loss cannot replace measurements of the generated physical observables.

    Exercises

    1. A wrong terminal covariance

    For one Gaussian mode, let ct=1+e−2t(c0−1)>0c_t=1+e^{-2t}(c_0-1)>0. Derive the deterministic map, the conditional law of XtX_t given Xt+hX_{t+h}, and the final ODE and reverse-SDE variances when the terminal variance is dTd_T instead of cTc_T. Check T=0T=0 and T→∞T\to\infty for dT=1d_T=1.

    Solution

    The deterministic reverse velocity is (1−1/cT−τ)Yτ(1-1/c_{T-\tau})Y_\tau. Since ∂tct=2(1−ct)\partial_t c_t=2(1-c_t), its solution is Yτ=cT−τ/cT Y0Y_\tau=\sqrt{c_{T-\tau}/c_T}\,Y_0. Thus the final variance is c0dT/cTc_0d_T/c_T.

    The joint forward covariance satisfies Cov⁡(Xt,Xt+h)=e−hct\operatorname{Cov}(X_t,X_{t+h})=e^{-h}c_t. Gaussian conditioning gives

    Xt∣Xt+h=y∼N(e−hctct+hy, ct−e−2hct2ct+h).X_t\mid X_{t+h}=y \sim\mathcal N\left( e^{-h}\frac{c_t}{c_{t+h}}y,\, c_t-e^{-2h}\frac{c_t^2}{c_{t+h}} \right).

    Composing the conditional means from TT to 00 gives F=e−Tc0/cTF=e^{-T}c_0/c_T. With the correct terminal variance, the exact reverse SDE ends at c0c_0. Changing only the initial variance adds F2(dT−cT)F^2(d_T-c_T), so

    cSDE,0=c0+e−2Tc02cT2(dT−cT).c_{\mathrm{SDE},0} =c_0+e^{-2T}\frac{c_0^2}{c_T^2}(d_T-c_T).

    At T=0T=0 both answers equal d0d_0, as no transport occurs. For dT=1d_T=1 and T→∞T\to\infty, both approach c0c_0. Their leading terminal errors differ: the ODE correction is of order e−2Te^{-2T}, while the SDE correction is of order e−4Te^{-4T}. Equality of the two marginals cannot be inferred after replacing the prescribed terminal law by another one.

    2. What does the denoising loss learn?

    Let U=−(Xt−atX0)/vtU=-(X_t-a_tX_0)/v_t for t>0t>0. Show that minimizing E∥s(Xt,t)−U∥2\mathbb E\lVert s(X_t,t)-U\rVert^2 over all square-integrable functions gives the marginal score. Explain why weighting by vtv_t, restricting the feature family and imposing symmetry do not prove exact reverse recovery.

    Solution

    Condition on Xt=xX_t=x. Differentiating its positive Gaussian convolution gives E[U∣Xt=x]=∇log⁡pt(x)\mathbb E[U\mid X_t=x]=\nabla\log p_t(x). Orthogonality of conditional expectation yields

    E∥s−U∥2=E∥s−s∗∥2+E∥U−s∗∥2.\mathbb E\lVert s-U\rVert^2 =\mathbb E\lVert s-s_*\rVert^2 +\mathbb E\lVert U-s_*\rVert^2.

    The second term is independent of ss, so the unconstrained minimum is attained by s∗s_*. A positive time weight leaves this pointwise optimum unchanged, but changes how a restricted family compromises among times. Here multiplying by vt\sqrt{v_t} gives the linear response vtXt−Z\sqrt{v_t}X_t-Z and design columns vte−2tPℓ∇Φab\sqrt{v_t}e^{-2t}P_\ell\nabla\Phi_{ab}; the ridge penalty further changes the optimum.

    Exact symmetry constrains allowed functions without determining their values. A conservative vector field may be a score of some normalized density at each time while those densities fail the forward Fokker–Planck equation. Reverse recovery requires the actual compatible marginal scores and terminal distribution, not only a gradient representation, symmetry or a small empirical weighted loss.

    References

    • Song, Yang, Jascha Sohl-Dickstein, Diederik P. Kingma, Abhishek Kumar, Stefano Ermon and Ben Poole. “Score-Based Generative Modeling through Stochastic Differential Equations.” arXiv:2011.13456v2, HTML (2021), §§3.1–3.4 and 4.3; Appendix D.1, Eqs. (35)–(37). The increasing reverse-time convention in (9) is translated explicitly above.

    Scrollable formula. Use Left and Right arrow keys to reveal hidden content.

    Scrollable table. Use Left and Right arrow keys to reveal hidden columns.

    Scrollable figure. Use Left and Right arrow keys to reveal hidden content.