Skip to content

Commit da41f5b

Browse files
committed
fix outer lr schedulng
1 parent 532af19 commit da41f5b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

open_diloco/train_fsdp.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,14 @@ def _get_lr_outer(
209209
*,
210210
num_warmup_steps: int,
211211
num_training_steps: int,
212+
num_cycles: float,
212213
min_lr_rate: float = 0.0,
213214
):
214215
if current_step < num_warmup_steps:
215216
return 1
216217

217218
progress = float(current_step - num_warmup_steps) / float(max(1, num_training_steps - num_warmup_steps))
218-
factor = 0.5 * (1.0 + math.cos(math.pi * 2.0 * progress))
219+
factor = 0.5 * (1.0 + math.cos(math.pi * float(num_cycles) * 2.0 * progress))
219220
factor = factor * (1 - min_lr_rate) + min_lr_rate
220221
return max(0, factor)
221222

@@ -226,6 +227,7 @@ def get_lr_outer(optimizer, config: Config):
226227
num_warmup_steps=config.warmup_steps,
227228
# num_training_steps=config.total_steps,
228229
num_training_steps=config.total_steps / 4,
230+
num_cycles=0.5,
229231
)
230232
return LambdaLR(optimizer, lambda_lr, -1)
231233

0 commit comments

Comments
 (0)