nemo_automodel.components.training.step_scheduler
nemo_automodel.components.training.step_scheduler
Module Contents
Classes
Functions
Data
API
Bases: Stateful
Scheduler for managing gradient accumulation and checkpointing steps.
Epoch iterator.
Returns whether this step needs to call the checkpoint saving.
Returns whether this step needs to run manual garbage collection.
Returns whether this is the last batch for this epoch.
Returns whether the current step is the final training step.
Training stops at whichever comes first: reaching max_steps or
exhausting the configured number of epochs (see __iter__ and
epochs). max_steps alone is therefore not enough to detect the
end — a small dataset can run out of epochs long before max_steps
is hit (e.g. max_steps=100 with only 60 steps’ worth of data). In
that case the last batch of the last epoch is the final step. Detect it
so the final checkpoint and consolidated export — which key off this
flag (see is_ckpt_step and the recipes’ is_final_checkpoint) —
are still written.
Returns whether this step should log to remote services (WandB, MLflow, etc.).
Returns whether this step needs to call the validation.
Returns whether SIGTERM was received.
Iterates over dataloader while keeping track of counters.
Raises:
StopIteration: If the dataloader was exhausted or max_steps was reached.
Yield complete accumulation windows after collective availability checks.
The only buffered data is the current optimizer step, as in the native iterator. There is no next-step lookahead that could advance checkpointed data progress.
Returns: Iterator[list[Mapping[str, object]]]
Iterator of microbatch mappings passed through without mutation. Tensor fields
Load the scheduler state from a dictionary.
Parameters:
Dictionary containing ‘step’ and ‘epoch’.
Set the epoch for the sampler and the collate function.
The collate function is notified as well as the sampler because a collator may derive per-epoch augmentation from the epoch. Only this scheduler’s dataloader is touched, so a separately built validation loader keeps a fixed epoch and therefore a fixed augmentation mix.
Get the current state of the scheduler.
Returns:
Current state with ‘step’ and ‘epoch’ keys.
User-facing step scheduler configuration.
These fields correspond to the YAML-configurable parameters of the
training loop. Runtime-only values (dataloader, dp_size,
local_batch_size) are passed separately to build_step_scheduler.
Save a checkpoint every N optimizer steps.
None defaults to once per epoch.
Force gc.collect() every N steps.
None disables manual GC.
Total samples per optimizer step across all GPUs.
Log to WandB / MLflow every N steps.
Rolling window size for averaged training loss metrics.
Hard cap on optimizer steps. None means derive from
num_epochs * epoch_len.
Number of training epochs. When None the builder
derives it from max_steps. Default: 10.
Signal(s) that trigger a graceful preemption checkpoint, each given as
a signal number, name (e.g. "SIGTERM"), or a list thereof. None disables
preemption checkpointing. Default: "SIGTERM".
Also checkpoint at every epoch boundary.
Initial epoch (for checkpoint resume).
Initial global step (for checkpoint resume).
Run validation every N optimizer steps.
None disables periodic validation.
Also run validation on checkpoint steps.
Build the step scheduler.
Parameters:
The training dataloader, or None when max_steps is explicit.
The size of the data parallel group.
The size of the local batch.
Process group whose ranks participate in distributed signal handling. All ranks participating in training must also agree on stream completion.
Whether to coordinate complete accumulation windows and
stop at final source exhaustion without restarting the loader. None
uses the loader’s synchronized_stream capability, defaulting to False.
Returns: StepScheduler
Configured StepScheduler.
Calculate the maximum number of steps.
Calculate the number of epochs out of maximum number of steps.