nvalchemi.distributed.DenseBatchPadder#

class nvalchemi.distributed.DenseBatchPadder(*, nbmat_key='neighbor_matrix', initial_factor=1.15, grow_factor=1.30, stride=16)[source]#

Built-in GraphPadder for dense (N, K) neighbor-matrix Batches (AIMNet2).

The batch-level counterpart of DensePadder. The framework compiles the whole wrapper.forward, so the fixed-shape padding must land on the halo-padded Batch before adapt_input runs — the same seam COOPadder uses. This padder pads the atom-level storage group to a fixed atom capacity with inert dead atoms (zeros, Z=0, joined to the last graph) and repoints the neighbor_matrix sentinel so no real atom ever sees a dead atom as a neighbor.

adapt_input then appends its own padding atom on top of this fixed-shape batch, so the compiled model input keeps a constant (n_cap + 1, …) shape across MD steps. The sentinel is repointed to n_cap — the index of that appended pad atom — so aimnet’s calc_masks masks every dead / sentinel neighbor slot to zero.

unpad() is a no-op: the owned-only mol_sum (masked by n_owned) drops the dead rows from the energy, and the per-atom force output is sliced by the framework’s output consolidation. The framework restores the transient padded storage separately (the padded Batch is reused in place across MD steps).

Parameters:
  • nbmat_key (str, default "neighbor_matrix") – The dense neighbor-matrix node field whose padding sentinel (unused slots, set to the pre-pad node count) must be repointed to the appended pad-atom index.

  • initial_factor (float) – Forwarded to resolve_cap() for the "atoms" capacity.

  • grow_factor (float) – Forwarded to resolve_cap() for the "atoms" capacity.

  • stride (int) – Forwarded to resolve_cap() for the "atoms" capacity.

pad(data, cap_state, cap_atoms=True)[source]#

Resolve the atom cap from cap_state and pad the halo-padded Batch to it. Mutates data in place and returns it; None is a safe no-op.

Parameters:
  • data (Batch)

  • cap_state (dict[str, int])

  • cap_atoms (bool)

Return type:

Batch

unpad(output, n_real=None)[source]#

No-op: the owned-only mol_sum + output consolidation drop dead rows.

Parameters:
  • output (Any)

  • n_real (int | None)

Return type:

Any