torchani.compile#

Ahead-of-time compilation of models into AOTInductor packages

Warning

This module is experimental. Its API and behavior may change without warning.

The compiled package computes energies and forces from an external neighborlist, and can be loaded without Python, from C++, using torch::inductor::AOTIModelPackageLoader, or from Python, using torch._inductor.aoti_load_package. Its signature is:

(species, coords, neighbor_idxs, shifts) -> (energies, forces)

with shapes (1, A), (1, A, 3), (2, P) and (P, 3). The number of atoms A and of pairs P are dynamic. All inputs must be contiguous, and coords must be mapped to the central cell. If the model uses cuAEV, the cuAEV extension must be loaded by the process before running the package.

Functions

compile_model

Compile a model's energies and forces into an AOTInductor package

torchani.compile.compile_model(model, package_path)[source]#

Compile a model’s energies and forces into an AOTInductor package

The model is compiled for the device and dtype of its parameters. See the module docstring for the signature of the compiled package.

Parameters:
  • model (_ANI) – The model to compile.

  • package_path (str | Path) – Path of the output .pt2 package.

Returns:

The path of the package.

Return type:

Path