The MatGL Library: Open-Source Graph Networks for Materials Science ✛

Original: "Materials Graph Library (MatGL), an open-source graph deep learning library for materials science and chemistry"
arXiv:2503.03837 · 2025-03-05 · CC BY 4.0 · 3 min
MatGL brings together five graph architectures and ready-to-use interatomic potentials in one open library.

Context

Graph neural networks for materials have multiplied in recent years, but each implementation lived in its own repository: MEGNet on TensorFlow, M3GNet on PyTorch, CHGNet with its own scripts. Porting a model to new data or comparing architectures was a project in itself. Libraries for a single architecture and packages like PyTorch-Geometric already existed, but materials science lacked a common layer that would tie together crystal structures, training, and molecular dynamics runs. MatGL fills this niche, building on DGL, a library that benchmarks show outperforms PyTorch-Geometric in memory and speed on large graphs.

Methods

MatGL is built on four components: a data pipeline, model architectures, training, and simulation interfaces. The pipeline takes Pymatgen or ASE structures, builds graphs with a specified cutoff radius, and caches them for reuse. The architectures, MEGNet, M3GNet, CHGNet, TensorNet, and SO3Net, are implemented modularly: layers, pooling, and activation functions are shared across models. Training goes through PyTorch Lightning, allowing scaling to multiple GPUs. For interatomic potentials, a Potential class is implemented that automatically handles energy normalization and computes forces, stresses, and Hessians via autodifferentiation. Interfaces to ASE and LAMMPS let you run structure relaxation and molecular dynamics with a single command.

Results

Benchmarks on four datasets show that MatGL reproduces the accuracy of the original models. On QM9, the free energy prediction error for M3GNet is 0.025 eV, for TensorNet 0.027 eV, and for SO3Net 0.025 eV; MEGNet lags with 0.037 eV. On Matbench for formation energy, M3GNet, TensorNet, and SO3Net give errors of 0.020–0.024 eV/atom, while MEGNet gives 0.037 eV/atom. For potentials on ANI-1x, the equivariant SO3Net achieves a force error of 0.035 eV/Å, compared to 0.075 eV/Å for M3GNet with transfer learning. On crystals from the Materials Project, CHGNet outperforms M3GNet and TensorNet: an energy error of 19.9 meV/atom versus 23.0 and 30.3 meV/atom. Inference speed for TensorNet on QM9 is 14.9 seconds for 6541 molecules on a single RTX 3090, while MEGNet takes 12 seconds but with worse accuracy.

Implications

MatGL does for graph models of materials what scikit-learn did for classical machine learning: it provides a unified interface where you can take a ready-made model, train your own, or compare architectures on the same data. This lowers the entry barrier for experimentalists and speeds up reproducibility. Unlike neighboring works that focus on a single architecture or on reinforcement learning, MatGL offers five models at once and links them to ASE and LAMMPS, turning the library into a platform for the full cycle, from data to molecular dynamics.

Future development

The next step is support for multi-GPU training and working with databases exceeding millions of structures. The authors plan to use memory-mapped databases for storing graphs to lift the memory limitation. This will allow training universal potentials on the entire Materials Project and running molecular dynamics for systems with hundreds of thousands of atoms.

Impact

The library is already integrated into MatSciML and the Amsterdam Modeling Suite, expanding its use in high-throughput materials screening and industrial modeling.

Next steps

Upcoming versions are expected to support distributed training and optimize the data pipeline for datasets with tens of millions of structures.

Key open problems

For materials science, the key unsolved problem is transferring models to chemical compositions and structures far from the training set. MatGL provides a tool for systematically testing such generalizability: you can quickly train a model on one dataset and run it on another without rewriting code. This directly relates to the question of how universal universal potentials really are beyond equilibrium configurations.

The knowledge machine's view

This section is addressed to the author of the paper and their colleagues. Neighbouring works were found by meaning-based search across our archive, not by word overlap. We do not review: we show the field around the work.

What the work does

MatGL brings together five graph architectures (MEGNet, M3GNet, CHGNet, TensorNet, SO3Net) in a single library with a data pipeline, training via PyTorch Lightning, and interfaces to ASE/LAMMPS. The authors reproduced the accuracy of the original models on QM9, Matbench, ANI-1x, and MPF-2021.2.8, showing errors comparable to DFT and high inference speed.

Where its strength is

A unified interface for training, comparing, and running five architectures, linking crystal structures to molecular dynamics, which makes the library a full-cycle platform.

Where it could go next

Worth trying

  • Try adding a magnetic moment feature to the MatGL graph pipeline and train TensorNet on data with nonzero magnetization.
  • Use the approach from the paper on stress in parts for data augmentation when training on defective structures.
  • Check how well MatGL's pretrained potentials transfer to crystals with magnetic ordering, and fine-tune them if necessary.

Why this may matter

Such an extension would allow MatGL to cover another class of materials science problems, namely predicting magnetic properties, and strengthen its role as a universal platform for graph models in materials science.

The pretrained M3GNet potential in MatGL predicts the energy and forces for a crystal of 1000 atoms in fractions of a second, whereas a DFT calculation of the same system would take hours on a supercomputer.

Key numbers

  • energy error on ANI-1x for SO3Net: 1.596 meV/atom
  • force error on ANI-1x for SO3Net: 0.035 eV/Å
  • TensorNet inference time on QM9: 14.9 s for 6541 molecules
  • number of architectures in MatGL: 5
  • number of pretrained models: 28 for properties and 6 for potentials
Concepts
machine learning materials graph neural network deep learning in medical imaging molecular property prediction protein language model neural network physics modeling graphite dataset Large Language Models generative model medical image to genomic mapping machine learned interatomic potential materials science Graphs neural network crystal imaging