From 840c7c2f4bc72c7c55edb2dea6d23f9a9c9734e0 Mon Sep 17 00:00:00 2001 From: djramic Date: Thu, 1 Oct 2026 21:38:55 +0200 Subject: [PATCH] [Bugfix][Engram] Fix intermittent Triton 3.8 crash in the lookup kernel (#59639) Signed-off-by: Djordje Ramic Signed-off-by: Andreas Karatzas Co-authored-by: Andreas Karatzas Co-authored-by: Andreas Karatzas --- vllm/models/deepseek_v41/common/engram.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/vllm/models/deepseek_v41/common/engram.py b/vllm/models/deepseek_v41/common/engram.py index 8452c1ad8a..d4810ee4ea 100644 --- a/vllm/models/deepseek_v41/common/engram.py +++ b/vllm/models/deepseek_v41/common/engram.py @@ -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.