xnn.common.models.dispersion_fast.atm_cpu#
The Axilrod-Teller-Muto three-body term on CPUs: dense per-center tiles, compiled.
The reference (three_body_energy()) lists every
triangle three times, once from each corner, as pairs of edges sharing a center, and
evaluates them as separate tensor operations on gathered copies. On a CPU that is about
twenty nanoseconds per triangle, an order of magnitude above the fused loops of the
Fortran codes. Here the edges of every center are sorted by neighbor index and cut
into tiles; a job is a pair of tiles of one center, and every pair of neighbors in it
forms a triangle with the center. A triangle of three distinct atoms is evaluated once,
from its smallest-index corner (a center pairs only neighbors of larger index), and a
third of its energy goes to each of its atoms, which is the reference’s bookkeeping. A
triangle with a repeated atom (two periodic images of one atom, or an image of the
center) is evaluated from every corner with a third of its energy each, in a flat pass
over those pairs. The tile and pair functions run compiled (torch.compile, the C++
and OpenMP code of inductor) on fixed batch shapes; their sources are marked dynamic, so
a new atom or edge count does not compile again. The gradients (forces, stress, the
dependence of C6 on the coordination numbers) are those of the compiled functions.
Module Attributes
the largest; a structure whose centers have fewer neighbors takes the smallest power of two (at least |
|
Tile pairs per compiled call. |
|
Repeated-atom pairs per compiled call. |
|
Squared distances at or below this are coincident images (the reference's guard). |
Functions
|
|
|
The ATM energies per atom |
|
Per-atom ATM energies |
Classes
|
The tile-pair jobs and repeated-atom pairs of one edge list (sorted by center, then neighbor). |