main
py 44 lines 1.3 KB
Raw
1 # SPDX-License-Identifier: Apache-2.0
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3 """Tests for Helion kernel availability and basic functionality.
4
5 This module demonstrates the pattern for testing optional Helion kernels.
6 Tests in this directory will be skipped if Helion is not installed.
7 """
8
9 import pytest
10
11 from vllm.utils.import_utils import has_helion
12
13 # Skip entire module if helion is not available
14 if not has_helion():
15 pytest.skip(
16 "Helion is not installed. Install with: pip install vllm[helion]",
17 allow_module_level=True,
18 )
19
20 import helion
21 import helion.language as hl
22 import torch
23
24
25 def test_helion_kernel_compilation_smoke():
26 """Smoke test: compile and run a simple Helion kernel."""
27
28 @helion.kernel(autotune_effort="none")
29 def add_kernel(x: torch.Tensor, y: torch.Tensor) -> torch.Tensor:
30 out = torch.empty_like(x)
31 for tile in hl.tile(x.size()):
32 out[tile] = x[tile] + y[tile]
33 return out
34
35 # Create test tensors
36 x = torch.randn(1024, device="cuda", dtype=torch.float32)
37 y = torch.randn(1024, device="cuda", dtype=torch.float32)
38
39 # Run the helion kernel
40 result = add_kernel(x, y)
41
42 # Verify correctness
43 expected = x + y
44 assert torch.allclose(result, expected), "Helion kernel output mismatch"