pytorch-lightning
pytorch-lightning copied to clipboard
Add `step` parameter to `TensorBoardLogger.log_hyperparams`
What does this PR do?
Adds a step parameter to TensorBoardLogger.log_hyperparams. This also mirrors the global_step param of torch.utils.tensorboard.SummaryWriter.add_hparams.
Currently, the metrics that get logged using this method are always logged to step 0:
https://github.com/Lightning-AI/pytorch-lightning/blob/2129fdf3622e39ba46be4e1139af408e7e951cf3/src/lightning/fabric/loggers/tensorboard.py#L246
so no meaningful graph is made for the metrics passed to TensorBoardLogger.log_hyperparams. torch.utils.tensorboard.SummaryWriter.add_hparams had the same problem until global_step was added:
- https://github.com/pytorch/pytorch/pull/109572
I added these changes to my local run and this is what I see now when I call self.logger.log_hyperparams(hparams, metrics=metrics, step=step):
Compared to before (2 epochs in, but you wouldn't know):
Before submitting
- Was this discussed/agreed via a GitHub issue? (not for typos and docs)
- [x] Did you read the contributor guideline, Pull Request section?
- [x] 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 minor internal changes/refactors)
PR review
Anyone in the community is welcome to review the PR. Before you start reviewing, make sure you have read the review guidelines. In short, see the following bullet-list:
Reviewer checklist
- [ ] 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
📚 Documentation preview 📚: https://pytorch-lightning--20176.org.readthedocs.build/en/20176/
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 88%. Comparing base (
9709c64) to head (cee2f3b). Report is 37 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #20176 +/- ##
=======================================
Coverage 88% 88%
=======================================
Files 267 267
Lines 23382 23382
=======================================
Hits 20479 20479
Misses 2903 2903
🚀 New features to boost your workflow:
- ❄ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
Is this good to merge?
Thank you @ringohoffman for the contribution!