-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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 an issue that caused Lightning to extract the batch size even though it was set by the user in LightningModule.log
#10408
Conversation
151647b
to
04314b8
Compare
extract_batch_size
only when its required
pytorch_lightning/trainer/connectors/logger_connector/logger_connector.py
Outdated
Show resolved
Hide resolved
if we do this, then we will have two different ways by which user can define their batch size. One will be this hook and another one will be |
To add to @rohitgr7 point,
@carmocca @awaelchli @SeanNaren Any thoughts ? |
…g` (#10408) Co-authored-by: Carlos Mocholi <carlossmocholi@gmail.com>
…g` (Lightning-AI#10408) Co-authored-by: Carlos Mocholi <carlossmocholi@gmail.com>
…g` (#10408) Co-authored-by: Carlos Mocholi <carlossmocholi@gmail.com>
…g` (#10408) Co-authored-by: Carlos Mocholi <carlossmocholi@gmail.com>
# Why? In #11 and #12 we see that updates to the occwl library introduced breaking changes which were not spotted in the example notebooks. Thank you to @[cteqeu](https://github.com/cteqeu) for reporting the issues and @[akashaero](https://github.com/akashaero) for sharing the workaround. This PR addresses the problems # What? - A new version of occwl is released [see here](https://github.com/AutodeskAILab/occwl/releases/tag/v1.0.0). We now fix the version of occwl to this version to avoid further unexpected breakage. - In [jupyter_segmentation_viewer.py](visualization/jupyter_segmentation_viewer.py) we remove the calls to the removed functions. - All the notebooks are rerun and retested. - Some warnings were firing in [pytorch-lightning](Lightning-AI/pytorch-lightning#10408). To ensure that all metrics are computed correctly we pass the number of faces to the logger as the batch size. Notice that the IoU and accuracy metrics reported in [the paper](https://arxiv.org/abs/2104.00706) are per-face rather than per solid. - In [scale_utils.py](utils/scale_utils.py) we make use of the scaling function in occwl rather than re-implementing it here.
What does this PR do?
Fixes: #10349 (comment)
Fixes: #10576
Seems like after we added the warning to check for batch_size for an ambiguous batch, a few users realized that the batch_size used internally isn't correct. We always make a call to extract batch size even when it's set by the user explicitly inside
self.log(batch_size=...)
which IMO is not required because we have a recursive call to extract batch size which causes unnecessary extraction for it even when it's not required plus it will raise a warning if someone specifies it and we still look for it. So now the call will be made inside.log
only when batch_size is not specified.In short: this fixes an issue that caused Lightning to extract the batch size even though it was set by the user in
LightningModule.log
.So an overview of the solution is:
track the batch and use it to extract batch_size inside
self.log
call when it's not specified explicitly and metric is being logged withon_epoch=True
and will be averaged at the end.Does your PR introduce any breaking changes? If yes, please list them.
Before submitting
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:
Did you have fun?
Make sure you had fun coding 🙃
cc @Borda @carmocca @edward-io @ananthsub