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

Refactor result handling in training loop #7506

Merged
merged 10 commits into from
May 13, 2021
Merged

Conversation

awaelchli
Copy link
Contributor

@awaelchli awaelchli commented May 12, 2021

What does this PR do?

Minor refactor, restores a tiny bit of sanity.

Removes the following state on TrainLoop:

  • _cur_step_result
  • _cur_grad_norm_dic

Fixes typo in spelling of grad_norm_dict

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 update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

Anyone in the community is free to review the PR once the tests have passed.
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 🙃

@pep8speaks
Copy link

pep8speaks commented May 12, 2021

Hello @awaelchli! Thanks for updating this PR.

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2021-05-12 22:18:05 UTC

@codecov
Copy link

codecov bot commented May 12, 2021

Codecov Report

Merging #7506 (b8ff2e0) into master (83283fd) will decrease coverage by 4%.
The diff coverage is 92%.

@@           Coverage Diff           @@
##           master   #7506    +/-   ##
=======================================
- Coverage      92%     88%    -4%     
=======================================
  Files         199     198     -1     
  Lines       13068   12837   -231     
=======================================
- Hits        12026   11269   -757     
- Misses       1042    1568   +526     

@awaelchli awaelchli added this to the v1.4 milestone May 12, 2021
@awaelchli awaelchli marked this pull request as ready for review May 12, 2021 19:24
@awaelchli awaelchli requested a review from ananthsub May 12, 2021 19:24
Comment on lines +198 to +205
def log_metrics(self, metrics, grad_norm_dict, step=None):
"""Logs the metric dict passed in.
If `step` parameter is None and `step` key is presented is metrics,
uses metrics["step"] as a step

Args:
metrics (dict): Metric values
grad_norm_dic (dict): Gradient norms
grad_norm_dict (dict): Gradient norms
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could add typehints to signature to reflect docstring

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, logger connector will be refactored
the only reason my PR touches this class is because I auto-renamed the variable everywhere.

Comment on lines 667 to 671
return AttributeDict(
signal=0,
grad_norm_dic=grad_norm_dic,
grad_norm_dict={},
training_step_output_for_epoch_end=batch_outputs,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want this more strongly typed as a dataclass instead of AttributeDict?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes good idea and attribute dict has to change as part of our refactor efforts anyway

@awaelchli awaelchli added the ready PRs ready to be merged label May 13, 2021
Copy link
Contributor

@tchaton tchaton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM !

@tchaton tchaton merged commit dd1a17b into master May 13, 2021
@tchaton tchaton deleted the refactor/training-loop-result branch May 13, 2021 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready PRs ready to be merged refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants