forked from intel/intel-extension-for-transformers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_benchmark.sh
232 lines (216 loc) · 7.2 KB
/
run_benchmark.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
#!/bin/bash
set -x
function main {
init_params "$@"
run_benchmark
}
# init params
function init_params {
iters=100
batch_size=16
tuned_checkpoint=saved_results
lm_eval_tasks="lambada_openai piqa"
for var in "$@"
do
case $var in
--topology=*)
topology=$(echo $var |cut -f2 -d=)
;;
--dataset_location=*)
dataset_location=$(echo $var |cut -f2 -d=)
;;
--input_model=*)
input_model=$(echo $var |cut -f2 -d=)
;;
--mode=*)
mode=$(echo $var |cut -f2 -d=)
;;
--batch_size=*)
batch_size=$(echo $var |cut -f2 -d=)
;;
--iters=*)
iters=$(echo ${var} |cut -f2 -d=)
;;
--int8=*)
int8=$(echo ${var} |cut -f2 -d=)
;;
--config=*)
tuned_checkpoint=$(echo $var |cut -f2 -d=)
;;
--task=*)
task=$(echo $var |cut -f2 -d=)
;;
--approach=*)
approach=$(echo $var |cut -f2 -d=)
;;
--backend=*)
backend=$(echo $var |cut -f2 -d=)
;;
*)
echo "Error: No such parameter: ${var}"
exit 1
;;
esac
done
}
# run_benchmark
function run_benchmark {
extra_cmd=''
if [ "${topology}" = "gpt_neo" ]; then
if [ "${task}" = "clm" ]; then
script="run_clm.py"
fi
DATASET_NAME="wikitext"
DATASET_CONFIG_NAME="wikitext-2-raw-v1"
model_name_or_path="EleutherAI/gpt-neo-125M"
elif [ "${topology}" = "gpt_j" ]; then
if [ "${task}" = "clm" ]; then
script="run_clm.py"
fi
DATASET_NAME="wikitext"
DATASET_CONFIG_NAME="wikitext-2-raw-v1"
model_name_or_path="/tf_dataset2/models/pytorch/gpt-j-6B"
if [ "${backend}" = "ipex" ]; then
script="run_clm_no_trainer.py"
model_name_or_path="/tf_dataset2/models/pytorch/gpt-j-6B"
extra_cmd=$extra_cmd" --ipex"
fi
elif [ "${topology}" = "gpt_j_woq" ]; then
script="run_clm_no_trainer.py"
model_name_or_path="/tf_dataset2/models/pytorch/gpt-j-6B"
lm_eval_tasks="lambada_openai"
extra_cmd=$extra_cmd" --approach weight_only"
elif [ "${topology}" = "chatglm_woq" ]; then
script="run_clm_no_trainer.py"
model_name_or_path="THUDM/chatglm-6b"
lm_eval_tasks="lambada_openai"
extra_cmd=$extra_cmd" --approach weight_only"
elif [ "${topology}" = "gpt_j_woq_awq" ]; then
script="run_clm_no_trainer.py"
model_name_or_path="/tf_dataset2/models/pytorch/gpt-j-6B"
lm_eval_tasks="lambada_openai"
extra_cmd=$extra_cmd" --approach weight_only"
elif [ "${topology}" = "mpt_7b_chat" ]; then
if [ "${backend}" = "ipex" ]; then
extra_cmd=$extra_cmd" --ipex"
fi
script="run_clm_no_trainer.py"
model_name_or_path="mosaicml/mpt-7b-chat"
elif [ "${topology}" = "falcon_7b_instruct" ]; then
script="run_clm_no_trainer.py"
model_name_or_path="tiiuae/falcon-7b-instruct"
elif [ "${topology}" = "opt_125m_woq" -o \
"${topology}" = "opt_125m_woq_awq" -o \
"${topology}" = "opt_125m_woq_gptq" -o \
"${topology}" = "opt_125m_woq_teq" ]; then
script="run_clm_no_trainer.py"
model_name_or_path="facebook/opt-125m"
lm_eval_tasks="lambada_openai"
extra_cmd=$extra_cmd" --approach weight_only"
elif [ "${topology}" = "opt_125m" ]; then
script="run_clm_no_trainer.py"
model_name_or_path="facebook/opt-125m"
if [ "${backend}" = "ipex" ]; then
extra_cmd=$extra_cmd" --ipex"
fi
elif [ "${topology}" = "opt_1.3b" ]; then
script="run_clm_no_trainer.py"
model_name_or_path="facebook/opt-1.3b"
if [ "${backend}" = "ipex" ]; then
extra_cmd=$extra_cmd" --ipex"
fi
elif [ "${topology}" = "opt_2.7b" ]; then
script="run_clm_no_trainer.py"
model_name_or_path="facebook/opt-2.7b"
if [ "${backend}" = "ipex" ]; then
extra_cmd=$extra_cmd" --ipex"
fi
elif [ "${topology}" = "opt_6.7b" ]; then
script="run_clm_no_trainer.py"
model_name_or_path="facebook/opt-6.7b"
if [ "${backend}" = "ipex" ]; then
extra_cmd=$extra_cmd" --ipex"
fi
elif [ "${topology}" = "llama_7b" ]; then
script="run_clm_no_trainer.py"
model_name_or_path="decapoda-research/llama-7b-hf"
if [ "${backend}" = "ipex" ]; then
extra_cmd=$extra_cmd" --ipex"
fi
elif [ "${topology}" = "bert" ]; then
script="run_mlm.py"
DATASET_NAME="wikitext"
DATASET_CONFIG_NAME="wikitext-2-raw-v1"
model_name_or_path="bert-base-uncased"
elif [ "${topology}" = "xlnet" ]; then
script="run_plm.py"
DATASET_NAME="wikitext"
DATASET_CONFIG_NAME="wikitext-2-raw-v1"
model_name_or_path="xlnet-base-cased"
elif [ "${topology}" = "gpt_neox" ]; then
script="run_clm.py"
DATASET_NAME="oscar"
DATASET_CONFIG_NAME="unshuffled_original_ast"
model_name_or_path="abeja/gpt-neox-japanese-2.7b"
elif [ "${topology}" = "bloom" ]; then
script="run_clm.py"
DATASET_NAME="lambada"
model_name_or_path="bigscience/bloom-560m"
fi
if [[ ${int8} == "true" ]]; then
extra_cmd=$extra_cmd" --int8"
if [ ${script} != "run_clm_no_trainer.py" ]; then
model_name_or_path=${tuned_checkpoint}
fi
fi
if [ "${script}" == "run_clm_no_trainer.py" ]; then
if [ "${lm_eval_tasks}" != "" ]; then
extra_cmd=$extra_cmd" --tasks ${lm_eval_tasks}"
fi
fi
echo $extra_cmd
if [[ ${mode} == "accuracy" ]]; then
mode_cmd=" --accuracy"
elif [[ ${mode} == "benchmark" ]]; then
if [ "${script}" == "run_clm_no_trainer.py" ]; then
echo "Error: Only support accuracy now."
echo "Please go to text-generation folder to get performance."
exit 1
fi
mode_cmd=" --benchmark"
fi
if [ "${script}" == "run_clm_no_trainer.py" ];then
python -u ./${script} \
--model ${model_name_or_path} \
--output_dir ${tuned_checkpoint} \
--batch_size ${batch_size} \
${mode_cmd} \
${extra_cmd}
elif [ -z ${DATASET_CONFIG_NAME} ];then
python -u ${script} \
--model_name_or_path ${model_name_or_path} \
--dataset_name ${DATASET_NAME} \
--do_eval \
--per_device_eval_batch_size ${batch_size} \
--output_dir ./tmp/benchmark_output \
--overwrite_output_dir \
--overwrite_cache \
--no_cuda \
${mode_cmd} \
${extra_cmd}
else
python -u ${script} \
--model_name_or_path ${model_name_or_path} \
--dataset_name ${DATASET_NAME} \
--dataset_config_name ${DATASET_CONFIG_NAME} \
--do_eval \
--per_device_eval_batch_size ${batch_size} \
--output_dir ./tmp/benchmark_output \
--overwrite_output_dir \
--overwrite_cache \
--no_cuda \
${mode_cmd} \
${extra_cmd}
fi
}
main "$@"