nemo_automodel.components.optim.scheduler
nemo_automodel.components.optim.scheduler
Learning rate decay and weight decay incr functions.
Module Contents
Classes
Functions
Data
API
Anneals learning rate and weight decay.
Parameters:
the optimizer to be used
initial learning rate
maximum learning rate
minimum learning rate
number of warmup steps
number of decay steps
decay style for learning rate
initial weight decay
final weight decay
number of weight decay increment steps
weight decay increment style
whether to use the checkpoint values for the optimizer param scheduler. Defaults to True.
whether to override the optimizer param scheduler values with the class values. Defaults to False.
number of weight decay decay steps. Defaults to None.
decay style for learning rate during weight decay decay steps. Defaults to None.
Return a string representation of the OptimizerParamScheduler.
Auxiliary function for checking the values in the checkpoint and setting them.
Parameters:
class value
checkpoint value
name of the parameter
Learning rate decay functions from: https://openreview.net/pdf?id=BJYwwY9ll pg. 4.
Argsa: param_group (dict): parameter group from the optimizer.
Weight decay incr functions.
Load the state dict.
Every restored field is applied before the final step call, so the
learning rate and weight decay written into optimizer.param_groups both
reflect the checkpoint’s schedule rather than the constructor’s. The step
count is treated as absolute, so loading is idempotent.
Parameters:
state dict to be load
Return the state dict.
Set lr and weight decay for all parameter groups.
Each group gets the scheduled value times its lr_mult / wd_mult (see _set_group_mults).
Parameters:
number of steps to increment
Return value as a float, or None when it is not numeric (e.g. relative-step Adafactor’s lr=None).
Store each param group’s constructed lr / weight_decay as lr_mult / wd_mult relative to group 0.
OptimizerParamScheduler.step rewrites every group’s lr and weight_decay from the schedule, so a
group built with its own values (a no-decay group, a separate head LR) would otherwise be reset to the base
schedule. LRSchedulerConfig.build reads the schedule’s base values from group 0, so each group keeps its ratio
to group 0 as a multiplier. The multipliers live in the param groups, so they are saved with the optimizer and
restored on resume instead of being recomputed from the resumed run’s config.
A group that already carries lr_mult (or a per-group max_lr / min_lr) or wd_mult keeps it
unchanged. Every other group, group 0 included, gets both keys so the saved param-group layout does not depend
on which groups happen to differ from group 0. The multiplier is 1.0 when group 0’s value is zero or non-numeric
(e.g. relative-step Adafactor’s lr=None).
Parameters:
Optimizer whose param groups still hold their constructed values.