MatterSim
Model Introduction
MatterSim is a deep-learning interatomic potential developed by Microsoft Research for a broad range of elements, temperatures, and pressures. It predicts energies and forces for inorganic materials, molecules, and periodic systems.
Paper: MatterSim: A deep-learning atomistic model across elements, temperatures, and pressures
Reference implementation: https://github.com/microsoft/mattersim
Model Description
MatterSim uses a deep-learning architecture trained on multiple materials and molecular datasets. It supports energy and force prediction, structure relaxation, molecular dynamics, and fine-tuning on custom datasets for inorganic materials, molecules, and periodic systems.
Use Cases
| Use case | Description |
|---|---|
| Single-point energy/force prediction | Quickly predict the energy and atomic forces of a given atomic structure |
| Batch structure inference | Predict energies and forces for multiple structures in a batch |
| Structure relaxation | Optimize atomic positions and cell shape with FIRE/BFGS |
| Molecular dynamics | Run short MD sampling in the NVT ensemble |
| Fine-tuning on custom data | Fine-tune a pretrained MatterSim model on your own dataset |
| Environment connectivity check | Use the single-point and relaxation scripts to verify the OneScience MatChem environment, model loading, and CUDA/DCU availability |
Usage
1. Using OneCode
Try intelligent, one-click AI4S programming in the OneCode online environment:
Try intelligent, one-click AI4S programming
2. Manual Installation and Usage
Hardware requirements
- A GPU or DCU is recommended.
- A CPU can be used for import checks and small-configuration connectivity tests, but full training and inference will be slow.
- DCU users must install DTK in advance. DTK 25.04.2 or later, or the OneScience-recommended version matching the current cluster, is recommended.
Download the Model Package
hf download OneScience-Group/Mattersim
cd mattersim
Install the Runtime Environment
DCU environment
# Activate DTK and conda first
conda create -n onescience311 python=3.11 -y
conda activate onescience311
# uv installation is also supported
pip install onescience[matchem-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
GPU environment
# Activate conda first
conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=12
conda activate onescience311
# uv installation is also supported
pip install onescience[matchem-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
Training Data
By default, this repository only includes the high_level_water.xyz sample data for quickly validating model loading, single-point inference, structure relaxation, molecular dynamics, and fine-tuning workflows. Download any additional training data separately and place it in data/.
Trained Weights
The repository includes weight/mattersim-v1.0.0-1M.pth. All scripts also accept a custom model weight through --checkpoint.
Inference
cd scripts
python single_point.py --checkpoint ../weight/mattersim-v1.0.0-1M.pth
cd scripts
python batch_inference.py --checkpoint ../weight/mattersim-v1.0.0-1M.pth
Structure relaxation
cd scripts
python relax.py --checkpoint ../weight/mattersim-v1.0.0-1M.pth --device cuda
The default checkpoint is
../weight/mattersim-v1.0.0-1M.pth.
Molecular dynamics
cd scripts
python md.py --checkpoint ../weight/mattersim-v1.0.0-1M.pth --device cuda
This script also uses
../weight/mattersim-v1.0.0-1M.pthby default.
Fine-Tuning
Edit the paths and parameters in scripts/finetune_config.yaml, including train_data_path and checkpoint:
cd scripts
# Edit train_data_path, checkpoint, and other fields in finetune_config.yaml
Single GPU:
python finetune.py --config finetune_config.yaml
Multi-GPU DDP:
torchrun --nproc_per_node=4 finetune.py --config finetune_config.yaml
Official OneScience Resources
| Platform | OneScience Main Repository | Skills Repository |
|---|---|---|
| Gitee | https://gitee.com/onescience-ai/onescience | https://gitee.com/onescience-ai/oneskills |
| GitHub | https://github.com/onescience-ai/OneScience | https://github.com/onescience-ai/oneskills |
Citation and License
- The MatterSim-related code comes from the MatChem examples in the OneScience project and refers to the upstream MatterSim project (https://github.com/microsoft/mattersim). The upstream MatterSim code is released under the MIT License.
- If you use MatterSim training or inference results in research, please cite the original MatterSim paper, the relevant OneScience projects, and the datasets used.
中文说明
模型简介
MatterSim 是 Microsoft Research 开发的基于深度学习的原子间势函数,适用于多种元素、温度和压力。它预测无机材料、分子和周期性体系的能量与力。
论文《MatterSim:跨元素、温度和压力的深度学习原子模型》
参考实现 https://github.com/microsoft/mattersim
模型描述
MatterSim 采用在多个材料与分子数据集上训练的深度学习架构,支持无机材料、分子与周期性体系的能量和力预测、结构弛豫、分子动力学以及在自定义数据集上微调(fine-tuning)。
使用场景
| 使用场景 | 说明 |
|---|---|
| 单点能量/力预测 | 快速预测给定原子结构的能量和原子力 |
| 批量结构推理(inference) | 批量预测多个结构的能量和力 |
| 结构弛豫 | 使用 FIRE/BFGS 优化原子位置和晶胞形状 |
| 分子动力学 | 在 NVT 系综中运行短程 MD 采样 |
| 自定义数据微调 | 在自己的数据集上微调预训练 MatterSim 模型 |
| 环境连通性检查 | 使用单点和弛豫脚本验证 OneScience MatChem 环境、模型加载及 CUDA/DCU 的可用性 |
使用方法
1. 使用 OneCode
在 OneCode 在线环境中体验智能一键 AI4S 编程。
2. 手动安装与使用
硬件要求
- 建议使用 GPU 或 DCU。
- 可使用 CPU 进行导入检查和小配置连通性测试,完整训练和推理速度较慢。
- DCU 用户必须提前安装 DTK。建议使用 DTK 25.04.2 或更高版本,或使用 OneScience 推荐的与当前集群匹配的版本。
下载模型包
hf download OneScience-Group/Mattersim
cd mattersim
安装运行环境
DCU 环境
# Activate DTK and conda first
conda create -n onescience311 python=3.11 -y
conda activate onescience311
# uv installation is also supported
pip install onescience[matchem-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
GPU 环境
# Activate conda first
conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=12
conda activate onescience311
# uv installation is also supported
pip install onescience[matchem-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
训练数据
默认情况下,本仓库仅包含 high_level_water.xyz 样本数据,用于快速验证模型加载、单点推理、结构弛豫、分子动力学和微调流程。其他训练数据需单独下载并放入 data/。
训练权重
本仓库包含 weight/mattersim-v1.0.0-1M.pth。所有脚本也可通过 --checkpoint 接收自定义模型权重。
推理
cd scripts
python single_point.py --checkpoint ../weight/mattersim-v1.0.0-1M.pth
cd scripts
python batch_inference.py --checkpoint ../weight/mattersim-v1.0.0-1M.pth
结构弛豫
cd scripts
python relax.py --checkpoint ../weight/mattersim-v1.0.0-1M.pth --device cuda
默认模型权重(检查点)(checkpoint)为
../weight/mattersim-v1.0.0-1M.pth。
分子动力学
cd scripts
python md.py --checkpoint ../weight/mattersim-v1.0.0-1M.pth --device cuda
此脚本默认也使用
../weight/mattersim-v1.0.0-1M.pth。
微调
编辑 scripts/finetune_config.yaml 中的路径和参数,包括 train_data_path 及 checkpoint。
cd scripts
# Edit train_data_path, checkpoint, and other fields in finetune_config.yaml
单 GPU
python finetune.py --config finetune_config.yaml
多 GPU DDP
torchrun --nproc_per_node=4 finetune.py --config finetune_config.yaml
OneScience 官方资源
| 平台 | OneScience 主仓库 | Skills 仓库 |
|---|---|---|
| Gitee | https://gitee.com/onescience-ai/onescience | https://gitee.com/onescience-ai/oneskills |
| GitHub | https://github.com/onescience-ai/OneScience | https://github.com/onescience-ai/oneskills |
引用与许可证
- MatterSim 相关代码来自 OneScience 项目的 MatChem 示例,并参考上游 MatterSim 项目 (https://github.com/microsoft/mattersim)。上游 MatterSim 代码按 MIT 许可证发布。
- 如果在研究中使用 MatterSim 训练或推理结果,请引用 MatterSim 原始论文、相关 OneScience 项目及所用数据集。
- Downloads last month
- 18