nvalchemi.training.hooks.TrainingUpdateOrchestrator#
- class nvalchemi.training.hooks.TrainingUpdateOrchestrator(*hooks)[source]#
Composes
TrainingUpdateHookinstances and drives updates.Claims the training-update stages
BEFORE_BATCH,DO_BACKWARD,DO_OPTIMIZER_STEP,AFTER_OPTIMIZER_STEP. The strategy also calls the orchestrator duringSETUPso child hooks can initialize runtime state before the first batch. Per-stage behavior is selected by directTrainingStagecomparisons to avoid per-batch multiple-dispatch overhead. See Training update hooks for the stage contract enforced by the orchestrator.- Parameters:
*hooks (TrainingUpdateHook or TrainingUpdateOrchestrator) – Hooks to compose. Any orchestrator argument is flattened into its children. Members are sorted by
priorityascending; ties preserve insertion order (Python’s stable sort).
- frequency#
Required by the
HookProtocol; always1.- Type:
int
- stage#
Set to
Noneso the registry consults_runs_on_stage.- Type:
None
- Raises:
TypeError – If any positional argument is not a
TrainingUpdateHookorTrainingUpdateOrchestrator.- Parameters:
hooks (TrainingUpdateHook | TrainingUpdateOrchestrator)
Notes
TrainingUpdateOrchestratorIS compatible with the standardHookProtocol – it is the registry-facing wrapper around one or moreTrainingUpdateHookinstances. Concrete training update hooks (EMAHook,GradientClipHook, etc.) are NOT directly Protocol-compliant on their own; they must be composed into an orchestrator before registration. The training strategy auto-wraps a bareTrainingUpdateHookfor convenience.On
DO_BACKWARDeach hook returns(_, loss); the orchestrator assignsctx.loss = lossbetween hooks so the next hook sees the transformed value.backward()is called once on the finalctx.loss. Example: a*0.5hook followed by a*2.0hook leavesctx.lossequal to the original loss before backward.- iter_hooks()[source]#
Yield child update hooks in orchestrator dispatch order.
- Return type:
Iterator[TrainingUpdateHook]
- property optimizer_step_skipped: bool#
Whether the most recent optimizer-step stage was vetoed.