xnn.common.train.graphed#
Training steps replayed as one CUDA graph (trainer.cuda_graph).
A training step on small molecules is bound by kernel launches: the model, the force derivative and the parameter gradients of a force loss take thousands of small kernels, each launched from the host. A captured step replays all of them as one graph. Capture needs fixed shapes and no host synchronization inside the step:
every batch is padded to fixed counts of atoms, edges and model indices by one inert structure (
PaddedCollate): its labels are masked out, so it adds exactly nothing to the loss and the gradients;the index work whose sizes depend on the data (the triplets of DimeNet, the embedding edges, triplets and quadruplets of GemNet) runs before the step, in the data-loader workers, through the model’s
index_planner(), and the batch carries the result asindex_plan;the loss runs without reading values back (
weighted_loss(sync=False)), the optimizer is capturable, and the logged values are read after the replay.
The first batches run as ordinary steps (they warm up the libraries’ workspaces), the next is captured and every later one replayed.
Module Attributes
The atomic number of the padding atoms. |
|
The spacing of the padding atoms along x (neighbors on the line, which carry the padding edges, sit within every cutoff; no edge links them to a real atom). |
|
Ordinary steps before the capture. |
Functions
|
Counts that fit every batch of |
|
The index plan of a batch from the plans of its structures ( |
|
The index planner of the first submodule of |
|
The inert structure that fills a batch: |
|
The real structures of a padded batch ( |
Classes
|
The fixed counts of a padded batch. |
|
The planner of a model whose shapes the batch fixes by itself and which takes no padding structure (a model bound to one system, |
|
A training step on padded batches, captured once and replayed. |
|
The planner of a model whose step needs no index work beyond its edges (PhysNet): the padded batch fixes the atom and edge counts only. |
|
Collate structures into a batch of fixed counts with its index plan. |
|
A dataset whose structures carry their index plans, built once. |