MatterGen is a generative model released by Microsoft for inorganic materials design across the periodic table, which can be guided through fine-tuning to generate materials satisfying multiple property constraints. This repository is its official implementation.
Main Capabilities
- Unconditional generation: sample inorganic material structures from a pretrained base model.
- Property-conditioned generation: use fine-tuned models to generate materials satisfying target properties, such as chemical system, space group, DFT magnetic density, DFT band gap, ML bulk modulus, HHI score, energy above the convex hull, etc.
- Multi-property conditioned generation: supports generating materials based on multiple property conditions simultaneously.
- Training and fine-tuning: supports training MatterGen from scratch or fine-tuning on property data.
- Evaluation: supports using the MatterSim machine learning force field to relax generated structures and calculate metrics such as novelty, uniqueness, and stability.
Usage
- Installation: the environment can be installed via uv, or the released package can be installed from PyPI. Linux and a CUDA GPU are required.
- Obtain pretrained models: checkpoints are provided for the unconditional base model and multiple property fine-tuned models, located at checkpoints/<model_name>, and can also be obtained from Hugging Face.
- Generate materials: run the generation script, optionally specifying --pretrained-name or --model_path. Outputs include files such as generated_crystals_cif.zip and generated_crystals.extxyz.
- Property-conditioned generation: use a fine-tuned model and set --diffusion-guidance-factor to control the degree of condition adherence.
- Multi-property conditioned generation: use a model that supports joint conditioning on multiple properties.
- Evaluation: use the mattergen-evaluate script to relax with the MatterSim force field and calculate metrics.
- Training: after preprocessing the dataset, run the training script. Hydra configuration overrides are supported.
- Fine-tuning: fine-tune the base model on property data, supporting multi-property fine-tuning and custom property data.
Applicable Scenarios
- Inorganic materials design and discovery.
- Property-oriented materials generation.
- Materials structure prediction (CSP mode).
- Benchmarking and evaluation of materials generation models.
Limitations
- Evaluation uses the MatterSim machine learning force field, which is much faster than DFT, but its accuracy may be lower than DFT, especially inrare chemical systems. It is recommended to verify results with DFT.
- The provided checkpoints were retrained using this repository and may differ from those used in the paper, so results may deviate.
- Running on Apple Silicon is experimental and requires setting PYTORCH_ENABLE_MPS_FALLBACK=1.
- Datasets and model checkpoints are provided via Git LFS, so Git LFS must be installed.
- Training and generation require a CUDA GPU; a single GPU's memory may be insufficient to support a batch size of 512, requiring gradient accumulation.
- Custom reference datasets must be compatible with MatterSim, or use DFT energies calculated according to a Materials Project-compatible scheme.