Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions tokamax/_src/hlo_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
from tokamax._src.ops import op as op_lib

DISABLE_JAX_EXPORT_CHECKS: Final[tuple[export.DisabledSafetyCheck, ...]] = (
export.DisabledSafetyCheck.custom_call(hlo_utils_common.PALLAS_TRITON_KEY),
*(
export.DisabledSafetyCheck.custom_call(key)
for key in hlo_utils_common.PALLAS_TRITON_KEYS
),
export.DisabledSafetyCheck.custom_call(hlo_utils_common.MOSAIC_GPU_KEY),
export.DisabledSafetyCheck.custom_call(hlo_utils_common.MOSAIC_TPU_KEY),
export.DisabledSafetyCheck.custom_call(hlo_utils_common.TRITON_KEY),
Expand Down Expand Up @@ -185,6 +188,19 @@ def _kernel_info_getter(cls):
return lambda op, call_stack: cls(**_get_common_kernel_info(op, call_stack))


_KERNEL_GETTER_DICT = {
hlo_utils_common.MOSAIC_GPU_KEY: _kernel_info_getter(
hlo_utils_common.MosaicGpuKernelInfo
),
hlo_utils_common.MOSAIC_TPU_KEY: _kernel_info_getter(
hlo_utils_common.MosaicTpuKernelInfo
),
}
for _key in hlo_utils_common.PALLAS_TRITON_KEYS:
_KERNEL_GETTER_DICT[_key] = _kernel_info_getter(
hlo_utils_common.TritonKernelInfo
)

_KERNEL_GETTER: Final[
immutabledict.immutabledict[
str,
Expand All @@ -193,17 +209,7 @@ def _kernel_info_getter(cls):
KernelInfoBase,
],
]
] = immutabledict.immutabledict({
hlo_utils_common.MOSAIC_GPU_KEY: _kernel_info_getter(
hlo_utils_common.MosaicGpuKernelInfo
),
hlo_utils_common.MOSAIC_TPU_KEY: _kernel_info_getter(
hlo_utils_common.MosaicTpuKernelInfo
),
hlo_utils_common.PALLAS_TRITON_KEY: _kernel_info_getter(
hlo_utils_common.TritonKernelInfo
),
})
] = immutabledict.immutabledict(_KERNEL_GETTER_DICT)
_get_tokamax_xla_kernel_info = _kernel_info_getter(
hlo_utils_common.TokamaxXlaKernelInfo
)
Expand Down
4 changes: 4 additions & 0 deletions tokamax/_src/hlo_utils_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@

TOKAMAX_NAME: Final[str] = 'tokamax'

PALLAS_TRITON_KEYS: Final[tuple[str, ...]] = (
'triton_kernel_call_ffi',
'__gpu$xla.gpu.triton',
)
PALLAS_TRITON_KEY: Final[str] = '__gpu$xla.gpu.triton'
MOSAIC_GPU_KEY: Final[str] = 'mosaic_gpu_v2'
MOSAIC_TPU_KEY: Final[str] = 'tpu_custom_call'
Expand Down
Loading