@@ -121,6 +121,16 @@ if [ "${DoCTest}" == "yes" ]; then
121121 ctest --output-on-failure 2>&1 | tee " ${LLAMA_TESTS_LOG_LOCATION} /ctest.log"
122122fi
123123
124+ run_llama_bench () {
125+ ./bin/llama-bench " $@ " 2>&1 | tee -a " ${LLAMA_TESTS_LOG_LOCATION} /llama-bench.log"
126+ BenchStatus=${PIPESTATUS[0]}
127+
128+ if [ " ${BenchStatus} " -ne 0 ]; then
129+ echo " ERROR: llama-bench failed with exit code ${BenchStatus} " | tee -a " ${LLAMA_TESTS_LOG_LOCATION} /llama-bench.log"
130+ return " ${BenchStatus} "
131+ fi
132+ }
133+
124134if [ " ${DoBenchmark} " == " yes" ]; then
125135 echo " Running benchmark..."
126136 cd " ${LLAMA_BUILD_DIR} " || exit
@@ -148,8 +158,7 @@ if [ "${DoBenchmark}" == "yes" ]; then
148158 if [ ${# ModelPaths[@]} -eq 0 ] && ./bin/llama-bench --help 2>&1 | grep -q -- " --hf-repo" ; then
149159 # Let llama-bench resolve/download the HF model directly. Using llama-cli as
150160 # a prefetch step can hang in ROCm/KFD waits on cold cache.
151- ./bin/llama-bench -hf " ${LLAMA_BENCH_HF_ID} " -ngl 999 -fa 1 -ub 2048 \
152- 2>&1 | tee -a " ${LLAMA_TESTS_LOG_LOCATION} /llama-bench.log"
161+ run_llama_bench -hf " ${LLAMA_BENCH_HF_ID} " -ngl 999 -fa 1 -ub 2048 || exit $?
153162 else
154163 if [ ${# ModelPaths[@]} -eq 0 ]; then
155164 echo " ERROR: No model files found in cache directory: ${CacheDir} "
@@ -159,7 +168,7 @@ if [ "${DoBenchmark}" == "yes" ]; then
159168 # Run benchmark for each model
160169 for LlamaModelPath in " ${ModelPaths[@]} " ; do
161170 echo " Benchmarking: ${LlamaModelPath} " | tee -a " ${LLAMA_TESTS_LOG_LOCATION} /llama-bench.log"
162- ./bin/llama-bench -ngl 999 -fa 1 -ub 2048 -m " ${LlamaModelPath} " 2>&1 | tee -a " ${LLAMA_TESTS_LOG_LOCATION} /llama-bench.log "
171+ run_llama_bench -ngl 999 -fa 1 -ub 2048 -m " ${LlamaModelPath} " || exit $?
163172 done
164173 fi
165174fi
0 commit comments