Skip to content

Commit e538f26

Browse files
[SCRIPT] Add a way to run all benchmarks (#2959)
Signed-off-by: Whitney Tsang <[email protected]>
1 parent 9eb9b6f commit e538f26

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

scripts/test-triton.sh

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ TEST_CORE=false
1515
TEST_INTERPRETER=false
1616
TEST_TUTORIAL=false
1717
TEST_MICRO_BENCHMARKS=false
18+
TEST_BENCHMARKS=false
1819
TEST_BENCHMARK_SOFTMAX=false
1920
TEST_BENCHMARK_GEMM=false
2021
TEST_BENCHMARK_ATTENTION=false
@@ -53,6 +54,10 @@ while [ -v 1 ]; do
5354
TEST_MICRO_BENCHMARKS=true
5455
shift
5556
;;
57+
--benchmarks)
58+
TEST_BENCHMARKS=true
59+
shift
60+
;;
5661
--softmax)
5762
TEST_BENCHMARK_SOFTMAX=true
5863
shift
@@ -116,7 +121,7 @@ while [ -v 1 ]; do
116121
done
117122

118123
# Only run interpreter test when $TEST_INTERPRETER is true
119-
if [ "$TEST_UNIT" = false ] && [ "$TEST_CORE" = false ] && [ "$TEST_INTERPRETER" = false ] && [ "$TEST_TUTORIAL" = false ] && [ "$TEST_MICRO_BENCHMARKS" = false ] && [ "$TEST_BENCHMARK_SOFTMAX" = false ] && [ "$TEST_BENCHMARK_GEMM" = false ] && [ "$TEST_BENCHMARK_ATTENTION" = false ] && [ "$TEST_INSTRUMENTATION" = false ] && [ "$TEST_INDUCTOR" = false ]; then
124+
if [ "$TEST_UNIT" = false ] && [ "$TEST_CORE" = false ] && [ "$TEST_INTERPRETER" = false ] && [ "$TEST_TUTORIAL" = false ] && [ "$TEST_MICRO_BENCHMARKS" = false ] && ["$TEST_BENCHMARKS" = false] && [ "$TEST_BENCHMARK_SOFTMAX" = false ] && [ "$TEST_BENCHMARK_GEMM" = false ] && [ "$TEST_BENCHMARK_ATTENTION" = false ] && [ "$TEST_INSTRUMENTATION" = false ] && [ "$TEST_INDUCTOR" = false ]; then
120125
TEST_UNIT=true
121126
TEST_CORE=true
122127
TEST_TUTORIAL=true
@@ -152,7 +157,7 @@ install_deps() {
152157
echo "**** Skipping installation of pytorch ****"
153158
else
154159
echo "**** Installing pytorch ****"
155-
if ([ ! -v USE_IPEX ] || [ "$USE_IPEX" = 1 ]) && ([ "$TEST_BENCHMARK_SOFTMAX" = true ] || [ "$TEST_BENCHMARK_GEMM" = true ] || [ "$TEST_BENCHMARK_ATTENTION" = true ]); then
160+
if ([ ! -v USE_IPEX ] || [ "$USE_IPEX" = 1 ]) && ([ "$TEST_BENCHMARKS" = true ] || [ "$TEST_BENCHMARK_SOFTMAX" = true ] || [ "$TEST_BENCHMARK_GEMM" = true ] || [ "$TEST_BENCHMARK_ATTENTION" = true ]); then
156161
$SCRIPTS_DIR/compile-pytorch-ipex.sh $([ $VENV = true ] && echo "--venv")
157162
else
158163
$SCRIPTS_DIR/install-pytorch.sh $([ $VENV = true ] && echo "--venv")
@@ -288,6 +293,21 @@ run_benchmark_attention() {
288293
python $TRITON_PROJ/benchmarks/triton_kernels_benchmark/flash_attention_fwd_benchmark.py
289294
}
290295

296+
run_benchmarks() {
297+
cd $TRITON_PROJ/benchmarks
298+
python setup.py install
299+
for file in $TRITON_PROJ/benchmarks/triton_kernels_benchmark/*.py; do
300+
benchmark=$(basename -- "$file" .py)
301+
if [[ $benchmark = @("__init__"|"benchmark_driver"|"benchmark_testing") ]]; then
302+
continue
303+
fi
304+
echo
305+
echo "****** Running ${benchmark} ******"
306+
echo
307+
python $file
308+
done
309+
}
310+
291311
run_instrumentation_tests() {
292312
# FIXME: the "instrumentation" test suite currently contains only one test, when all tests
293313
# are skipped pytest reports an error. If the only test is the skip list, then we shouldn't
@@ -339,6 +359,9 @@ test_triton() {
339359
if [ "$TEST_MICRO_BENCHMARKS" = true ]; then
340360
run_microbench_tests
341361
fi
362+
if [ "$TEST_BENCHMARKS" = true ]; then
363+
run_benchmarks
364+
fi
342365
if [ "$TEST_BENCHMARK_SOFTMAX" = true ]; then
343366
run_benchmark_softmax
344367
fi

0 commit comments

Comments
 (0)