xnn.trfnn.models.base.TransformerPotential#

class xnn.trfnn.models.base.TransformerPotential(*args, **kwargs)[source]#

Bases: InteratomicPotential

Base of the transformer potentials: energy standardization and per-element references.

Subclasses call _init_energy_terms() in their __init__. Models whose constants (coupling coefficients, grid matrices) must stay exact in float64 set exact_float64 = True.

Variables:
  • energy_shift (energy_scale,) – The per-atom standardization buffers.

  • atom_ref (torch.nn.Embedding) – Learnable per-element energy reference indexed by Z, initialized to zero.

Parameters:
fast_path = ''#

the module of the model’s fast path (its AUTO_POLICY and AUTO_POLICY_TRAINING)

set_use_fast(use_fast)[source]#

Choose between the reference layers and the fused kernels of the fast path.

Parameters:

use_fast (bool or str) – "auto" (the default): the fused GPU kernels (see the model’s fast-path module in xnn.trfnn.fast) where they are available and faster for the input (a CUDA device, a graph above the size crossover measured for evaluation, AUTO_POLICY, or for training, AUTO_POLICY_TRAINING); True: wherever they are available; False: always the reference implementation. The kernels are twice differentiable, so force training takes them as well.

Returns:

self.

Return type:

TransformerPotential

set_energy_scale_shift(scale, shift)[source]#

Set the per-atom energy standardization from training statistics.

Parameters:
  • scale (float) – Standard deviation of the training-set energy per atom.

  • shift (float) – Mean training-set energy per atom.

Return type:

None

set_atomic_energies(species, values)[source]#

Initialize the per-element reference energies atom_ref.

Parameters:
  • species (list of int) – Atomic numbers the values refer to, in order.

  • values (array-like) – One reference energy per entry of species.

Raises:

ValueError – If the number of values does not match the number of species.

Return type:

None