nvalchemi.enhanced_sampling.EpochCommitHook#

class nvalchemi.enhanced_sampling.EpochCommitHook(targets, *, frequency)[source]#

Fire StatefulHook.commit() on a consistency-epoch cadence.

The cadence is frequency, so the registry gates the dispatch and nothing here re-implements “has the boundary been crossed”. Commits stay idempotent by epoch index regardless, because the boundary is also reached eagerly when a checkpoint drains a completed epoch.

Parameters:
  • targets (list[StatefulHook]) – The stateful hooks to commit — for enhanced sampling, the single BiasHook, which fans out to its adaptive biases.

  • frequency (int) – Steps per consistency epoch.

commit_epoch(epoch)[source]#

Commit epoch, at most once.

Idempotent by design: the boundary is reached from two directions — the cadence, and a checkpoint draining a completed epoch — and a shared-history bias that merged its pending deposits twice would double-count them.

Parameters:

epoch (int) – Index of the completed epoch. Negative, or already committed, is a no-op.

Return type:

None

load_state_dict(state)[source]#

Restore the boundary cursor.

Parameters:

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

Return type:

None

state_dict()[source]#

Return the boundary cursor that must survive a restart.

Returns:

The last epoch committed. Restarting at -1 would re-commit epochs whose shared history was already published, which a bias that merges pending deposits would double-count.

Return type:

Mapping[str, Any]