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 accumulate_grad_batches on init #9652

Merged
merged 13 commits into from
Sep 24, 2021
Merged

Fix accumulate_grad_batches on init #9652

merged 13 commits into from
Sep 24, 2021

Conversation

rohitgr7
Copy link
Contributor

@rohitgr7 rohitgr7 commented Sep 22, 2021

What does this PR do?

Just a small fix to make sure that accumulate_grad_batches is an int all the time and we use gradient accumulation scheduler to define it's value.

self.trainer.accumulate_grad_batches = self.trainer.accumulation_scheduler.get_accumulate_grad_batches(0)

the reason to have this one even here though it's updated inside on_train_epoch_start is because I have seen users using it to calculate total training_steps which is usually used while defining some of the schedulers. So this is required at this point.

also in case a scheduler is passed inside callbacks then that is also taken care off now.

Does your PR introduce any breaking changes? If yes, please list them.

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 list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

Anyone in the community is welcome to review the PR.
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

Did you have fun?

Make sure you had fun coding 🙃

@rohitgr7 rohitgr7 changed the title Fix accumulate_grad_batches on init Fix accumulate_grad_batches on init Sep 22, 2021
@rohitgr7 rohitgr7 marked this pull request as ready for review September 22, 2021 21:37
@rohitgr7 rohitgr7 self-assigned this Sep 22, 2021
@github-actions
Copy link
Contributor

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

@rohitgr7 rohitgr7 added the bug Something isn't working label Sep 22, 2021
@rohitgr7 rohitgr7 added this to the v1.4.x milestone Sep 22, 2021
@codecov
Copy link

codecov bot commented Sep 22, 2021

Codecov Report

Merging #9652 (9e6cee9) into master (ce00053) will decrease coverage by 4%.
The diff coverage is 82%.

❗ Current head 9e6cee9 differs from pull request most recent head 829aa12. Consider uploading reports for the commit 829aa12 to get more accurate results

@@           Coverage Diff           @@
##           master   #9652    +/-   ##
=======================================
- Coverage      93%     89%    -4%     
=======================================
  Files         179     179            
  Lines       15286   15285     -1     
=======================================
- Hits        14177   13566   -611     
- Misses       1109    1719   +610     

@github-actions
Copy link
Contributor

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

1 similar comment
@github-actions
Copy link
Contributor

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

tests/trainer/test_trainer.py Outdated Show resolved Hide resolved
@mergify mergify bot added the ready PRs ready to be merged label Sep 23, 2021
@rohitgr7
Copy link
Contributor Author

moved the logic to callback connector since GradientAccumulateCallback is also a callback and we need to take care for that if that is passed by user inside callback. if a callback is passed we check if the other argument is passed or not.. if both are present then a minconfig error is raised (we can check it to warning if required) else callback is considered as well.

@rohitgr7 rohitgr7 removed the ready PRs ready to be merged label Sep 23, 2021
@mergify mergify bot added the ready PRs ready to be merged label Sep 23, 2021
@rohitgr7
Copy link
Contributor Author

seems like there is some issue with ipus + accumulate_grad_batches.. need to explore more on this.

@rohitgr7 rohitgr7 changed the title Fix accumulate_grad_batches on init [WIP] Fix accumulate_grad_batches on init Sep 23, 2021
@github-actions
Copy link
Contributor

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

@rohitgr7 rohitgr7 changed the title [WIP] Fix accumulate_grad_batches on init Fix accumulate_grad_batches on init Sep 24, 2021
@github-actions
Copy link
Contributor

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

1 similar comment
@github-actions
Copy link
Contributor

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

@rohitgr7
Copy link
Contributor Author

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

apologies for this.. initially I thought this is going to be a simple fix.. but turns out there were 2 more issues.

@rohitgr7 rohitgr7 enabled auto-merge (squash) September 24, 2021 18:23
@Borda
Copy link
Member

Borda commented Sep 24, 2021

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

apologies for this.. initially I thought this is going to be a simple fix.. but turns out there were 2 more issues.

That is fine, take it easy...
@tchaton the bot is quite annoying 🐰

@rohitgr7 rohitgr7 merged commit 8fcdcb5 into master Sep 24, 2021
@rohitgr7 rohitgr7 deleted the bugfix/acc_grad branch September 24, 2021 18:51
awaelchli added a commit that referenced this pull request Sep 29, 2021
Co-authored-by: Rohit Gupta <[email protected]>
Co-authored-by: Carlos Mocholí <[email protected]>
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.

6 participants