run.sh 32 KB

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