Skip to main content

Training and evaluating machine learning models for atomistic systems.

Project description

https://raw.githubusercontent.com/metatensor/metatrain/refs/heads/main/docs/src/logo/metatrain.svg

Github Actions Tests Job Status Code coverage Documentation

metatrain is a command line interface (cli) to train and evaluate atomistic models of various architectures. It features a common yaml option inputs to configure training and evaluation. Trained models are exported as standalone files that can be used directly in various molecular dynamics (MD) engines (e.g. LAMMPS, i-PI, ASE …) using the metatensor atomistic interface.

The idea behind metatrain is to have a general hub that provide an homogeneous environment and user interface transforms every ML architecture in an end-to-end model that can be connected to an MD engine. Any custom architecture compatible with TorchScript can be integrated in metatrain, gaining automatic access to a training and evaluation interface, as well as compatibility with various MD engines.

Note: metatrain does not provide mathematical functionalities per se but relies on external models that implement the various architectures.

List of Implemented Architectures

Currently metatrain supports the following architectures for building an atomistic model.

Name

Description

GAP

Sparse Gaussian Approximation Potential (GAP) using Smooth Overlap of Atomic Positions (SOAP).

PET

Point Edge Transformer (PET), interatomic machine learning potential

NanoPET (experimental)

re-implementation of the original PET with slightly improved training and evaluation speed

NativePET (experimental)

re-implementation of the original PET, preserving the original architecture and providing a clean code implementation and additional features

SOAP BPNN

A Behler-Parrinello neural network with SOAP features

Documentation

For details, tutorials, and examples, please have a look at our documentation.

Installation

You can install metatrain with pip:

pip install metatrain

In addition, specific models must be installed by specifying the model name. For example, to install the SOAP-BPNN model, you can run:

pip install metatrain[soap-bpnn]

You can then use mtt from the command line to train your models!

Quickstart

To train a model, you can use the following command:

mtt train options.yaml

Where options.yaml is a configuration file that specifies the training options. For example, the following configuration file trains a SOAP-BPNN model on the QM9 dataset:

# architecture used to train the model
architecture:
  name: soap_bpnn
  training:
    num_epochs: 5 # a very short training run

# Mandatory section defining the parameters for system and target data of the
# training set
training_set:
  systems: "qm9_reduced_100.xyz" # file where the positions are stored
  targets:
    energy:
      key: "U0" # name of the target value
      unit: "eV" # unit of the target value

test_set: 0.1 # 10 % of the training_set are randomly split and taken for test set
validation_set: 0.1 # 10 % of the training_set are randomly split and for validation set

Shell Completion

metatrain comes with completion definitions for its commands for bash and zsh. Since it is difficult to automatically configure shell completions in a robust manner, you must manually configure your shell to enable its completion support.

To make the completions available, source the definitions as part of your shell’s startup. Add the following to your ~/.bash_profile, ~/.zshrc (or, if they don’t exist, ~/.profile):

source $(mtt --shell-completion)

Having problems or ideas?

Having a problem with metatrain? Please let us know by submitting an issue.

Submit new features or bug fixes through a pull request.

Contributors

Thanks goes to all people that make metatrain possible:

https://contrib.rocks/image?repo=metatensor/metatrain

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

metatrain-2025.5.tar.gz (253.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

metatrain-2025.5-py3-none-any.whl (306.9 kB view details)

Uploaded Python 3

File details

Details for the file metatrain-2025.5.tar.gz.

File metadata

  • Download URL: metatrain-2025.5.tar.gz
  • Upload date:
  • Size: 253.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for metatrain-2025.5.tar.gz
Algorithm Hash digest
SHA256 36a073e25421cae46b8c567d27a8e953f9d64afa92c2ce6ad9dcaaacf5c95c48
MD5 422523ded10a41fe0d98ad493cdceb74
BLAKE2b-256 b0de9d5adfd591d04a97c8766f853460b0afba3e61668c2931bc5b5029854a68

See more details on using hashes here.

Provenance

The following attestation bundles were made for metatrain-2025.5.tar.gz:

Publisher: release.yml on metatensor/metatrain

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file metatrain-2025.5-py3-none-any.whl.

File metadata

  • Download URL: metatrain-2025.5-py3-none-any.whl
  • Upload date:
  • Size: 306.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for metatrain-2025.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a7a62d0eefb403ab58f4fa3966f89788925c3a2f6e617b53185826c590b6c45d
MD5 64f246d31c697460af3787fb0b4de31d
BLAKE2b-256 d191da5f5d5804a8e33bdf3cb2397844fba19822e988f94095121c1b4fcf3397

See more details on using hashes here.

Provenance

The following attestation bundles were made for metatrain-2025.5-py3-none-any.whl:

Publisher: release.yml on metatensor/metatrain

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page