main
py 34 lines 1.04 KB
Raw
1 # SPDX-License-Identifier: Apache-2.0
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3 """Helion kernel implementation.
4
5 Importing this package does NOT register any kernels. Runtime code imports the
6 specific op module it needs, e.g.::
7
8 from vllm.kernels.helion.ops import scaled_mm # noqa: F401
9
10 which triggers that op's ``@register_kernel`` as an import side effect.
11
12 Tools that need the full registry (e.g. tools/autotune_helion_kernels.py)
13 call ``import_all_ops()`` to force every op module to register.
14 """
15
16 import importlib
17 import pkgutil
18
19
20 def import_all_kernels() -> list[str]:
21 """Import every kernel submodule so all ``@register_kernel`` decorators run.
22
23 Returns:
24 The fully-qualified module names that were imported.
25
26 """
27 imported: list[str] = []
28 for module_info in pkgutil.iter_modules(__path__):
29 if module_info.ispkg:
30 continue
31 module_name = f"{__name__}.{module_info.name}"
32 importlib.import_module(module_name)
33 imported.append(module_name)
34 return imported