diff --git a/tests/model_executor/test_jit_warmup_triton_launcher.py b/tests/model_executor/test_jit_warmup_triton_launcher.py index 2e81cb6000..725a383833 100644 --- a/tests/model_executor/test_jit_warmup_triton_launcher.py +++ b/tests/model_executor/test_jit_warmup_triton_launcher.py @@ -207,6 +207,26 @@ def test_triton_kernel_decorator_returns_launcher( launch(first, 1, 7, stale_constexpr=True) +def test_triton_kernel_decorator_without_triton( + monkeypatch: pytest.MonkeyPatch, +) -> None: + monkeypatch.setattr(jit_warmup_triton_helper, "HAS_TRITON", False) + monkeypatch.setattr(jit_warmup_triton_helper, "triton", object()) + kernel = _FakeTritonKernel() + + def warmup_inputs() -> dict[str, Any]: + return dict(first="warmup", second=1) + + @triton_kernel_dispatcher_with_warmup(kernel=kernel, warmup_inputs=warmup_inputs) + def launch(first: str, second: int) -> LaunchSpec: + return (2,), dict(CONST=7) + + launch("runtime", 2) + assert kernel.runtime_calls == [ + ((2,), (), {"first": "runtime", "second": 2, "CONST": 7}) + ] + + def test_triton_kernel_decorator_exhausts_large_ranges_before_deduplication( monkeypatch: pytest.MonkeyPatch, ) -> None: diff --git a/vllm/model_executor/warmup/jit_warmup_triton_helper.py b/vllm/model_executor/warmup/jit_warmup_triton_helper.py index dab055902a..198e6fdbe2 100644 --- a/vllm/model_executor/warmup/jit_warmup_triton_helper.py +++ b/vllm/model_executor/warmup/jit_warmup_triton_helper.py @@ -15,7 +15,7 @@ from vllm.model_executor.warmup.jit_warmup import ( get_function_source_node, ) from vllm.platforms import current_platform -from vllm.triton_utils import triton +from vllm.triton_utils import HAS_TRITON, triton CompileKeyT = TypeVar("CompileKeyT") P = ParamSpec("P") @@ -428,6 +428,8 @@ class _AutomaticTritonJitKernel(VllmTritonJitKernel[TritonCompileKey]): def _is_autotuned(kernel: Any) -> bool: + if not HAS_TRITON: + return False Autotuner = triton.runtime.autotuner.Autotuner while kernel is not None: