Skip to content

Commit f5bffea

Browse files
committed
fix outer lr schedulng
1 parent b386b65 commit f5bffea

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
@@ -208,13 +208,14 @@ def _get_lr_outer(
208208
*,
209209
num_warmup_steps: int,
210210
num_training_steps: int,
211+
num_cycles: float,
211212
min_lr_rate: float = 0.0,
212213
):
213214
if current_step < num_warmup_steps:
214215
return 1
215216

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

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

0 commit comments

Comments
 (0)