[inductor][ez] add template/externchoice uid (#161341)

# why

- to have a central registry of templates/externkernelchoice
  to match them to heuristics etc, they need unique names
- mm is both the triton template name and the aten_mm name

# what

- add a uid() to KernelTemplate/ExternKernelChoice that returns name
- override in ExternKernel to prepend "aten::"
- override in TritonTemplate to prepend "triton::"

This id is just use to find template heuristics, so it has no other
impact

# testing

```
python3 -bb -m pytest test/inductor/test_max_autotune.py -v
```

Differential Revision: [D81520579](https://our.internmc.facebook.com/intern/diff/D81520579)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/161341
Approved by: https://github.com/jansel, https://github.com/eellison
ghstack dependencies: #162075, #161340
This commit is contained in:
Ruben Rodriguez Buchillon
2025-09-05 07:38:40 -07:00
committed by PyTorch MergeBot
parent 9602590b15
commit 4902c76c65
8 changed files with 139 additions and 74 deletions

View File

@ -1443,6 +1443,11 @@ class TritonTemplate(KernelTemplate):
# was not used are the same.
test_cache = False
@property
def uid(self) -> str:
# unique by prefixing with triton
return f"triton::{self.name}"
def maybe_append_choice(
self, choices: list[Any], **kwargs: Any
) -> Optional[NotImplementedError]:
@ -1909,6 +1914,11 @@ class ExternKernelChoice:
self, input_nodes, layout, kwargs, has_out_variant=self.has_out_variant
)
@property
def uid(self) -> str:
# unique by prefixing with aten
return f"aten::{self.name}"
def maybe_append_choice(
self, choices: list[Any], **kwargs: Any
) -> Optional[NotImplementedError]: