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

summarize total size of model params in bytes #5590

Merged
merged 30 commits into from Jan 25, 2021

Conversation

kartik4949
Copy link
Contributor

@kartik4949 kartik4949 commented Jan 20, 2021

What does this PR do?

A simplified version of model size i.e only consider total params for calculating model size.
followup pr of #4810

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
  • Check that target branch and milestone match!

Did you have fun?

Make sure you had fun coding 🙃

@pep8speaks
Copy link

pep8speaks commented Jan 20, 2021

Hello @kartik4949! Thanks for updating this PR.

Line 185:73: E261 at least two spaces before inline comment
Line 392:1: E302 expected 2 blank lines, found 1

Line 43:53: E261 at least two spaces before inline comment
Line 44:55: E261 at least two spaces before inline comment
Line 44:69: W291 trailing whitespace

Comment last updated at 2021-01-25 01:10:41 UTC

@Borda Borda added the feature Is an improvement or enhancement label Jan 20, 2021
@Borda Borda added this to the 1.2 milestone Jan 20, 2021
@Borda
Copy link
Member

Borda commented Jan 20, 2021

@kartik4949 nice enhancement, mind rebase it on release/1.2-dev?

EDIT: resolved, no action needed any more...

@Borda Borda changed the base branch from master to release/1.2-dev January 20, 2021 17:04
pytorch_lightning/core/memory.py Outdated Show resolved Hide resolved
tests/core/test_memory.py Outdated Show resolved Hide resolved
pytorch_lightning/core/memory.py Outdated Show resolved Hide resolved
@kartik4949
Copy link
Contributor Author

@rohitgr7 @Borda @justusschock completed the PR, I think it's ready for merge. suggestions are welcomed :)

Copy link
Member

@awaelchli awaelchli left a comment

Choose a reason for hiding this comment

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

good work
just needs a bit more polish I think :))

pytorch_lightning/core/memory.py Outdated Show resolved Hide resolved
pytorch_lightning/core/memory.py Outdated Show resolved Hide resolved
pytorch_lightning/core/memory.py Outdated Show resolved Hide resolved
pytorch_lightning/core/memory.py Outdated Show resolved Hide resolved
pytorch_lightning/core/memory.py Outdated Show resolved Hide resolved
tests/core/test_memory.py Outdated Show resolved Hide resolved
@kartik4949
Copy link
Contributor Author

@awaelchli @rohitgr7 done with all suggested changes,
merged the two function, will separate them in follow up PR. :)

Copy link
Member

@awaelchli awaelchli left a comment

Choose a reason for hiding this comment

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

this looks super clean now. great stuff. please ping me with your follow up that you planned, I'd like to have a close look :)

@awaelchli awaelchli changed the title simplified model size calc compute total size of model params in bytes Jan 21, 2021
@awaelchli awaelchli changed the title compute total size of model params in bytes summarize total size of model params in bytes Jan 21, 2021
@awaelchli
Copy link
Member

just one final request, could you add this to the changelog file? thx

@codecov
Copy link

codecov bot commented Jan 21, 2021

Codecov Report

Merging #5590 (e6dc2ba) into release/1.2-dev (cb58fde) will increase coverage by 0%.
The diff coverage is 100%.

@@               Coverage Diff               @@
##           release/1.2-dev   #5590   +/-   ##
===============================================
  Coverage               92%     92%           
===============================================
  Files                  153     153           
  Lines                10845   10860   +15     
===============================================
+ Hits                 10022   10037   +15     
  Misses                 823     823           

@kartik4949
Copy link
Contributor Author

kartik4949 commented Jan 21, 2021

@rohitgr7
in changelog,
I should add changes in the unreleased block right?

@rohitgr7
Copy link
Contributor

@rohitgr7
in changelog,
I should add changes in the unreleased block right?

@kartik4949 yes.

@rohitgr7 rohitgr7 added the ready PRs ready to be merged label Jan 22, 2021
@kartik4949
Copy link
Contributor Author

@rohitgr7
in changelog,
I should add changes in the unreleased block right?

@kartik4949 yes.

done!

Copy link
Contributor

@gianscarpe gianscarpe left a comment

Choose a reason for hiding this comment

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

LGTM, nice feature!

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.

Overall, looks good !

pytorch_lightning/core/memory.py Show resolved Hide resolved
@kartik4949
Copy link
Contributor Author

added test to check model_size with different precision. as suggested by @rohitgr7.

@SkafteNicki SkafteNicki merged commit db78422 into Lightning-AI:release/1.2-dev Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Is an improvement or enhancement ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants