Abstract
In molecular dynamics (MD), neural network (NN) potentials trained bottom-up on quantum mechanical data have seen tremendous success recently. Top-down approaches that learn NN potentials directly from experimental data have received less attention, typically facing numerical and computational challenges when backpropagating through MD simulations. We present the Differentiable Trajectory Reweighting (DiffTRe) method, which bypasses differentiation through the MD simulation for time-independent observables. Leveraging thermodynamic perturbation theory, we avoid exploding gradients and achieve around 2 orders of magnitude speed-up in gradient computation for top-down learning. We show effectiveness of DiffTRe in learning NN potentials for an atomistic model of diamond and a coarse-grained model of water based on diverse experimental observables including thermodynamic, structural and mechanical properties. Importantly, DiffTRe also generalizes bottom-up structural coarse-graining methods such as iterative Boltzmann inversion to arbitrary potentials. The presented method constitutes an important milestone towards enriching NN potentials with experimental data, particularly when accurate bottom-up data is unavailable.
Introduction
Molecular modeling relies on "potentials" to define particle interactions. Traditionally, these are developed using a bottom-up approach: training neural networks (NN) to replicate forces and energies from expensive quantum mechanical simulations like Density Functional Theory (DFT). However, these models are inherently limited by the accuracy of the underlying simulations, which often diverge from experimental reality.
An alternative is top-down learning, where potentials are optimized to match real-world experimental observables such as density or mechanical stiffness. The primary obstacle to top-down learning is the computational cost and numerical instability associated with backpropagating through thousands of molecular dynamics (MD) time steps. Standard automatic differentiation (AD) through an MD integrator often leads to "exploding gradients" and prohibitive memory requirements. To address this, we introduce Differentiable Trajectory Reweighting (DiffTRe), a method that bypasses the need to differentiate through the MD integrator for equilibrium properties.
Methodology
DiffTRe sidesteps the complexities of the MD integrator by leveraging thermodynamic perturbation theory. The core insight is that for time-independent (equilibrium) observables, the specific sequence of states in a trajectory is irrelevant; only their statistical distribution matters.
The workflow consists of several key components:
- Trajectory Reweighting: Instead of re-simulating for every parameter update, DiffTRe uses a reference trajectory generated by a previous potential. It calculates weights for each state in the trajectory using the Boltzmann distribution formula, determining how much each state contributes to the observable under the updated potential.
- Differentiable Path: By using these weights, the relationship between potential parameters and final observables becomes a direct, differentiable function, avoiding the chaotic dynamics of the integrator.
- Adaptive Sampling: The method monitors the "effective sample size" ($N_{\text{eff}}$). If the updated potential deviates significantly from the reference, a new trajectory is generated to maintain accuracy.
- Potential Architecture: The model combines a learnable NN (specifically DimeNet++) with a physical "prior" potential (e.g., a repulsive force). This prior ensures physical stability during the early stages of training.
Experiments and Results
The effectiveness of DiffTRe was validated across three distinct scenarios: a 1D double-well toy model, atomistic diamond, and coarse-grained water.
In the atomistic diamond case, a DimeNet++ model was trained using experimental elastic stiffness moduli ($C_{11}, C_{12}, C_{44}$). The model successfully converged to these values and demonstrated strong generalization by accurately predicting stress-strain curves that matched DFT data.
For coarse-grained (CG) water, where each molecule is represented by a single bead, the model was trained on experimental Radial Distribution Functions (RDF), Angular Distribution Functions (ADF), and pressure. Matching these diverse observables simultaneously is a significant challenge for traditional pair potentials, yet DiffTRe achieved high accuracy.
Key performance metrics include:
- Efficiency: Gradient computation is approximately 100x faster than direct reverse-mode AD.
- Memory: Significant reduction in memory overhead, as only subsampled states need to be stored.
- Robustness: The training process proved robust to different prior potentials and random weight initializations.
Discussion
DiffTRe represents a modern, high-dimensional generalization of classical techniques like Iterative Boltzmann Inversion (IBI). While IBI is typically restricted to simple pair potentials, DiffTRe enables the optimization of complex, many-body neural network potentials. By keeping gradient magnitudes constant regardless of simulation length, it effectively solves the gradient explosion problem that plagues direct AD through MD.
Limitations and Future Work
Currently, DiffTRe is limited to time-independent observables due to its reliance on equilibrium reweighting. It cannot yet be applied to dynamical properties like viscosity or diffusion coefficients. Additionally, while the method is robust, a well-chosen prior potential remains beneficial for guiding initial training. Future research will explore incorporating a broader range of experimental data types to further constrain potentials and applying the method to large-scale multi-component systems where quantum data is unavailable.
Summary updated