Register the kernel in veomni/ops/kernels/<op_name>/__init__.py. One
KERNEL_REGISTRY.register(KernelSpec(...)) call per implementation —
register() takes a single KernelSpec and returns None, so it is not a
decorator:
from veomni.ops.kernel_registry import KERNEL_REGISTRY, HardwareRequirement, KernelSpec
def _my_op_triton_factory():
from .triton_kernel import my_op_triton
return my_op_triton
KERNEL_REGISTRY.register(
KernelSpec(
name="triton",
op_name="my_op",
variant="standard",
factory=_my_op_triton_factory,
hardware=HardwareRequirement(device_type="gpu"),
description="Triton my_op",
)
)
factory is a zero-argument callable returning the kernel, not the
kernel itself. Keeping it lazy is what stops an optional dependency (Liger,
Triton, torch_npu) from being imported just because the module was loaded.
hardware is enforced at resolve() time, so an unavailable kernel fails
with a clear error instead of at first use.
Mind the two axes: (op_name, variant) identifies the slot, name
identifies the implementation within it. Kernels in different variants
never collide.
Then declare a matching OpSlot in the patchgen config of every model that
uses it — the arguments are (op_name, variant), not an implementation:
from veomni.ops.dispatch import OpSlot
veomni_my_op = OpSlot("my_op", "standard")
_bind_veomni_ops() calls slot.bind(impl_name) with the implementation
selected by OpsImplementationConfig. See
veomni/ops/kernels/rotary/__init__.py for a live example, and
veomni/ops/README.md for the op/variant/impl table.