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

Disable training with zero num_training_batches when insufficient limit_train_batches #5703

Merged
merged 13 commits into from
Feb 3, 2021

Conversation

kaushikb11
Copy link
Contributor

@kaushikb11 kaushikb11 commented Jan 29, 2021

What does this PR do?

Training should be disabled when limit_train_batches is float, and num_training_batches == int(num_training_batches * limit_train_batches) == 0, this would be lead to zero num_training_batches. But the Training wasn't being skipped, while still doing 1 step per epoch. This PR addresses the issue.

Fixes #5029

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)
  • 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

Anyone in the community is free to review the PR once the tests have passed.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:

  • 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
  • Check that target branch and milestone match!

Did you have fun?

Make sure you had fun coding 🙃

@pep8speaks
Copy link

pep8speaks commented Jan 29, 2021

Hello @kaushikb11! Thanks for updating this PR.

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2021-02-02 17:06:55 UTC

@kaushikb11 kaushikb11 added the bug Something isn't working label Jan 29, 2021
@kaushikb11 kaushikb11 marked this pull request as draft January 29, 2021 12:39
pytorch_lightning/trainer/training_loop.py Outdated Show resolved Hide resolved
pytorch_lightning/trainer/training_loop.py Outdated Show resolved Hide resolved
tests/trainer/test_trainer.py Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jan 30, 2021

Codecov Report

Merging #5703 (0c65d55) into master (793fe73) will decrease coverage by 0%.
The diff coverage is 100%.

@@          Coverage Diff           @@
##           master   #5703   +/-   ##
======================================
- Coverage      90%     89%   -0%     
======================================
  Files         134     134           
  Lines       10057   10053    -4     
======================================
- Hits         9010    8982   -28     
- Misses       1047    1071   +24     

@kaushikb11 kaushikb11 marked this pull request as ready for review January 30, 2021 12:09
Copy link
Contributor

@rohitgr7 rohitgr7 left a comment

Choose a reason for hiding this comment

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

lgtm!

pytorch_lightning/trainer/training_loop.py Show resolved Hide resolved
@Borda Borda added the ready PRs ready to be merged label Feb 2, 2021
@Borda Borda enabled auto-merge (squash) February 2, 2021 08:47
@Borda Borda merged commit ba04bb3 into Lightning-AI:master Feb 3, 2021
tchaton pushed a commit that referenced this pull request Feb 5, 2021
…it_train_batches (#5703)

* disable training when zero num_train_batches with limit_train_batches

* refactor train skip condition

* fix formatting issues

* fix formatting issues

* ref: test error msg

* fix tests for data loader calls

* fix train dataloader condition

* update limit_train_batches upper range in test comment

* remove model state check test

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Borda pushed a commit that referenced this pull request Feb 5, 2021
…it_train_batches (#5703)

* disable training when zero num_train_batches with limit_train_batches

* refactor train skip condition

* fix formatting issues

* fix formatting issues

* ref: test error msg

* fix tests for data loader calls

* fix train dataloader condition

* update limit_train_batches upper range in test comment

* remove model state check test

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Borda pushed a commit that referenced this pull request Feb 5, 2021
…it_train_batches (#5703)

* disable training when zero num_train_batches with limit_train_batches

* refactor train skip condition

* fix formatting issues

* fix formatting issues

* ref: test error msg

* fix tests for data loader calls

* fix train dataloader condition

* update limit_train_batches upper range in test comment

* remove model state check test

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Behaviour when limit_train_batches is float is inconsistent
6 participants