nvalchemi.enhanced_sampling.WalkerIdentityHook#

class nvalchemi.enhanced_sampling.WalkerIdentityHook(*, steps_per_epoch, exchange=None)[source]#

Stamp walker identity and step counters onto the live batch.

walker_id and thermodynamic_state_id are assigned once and then preserved; the counters are refreshed every step. All five fields are also registered as BaseDynamics bookkeeping keys, so they survive refill and graduation rather than depending on this hook alone.

Parameters:
  • steps_per_epoch (int) – Divisor for sampling_epoch.

  • exchange (ReplicaExchange | None) – Ladder, when replica exchange is configured. Read for the initial assignment and the segment divisor only; attempts are the swap hook’s job.

next_walker_id#

The identifier the next unstamped graph will receive. Carried in a checkpoint so a resumed run does not reissue identifiers.

current_batch#

The batch last stamped, which is what checkpoint() saves when the caller does not name one.

load_state_dict(state)[source]#

Restore the identifier allocation.

Parameters:

state (Mapping[str, Any]) – A mapping produced by state_dict().

Return type:

None

on_register(workflow)[source]#

Remember the engine the thermodynamic assignment has to drive.

Parameters:

workflow (Any) – The BaseDynamics doing the registering.

Return type:

None

stamp(batch, step)[source]#

Write identity and counter fields for step onto batch.

Exposed separately from __call__() because force priming needs the batch stamped without a hook dispatch behind it.

Parameters:
  • batch (Batch) – The live batch.

  • step (int) – The dynamics step the stamp describes.

Return type:

None

state_dict()[source]#

Return the identifier allocation that must survive a restart.

Returns:

The next identifier to issue. A resumed run that restarted the counter would reissue ids already attached to saved history.

Return type:

Mapping[str, Any]