Skip to content

Commit

Permalink
[benchmark] skip perf test of cummin when triton < 3.0 (FlagOpen#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
StrongSpoon authored Jan 2, 2025
1 parent 2ffa6f4 commit 5b3468f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
25 changes: 25 additions & 0 deletions benchmark/performance_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import gc
import importlib
import logging
import time
from typing import Any, Generator, List, Optional, Tuple
Expand Down Expand Up @@ -30,6 +31,30 @@
torch_backend_device.matmul.allow_tf32 = False


def SkipVersion(module_name, skip_pattern):
cmp = skip_pattern[0]
assert cmp in ("=", "<", ">"), f"Invalid comparison operator: {cmp}"
try:
M, N = skip_pattern[1:].split(".")
M, N = int(M), int(N)
except Exception:
raise ValueError("Cannot parse version number from skip_pattern.")

try:
module = importlib.import_module(module_name)
version = module.__version__
major, minor = map(int, version.split(".")[:2])
except Exception:
raise ImportError(f"Cannot determine version of module: {module_name}")

if cmp == "=":
return major == M and minor == N
elif cmp == "<":
return (major, minor) < (M, N)
else:
return (major, minor) > (M, N)


class Benchmark:
device: str = device
DEFAULT_METRICS = DEFAULT_METRICS
Expand Down
8 changes: 7 additions & 1 deletion benchmark/test_reduction_perf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Benchmark,
Config,
GenericBenchmark2DOnly,
SkipVersion,
generate_tensor_input,
unary_input_fn,
)
Expand Down Expand Up @@ -153,7 +154,12 @@ def cumsum_input_fn(shape, cur_dtype, device):
torch.cummin,
cumsum_input_fn,
FLOAT_DTYPES + INT_DTYPES,
marks=pytest.mark.cummin,
marks=[
pytest.mark.cummin,
pytest.mark.skipif(
SkipVersion("triton", "<3.0"), reason="triton not supported"
),
],
),
],
)
Expand Down

0 comments on commit 5b3468f

Please sign in to comment.