-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Closed
Labels
bugSomething isn't workingSomething isn't workingdocsDocumentation relatedDocumentation relatedhelp wantedOpen to be worked onOpen to be worked on
Milestone
Description
🐛 Bug
The tutorial step optimizer at arbitrary intervals has a bug/feature(*) that the closure is evaluated (with optimizer_idx=1) only every other batch, not every batch.
(*bug/feature) Note: this behavior is intended for e.g. GAN training where a part of the model is only trained every n batches, and the tutorial has the expected behavior. But the language looks like the tutorial is also applicable to people who are trying to implement accumulate_grad_batches here (Pytorch-lightning forbids us using accumulate_grad_batches if we override optimizer_step). For this use case, using the tutorial leads to the unexpected behavior.
Please reproduce using the BoringModel
To Reproduce
Difference: overrode optimizer_step, added printing in training_step.
Expected behavior
The training step is called every batch.
training_step(batch_idx=0)
training_step(batch_idx=1)
training_step(batch_idx=2)
training_step(batch_idx=3)
training_step(batch_idx=4)
training_step(batch_idx=5)
training_step(batch_idx=6)
...
Actual behavior
training_step(batch_idx=1)
training_step(batch_idx=3)
training_step(batch_idx=5)
training_step(batch_idx=7)
training_step(batch_idx=9)
training_step(batch_idx=11)
training_step(batch_idx=13)
...
Metadata
Metadata
Labels
bugSomething isn't workingSomething isn't workingdocsDocumentation relatedDocumentation relatedhelp wantedOpen to be worked onOpen to be worked on