[bugfix] Changed CometLogger to stop modifying metrics in place#9150
Conversation
…ore calling val.cpu().detach()
awaelchli
left a comment
There was a problem hiding this comment.
@sohamtiwari3120 looking pretty good!
would you mind adding a changelog entry too in the file CHANGELOG.md?
Codecov Report
@@ Coverage Diff @@
## master #9150 +/- ##
=======================================
- Coverage 92% 88% -4%
=======================================
Files 176 176
Lines 14870 14825 -45
=======================================
- Hits 13719 13059 -660
- Misses 1151 1766 +615 |
|
Hi @awaelchli! |
akihironitta
left a comment
There was a problem hiding this comment.
LGTM once the test is added!
Hi @akihironitta I modified the log_metrics function. So should I test whether the metrics dictionary is changing or not? Or you're talking about some other test. Thanks! |
|
So you want to test that metrics are no longer changed inplace when we call metrics=dict(mymetric=Mock())
logger.log_metrics(metrics)
metrics["mymetric"].cpu.assert_not_called()This would go into the file |
Head branch was pushed to by a user without write access
…tps://github.com/sohamtiwari3120/pytorch-lightning into bug/7021_comet_logger_modifying_metrics_in_place
|
Hi @awaelchli @tchaton Sincerely, |
|
looks pretty good! fingers crossed it passes :) |
|
@awaelchli it seems that the test I added worked finally! 😄 |
removed changes for tests from changelog, that should not be mentioned Co-authored-by: Adrian Wälchli <aedu.waelchli@gmail.com>
|
Hi! Do I need to make any further changes to the PR for it to auto-merge? Or should I leave it as it is now? Thanks |
Co-authored-by: Adrian Wälchli <aedu.waelchli@gmail.com> Co-authored-by: Carlos Mocholí <carlossmocholi@gmail.com>
Co-authored-by: Adrian Wälchli <aedu.waelchli@gmail.com> Co-authored-by: Carlos Mocholí <carlossmocholi@gmail.com>
What does this PR do?
modified log_metrics() in comet.py to make a copy of metrics dictionary before calling val.cpu().detach(), hence preventing metrics from being changed in place.
Fixes #7021
Does your PR introduce any breaking changes? If yes, please list them.
None
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 🙃