|
| 1 | +#!/bin/bash |
| 2 | +set -x |
| 3 | + |
| 4 | +function main { |
| 5 | + |
| 6 | + init_params "$@" |
| 7 | + run_benchmark |
| 8 | + |
| 9 | +} |
| 10 | + |
| 11 | +# init params |
| 12 | +function init_params { |
| 13 | + iters=100 |
| 14 | + batch_size=16 |
| 15 | + approach=static |
| 16 | + tuned_checkpoint=saved_results |
| 17 | + task=lambada_openai |
| 18 | + echo ${max_eval_samples} |
| 19 | + for var in "$@" |
| 20 | + do |
| 21 | + case $var in |
| 22 | + --topology=*) |
| 23 | + topology=$(echo $var |cut -f2 -d=) |
| 24 | + ;; |
| 25 | + --dataset_location=*) |
| 26 | + dataset_location=$(echo $var |cut -f2 -d=) |
| 27 | + ;; |
| 28 | + --input_model=*) |
| 29 | + input_model=$(echo $var |cut -f2 -d=) |
| 30 | + ;; |
| 31 | + --mode=*) |
| 32 | + mode=$(echo $var |cut -f2 -d=) |
| 33 | + ;; |
| 34 | + --batch_size=*) |
| 35 | + batch_size=$(echo $var |cut -f2 -d=) |
| 36 | + ;; |
| 37 | + --iters=*) |
| 38 | + iters=$(echo ${var} |cut -f2 -d=) |
| 39 | + ;; |
| 40 | + --int8=*) |
| 41 | + int8=$(echo ${var} |cut -f2 -d=) |
| 42 | + ;; |
| 43 | + --config=*) |
| 44 | + tuned_checkpoint=$(echo $var |cut -f2 -d=) |
| 45 | + ;; |
| 46 | + *) |
| 47 | + echo "Error: No such parameter: ${var}" |
| 48 | + exit 1 |
| 49 | + ;; |
| 50 | + esac |
| 51 | + done |
| 52 | + |
| 53 | +} |
| 54 | + |
| 55 | + |
| 56 | +# run_benchmark |
| 57 | +function run_benchmark { |
| 58 | + extra_cmd='' |
| 59 | + |
| 60 | + if [[ ${mode} == "accuracy" ]]; then |
| 61 | + mode_cmd=" --accuracy " |
| 62 | + elif [[ ${mode} == "performance" ]]; then |
| 63 | + mode_cmd=" --performance --iters "${iters} |
| 64 | + else |
| 65 | + echo "Error: No such mode: ${mode}" |
| 66 | + exit 1 |
| 67 | + fi |
| 68 | + |
| 69 | + if [[ ${int8} == "true" ]]; then |
| 70 | + extra_cmd=$extra_cmd" --int8" |
| 71 | + fi |
| 72 | + echo $extra_cmd |
| 73 | + |
| 74 | + if [ "${topology}" = "opt_125m_woq_gptq_int4" ]; then |
| 75 | + model_name_or_path="facebook/opt-125m" |
| 76 | + approach="weight_only" |
| 77 | + extra_cmd=$extra_cmd" --woq_algo GPTQ --woq_bits 4 --woq_group_size 128 --woq_scheme asym --woq_use_mse_search --gptq_use_max_length" |
| 78 | + elif [ "${topology}" = "opt_125m_woq_gptq_int4_dq_bnb" ]; then |
| 79 | + model_name_or_path="facebook/opt-125m" |
| 80 | + approach="weight_only" |
| 81 | + extra_cmd=$extra_cmd" --woq_algo GPTQ --woq_bits 4 --woq_group_size 128 --woq_scheme asym --woq_use_mse_search --gptq_use_max_length" |
| 82 | + extra_cmd=$extra_cmd" --double_quant_type BNB_NF4" |
| 83 | + elif [ "${topology}" = "opt_125m_woq_gptq_int4_dq_ggml" ]; then |
| 84 | + model_name_or_path="facebook/opt-125m" |
| 85 | + approach="weight_only" |
| 86 | + extra_cmd=$extra_cmd" --woq_algo GPTQ --woq_bits 4 --woq_group_size 128 --woq_scheme asym --woq_use_mse_search --gptq_use_max_length --gptq_percdamp 0.1 --gptq_actorder" |
| 87 | + extra_cmd=$extra_cmd" --double_quant_type GGML_TYPE_Q4_K" |
| 88 | + elif [ "${topology}" = "opt_125m_ipex" ]; then |
| 89 | + model_name_or_path="facebook/opt-125m" |
| 90 | + extra_cmd=$extra_cmd" --ipex" |
| 91 | + elif [ "${topology}" = "opt_125m_ipex_sq" ]; then |
| 92 | + model_name_or_path="facebook/opt-125m" |
| 93 | + extra_cmd=$extra_cmd" --ipex --sq --alpha 0.5" |
| 94 | + elif [ "${topology}" = "llama2_7b_gptq_int4" ]; then |
| 95 | + model_name_or_path="meta-llama/Llama-2-7b-hf" |
| 96 | + approach="weight_only" |
| 97 | + extra_cmd=$extra_cmd" --woq_algo GPTQ --woq_bits 4 --woq_group_size 128 --woq_scheme asym --woq_use_mse_search --gptq_use_max_length" |
| 98 | + elif [ "${topology}" = "llama2_7b_gptq_int4_dq_bnb" ]; then |
| 99 | + model_name_or_path="meta-llama/Llama-2-7b-hf" |
| 100 | + approach="weight_only" |
| 101 | + extra_cmd=$extra_cmd" --woq_algo GPTQ --woq_bits 4 --woq_group_size 128 --woq_scheme asym --woq_use_mse_search --gptq_use_max_length" |
| 102 | + extra_cmd=$extra_cmd" --double_quant_type BNB_NF4" |
| 103 | + elif [ "${topology}" = "llama2_7b_gptq_int4_dq_ggml" ]; then |
| 104 | + model_name_or_path="meta-llama/Llama-2-7b-hf" |
| 105 | + approach="weight_only" |
| 106 | + extra_cmd=$extra_cmd" --woq_algo GPTQ --woq_bits 4 --woq_group_size 128 --woq_scheme asym --woq_use_mse_search --gptq_use_max_length" |
| 107 | + extra_cmd=$extra_cmd" --double_quant_type GGML_TYPE_Q4_K" |
| 108 | + elif [ "${topology}" = "llama2_7b_ipex" ]; then |
| 109 | + model_name_or_path="meta-llama/Llama-2-7b-hf" |
| 110 | + extra_cmd=$extra_cmd" --ipex" |
| 111 | + elif [ "${topology}" = "llama2_7b_ipex_sq" ]; then |
| 112 | + model_name_or_path="meta-llama/Llama-2-7b-hf" |
| 113 | + extra_cmd=$extra_cmd" --ipex --sq --alpha 0.8" |
| 114 | + elif [ "${topology}" = "gpt_j_woq_rtn_int4" ]; then |
| 115 | + model_name_or_path="EleutherAI/gpt-j-6b" |
| 116 | + approach="weight_only" |
| 117 | + extra_cmd=$extra_cmd" --woq_algo RTN --woq_bits 4 --woq_group_size 128 --woq_scheme asym --woq_use_mse_search" |
| 118 | + elif [ "${topology}" = "gpt_j_woq_rtn_int4_dq_bnb" ]; then |
| 119 | + model_name_or_path="EleutherAI/gpt-j-6b" |
| 120 | + approach="weight_only" |
| 121 | + extra_cmd=$extra_cmd" --woq_algo RTN --woq_bits 4 --woq_group_size 128 --woq_scheme asym --woq_use_mse_search" |
| 122 | + extra_cmd=$extra_cmd" --double_quant_type BNB_NF4" |
| 123 | + elif [ "${topology}" = "gpt_j_woq_rtn_int4_dq_ggml" ]; then |
| 124 | + model_name_or_path="EleutherAI/gpt-j-6b" |
| 125 | + approach="weight_only" |
| 126 | + extra_cmd=$extra_cmd" --woq_algo RTN --woq_bits 4 --woq_group_size 128 --woq_scheme asym --woq_use_mse_search" |
| 127 | + extra_cmd=$extra_cmd" --double_quant_type GGML_TYPE_Q4_K" |
| 128 | + elif [ "${topology}" = "gpt_j_woq_gptq_int4" ]; then |
| 129 | + model_name_or_path="EleutherAI/gpt-j-6b" |
| 130 | + approach="weight_only" |
| 131 | + extra_cmd=$extra_cmd" --woq_algo GPTQ --woq_bits 4 --woq_group_size 128 --woq_scheme asym --woq_use_mse_search --gptq_use_max_length" |
| 132 | + elif [ "${topology}" = "gpt_j_woq_gptq_int4_dq_bnb" ]; then |
| 133 | + model_name_or_path="EleutherAI/gpt-j-6b" |
| 134 | + approach="weight_only" |
| 135 | + extra_cmd=$extra_cmd" --woq_algo GPTQ --woq_bits 4 --woq_group_size 128 --woq_scheme asym --woq_use_mse_search --gptq_use_max_length" |
| 136 | + extra_cmd=$extra_cmd" --double_quant_type BNB_NF4" |
| 137 | + elif [ "${topology}" = "gpt_j_woq_gptq_int4_dq_ggml" ]; then |
| 138 | + model_name_or_path="EleutherAI/gpt-j-6b" |
| 139 | + approach="weight_only" |
| 140 | + extra_cmd=$extra_cmd" --woq_algo GPTQ --woq_bits 4 --woq_group_size 128 --woq_scheme asym --woq_use_mse_search --gptq_use_max_length" |
| 141 | + extra_cmd=$extra_cmd" --double_quant_type GGML_TYPE_Q4_K" |
| 142 | + elif [ "${topology}" = "gpt_j_ipex" ]; then |
| 143 | + model_name_or_path="EleutherAI/gpt-j-6b" |
| 144 | + extra_cmd=$extra_cmd" --ipex" |
| 145 | + elif [ "${topology}" = "gpt_j_ipex_sq" ]; then |
| 146 | + model_name_or_path="EleutherAI/gpt-j-6b" |
| 147 | + extra_cmd=$extra_cmd" --ipex --sq --alpha 1.0" |
| 148 | + fi |
| 149 | + |
| 150 | + python -u run_clm_no_trainer.py \ |
| 151 | + --model ${model_name_or_path} \ |
| 152 | + --approach ${approach} \ |
| 153 | + --output_dir ${tuned_checkpoint} \ |
| 154 | + --task ${task} \ |
| 155 | + --batch_size ${batch_size} \ |
| 156 | + ${extra_cmd} ${mode_cmd} |
| 157 | +} |
| 158 | + |
| 159 | +main "$@" |
0 commit comments