Abstract
Machine learning interatomic potentials (MLIPs) enable more efficient molecular dynamics (MD) simulations with ab initio accuracy. However, distribution shift between training and test data causes deterioration of test performance and can lead to the collapse of MD simulations. We propose an online Test-time Adaptation Interatomic Potential (TAIP) framework to improve generalization. By designing a dual-level self-supervised learning approach that leverages global structure and atomic local environment information, TAIP aligns the model with test data on the fly. Extensive experiments demonstrate TAIP’s capability to bridge the domain gap without additional data, enhancing performance across various benchmarks and enabling stable MD simulations where baseline models fail.
Introduction
Machine Learning Interatomic Potentials (MLIPs) represent a significant advancement in computational chemistry, promising the speed of classical force fields with the accuracy of quantum mechanical ab initio methods. Despite their potential, MLIPs often struggle with distribution shift. During a Molecular Dynamics (MD) simulation, atoms may explore configurations significantly different from those in the training set. When a model encounters such out-of-distribution (OOD) data, its predictions become unreliable, often resulting in "simulation collapse"—a state where atoms behave unphysically, flying apart or clumping together.
Traditionally, addressing this required active learning cycles: halting the simulation, labeling new data via expensive quantum calculations, and retraining. The TAIP framework introduces a more efficient alternative: adapting the model to new data during the test phase without human intervention or new labels.
The TAIP Framework
The core of the TAIP framework is an online adaptation process that occurs during inference. Unlike standard models that remain static after training, TAIP updates its internal representations based on the specific geometry of the test sample it is currently processing.
Dual-Level Self-Supervised Learning
To enable this adaptation, the model is trained on three auxiliary self-supervised learning (SSL) tasks that do not require external labels. These tasks force the model to learn the underlying structural distribution of the molecular systems:
- Noise Intensity Prediction (Global): The model predicts the intensity of noise added to a molecular structure, requiring the encoder to understand global structural patterns.
- Atom Feature Recovery (Local): Similar to masked language modeling, specific atom types are masked, and the model must infer them based on their local chemical environment.
- Pseudo Force Recovery (Local): The model reconstructs masked "pseudo forces"—gradients of a pseudo-energy—by analyzing the surrounding atomic neighborhood.
Test-Time Adaptation Mechanism
During the inference stage, when a new atomic structure is encountered, the model performs a single gradient descent step. It updates its encoder parameters using the SSL tasks before outputting final energy and force values. This "fine-tuning" step aligns the model's internal embeddings with the test data, effectively bridging the domain gap. Visualization via t-SNE confirms that this process moves test data embeddings closer to the training distribution.
Experimental Results
TAIP was evaluated on several benchmarks, ranging from small molecules to complex periodic systems:
- MD17 & ISO17: TAIP reduced energy and force prediction errors by an average of 30% on MD17. On the ISO17 dataset, which tests generalization to unknown isomers, TAIP achieved a 31-40% error reduction.
- Phase Changes and Electrolytes: In simulations of liquid water to ice and high-concentration electrolyte solutions, TAIP demonstrated superior stability. While baseline models like SchNet and PaiNN often collapsed within 1 picosecond, TAIP-enabled models remained stable for over 500 picoseconds.
Conclusion
TAIP offers a robust solution to the distribution shift problem in MLIPs. By leveraging the inherent geometric information of test data through self-supervised learning, it significantly improves prediction accuracy and simulation stability. While the per-step gradient update introduces some computational overhead, the gain in reliability—particularly in preventing catastrophic simulation failure—makes it a valuable tool for complex molecular modeling. Future work will focus on optimizing the adaptation strategy and scaling the framework to even larger biomolecular systems.
Summary updated