Online test-time adaptation for better generalization of interatomic potentials to out-of-distribution data

Taoyong Cui, Chenyu Tang, Dongzhan Zhou, Yuqiang Li, Xingao Gong, Wanli Ouyang, Mao Su, Shufei ZhangNature Communications 2025 · OpenReview

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.

Overview of the TAIP framework across training, test-time adaptation, and inference phases.

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:

  1. Noise Intensity Prediction (Global): The model predicts the intensity of noise added to a molecular structure, requiring the encoder to understand global structural patterns.
  2. 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.
  3. Pseudo Force Recovery (Local): The model reconstructs masked "pseudo forces"—gradients of a pseudo-energy—by analyzing the surrounding atomic neighborhood.
Detail of the local self-supervised learning tasks: Atom Feature Recovery and Pseudo Force Recovery.

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

Abstract

Machine learning interatomic potentials (MLIPs) enable more efficient molecular dynamics (MD) simulations with ab initio accuracy, which have been used in various domains of physical science. However, distribution shift between training and test data causes deterioration of the test performance of MLIPs, and even leads to collapse of MD simulations. In this work, we propose an online Test-time Adaptation Interatomic Potential (TAIP) framework to improve the generalization on test data. Specifically, we design a dual-level self-supervised learning approach that leverages global structure and atomic local environment information to align the model with the test data. Extensive experiments demonstrate TAIP’s capability to bridge the domain gap between training and test dataset without additional data. TAIP enhances the test performance on various benchmarks, from small molecule datasets to complex periodic molecular systems with various types of elements. TAIP also enables stable MD simulations where the corresponding baseline models collapse. Molecular dynamics simulations using machine learning interatomic potentials often face stability issues due to distribution shifts. Here, the authors develop an online test-time adaptation framework to improve generalization, allowing for more stable simulations without the need for additional training data.
BibTeX
@inproceedings{cui2025online,
  author = {Taoyong Cui and Chenyu Tang and Dongzhan Zhou and Yuqiang Li and Xingao Gong and Wanli Ouyang and Mao Su and Shufei Zhang},
  title = {{Online test-time adaptation for better generalization of interatomic potentials to out-of-distribution data}},
  booktitle = {Nature Communications},
  year = {2025},
  url = {https://openreview.net/forum?id=R0UiGzXnPl},
}
Figure