run.sh 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. #/bin/bash
  2. #
  3. # sample usage:
  4. #
  5. # mkdir tmp
  6. #
  7. # # CPU-only build
  8. # bash ./ci/run.sh ./tmp/results ./tmp/mnt
  9. #
  10. # # with CUDA support
  11. # GG_BUILD_CUDA=1 bash ./ci/run.sh ./tmp/results ./tmp/mnt
  12. #
  13. # # with SYCL support
  14. # GG_BUILD_SYCL=1 bash ./ci/run.sh ./tmp/results ./tmp/mnt
  15. #
  16. if [ -z "$2" ]; then
  17. echo "usage: $0 <output-dir> <mnt-dir>"
  18. exit 1
  19. fi
  20. mkdir -p "$1"
  21. mkdir -p "$2"
  22. OUT=$(realpath "$1")
  23. MNT=$(realpath "$2")
  24. rm -f "$OUT/*.log"
  25. rm -f "$OUT/*.exit"
  26. rm -f "$OUT/*.md"
  27. sd=`dirname $0`
  28. cd $sd/../
  29. SRC=`pwd`
  30. CMAKE_EXTRA="-DLLAMA_FATAL_WARNINGS=ON"
  31. if [ ! -z ${GG_BUILD_METAL} ]; then
  32. CMAKE_EXTRA="${CMAKE_EXTRA} -DLLAMA_METAL_SHADER_DEBUG=ON"
  33. fi
  34. if [ ! -z ${GG_BUILD_CUDA} ]; then
  35. CMAKE_EXTRA="${CMAKE_EXTRA} -DLLAMA_CUBLAS=1"
  36. fi
  37. if [ ! -z ${GG_BUILD_SYCL} ]; then
  38. if [ -z ${ONEAPI_ROOT} ]; then
  39. echo "Not detected ONEAPI_ROOT, please install oneAPI base toolkit and enable it by:"
  40. echo "source /opt/intel/oneapi/setvars.sh"
  41. exit 1
  42. fi
  43. CMAKE_EXTRA="${CMAKE_EXTRA} -DLLAMA_SYCL=1 DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DLLAMA_SYCL_F16=ON"
  44. fi
  45. ## helpers
  46. # download a file if it does not exist or if it is outdated
  47. function gg_wget {
  48. local out=$1
  49. local url=$2
  50. local cwd=`pwd`
  51. mkdir -p $out
  52. cd $out
  53. # should not re-download if file is the same
  54. wget -nv -N $url
  55. cd $cwd
  56. }
  57. function gg_printf {
  58. printf -- "$@" >> $OUT/README.md
  59. }
  60. function gg_run {
  61. ci=$1
  62. set -o pipefail
  63. set -x
  64. gg_run_$ci | tee $OUT/$ci.log
  65. cur=$?
  66. echo "$cur" > $OUT/$ci.exit
  67. set +x
  68. set +o pipefail
  69. gg_sum_$ci
  70. ret=$((ret | cur))
  71. }
  72. ## ci
  73. # ctest_debug
  74. function gg_run_ctest_debug {
  75. cd ${SRC}
  76. rm -rf build-ci-debug && mkdir build-ci-debug && cd build-ci-debug
  77. set -e
  78. (time cmake -DCMAKE_BUILD_TYPE=Debug ${CMAKE_EXTRA} .. ) 2>&1 | tee -a $OUT/${ci}-cmake.log
  79. (time make -j ) 2>&1 | tee -a $OUT/${ci}-make.log
  80. (time ctest --output-on-failure -L main -E test-opt ) 2>&1 | tee -a $OUT/${ci}-ctest.log
  81. set +e
  82. }
  83. function gg_sum_ctest_debug {
  84. gg_printf '### %s\n\n' "${ci}"
  85. gg_printf 'Runs ctest in debug mode\n'
  86. gg_printf '- status: %s\n' "$(cat $OUT/${ci}.exit)"
  87. gg_printf '```\n'
  88. gg_printf '%s\n' "$(cat $OUT/${ci}-ctest.log)"
  89. gg_printf '```\n'
  90. gg_printf '\n'
  91. }
  92. # ctest_release
  93. function gg_run_ctest_release {
  94. cd ${SRC}
  95. rm -rf build-ci-release && mkdir build-ci-release && cd build-ci-release
  96. set -e
  97. (time cmake -DCMAKE_BUILD_TYPE=Release ${CMAKE_EXTRA} .. ) 2>&1 | tee -a $OUT/${ci}-cmake.log
  98. (time make -j ) 2>&1 | tee -a $OUT/${ci}-make.log
  99. if [ -z ${GG_BUILD_LOW_PERF} ]; then
  100. (time ctest --output-on-failure -L main ) 2>&1 | tee -a $OUT/${ci}-ctest.log
  101. else
  102. (time ctest --output-on-failure -L main -E test-opt ) 2>&1 | tee -a $OUT/${ci}-ctest.log
  103. fi
  104. set +e
  105. }
  106. function gg_sum_ctest_release {
  107. gg_printf '### %s\n\n' "${ci}"
  108. gg_printf 'Runs ctest in release mode\n'
  109. gg_printf '- status: %s\n' "$(cat $OUT/${ci}.exit)"
  110. gg_printf '```\n'
  111. gg_printf '%s\n' "$(cat $OUT/${ci}-ctest.log)"
  112. gg_printf '```\n'
  113. }
  114. function gg_get_model {
  115. local gguf_3b="$MNT/models/open-llama/3B-v2/ggml-model-f16.gguf"
  116. local gguf_7b="$MNT/models/open-llama/7B-v2/ggml-model-f16.gguf"
  117. if [[ -s $gguf_3b ]]; then
  118. echo -n "$gguf_3b"
  119. elif [[ -s $gguf_7b ]]; then
  120. echo -n "$gguf_7b"
  121. else
  122. echo >&2 "No model found. Can't run gg_run_ctest_with_model."
  123. exit 1
  124. fi
  125. }
  126. function gg_run_ctest_with_model_debug {
  127. cd ${SRC}
  128. local model; model=$(gg_get_model)
  129. cd build-ci-debug
  130. set -e
  131. (LLAMACPP_TEST_MODELFILE="$model" time ctest --output-on-failure -L model) 2>&1 | tee -a $OUT/${ci}-ctest.log
  132. set +e
  133. cd ..
  134. }
  135. function gg_run_ctest_with_model_release {
  136. cd ${SRC}
  137. local model; model=$(gg_get_model)
  138. cd build-ci-release
  139. set -e
  140. (LLAMACPP_TEST_MODELFILE="$model" time ctest --output-on-failure -L model) 2>&1 | tee -a $OUT/${ci}-ctest.log
  141. set +e
  142. cd ..
  143. }
  144. function gg_sum_ctest_with_model_debug {
  145. gg_printf '### %s\n\n' "${ci}"
  146. gg_printf 'Runs ctest with model files in debug mode\n'
  147. gg_printf '- status: %s\n' "$(cat $OUT/${ci}.exit)"
  148. gg_printf '```\n'
  149. gg_printf '%s\n' "$(cat $OUT/${ci}-ctest.log)"
  150. gg_printf '```\n'
  151. }
  152. function gg_sum_ctest_with_model_release {
  153. gg_printf '### %s\n\n' "${ci}"
  154. gg_printf 'Runs ctest with model files in release mode\n'
  155. gg_printf '- status: %s\n' "$(cat $OUT/${ci}.exit)"
  156. gg_printf '```\n'
  157. gg_printf '%s\n' "$(cat $OUT/${ci}-ctest.log)"
  158. gg_printf '```\n'
  159. }
  160. # open_llama_3b_v2
  161. function gg_run_open_llama_3b_v2 {
  162. cd ${SRC}
  163. gg_wget models-mnt/open-llama/3B-v2/ https://huggingface.co/openlm-research/open_llama_3b_v2/raw/main/config.json
  164. gg_wget models-mnt/open-llama/3B-v2/ https://huggingface.co/openlm-research/open_llama_3b_v2/resolve/main/tokenizer.model
  165. gg_wget models-mnt/open-llama/3B-v2/ https://huggingface.co/openlm-research/open_llama_3b_v2/raw/main/tokenizer_config.json
  166. gg_wget models-mnt/open-llama/3B-v2/ https://huggingface.co/openlm-research/open_llama_3b_v2/raw/main/special_tokens_map.json
  167. gg_wget models-mnt/open-llama/3B-v2/ https://huggingface.co/openlm-research/open_llama_3b_v2/resolve/main/pytorch_model.bin
  168. gg_wget models-mnt/open-llama/3B-v2/ https://huggingface.co/openlm-research/open_llama_3b_v2/raw/main/generation_config.json
  169. gg_wget models-mnt/wikitext/ https://huggingface.co/datasets/ggml-org/ci/resolve/main/wikitext-2-raw-v1.zip
  170. unzip -o models-mnt/wikitext/wikitext-2-raw-v1.zip -d models-mnt/wikitext/
  171. head -n 60 models-mnt/wikitext/wikitext-2-raw/wiki.test.raw > models-mnt/wikitext/wikitext-2-raw/wiki.test-60.raw
  172. path_models="../models-mnt/open-llama/3B-v2"
  173. path_wiki="../models-mnt/wikitext/wikitext-2-raw"
  174. rm -rf build-ci-release && mkdir build-ci-release && cd build-ci-release
  175. set -e
  176. (time cmake -DCMAKE_BUILD_TYPE=Release ${CMAKE_EXTRA} -DLLAMA_QKK_64=1 .. ) 2>&1 | tee -a $OUT/${ci}-cmake.log
  177. (time make -j ) 2>&1 | tee -a $OUT/${ci}-make.log
  178. python3 ../convert.py ${path_models}
  179. model_f16="${path_models}/ggml-model-f16.gguf"
  180. model_q8_0="${path_models}/ggml-model-q8_0.gguf"
  181. model_q4_0="${path_models}/ggml-model-q4_0.gguf"
  182. model_q4_1="${path_models}/ggml-model-q4_1.gguf"
  183. model_q5_0="${path_models}/ggml-model-q5_0.gguf"
  184. model_q5_1="${path_models}/ggml-model-q5_1.gguf"
  185. model_q2_k="${path_models}/ggml-model-q2_k.gguf"
  186. model_q3_k="${path_models}/ggml-model-q3_k.gguf"
  187. model_q4_k="${path_models}/ggml-model-q4_k.gguf"
  188. model_q5_k="${path_models}/ggml-model-q5_k.gguf"
  189. model_q6_k="${path_models}/ggml-model-q6_k.gguf"
  190. wiki_test_60="${path_wiki}/wiki.test-60.raw"
  191. ./bin/quantize ${model_f16} ${model_q8_0} q8_0
  192. ./bin/quantize ${model_f16} ${model_q4_0} q4_0
  193. ./bin/quantize ${model_f16} ${model_q4_1} q4_1
  194. ./bin/quantize ${model_f16} ${model_q5_0} q5_0
  195. ./bin/quantize ${model_f16} ${model_q5_1} q5_1
  196. ./bin/quantize ${model_f16} ${model_q2_k} q2_k
  197. ./bin/quantize ${model_f16} ${model_q3_k} q3_k
  198. ./bin/quantize ${model_f16} ${model_q4_k} q4_k
  199. ./bin/quantize ${model_f16} ${model_q5_k} q5_k
  200. ./bin/quantize ${model_f16} ${model_q6_k} q6_k
  201. (time ./bin/main --model ${model_f16} -s 1234 -n 64 --ignore-eos -p "I believe the meaning of life is" ) 2>&1 | tee -a $OUT/${ci}-tg-f16.log
  202. (time ./bin/main --model ${model_q8_0} -s 1234 -n 64 --ignore-eos -p "I believe the meaning of life is" ) 2>&1 | tee -a $OUT/${ci}-tg-q8_0.log
  203. (time ./bin/main --model ${model_q4_0} -s 1234 -n 64 --ignore-eos -p "I believe the meaning of life is" ) 2>&1 | tee -a $OUT/${ci}-tg-q4_0.log
  204. (time ./bin/main --model ${model_q4_1} -s 1234 -n 64 --ignore-eos -p "I believe the meaning of life is" ) 2>&1 | tee -a $OUT/${ci}-tg-q4_1.log
  205. (time ./bin/main --model ${model_q5_0} -s 1234 -n 64 --ignore-eos -p "I believe the meaning of life is" ) 2>&1 | tee -a $OUT/${ci}-tg-q5_0.log
  206. (time ./bin/main --model ${model_q5_1} -s 1234 -n 64 --ignore-eos -p "I believe the meaning of life is" ) 2>&1 | tee -a $OUT/${ci}-tg-q5_1.log
  207. (time ./bin/main --model ${model_q2_k} -s 1234 -n 64 --ignore-eos -p "I believe the meaning of life is" ) 2>&1 | tee -a $OUT/${ci}-tg-q2_k.log
  208. (time ./bin/main --model ${model_q3_k} -s 1234 -n 64 --ignore-eos -p "I believe the meaning of life is" ) 2>&1 | tee -a $OUT/${ci}-tg-q3_k.log
  209. (time ./bin/main --model ${model_q4_k} -s 1234 -n 64 --ignore-eos -p "I believe the meaning of life is" ) 2>&1 | tee -a $OUT/${ci}-tg-q4_k.log
  210. (time ./bin/main --model ${model_q5_k} -s 1234 -n 64 --ignore-eos -p "I believe the meaning of life is" ) 2>&1 | tee -a $OUT/${ci}-tg-q5_k.log
  211. (time ./bin/main --model ${model_q6_k} -s 1234 -n 64 --ignore-eos -p "I believe the meaning of life is" ) 2>&1 | tee -a $OUT/${ci}-tg-q6_k.log
  212. (time ./bin/perplexity --model ${model_f16} -f ${wiki_test_60} -c 128 -b 128 --chunks 1 ) 2>&1 | tee -a $OUT/${ci}-tg-f16.log
  213. (time ./bin/perplexity --model ${model_q8_0} -f ${wiki_test_60} -c 128 -b 128 --chunks 1 ) 2>&1 | tee -a $OUT/${ci}-tg-q8_0.log
  214. (time ./bin/perplexity --model ${model_q4_0} -f ${wiki_test_60} -c 128 -b 128 --chunks 1 ) 2>&1 | tee -a $OUT/${ci}-tg-q4_0.log
  215. (time ./bin/perplexity --model ${model_q4_1} -f ${wiki_test_60} -c 128 -b 128 --chunks 1 ) 2>&1 | tee -a $OUT/${ci}-tg-q4_1.log
  216. (time ./bin/perplexity --model ${model_q5_0} -f ${wiki_test_60} -c 128 -b 128 --chunks 1 ) 2>&1 | tee -a $OUT/${ci}-tg-q5_0.log
  217. (time ./bin/perplexity --model ${model_q5_1} -f ${wiki_test_60} -c 128 -b 128 --chunks 1 ) 2>&1 | tee -a $OUT/${ci}-tg-q5_1.log
  218. (time ./bin/perplexity --model ${model_q2_k} -f ${wiki_test_60} -c 128 -b 128 --chunks 1 ) 2>&1 | tee -a $OUT/${ci}-tg-q2_k.log
  219. (time ./bin/perplexity --model ${model_q3_k} -f ${wiki_test_60} -c 128 -b 128 --chunks 1 ) 2>&1 | tee -a $OUT/${ci}-tg-q3_k.log
  220. (time ./bin/perplexity --model ${model_q4_k} -f ${wiki_test_60} -c 128 -b 128 --chunks 1 ) 2>&1 | tee -a $OUT/${ci}-tg-q4_k.log
  221. (time ./bin/perplexity --model ${model_q5_k} -f ${wiki_test_60} -c 128 -b 128 --chunks 1 ) 2>&1 | tee -a $OUT/${ci}-tg-q5_k.log
  222. (time ./bin/perplexity --model ${model_q6_k} -f ${wiki_test_60} -c 128 -b 128 --chunks 1 ) 2>&1 | tee -a $OUT/${ci}-tg-q6_k.log
  223. (time ./bin/imatrix --model ${model_f16} -f ${wiki_test_60} -c 128 -b 128 --chunks 1 ) 2>&1 | tee -a $OUT/${ci}-imatrix.log
  224. (time ./bin/save-load-state --model ${model_q4_0} ) 2>&1 | tee -a $OUT/${ci}-save-load-state.log
  225. function check_ppl {
  226. qnt="$1"
  227. ppl=$(echo "$2" | grep -oE "[0-9]+\.[0-9]+" | tail -n 1)
  228. if [ $(echo "$ppl > 20.0" | bc) -eq 1 ]; then
  229. printf ' - %s @ %s (FAIL: ppl > 20.0)\n' "$qnt" "$ppl"
  230. return 20
  231. fi
  232. printf ' - %s @ %s OK\n' "$qnt" "$ppl"
  233. return 0
  234. }
  235. check_ppl "f16" "$(cat $OUT/${ci}-tg-f16.log | grep "^\[1\]")" | tee -a $OUT/${ci}-ppl.log
  236. check_ppl "q8_0" "$(cat $OUT/${ci}-tg-q8_0.log | grep "^\[1\]")" | tee -a $OUT/${ci}-ppl.log
  237. check_ppl "q4_0" "$(cat $OUT/${ci}-tg-q4_0.log | grep "^\[1\]")" | tee -a $OUT/${ci}-ppl.log
  238. check_ppl "q4_1" "$(cat $OUT/${ci}-tg-q4_1.log | grep "^\[1\]")" | tee -a $OUT/${ci}-ppl.log
  239. check_ppl "q5_0" "$(cat $OUT/${ci}-tg-q5_0.log | grep "^\[1\]")" | tee -a $OUT/${ci}-ppl.log
  240. check_ppl "q5_1" "$(cat $OUT/${ci}-tg-q5_1.log | grep "^\[1\]")" | tee -a $OUT/${ci}-ppl.log
  241. check_ppl "q2_k" "$(cat $OUT/${ci}-tg-q2_k.log | grep "^\[1\]")" | tee -a $OUT/${ci}-ppl.log
  242. check_ppl "q3_k" "$(cat $OUT/${ci}-tg-q3_k.log | grep "^\[1\]")" | tee -a $OUT/${ci}-ppl.log
  243. check_ppl "q4_k" "$(cat $OUT/${ci}-tg-q4_k.log | grep "^\[1\]")" | tee -a $OUT/${ci}-ppl.log
  244. check_ppl "q5_k" "$(cat $OUT/${ci}-tg-q5_k.log | grep "^\[1\]")" | tee -a $OUT/${ci}-ppl.log
  245. check_ppl "q6_k" "$(cat $OUT/${ci}-tg-q6_k.log | grep "^\[1\]")" | tee -a $OUT/${ci}-ppl.log
  246. cat $OUT/${ci}-imatrix.log | grep "Final" >> $OUT/${ci}-imatrix-sum.log
  247. # lora
  248. function compare_ppl {
  249. qnt="$1"
  250. ppl1=$(echo "$2" | grep -oE "[0-9]+\.[0-9]+" | tail -n 1)
  251. ppl2=$(echo "$3" | grep -oE "[0-9]+\.[0-9]+" | tail -n 1)
  252. if [ $(echo "$ppl1 < $ppl2" | bc) -eq 1 ]; then
  253. printf ' - %s @ %s (FAIL: %s > %s)\n' "$qnt" "$ppl" "$ppl1" "$ppl2"
  254. return 20
  255. fi
  256. printf ' - %s @ %s %s OK\n' "$qnt" "$ppl1" "$ppl2"
  257. return 0
  258. }
  259. path_lora="../models-mnt/open-llama/3B-v2/lora"
  260. path_shakespeare="../models-mnt/shakespeare"
  261. shakespeare="${path_shakespeare}/shakespeare.txt"
  262. lora_shakespeare="${path_lora}/ggml-adapter-model.bin"
  263. gg_wget ${path_lora} https://huggingface.co/slaren/open_llama_3b_v2_shakespeare_lora/resolve/main/adapter_config.json
  264. gg_wget ${path_lora} https://huggingface.co/slaren/open_llama_3b_v2_shakespeare_lora/resolve/main/adapter_model.bin
  265. gg_wget ${path_shakespeare} https://huggingface.co/slaren/open_llama_3b_v2_shakespeare_lora/resolve/main/shakespeare.txt
  266. python3 ../convert-lora-to-ggml.py ${path_lora}
  267. # f16
  268. (time ./bin/perplexity --model ${model_f16} -f ${shakespeare} -c 128 -b 128 --chunks 1 ) 2>&1 | tee -a $OUT/${ci}-ppl-shakespeare-f16.log
  269. (time ./bin/perplexity --model ${model_f16} -f ${shakespeare} --lora ${lora_shakespeare} -c 128 -b 128 --chunks 1 ) 2>&1 | tee -a $OUT/${ci}-ppl-shakespeare-lora-f16.log
  270. compare_ppl "f16 shakespeare" "$(cat $OUT/${ci}-ppl-shakespeare-f16.log | grep "^\[1\]")" "$(cat $OUT/${ci}-ppl-shakespeare-lora-f16.log | grep "^\[1\]")" | tee -a $OUT/${ci}-lora-ppl.log
  271. # q8_0
  272. (time ./bin/perplexity --model ${model_q8_0} -f ${shakespeare} -c 128 -b 128 --chunks 1 ) 2>&1 | tee -a $OUT/${ci}-ppl-shakespeare-q8_0.log
  273. (time ./bin/perplexity --model ${model_q8_0} -f ${shakespeare} --lora ${lora_shakespeare} -c 128 -b 128 --chunks 1 ) 2>&1 | tee -a $OUT/${ci}-ppl-shakespeare-lora-q8_0.log
  274. compare_ppl "q8_0 shakespeare" "$(cat $OUT/${ci}-ppl-shakespeare-q8_0.log | grep "^\[1\]")" "$(cat $OUT/${ci}-ppl-shakespeare-lora-q8_0.log | grep "^\[1\]")" | tee -a $OUT/${ci}-lora-ppl.log
  275. # q8_0 + f16 lora-base
  276. (time ./bin/perplexity --model ${model_q8_0} -f ${shakespeare} --lora ${lora_shakespeare} --lora-base ${model_f16} -c 128 -b 128 --chunks 1 ) 2>&1 | tee -a $OUT/${ci}-ppl-shakespeare-lora-q8_0-f16.log
  277. compare_ppl "q8_0 / f16 base shakespeare" "$(cat $OUT/${ci}-ppl-shakespeare-q8_0.log | grep "^\[1\]")" "$(cat $OUT/${ci}-ppl-shakespeare-lora-q8_0-f16.log | grep "^\[1\]")" | tee -a $OUT/${ci}-lora-ppl.log
  278. set +e
  279. }
  280. function gg_sum_open_llama_3b_v2 {
  281. gg_printf '### %s\n\n' "${ci}"
  282. gg_printf 'OpenLLaMA 3B-v2:\n'
  283. gg_printf '- status: %s\n' "$(cat $OUT/${ci}.exit)"
  284. gg_printf '- perplexity:\n%s\n' "$(cat $OUT/${ci}-ppl.log)"
  285. gg_printf '- imatrix:\n```\n%s\n```\n' "$(cat $OUT/${ci}-imatrix-sum.log)"
  286. gg_printf '- lora:\n%s\n' "$(cat $OUT/${ci}-lora-ppl.log)"
  287. gg_printf '- f16: \n```\n%s\n```\n' "$(cat $OUT/${ci}-tg-f16.log)"
  288. gg_printf '- q8_0:\n```\n%s\n```\n' "$(cat $OUT/${ci}-tg-q8_0.log)"
  289. gg_printf '- q4_0:\n```\n%s\n```\n' "$(cat $OUT/${ci}-tg-q4_0.log)"
  290. gg_printf '- q4_1:\n```\n%s\n```\n' "$(cat $OUT/${ci}-tg-q4_1.log)"
  291. gg_printf '- q5_0:\n```\n%s\n```\n' "$(cat $OUT/${ci}-tg-q5_0.log)"
  292. gg_printf '- q5_1:\n```\n%s\n```\n' "$(cat $OUT/${ci}-tg-q5_1.log)"
  293. gg_printf '- q2_k:\n```\n%s\n```\n' "$(cat $OUT/${ci}-tg-q2_k.log)"
  294. gg_printf '- q3_k:\n```\n%s\n```\n' "$(cat $OUT/${ci}-tg-q3_k.log)"
  295. gg_printf '- q4_k:\n```\n%s\n```\n' "$(cat $OUT/${ci}-tg-q4_k.log)"
  296. gg_printf '- q5_k:\n```\n%s\n```\n' "$(cat $OUT/${ci}-tg-q5_k.log)"
  297. gg_printf '- q6_k:\n```\n%s\n```\n' "$(cat $OUT/${ci}-tg-q6_k.log)"
  298. gg_printf '- save-load-state: \n```\n%s\n```\n' "$(cat $OUT/${ci}-save-load-state.log)"
  299. gg_printf '- shakespeare (f16):\n```\n%s\n```\n' "$(cat $OUT/${ci}-ppl-shakespeare-f16.log)"
  300. gg_printf '- shakespeare (f16 lora):\n```\n%s\n```\n' "$(cat $OUT/${ci}-ppl-shakespeare-lora-f16.log)"
  301. gg_printf '- shakespeare (q8_0):\n```\n%s\n```\n' "$(cat $OUT/${ci}-ppl-shakespeare-q8_0.log)"
  302. gg_printf '- shakespeare (q8_0 lora):\n```\n%s\n```\n' "$(cat $OUT/${ci}-ppl-shakespeare-lora-q8_0.log)"
  303. gg_printf '- shakespeare (q8_0 / f16 base lora):\n```\n%s\n```\n' "$(cat $OUT/${ci}-ppl-shakespeare-lora-q8_0-f16.log)"
  304. }
  305. # open_llama_7b_v2
  306. # requires: GG_BUILD_CUDA
  307. function gg_run_open_llama_7b_v2 {
  308. cd ${SRC}
  309. gg_wget models-mnt/open-llama/7B-v2/ https://huggingface.co/openlm-research/open_llama_7b_v2/raw/main/config.json
  310. gg_wget models-mnt/open-llama/7B-v2/ https://huggingface.co/openlm-research/open_llama_7b_v2/resolve/main/tokenizer.model
  311. gg_wget models-mnt/open-llama/7B-v2/ https://huggingface.co/openlm-research/open_llama_7b_v2/raw/main/tokenizer_config.json
  312. gg_wget models-mnt/open-llama/7B-v2/ https://huggingface.co/openlm-research/open_llama_7b_v2/raw/main/special_tokens_map.json
  313. gg_wget models-mnt/open-llama/7B-v2/ https://huggingface.co/openlm-research/open_llama_7b_v2/raw/main/pytorch_model.bin.index.json
  314. gg_wget models-mnt/open-llama/7B-v2/ https://huggingface.co/openlm-research/open_llama_7b_v2/resolve/main/pytorch_model-00001-of-00002.bin
  315. gg_wget models-mnt/open-llama/7B-v2/ https://huggingface.co/openlm-research/open_llama_7b_v2/resolve/main/pytorch_model-00002-of-00002.bin
  316. gg_wget models-mnt/open-llama/7B-v2/ https://huggingface.co/openlm-research/open_llama_7b_v2/raw/main/generation_config.json
  317. gg_wget models-mnt/wikitext/ https://huggingface.co/datasets/ggml-org/ci/resolve/main/wikitext-2-raw-v1.zip
  318. unzip -o models-mnt/wikitext/wikitext-2-raw-v1.zip -d models-mnt/wikitext/
  319. path_models="../models-mnt/open-llama/7B-v2"
  320. path_wiki="../models-mnt/wikitext/wikitext-2-raw"
  321. rm -rf build-ci-release && mkdir build-ci-release && cd build-ci-release
  322. set -e
  323. (time cmake -DCMAKE_BUILD_TYPE=Release ${CMAKE_EXTRA} -DLLAMA_CUBLAS=1 .. ) 2>&1 | tee -a $OUT/${ci}-cmake.log
  324. (time make -j ) 2>&1 | tee -a $OUT/${ci}-make.log
  325. python3 ../convert.py ${path_models}
  326. model_f16="${path_models}/ggml-model-f16.gguf"
  327. model_q8_0="${path_models}/ggml-model-q8_0.gguf"
  328. model_q4_0="${path_models}/ggml-model-q4_0.gguf"
  329. model_q4_1="${path_models}/ggml-model-q4_1.gguf"
  330. model_q5_0="${path_models}/ggml-model-q5_0.gguf"
  331. model_q5_1="${path_models}/ggml-model-q5_1.gguf"
  332. model_q2_k="${path_models}/ggml-model-q2_k.gguf"
  333. model_q3_k="${path_models}/ggml-model-q3_k.gguf"
  334. model_q4_k="${path_models}/ggml-model-q4_k.gguf"
  335. model_q5_k="${path_models}/ggml-model-q5_k.gguf"
  336. model_q6_k="${path_models}/ggml-model-q6_k.gguf"
  337. wiki_test="${path_wiki}/wiki.test.raw"
  338. ./bin/quantize ${model_f16} ${model_q8_0} q8_0
  339. ./bin/quantize ${model_f16} ${model_q4_0} q4_0
  340. ./bin/quantize ${model_f16} ${model_q4_1} q4_1
  341. ./bin/quantize ${model_f16} ${model_q5_0} q5_0
  342. ./bin/quantize ${model_f16} ${model_q5_1} q5_1
  343. ./bin/quantize ${model_f16} ${model_q2_k} q2_k
  344. ./bin/quantize ${model_f16} ${model_q3_k} q3_k
  345. ./bin/quantize ${model_f16} ${model_q4_k} q4_k
  346. ./bin/quantize ${model_f16} ${model_q5_k} q5_k
  347. ./bin/quantize ${model_f16} ${model_q6_k} q6_k
  348. (time ./bin/main --model ${model_f16} -t 1 -ngl 999 -s 1234 -n 256 --ignore-eos -p "I believe the meaning of life is" ) 2>&1 | tee -a $OUT/${ci}-tg-f16.log
  349. (time ./bin/main --model ${model_q8_0} -t 1 -ngl 999 -s 1234 -n 256 --ignore-eos -p "I believe the meaning of life is" ) 2>&1 | tee -a $OUT/${ci}-tg-q8_0.log
  350. (time ./bin/main --model ${model_q4_0} -t 1 -ngl 999 -s 1234 -n 256 --ignore-eos -p "I believe the meaning of life is" ) 2>&1 | tee -a $OUT/${ci}-tg-q4_0.log
  351. (time ./bin/main --model ${model_q4_1} -t 1 -ngl 999 -s 1234 -n 256 --ignore-eos -p "I believe the meaning of life is" ) 2>&1 | tee -a $OUT/${ci}-tg-q4_1.log
  352. (time ./bin/main --model ${model_q5_0} -t 1 -ngl 999 -s 1234 -n 256 --ignore-eos -p "I believe the meaning of life is" ) 2>&1 | tee -a $OUT/${ci}-tg-q5_0.log
  353. (time ./bin/main --model ${model_q5_1} -t 1 -ngl 999 -s 1234 -n 256 --ignore-eos -p "I believe the meaning of life is" ) 2>&1 | tee -a $OUT/${ci}-tg-q5_1.log
  354. (time ./bin/main --model ${model_q2_k} -t 1 -ngl 999 -s 1234 -n 256 --ignore-eos -p "I believe the meaning of life is" ) 2>&1 | tee -a $OUT/${ci}-tg-q2_k.log
  355. (time ./bin/main --model ${model_q3_k} -t 1 -ngl 999 -s 1234 -n 256 --ignore-eos -p "I believe the meaning of life is" ) 2>&1 | tee -a $OUT/${ci}-tg-q3_k.log
  356. (time ./bin/main --model ${model_q4_k} -t 1 -ngl 999 -s 1234 -n 256 --ignore-eos -p "I believe the meaning of life is" ) 2>&1 | tee -a $OUT/${ci}-tg-q4_k.log
  357. (time ./bin/main --model ${model_q5_k} -t 1 -ngl 999 -s 1234 -n 256 --ignore-eos -p "I believe the meaning of life is" ) 2>&1 | tee -a $OUT/${ci}-tg-q5_k.log
  358. (time ./bin/main --model ${model_q6_k} -t 1 -ngl 999 -s 1234 -n 256 --ignore-eos -p "I believe the meaning of life is" ) 2>&1 | tee -a $OUT/${ci}-tg-q6_k.log
  359. (time ./bin/perplexity --model ${model_f16} -f ${wiki_test} -t 1 -ngl 999 -c 2048 -b 512 --chunks 4 ) 2>&1 | tee -a $OUT/${ci}-tg-f16.log
  360. (time ./bin/perplexity --model ${model_q8_0} -f ${wiki_test} -t 1 -ngl 999 -c 2048 -b 512 --chunks 4 ) 2>&1 | tee -a $OUT/${ci}-tg-q8_0.log
  361. (time ./bin/perplexity --model ${model_q4_0} -f ${wiki_test} -t 1 -ngl 999 -c 2048 -b 512 --chunks 4 ) 2>&1 | tee -a $OUT/${ci}-tg-q4_0.log
  362. (time ./bin/perplexity --model ${model_q4_1} -f ${wiki_test} -t 1 -ngl 999 -c 2048 -b 512 --chunks 4 ) 2>&1 | tee -a $OUT/${ci}-tg-q4_1.log
  363. (time ./bin/perplexity --model ${model_q5_0} -f ${wiki_test} -t 1 -ngl 999 -c 2048 -b 512 --chunks 4 ) 2>&1 | tee -a $OUT/${ci}-tg-q5_0.log
  364. (time ./bin/perplexity --model ${model_q5_1} -f ${wiki_test} -t 1 -ngl 999 -c 2048 -b 512 --chunks 4 ) 2>&1 | tee -a $OUT/${ci}-tg-q5_1.log
  365. (time ./bin/perplexity --model ${model_q2_k} -f ${wiki_test} -t 1 -ngl 999 -c 2048 -b 512 --chunks 4 ) 2>&1 | tee -a $OUT/${ci}-tg-q2_k.log
  366. (time ./bin/perplexity --model ${model_q3_k} -f ${wiki_test} -t 1 -ngl 999 -c 2048 -b 512 --chunks 4 ) 2>&1 | tee -a $OUT/${ci}-tg-q3_k.log
  367. (time ./bin/perplexity --model ${model_q4_k} -f ${wiki_test} -t 1 -ngl 999 -c 2048 -b 512 --chunks 4 ) 2>&1 | tee -a $OUT/${ci}-tg-q4_k.log
  368. (time ./bin/perplexity --model ${model_q5_k} -f ${wiki_test} -t 1 -ngl 999 -c 2048 -b 512 --chunks 4 ) 2>&1 | tee -a $OUT/${ci}-tg-q5_k.log
  369. (time ./bin/perplexity --model ${model_q6_k} -f ${wiki_test} -t 1 -ngl 999 -c 2048 -b 512 --chunks 4 ) 2>&1 | tee -a $OUT/${ci}-tg-q6_k.log
  370. (time ./bin/imatrix --model ${model_f16} -f ${wiki_test} -t 1 -ngl 999 -c 2048 -b 512 --chunks 4 ) 2>&1 | tee -a $OUT/${ci}-imatrix.log
  371. (time ./bin/save-load-state --model ${model_q4_0} ) 2>&1 | tee -a $OUT/${ci}-save-load-state.log
  372. function check_ppl {
  373. qnt="$1"
  374. ppl=$(echo "$2" | grep -oE "[0-9]+\.[0-9]+" | tail -n 1)
  375. if [ $(echo "$ppl > 20.0" | bc) -eq 1 ]; then
  376. printf ' - %s @ %s (FAIL: ppl > 20.0)\n' "$qnt" "$ppl"
  377. return 20
  378. fi
  379. printf ' - %s @ %s OK\n' "$qnt" "$ppl"
  380. return 0
  381. }
  382. check_ppl "f16" "$(cat $OUT/${ci}-tg-f16.log | grep "^\[1\]")" | tee -a $OUT/${ci}-ppl.log
  383. check_ppl "q8_0" "$(cat $OUT/${ci}-tg-q8_0.log | grep "^\[1\]")" | tee -a $OUT/${ci}-ppl.log
  384. check_ppl "q4_0" "$(cat $OUT/${ci}-tg-q4_0.log | grep "^\[1\]")" | tee -a $OUT/${ci}-ppl.log
  385. check_ppl "q4_1" "$(cat $OUT/${ci}-tg-q4_1.log | grep "^\[1\]")" | tee -a $OUT/${ci}-ppl.log
  386. check_ppl "q5_0" "$(cat $OUT/${ci}-tg-q5_0.log | grep "^\[1\]")" | tee -a $OUT/${ci}-ppl.log
  387. check_ppl "q5_1" "$(cat $OUT/${ci}-tg-q5_1.log | grep "^\[1\]")" | tee -a $OUT/${ci}-ppl.log
  388. check_ppl "q2_k" "$(cat $OUT/${ci}-tg-q2_k.log | grep "^\[1\]")" | tee -a $OUT/${ci}-ppl.log
  389. check_ppl "q3_k" "$(cat $OUT/${ci}-tg-q3_k.log | grep "^\[1\]")" | tee -a $OUT/${ci}-ppl.log
  390. check_ppl "q4_k" "$(cat $OUT/${ci}-tg-q4_k.log | grep "^\[1\]")" | tee -a $OUT/${ci}-ppl.log
  391. check_ppl "q5_k" "$(cat $OUT/${ci}-tg-q5_k.log | grep "^\[1\]")" | tee -a $OUT/${ci}-ppl.log
  392. check_ppl "q6_k" "$(cat $OUT/${ci}-tg-q6_k.log | grep "^\[1\]")" | tee -a $OUT/${ci}-ppl.log
  393. cat $OUT/${ci}-imatrix.log | grep "Final" >> $OUT/${ci}-imatrix-sum.log
  394. # lora
  395. function compare_ppl {
  396. qnt="$1"
  397. ppl1=$(echo "$2" | grep -oE "[0-9]+\.[0-9]+" | tail -n 1)
  398. ppl2=$(echo "$3" | grep -oE "[0-9]+\.[0-9]+" | tail -n 1)
  399. if [ $(echo "$ppl1 < $ppl2" | bc) -eq 1 ]; then
  400. printf ' - %s @ %s (FAIL: %s > %s)\n' "$qnt" "$ppl" "$ppl1" "$ppl2"
  401. return 20
  402. fi
  403. printf ' - %s @ %s %s OK\n' "$qnt" "$ppl1" "$ppl2"
  404. return 0
  405. }
  406. path_lora="../models-mnt/open-llama/7B-v2/lora"
  407. path_shakespeare="../models-mnt/shakespeare"
  408. shakespeare="${path_shakespeare}/shakespeare.txt"
  409. lora_shakespeare="${path_lora}/ggml-adapter-model.bin"
  410. gg_wget ${path_lora} https://huggingface.co/slaren/open_llama_7b_v2_shakespeare_lora/resolve/main/adapter_config.json
  411. gg_wget ${path_lora} https://huggingface.co/slaren/open_llama_7b_v2_shakespeare_lora/resolve/main/adapter_model.bin
  412. gg_wget ${path_shakespeare} https://huggingface.co/slaren/open_llama_7b_v2_shakespeare_lora/resolve/main/shakespeare.txt
  413. python3 ../convert-lora-to-ggml.py ${path_lora}
  414. # f16
  415. (time ./bin/perplexity --model ${model_f16} -f ${shakespeare} -t 1 -ngl 999 -c 2048 -b 512 --chunks 3 ) 2>&1 | tee -a $OUT/${ci}-ppl-shakespeare-f16.log
  416. (time ./bin/perplexity --model ${model_f16} -f ${shakespeare} --lora ${lora_shakespeare} -t 1 -ngl 999 -c 2048 -b 512 --chunks 3 ) 2>&1 | tee -a $OUT/${ci}-ppl-shakespeare-lora-f16.log
  417. compare_ppl "f16 shakespeare" "$(cat $OUT/${ci}-ppl-shakespeare-f16.log | grep "^\[1\]")" "$(cat $OUT/${ci}-ppl-shakespeare-lora-f16.log | grep "^\[1\]")" | tee -a $OUT/${ci}-lora-ppl.log
  418. # currently not supported by the CUDA backend
  419. # q8_0
  420. #(time ./bin/perplexity --model ${model_q8_0} -f ${shakespeare} -t 1 -ngl 999 -c 2048 -b 512 --chunks 3 ) 2>&1 | tee -a $OUT/${ci}-ppl-shakespeare-q8_0.log
  421. #(time ./bin/perplexity --model ${model_q8_0} -f ${shakespeare} --lora ${lora_shakespeare} -t 1 -ngl 999 -c 2048 -b 512 --chunks 3 ) 2>&1 | tee -a $OUT/${ci}-ppl-shakespeare-lora-q8_0.log
  422. #compare_ppl "q8_0 shakespeare" "$(cat $OUT/${ci}-ppl-shakespeare-q8_0.log | grep "^\[1\]")" "$(cat $OUT/${ci}-ppl-shakespeare-lora-q8_0.log | grep "^\[1\]")" | tee -a $OUT/${ci}-lora-ppl.log
  423. # q8_0 + f16 lora-base
  424. #(time ./bin/perplexity --model ${model_q8_0} -f ${shakespeare} --lora ${lora_shakespeare} --lora-base ${model_f16} -t 1 -ngl 999 -c 2048 -b 512 --chunks 3 ) 2>&1 | tee -a $OUT/${ci}-ppl-shakespeare-lora-q8_0-f16.log
  425. #compare_ppl "q8_0 / f16 shakespeare" "$(cat $OUT/${ci}-ppl-shakespeare-q8_0.log | grep "^\[1\]")" "$(cat $OUT/${ci}-ppl-shakespeare-lora-q8_0-f16.log | grep "^\[1\]")" | tee -a $OUT/${ci}-lora-ppl.log
  426. set +e
  427. }
  428. function gg_sum_open_llama_7b_v2 {
  429. gg_printf '### %s\n\n' "${ci}"
  430. gg_printf 'OpenLLaMA 7B-v2:\n'
  431. gg_printf '- status: %s\n' "$(cat $OUT/${ci}.exit)"
  432. gg_printf '- perplexity:\n%s\n' "$(cat $OUT/${ci}-ppl.log)"
  433. gg_printf '- imatrix:\n```\n%s\n```\n' "$(cat $OUT/${ci}-imatrix-sum.log)"
  434. gg_printf '- lora:\n%s\n' "$(cat $OUT/${ci}-lora-ppl.log)"
  435. gg_printf '- f16: \n```\n%s\n```\n' "$(cat $OUT/${ci}-tg-f16.log)"
  436. gg_printf '- q8_0:\n```\n%s\n```\n' "$(cat $OUT/${ci}-tg-q8_0.log)"
  437. gg_printf '- q4_0:\n```\n%s\n```\n' "$(cat $OUT/${ci}-tg-q4_0.log)"
  438. gg_printf '- q4_1:\n```\n%s\n```\n' "$(cat $OUT/${ci}-tg-q4_1.log)"
  439. gg_printf '- q5_0:\n```\n%s\n```\n' "$(cat $OUT/${ci}-tg-q5_0.log)"
  440. gg_printf '- q5_1:\n```\n%s\n```\n' "$(cat $OUT/${ci}-tg-q5_1.log)"
  441. gg_printf '- q2_k:\n```\n%s\n```\n' "$(cat $OUT/${ci}-tg-q2_k.log)"
  442. gg_printf '- q3_k:\n```\n%s\n```\n' "$(cat $OUT/${ci}-tg-q3_k.log)"
  443. gg_printf '- q4_k:\n```\n%s\n```\n' "$(cat $OUT/${ci}-tg-q4_k.log)"
  444. gg_printf '- q5_k:\n```\n%s\n```\n' "$(cat $OUT/${ci}-tg-q5_k.log)"
  445. gg_printf '- q6_k:\n```\n%s\n```\n' "$(cat $OUT/${ci}-tg-q6_k.log)"
  446. gg_printf '- save-load-state: \n```\n%s\n```\n' "$(cat $OUT/${ci}-save-load-state.log)"
  447. gg_printf '- shakespeare (f16):\n```\n%s\n```\n' "$(cat $OUT/${ci}-ppl-shakespeare-f16.log)"
  448. gg_printf '- shakespeare (f16 lora):\n```\n%s\n```\n' "$(cat $OUT/${ci}-ppl-shakespeare-lora-f16.log)"
  449. #gg_printf '- shakespeare (q8_0):\n```\n%s\n```\n' "$(cat $OUT/${ci}-ppl-shakespeare-q8_0.log)"
  450. #gg_printf '- shakespeare (q8_0 lora):\n```\n%s\n```\n' "$(cat $OUT/${ci}-ppl-shakespeare-lora-q8_0.log)"
  451. #gg_printf '- shakespeare (q8_0 / f16 base lora):\n```\n%s\n```\n' "$(cat $OUT/${ci}-ppl-shakespeare-lora-q8_0-f16.log)"
  452. }
  453. # bge-small
  454. function gg_run_embd_bge_small {
  455. cd ${SRC}
  456. gg_wget models-mnt/bge-small/ https://huggingface.co/BAAI/bge-small-en-v1.5/raw/main/config.json
  457. gg_wget models-mnt/bge-small/ https://huggingface.co/BAAI/bge-small-en-v1.5/resolve/main/tokenizer.model
  458. gg_wget models-mnt/bge-small/ https://huggingface.co/BAAI/bge-small-en-v1.5/raw/main/tokenizer_config.json
  459. gg_wget models-mnt/bge-small/ https://huggingface.co/BAAI/bge-small-en-v1.5/raw/main/special_tokens_map.json
  460. gg_wget models-mnt/bge-small/ https://huggingface.co/BAAI/bge-small-en-v1.5/resolve/main/pytorch_model.bin
  461. gg_wget models-mnt/bge-small/ https://huggingface.co/BAAI/bge-small-en-v1.5/raw/main/sentence_bert_config.json
  462. gg_wget models-mnt/bge-small/ https://huggingface.co/BAAI/bge-small-en-v1.5/raw/main/vocab.txt
  463. gg_wget models-mnt/bge-small/ https://huggingface.co/BAAI/bge-small-en-v1.5/raw/main/modules.json
  464. gg_wget models-mnt/bge-small/ https://huggingface.co/BAAI/bge-small-en-v1.5/raw/main/config.json
  465. gg_wget models-mnt/bge-small/1_Pooling https://huggingface.co/BAAI/bge-small-en-v1.5/raw/main/1_Pooling/config.json
  466. path_models="../models-mnt/bge-small"
  467. rm -rf build-ci-release && mkdir build-ci-release && cd build-ci-release
  468. set -e
  469. (time cmake -DCMAKE_BUILD_TYPE=Release ${CMAKE_EXTRA} .. ) 2>&1 | tee -a $OUT/${ci}-cmake.log
  470. (time make -j ) 2>&1 | tee -a $OUT/${ci}-make.log
  471. python3 ../convert-hf-to-gguf.py ${path_models}
  472. model_f16="${path_models}/ggml-model-f16.gguf"
  473. model_q8_0="${path_models}/ggml-model-q8_0.gguf"
  474. ./bin/quantize ${model_f16} ${model_q8_0} q8_0
  475. (time ./bin/embedding --model ${model_f16} -p "I believe the meaning of life is" ) 2>&1 | tee -a $OUT/${ci}-tg-f16.log
  476. (time ./bin/embedding --model ${model_q8_0} -p "I believe the meaning of life is" ) 2>&1 | tee -a $OUT/${ci}-tg-q8_0.log
  477. set +e
  478. }
  479. function gg_sum_embd_bge_small {
  480. gg_printf '### %s\n\n' "${ci}"
  481. gg_printf 'BGE Small (BERT):\n'
  482. gg_printf '- status: %s\n' "$(cat $OUT/${ci}.exit)"
  483. gg_printf '- f16: \n```\n%s\n```\n' "$(cat $OUT/${ci}-tg-f16.log)"
  484. gg_printf '- q8_0:\n```\n%s\n```\n' "$(cat $OUT/${ci}-tg-q8_0.log)"
  485. }
  486. ## main
  487. if [ -z ${GG_BUILD_LOW_PERF} ]; then
  488. # Create symlink: ./llama.cpp/models-mnt -> $MNT/models/models-mnt
  489. rm -rf ${SRC}/models-mnt
  490. mnt_models=${MNT}/models
  491. mkdir -p ${mnt_models}
  492. ln -sfn ${mnt_models} ${SRC}/models-mnt
  493. # Create a fresh python3 venv and enter it
  494. python3 -m venv "$MNT/venv"
  495. source "$MNT/venv/bin/activate"
  496. pip install -r ${SRC}/requirements.txt --disable-pip-version-check
  497. pip install --editable gguf-py --disable-pip-version-check
  498. fi
  499. ret=0
  500. test $ret -eq 0 && gg_run ctest_debug
  501. test $ret -eq 0 && gg_run ctest_release
  502. if [ -z ${GG_BUILD_LOW_PERF} ]; then
  503. test $ret -eq 0 && gg_run embd_bge_small
  504. if [ -z ${GG_BUILD_VRAM_GB} ] || [ ${GG_BUILD_VRAM_GB} -ge 8 ]; then
  505. if [ -z ${GG_BUILD_CUDA} ]; then
  506. test $ret -eq 0 && gg_run open_llama_3b_v2
  507. else
  508. test $ret -eq 0 && gg_run open_llama_7b_v2
  509. fi
  510. test $ret -eq 0 && gg_run ctest_with_model_debug
  511. test $ret -eq 0 && gg_run ctest_with_model_release
  512. fi
  513. fi
  514. exit $ret