Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions python/test/unit/hopper/test_experimental_tma.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import triton
import triton.language as tl
from triton.tools.experimental_descriptor import (create_1d_tma_descriptor, create_2d_tma_descriptor)
from triton._internal_testing import dtypes_with_bfloat16, numpy_random, to_triton, requires_tma
from triton._internal_testing import dtypes_with_bfloat16, numpy_random, to_triton, requires_tma, supports_tma, tma_skip_msg

from typing import Optional

Expand All @@ -29,9 +29,11 @@ def unwrap_tensor(t: torch.Tensor | triton.runtime.jit.TensorWrapper):
tma_dtypes = sorted(set(dtypes_with_bfloat16) - {"int64", "uint64", "float64"})


@requires_tma
@pytest.mark.parametrize("byval_tma", [True, False])
def test_experimetal_descriptor_load(byval_tma):
if not supports_tma(byval_tma):
pytest.skip(tma_skip_msg(byval_tma))
return
device = "cuda"
SIZE = 128

Expand Down Expand Up @@ -82,11 +84,13 @@ def matmul_kernel_tma(a_desc_ptr, b_desc_ptr, c_desc_ptr, #
tl._experimental_descriptor_store(c_desc_ptr, accumulator, [offs_am, offs_bn])


@requires_tma
@pytest.mark.parametrize("num_stages", [1, 4])
@pytest.mark.parametrize("BLOCK_M, BLOCK_N, BLOCK_K", [(32, 32, 32), (128, 64, 64), (128, 128, 64), (128, 256, 64)])
@pytest.mark.parametrize("byval_tma", [True, False])
def test_experimental_tma_matmul(num_stages, BLOCK_M, BLOCK_N, BLOCK_K, byval_tma):
if not supports_tma(byval_tma):
pytest.skip(tma_skip_msg(byval_tma))
return
device = "cuda"
M, N, K = 8192, 8192, 1024
torch.manual_seed(42)
Expand Down
16 changes: 13 additions & 3 deletions python/triton/_internal_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import torch
import triton
import triton.language as tl
from triton.backends.nvidia.compiler import _path_to_binary
import pytest

from numpy.random import RandomState
Expand Down Expand Up @@ -140,8 +141,17 @@ def to_numpy(x):
raise ValueError(f"Not a triton-compatible tensor: {x}")


def supports_tma():
return is_cuda() and torch.cuda.get_device_capability()[0] >= 9
def supports_tma(byval_only=False):
_, cuda_version = _path_to_binary("ptxas")
min_cuda_version = 12.0 if byval_only else 12.3
return is_cuda() and torch.cuda.get_device_capability()[0] >= 9 and float(cuda_version) >= min_cuda_version


def tma_skip_msg(byval_only=False):
if byval_only:
return "Requires __grid_constant__ TMA support (NVIDIA Hopper or higher, CUDA 12.0 or higher)"
else:
return "Requires advanced TMA support (NVIDIA Hopper or higher, CUDA 12.3 or higher)"


requires_tma = pytest.mark.skipif(not supports_tma(), reason="Requires TMA support (NVIDIA Hopper or higher)")
requires_tma = pytest.mark.skipif(not supports_tma(), reason=tma_skip_msg())
Loading