Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 0765363

Browse files
authored
Refactored scripts for benchmark suits (#102)
1 parent a0fa7c7 commit 0765363

File tree

12 files changed

+100
-91
lines changed

12 files changed

+100
-91
lines changed

.github/workflows/execute-test-script.yml

+8-6
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ on:
3333
test_script:
3434
description: Test script to run
3535
required: false
36-
default: "./mlp.sh"
36+
default: "mlp.sh"
3737
type: string
3838
secrets:
3939
DB_URL:
@@ -122,11 +122,13 @@ jobs:
122122
URL="--url ${{ secrets.DB_URL }}"
123123
fi
124124
125-
export DL_BENCH_ARGS="--host ${{ inputs.runner_type }} --compiler ${{ inputs.compiler }} --device ${{ inputs.device }} --tag ${{ inputs.tag }} ${URL}"
125+
export COMPILER="${{ inputs.compiler }}"
126+
export DEVICE="${{ inputs.device }}"
127+
export OTHER_ARGS="--host ${{ inputs.runner_type }} --tag ${{ inputs.tag }} ${URL}"
126128
127129
# We mainly want to verify our own backend
128130
if [[ ${{ inputs.compiler }} != *torch_mlir* ]]; then
129-
DL_BENCH_ARGS="${DL_BENCH_ARGS} --skip_verification"
131+
OTHER_ARGS="${OTHER_ARGS} --skip_verification"
130132
fi
131133
132134
# HOST CONFIG
@@ -136,11 +138,11 @@ jobs:
136138
echo "CPU cores configured: $OMP_NUM_THREADS"
137139
if [[ ${LABELS} = *glados* ]]; then
138140
export HF_HOME="/cache/torchmlir/huggingface_cache"
139-
140-
numactl -m 0 --physcpubind=0-31 ${{ inputs.test_script }}
141+
142+
numactl -m 0 --physcpubind=0-31 ./bench_suit/${{ inputs.test_script }}
141143
else
142144
export HF_HOME="/data/torchmlir/huggingface_cache"
143-
source ${{ inputs.test_script}}
145+
source ./bench_suit/${{ inputs.test_script}}
144146
fi
145147
146148

.github/workflows/test-single-config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ on:
5555
test_scripts:
5656
description: Test scripts to execute
5757
required: false
58-
default: '["./mlp.sh", "./cnn.sh", "./llm.sh"]'
58+
default: '["mlp.sh", "cnn.sh", "llm.sh"]'
5959
type: string
6060

6161
jobs:

.github/workflows/test.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ on:
1919
test_scripts:
2020
description: Test scripts to execute
2121
required: false
22-
default: '["./mlp.sh", "./cnn.sh", "./llm.sh"]'
22+
default: '["mlp.sh", "cnn.sh", "llm.sh"]'
2323
type: string
2424
schedule:
2525
# Runs at 12pm UTC (6am CST) on every Saturday
@@ -44,13 +44,13 @@ jobs:
4444
- ipex_onednn_graph
4545
- torch_mlir
4646
- torch_mlir_xsmm
47-
test_script: ${{ github.event_name == 'workflow_dispatch' && fromJson(inputs.test_scripts) || fromJson('["./mlp.sh", "./cnn.sh", "./llm.sh"]') }}
47+
test_script: ${{ github.event_name == 'workflow_dispatch' && fromJson(inputs.test_scripts) || fromJson('["mlp.sh", "cnn.sh", "llm.sh"]') }}
4848
exclude:
49-
- test_script: "./llm.sh"
49+
- test_script: "llm.sh"
5050
compiler: torchscript
51-
- test_script: "./llm.sh"
51+
- test_script: "llm.sh"
5252
compiler: torchscript_onednn
53-
- test_script: "./llm.sh"
53+
- test_script: "llm.sh"
5454
compiler: ipex_onednn_graph
5555
fail-fast: false
5656
uses: ./.github/workflows/execute-test-script.yml

.github/workflows/test_nvidia.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414
test_scripts:
1515
description: Test scripts to execute
1616
required: false
17-
default: '["./mlp.sh", "./cnn.sh", "./llm.sh"]'
17+
default: '["mlp.sh", "cnn.sh", "llm.sh"]'
1818
type: string
1919

2020
jobs:

bench_suit/cnn.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
. "$(dirname "$0")/common.sh"
4+
5+
DTYPEs="float32 bfloat16"
6+
if [ "$COMPILER" = 'ipex_onednn_graph' ]; then
7+
DTYPEs="$DTYPEs int8"
8+
fi
9+
10+
run_benchmark_suit cnn "$DTYPEs" "1 32 128" "vgg16 resnet18 resnet50 resnext50 resnext101 densenet121"
11+
print_report

bench_suit/common.sh

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
3+
set -x
4+
5+
if [ -z "${COMPILER}" ]; then
6+
echo "Please, provide COMPILER environment variable"
7+
exit 1
8+
fi
9+
10+
if [ -z "${DEVICE}" ]; then
11+
echo "Please, provide DEVICE environment variable"
12+
exit 1
13+
fi
14+
15+
if [ -z "${OTHER_ARGS}" ]; then
16+
echo "Please, provide OTHER_ARGS environment variable"
17+
exit 1
18+
fi
19+
20+
# List of all benchmark runs that failed to report
21+
failed_commands=()
22+
23+
run_benchmark_suit() {
24+
BENCHMARK="$1"
25+
DTYPEs="$2"
26+
BSs="$3"
27+
NAMEs="$4"
28+
29+
echo "Running suit for benchmark=\"$BENCHMARK\" DTYPEs=\"$DTYPEs\" BSs=\"$BSs\" NAMEs=\"$NAMEs\""
30+
31+
for DTYPE in $DTYPEs
32+
do
33+
for BS in $BSs
34+
do
35+
for NAME in $NAMEs
36+
do
37+
echo "Benchmark $NAME with BS=$BS and DTYPE=$DTYPE"
38+
BS_TXT=$(printf "%04d" $BS)
39+
40+
CMD="benchmark-run -c ${COMPILER} -d ${DEVICE} -b ${BENCHMARK} -p name='${NAME}' --dtype ${DTYPE} -bs $BS --benchmark_desc ${NAME}_bs${BS_TXT} ${OTHER_ARGS}"
41+
$CMD || failed_commands+=("$CMD")
42+
done
43+
done
44+
done
45+
}
46+
47+
48+
print_report() {
49+
if [ ${#failed_commands[@]} -gt 0 ]; then
50+
echo "Some benchmarks failed, here's the list:"
51+
for CMD in "${failed_commands[@]}"; do
52+
echo "$CMD"
53+
done
54+
exit 1
55+
fi
56+
}

bench_suit/llm.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
. "$(dirname "$0")/common.sh"
4+
5+
run_benchmark_suit llm "bfloat16" "1 4 8" "llama2-7b llama2-13b gptj"
6+
print_report

bench_suit/mlp.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
. "$(dirname "$0")/common.sh"
4+
5+
DTYPEs="float32 bfloat16"
6+
if [ "$COMPILER" = 'ipex_onednn_graph' ]; then
7+
DTYPEs="$DTYPEs int8"
8+
fi
9+
10+
run_benchmark_suit mlp "$DTYPEs" "1024" "size2 size3 size4 size5 size5_sigm size5_tanh size5_gelu size5_linear size5_inplace size5_bn size5_bn_gelu size5_drop_gelu 100@512 25@1024 4@16384 2@16384"
11+
run_benchmark_suit mlp "$DTYPEs" "1 16 256 2048 8196" "size5"
12+
print_report

cnn.sh

-24
This file was deleted.

llm.sh

-24
This file was deleted.

repro.sh renamed to local/repro.sh

File renamed without changes.

mlp.sh

-30
This file was deleted.

0 commit comments

Comments
 (0)