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 logging metrics in DDP mode #426

Merged
merged 14 commits into from
Sep 7, 2022
Merged

Fix logging metrics in DDP mode #426

merged 14 commits into from
Sep 7, 2022

Conversation

ashleve
Copy link
Owner

@ashleve ashleve commented Aug 23, 2022

What does this PR do?

Fixes #407

Implements logging metrics through objects instead of through values.

Wraps loss in MeanMetric to unify the way loss and accuracy are logged.

Gets rid of resetting metrics at the end of epoch since it's no longer needed when logging through metric object.

*The main motivation for this PR is no longer needing to set sync_dist=True in DDP mode to synchronize metrics across GPU processes (since synchronization is automatic when logging through metric object).

**Notice logging through metric object and logging through value gives exactly the same results:

self.log("val/loss_v1", loss_value, on_step=True, on_epoch=True)
self.log("val/loss_v2", self.val_loss, on_step=True, on_epoch=True)

image

Before submitting

  • Did you make sure title is self-explanatory and the description concisely explains the PR?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you list all the breaking changes introduced by this pull request?
  • Did you test your PR locally with pytest command?
  • Did you run pre-commit hooks with pre-commit run -a command?

Did you have fun?

Make sure you had fun coding 🙃

@ashleve ashleve added the bug Something isn't working label Aug 23, 2022
@ashleve ashleve self-assigned this Aug 23, 2022
@codecov-commenter
Copy link

codecov-commenter commented Aug 24, 2022

Codecov Report

Base: 84.59% // Head: 84.81% // Increases project coverage by +0.22% 🎉

Coverage data is based on head (f45f90c) compared to base (2f3fe86).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #426      +/-   ##
==========================================
+ Coverage   84.59%   84.81%   +0.22%     
==========================================
  Files           9        9              
  Lines         344      349       +5     
==========================================
+ Hits          291      296       +5     
  Misses         53       53              
Impacted Files Coverage Δ
src/models/mnist_module.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ashleve ashleve closed this Sep 7, 2022
@ashleve ashleve reopened this Sep 7, 2022
@ashleve ashleve merged commit 0c9ba19 into main Sep 7, 2022
@ashleve ashleve deleted the fix-metric-logging branch September 7, 2022 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: log metrics in DDP mode
2 participants