[Bugfix] Skip Triton autotune inspection without Triton (#56676)
Signed-off-by: Kevin Luu <51931015+khluu@users.noreply.github.com>
Kevin H. Luu committed
Sep 13, 2026 at 10:05 UTC
dec0b5d63fc42dc1d1789caf572195c73dd86ea6
2 files changed
+23
-1
tests/model_executor/test_jit_warmup_triton_launcher.py
+20
@@ -207,6 +207,26 @@ def test_triton_kernel_decorator_returns_launcher(
207
launch(first, 1, 7, stale_constexpr=True)
208
209
210
+def test_triton_kernel_decorator_without_triton(
211
+ monkeypatch: pytest.MonkeyPatch,
212
+) -> None:
213
+ monkeypatch.setattr(jit_warmup_triton_helper, "HAS_TRITON", False)
214
+ monkeypatch.setattr(jit_warmup_triton_helper, "triton", object())
215
+ kernel = _FakeTritonKernel()
216
+
217
+ def warmup_inputs() -> dict[str, Any]:
218
+ return dict(first="warmup", second=1)
219
+
220
+ @triton_kernel_dispatcher_with_warmup(kernel=kernel, warmup_inputs=warmup_inputs)
221
+ def launch(first: str, second: int) -> LaunchSpec:
222
+ return (2,), dict(CONST=7)
223
+
224
+ launch("runtime", 2)
225
+ assert kernel.runtime_calls == [
226
+ ((2,), (), {"first": "runtime", "second": 2, "CONST": 7})
227
+ ]
228
+
229
+
230
def test_triton_kernel_decorator_exhausts_large_ranges_before_deduplication(
231
monkeypatch: pytest.MonkeyPatch,
232
) -> None:
vllm/model_executor/warmup/jit_warmup_triton_helper.py
+3
-1
@@ -15,7 +15,7 @@ from vllm.model_executor.warmup.jit_warmup import (
15
get_function_source_node,
16
)
17
from vllm.platforms import current_platform
18
-from vllm.triton_utils import triton
18
+from vllm.triton_utils import HAS_TRITON, triton
19
20
CompileKeyT = TypeVar("CompileKeyT")
21
P = ParamSpec("P")
@@ -428,6 +428,8 @@ class _AutomaticTritonJitKernel(VllmTritonJitKernel[TritonCompileKey]):
428
429
430
def _is_autotuned(kernel: Any) -> bool:
431
+ if not HAS_TRITON:
432
+ return False
433
Autotuner = triton.runtime.autotuner.Autotuner
434
435
while kernel is not None: