Online Test-time Adaptation for InteratomicPotentials

Shufei Zhang, Taoyong Cui, Chenyu Tang, D.c. Zhou, Yuqiang Li, Xingao Gong, Wanli Ouyang, Mao SuResearch Square 2024

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. Remarkably, it also enables stable MD simulations where the corresponding baseline models collapse.

Introduction

Molecular Dynamics (MD) simulations serve as critical "microscopes" for observing atomic-level phenomena in computational chemistry and materials science. While ab initio methods provide high accuracy, their computational cost is often prohibitive for large-scale or long-duration simulations. Machine Learning Interatomic Potentials (MLIPs) have emerged as a powerful alternative, offering near-quantum accuracy at a fraction of the cost.

Despite their success, MLIPs suffer from a significant "brittleness" known as distribution shift. When a simulation encounters atomic configurations outside the model's training distribution—such as during phase transitions or rare chemical events—prediction errors can spike. This often results in "simulation collapse," where unphysical force predictions cause atoms to disperse unrealistically, terminating the simulation. Traditional solutions like active learning require expensive re-labeling of data, which is not always feasible in real-time research.

Methodology: The TAIP Framework

To address these challenges, we introduce TAIP (Test-time Adaptation Interatomic Potential). Unlike static models, TAIP treats the inference phase as an opportunity for continuous learning. The framework employs a dual-level self-supervised learning (SSL) approach to align the model's encoder with the test data on-the-fly.

Overview of the TAIP framework showing the training, adaptation, and inference stages, alongside the four self-supervised learning blocks.

The core of TAIP consists of three primary auxiliary tasks that do not require ground-truth labels:

  1. Noise Intensity Prediction: The model estimates the level of noise added to a molecular structure, facilitating an understanding of the global geometry.
  2. Atom Feature Recovery: By masking specific atoms and requiring the model to predict their properties from neighbors, the model learns the local chemical environment.
  3. Pseudo Force Recovery: The model predicts gradients of a simplified energy for masked regions, enhancing its grasp of inter-atomic relationships.

During an MD simulation, for every new atomic frame, the model performs a single gradient update to its encoder parameters to minimize these SSL losses before generating the final force and energy predictions. This "online" adaptation ensures the model remains synchronized with the evolving system.

Experimental Results

The TAIP framework was evaluated across diverse benchmarks, including small organic molecules (MD17), isomers (ISO17), and complex periodic systems like liquid water, ice, and electrolyte solutions.

Performance comparison of TAIP-enhanced models (SchNet-TAIP, PaiNN-TAIP) against baselines across ISO17, Water, and Electrolyte datasets.

Accuracy and Generalization

As shown in the experimental results, TAIP consistently outperforms baseline models like SchNet and PaiNN. On average, TAIP reduces energy and force prediction errors by approximately 30%. In challenging scenarios like the ISO17 dataset (unknown molecules/conformations) and electrolyte solutions, the error reduction is particularly pronounced, demonstrating the framework's ability to bridge significant domain gaps.

Simulation Stability

The most critical metric for MD is stability. In simulations of ice and high-concentration electrolytes, baseline models frequently collapsed within 1 picosecond. In contrast, models equipped with TAIP maintained stability for over 500 picoseconds. This leap in reliability is attributed to the model's ability to adapt to "out-of-distribution" frames before they can trigger unphysical force calculations.

Discussion and Conclusion

TAIP presents a paradigm shift in how MLIPs are deployed, moving from static inference to dynamic adaptation. By leveraging self-supervision, the framework provides a robust defense against distribution shift without the need for additional labeled data.

While the computational overhead of a gradient update per step is modest, future optimizations could involve triggering adaptation only when a shift is detected. Additionally, exploring the integration of TAIP with equivariant transformer-based architectures remains a promising avenue for future research. Overall, TAIP significantly enhances the reliability of MD simulations, paving the way for more complex and accurate molecular discovery.

Summary updated

BibTeX
@inproceedings{zhang2024online,
  author = {Shufei Zhang and Taoyong Cui and Chenyu Tang and D.C. Zhou and Yuqiang Li and Xingao Gong and Wanli Ouyang and Mao Su},
  title = {{Online Test-time Adaptation for InteratomicPotentials}},
  booktitle = {Research Square},
  year = {2024},
  doi = {10.21203/rs.3.rs-4388576/v1},
}
Figure