[Misc] Use pytest.mark.skipif in sgl-kernel test (#5137)

This commit is contained in:
yinfan98
2025-04-08 12:35:14 +08:00
committed by GitHub
parent ade714a67f
commit 9798e72baa
3 changed files with 29 additions and 11 deletions

View File

@@ -2,11 +2,7 @@ import pytest
import torch
from sgl_kernel import cutlass_scaled_fp4_mm, scaled_fp4_quant
if torch.cuda.get_device_capability() < (10, 0):
pytest.skip(
reason="Nvfp4 Requires compute capability of 10 or above.",
allow_module_level=True,
)
skip_condition = torch.cuda.get_device_capability() < (10, 0)
DTYPES = [torch.float16, torch.bfloat16]
# m, n, k
@@ -108,6 +104,9 @@ def get_ref_results(
return torch.matmul(a_in_dtype, b_in_dtype.t())
@pytest.mark.skipif(
skip_condition, reason="Nvfp4 Requires compute capability of 10 or above."
)
@pytest.mark.parametrize("dtype", DTYPES)
@pytest.mark.parametrize("shape", SHAPES)
@torch.inference_mode()
@@ -149,3 +148,7 @@ def test_nvfp4_gemm(
)
torch.testing.assert_close(out, expected_out.to(dtype=dtype), atol=1e-1, rtol=1e-1)
if __name__ == "__main__":
pytest.main([__file__])