nvalchemi.hooks.HookContext#

class nvalchemi.hooks.HookContext(*, batch, model=None, global_rank=0, workflow=None)[source]#

Common context object passed to hooks.

HookContext contains fields shared by all hook-enabled workflows. Workflow-specific subclasses add state that is only meaningful in that domain, such as dynamics step counts or training losses.

Parameters:
batch#

Current batch being processed. None is used for lifecycle stages that run before the first batch is available.

Type:

Batch | None

model#

Model being used (if applicable).

Type:

BaseModelMixin | None

global_rank#

Distributed rank of this process.

Type:

int

workflow#

Back-reference to the engine running the hooks. None when the workflow does not inject itself.

Type:

Any