[OOT] Add OOT support for linear kernel. (#37989)

Signed-off-by: menogrey <1299267905@qq.com>
This commit is contained in:
zhangyiming
2026-03-31 14:33:21 +08:00
committed by GitHub
parent 6cc7abdc66
commit 1ac6694297
2 changed files with 76 additions and 0 deletions
@@ -367,10 +367,44 @@ def choose_mp_linear_kernel(
)
def register_linear_kernel(
kernel_class: type,
platform: PlatformEnum,
kernel_type: str = "mp",
) -> None:
"""
Register a new linear kernel class to be considered in kernel selection.
Args:
kernel_class (type): The kernel class to register.
platform (PlatformEnum): The platform for which this kernel is applicable.
kernel_type (str): The type of the kernel, either "mp", "int8", or "fp8".
Defaults to "mp".
Raises:
ValueError: If the kernel_type is not recognized.
"""
if kernel_type == "mp":
if platform not in _POSSIBLE_KERNELS:
_POSSIBLE_KERNELS[platform] = []
_POSSIBLE_KERNELS[platform].append(kernel_class)
elif kernel_type == "int8":
if platform not in _POSSIBLE_INT8_KERNELS:
_POSSIBLE_INT8_KERNELS[platform] = []
_POSSIBLE_INT8_KERNELS[platform].append(kernel_class)
elif kernel_type == "fp8":
if platform not in _POSSIBLE_FP8_KERNELS:
_POSSIBLE_FP8_KERNELS[platform] = []
_POSSIBLE_FP8_KERNELS[platform].append(kernel_class)
else:
raise ValueError(f"Unrecognized kernel type: {kernel_type}")
__all__ = [
"init_fp8_linear_kernel",
"init_int8_linear_kernel",
"choose_mp_linear_kernel",
"register_linear_kernel",
"FP8ScaledMMLinearKernel",
"Int8ScaledMMLinearKernel",
"ScaledMMLinearKernel",