xnn.common.deploy.graphed_eval.GraphedEvaluation#

class xnn.common.deploy.graphed_eval.GraphedEvaluation(model, margin=1.05, slack=64, warmup=2, trial=3, max_ms=100.0)[source]#

Bases: object

A model’s evaluations on padded graphs, captured once per size class and replayed.

Parameters:
  • model (torch.nn.Module) – The evaluation, model(graph) -> dict (for example a ForceStressOutput), on a CUDA device; it or one of its submodules must provide index_planner().

  • margin (float, optional) – Relative headroom of the atom, edge and plan counts over the first input (and over an input that outgrows them), by default 1.05: in molecular dynamics the edge count drifts by a few percent, and every padding edge costs as much as a real one.

  • slack (int, optional) – Absolute headroom added to the counts, by default 64.

  • warmup (int, optional) – Ordinary evaluations before the capture, by default 2. They and the capture run with TorchScript fusion off, so that no TorchScript block compiles a kernel while it is recorded.

  • trial (int, optional) – Replays and ordinary evaluations timed against each other after a capture, by default 3; the faster is used until the input outgrows the counts. 0 always replays.

  • max_ms (float or None, optional) – Wall time in milliseconds of an ordinary evaluation of the first input above which nothing is captured and evaluations stay ordinary, by default 100: the launches are a small part of such an evaluation, and a graph’s memory would come on top of its own. The first calls are ordinary evaluations, timed, until one takes at most max_ms or PROBES of them took longer. None captures whatever the time, from the first call.

Raises:

ValueError – If the model has no index planner.