# Triton kernel launch in TorchInductor

**URL:** <https://discuss.pytorch.org/t/triton-kernel-launch-in-torchinductor/192899>\
**Category:** torch.\_inductor\
**Created:** [November 30, 2023, 6:19pm UTC](https://discuss.pytorch.org/t/triton-kernel-launch-in-torchinductor/192899 "2023-11-30T18:19:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![trusira](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/trusira/32/63387_2.png) [@trusira](https://discuss.pytorch.org/u/trusira)\
**Post date:** [November 30, 2023, 6:19pm UTC](https://discuss.pytorch.org/t/triton-kernel-launch-in-torchinductor/192899/1 "2023-11-30T18:19:32Z")

</div>

I’m trying to understand how TorchInductor is scheduling generated Triton kernels for execution. I can see in [`precompile`](https://github.com/pytorch/pytorch/blob/2a3d8e50fb2923990a5549de63ea38a2e0671cc6/torch/_inductor/triton_heuristics.py#L180) function of `CachingAutotuner`, kernel binaries and launchers are being populated. But I’m not sure where these launchers are actually launched/called and how corresponding `cudaLaunchKernel`s are issued.

Could someone please point me in the right direction?  
Thanks in advance!

---

<div class="post-metadata">

**Author:** ![trusira](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/trusira/32/63387_2.png) [@trusira](https://discuss.pytorch.org/u/trusira)\
**Post date:** [December 7, 2023, 9:12pm UTC](https://discuss.pytorch.org/t/triton-kernel-launch-in-torchinductor/192899/2 "2023-12-07T21:12:40Z")

</div>

From what I was able to find, this is handled by Triton during the launcher generation for each kernel in  
[`def generate_launcher(constants, signature, ids)`](https://github.com/openai/triton/blob/0027cf785efa64ff7e6120bf1633b4ce6291c54d/python/triton/compiler/make_launcher.py#L66).  
It compiles the CUDA launcher code into a shared library and commits to the codecache.

> <https://github.com/openai/triton/blob/0027cf785efa64ff7e6120bf1633b4ce6291c54d/python/triton/compiler/make_launcher.py#L39>
