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

Changed the model size calculation using ByteCounter #10123

Merged
merged 10 commits into from
Nov 1, 2021
Merged

Conversation

rohitgr7
Copy link
Contributor

@rohitgr7 rohitgr7 commented Oct 25, 2021

What does this PR do?

Fixes #10074
all credits to @ruro :)
Tests are already there for get_model_size_mb

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 🙃

@rohitgr7 rohitgr7 changed the title use bytecounter Add ByteCounter to calculate model size Oct 25, 2021
@rohitgr7 rohitgr7 added this to the v1.5 milestone Oct 25, 2021
@rohitgr7 rohitgr7 added the feature Is an improvement or enhancement label Oct 25, 2021
@tchaton
Copy link
Contributor

tchaton commented Oct 25, 2021

Hey @rohitgr7,

I believe we should also have a version for DeepSpeed FSDP which reduces the number of bytes across processes.

Best,
T.C

@rohitgr7
Copy link
Contributor Author

Hey @rohitgr7,

I believe we should also have a version for DeepSpeed FSDP which reduces the number of bytes across processes.

Best, T.C

will have a look. maybe in a separate one?

@rohitgr7
Copy link
Contributor Author

@tchaton couldn't find a way to support this for Deepspeed/FSDP. Discussed this with @SeanNaren too and seems like its right not practically possible since weights are sharded and are not kept in a readable format. I'd suggest for now we can merge this for v1.5 and later we can explore more.

@rohitgr7 rohitgr7 marked this pull request as ready for review October 30, 2021 20:09
@rohitgr7 rohitgr7 requested a review from justusschock October 30, 2021 20:09
@rohitgr7 rohitgr7 requested a review from kaushikb11 November 1, 2021 10:21
Copy link
Contributor

@kaushikb11 kaushikb11 left a comment

Choose a reason for hiding this comment

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

LGTM! Could you add it to the class that it's not supported by DeepSpeed and Sharded plugins.

@mergify mergify bot added the has conflicts label Nov 1, 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 !

@rohitgr7 rohitgr7 enabled auto-merge (squash) November 1, 2021 11:27
@mergify mergify bot added ready PRs ready to be merged and removed has conflicts labels Nov 1, 2021
@codecov
Copy link

codecov bot commented Nov 1, 2021

Codecov Report

Merging #10123 (16d6c9a) into master (a1fe5ba) will decrease coverage by 1%.
The diff coverage is 100%.

❗ Current head 16d6c9a differs from pull request most recent head 249fd8e. Consider uploading reports for the commit 249fd8e to get more accurate results

@@           Coverage Diff            @@
##           master   #10123    +/-   ##
========================================
- Coverage      92%      92%    -1%     
========================================
  Files         181      182     +1     
  Lines       16408    17108   +700     
========================================
+ Hits        15175    15700   +525     
- Misses       1233     1408   +175     

Copy link
Contributor

@SeanNaren SeanNaren left a comment

Choose a reason for hiding this comment

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

Looks good! can we add an issue around FSDP/DeepSpeed support for summarization of model size? As @tchaton mentioned it is possible, just will require some thought/implementation

pytorch_lightning/utilities/memory.py Outdated Show resolved Hide resolved
pytorch_lightning/core/lightning.py Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@rohitgr7 rohitgr7 changed the title Add ByteCounter to calculate model size Changed the model size calculation using `ByteCounter Nov 1, 2021
@rohitgr7 rohitgr7 changed the title Changed the model size calculation using `ByteCounter Changed the model size calculation using ByteCounter Nov 1, 2021
@rohitgr7 rohitgr7 disabled auto-merge November 1, 2021 15:08
@rohitgr7 rohitgr7 enabled auto-merge (squash) November 1, 2021 15:08
@rohitgr7 rohitgr7 merged commit b77aa71 into master Nov 1, 2021
@rohitgr7 rohitgr7 deleted the add/byte_counter branch November 1, 2021 16:42
@rohitgr7 rohitgr7 mentioned this pull request Nov 2, 2021
12 tasks
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.

get_model_size_mb (LightningModule.model_size) shouldn't create temporary files in the current directory
7 participants