| name | fairchem |
| description | Expert guidance for Meta's FAIRChem library - machine learning methods for materials science and quantum chemistry using pretrained UMA models with ASE integration for fast, accurate predictions |
| allowed-tools | ["*"] |
FAIRChem Skill
This skill provides expert guidance for using FAIRChem (formerly OCP - Open Catalyst Project), Meta's FAIR Chemistry library of machine learning methods for materials science and quantum chemistry.
When to Use This Skill
Use this skill when:
- Using ML potentials for materials and molecular simulations
- Running fast geometry optimizations with pretrained models
- Performing large-scale MD simulations
- Calculating energies and forces without DFT
- Working with the UMA (Universal Materials Algebra) models
- Needing predictions for catalysis, molecules, crystals, or MOFs
- Integrating ML models with ASE workflows
- Scaling calculations across multiple GPUs
What is FAIRChem?
FAIRChem is Meta's machine learning framework for chemistry that provides:
- Pretrained UMA models (
uma-s-1p1, uma-m-1p1) for universal predictions
- Domain-specific tasks: catalysis (oc20), materials (omat), molecules (omol), MOFs (odac), crystals (omc)
- ASE integration via
FAIRChemCalculator
- Multi-GPU support for distributed inference
- Fast predictions: 100-1000× faster than DFT
Key Advantage
FAIRChem allows you to use the same model across different chemistry domains by simply changing the task_name parameter.
Core Concepts
1. UMA Models
Universal Materials Algebra models trained on diverse datasets:
uma-s-1p1: Small model (~50M parameters) - faster inference
uma-m-1p1: Medium model (~300M parameters) - higher accuracy
2. Task Names (Domains)
Specify the chemistry domain for domain-specific predictions:
oc20: Catalysis (surfaces with adsorbates)
omat: Inorganic materials (crystals, bulk)
omol: Molecules (organic chemistry)
odac: Metal-organic frameworks (MOFs)
omc: Molecular crystals
3. FAIRChemCalculator
ASE calculator interface that wraps UMA models:
- Drop-in replacement for DFT calculators
- Supports all ASE workflows
- Provides energies, forces, and stresses
- Compatible with optimization, MD, NEB
4. Inference Settings
Performance optimization modes:
turbo: Maximum speed, slightly reduced accuracy
- Standard: Balanced speed and accuracy
- Multi-GPU: Distributed inference with
workers=N
Installation
pip install fairchem-core
pip install fairchem-core[gpu]
pip install huggingface-hub
huggingface-cli login
Note: You must have a Hugging Face account and request access to the UMA model repository.
Basic Usage Pattern
Standard Workflow
from fairchem.data.ase import FAIRChemCalculator
from fairchem.predict import load_predict_unit
from ase.build import bulk
from ase.optimize import LBFGS
predict_unit = load_predict_unit("uma-m-1p1")
calc = FAIRChemCalculator(
predict_unit=predict_unit,
task_name="omat"
)
atoms = bulk("Cu", "fcc", a=3.6)
atoms.calc = calc
energy = atoms.get_potential_energy()
forces = atoms.get_forces()
opt = LBFGS(atoms)
opt.run(fmax=0.05)
Common Workflows
Workflow 1: Catalysis - Surface Adsorption
from fairchem.data.ase import FAIRChemCalculator
from fairchem.predict import load_predict_unit
from ase.build import fcc111, add_adsorbate
from ase.optimize import LBFGS
from ase.constraints import FixAtoms
predict_unit = load_predict_unit("uma-m-1p1")
calc = FAIRChemCalculator(
predict_unit=predict_unit,
task_name="oc20"
)
slab = fcc111("Cu", size=(4, 4, 4), vacuum=10.0)
add_adsorbate(slab, "CO", height=2.0, position="fcc")
n_atoms_per_layer = 16
constraint = FixAtoms(indices=range(n_atoms_per_layer * 2))
slab.set_constraint(constraint)
slab.calc = calc
opt = LBFGS(slab, trajectory="slab_opt.traj")
opt.run(fmax=0.05)
E = slab.get_potential_energy()
forces = slab.get_forces()
Workflow 2: Bulk Materials - Lattice Optimization
from fairchem.data.ase import FAIRChemCalculator
from fairchem.predict import load_predict_unit
from ase.build import bulk
from ase.optimize import FIRE
from ase.filters import FrechetCellFilter
predict_unit = load_predict_unit("uma-m-1p1")
calc = FAIRChemCalculator(
predict_unit=predict_unit,
task_name="omat"
)
atoms = bulk("Fe", "bcc", a=2.87)
atoms.calc = calc
ucf = FrechetCellFilter(atoms)
opt = FIRE(ucf)
opt.run(fmax=0.05)
optimized_lattice = atoms.cell.cellpar()[0]
print(f"Optimized lattice constant: {optimized_lattice:.3f} Å")
Workflow 3: Molecular Dynamics
from fairchem.data.ase import FAIRChemCalculator
from fairchem.predict import load_predict_unit
from ase.build import bulk
from ase.md.velocitydistribution import MaxwellBoltzmannDistribution
from ase.md.langevin import Langevin
from ase import units
predict_unit = load_predict_unit(
"uma-s-1p1",
inference_settings="turbo"
)
calc = FAIRChemCalculator(
predict_unit=predict_unit,
task_name="omat",
workers=4
)
atoms = bulk("C", "diamond", a=3.57) * (10, 10, 10)
atoms.calc = calc
MaxwellBoltzmannDistribution(atoms, temperature_K=300)
dyn = Langevin(
atoms,
timestep=1.0 * units.fs,
temperature_K=300,
friction=0.002
)
from ase.io.trajectory import Trajectory
traj = Trajectory("md.traj", "w", atoms)
dyn.attach(traj.write, interval=10)
dyn.run(5000)
Workflow 4: Molecular Systems
from fairchem.data.ase import FAIRChemCalculator
from fairchem.predict import load_predict_unit
from ase.build import molecule
from ase.optimize import LBFGS
predict_unit = load_predict_unit("uma-m-1p1")
calc = FAIRChemCalculator(
predict_unit=predict_unit,
task_name="omol"
)
mol = molecule("H2O")
mol.center(vacuum=10.0)
mol.calc = calc
opt = LBFGS(mol, trajectory="mol_opt.traj")
opt.run(fmax=0.05)
E = mol.get_potential_energy()
forces = mol.get_forces()
Workflow 5: NEB Calculations
from fairchem.data.ase import FAIRChemCalculator
from fairchem.predict import load_predict_unit
from ase.neb import NEB
from ase.optimize import BFGS
from ase.io import read
predict_unit = load_predict_unit("uma-m-1p1")
calc = FAIRChemCalculator(
predict_unit=predict_unit,
task_name="oc20"
)
initial = read("initial.traj")
final = read("final.traj")
images = [initial]
images += [initial.copy() for i in range(5)]
images += [final]
neb = NEB(images)
neb.interpolate()
for image in images[1:-1]:
image.calc = calc
opt = BFGS(neb, trajectory="neb.traj")
opt.run(fmax=0.05)
energies = [img.get_potential_energy() for img in images]
barrier = max(energies) - energies[0]
print(f"Barrier: {barrier:.3f} eV")
Model Loading Options
Load Pretrained UMA Model
from fairchem.predict import load_predict_unit
predict_unit = load_predict_unit("uma-m-1p1")
predict_unit = load_predict_unit(
"uma-m-1p1",
inference_settings="turbo"
)
predict_unit = load_predict_unit(
"uma-m-1p1",
device="cuda:0"
)
predict_unit = load_predict_unit(
"/path/to/checkpoint.pt",
device="cuda"
)
Available Models
uma-s-1p1: Small, fast (~50M params)
uma-m-1p1: Medium, accurate (~300M params)
Task Selection Guide
| Domain | Task Name | Use For | Examples |
|---|
| Catalysis | oc20 | Surfaces + adsorbates | CO on Cu(111), O on Pt |
| Materials | omat | Bulk crystals, defects | Fe lattice, Si bulk |
| Molecules | omol | Organic molecules | H2O, CH4, proteins |
| MOFs | odac | Metal-organic frameworks | ZIF-8, MOF-5 |
| Crystals | omc | Molecular crystals | Ice, organic crystals |
Performance Optimization
Multi-GPU Inference
calc = FAIRChemCalculator(
predict_unit=predict_unit,
task_name="omat",
workers=8
)
Turbo Mode
predict_unit = load_predict_unit(
"uma-s-1p1",
inference_settings="turbo"
)
Batch Predictions
results = []
for atoms in [atoms1, atoms2, atoms3]:
atoms.calc = calc
results.append({
'energy': atoms.get_potential_energy(),
'forces': atoms.get_forces()
})
Best Practices
1. Task Selection
Always choose the appropriate task for your system:
- Surfaces with adsorbates →
oc20
- Bulk materials →
omat
- Isolated molecules →
omol
- MOFs →
odac
- Molecular crystals →
omc
2. Model Selection
- Initial screening: Use
uma-s-1p1 + turbo
- Production calculations: Use
uma-m-1p1
- Very large systems: Use
uma-s-1p1 + workers
3. Validation
ML models have different error characteristics than DFT:
ml_energy = atoms.get_potential_energy()
atoms.calc = Vasp(...)
dft_energy = atoms.get_potential_energy()
error = abs(ml_energy - dft_energy)
4. Uncertainty Quantification
FAIRChem models provide predictions but not uncertainty:
- Test on similar known systems first
- Validate against DFT for critical results
- Use ensemble of predictions if available
5. Memory Management
For large systems:
predict_unit = load_predict_unit(
"uma-s-1p1",
inference_settings="turbo"
)
calc = FAIRChemCalculator(
predict_unit=predict_unit,
task_name="omat",
workers=4
)
Common Patterns
Energy Calculation
atoms.calc = calc
energy = atoms.get_potential_energy()
forces = atoms.get_forces()
stress = atoms.get_stress()
Geometry Optimization
from ase.optimize import LBFGS, FIRE, BFGS
opt = LBFGS(atoms, trajectory="opt.traj")
opt.run(fmax=0.05)
opt = FIRE(atoms)
opt.run(fmax=0.05)
Cell Optimization
from ase.filters import FrechetCellFilter
ucf = FrechetCellFilter(atoms)
opt = FIRE(ucf)
opt.run(fmax=0.05)
Integration with ASE
FAIRChemCalculator is a full ASE calculator:
from ase.vibrations import Vibrations
from ase.thermochemistry import IdealGasThermo
from ase.eos import calculate_eos
vib = Vibrations(atoms)
vib.run()
thermo = IdealGasThermo(...)
eos = calculate_eos(atoms)
Troubleshooting
Hugging Face Authentication
huggingface-cli login
GPU Memory Issues
predict_unit = load_predict_unit("uma-s-1p1")
predict_unit = load_predict_unit(
"uma-s-1p1",
inference_settings="turbo"
)
Slow Inference
inference_settings="turbo"
workers=N
"uma-s-1p1"
Wrong Task Selection
task_name="oc20"
task_name="omat"
Version Compatibility
Important: FAIRChem v2 is a breaking change from v1
- v2 code is NOT compatible with v1 models
- v1 code is NOT compatible with v2 models
- UMA models require FAIRChem >= 2.0
import fairchem
print(fairchem.__version__)
Comparison with DFT
| Aspect | FAIRChem | DFT |
|---|
| Speed | 100-1000× faster | Slower |
| Accuracy | ~0.1 eV | Reference |
| Scaling | Linear, multi-GPU | Cubic |
| System size | 1000s of atoms | 10-100s atoms |
| Use case | Screening, MD | High accuracy |
When to Use FAIRChem vs DFT
Use FAIRChem for:
- Initial screening of many structures
- Long MD simulations
- Large systems (>500 atoms)
- Rapid prototyping
- High-throughput workflows
Use DFT for:
- Final validation
- Novel chemistries outside training data
- When highest accuracy needed
- Electronic structure analysis
- Magnetic properties
Resources
When suggesting FAIRChem solutions:
- Specify correct task_name for the domain
- Recommend appropriate model (s vs m)
- Suggest performance optimizations (turbo, workers)
- Include validation against known results
- Mention Hugging Face authentication requirement
- Provide complete working examples
- Note v2 compatibility requirements
Example Response Pattern
When helping with FAIRChem:
- Identify the chemistry domain (catalysis, materials, molecules, etc.)
- Select appropriate task_name
- Choose model based on accuracy/speed requirements
- Provide complete code with imports
- Suggest performance optimizations if needed
- Recommend validation steps
- Note any domain-specific considerations