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

Add enable_model_summary flag and deprecate weights_summary #9699

Merged

Conversation

ananthsub
Copy link
Contributor

@ananthsub ananthsub commented Sep 25, 2021

What does this PR do?

Fixes #9043
Adds enable_model_summary flag to match enable_progress_bar flag being added here: #9664

This PR also deprecates the Trainer weights_summary flag and property which dictated the mode for display. Users are expected to customize this with the callback. This deprecation was required because we needed to support arbitrary module depths for summarization (int) while the current mode only supported a few fixed modes ("top" vs "full"). This customization is much easier with the ModelSummary callbacks @kaushikb11 introduced.

Does your PR introduce any breaking changes? If yes, please list them.

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 list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

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:

  • 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 🙃

@ananthsub ananthsub added callback deprecation Includes a deprecation labels Sep 25, 2021
@ananthsub ananthsub changed the title Add enable_model_summary flag Add enable_model_summary flag and deprecate weights_summary Sep 25, 2021
@ananthsub ananthsub added this to the v1.5 milestone Sep 25, 2021
@ananthsub ananthsub force-pushed the feat/add-enable-model-summary-flag branch from 3a7328b to d83ed9d Compare September 30, 2021 07:03
@mergify mergify bot removed the has conflicts label Sep 30, 2021
@ananthsub ananthsub force-pushed the feat/add-enable-model-summary-flag branch from 075fb46 to 8de7fd5 Compare September 30, 2021 07:30
Copy link
Contributor

@rohitgr7 rohitgr7 left a comment

Choose a reason for hiding this comment

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

LG!. Just some minor comments.

docs/source/common/trainer.rst Outdated Show resolved Hide resolved
docs/source/common/trainer.rst Show resolved Hide resolved
@ananthsub ananthsub force-pushed the feat/add-enable-model-summary-flag branch from 877d0bf to 4e87889 Compare September 30, 2021 07:53
@codecov
Copy link

codecov bot commented Sep 30, 2021

Codecov Report

Merging #9699 (799fdf7) into master (4610fdd) will decrease coverage by 4%.
The diff coverage is 100%.

@@           Coverage Diff           @@
##           master   #9699    +/-   ##
=======================================
- Coverage      93%     89%    -4%     
=======================================
  Files         178     178            
  Lines       15653   15671    +18     
=======================================
- Hits        14511   13920   -591     
- Misses       1142    1751   +609     

@kaushikb11
Copy link
Contributor

kaushikb11 commented Sep 30, 2021

Do we need the enable_ prefix? I think model_summary is straightforward as it is a boolean flag.

@ananthsub
Copy link
Contributor Author

ananthsub commented Sep 30, 2021

Do we need the enable_ prefix? I think model_summary is straightforward as it is a boolean flag.

This also came up in these places:
#9616 (comment)
#9664 (comment)
#9754 (comment)

Options so far:

  1. Use enable_ as a prefix
  • Pros:
    • consistent naming sceheme: users can scan through the trainer flags and see what features are enabled by default by the Trainer
    • enable_ as a a prefix indicates these are booleans
  • Cons:
    • More verbose
  1. Directly use the name. e.g. model_summary, progress_bar, checkpointing
  • Pros:
    • Less verbose
  • Cons:
    • May have confusion with the callback implementation (e.g. model_summary as a flag: does it take the ModelSummary callback? or a boolean? would trainer.model_summary be the callback instance, or the boolean flag passed into the trainer?
  1. Other options?

@PyTorchLightning/core-contributors

Poll:

Option 1 -> 👍
Option 2 -> 🚀
Other -> comment

@mergify mergify bot added the has conflicts label Oct 1, 2021
@daniellepintz
Copy link
Contributor

daniellepintz commented Oct 4, 2021

I am strongly in favor of option 1. To expand on "consistent naming scheme" you mentioned, consider these Trainer arguments:

  • profiler of type BaseProfiler
  • accelerator of type Accelerator
  • logger of type LightningLoggerBase

if I were reading these arguments and then saw one named model_summary I would assume it to be of type ModelSummary.

IMO boolean argument names should be prefixed with a verb, such as enable_progress_bar, reload_dataloaders_every_epoch, terminate_on_nan, move_metrics_to_cpu

@daniellepintz
Copy link
Contributor

Question: under what circumstances would users want to disable the model summary? Is it critical we have this flag?

docs/source/common/debugging.rst Outdated Show resolved Hide resolved
@carmocca
Copy link
Contributor

carmocca commented Oct 5, 2021

under what circumstances would users want to disable the model summary? Is it critical we have this flag?

Maybe the summary is not correct for your model, maybe you are calling fit multiple times and you don't want it to appear repeatedly...

@daniellepintz
Copy link
Contributor

Maybe the summary is not correct for your model, maybe you are calling fit multiple times and you don't want it to appear repeatedly...

Hmm, if the summary is not correct that sounds like a bug, and we should operate under the assumption that we have no bugs. The other case seems pretty rare, but I don't have a lot of background knowledge here so don't feel strongly

@ananthsub ananthsub force-pushed the feat/add-enable-model-summary-flag branch from 3a1c155 to fe8d615 Compare October 6, 2021 20:25
@mergify mergify bot added ready PRs ready to be merged and removed has conflicts labels Oct 6, 2021
CHANGELOG.md Outdated Show resolved Hide resolved
@daniellepintz
Copy link
Contributor

@williamFalcon makes sense, I agree user experience is very important and didn’t mean to suggest otherwise!

@mergify mergify bot added the has conflicts label Oct 7, 2021
Copy link
Contributor

@rohitgr7 rohitgr7 left a comment

Choose a reason for hiding this comment

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

LG!

@kaushikb11 kaushikb11 self-assigned this Oct 12, 2021
@mergify mergify bot removed the has conflicts label Oct 13, 2021
Co-authored-by: Adrian Wälchli <aedu.waelchli@gmail.com>
@kaushikb11 kaushikb11 enabled auto-merge (squash) October 13, 2021 09:37
@kaushikb11 kaushikb11 merged commit 28fc8d2 into Lightning-AI:master Oct 13, 2021
rohitgr7 pushed a commit to Tshimanga/pytorch-lightning that referenced this pull request Oct 18, 2021
…tning-AI#9699)

Co-authored-by: Adrian Wälchli <aedu.waelchli@gmail.com>
Co-authored-by: Kaushik B <45285388+kaushikb11@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Kaushik B <kaushikbokka@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
callback deprecation Includes a deprecation ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC] Deprecate weights_summary off the Trainer constructor
10 participants