nvalchemi.distributed.DomainParallel#
- class nvalchemi.distributed.DomainParallel(dynamics, config, **kwargs)[source]#
Wraps any
BaseDynamicssubclass with spatial domain decomposition.Flow per step:
Outer BEFORE_STEP hooks on owned batch.
Inner dynamics
pre_update(velocity-Verlet half-kick) on owned batch.Wrap positions into the periodic box.
Sync the updated positions back into the persistent
ShardedBatch(update_from_batch).DistributedModel(sharded)— the adapter rebuilds the halo block, rebuilds NL, runs the wrapper, consolidates owned-shape outputs.Write the consolidated outputs back to the owned batch in-place.
Inner dynamics
post_update(velocity-Verlet finalize) on owned batch.Atom migration (
reshard_by_destination) for atoms that crossed domain boundaries.Outer AFTER_STEP hooks on owned batch.
- Parameters:
dynamics (BaseDynamics) – The underlying single-GPU dynamics integrator or optimizer.
config (DomainConfig) – Domain decomposition configuration.
**kwargs (Any) – Forwarded to
BaseDynamics.__init__(hooks,n_steps,device_type, …).
- close()[source]#
Release resources held by the adapter (restores any state its
distributed_setupmutated on the inner wrapper). Safe to call multiple times.- Return type:
None
- gather(local_batch, dst=0)[source]#
Gather the distributed system back into a full
Batchon rank dst. ReturnsNoneon other ranks.Single-process fallback: returns
local_batchunchanged.
- partition(batch)[source]#
Scatter the full-system batch across ranks and build the per-step machinery (
ShardedBatch+DistributedModel).Must be called once before
run()/step().
- step(batch)[source]#
Execute one domain-decomposed dynamics step.
- Parameters:
batch (Batch)
- Return type:
tuple[Batch, torch.Tensor | None]