- Home
- Library
- Computational Quantum Field Theory
- Learning to Sample Field Configurations
- Continuous and Stochastic Normalizing Flows
Continuous and Stochastic Normalizing Flows
A transported field configuration is not enough to evaluate a probability ratio. For a deterministic invertible map, its Jacobian supplies the missing density. For a stochastic procedure, the recorded transitions determine a path density; obtaining the endpoint density normally requires integrating over unobserved paths.
This distinction matters when a learned proposal enters importance sampling or Metropolis acceptance. We will compute a continuous transport density, test what a numerical solver actually approximates, and build an explicit Gaussian path example. The interacting comparison uses the same frozen score as diffusion and score-based field models, so the density and cost discussion refers to an actual fitted model rather than a hypothetical exact score.
Preparation: Change of variables, Gaussian conditioning, and ordinary differential equations. The sampling time is artificial. The field has two real coordinates with the positive Euclidean measure defined on the preceding page.
The density of a continuous map
Let
Assume that is continuously differentiable in its spatial argument, globally Lipschitz there uniformly on , and that and its spatial derivative are jointly continuous. The solution exists globally over this interval and defines an invertible differentiable map . These hypotheses matter: a learned polynomial vector field can generate finite-time escape, in which case a global change-of-variables claim is unjustified.
Differentiate the solution with respect to . Its Jacobian matrix obeys
Jacobi's determinant identity then gives
The determinant is positive, since it starts at one and is the exponential of a finite integral. Hence the transported model density satisfies
The same equation follows from probability conservation: . This is an exact statement about the density of the specified continuous flow. It does not assert that this density equals a desired physical target. See Song et al., Appendix D.1–D.2, Eqs. (35)–(40).
A density that can be checked exactly
The free two-site field has covariance . Under ,
The exact reverse probability-flow velocity is . Its map and determinant are
Starting with gives covariance . Substituting the map into the normalized Gaussian density reproduces (4), including its sign and endpoint term. The companion independently integrates the divergence at quadrature orders and for , and compares it with (6).
Starting instead with a standard Gaussian gives a different but still normalized final model:
Computing its density exactly does not make it the intended . Density correctness and target approximation are separate questions.
For the interacting field, the fitted score on the preceding page has the form . Its reverse ODE velocity is , so the linear terms cancel. Bounded feature gradients and Hessians ensure the global assumptions used above. The density in (4) therefore exists for this learned continuous map even though its field moments are biased.
Continuous divergence is not a discrete Jacobian
Suppose a numerical integrator returns a map and also integrates the scalar equation . There are now two quantities:
They coincide for the exact flow but need not coincide at finite step size. The first is the derivative of the numerical update itself. The second approximates the log determinant of the continuous flow. Treating the latter as an exact density for the numerical proposal can invalidate a probability ratio.
For RK4 we differentiate every stage and compose the resulting matrices. Equivalently, apply RK4 to the coupled state and variational equations, using the same intermediate states. This produces the actual derivative of the finite RK4 map. We separately integrate its divergence and compare the two.
The fixed experiment uses base Gaussian probes and the same -coefficient interacting score. Over the sampled points:
| RK4 steps | Maximum log-determinant discrepancy | Maximum reverse-map defect |
|---|---|---|
The reverse-map defect integrates the ODE back from each computed endpoint. All tested numerical determinants are positive, but checking finitely many points is not a global invertibility proof for . The global proof above concerns the continuous flow.
On the first eight probes, centered differences of the complete numerical map agree with its stage-derived Jacobian to about at difference step ; reducing that step to exposes roundoff. On a predetermined subset of probes, DOP853 with two fixed tolerance pairs changes the augmented solution by . At RK4 steps, the largest endpoint difference from the tighter reference is and the divergence-integral difference is .
These checks resolve numerical transport and density error on the declared probes. They do not bound every tail configuration or remove score-model bias. The small continuous-solver error coexists with the substantial interacting moment bias measured on the previous page.
Left: two distinct density diagnostics converge with step refinement on the fixed probes. Right: sampling-only transport times use identical batch sizes and score-call budgets; density derivatives, training and input generation are accounted for separately. The timings describe this implementation, not an accuracy or scaling theorem.
Stochastic transitions define an extended probability space
Let a reverse sampler start from and apply normalized stochastic kernels . Its joint path density is
For reverse Euler with step , the kernels are known Gaussians with mean and covariance . This makes (9) tractable. Its endpoint density is instead
One realized noise history does not perform that integral. In particular, paths sharing an endpoint can have different values of (9).
There is nevertheless a useful exact construction on path space. Choose normalized kernels toward the noisier fields and define
Successively integrating out gives the desired endpoint marginal . In this example the can be exact OU noising kernels, with mean and covariance .
The extended importance ratio is
If covers and the required moments are integrable, independent proposal paths can be weighted by (12). If is known only up to normalization, the corresponding self-normalized estimator is consistent under the usual law-of-large-numbers conditions, but has finite-sample ratio bias. An independent Metropolis algorithm could instead operate on the entire path. Neither procedure substitutes a path probability for the endpoint proposal density in an ordinary endpoint-only ratio. This construction and its marginal distinction are explicit in Wu, Köhler and Noé, §2, Eqs. (8)–(12) and Theorem 1.
A fully calculable path check
Take the free Gaussian field at chronological times . Assemble its full six-dimensional covariance directly:
Its joint normalized Gaussian density agrees with the product of the two forward transition densities and with the product of the two exact conditional reverse densities. The latter use
The ratio (12) is then one for every path, since both factorizations describe the same joint law. The companion checks the origin and all twelve signed coordinate-unit vectors against the independently assembled joint covariance.
Replace the reverse kernels by Euler kernels. Their product still agrees with the corresponding six-dimensional Gaussian joint density, but it differs from the two-dimensional endpoint density obtained by marginalization. In the retained example, two paths ending at the origin have joint log densities and , while both have endpoint log density . The stochastic model's density is not ill-defined; the path and endpoint are simply different random variables.
This is a Gaussian density calculation, not an executed interacting path-space Metropolis or importance-sampling study. The interacting outputs on the preceding page remain explicitly uncorrected.
Density estimation and cost
In many dimensions, a trace such as can be estimated with a random vector satisfying :
This is the trace estimator used in Song et al., Appendix D.2, Eq. (40). Here the dimension is only two, so the calculation evaluates the trace directly. In a stochastic trace calculation, unbiasedness of the trace estimate does not make an exponentiated log-density estimate unbiased. For example,
An ordinary Metropolis ratio requires the appropriate proposal probabilities; arbitrary noisy log-density substitutes do not inherit its invariance proof. Specialized extended-space methods need their own positive-weight and distributional construction.
For the actual interacting score model, the matched sampling budgets are score evaluations per trajectory: that many Euler steps versus one quarter as many RK4 steps. A fixed batch of uses cached base vectors and Brownian increments, one warmup and three timed replays:
| Score calls per trajectory | Euler SDE median time | RK4 ODE median time |
|---|---|---|
These are comparable transport-kernel timings on one implementation. They exclude cached-input generation, training and I/O. A fresh Euler trajectory also needs Gaussian variates beyond its two base variates; the deterministic trajectory needs only the two base variates. Integrating the ODE Jacobian or density adds derivative evaluations and state components, which are absent from the sampling-only timing table. The fitted model's one-time SVD and design diagnostics took about in this run.
Equal score calls therefore do not imply equal end-to-end cost or equal accuracy. Both outputs have model bias, and their stochastic uncertainties differ. No break-even or high-dimensional advantage is inferred. The companion retains all raw timing repeats and input-generation costs, so exclusion of cached work is explicit.
The pure maps and checks are in continuous_transport.py, transport_checks.py and transport-results.json under examples/computational-qft/generative-models/. Reproduction consumes the delivered score coefficients; plotting does not train or resample. For corrections with an explicitly normalized finite proposal, continue to corrected learned proposals.
Summary
A globally defined continuous flow has a tractable density through its divergence or variational determinant. A numerical approximation introduces a separate density error, and a learned flow can still miss the physical target. Stochastic transitions supply an extended path law; a valid correction must use that law or compute the endpoint marginal. Keeping these objects distinct makes both probability ratios and cost comparisons meaningful.
Exercises
1. A continuous map and its Euler approximation
For in dimensions, derive the exact density transformation over a time step . Compare the log determinant of a single Euler map with the integrated divergence. State the conditions for invertibility and explain what density would be correct for each map.
Solution
The exact map is , with Jacobian . Thus
The variational equation is , and its log determinant is , equal to the integrated divergence.
Euler gives , which is invertible precisely when . Its correct density is
For , its log determinant expands as
Replacing this determinant by while keeping the Euler endpoint mixes two different maps. At , the Euler map collapses all inputs to a point and has no ordinary density obtained by an invertible change of variables. The exact continuous map remains invertible for every finite real .
2. Integrating out a stochastic history
Let , and , with independent centered Gaussian noises of positive variances . Compute the endpoint law. Explain why a product of transition densities is insufficient as an endpoint proposal probability, and derive the extended-path ratio for a chosen target density and normalized backward kernels.
Solution
Substitution gives . Hence
Its density is the joint density
integrated over . At the same fixed , changing or changes the product, while the endpoint density remains .
Choose normalized and . The joint target has marginal . Therefore is the valid extended weight. With known normalized densities, whenever the integral exists. Replacing an unknown normalization by a ratio of empirical weighted sums introduces finite-sample ratio bias, even though the large-sample limit is correct under integrability.
Finally, if an unbiased log-density approximation adds , Gaussian integration gives . Exponentiation therefore changes its expectation. A noisy log estimate cannot be treated as an exact endpoint or path density merely because its noise has zero mean.
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), §4.3 and Appendix D.1–D.2, Eqs. (35)–(40).
- Wu, Hao, Jonas Köhler and Frank Noé. “Stochastic Normalizing Flows.” arXiv:2002.06707v3, HTML (2020), §2, Eqs. (8)–(16), especially the endpoint marginal, path ratio and Theorem 1; §3 for stochastic transition implementations.
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.