pytorch
c19d19f6 - [profiler] support cuLaunchKernel (for triton kernel launches) & update kineto submodule (#99571)

Commit
1 year ago
[profiler] support cuLaunchKernel (for triton kernel launches) & update kineto submodule (#99571) **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") ``` which generated this chrometrace: <img width="930" alt="Screenshot 2023-04-18 at 2 58 25 PM" src="https://user-images.githubusercontent.com/5067123/232966895-b65f9daf-7645-44f8-9e2b-f8c11c86ef0a.png"> 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: * JSON string sanitizing for event names (likely fix for #99572) * cuda initialization fixes for multiprocessing * cuKernelLaunch events (i.e. for this PR) * DISABLE_CUPTI_LAZY_REINIT (from @aaronenyeshi) Pull Request resolved: https://github.com/pytorch/pytorch/pull/99571 Approved by: https://github.com/ngimel, https://github.com/aaronenyeshi
Author
Committer
Parents
Loading