nvalchemi.dynamics.StructureSource#

class nvalchemi.dynamics.StructureSource(*args, **kwargs)[source]#

Structures a propagator starts from, served in order from one position.

The protocol lists the members an in-flight batching driver reads, so any object that provides them can stand in for a dataset-backed sampler. probe() returns one row for checks that run at construction. shard() narrows the source to the rows one rank owns and resets the position. initial_batch() builds the batch the first step propagates from. draw() serves the fresh structures a backfill adds. exhausted reports whether any structure is left. state_dict() and load_state_dict() carry the position through a restart. OrderedStructureSampler is the reference implementation, backed by a dataset.

Examples

>>> from nvalchemi.dynamics import OrderedStructureSampler, StructureSource
>>> isinstance(OrderedStructureSampler(dataset), StructureSource)
True
draw(*, limit=None, fits=None, on_miss='stop')[source]#

Serve the next structures while they pass fits.

Parameters:
  • limit (int | None)

  • fits (FitPolicy | None)

  • on_miss (Literal['stop', 'skip'])

Return type:

list[AtomicData]

property exhausted: bool#

Whether the source has no structure left to hand out.

initial_batch()[source]#

Return the batch the first step propagates from, advancing the position.

A source that feeds a trajectory lifecycle stamps every structure with a status of 0 and its own system_id, as OrderedStructureSampler does.

Return type:

Batch

load_state_dict(state)[source]#

Resume this source at the position state recorded.

Parameters:

state (Mapping[str, Any])

Return type:

None

probe()[source]#

Return one row, collated as the one-graph batch a propagator receives.

Return type:

Batch

shard(rank, world_size)[source]#

Narrow the source to the rows rank of world_size owns and reset it.

Parameters:
  • rank (int)

  • world_size (int)

Return type:

None

state_dict()[source]#

Return the position a restart resumes this source from.

Return type:

dict[str, Any]