Skip to content

Commit edc8bdb

Browse files
anmyachevpbchekin
andauthored
Introduce BENCHMARKING_METHOD for Triton benchmarks (#2376)
Required for #2343 because it will add a new benchmarking method: `UPSTREAM_PYTORCH_PROFILER` The option is added more with an eye on CI, so for now I left `USE_IPEX` option so as not to change the interaction interface (default behavior is also not changed). --------- Signed-off-by: Anatoly Myachev <[email protected]> Co-authored-by: Pavel Chekin <[email protected]>
1 parent 59e2621 commit edc8bdb

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

.github/workflows/triton-benchmarks.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,22 @@ on:
1111
description: Tag for benchmark results
1212
type: string
1313
default: "test"
14-
install_ipex:
15-
description: Install Intel PyTorch Extension
16-
type: boolean
17-
default: true
14+
benchmarking_method:
15+
description: The method used to obtain performance numbers
16+
type: choice
17+
options:
18+
- PYTORCH_LEGACY_PROFILER_USING_IPEX
19+
- ELAPSED_TIME
20+
default: PYTORCH_LEGACY_PROFILER_USING_IPEX
1821
schedule:
1922
- cron: "5 23 * * *"
2023

2124
permissions: read-all
2225

2326
env:
2427
PYTHON_VERSION: "3.10"
25-
USE_IPEX: ${{ github.event_name == 'schedule' && '1' || inputs.install_ipex && '1' || '0' }}
28+
BENCHMARKING_METHOD: ${{ github.event_name == 'schedule' && 'PYTORCH_LEGACY_PROFILER_USING_IPEX' || inputs.benchmarking_method }}
29+
USE_IPEX: ${{ github.event_name == 'schedule' && '1' || inputs.benchmarking_method == 'PYTORCH_LEGACY_PROFILER_USING_IPEX' && '1' || '0' }}
2630

2731
jobs:
2832
build:

benchmarks/triton_kernels_benchmark/benchmark_testing.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
from typing import Any, Dict, List
55

66
USE_IPEX_OPTION = os.getenv("USE_IPEX", "1") == "1"
7+
if USE_IPEX_OPTION:
8+
BENCHMARKING_METHOD = "PYTORCH_LEGACY_PROFILER_USING_IPEX"
9+
else:
10+
BENCHMARKING_METHOD = os.getenv("BENCHMARKING_METHOD", "ELAPSED_TIME")
711

812

913
def synchronize():
@@ -122,8 +126,8 @@ def extract_kernels(funcs):
122126
return _summarize_statistics(times, quantiles, return_mode)
123127

124128

125-
def do_bench_no_ipex(fn, warmup=25, rep=100, grad_to_none=None, quantiles=None, fast_flush=True, return_mode="mean",
126-
device="xpu"):
129+
def do_bench_elapsed_time(fn, warmup=25, rep=100, grad_to_none=None, quantiles=None, fast_flush=True,
130+
return_mode="mean", device="xpu"):
127131
"""
128132
Benchmark the runtime of the provided function. By default, return the median runtime of :code:`fn` along with
129133
the 20-th and 80-th performance percentile.
@@ -151,9 +155,12 @@ def do_bench_no_ipex(fn, warmup=25, rep=100, grad_to_none=None, quantiles=None,
151155
return _summarize_statistics(times, quantiles, return_mode)
152156

153157

154-
do_bench = do_bench_no_ipex
155-
if USE_IPEX_OPTION:
158+
if BENCHMARKING_METHOD == "PYTORCH_LEGACY_PROFILER_USING_IPEX":
156159
do_bench = do_bench_ipex
160+
elif BENCHMARKING_METHOD == "ELAPSED_TIME":
161+
do_bench = do_bench_elapsed_time
162+
else:
163+
raise NotImplementedError(f"BENCHMARKING_METHOD: {BENCHMARKING_METHOD} isn't implemented")
157164

158165

159166
def assert_close(x, y, atol=None, rtol=None, err_msg=""):

scripts/capture-hw-details.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fi
6161
if [[ "${USE_IPEX:-}" == "1" ]]; then
6262
export BENCHMARKING_METHOD="PYTORCH_LEGACY_PROFILER_USING_IPEX"
6363
elif [[ "${USE_IPEX:-}" == "0" ]]; then
64-
export BENCHMARKING_METHOD="ELAPSED_TIME"
64+
export BENCHMARKING_METHOD="${BENCHMARKING_METHOD:-ELAPSED_TIME}"
6565
fi
6666

6767
if [ "$QUIET" = false ]; then

0 commit comments

Comments
 (0)