xnn.common.deploy.graphed_eval#
Evaluations of a model replayed as one CUDA graph (molecular dynamics, optimization, screening).
On small structures an evaluation (the energy and its derivatives) is bound by kernel launches:
the model and the force derivative take a thousand small kernels, each launched from the host. A
captured evaluation records them once and replays them. Capture needs fixed shapes and no host
synchronization inside the evaluation, as the captured training step of
xnn.common.train.graphed, whose pieces this reuses:
every input is padded to fixed counts of atoms, edges and model indices by one inert structure (
padding_structure()), whose results are dropped;the index work whose sizes depend on the input runs before the replay, through the model’s
index_planner();the counts carry a margin, and an input that outgrows them (or has another number of structures) is captured again; a model bound to one system (its planner’s
padsfalse) is replayed on the batch as it comes, and captured again when the counts change.
The replay runs the same code as an ordinary evaluation, so the results agree with it to round-off.
On large structures the launches are a small part of an evaluation and the padding costs more than
they do: the first input is evaluated ordinarily and timed, an evaluation slower than max_ms is
not captured at all, and after each capture a few replays are timed against ordinary evaluations,
and the faster is kept (the graph and its memory are released when the ordinary evaluation wins).
Module Attributes
the capture goes ahead at the first one no slower than |
Classes
|
A model's evaluations on padded graphs, captured once per size class and replayed. |