Smooth Normalizing Flows

Abstract:
Normalizing flows are a promising tool for modeling probability distributions in physical systems. While state-of-the-art flows accurately approximate distributions and energies, applications in physics additionally require smooth energies to compute forces and higher-order derivatives. Furthermore, such densities are often defined on non-trivial topologies. A recent example are Boltzmann Generators for generating 3D-structures of peptides and small proteins. These generative models leverage the space of internal coordinates (dihedrals, angles, and bonds), which is a product of hypertori and compact intervals. In this work, we introduce a class of smooth mixture transformations working on both compact intervals and hypertori. Mixture transformations employ root-finding methods to invert them in practice, which has so far prevented bi-directional flow training. To this end, we show that parameter gradients and forces of such inverses can be computed from forward evaluations via the inverse function theorem. We demonstrate two advantages of such smooth flows: they allow training by force matching to simulation data and can be used as potentials in molecular dynamics simulations.

heading: 1 Introduction
text: Generative learning using normalizing flows (NF) [50, 42, 39] has become a widely applicable tool in the physical sciences which has e.g. been used for sampling lattice models [36, 37, 31, 4, 1], approximating the equilibrium density of molecular systems [38, 29, 56, 58] or estimating free energy differences [55, 10].
Such models approximate a target density µ via diffeomorphic maps f(·;θ) : Ω ⊂ Rd → Ω by transforming samples z ∼ p0(z) of a base density into samples x = f(z;θ) such that they follow the push-forward density
x ∼ pf (x;θ) := p0 ( f−1(x;θ) ) ∣∣det ∂xf−1(x;θ)∣∣ . (1) Flows can be trained on data by maximizing the likelihood or via minimizing of the reverse KL divergence DKL [pf (·;θ)‖µ] if µ is known up to a normalizing constant. While NFs are usually introduced as smooth diffeomorphisms, most applications like density estimation or sampling only require C1-smooth transformations. Higher-order smoothness of flows has not been discussed so far and can become a challenge as soon as multi-modal transformations on other topologies than Rd are discussed.
∗J.K and A.K. contributed equally to this work.
35th Conference on Neural Information Processing Systems (NeurIPS 2021).
Ck-smoothness of NFs with k > 1 is especially important for applications in physics. Physical models usually come in the form of differential equations, where the derivatives bear a physical meaning that is often crucial to fit, evaluate, or interpret the model. Thus, the construction of expressive, smooth flow architectures will likely open up new avenues of research in this domain.
Boltzmann Generators A recent application of NFs to a physical problem are Boltzmann Generators (BG) [38], which we see as the main application area for the methods introduced in this paper. They are generative models trained to sample conformations of molecules in equilibrium, which follow a Boltzmann-type distribution µ(x) ∝ exp(−u(x)). Here u is the dimensionless potential energy defined by the molecular system and the thermodynamic state (e.g. Canonical ensemble at a certain temperature) it is simulated in. BGs can be trained by a combination of MLE on possibly biased trajectory data and simultaneous minimization of the reverse KL divergence to the target density µ(x). This bi-directional training scheme can achieve sampling of low-energy equilibrium structures. After training, BGs can be used e.g. for importance sampling or for providing efficient proposals when being used in MCMC applications [45].
In the context of BGs, the negative gradient of the log push-forward density with respect to x corresponds to the atomistic forces. Access to well-behaved forces is pivotal in most classical molecular computations: they simplify optimization of molecular models, drive molecular dynamics (MD) simulations, enable computations of macroscopic observables, and facilitate multiscale modeling.
In this work, we will primarily focus on two important implications of smooth flow forces. First, we show that they enable the training of NFs via force matching (FM), i.e. minimizing the force mean-squared error with respect to reference data. In combining FM with density estimation, NFs are pushed to match the distributions and their derivatives, which implicitly leads to favorable regularization. Second, we apply flow forces to drive dynamics simulations. Such simulations are required in many applications to not only sample the target distribution but also compute dynamical observables such as transition rates or diffusivities.
Respecting Topological Constraints Many physical models operate on nontrivial topologies, i.e. the d-dimensional hyper-torus Td, which can become an obstacle in constructing smooth flows. An important example are BGs for peptides and small proteins which require an internal coordinate (IC) transformation to achieve low-energy sampling of structures [38]. This non-trainable layer transforms Euclidean coordinates x ∈ Rn×3 into a representation given by distances d ∈ [a1, b1]× . . . × [an−1, bn−1], angles α ∈ [0, π]n−2 and dihedral torsion angles τ ∈ Tn−3. As molecular energies are often invariant to translation and rotation, IC transformations are useful as they are bijective with the equivalence class of all-atom coordinates that are identical up to global rotations and translations. The learning problem can then be reduced to modeling the joint distribution µ(d,α, τ ) which is supported on the nontrivial topological space XIC := I2n−3 × Tn−3, where I = [0, 1] denotes the closed unit interval.
Recent work [38, 56] suggested to model the density within an open set Ω ⊂ XIC, leverage C∞smooth normalizing flows defined on Rd and then prevent significant mass around singular points using regularizing losses. Such an approach however can lead to bias and ill-behaved training and requires a-priori knowledge of the support of the densities. Later work [9] approached the problem using C1-smooth splines flows which leads to accurate samples, however results in broken forces.
To overcome these limitations while still benefiting from the merits of prior work, such as bidirectional training and fast forward/inverse transformations we formulate the following desiderata for flow transformations on-top of IC layers: (A) They must have support on Id and Td. (B) They should beC∞-smooth. (C) They must allow bi-directional training. (D) Forward and inverse direction must be efficient to evaluate.
Satisfying (D) can be achieved using coupling layers [11, 12]. This reduces the problem to finding element-wise conditional transformations satisfying (A-C).
Contributions In this work we propose the following novelties:
• We present a new C∞-smooth transformation with compact support which can simultaneously be used for expressive transformations on Id as well as the hypertorus Td. This satisfies (A) and (B).
• We present novel algorithm which allows optimizing non-analytic inverse directions of flows that can only be evaluated via black-box root finding methods. This satisfies (C).
• We show that training of smooth flows through combinations of force matching, density estimation, and energy-based training can achieve nearly perfect equilibrium densities.
• We show that forces of such smooth flows can be used in dynamical simulations.

heading: 2 Related Work
text: While related work exist for each of the requirements (A-D) above, none of them provides a framework that addresses all of them. Specifically, multi-modality in element-wise flow transformations has been approached using splines [13, 35], monotonoic polynomials [26, 41], monotonic neural networks which directly approximate an inverse CDF transformation [22, 8], mixtures of unimodal transformations [21, 43] and stochastic transition steps [56, 7].
Flows on non-trivial manifolds have been discussed for hypertori and -spheres [43], Lie groups [16, 4], hyperbolic spaces [3] as well as on general manifolds [15, 18, 33, 32, 5, 27]. Applications of flows for molecular systems include approximation of the equilibrium density [38, 56, 29], generation of molecular conformations [58, 44] and free energy differences [55, 10]. Using forces to train neural network potentials of molecules was done e.g. in [53, 24].
Backpropagation through black-box functions was generally discussed in [19]. More related to our work is Bai et al. [2] who discuss training models whose outputs are obtained through fix-point equations. Finally Shirobokov et al. [46] discuss backpropagation through black-box simulators using surrogate models.
Using force-matching for training generative models is rarely used in machine learning due to absence of an (unnormalized) target density. However, a common method to train unnormalized energy-based models purely on data is given by score-matching (SM) [25, 47]. SM assumes an unknown density for the data distribution and attempts to match forces implicitly, e.g. via sliced [49] or denoising [52] score-matching. A survey on score-matching and its relation to other approaches of training energy-based models on data is e.g. given in Song and Kingma [48].
We discuss related work on flows for I and the unit circle in detail in Section 4.

heading: 3 Incorporating Forces into Flow Training
text: NFs are most commonly trained by minimizing the negative log likelihood (NLL), LNLL(θ) := −Ex∼µ(x)[log pf (x;θ)] = DKL[µ||pf (·;θ)] + const, (2)
or by minimizing the reverse KL divergence (KLD) LKLD(θ) := DKL[pf (·;θ)||µ] + const. (3)
BGs as discussed in Noé et al. [38] use a convex combination of the two in order to avoid modecollapse while still being able to achieve low-energy samples. If reference forces f(x) = −∂xu(x) corresponding to samples x are available and f(·;θ) is at least C2-smooth, the optimization can naturally be augmented by the force mean-squared error:
LFM(θ) := Ex∼µ(x) [ ‖f(x)− ∂x log pf (x;θ)‖22 ] . (4)
As was shown in Wang et al. [53] such force-matching can lead to unbiased potential surfaces even if samples are not sampled from equilibrium. Similarly to Noé et al. [38] we can thus define a loss function for smooth flows as the convex combination
L(θ) = ωnLNLL(θ) + ωkLKLD(θ) + ωfLFM(θ). (5)

heading: 4 Smooth flows on the closed interval and the unit circle
text: We now discuss how to achieve smooth flows on Id and Td. To unify the discussion we consider the unit circle S1 to be the quotient space I/ ∼ using the relation x ∼ x′ ⇔ (x = x′) ∨ (x = 0 ∧ x′ = 1) ∨ (x′ = 0 ∧ x = 1). The d-dimensional hypertorus is given by the direct product Td = S1× . . .×S1. Following the usual definition we say that f is Ck-smooth on a compact interval [a, b] iff there exists a Ck-smooth continuation of f on an open set Ω ⊃ [a, b].
Smooth flows on I Any smooth diffeomorphism on R or an open interval (a, b) ⊃ I can be restricted to I and re-scaled to satisfy this requirement. Let f : Ω→ Ω be Ck-smooth for some open set I ⊂ Ω ⊂ R. Then f̃(x) = (f(x)− f(0))/(f(1)− f(0)) defines a Ck-smooth diffeomorphism on I. Simple C∞ transformations on R are given by affine transformations [12]. After re-scaling any affine map will result in the same identity mapping and thus will not be able to model complex densities. Powerful and computationally efficient multi-modal transformations on I can be achieved using rational-quadratic splines [13]. Those are C1-smooth and thus will result in discontinuous forces which can be disadvantageous for physical applications. Possible other C∞-smooth candidate transformations with analytic forward evaluation are given by mixtures of logistic transformations [21] or deep sigmoid/deep dense sigmoid flows [22]. Those are only continuous on (0, 1) and thus special care has to be taken to avoid problematic behavior on the tails. Finally, multi-modal C∞ transformations on R can be achieved using non-analytic methods [6, 54]. Yet, computational costs (solving and backpropagating over ODEs, inverting quadrature integrations via bisections) and numerical accuracy (non-anlytic forward passes) limit their applicability e.g. when used in deep coupling layers which are required to capture multivariate correlations or when trying to match densities up to high accuracy e.g. as necessary for molecular modeling.
Smooth flows on S1 Flows on the hypertorus were discussed in Rezende et al. [43] who introduced necessary conditions for the transformations to define C0-continuous densities, such that they can be used in density estimation tasks. In their work Rezende et al. [43] introduced three candidates satisfying this condition: mixtures of non-compact projections (NCP), rational-quadratic circular spline flows (CSF) and mixtures of Moebius transformations (MoMT). While NCPs and CSFs satisfy C1-continuity and thus render forces discontinuous, only MoMTs define smooth densities. While MoMTs trivially also define C∞-flows on I their periodicity would be limiting when applied to non-periodic densities.
Smooth compact bump functions In addition to this previous work we leverage a third way to construct smooth transformations which works for both I and S1. Here we follow a general construction principle for smooth bump functions e.g. as explained in Tu [51]. All proofs can be found in the supplementary material.
First, define a Ck-smooth and strictly increasing ramp function ρ : I→ I with ρ(0) = 0 and ρ(1) = 1. Second, define the generalized sigmoid
σ[ρ](x) := ρ(x)
ρ(x) + ρ(1− x) . (6)
Then σ[ρ] will be a Ck-diffeomorphsim on I and furthermore all derivatives up to order k vanish at the boundary. The first derivative defines a non-negative smooth bump function with support [0, 1] and maximum at 0.5. We can introduce a concentration parameter a ∈ R>0 and a location parameter b ∈ [0, 1], which makes g(x) := σ[ρ] ( a · (x− b) + 12 ) a smooth bijection from [− 12a + b, 1 2a + b] to [0, 1] with all values and higher-order derivatives vanishing outside the domain. Furthermore, by introducing c ∈ (0, 1] and setting
f(x) := (1− c) · ( g(x)− g(0) g(1)− g(0) ) + c · x, (7)
we can define flexible unimodal Ck-diffeomorphisms on [0, 1]. When used within coupling layers, we let a, b, c be the output of some not further constrained neural network.
Ck and C∞ ramp functions There are many possible choices for ramp functions satisfying above mentioned properties. A simple Ck ramp function is given by the k-th order monomial ρ(x) = xk. More interestingly, C∞ smoothness on [0, 1] can be achieved using the ramp ρ(x) = exp ( − 1 α·xβ ) for x > 0 and ρ(x) = 0 for x ≤ 0. Here we set α > 0 and β > 1. We make α a trainable parameter. Optimizing β is possible in principle, yet fixing β ∈ {1, 2} and treating it as a hyper-parameter stabilized training and led to better results.
Smooth and efficient circular wrapping As discussed in Rezende et al. [43] and Falorsi et al. [16] we can turn any Ck-smooth density p(x) with support on R into a Ck-smooth density on S1 using the marginalization p̃(x) = ∑ k∈Z p(x+ k). This construction is generally problematic due to two
reasons: (i) non-vanishing tails (e.g. if p(x) is Gaussian) require evaluating an infinite series which in most cases has no analytic expression and can be numerically challenging (ii) smooth densities with compact support in some interval [a, b], for example sigmoidal transforms, can introduce non-smooth behavior at the interval boundaries.
Smooth and compactly supported transformations as introduced above do not suffer from this: (i) due to compact support the series will always have a finite number of non-vanishing contributions, (ii) as the transformations are Ck on all of R and all derivatives are compactly supported wrapping will always result in a Ck-smooth density on S1.
Multi-modality via mixtures Similarly, as discussed in prior work [21, 43] any convex sum of Ck-diffeomorphisms on I defines a Ck-diffeomorphism on I. Thus we can combine multiple of those unimodal transformations defined in Eq. (7) to obtain arbitrarily complex multi-modal transformations on I and S1, see Fig. 1.

heading: 5 Optimizing non-analytic inverse flows
text: A drawback of mixture-based flows is their lack of an analytic inverse. Prior work such as [21, 43] suggested to rely on black-box inversion methods like a bisection search to sample from trained models. While this leads to accurate samples, the discrete nature of such black-box oracles does not allow to minimize L(θ) as defined in Eq. (5). A possible remedy to this can be derived using the inverse function theorem. Let f(·;θ) : Ω ⊂ R→ Ω be a scalar diffeomorphism and let furthermore x = f−1(y;θ) be obtained via a black-box inversion algorithm. To minimize losses depending on x(y;θ) or log |∂yx(y;θ)| we need to compute gradients with respect to y and θ. Here we derive the following relations for the derivatives (all details in supplementary material):
∂yx(y;θ) = (∂xf(x;θ)) −1 (8)
∂θx(y;θ) = − (∂xf(x;θ))−1 ∂θf(x;θ) (9) ∂y log |∂yx(y;θ)| = − (∂xf(x;θ))−1 log |∂xf(x;θ)| (10) ∂θ log |∂yx(y;θ)| = − (∂xf(x;θ))−1 (log |∂xf(x;θ)| ∂θf(x;θ)− ∂θ∂xf(x;θ)) (11)
We remark that (8) corresponds to the implicit reparameterization gradient as introduced in Figurnov et al. [17]. Using these rules, we can first compute x via a black-box oracle for any input y and then compute all necessary gradients using forward evaluations and derivatives of f(·;θ). Derivatives of f(·;θ) are usually accessible for computing the log Jacobian of the transformation. We can obtain higher-order derivatives using automatic differentiation. It is easy to see that this construction extends to multivariate diffeomorphisms with diagonal Jacobian as used in coupling layers. It can be generalized to arbitrary higher order derivatives using the Faà di Bruno formula, e.g. when aiming
to do force matching through a black-box inversion algorithm. As our experiments only require losses involving second order derivatives for the inverse direction we leave this for future work. Note that Equations (8) - (11) can be applied to any other element-wise flow transformation that lacks an analytic inverse and is not tied to mixture models.
Another problem of bisection is its sequential execution which can become prohibitively slow during training. E.g. achieving an error of 10−6 requires around 20 iterations. To obtain speedup on GPUs we suggest to generalize the classic binary search to searching in a grid of K bins simultaneoulsy (see details in Supp. Mat.). For K = 2 it results in the usual bisection method. However, by leveraging vectorized execution we can reduce the number of iterations by a factor O (1/ logK) at the expense of increasing memory by a factor O (K). Practical speedup depends on the actual number of parallel workers and thus depending on dimensionality, batch size and number of mixture components the optimal choice of K varies.

heading: 6 Experiments
text: The numerical experiments in this work are tailored to show the benefits of smooth flows over non-smooth flows. Therefore, we mainly compare mixtures of bump functions to neural spline flows [13], which exhibit state-of-the-art generative performance but whose densities are only first-order continuously differentiable.
6.1 Illustrative Toy Example
To highlight the difference in terms of smoothness, the two flow architectures were applied to a two-dimensional toy example. Fig. 2 a) depicts the reference energy and forces on samples from the ground-truth distribution. Both flows were trained through density estimations on those samples (see SI for details). The smooth flows and spline flows matched the density well, which demonstrates their expressivity. However, the force field of the spline flow contained dramatic outliers, while the forces of the smooth flow matched the regular behavior of the reference forces.

heading: 6.2 Runtime Comparison
text: While the rational-quadratic splines are analytically invertible, mixture transformations obviously increase computational cost of the inversion due to the iterative root-finding procedure. To quantify this gap in performance, the inverse evaluation of a spline flow was compared with a modified version, where the analytic inverse was replaced by the multi-bin bisection from Section 5. The performance of the bisection was evaluated for different numbers of bins K = 2m, m = 1, . . . , 8, and the most efficient K was picked for each input size (“dim”). Both transformations were coupled to a conditioner with the same input size (dim) and 64 hidden neurons.
For small tensor dimensions (2-32), the optimal multi-bin bisection employed up to 256 bins on the GPU, which resulted in only a factor of 2-3 slowdown compared to analytic inversion. For larger dimensions (2048), the parallelization over multiple bins became less effective, leading to one order of magnitude difference in computational cost. The compute times and optimal bin sizes were comparable for the inverse network pass and its backward-pass. More details on these runtime comparisons can be found in the supplementary material.

heading: 6.3 Smooth Flows Enable Boltzmann Generator Training through Force Matching
text: To demonstrate the advantages of smooth flows, we train a Boltzmann generator (BG) for a small molecule, alanine dipeptide, which is described in the supplementary material. This is a common test case for molecular computations and was previously considered for sampling with normalizing flows in [56, 9, 30]. The molecular system has 60 degrees of freedom (global rotation and translation excluded). Its potential energy surface is highly sensitive to small displacements [30] and contains singularities.
In previous work [56, 9, 30], BGs for alanine dipeptide used stochastic augmentation of the base space. The introduction of noise variables facilitates creating expressive normalizing flows but prevents computation of deterministic forces. Some have also used spline flows to sample molecular configurations [55, 10].
As a proof-of-concept for the force matching loss, we trained smooth flows for alanine dipeptide using a 1000:1 weighting between the force matching residual and the negative log likelihood, see supplementary material for details on the flow and training setup. No stochastic augmentation or energy-based training was used and no reweighting was conducted for postprocessing.
Figure 3 c) compares the flow distribution with the target Boltzmann distribution on the test data from MD and on flow samples. The left column shows that the flow has almost perfectly learned the nontrivial joint distribution between the two backbone torsion angles φ and ψ, including the sparsely populated metastable region around φ ≈ 1. In contrast to previous work that used affine coupling layers [56], the modes are cleanly separated, see also Fig. SI-3 for a direct comparison. The center column compares flows forces with target forces. Those forces are highly sensitive to small
perturbations of the molecular configurations. Nevertheless, they matched up to a root-mean square deviation of 25 and 46 kBT /nm in the target ensemble and the generated ensemble, respectively. Note that the training was stopped after 10 epochs, where the validation force matching residual had not yet fully converged, so that even further improvements may be possible with longer training or extensive hyperparameter optimization. A more detailed analysis of the forces and sampling efficiency of the BGs is shown in supplementary material, Figure SI-4. Smooth flows trained by a combination of density estimation and FM attain a favorable sampling efficiency of 42%, compared to 25% and < 1% for spline and RealNVP flows, respectively.
Finally, the right column of Figure 3 c) depicts the distribution of flow and target energies evaluated on the same samples. The flow energies were shifted so that the minimum energy matched with the molecular mechanics energy. It has not escaped our notice that this constant offset (189 kBT on the test set and 190 kBT on the flow samples) corresponds to the log partition function, a quantity whose intractability has complicated research in statistical mechanics for decades.
The energy distribution of the flow tracked the ground truth exponential distribution almost perfectly even though no target energies or forces were evaluated on the flow samples during training. This close-to-perfect match demonstrates that including force information into the training process presents an efficient means for regularization. Figure 3 a) shows representative conformations generated by the BG, which confirm the high quality of the molecular structures.

heading: 6.4 Boltzmann Generator Training through Black-Box Root-Finding
text: Two experiments were conducted to demonstrate that flows can be trained through a black-box root-finding algorithm.
First, the BG from section 6.3 was trained with all smooth transformations operating in the inverse direction. Consequently, inverse problems had to be solved when computing the negative log likelihood with respect to data, while the sampling occurred analytically. Figure 3 b) shows the joint marginal distribution of the backbone torsions on the BG samples. The distribution matches the data and the smooth flows that were trained in forward mode (see Fig. 3). This result shows that training with gradients computed from the inverse function theorem is feasible.
Second, flows were trained by different combinations of density estimation, force matching, and energy-based training, where computing ∂θLKLD requires the gradients of the inverse flow. The training of spline flows with inclusion of the force matching error (ωf > 0) was notoriously unstable. This led to 10/10 and 7/10 failed runs for ωk = 0 and ωk = 0.1, respectively. This is understandable
from the discontinuity of the spline forces. Even the combination of NLL and KLD led to instabilities for 2/10 runs. (Gradients were not clipped during training to enable a mostly unbiased comparison). In contrast, all training runs with our smooth flows concluded successfully.
Table 1 shows the metrics on the test set after 10 training epochs using spline flows and smooth flows (see SI for specifics about the flow architecture and training). With pure density estimation (ωk = ωf = 0), both architectures achieved similar NLL. However, the smooth flow achieved much lower FME and KLD. The NLL and FME were further improved when force data was presented to the flow during training. Including reverse KLD in the loss yielded reasonable metrics for the smooth flows, indicating that the backpropagation through root-finding was numerically stable. However, the metrics were consistently worse than with pure NLL training for both types of flows (spline and smooth) and were subject to large fluctuations. In contrast, including the FME proved to be a more stable approach to include information about the target energy into the training.

heading: 6.5 Smooth Flows as Potentials in Molecular Dynamics
text: A challenging test for the smoothness of a flow is its use as a potential energy in a dynamics simulation. Especially simulations in the microcanonical ensemble are extremely sensitive to numerical errors as the symplectic integration does not impose any additional stabilizing mechanism on the total energy. This means that any inconsistencies between energies and forces on the scale of one integration step easily cause drifting, strongly fluctuating, or exploding energies.
Therefore, we ran MD simulations using the flow energy uθ = − log pf (·;θ), from Section 6.3 as the potential. For comparison, simulations were also run with spline flows that were trained purely by density estimation. Simulations started from stable structures of an MD simulation and were equilibrated in each potential for 1 ps using a Langevin thermostat with 10/ps friction coefficient.
Figure 4 depicts the evolution of the total energy over 5 ps simulations in the microcanonical ensemble. As expected, the classical simulation kept the total energy roughly constant within a standard deviation of 6× 10−4 kJ/mol per degree of freedom. Astoundingly, the smooth flow potentials also maintained the energies within 8× 10−4 kJ/mol per degree of freedom using the same 1 fs time step. In contrast, the simulations with spline flow potentials quickly fell apart with potential and kinetic energies growing out of bounds. Those instabilities persisted even with an order-of-magnitude smaller time step (not shown).
While the infeasibility of spline flows for this task was expected, the competitive behavior of smooth flows with molecular mechanics force fields that were tailored for dynamics highlights their regularity and the consistency of their forces.

heading: 7 Discussion
text: Limitations and outlook Despite the promising results we mention the following possible limitations of the method in the present state and discuss possible improvements for future work:
First, smooth flows as implemented in this work impose numerical overhead in comparison to non-smooth alternatives such as spline flows. While this can be considered a question of concrete engineering it also opens search for more efficient smooth alternatives.
In addition, the differentiation rules for black-box inverses provide correct algebraic gradients. Yet for considerably multi-modal distributions maintaining numerical stability can become a challenge. Future work should thus focus on studying and improving numerical stability of the bidirectional training.
While potentials can be trained up to an accuracy where they allow for energy-conserving simulations, it is yet to show that they also provide accurate equilibrium distribution for long-run simulations. At this point a major bottleneck is the inferior evaluation performance per step of a flow-based force-field compared to common force-field implementations.
Furthermore, internal coordinates are a very efficient representation space for smaller poly-peptides. However, they are difficult to scale to large proteins, protein complexes or systems with non-trivial topologies, e.g. proteins with disulfide bonds. Integrating recent advances in graph-based molecular representations with force-matched flows will likely be required for a succesful modeling of such systems.
Finally, training with forces improves the resulting potential compared to just training with samples. However, for many MD data forces have not been stored and recomputing them requires a significant computational overhead.
Conclusion We introduced a range of contributions which can improve upcoming work on applying flows to physical problems.
The proposed approach for backpropagation through black-box root-finders can help to obviate the search for analytically invertible transformations if bi-directional training is necessary. As we show the method works especially well for relatively low-dimensional problems. Scaling the approach, generalizing it to non-diagonal Jacobians and improving its numerics are interesting questions for future work.
The MD simulation example shows that C∞-smooth flows on non-trivial topologies can open new avenues of research as well as new applications for flows. By carefully respecting the topological domain as well as the smoothness of the target potential we can approximate the equilibrium density of a small peptide nearly perfectly. Finally, we showed that incorporating force information together with MLE outperforms the state-of-the-art approach of combining MLE with minimizing of the reverse KL divergence. It does not suffer from mode-collapse, yet includes information of the target potential which is required to achieve low-energy samples.
Combined, these results could improve methods used for learning the mean potential surface of coarse-grained molecules, pave the way to multi-scale flows for modeling large protein systems and eventually help to accelerate simulations and sampling.

heading: Acknowledgements
text: We thank the anonymous reviewers at NeurIPS 2021 for their insightful comments. Special thanks to Yaoyi Chen for setting up the alanine dipeptide system and Manuel Dibak, Leon Klein, Oana-Iuliana Popescu, Leon Sixt, and Michael Figurnov for helpful discussions and feedback on the manuscript and pointers to related work. We acknowledge funding from the European Commission (ERC CoG 772230 ScaleCell), Deutsche Forschungsgemeinschaft (GRK DAEDALUS, SFB1114/A04), the German Ministry for Education and Research (Berlin Institute for the Foundations of Learning and Data BIFOLD), and the Berlin Mathematics center MATH+ (Project AA1-6 and EF1-2).

Review summaries:
This paper is proposing smooth normalizing flows for modeling probability distribution in physical systems.  This is because the existing flow-based model approximates distributions and energies by computing forces and higher-order derivatives based on smoothed energies. This work aims at addressing this challenge by introducing a class of smooth mixture transformations working on both compact intervals and hypertori.  The proposed methods show advantages on two points: 1) enable training by force matching to simulation data and 2) used as potentials in MD simulations.  

The paper considers a set of problems that come up when fitting normalizing flows to datasets of interest in physical sciences, and proposes a set of solutions to those problems.  To begin with, when it comes to datasets in physical sciences we might be interested in matching the *gradient* of the log density of the target distribution, as well as the log density itself. This is because this gradient can correspond to the *forces* acting on the physical objects, and as such the gradient is important to get right, in order to make the model useful in downstream applications, e.g. simulation. Furthermore, we often have access to the *true* forces at the points in the training sample, and would like to regularize the model to make its gradients match the available true gradients. Authors consider a straightforward way to implement such regularization: adding the MSE between the model's gradient and the true gradient to the training objective. However, doing this requires a normalizing flow model that is at least $C^2$-smooth, as the second-order gradients will be used during optimization.  Moreover, the data of interest in this context often has non-trivial topology, containing quantities such as angles, directions or axis. There's been prior work on building normalizing flows suitable for such data, but authors point out that there is no existing model that would be a) restricted to a manifold of interest (say, a circle or a torus)  b) $C^{\infty}$ (or at least $C^k$ for some $k > 1$) continuous c) *expressive*, i.e. able to represent complex densities on the manifold  Authors propose a way to construct a normalizing flow that *would* have the properties above. More specifically, authors parametrize a $C^k$-continuous univariate diffeomorphism on $[0,1]$, which could then be turned to a diffeomorphism on a circle, torus etc. using methods by Rezende et al. [34], and/or used as the elementwise transformation in coupling/autoregressive layers.   Unfortunately, to make the transformation above expressive, authors have to consider a mixture of simpler transformations, hence the transformation has no analytic inverse. This is not an uncommon limitation when it comes to normalizing flows, where inverting some of the flows (e.g. for sampling) requires performing numerical root-finding. This presents a problem in the context of this work: in literature it has been demonstrated that it is desirable to train the flow on a convex combination of a forward and an *inverse* KL divergences. The latter is the one that presents a problem as it requires sampling from the flow *and* evaluating the gradients of its inverse during training. The cost of doing this can be prohibitive when the inverse is not analytic. Authors derive a way to compute said gradients by *only* using samples from the model and the gradients of the forward transformation, which are typically readily available.  Finally, authors evaluate the proposed solutions on a battery of benchmarks, both synthetic and real, showing that the final model demonstrates desirable behaviour when compared to a strong baseline. 

The paper introduces a class of $C^k$-smooth ($k>1$) transformations working on compact intervals and hypertori that can be used to construct normalising flows. Such type of smooth transformations are important in physical systems as (1) they respect topological constraints and (2) higher-order derivatives have physical interpretations; however, existing transformations either don't respect the constraints or are limited to have only $C^1$-smoothness. Learning flows consisting mixtures of proposed transformations that requires black-box root-finders is made efficient through gradients derived by the inverse function theorem. The benefit of accessing to higher-order derivatives is demonstrated by training normalizing flows with force-matching regularisation and dynamics simulations of trained flows.

The authors introduce a flow architecture, which they call smooth normalizing flows, that can operate on compact intervals and hypertori and has a C-infinity-smooth transformation. Furthermore, they propose to train normalizing flows via force matching, i.e. matching the gradients of the flow transformation which those of the energy function of the target distribution. They also show that a transformation with non-analytic inverse can be used to define a flow model which is trained by evaluating the inverse via black-box root finding and computing the gradients through the forward pass of each layer. On the experiment side, the authors apply their method to a toy example as well as the Boltzmann distribution of a complex molecule. They demonstrate that their flow architecture is expressive and the presented training procedure can be successfully used. When force matching is used, the gradients of the flow transformation resemble the respective gradients of the energy function of the target indeed more accurately and they can even be used as forces in molecular dynamics simulations.