Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix global step update when the epoch is skipped #7677

Merged
merged 3 commits into from
May 24, 2021

Conversation

carmocca
Copy link
Contributor

@carmocca carmocca commented May 24, 2021

What does this PR do?

When the epoch is skipped (on_train_batch_start returns -1), global_step is still updated.

This to me is wrong, even though we have tests for the previous behavior.
Added by @ydcjeff in #3700

Part of #7357

Before submitting

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • [n/a] Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

@carmocca carmocca added the bug Something isn't working label May 24, 2021
@carmocca carmocca added this to the v1.3.x milestone May 24, 2021
@carmocca carmocca self-assigned this May 24, 2021
@codecov
Copy link

codecov bot commented May 24, 2021

Codecov Report

Merging #7677 (6b5da9b) into master (0c958c5) will decrease coverage by 0%.
The diff coverage is 100%.

@@          Coverage Diff           @@
##           master   #7677   +/-   ##
======================================
- Coverage      93%     92%   -0%     
======================================
  Files         200     200           
  Lines       12955   12965   +10     
======================================
- Hits        11991   11964   -27     
- Misses        964    1001   +37     

@@ -229,26 +229,6 @@ def train_dataloader(self):
trainer.fit(model)


@pytest.mark.parametrize('max_epochs,batch_idx_', [(2, 5), (3, 8), (4, 12)])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the test since it is testing more of the training loop internals than the model hook itself.

model = CurrentModel()
trainer = Trainer(max_epochs=max_epochs, limit_train_batches=10)
trainer.fit(model)
if batch_idx_ > trainer.num_training_batches - 1:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if was not running previously with the previous condition

@tchaton tchaton merged commit 8b01497 into master May 24, 2021
@tchaton tchaton deleted the bugfix/global_step_skip_epoch branch May 24, 2021 16:36
awaelchli added a commit that referenced this pull request May 25, 2021
awaelchli added a commit that referenced this pull request May 25, 2021
* Fix global step update when the epoch is skipped

* Update CHANGELOG

* Move test
@Borda Borda mentioned this pull request May 25, 2021
Borda pushed a commit that referenced this pull request May 26, 2021
* Fix global step update when the epoch is skipped

* Update CHANGELOG

* Move test
lexierule pushed a commit that referenced this pull request May 26, 2021
* Fix global step update when the epoch is skipped

* Update CHANGELOG

* Move test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants