-
Notifications
You must be signed in to change notification settings - Fork 25.2k
[profiler] support cuLaunchKernel (for triton kernel launches) & update kineto submodule #99571
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
Conversation
…te kineto submodule **Background**: Prior to this PR, traces for PT2 w/ inductor don't contain connections between CUDA kernels and the CPU launch site. This PR adds those connections. **Details**: Triton kernels launched by inductor use cuLaunchKernel instead of cudaLaunchKernel. cuLaunchKernel is part of the driver API, while cudaLaunchKernel is part of the runtime API. In order to support cuLaunchKernel, we added support in kineto (pytorch/kineto#752) to also start listening to driver events; hence why we need to update the kineto submodule. After the change in kineto, we just need to turn this on in the PyTorch repo by adding CUDA_DRIVER activity type to the CPU and CUDA activity type lists; then **Testing**: Added test/inductor/test_profiler.py to check for `cuLaunchKernel` in json trace files. Also, I ran this test: ```python import torch x = torch.rand((2, 2), device='cuda') def fn(x): return x.relu() fn_c = torch.compile(fn) fn_c(x) with torch.profiler.profile(with_stack=True) as prof: fn_c(x) prof.export_chrome_trace("relu_profile.json") ``` [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/99571
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 26d50ae: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
…te kineto submodule **Background**: Prior to this PR, traces for PT2 w/ inductor don't contain connections between CUDA kernels and the CPU launch site. This PR adds those connections. **Details**: Triton kernels launched by inductor use cuLaunchKernel instead of cudaLaunchKernel. cuLaunchKernel is part of the driver API, while cudaLaunchKernel is part of the runtime API. In order to support cuLaunchKernel, we added support in kineto (pytorch/kineto#752) to also start listening to driver events; hence why we need to update the kineto submodule. After the change in kineto, we just need to turn this on in the PyTorch repo by adding CUDA_DRIVER activity type to the CPU and CUDA activity type lists; then **Testing**: Added test/inductor/test_profiler.py to check for `cuLaunchKernel` in json trace files. Also, I ran this test: ```python import torch x = torch.rand((2, 2), device='cuda') def fn(x): return x.relu() fn_c = torch.compile(fn) fn_c(x) with torch.profiler.profile(with_stack=True) as prof: fn_c(x) prof.export_chrome_trace("relu_profile.json") ``` ghstack-source-id: 85fe6b4 Pull Request resolved: #99571
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.
LGTM! Thank you for adding the flow fix for cuLaunchKernel and updating the Kineto submodule!
@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 |
Stack from ghstack:
Background: Prior to this PR, traces for PT2 w/ inductor don't contain connections between CUDA kernels and the CPU launch site. This PR adds those connections.
Details: Triton kernels launched by inductor use cuLaunchKernel instead of cudaLaunchKernel. cuLaunchKernel is part of the driver API, while cudaLaunchKernel is part of the runtime API. In order to support cuLaunchKernel, we added support in kineto (pytorch/kineto#752) to also start listening to driver events; hence why we need to update the kineto submodule.
After the change in kineto, we just need to turn this on in the PyTorch repo by adding CUDA_DRIVER activity type to the CPU and CUDA activity type lists; then
Testing: Added test/inductor/test_profiler.py to check for
cuLaunchKernel
in json trace files.Also, I ran this test:
which generated this chrometrace:

in which you can see flows between a
cuLaunchKernel
on the CPU side, and the triton kernel on the GPU.Kineto Updates: To get the kineto-side changes required for cupti driver events, this PR updates the kineto pin. In that updated kineto submodule, we also have:
autograd.profile.profiler
fails to export valid chrome trace files on Windows #98432)cc @robieta @chaekit @aaronenyeshi @ngimel @nbcsm @guotuofeng @guyang3532 @gaoteng-git @tiffzhaofb @dzhulgakov @soumith @voznesenskym @penguinwu @anijain2305 @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @Xia-Weiwen @wenzhe-nrv @jiayisunx @peterbell10 @desertfire