Skip to content

Commit a1d4c18

Browse files
rillomastaronaeo
andauthored
ci: Allow ninja to be used during unit test (ggml-org#20742)
* Remove make dependency * Added option to specify Ninja generator * use ninja-build as default for several CI * Revert "use ninja-build as default for several CI" This reverts commit f552c45. * changed use plain string rather than arrays * Enabled ninja build by default for experimentation * ci: add run.sh to test conditions to trigger GitHub CI and self-hosted runners Signed-off-by: Aaron Teo <aaron.teo1@ibm.com> * Enabled ninja build by default on self-hosted envs for experimentation * ci: revert generator to ninja instead of ninja multi-config Signed-off-by: Aaron Teo <aaron.teo1@ibm.com> * ci: install ninja-build for self-hosted workflows Signed-off-by: Aaron Teo <aaron.teo1@ibm.com> * ci: revert ninja from self-hosted runners Signed-off-by: Aaron Teo <aaron.teo1@ibm.com> * ci: missed one self-hosted step Signed-off-by: Aaron Teo <aaron.teo1@ibm.com> * ci: fix windows ci errors from an errenous revert Signed-off-by: Aaron Teo <aaron.teo1@ibm.com> * Added explicit build types for Ninja Also reverted some needless change * ci: use ninja multi-config for vulkan-x64 build Signed-off-by: Aaron Teo <aaron.teo1@ibm.com> * added time command to measure build time * Keeping some configs to use Ninja which show improvement * minor fix based on review Co-authored-by: Aaron Teo <taronaeo@gmail.com> * ci: rm `time` from custom containers Signed-off-by: Aaron Teo <aaron.teo1@ibm.com> --------- Signed-off-by: Aaron Teo <aaron.teo1@ibm.com> Co-authored-by: Aaron Teo <aaron.teo1@ibm.com> Co-authored-by: Aaron Teo <taronaeo@gmail.com>
1 parent 87bbeee commit a1d4c18

2 files changed

Lines changed: 50 additions & 39 deletions

File tree

.github/workflows/build.yml

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787
-DGGML_METAL_EMBED_LIBRARY=OFF \
8888
-DGGML_METAL_SHADER_DEBUG=ON \
8989
-DGGML_RPC=ON
90-
cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
90+
time cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
9191
leaks -atExit -- ./build/bin/test-thread-safety -hf ggml-org/gemma-3-270m-qat-GGUF -ngl 99 -p "$(printf 'hello %.0s' {1..128})" -n 16 -c 512 -ub 32 -np 2 -t 2 -lv 1
9292
9393
- name: Test
@@ -124,7 +124,7 @@ jobs:
124124
-DGGML_METAL=OFF \
125125
-DGGML_RPC=ON \
126126
-DCMAKE_OSX_DEPLOYMENT_TARGET=13.3
127-
cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
127+
time cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
128128
129129
- name: Test
130130
id: cmake_test
@@ -165,8 +165,8 @@ jobs:
165165
id: cmake_build
166166
run: |
167167
export CMAKE_PREFIX_PATH=dawn
168-
cmake -B build -DGGML_WEBGPU=ON -DGGML_METAL=OFF -DGGML_BLAS=OFF
169-
cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
168+
cmake -B build -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DGGML_WEBGPU=ON -DGGML_METAL=OFF -DGGML_BLAS=OFF
169+
time cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
170170
171171
- name: Test
172172
id: cmake_test
@@ -231,7 +231,7 @@ jobs:
231231
cmake -B build \
232232
-DLLAMA_FATAL_WARNINGS=ON \
233233
-DGGML_RPC=ON
234-
cmake --build build --config Release -j $(nproc)
234+
time cmake --build build --config Release -j $(nproc)
235235
236236
- name: Test
237237
id: cmake_test
@@ -274,14 +274,16 @@ jobs:
274274
id: depends
275275
run: |
276276
sudo apt-get update
277-
sudo apt-get install build-essential libssl-dev
277+
sudo apt-get install build-essential libssl-dev ninja-build
278278
279279
- name: Build
280280
id: cmake_build
281281
run: |
282282
cmake -B build \
283+
-G "Ninja" \
284+
-DCMAKE_BUILD_TYPE=Release \
283285
-DGGML_RPC=ON
284-
cmake --build build --config Release -j $(nproc)
286+
time cmake --build build --config Release -j $(nproc)
285287
286288
- name: Test
287289
id: cmake_test
@@ -300,12 +302,13 @@ jobs:
300302
- name: Dependencies
301303
id: depends
302304
run: |
303-
sudo apt-get install -y glslc libvulkan-dev libssl-dev
305+
sudo apt-get install -y glslc libvulkan-dev libssl-dev ninja-build
304306
305307
- name: Configure
306308
id: cmake_configure
307309
run: |
308310
cmake -B build \
311+
-G "Ninja" \
309312
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
310313
-DGGML_BACKEND_DL=ON \
311314
-DGGML_CPU_ALL_VARIANTS=ON \
@@ -314,7 +317,7 @@ jobs:
314317
- name: Build
315318
id: cmake_build
316319
run: |
317-
cmake --build build -j $(nproc)
320+
time cmake --build build -j $(nproc)
318321
319322
ubuntu-24-webgpu:
320323
runs-on: ubuntu-24.04
@@ -336,7 +339,8 @@ jobs:
336339
run: |
337340
sudo add-apt-repository -y ppa:kisak/kisak-mesa
338341
sudo apt-get update -y
339-
sudo apt-get install -y build-essential mesa-vulkan-drivers libxcb-xinput0 libxcb-xinerama0 libxcb-cursor-dev libssl-dev
342+
sudo apt-get install -y build-essential mesa-vulkan-drivers \
343+
libxcb-xinput0 libxcb-xinerama0 libxcb-cursor-dev libssl-dev
340344
341345
- name: Get latest Vulkan SDK version
342346
id: vulkan_sdk_version
@@ -378,7 +382,7 @@ jobs:
378382
export Dawn_DIR=dawn/lib64/cmake/Dawn
379383
cmake -B build \
380384
-DGGML_WEBGPU=ON
381-
cmake --build build --config Release -j $(nproc)
385+
time cmake --build build --config Release -j $(nproc)
382386
383387
- name: Test
384388
id: cmake_test
@@ -415,11 +419,13 @@ jobs:
415419
run: |
416420
source emsdk/emsdk_env.sh
417421
emcmake cmake -B build-wasm \
422+
-G "Ninja" \
423+
-DCMAKE_BUILD_TYPE=Release \
418424
-DGGML_WEBGPU=ON \
419425
-DLLAMA_OPENSSL=OFF \
420426
-DEMDAWNWEBGPU_DIR=emdawnwebgpu_pkg
421427
422-
cmake --build build-wasm --target test-backend-ops -j $(nproc)
428+
time cmake --build build-wasm --config Release --target test-backend-ops -j $(nproc)
423429
424430
ubuntu-22-hip:
425431
runs-on: ubuntu-22.04
@@ -479,7 +485,7 @@ jobs:
479485
run: |
480486
cmake -B build -S . \
481487
-DGGML_MUSA=ON
482-
cmake --build build --config Release -j $(nproc)
488+
time cmake --build build --config Release -j $(nproc)
483489
484490
ubuntu-22-sycl:
485491
runs-on: ubuntu-22.04
@@ -528,7 +534,7 @@ jobs:
528534
-DGGML_SYCL=ON \
529535
-DCMAKE_C_COMPILER=icx \
530536
-DCMAKE_CXX_COMPILER=icpx
531-
cmake --build build --config Release -j $(nproc)
537+
time cmake --build build --config Release -j $(nproc)
532538
533539
ubuntu-22-sycl-fp16:
534540
runs-on: ubuntu-22.04
@@ -551,7 +557,7 @@ jobs:
551557
shell: bash
552558
run: |
553559
sudo apt update
554-
sudo apt install intel-oneapi-compiler-dpcpp-cpp libssl-dev
560+
sudo apt install intel-oneapi-compiler-dpcpp-cpp libssl-dev ninja-build
555561
556562
- name: install oneAPI MKL library
557563
shell: bash
@@ -574,11 +580,13 @@ jobs:
574580
run: |
575581
source /opt/intel/oneapi/setvars.sh
576582
cmake -B build \
583+
-G "Ninja" \
584+
-DCMAKE_BUILD_TYPE=Release \
577585
-DGGML_SYCL=ON \
578586
-DCMAKE_C_COMPILER=icx \
579587
-DCMAKE_CXX_COMPILER=icpx \
580588
-DGGML_SYCL_F16=ON
581-
cmake --build build --config Release -j $(nproc)
589+
time cmake --build build --config Release -j $(nproc)
582590
583591
ubuntu-24-openvino:
584592
name: ubuntu-24-openvino-${{ matrix.openvino_device }}
@@ -648,7 +656,7 @@ jobs:
648656
cmake -B build/ReleaseOV -G Ninja \
649657
-DCMAKE_BUILD_TYPE=Release \
650658
-DGGML_OPENVINO=ON
651-
cmake --build build/ReleaseOV --config Release -j $(nproc)
659+
time cmake --build build/ReleaseOV --config Release -j $(nproc)
652660
653661
- name: Test
654662
id: cmake_test
@@ -1039,7 +1047,7 @@ jobs:
10391047
-DCMAKE_C_COMPILER=riscv64-linux-gnu-gcc-14 \
10401048
-DCMAKE_CXX_COMPILER=riscv64-linux-gnu-g++-14
10411049
1042-
cmake --build build --config Release -j $(nproc)
1050+
time cmake --build build --config Release -j $(nproc)
10431051
10441052
- name: Test
10451053
id: cmake_test

ci/run.sh

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ SRC=`pwd`
5757
CMAKE_EXTRA="-DLLAMA_FATAL_WARNINGS=${LLAMA_FATAL_WARNINGS:-ON} -DLLAMA_OPENSSL=OFF -DGGML_SCHED_NO_REALLOC=ON"
5858
CTEST_EXTRA=""
5959

60+
# Default to use make unless specified for compatibility
61+
CMAKE_GENERATOR="Unix Makefiles"
62+
63+
if [ ! -z "${GG_BUILD_NINJA}" ]; then
64+
CMAKE_GENERATOR="Ninja"
65+
fi
66+
6067
if [ ! -z ${GG_BUILD_METAL} ]; then
6168
CMAKE_EXTRA="${CMAKE_EXTRA} -DGGML_METAL=ON"
6269
fi
@@ -242,13 +249,13 @@ function gg_run_ctest_debug {
242249

243250
set -e
244251

245-
# Check cmake, make and ctest are installed
252+
# Check cmake and ctest are installed
246253
gg_check_build_requirements
247254

248-
(time cmake -DCMAKE_BUILD_TYPE=Debug ${CMAKE_EXTRA} .. ) 2>&1 | tee -a $OUT/${ci}-cmake.log
249-
(time make -j$(nproc) ) 2>&1 | tee -a $OUT/${ci}-make.log
255+
(cmake -G "${CMAKE_GENERATOR}" -DCMAKE_BUILD_TYPE=Debug ${CMAKE_EXTRA} .. ) 2>&1 | tee -a $OUT/${ci}-cmake.log
256+
(time cmake --build . --config Debug -j$(nproc)) 2>&1 | tee -a $OUT/${ci}-make.log
250257

251-
(time ctest --output-on-failure -L main -E "test-opt|test-backend-ops" ${CTEST_EXTRA}) 2>&1 | tee -a $OUT/${ci}-ctest.log
258+
(time ctest -C Debug --output-on-failure -L main -E "test-opt|test-backend-ops" ${CTEST_EXTRA}) 2>&1 | tee -a $OUT/${ci}-ctest.log
252259

253260
set +e
254261
}
@@ -273,16 +280,16 @@ function gg_run_ctest_release {
273280

274281
set -e
275282

276-
# Check cmake, make and ctest are installed
283+
# Check cmake and ctest are installed
277284
gg_check_build_requirements
278285

279-
(time cmake -DCMAKE_BUILD_TYPE=Release ${CMAKE_EXTRA} .. ) 2>&1 | tee -a $OUT/${ci}-cmake.log
280-
(time make -j$(nproc) ) 2>&1 | tee -a $OUT/${ci}-make.log
286+
(cmake -G "${CMAKE_GENERATOR}" -DCMAKE_BUILD_TYPE=Release ${CMAKE_EXTRA} .. ) 2>&1 | tee -a $OUT/${ci}-cmake.log
287+
(time cmake --build . --config Release -j$(nproc)) 2>&1 | tee -a $OUT/${ci}-make.log
281288

282289
if [ -z ${GG_BUILD_LOW_PERF} ]; then
283-
(time ctest --output-on-failure -L 'main|python' ${CTEST_EXTRA}) 2>&1 | tee -a $OUT/${ci}-ctest.log
290+
(time ctest -C Release --output-on-failure -L 'main|python' ${CTEST_EXTRA}) 2>&1 | tee -a $OUT/${ci}-ctest.log
284291
else
285-
(time ctest --output-on-failure -L main -E test-opt ${CTEST_EXTRA}) 2>&1 | tee -a $OUT/${ci}-ctest.log
292+
(time ctest -C Release --output-on-failure -L main -E test-opt ${CTEST_EXTRA}) 2>&1 | tee -a $OUT/${ci}-ctest.log
286293
fi
287294

288295
set +e
@@ -340,7 +347,7 @@ function gg_run_ctest_with_model_debug {
340347
cd build-ci-debug
341348
set -e
342349

343-
(LLAMACPP_TEST_MODELFILE="$model" time ctest --output-on-failure -L model) 2>&1 | tee -a $OUT/${ci}-ctest.log
350+
(LLAMACPP_TEST_MODELFILE="$model" time ctest -C Debug --output-on-failure -L model) 2>&1 | tee -a $OUT/${ci}-ctest.log
344351

345352
set +e
346353
cd ..
@@ -353,7 +360,7 @@ function gg_run_ctest_with_model_release {
353360
cd build-ci-release
354361
set -e
355362

356-
(LLAMACPP_TEST_MODELFILE="$model" time ctest --output-on-failure -L model) 2>&1 | tee -a $OUT/${ci}-ctest.log
363+
(LLAMACPP_TEST_MODELFILE="$model" time ctest -C Release --output-on-failure -L model) 2>&1 | tee -a $OUT/${ci}-ctest.log
357364

358365
# test memory leaks
359366
#if [[ ! -z ${GG_BUILD_METAL} ]]; then
@@ -407,8 +414,8 @@ function gg_run_qwen3_0_6b {
407414

408415
set -e
409416

410-
(time cmake -DCMAKE_BUILD_TYPE=Release ${CMAKE_EXTRA} .. ) 2>&1 | tee -a $OUT/${ci}-cmake.log
411-
(time make -j$(nproc) ) 2>&1 | tee -a $OUT/${ci}-make.log
417+
(cmake -G "${CMAKE_GENERATOR}" -DCMAKE_BUILD_TYPE=Release ${CMAKE_EXTRA} .. ) 2>&1 | tee -a $OUT/${ci}-cmake.log
418+
(time cmake --build . --config Release -j$(nproc)) 2>&1 | tee -a $OUT/${ci}-make.log
412419

413420
python3 ../convert_hf_to_gguf.py ${path_models} --outfile ${path_models}/ggml-model-f16.gguf --outtype f16
414421
python3 ../convert_hf_to_gguf.py ${path_models} --outfile ${path_models}/ggml-model-bf16.gguf --outtype bf16
@@ -556,8 +563,8 @@ function gg_run_embd_bge_small {
556563

557564
set -e
558565

559-
(time cmake -DCMAKE_BUILD_TYPE=Release ${CMAKE_EXTRA} .. ) 2>&1 | tee -a $OUT/${ci}-cmake.log
560-
(time make -j$(nproc) ) 2>&1 | tee -a $OUT/${ci}-make.log
566+
(cmake -G "${CMAKE_GENERATOR}" -DCMAKE_BUILD_TYPE=Release ${CMAKE_EXTRA} .. ) 2>&1 | tee -a $OUT/${ci}-cmake.log
567+
(time cmake --build . --config Release -j$(nproc)) 2>&1 | tee -a $OUT/${ci}-make.log
561568

562569
python3 ../convert_hf_to_gguf.py ${path_models} --outfile ${path_models}/ggml-model-f16.gguf
563570

@@ -601,8 +608,8 @@ function gg_run_rerank_tiny {
601608

602609
set -e
603610

604-
(time cmake -DCMAKE_BUILD_TYPE=Release ${CMAKE_EXTRA} .. ) 2>&1 | tee -a $OUT/${ci}-cmake.log
605-
(time make -j$(nproc) ) 2>&1 | tee -a $OUT/${ci}-make.log
611+
(cmake -G "${CMAKE_GENERATOR}" -DCMAKE_BUILD_TYPE=Release ${CMAKE_EXTRA} .. ) 2>&1 | tee -a $OUT/${ci}-cmake.log
612+
(time cmake --build . --config Release -j$(nproc)) 2>&1 | tee -a $OUT/${ci}-make.log
606613

607614
python3 ../convert_hf_to_gguf.py ${path_models} --outfile ${path_models}/ggml-model-f16.gguf
608615

@@ -652,10 +659,6 @@ function gg_check_build_requirements {
652659
gg_printf 'cmake not found, please install'
653660
fi
654661

655-
if ! command -v make &> /dev/null; then
656-
gg_printf 'make not found, please install'
657-
fi
658-
659662
if ! command -v ctest &> /dev/null; then
660663
gg_printf 'ctest not found, please install'
661664
fi

0 commit comments

Comments
 (0)