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

torch/csrc/profiler/README.md - stubs, RecordFunction, Autograd interaction #108470

Closed

Conversation

davidberard98
Copy link
Contributor

@davidberard98 davidberard98 commented Sep 2, 2023

Stack from ghstack (oldest at bottom):

Technical details about the profiler - stubs for the stuff I haven't had time to fill out yet, plus details about RecordFunction and the profiler's interaction with autograd.

reviewers - see https://github.com/pytorch/pytorch/blob/06c41eea9e37b5799e4f14601c95fa7810297759/torch/csrc/profiler/README.md for rendered markdown

Technical details about the profiler.

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Sep 2, 2023

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/108470

Note: Links to docs will display an error until the docs builds have been completed.

⏳ 1 Pending, 2 Unrelated Failures

As of commit e249949 with merge base bde75eb (image):

UNSTABLE - The following jobs failed but were likely due to flakiness present on trunk and has been marked as unstable:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot bot added topic: not user facing topic category labels Sep 2, 2023
davidberard98 added a commit that referenced this pull request Sep 2, 2023
Technical details about the profiler.

ghstack-source-id: 1a8123894b5fe4237e33a97eb884d3a2312371b8
Pull Request resolved: #108470
Technical details about the profiler.

[ghstack-poisoned]
davidberard98 added a commit that referenced this pull request Sep 7, 2023
Technical details about the profiler.

ghstack-source-id: 3a69bad5dac53f14d2b2ed84c184b79d63d0f301
Pull Request resolved: #108470
@davidberard98 davidberard98 changed the title [WIP] torch/csrc/profiler/README.md torch/csrc/profiler/README.md - stubs, RecordFunction, Autograd interaction Sep 7, 2023
@davidberard98 davidberard98 added release notes: profiler release notes category topic: docs topic category and removed topic: not user facing topic category labels Sep 7, 2023
@davidberard98 davidberard98 marked this pull request as ready for review September 7, 2023 23:59
@anupambhatnagar
Copy link
Contributor

@davidberard98 Thanks for putting this readme together. Is this PR currently a WIP or are you planning to commit it as is?

@davidberard98
Copy link
Contributor Author

@anupambhatnagar I was planning to land it as is - not sure I have a good enough understanding of the other parts to write about them clearly right now.

Copy link
Member

@aaronenyeshi aaronenyeshi 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 great, added a few small comments. This is a great addition to the profiler docs, and a good start for further sections.

Also, wondering since RecordFunction is a C++ struct, should we annotate it as code? Like RecordFunction ?

The profiler instruments PyTorch to collect information about the model's execution. Its main features are:
* Instrumenting op calls on the CPU side
* Interfacing with [Kineto](https://github.com/pytorch/kineto/) to collect information from the GPU (or other accelerators)
* Collecting python stacktraces
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Collecting python stacktraces
* Collecting python stack traces


RecordFunction is used by the profiler to instrument CPU-side events.

RecordFunction is a general method of instrumenting function calls in pytorch. It can be used for other general applications, e.g. see [Features for Large-Scale Deployments](https://pytorch.org/docs/stable/notes/large_scale_deployments.html). In PyTorch, it is already included at some important locations; notably, in the [dispatcher](https://github.com/pytorch/pytorch/blob/247c603da9b780534e25fb1d90b6e5a528b625b1/aten/src/ATen/core/dispatch/Dispatcher.h#L650), surrounding every op.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
RecordFunction is a general method of instrumenting function calls in pytorch. It can be used for other general applications, e.g. see [Features for Large-Scale Deployments](https://pytorch.org/docs/stable/notes/large_scale_deployments.html). In PyTorch, it is already included at some important locations; notably, in the [dispatcher](https://github.com/pytorch/pytorch/blob/247c603da9b780534e25fb1d90b6e5a528b625b1/aten/src/ATen/core/dispatch/Dispatcher.h#L650), surrounding every op.
RecordFunction is a general method of instrumenting function calls in PyTorch. It can be used for other general applications, e.g. see [Features for Large-Scale Deployments](https://pytorch.org/docs/stable/notes/large_scale_deployments.html). In PyTorch, it is already included at some important locations; notably, in the [dispatcher](https://github.com/pytorch/pytorch/blob/247c603da9b780534e25fb1d90b6e5a528b625b1/aten/src/ATen/core/dispatch/Dispatcher.h#L650), surrounding every op.


RecordFunction is a general method of instrumenting function calls in pytorch. It can be used for other general applications, e.g. see [Features for Large-Scale Deployments](https://pytorch.org/docs/stable/notes/large_scale_deployments.html). In PyTorch, it is already included at some important locations; notably, in the [dispatcher](https://github.com/pytorch/pytorch/blob/247c603da9b780534e25fb1d90b6e5a528b625b1/aten/src/ATen/core/dispatch/Dispatcher.h#L650), surrounding every op.

Users (or PyTorch itself) can register callbacks that will be executed whenever a RecordFunction guard is encountered. The profiler uses this mechanism to record the start and end times for each op call, as well as user-provided RecordFunction anntations. The RecordFunction machinery is designed to have relatively low overhead, especially when there are no callbacks registered. Nevertheless, there can still be some overhead.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Users (or PyTorch itself) can register callbacks that will be executed whenever a RecordFunction guard is encountered. The profiler uses this mechanism to record the start and end times for each op call, as well as user-provided RecordFunction anntations. The RecordFunction machinery is designed to have relatively low overhead, especially when there are no callbacks registered. Nevertheless, there can still be some overhead.
Users (or PyTorch itself) can register callbacks that will be executed whenever a RecordFunction guard is encountered. The profiler uses this mechanism to record the start and end times for each op call, as well as user-provided RecordFunction annotations. The RecordFunction machinery is designed to have relatively low overhead, especially when there are no callbacks registered. Nevertheless, there can still be some overhead.

…ograd interaction"


Technical details about the profiler - stubs for the stuff I haven't had time to fill out yet, plus details about RecordFunction and the profiler's interaction with autograd.

reviewers - see https://github.com/pytorch/pytorch/blob/06c41eea9e37b5799e4f14601c95fa7810297759/torch/csrc/profiler/README.md for rendered markdown

[ghstack-poisoned]
@pytorch-bot pytorch-bot bot added the topic: not user facing topic category label Sep 12, 2023
davidberard98 added a commit that referenced this pull request Sep 12, 2023
Technical details about the profiler.

ghstack-source-id: 3b9d5a61170fd9c493a3a51d72fbfca462c2f376
Pull Request resolved: #108470
…ograd interaction"


Technical details about the profiler - stubs for the stuff I haven't had time to fill out yet, plus details about RecordFunction and the profiler's interaction with autograd.

reviewers - see https://github.com/pytorch/pytorch/blob/06c41eea9e37b5799e4f14601c95fa7810297759/torch/csrc/profiler/README.md for rendered markdown

[ghstack-poisoned]
davidberard98 added a commit that referenced this pull request Sep 12, 2023
Technical details about the profiler.

ghstack-source-id: 100a8391c96b0fb76f078ad859fe2a4e74cbb17e
Pull Request resolved: #108470
@davidberard98
Copy link
Contributor Author

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Sep 13, 2023
@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@facebook-github-bot facebook-github-bot deleted the gh/davidberard98/231/head branch September 16, 2023 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk Trigger trunk jobs on your pull request Merged release notes: profiler release notes category topic: docs topic category topic: not user facing topic category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants