Fast, Modular, and Differentiable Framework for Machine Learning-Enhanced Molecular Simulations

Henrik Christiansen, Takashi Maruyama, Federico Errica, Viktor Zaverkin, Makoto Takamoto, Francesco Alesiani · DOI

Abstract

Molecular simulations serve as critical "computational microscopes" for studying biological and material systems at the atomic level. However, researchers often face a dichotomy between high-performance classical engines and flexible, machine learning (ML)-integrated frameworks. This paper introduces DIMOS (Differentiable Molecular Simulation framework), a PyTorch-native engine designed to bridge this gap. By implementing efficient neighborlists and cell lists, DIMOS achieves $O(N)$ scaling, enabling differentiable simulations of systems with hundreds of thousands of atoms. We demonstrate that DIMOS provides up to a 170x speedup over existing differentiable tools and enhances sampling efficiency by 3x through the end-to-end optimization of simulation parameters.

Introduction

Traditional molecular dynamics (MD) software, such as LAMMPS or OpenMM, is highly optimized but often rigid, making the integration of modern Machine Learning Interatomic Potentials (MLIPs) a complex engineering task. Conversely, existing differentiable frameworks—which allow for gradient calculation through entire simulation trajectories—frequently lack the algorithmic optimizations required for large-scale systems, often suffering from $O(N^2)$ complexity. Furthermore, many of these tools are built in Jax or Julia, creating a barrier for the extensive community of researchers already utilizing the PyTorch ecosystem.

DIMOS addresses these challenges by providing a high-performance, modular, and PyTorch-native engine. It allows researchers to treat simulations as differentiable functions, enabling the training of simulation parameters alongside neural network weights.

Methodology

DIMOS is designed from the ground up to prioritize modularity and scalability within the PyTorch framework. Key technical innovations include:

  • Linear Scaling ($O(N)$): Unlike previous differentiable tools that calculate interactions between all atom pairs, DIMOS implements Verlet neighborlists and cell lists. This allows the framework to scale linearly with system size, making it viable for large-scale biological simulations.
  • Advanced Electrostatics: The framework includes a custom PyTorch implementation of Particle-Mesh Ewald (PME), the standard method for calculating long-range electrostatic forces in periodic systems.
  • Hybrid ML/MM Support: DIMOS facilitates "mixed" simulations, where critical regions (such as an enzyme's active site) are modeled with high-accuracy ML potentials, while the surrounding environment is handled by efficient classical mechanics (MM).
  • Differentiable Hamiltonian Monte Carlo (HMC): By differentiating through the HMC integration, the framework can automatically optimize simulation parameters—such as atomic masses and timesteps—to maximize sampling efficiency.

Benchmarking and Results

The performance of DIMOS was evaluated across a variety of systems, including water boxes (up to 300,000 atoms) and protein systems such as Alanine-dipeptide, Trp-Cage, and Dihydrofolate reductase (DHFR).

Computational Speed

DIMOS demonstrates a significant performance advantage over existing differentiable frameworks. For large systems, it achieves up to a 170x speedup over TorchMD by avoiding the $O(N^2)$ complexity trap. When integrated with state-of-the-art ML potentials like MACE or ORB, DIMOS is approximately 1.6x faster than the Atomic Simulation Environment (ASE) and 5x faster than TorchSim.

Sampling Efficiency

A key advantage of differentiability is the ability to optimize the simulation itself. By using gradient descent to find optimal atomic masses and timesteps, the authors achieved a 3x acceleration in sampling efficiency. This process physically re-partitions mass to allow for larger timesteps without compromising numerical stability or accuracy.

Large-Scale Application

The framework successfully simulated the DHFR protein (23,558 atoms) using a hybrid ML/MM approach. This task represents a significant milestone, as pure ML models for systems of this size are currently computationally prohibitive on standard hardware.

Discussion

While DIMOS does not yet match the peak raw speed of production-grade classical engines like OpenMM (which remains roughly 40x faster), its value lies in its modularity and differentiability. For researchers developing new methodologies, the ability to swap a classical bond for an ML potential with a single line of Python code—while maintaining the ability to backpropagate through the entire system—is a transformative capability.

DIMOS moves differentiable molecular dynamics from the realm of small-molecule "toy" systems into the domain of realistic biological and material science applications. By proving that $O(N)$ scaling is achievable within a PyTorch-native differentiable framework, it opens new avenues for ML-enhanced molecular discovery.

Limitations and Future Work

Despite its advances, DIMOS currently lacks multi-GPU support, which is necessary for simulating massive systems such as entire viral capsids. Additionally, future updates aim to include support for more general simulation box geometries and the inclusion of virtual particles used in advanced force fields.

DIMOS is open-source and available to the research community at: https://github.com/nec-research/DIMOS.

Summary updated

BibTeX
@misc{christiansen2025fast,
  author = {Henrik Christiansen and Takashi Maruyama and Federico Errica and Viktor Zaverkin and Makoto Takamoto and Francesco Alesiani},
  title = {{Fast, Modular, and Differentiable Framework for Machine Learning-Enhanced Molecular Simulations}},
  year = {2025},
  eprint = {2503.20541},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2503.20541},
}
Figure