xnn.hybnn.models.spookynet.SpookyNetPlanner#

class xnn.hybnn.models.spookynet.SpookyNetPlanner(local_cutoff, lr_cutoff, long_range, ewald)[source]#

Bases: object

The index work of a SpookyNet step, done before the step for captured steps.

A captured step (xnn.common.train.graphed) needs fixed shapes and no host synchronization. SpookyNet selects its local edges and its long-range pairs by distance, and pads the attention to the largest structure: each reads values back from the device. A data-loader worker builds them on the CPU instead: "local" (the edges within the local cutoff), "lr" (the edges within lr_cutoff) or "lr_dst" and "lr_src" (all ordered pairs of every structure, without lr_cutoff), and "slot" (each atom’s position in its structure, which gives the size n_max of the attention). SpookyNet.forward() takes them from the batch’s index_plan. The Ewald sum is not supported. Holds only the model’s cutoffs.

Parameters:
  • local_cutoff (float) – The cutoff of the local interactions.

  • lr_cutoff (float or None) – The cutoff of the long-range terms (None: all pairs).

  • long_range (bool) – Whether the model has electrostatics or dispersion.

  • ewald (bool) – Whether the model sums the electrostatics of periodic structures by Ewald.

maxima = ('n_max',)#

Plan sizes that are the largest over the structures rather than sums.

offsets: Dict[str, str | None]#

The count each plan entry indexes (for batching the plans of single structures).

sizes(plan)[source]#

The sizes a padded batch fixes: atoms, local edges, long-range pairs and n_max.

Parameters:

plan (Dict[str, Tensor])

Return type:

Dict[str, int]

static pad(plan, sizes, dummy_edge)[source]#

plan filled up to sizes: edges with the padding edge dummy_edge, pairs with the first two padding atoms (both outside every real structure).

Parameters:
Return type:

Dict[str, Tensor]