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
[Profiler] iterate frontend function events for profiler post processing #124596
[Profiler] iterate frontend function events for profiler post processing #124596
Conversation
whose correlation id is 0, then post processing is to iterate the frontend function events Signed-off-by: Chen, Zejun <zejun.chen@intel.com>
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/124596
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (2 Unrelated Failures)As of commit 53af78e with merge base b198423 (): FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Hi, @aaronenyeshi Could you help review the PR? Thank you. 👍 |
It looks like we've encountered the same issue. If this patch is merged, then the PR #124389 can be closed. |
Woohoo! We are solving the same issue. Thank you for help. Both PR are ok to me. Thank you |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both implementations are good, let's go and merge this since its easier reading the comments and variable names.
@pytorchbot merge |
Merge startedYour 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 |
…ing (pytorch#124596) The `function_events` in `_parse_kineto_results` is used to contain all function events from the result. It contains 2 kinds of events. One is frontend function events whose correlation id is 0, for example, `aten::add`, `aten::mul`. They are on the top level of the profile results. The other is the backend events, which are associated with the frontend events and its correlation id is > 0, for example, `at::native::vectorized_elementwise_kernel`, it should be the backend event of a frontend element-wise op. They have the device execution duration for the related frontend op. In the following post processing code, the **frontend function events** should be iterated to find its correlated backend events in `device_corr_map`, instead of iterating all function events, because `device_corr_map` is designed as a dict, whose key is the id of the frontend function event. https://github.com/pytorch/pytorch/blob/3af12447f85dfede191a113c052e58fa7b21a8b3/torch/autograd/profiler.py#L543-L560 https://github.com/pytorch/pytorch/blob/3af12447f85dfede191a113c052e58fa7b21a8b3/torch/autograd/profiler.py#L537-L540 Pull Request resolved: pytorch#124596 Approved by: https://github.com/aaronenyeshi
…ing (pytorch#124596) The `function_events` in `_parse_kineto_results` is used to contain all function events from the result. It contains 2 kinds of events. One is frontend function events whose correlation id is 0, for example, `aten::add`, `aten::mul`. They are on the top level of the profile results. The other is the backend events, which are associated with the frontend events and its correlation id is > 0, for example, `at::native::vectorized_elementwise_kernel`, it should be the backend event of a frontend element-wise op. They have the device execution duration for the related frontend op. In the following post processing code, the **frontend function events** should be iterated to find its correlated backend events in `device_corr_map`, instead of iterating all function events, because `device_corr_map` is designed as a dict, whose key is the id of the frontend function event. https://github.com/pytorch/pytorch/blob/3af12447f85dfede191a113c052e58fa7b21a8b3/torch/autograd/profiler.py#L543-L560 https://github.com/pytorch/pytorch/blob/3af12447f85dfede191a113c052e58fa7b21a8b3/torch/autograd/profiler.py#L537-L540 Pull Request resolved: pytorch#124596 Approved by: https://github.com/aaronenyeshi
…ing (pytorch#124596) The `function_events` in `_parse_kineto_results` is used to contain all function events from the result. It contains 2 kinds of events. One is frontend function events whose correlation id is 0, for example, `aten::add`, `aten::mul`. They are on the top level of the profile results. The other is the backend events, which are associated with the frontend events and its correlation id is > 0, for example, `at::native::vectorized_elementwise_kernel`, it should be the backend event of a frontend element-wise op. They have the device execution duration for the related frontend op. In the following post processing code, the **frontend function events** should be iterated to find its correlated backend events in `device_corr_map`, instead of iterating all function events, because `device_corr_map` is designed as a dict, whose key is the id of the frontend function event. https://github.com/pytorch/pytorch/blob/3af12447f85dfede191a113c052e58fa7b21a8b3/torch/autograd/profiler.py#L543-L560 https://github.com/pytorch/pytorch/blob/3af12447f85dfede191a113c052e58fa7b21a8b3/torch/autograd/profiler.py#L537-L540 Pull Request resolved: pytorch#124596 Approved by: https://github.com/aaronenyeshi
The
function_events
in_parse_kineto_results
is used to contain all function events from the result. It contains 2 kinds of events. One is frontend function events whose correlation id is 0, for example,aten::add
,aten::mul
. They are on the top level of the profile results. The other is the backend events, which are associated with the frontend events and its correlation id is > 0, for example,at::native::vectorized_elementwise_kernel
, it should be the backend event of a frontend element-wise op. They have the device execution duration for the related frontend op.In the following post processing code, the frontend function events should be iterated to find its correlated backend events in
device_corr_map
, instead of iterating all function events, becausedevice_corr_map
is designed as a dict, whose key is the id of the frontend function event.pytorch/torch/autograd/profiler.py
Lines 543 to 560 in 3af1244
pytorch/torch/autograd/profiler.py
Lines 537 to 540 in 3af1244