[Bugfix][Engram] Fix intermittent Triton 3.8 crash in the lookup kernel (#59639)

Signed-off-by: Djordje Ramic <djoramic@amd.com>
Signed-off-by: Andreas Karatzas <andreas.karatzas@protonmail.com>
Co-authored-by: Andreas Karatzas <andreas.karatzas@protonmail.com>
Co-authored-by: Andreas Karatzas <akaratza@amd.com>
This commit is contained in:
djramic
2026-10-01 19:38:55 +00:00
committed by GitHub
co-authored by Andreas Karatzas Andreas Karatzas
parent 7b44aad5db
commit 840c7c2f4b
+11 -2
View File
@@ -605,6 +605,15 @@ def _engram_head_shard_weight_loader(
param.data.copy_(shard)
# Branching on SORTED at runtime intermittently crashes Triton 3.8's
# RemoveLayoutConversions.
# TODO: Remove the 3.8 check once Triton ships
# https://github.com/triton-lang/triton/pull/10706.
_SORTED_IS_CONSTEXPR = tl.constexpr(
triton.__version__.startswith("3.8") and current_platform.is_rocm()
)
@triton.jit(
do_not_specialize=[
"vocab_start",
@@ -613,7 +622,7 @@ def _engram_head_shard_weight_loader(
"ids_stride_t",
"ids_stride_h",
"GRID",
"SORTED",
*(() if _SORTED_IS_CONSTEXPR else ("SORTED",)),
]
)
def _engram_lookup_kernel(
@@ -634,7 +643,7 @@ def _engram_lookup_kernel(
QUANT_BLOCK: tl.constexpr,
BLOCK_R: tl.constexpr,
GRID,
SORTED,
SORTED: tl.constexpr if _SORTED_IS_CONSTEXPR else None, # type: ignore[valid-type]
):
"""Gather fp8 rows, apply their ue8m0 block scales, write bf16.