|
| 1 | +#/bin/bash |
| 2 | + |
| 3 | +sd=`dirname $0` |
| 4 | +cd $sd/../ |
| 5 | + |
| 6 | +SRC=`pwd` |
| 7 | +OUT="$1" |
| 8 | +MNT="$2" |
| 9 | + |
| 10 | +## helpers |
| 11 | + |
| 12 | +# download a file if it does not exist or if it is outdated |
| 13 | +function gg_wget { |
| 14 | + local out=$1 |
| 15 | + local url=$2 |
| 16 | + |
| 17 | + local cwd=`pwd` |
| 18 | + |
| 19 | + mkdir -p $out |
| 20 | + cd $out |
| 21 | + |
| 22 | + # should not re-download if file is the same |
| 23 | + wget -N $url |
| 24 | + |
| 25 | + cd $cwd |
| 26 | +} |
| 27 | + |
| 28 | +function gg_printf { |
| 29 | + printf -- "$@" >> $OUT/README.md |
| 30 | +} |
| 31 | + |
| 32 | +function gg_run { |
| 33 | + ci=$1 |
| 34 | + |
| 35 | + set -o pipefail |
| 36 | + set -x |
| 37 | + |
| 38 | + gg_run_$ci | tee $OUT/$ci.log |
| 39 | + cur=$? |
| 40 | + echo "$cur" > $OUT/$ci.exit |
| 41 | + |
| 42 | + set +x |
| 43 | + set +o pipefail |
| 44 | + |
| 45 | + gg_sum_$ci |
| 46 | + |
| 47 | + ret=$((ret | cur)) |
| 48 | +} |
| 49 | + |
| 50 | +## ci |
| 51 | + |
| 52 | +# ctest_debug |
| 53 | + |
| 54 | +function gg_run_ctest_debug { |
| 55 | + cd ${SRC} |
| 56 | + |
| 57 | + rm -rf build-ci-debug && mkdir build-ci-debug && cd build-ci-debug |
| 58 | + |
| 59 | + set -e |
| 60 | + |
| 61 | + (time cmake -DCMAKE_BUILD_TYPE=Debug .. ) 2>&1 | tee -a $OUT/${ci}-cmake.log |
| 62 | + (time make -j ) 2>&1 | tee -a $OUT/${ci}-make.log |
| 63 | + |
| 64 | + (time ctest --output-on-failure -E test-opt ) 2>&1 | tee -a $OUT/${ci}-ctest.log |
| 65 | + |
| 66 | + set +e |
| 67 | +} |
| 68 | + |
| 69 | +function gg_sum_ctest_debug { |
| 70 | + gg_printf '### %s\n\n' "${ci}" |
| 71 | + |
| 72 | + gg_printf 'Runs ctest in debug mode\n' |
| 73 | + gg_printf '- status: %s\n' "$(cat $OUT/${ci}.exit)" |
| 74 | + gg_printf '```\n' |
| 75 | + gg_printf '%s\n' "$(cat $OUT/${ci}-ctest.log)" |
| 76 | + gg_printf '```\n' |
| 77 | + gg_printf '\n' |
| 78 | +} |
| 79 | + |
| 80 | +# ctest_release |
| 81 | + |
| 82 | +function gg_run_ctest_release { |
| 83 | + cd ${SRC} |
| 84 | + |
| 85 | + rm -rf build-ci-release && mkdir build-ci-release && cd build-ci-release |
| 86 | + |
| 87 | + set -e |
| 88 | + |
| 89 | + (time cmake -DCMAKE_BUILD_TYPE=Release .. ) 2>&1 | tee -a $OUT/${ci}-cmake.log |
| 90 | + (time make -j ) 2>&1 | tee -a $OUT/${ci}-make.log |
| 91 | + |
| 92 | + if [ -z $GG_BUILD_LOW_PERF ]; then |
| 93 | + (time ctest --output-on-failure ) 2>&1 | tee -a $OUT/${ci}-ctest.log |
| 94 | + else |
| 95 | + (time ctest --output-on-failure -E test-opt ) 2>&1 | tee -a $OUT/${ci}-ctest.log |
| 96 | + fi |
| 97 | + |
| 98 | + set +e |
| 99 | +} |
| 100 | + |
| 101 | +function gg_sum_ctest_release { |
| 102 | + gg_printf '### %s\n\n' "${ci}" |
| 103 | + |
| 104 | + gg_printf 'Runs ctest in release mode\n' |
| 105 | + gg_printf '- status: %s\n' "$(cat $OUT/${ci}.exit)" |
| 106 | + gg_printf '```\n' |
| 107 | + gg_printf '%s\n' "$(cat $OUT/${ci}-ctest.log)" |
| 108 | + gg_printf '```\n' |
| 109 | +} |
| 110 | + |
| 111 | +# mpt |
| 112 | + |
| 113 | +#function gg_run_mpt { |
| 114 | +# cd ${SRC} |
| 115 | +# |
| 116 | +# gg_wget models/mpt/7B/ https://huggingface.co/mosaicml/mpt-7b/raw/main/config.json |
| 117 | +# gg_wget models/mpt/7B/ https://huggingface.co/mosaicml/mpt-7b/raw/main/tokenizer.json |
| 118 | +# gg_wget models/mpt/7B/ https://huggingface.co/mosaicml/mpt-7b/raw/main/tokenizer_config.json |
| 119 | +# gg_wget models/mpt/7B/ https://huggingface.co/mosaicml/mpt-7b/raw/main/pytorch_model.bin.index.json |
| 120 | +# gg_wget models/mpt/7B/ https://huggingface.co/mosaicml/mpt-7b/raw/main/configuration_mpt.py |
| 121 | +# gg_wget models/mpt/7B/ https://huggingface.co/mosaicml/mpt-7b/resolve/main/pytorch_model-00001-of-00002.bin |
| 122 | +# gg_wget models/mpt/7B/ https://huggingface.co/mosaicml/mpt-7b/resolve/main/pytorch_model-00002-of-00002.bin |
| 123 | +# |
| 124 | +# cd build-ci-release |
| 125 | +# |
| 126 | +# set -e |
| 127 | +# |
| 128 | +# path_models="../models/mpt/7B" |
| 129 | +# model_f16="${path_models}/ggml-model-f16.bin" |
| 130 | +# model_q4_0="${path_models}/ggml-model-q4_0.bin" |
| 131 | +# |
| 132 | +# python3 ../examples/mpt/convert-h5-to-ggml.py ${path_models} 1 |
| 133 | +# ./bin/mpt-quantize ${model_f16} ${model_q4_0} q4_0 |
| 134 | +# |
| 135 | +# (time ./bin/mpt --model ${model_f16} -s 1234 -n 64 -t 8 -p "I believe the meaning of life is") 2>&1 | tee -a $OUT/${ci}-tg.log |
| 136 | +# (time ./bin/mpt --model ${model_q4_0} -s 1234 -n 64 -t 8 -p "I believe the meaning of life is") 2>&1 | tee -a $OUT/${ci}-tg.log |
| 137 | +# |
| 138 | +# set +e |
| 139 | +#} |
| 140 | +# |
| 141 | +#function gg_sum_mpt { |
| 142 | +# gg_printf '### %s\n\n' "${ci}" |
| 143 | +# |
| 144 | +# gg_printf 'Runs short MPT text generation\n' |
| 145 | +# gg_printf '- status: %s\n' "$(cat $OUT/${ci}.exit)" |
| 146 | +# gg_printf '```\n' |
| 147 | +# gg_printf '%s\n' "$(cat $OUT/${ci}-tg.log)" |
| 148 | +# gg_printf '```\n' |
| 149 | +#} |
| 150 | + |
| 151 | +## main |
| 152 | + |
| 153 | +if [ -z $GG_BUILD_LOW_PERF ]; then |
| 154 | + rm -rf ${SRC}/models-mnt |
| 155 | + |
| 156 | + mkdir -p $(realpath ${MNT}/models) |
| 157 | + ln -sfn ${MNT}/models ${SRC}/models-mnt |
| 158 | + |
| 159 | + python3 -m pip install -r ${SRC}/requirements.txt |
| 160 | +fi |
| 161 | + |
| 162 | +ret=0 |
| 163 | + |
| 164 | +test $ret -eq 0 && gg_run ctest_debug |
| 165 | +test $ret -eq 0 && gg_run ctest_release |
| 166 | + |
| 167 | +#if [ -z $GG_BUILD_LOW_PERF ]; then |
| 168 | +# test $ret -eq 0 && gg_run mpt |
| 169 | +#fi |
| 170 | + |
| 171 | +exit $ret |
0 commit comments