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

Enable dumping raw prof files in AdvancedProfiler #19703

Merged

Conversation

clumsy
Copy link
Contributor

@clumsy clumsy commented Mar 26, 2024

What does this PR do?

Adding a new dump_stats flag to AdvanedProfiler to persist .prof files collected during profiling. These files can be visualized by SnakeViz like so: snakeviz fit-run-[Strategy]DDPStrategy.on_train_end.prof

Screenshot 2024-03-26 at 10 04 17 AM

A .prof file is created for each profiled action, e.g.:

...
fit-run-[Strategy]DDPStrategy.on_train_end.prof
fit-run-[Callback]TQDMProgressBar.on_fit_end.prof
fit-run-[Callback]ModelSummary.on_fit_end.prof
fit-run-[Callback]ModelCheckpoint{'monitor': None, 'mode': 'min', 'every_n_train_steps': 0, 'every_n_epochs': 1, 'train_time_interval': None}.on_fit_end.prof
fit-run-[Callback]LearningRateMonitor.on_fit_end.prof
...

Fixes #19698

No breaking changes, adding a new backward-compatible flag, with the new functionality disabled by default.

Before submitting
  • Was this discussed/agreed 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 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--19703.org.readthedocs.build/en/19703/

@github-actions github-actions bot added the pl Generic label for PyTorch Lightning package label Mar 26, 2024
@clumsy
Copy link
Contributor Author

clumsy commented Mar 26, 2024

For your consideration, @awaelchli

@clumsy clumsy force-pushed the feat/advanced_profiler_dump_stats branch from cf1947c to 0c21547 Compare March 26, 2024 14:31
@clumsy
Copy link
Contributor Author

clumsy commented Apr 8, 2024

Are there any concerns about this change, @awaelchli? Thanks!

@clumsy
Copy link
Contributor Author

clumsy commented Jun 7, 2024

Just bumping this one in case it got lost in notifications, @awaelchli.

Copy link
Contributor

@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.

@clumsy Looks great to me. Just a few minor comments

src/lightning/pytorch/profilers/advanced.py Outdated Show resolved Hide resolved
src/lightning/pytorch/profilers/advanced.py Outdated Show resolved Hide resolved
src/lightning/pytorch/profilers/advanced.py Outdated Show resolved Hide resolved
src/lightning/pytorch/profilers/advanced.py Outdated Show resolved Hide resolved
src/lightning/pytorch/profilers/advanced.py Outdated Show resolved Hide resolved
@awaelchli awaelchli changed the title feat: add dump_stats to advanced profiler (#19698) Enable dumping raw prof files in AdvancedProfiler Jun 9, 2024
@mergify mergify bot removed the has conflicts label Jun 16, 2024
@clumsy clumsy force-pushed the feat/advanced_profiler_dump_stats branch from 0c21547 to 8ae52ef Compare June 21, 2024 01:59
@clumsy
Copy link
Contributor Author

clumsy commented Jun 21, 2024

Thanks for checking, @awaelchli! I've addressed your comments. Please let me know if the are remaining concerns.

src/lightning/pytorch/CHANGELOG.md Outdated Show resolved Hide resolved
src/lightning/pytorch/profilers/advanced.py Outdated Show resolved Hide resolved
tests/tests_pytorch/profilers/test_profiler.py Outdated Show resolved Hide resolved
@awaelchli awaelchli added feature Is an improvement or enhancement profiler community This PR is from the community labels Jun 21, 2024
@awaelchli awaelchli added this to the 2.4 milestone Jun 21, 2024
@awaelchli
Copy link
Contributor

@clumsy Are you still interested in finishing the PR? I think it's very close to land.

@clumsy clumsy force-pushed the feat/advanced_profiler_dump_stats branch from ff6fe92 to 4dfc086 Compare July 15, 2024 13:47
@clumsy
Copy link
Contributor Author

clumsy commented Jul 15, 2024

Sure, addressed the comments, @awaelchli

Copy link

codecov bot commented Jul 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82%. Comparing base (2dc9c3d) to head (4dfc086).
Report is 55 commits behind head on master.

❗ There is a different number of reports uploaded between BASE (2dc9c3d) and HEAD (4dfc086). Click for more details.

HEAD has 85 uploads less than BASE
Flag BASE (2dc9c3d) HEAD (4dfc086)
cpu 40 21
lightning 33 17
pytest 25 3
python3.9 12 6
python3.10 11 6
python3.11 12 6
lightning_fabric 6 0
gpu 6 3
python3.12 5 3
Additional details and impacted files
@@            Coverage Diff            @@
##           master   #19703     +/-   ##
=========================================
- Coverage      91%      82%     -9%     
=========================================
  Files         266      263      -3     
  Lines       22968    22931     -37     
=========================================
- Hits        20799    18755   -2044     
- Misses       2169     4176   +2007     

@awaelchli
Copy link
Contributor

Nice @clumsy thank you for addressing the remaining comments.

@awaelchli awaelchli merged commit 74470a6 into Lightning-AI:master Jul 15, 2024
76 checks passed
@clumsy clumsy deleted the feat/advanced_profiler_dump_stats branch July 15, 2024 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community This PR is from the community feature Is an improvement or enhancement pl Generic label for PyTorch Lightning package profiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dump prof files from AdvancedProfiler
3 participants