Overview
MLIPCalculator combines MLIP (the PyTorch model wrapper) with ASE’s Calculator base class to produce a drop-in ASE calculator that can compute energies, forces, and stress for any Atoms object.
Inheritance
Implemented properties
Constructor
The underlying PyTorch MLIP model. The model is moved to
device during construction.Target compute device. When
None, the device is selected automatically by get_freer_device() — see device selection below.Neighbor-list cutoff radius in Angstroms. Passed to
collate_fn when building the graph for each calculate call.Path to a restart file. Forwarded to
ase.calculators.calculator.Calculator.__init__.Optional
Atoms object to attach on construction. Forwarded to the ASE Calculator.Working directory for file I/O. Forwarded to the ASE
Calculator.Extra keyword arguments forwarded verbatim to
ase.calculators.calculator.Calculator.__init__.calculate
atoms and stores the results in self.results.
Execution flow:
- Calls
super().calculate(atoms, properties, system_changes)(ASE bookkeeping). - Builds a batched graph via
collate_fn([atoms], cutoff=self.cutoff)and moves it toself.device. - Runs
self.forward(data)to get model outputs. - Extracts and stores results:
The atomic structure to evaluate.
Subset of
implemented_properties to compute. Accepted values: "energy", "forces", "stress".List of changes since the last calculation. Forwarded to the ASE base class to decide whether to recompute. Defaults to
ase.calculators.calculator.all_changes.Results stored in self.results
Total potential energy of the system in eV. Populated when
"energy" is in properties.Atomic forces in eV/Å. Populated when
"forces" is in properties. Moved to CPU and detached before storing.Virial stress tensor in eV/ų (Voigt notation). Populated when
"stress" is in properties. Moved to CPU and detached before storing.Device selection
Whendevice=None (the default), MLIPCalculator calls get_freer_device() from mlip_arena.models.utils to pick the best available device:
| Condition | Selected device |
|---|---|
| One or more CUDA GPUs present | cuda:<i> where <i> is the GPU with the most free memory |
| No CUDA, but MPS available (Apple Silicon) | mps |
| Neither CUDA nor MPS | cpu |
device argument:
MLIPCalculator vs. external calculators
Some models in the registry wrap third-party calculator classes directly rather than subclassingMLIPCalculator. Use the following guidance:
| Use case | Recommendation |
|---|---|
Models with a native MLIPCalculator subclass | Use MLIPCalculator — consistent API, graph construction handled internally |
| CHGNet | CHGNet wraps CHGNetCalculator from the chgnet package — use via MLIPEnum["CHGNet"].value() |
| MACE-MP / MACE-MPA / MACE-OFF | Wrap MACECalculator from mace-torch — use via MLIPEnum |
| General usage | Always instantiate through MLIPEnum for automatic device selection and consistent behavior |