crowsonkb / k-diffusion

Karras et al. (2022) diffusion models for PyTorch
MIT License
2.26k stars 372 forks source link

Learning rate scheduler broken #50

Closed kyleliang919 closed 1 year ago

kyleliang919 commented 1 year ago

the code is calling sched.step() without epoch number, which causes the learning rate to increase rapidly essentially without warmup. https://github.com/pytorch/pytorch/blob/master/torch/optim/lr_scheduler.py

crowsonkb commented 1 year ago

The LR scheduler in train.py is being used in the per step mode rather than per epoch, which means the warmup and decay are expressed in terms of numbers of steps rather than numbers of epochs (I train a lot on huge datasets and sometimes don't actually get through one epoch). You need to use a much slower warmup than you would if it were expressed in terms of epochs.

kyleliang919 commented 1 year ago

Thanks for the clarification.