Skip to content

Commit 04d33d3

Browse files
committed
Fix(scheduler): WarmupLR inherits optimizer lr when not specified
This commit ensures that the WarmupLR scheduler correctly inherits the learning rate from the optimizer's parameters when `warmup_max_lr` is not explicitly provided in the scheduler's configuration. This prevents the scheduler from falling back to a hard-coded default value, aligning its behavior with user expectations. Fixes #7303 Signed-off-by: Vensenmu <[email protected]>#
1 parent f394e78 commit 04d33d3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

deepspeed/runtime/lr_schedules.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,13 +655,16 @@ class WarmupLR(object):
655655
def __init__(self,
656656
optimizer: Optimizer,
657657
warmup_min_lr: float = 0.0,
658-
warmup_max_lr: float = 0.001,
658+
warmup_max_lr: float = None,
659659
warmup_num_steps: int = 1000,
660660
warmup_type: str = WARMUP_LOG_RATE,
661661
last_batch_iteration: int = -1):
662662

663663
self.optimizer = get_torch_optimizer(optimizer)
664664

665+
if warmup_max_lr is None:
666+
warmup_max_lr = [group['lr'] for group in self.optimizer.param_groups][0]
667+
665668
self.min_lrs = self._format_param(self.optimizer, warmup_min_lr, "min_lr")
666669
self.max_lrs = self._format_param(self.optimizer, warmup_max_lr, "max_lr")
667670
self.delta_lrs = [big - small for big, small in zip(self.max_lrs, self.min_lrs)]

0 commit comments

Comments
 (0)