Reversible molecular simulation for training classical and machine learning force fields
Joe G Greener · 2024
Read Reversible molecular simulation for training classical and machine learning force fields by Joe G Greener (2024) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2412-04374.txt.
Introduction
Joe Greener improves a method for training molecular force fields by running simulations backward in time, in a paper published in two thousand twenty-four. Force fields are the rulebooks that tell molecular dynamics how atoms push and pull on each other, and the next generation will be fitted to rich experimental data.
Fitting works best when one can compute how each observable shifts as the rules change. A known approach gets those gradients by differentiating through a simulation, but memory costs grow with the run's length. Greener's version runs a reverse-time simulation alongside, keeping memory nearly flat at a cost close to one forward run. He applies it to all-atom water, to gas diffusion models, and to training a machine learning potential for diamond from scratch. Compared with a reweighting method, the gradients come out more accurate. The approach can also match how observables evolve over time.
Catalog record
| CREATOR | Joe G Greener |
|---|---|
| YEAR | 2024 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 60 KB |
| VERSION | 1.0 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2412-04374
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
Reversible molecular simulation for training classical and machine learning force fields Joe G Greener Abstract The next generation of force fields for molecular dynamics will be developed using a wealth of data. Training systematically with experimental data remains a challenge, however, especially for machine learning potentials. Differentiable molecular simulation calculates gradients of observables with respect to parameters through molecular dynamics trajectories. Here we improve this approach by explicitly calculating gradients using a reverse-time simulation with effectively constant memory cost and a computation count similar to the forward simulation. The method is applied to learn all-atom water and gas diffusion models with different functional forms, and to train a machine learning potential for diamond from scratch. Comparison to ensemble reweighting indicates that reversible simulation can provide more accurate gradients and train to match time-dependent observables. Introduction Molecular dynamics (MD) simulations have given us insight into how atoms move, from biomolecules to materials [ 1 ] . Key to the accuracy of a MD simulation is the accuracy of the force field used to describe how the atoms interact. For classical molecular mechanics, force field development has largely been manual with parameters tuned to give the best possible match to quantum mechanical (QM) data (bottom-up) and condensed phase properties (top-down) [ 2 , 3 ] . There have been automated approaches, including ensemble reweighting methods [ 4 , 5 , 6 , 7 , 8 ] like the popular ForceBalance [ 9 , 10 , 11 ] , and graph neural networks to avoid discrete atom typing [ 12 ] , but much work is still done manually [ 13 ] . The recently emerging and promising machine learning interatomic potentials (MLIPs) [ 14 , 15 ] are typically trained bottom-up on QM data alone [ 16 ] , though this can give a distorted view of the utility of these models [ 17 ] . Whilst MLIPs can be validated on other data [ 18 ] , using non-QM data during training has proved challenging. This puts a heavy emphasis on generating large and diverse QM datasets and neglects other available data. One approach to training force fields with experimental data is differentiable molecular simulation (DMS), in which automatic differentiation (AD) [ 19 ] is used to obtain the gradients of a loss value with respect to the parameters over a simulation. This has had a number of recent applications [ 20 , 21 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 ] with dedicated software available [ 32 , 33 , 34 , 35 , 26 ] . It is appealing due to the variety of possible loss functions and because the gradients are exact with respect to the forward simulation. There are, however, three main problems with DMS. Firstly, the memory required is linear in the number of simulation steps meaning that gradient checkpointing is required for longer simulations (reducing the memory scaling to logarithmic [ 36 ] ) and that larger neural networks may be incompatible. Secondly, performance is considerably slower than standard simulation due to the overhead of reverse mode AD (RAD). Finally, the gradients are prone to explosion due to the numerical integration. DMS holds promise despite this, particularly for training on time-dependent observables where ensemble reweighting approaches are not generally applicable [ 37 ] . Examples of these include diffusion coefficients, autocorrelation functions, relaxation rates, thermal conductivity and reaction rates, where available data is challenging to use during training. Here we take inspiration from reversible differential equation solvers [ 38 , 39 , 40 ] and reversible neural networks [ 41 , 42 , 43 ] and ask if DMS can be done without storing intermediate states, i.e. by explicitly deriving gradients rather than using conventional AD. This is motivated by three features of molecular simulations: they consist of the same step repeated many times, the algorithm does not contain branching, and they are reversible in certain situations. We find that identical gradients to DMS with RAD can be obtained with effectively constant memory cost and a computation count comparable to standard simulation, and explore gradient truncation as a way to avoid gradient explosion. This reversible simulation approach is demonstrated with three examples: learning molecular mechanics water models with different functional forms, training to match gas diffusion data, and learning a MLIP for diamond from scratch. Results Reversible molecular simulation A molecular simulation is run using a force field with parameters \sigma_{j} . We wish to improve \sigma_{j} to better match experimental data. Whilst it is possible to do this using gradient-free approaches, this scales poorly with parameter number and both molecular mechanics force fields and MLIPs can have thousands of parameters or more. Consequently, we wish to calculate \frac{\textrm{d}l}{\textrm{d}\sigma_{j}} where the loss function l represents the match of the simulation to experiment. Existing gradient-based approaches to parameterise force fields are summarised in Table 1 and Figure 1 A. Class Method Pros and cons Not gradient-based Manual adjustment [ 13 ] ✓ Use human expertise ✓ Use fast software ✗ Poor scaling in parameter number ✗ Takes human time Sampling approaches [ 44 ] ✓ Automated ✓ Use fast software ✗ Poor scaling in parameter number Numerical Finite differences ✓ Accurate gradients for smooth functions ✓ Use fast software ✗ Poor scaling in parameter number ✗ Needs tuning or can be inaccurate Ensemble-based Ensemble reweighting, e.g. ForceBalance [ 9 ] ✓ Applicable to a variety of properties ✓ Can be enhanced with AD ✗ Not applicable to time-dependent properties Differentiable trajectory reweighting (DiffTre) [ 6 ] ✓ More efficient version of ensemble reweighting ✗ Not applicable to time-dependent properties Trajectory-based Adjoint method [ 45 ] ✓ Memory efficient ✗ Solves separate adjoint equation ✗ Can be unstable Differentiable simulation [ 26 ] ✓ Accurate gradients ✗ Poor memory scaling with trajectory length Reversible simulation (this work) ✓ Memory-efficient ✗ Needs custom implementation Table 1: Approaches to parameterise force fields, with a focus on methods that calculate the gradient of the match to experiment with respect to the force field parameters \frac{\textrm{d}l}{\textrm{d}\sigma_{j}} . See also Figure 1 A. Figure 1: Reversible molecular simulation. (A) Different approaches to calculate gradients through molecular simulations. See also Table 1 . (B) The difference between gradients obtained over simulations of TIP3P water from reversible simulation and DMS with RAD, which is mathematically equivalent but shows discrepancies due to a different order of floating point operations. Fractional differences are shown for the Langevin middle integrator with \gamma=1 ps -1 and double precision floats (f64) used throughout the work, plus the leapfrog Verlet integrator and single precision floats (f32). (C) Correlation of the gradients from reversible simulation and ensemble reweighting for simulations with the same parameters. For C-E the Lennard-Jones \sigma gradient from 50 ps simulations of the water model is shown, with the simulation setup matching the water model training. To show a variety of loss and gradient values, 125 sets of parameters were run corresponding to \sigma in (0.301, 0.308, 0.315, 0.322, 0.329) nm, \varepsilon in (0.436, 0.536, 0.636, 0.736, 0.836) kJ/mol and O partial charge in (-0.934, -0.884, -0.834, -0.784, -0.734). (D) Testing how gradients change with