Models¶
Most of the code in metatomic.torch
is here to define and export
models and to store model metadata. The corresponding classes are documented
below:
We also provide a couple of functions to work with the models:
- metatomic.torch.read_model_metadata(path: str) ModelMetadata [source]¶
Read metadata of a saved metatenor atomistic model.
This function allows to access the metadata of a model without loading it in advance.
- Parameters:
path (str) – path to the exported model file
- Return type:
- metatomic.torch.load_atomistic_model(path, extensions_directory=None) AtomisticModel [source]¶
Check and then load the metatomic model at the given path.
This function calls
metatomic.torch.check_atomistic_model()
andmetatomic.torch.load_model_extensions()
before attempting to load the model.- Parameters:
path – path to an exported metatensor model
extensions_directory – path to a directory containing all extensions required by the exported model
- Return type:
- metatomic.torch.check_atomistic_model(path: str)[source]¶
Check that the file at
path
contains an exported metatensor atomistic model, and that this model can be loaded in the current process.This function should be called before
torch.jit.load()
when loading an existing model.- Parameters:
path (str) – path to the exported model file
- metatomic.torch.load_model_extensions(path: str, extensions_directory: str | None = None)[source]¶
Load the TorchScript extensions (and their dependencies) that the model at
path
uses.If
extensions_directory
is provided, we look for the extensions and their dependencies in there first. If this function fails to load some library, it will produce a warning using Torch’s warnings infrastructure. Users can set theMETATENSOR_DEBUG_EXTENSIONS_LOADING
environment variable to get more informations about a failure in the standard error output.- Parameters:
path (str) – path to the exported model file
extensions_directory (str | None) – path to a directory containing the extensions. This directory will typically be created by calling
AtomisticModel.export()
withcollect_extensions=extensions_directory
.
- metatomic.torch.unit_conversion_factor(quantity: str, from_unit: str, to_unit: str)[source]¶
Get the multiplicative conversion factor from
from_unit
toto_unit
. Both units must be valid and known for the given physicalquantity
. The set of valid quantities and units is available here.
Known quantities and units¶
The following quantities and units can be used with metatomic models. Adding new
units and quantities is very easy, please contact us if you need something else!
In the mean time, you can create metatomic.torch.ModelOutput
with
quantities that are not in this table. A warning will be issued and no unit
conversion will be performed.
When working with one of the quantity in this table, the unit you use must be one of the registered unit.
quantity |
units |
---|---|
length |
angstrom (A), Bohr, meter, centimeter (cm), millimeter (mm), micrometer (um, µm), nanometer (nm) |
energy |
eV, meV, Hartree, kcal/mol, kJ/mol, Joule (J), Rydberg (Ry) |