build.yml 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116
  1. name: CI
  2. on:
  3. workflow_dispatch: # allows manual triggering
  4. push:
  5. branches:
  6. - master
  7. paths: [
  8. '.github/workflows/build.yml',
  9. '.github/workflows/build-linux-cross.yml',
  10. '.github/workflows/build-cmake-pkg.yml',
  11. '**/CMakeLists.txt',
  12. '**/.cmake',
  13. '**/*.h',
  14. '**/*.hpp',
  15. '**/*.c',
  16. '**/*.cpp',
  17. '**/*.cu',
  18. '**/*.cuh',
  19. '**/*.swift',
  20. '**/*.m',
  21. '**/*.metal',
  22. '**/*.comp'
  23. ]
  24. pull_request:
  25. types: [opened, synchronize, reopened]
  26. paths: [
  27. '.github/workflows/build.yml',
  28. '.github/workflows/build-linux-cross.yml',
  29. '.github/workflows/build-cmake-pkg.yml',
  30. '**/CMakeLists.txt',
  31. '**/.cmake',
  32. '**/*.h',
  33. '**/*.hpp',
  34. '**/*.c',
  35. '**/*.cpp',
  36. '**/*.cu',
  37. '**/*.cuh',
  38. '**/*.swift',
  39. '**/*.m',
  40. '**/*.metal',
  41. '**/*.comp'
  42. ]
  43. concurrency:
  44. group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
  45. cancel-in-progress: true
  46. env:
  47. GGML_NLOOP: 3
  48. GGML_N_THREADS: 1
  49. LLAMA_LOG_COLORS: 1
  50. LLAMA_LOG_PREFIX: 1
  51. LLAMA_LOG_TIMESTAMPS: 1
  52. jobs:
  53. macOS-latest-cmake-arm64:
  54. runs-on: macos-14
  55. steps:
  56. - name: Clone
  57. id: checkout
  58. uses: actions/checkout@v4
  59. - name: ccache
  60. uses: hendrikmuhs/ccache-action@v1.2.16
  61. with:
  62. key: macOS-latest-cmake-arm64
  63. evict-old-files: 1d
  64. - name: Dependencies
  65. id: depends
  66. continue-on-error: true
  67. run: |
  68. brew update
  69. brew install curl
  70. - name: Build
  71. id: cmake_build
  72. run: |
  73. sysctl -a
  74. cmake -B build \
  75. -DCMAKE_BUILD_RPATH="@loader_path" \
  76. -DLLAMA_FATAL_WARNINGS=ON \
  77. -DGGML_METAL_USE_BF16=ON \
  78. -DGGML_METAL_EMBED_LIBRARY=OFF \
  79. -DGGML_METAL_SHADER_DEBUG=ON \
  80. -DGGML_RPC=ON
  81. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
  82. - name: Test
  83. id: cmake_test
  84. run: |
  85. cd build
  86. ctest -L 'main|curl' --verbose --timeout 900
  87. macOS-latest-cmake-x64:
  88. runs-on: macos-13
  89. steps:
  90. - name: Clone
  91. id: checkout
  92. uses: actions/checkout@v4
  93. - name: ccache
  94. uses: hendrikmuhs/ccache-action@v1.2.16
  95. with:
  96. key: macOS-latest-cmake-x64
  97. evict-old-files: 1d
  98. - name: Dependencies
  99. id: depends
  100. continue-on-error: true
  101. run: |
  102. brew update
  103. brew install curl
  104. - name: Build
  105. id: cmake_build
  106. run: |
  107. sysctl -a
  108. # Metal is disabled due to intermittent failures with Github runners not having a GPU:
  109. # https://github.com/ggml-org/llama.cpp/actions/runs/8635935781/job/23674807267#step:5:2313
  110. cmake -B build \
  111. -DCMAKE_BUILD_RPATH="@loader_path" \
  112. -DLLAMA_FATAL_WARNINGS=ON \
  113. -DGGML_METAL=OFF \
  114. -DGGML_RPC=ON
  115. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
  116. - name: Test
  117. id: cmake_test
  118. run: |
  119. cd build
  120. ctest -L main --verbose --timeout 900
  121. ubuntu-cpu-cmake:
  122. strategy:
  123. matrix:
  124. include:
  125. - build: 'x64'
  126. os: ubuntu-22.04
  127. - build: 'arm64'
  128. os: ubuntu-22.04-arm
  129. runs-on: ${{ matrix.os }}
  130. steps:
  131. - name: Clone
  132. id: checkout
  133. uses: actions/checkout@v4
  134. - name: ccache
  135. uses: hendrikmuhs/ccache-action@v1.2.16
  136. with:
  137. key: ubuntu-cpu-cmake
  138. evict-old-files: 1d
  139. - name: Dependencies
  140. id: depends
  141. run: |
  142. sudo apt-get update
  143. sudo apt-get install build-essential libcurl4-openssl-dev
  144. - name: Build
  145. id: cmake_build
  146. run: |
  147. cmake -B build \
  148. -DLLAMA_FATAL_WARNINGS=ON \
  149. -DGGML_RPC=ON
  150. cmake --build build --config Release -j $(nproc)
  151. - name: Test
  152. id: cmake_test
  153. run: |
  154. cd build
  155. ctest -L 'main|curl' --verbose --timeout 900
  156. - name: Test llama2c conversion
  157. id: llama2c_test
  158. run: |
  159. cd build
  160. echo "Fetch tokenizer"
  161. wget https://huggingface.co/karpathy/tinyllamas/resolve/main/stories260K/tok512.bin
  162. echo "Fetch llama2c model"
  163. wget https://huggingface.co/karpathy/tinyllamas/resolve/main/stories260K/stories260K.bin
  164. ./bin/llama-convert-llama2c-to-ggml --copy-vocab-from-model ./tok512.bin --llama2c-model stories260K.bin --llama2c-output-model stories260K.gguf
  165. ./bin/llama-cli -m stories260K.gguf -p "One day, Lily met a Shoggoth" -n 500 -c 256
  166. ubuntu-latest-cmake-sanitizer:
  167. runs-on: ubuntu-latest
  168. continue-on-error: true
  169. strategy:
  170. matrix:
  171. sanitizer: [ADDRESS, THREAD, UNDEFINED]
  172. build_type: [Debug]
  173. steps:
  174. - name: Clone
  175. id: checkout
  176. uses: actions/checkout@v4
  177. - name: ccache
  178. uses: hendrikmuhs/ccache-action@v1.2.16
  179. with:
  180. key: ubuntu-latest-cmake-sanitizer-${{ matrix.sanitizer }}
  181. evict-old-files: 1d
  182. - name: Dependencies
  183. id: depends
  184. run: |
  185. sudo apt-get update
  186. sudo apt-get install build-essential libcurl4-openssl-dev
  187. - name: Build
  188. id: cmake_build
  189. if: ${{ matrix.sanitizer != 'THREAD' }}
  190. run: |
  191. cmake -B build \
  192. -DLLAMA_FATAL_WARNINGS=ON \
  193. -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON \
  194. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
  195. cmake --build build --config ${{ matrix.build_type }} -j $(nproc)
  196. - name: Build (no OpenMP)
  197. id: cmake_build_no_openmp
  198. if: ${{ matrix.sanitizer == 'THREAD' }}
  199. run: |
  200. cmake -B build \
  201. -DLLAMA_FATAL_WARNINGS=ON \
  202. -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON \
  203. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
  204. -DGGML_OPENMP=OFF
  205. cmake --build build --config ${{ matrix.build_type }} -j $(nproc)
  206. - name: Test
  207. id: cmake_test
  208. run: |
  209. cd build
  210. ctest -L main --verbose --timeout 900
  211. ubuntu-latest-llguidance:
  212. runs-on: ubuntu-latest
  213. steps:
  214. - name: Clone
  215. id: checkout
  216. uses: actions/checkout@v4
  217. - name: Dependencies
  218. id: depends
  219. run: |
  220. sudo apt-get update
  221. sudo apt-get install build-essential libcurl4-openssl-dev
  222. - name: Build
  223. id: cmake_build
  224. run: |
  225. mkdir build
  226. cd build
  227. cmake .. \
  228. -DLLAMA_FATAL_WARNINGS=ON \
  229. -DLLAMA_LLGUIDANCE=ON
  230. cmake --build . --config Release -j $(nproc)
  231. - name: Test
  232. id: cmake_test
  233. run: |
  234. cd build
  235. ctest -L main --verbose --timeout 900
  236. ubuntu-latest-cmake-rpc:
  237. runs-on: ubuntu-latest
  238. continue-on-error: true
  239. steps:
  240. - name: Clone
  241. id: checkout
  242. uses: actions/checkout@v4
  243. - name: ccache
  244. uses: hendrikmuhs/ccache-action@v1.2.16
  245. with:
  246. key: ubuntu-latest-cmake-rpc
  247. evict-old-files: 1d
  248. - name: Dependencies
  249. id: depends
  250. run: |
  251. sudo apt-get update
  252. sudo apt-get install build-essential libcurl4-openssl-dev
  253. - name: Build
  254. id: cmake_build
  255. run: |
  256. cmake -B build \
  257. -DGGML_RPC=ON
  258. cmake --build build --config Release -j $(nproc)
  259. - name: Test
  260. id: cmake_test
  261. run: |
  262. cd build
  263. ctest -L main --verbose
  264. ubuntu-22-cmake-vulkan:
  265. runs-on: ubuntu-22.04
  266. steps:
  267. - name: Clone
  268. id: checkout
  269. uses: actions/checkout@v4
  270. - name: ccache
  271. uses: hendrikmuhs/ccache-action@v1.2.16
  272. with:
  273. key: ubuntu-22-cmake-vulkan
  274. evict-old-files: 1d
  275. - name: Dependencies
  276. id: depends
  277. run: |
  278. wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add -
  279. sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
  280. sudo apt-get update -y
  281. sudo apt-get install -y build-essential mesa-vulkan-drivers vulkan-sdk libcurl4-openssl-dev
  282. - name: Build
  283. id: cmake_build
  284. run: |
  285. cmake -B build \
  286. -DGGML_VULKAN=ON
  287. cmake --build build --config Release -j $(nproc)
  288. - name: Test
  289. id: cmake_test
  290. run: |
  291. cd build
  292. export GGML_VK_VISIBLE_DEVICES=0
  293. # This is using llvmpipe and runs slower than other backends
  294. ctest -L main --verbose --timeout 4200
  295. ubuntu-22-cmake-hip:
  296. runs-on: ubuntu-22.04
  297. container: rocm/dev-ubuntu-22.04:6.0.2
  298. steps:
  299. - name: Clone
  300. id: checkout
  301. uses: actions/checkout@v4
  302. - name: Dependencies
  303. id: depends
  304. run: |
  305. sudo apt-get update
  306. sudo apt-get install -y build-essential git cmake rocblas-dev hipblas-dev libcurl4-openssl-dev
  307. - name: ccache
  308. uses: hendrikmuhs/ccache-action@v1.2.16
  309. with:
  310. key: ubuntu-22-cmake-hip
  311. evict-old-files: 1d
  312. - name: Build with native CMake HIP support
  313. id: cmake_build
  314. run: |
  315. cmake -B build -S . \
  316. -DCMAKE_HIP_COMPILER="$(hipconfig -l)/clang" \
  317. -DGGML_HIP_ROCWMMA_FATTN=ON \
  318. -DGGML_HIP=ON
  319. cmake --build build --config Release -j $(nproc)
  320. - name: Build with legacy HIP support
  321. id: cmake_build_legacy_hip
  322. run: |
  323. cmake -B build2 -S . \
  324. -DCMAKE_C_COMPILER=hipcc \
  325. -DCMAKE_CXX_COMPILER=hipcc \
  326. -DGGML_HIP_ROCWMMA_FATTN=ON \
  327. -DGGML_HIP=ON
  328. cmake --build build2 --config Release -j $(nproc)
  329. ubuntu-22-cmake-musa:
  330. runs-on: ubuntu-22.04
  331. container: mthreads/musa:rc4.0.1-mudnn-devel-ubuntu22.04
  332. steps:
  333. - name: Clone
  334. id: checkout
  335. uses: actions/checkout@v4
  336. - name: Dependencies
  337. id: depends
  338. run: |
  339. apt-get update
  340. apt-get install -y build-essential git cmake libcurl4-openssl-dev
  341. - name: ccache
  342. uses: hendrikmuhs/ccache-action@v1.2.16
  343. with:
  344. key: ubuntu-22-cmake-musa
  345. evict-old-files: 1d
  346. - name: Build with native CMake MUSA support
  347. id: cmake_build
  348. run: |
  349. cmake -B build -S . \
  350. -DGGML_MUSA=ON
  351. cmake --build build --config Release -j $(nproc)
  352. ubuntu-22-cmake-sycl:
  353. runs-on: ubuntu-22.04
  354. continue-on-error: true
  355. steps:
  356. - uses: actions/checkout@v4
  357. - name: add oneAPI to apt
  358. shell: bash
  359. run: |
  360. cd /tmp
  361. wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  362. sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  363. rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  364. sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
  365. - name: install oneAPI dpcpp compiler
  366. shell: bash
  367. run: |
  368. sudo apt update
  369. sudo apt install intel-oneapi-compiler-dpcpp-cpp libcurl4-openssl-dev
  370. - name: install oneAPI MKL library
  371. shell: bash
  372. run: |
  373. sudo apt install intel-oneapi-mkl-devel
  374. - name: Clone
  375. id: checkout
  376. uses: actions/checkout@v4
  377. - name: ccache
  378. uses: hendrikmuhs/ccache-action@v1.2.16
  379. with:
  380. key: ubuntu-22-cmake-sycl
  381. evict-old-files: 1d
  382. - name: Build
  383. id: cmake_build
  384. run: |
  385. source /opt/intel/oneapi/setvars.sh
  386. cmake -B build \
  387. -DGGML_SYCL=ON \
  388. -DCMAKE_C_COMPILER=icx \
  389. -DCMAKE_CXX_COMPILER=icpx
  390. cmake --build build --config Release -j $(nproc)
  391. ubuntu-22-cmake-sycl-fp16:
  392. runs-on: ubuntu-22.04
  393. continue-on-error: true
  394. steps:
  395. - uses: actions/checkout@v4
  396. - name: add oneAPI to apt
  397. shell: bash
  398. run: |
  399. cd /tmp
  400. wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  401. sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  402. rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  403. sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
  404. - name: install oneAPI dpcpp compiler
  405. shell: bash
  406. run: |
  407. sudo apt update
  408. sudo apt install intel-oneapi-compiler-dpcpp-cpp libcurl4-openssl-dev
  409. - name: install oneAPI MKL library
  410. shell: bash
  411. run: |
  412. sudo apt install intel-oneapi-mkl-devel
  413. - name: Clone
  414. id: checkout
  415. uses: actions/checkout@v4
  416. - name: ccache
  417. uses: hendrikmuhs/ccache-action@v1.2.16
  418. with:
  419. key: ubuntu-22-cmake-sycl-fp16
  420. evict-old-files: 1d
  421. - name: Build
  422. id: cmake_build
  423. run: |
  424. source /opt/intel/oneapi/setvars.sh
  425. cmake -B build \
  426. -DGGML_SYCL=ON \
  427. -DCMAKE_C_COMPILER=icx \
  428. -DCMAKE_CXX_COMPILER=icpx \
  429. -DGGML_SYCL_F16=ON
  430. cmake --build build --config Release -j $(nproc)
  431. build-linux-cross:
  432. uses: ./.github/workflows/build-linux-cross.yml
  433. build-cmake-pkg:
  434. uses: ./.github/workflows/build-cmake-pkg.yml
  435. macOS-latest-cmake-ios:
  436. runs-on: macos-latest
  437. steps:
  438. - name: Clone
  439. id: checkout
  440. uses: actions/checkout@v4
  441. - name: ccache
  442. uses: hendrikmuhs/ccache-action@v1.2.16
  443. with:
  444. key: macOS-latest-cmake-ios
  445. evict-old-files: 1d
  446. - name: Dependencies
  447. id: depends
  448. continue-on-error: true
  449. run: |
  450. brew update
  451. - name: Build
  452. id: cmake_build
  453. run: |
  454. sysctl -a
  455. cmake -B build -G Xcode \
  456. -DGGML_METAL_USE_BF16=ON \
  457. -DGGML_METAL_EMBED_LIBRARY=ON \
  458. -DLLAMA_BUILD_COMMON=OFF \
  459. -DLLAMA_BUILD_EXAMPLES=OFF \
  460. -DLLAMA_BUILD_TOOLS=OFF \
  461. -DLLAMA_BUILD_TESTS=OFF \
  462. -DLLAMA_BUILD_SERVER=OFF \
  463. -DCMAKE_SYSTEM_NAME=iOS \
  464. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
  465. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  466. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  467. macOS-latest-cmake-tvos:
  468. runs-on: macos-latest
  469. steps:
  470. - name: Clone
  471. id: checkout
  472. uses: actions/checkout@v4
  473. - name: ccache
  474. uses: hendrikmuhs/ccache-action@v1.2.16
  475. with:
  476. key: macOS-latest-cmake-tvos
  477. evict-old-files: 1d
  478. - name: Dependencies
  479. id: depends
  480. continue-on-error: true
  481. run: |
  482. brew update
  483. - name: Build
  484. id: cmake_build
  485. run: |
  486. sysctl -a
  487. cmake -B build -G Xcode \
  488. -DGGML_METAL_USE_BF16=ON \
  489. -DGGML_METAL_EMBED_LIBRARY=ON \
  490. -DLLAMA_BUILD_COMMON=OFF \
  491. -DLLAMA_BUILD_EXAMPLES=OFF \
  492. -DLLAMA_BUILD_TOOLS=OFF \
  493. -DLLAMA_BUILD_TESTS=OFF \
  494. -DLLAMA_BUILD_SERVER=OFF \
  495. -DCMAKE_SYSTEM_NAME=tvOS \
  496. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
  497. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  498. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  499. macOS-latest-cmake-visionos:
  500. runs-on: macos-latest
  501. steps:
  502. - name: Clone
  503. id: checkout
  504. uses: actions/checkout@v4
  505. - name: Dependencies
  506. id: depends
  507. continue-on-error: true
  508. run: |
  509. brew update
  510. - name: Build
  511. id: cmake_build
  512. run: |
  513. sysctl -a
  514. cmake -B build -G Xcode \
  515. -DGGML_METAL_USE_BF16=ON \
  516. -DGGML_METAL_EMBED_LIBRARY=ON \
  517. -DLLAMA_BUILD_COMMON=OFF \
  518. -DLLAMA_BUILD_EXAMPLES=OFF \
  519. -DLLAMA_BUILD_TOOLS=OFF \
  520. -DLLAMA_BUILD_TESTS=OFF \
  521. -DLLAMA_BUILD_SERVER=OFF \
  522. -DCMAKE_SYSTEM_NAME=visionOS \
  523. -DCMAKE_OSX_DEPLOYMENT_TARGET=1.0 \
  524. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  525. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  526. macOS-latest-swift:
  527. runs-on: macos-latest
  528. strategy:
  529. matrix:
  530. destination: ['generic/platform=macOS', 'generic/platform=iOS', 'generic/platform=tvOS']
  531. steps:
  532. - name: Clone
  533. id: checkout
  534. uses: actions/checkout@v4
  535. - name: ccache
  536. uses: hendrikmuhs/ccache-action@v1.2.16
  537. with:
  538. key: macOS-latest-swift
  539. evict-old-files: 1d
  540. - name: Dependencies
  541. id: depends
  542. continue-on-error: true
  543. run: |
  544. brew update
  545. - name: Build llama.cpp with CMake
  546. id: cmake_build
  547. run: |
  548. sysctl -a
  549. cmake -B build -G Xcode \
  550. -DGGML_METAL_USE_BF16=ON \
  551. -DGGML_METAL_EMBED_LIBRARY=ON \
  552. -DLLAMA_CURL=OFF \
  553. -DLLAMA_BUILD_EXAMPLES=OFF \
  554. -DLLAMA_BUILD_TOOLS=OFF \
  555. -DLLAMA_BUILD_TESTS=OFF \
  556. -DLLAMA_BUILD_SERVER=OFF \
  557. -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
  558. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
  559. - name: xcodebuild for swift package
  560. id: xcodebuild
  561. run: |
  562. ./build-xcframework.sh
  563. windows-msys2:
  564. runs-on: windows-2025
  565. strategy:
  566. fail-fast: false
  567. matrix:
  568. include:
  569. - { sys: UCRT64, env: ucrt-x86_64, build: Release }
  570. - { sys: CLANG64, env: clang-x86_64, build: Release }
  571. steps:
  572. - name: Clone
  573. uses: actions/checkout@v4
  574. - name: ccache
  575. uses: hendrikmuhs/ccache-action@v1.2.16
  576. with:
  577. key: windows-msys2
  578. variant: ccache
  579. evict-old-files: 1d
  580. - name: Setup ${{ matrix.sys }}
  581. uses: msys2/setup-msys2@v2
  582. with:
  583. update: true
  584. msystem: ${{matrix.sys}}
  585. install: >-
  586. base-devel
  587. git
  588. mingw-w64-${{matrix.env}}-toolchain
  589. mingw-w64-${{matrix.env}}-cmake
  590. mingw-w64-${{matrix.env}}-openblas
  591. - name: Build using CMake
  592. shell: msys2 {0}
  593. run: |
  594. cmake -B build
  595. cmake --build build --config ${{ matrix.build }} -j $(nproc)
  596. - name: Clean after building using CMake
  597. shell: msys2 {0}
  598. run: |
  599. rm -rf build
  600. - name: Build using CMake w/ OpenBLAS
  601. shell: msys2 {0}
  602. run: |
  603. cmake -B build -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS
  604. cmake --build build --config ${{ matrix.build }} -j $(nproc)
  605. windows-latest-cmake:
  606. runs-on: windows-2025
  607. env:
  608. OPENBLAS_VERSION: 0.3.23
  609. SDE_VERSION: 9.33.0-2024-01-07
  610. VULKAN_VERSION: 1.4.313.2
  611. strategy:
  612. matrix:
  613. include:
  614. - build: 'cpu-x64 (static)'
  615. arch: 'x64'
  616. defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/x64-windows-llvm.cmake -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DBUILD_SHARED_LIBS=OFF'
  617. - build: 'openblas-x64'
  618. arch: 'x64'
  619. defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/x64-windows-llvm.cmake -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DGGML_OPENMP=OFF -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS -DBLAS_INCLUDE_DIRS="$env:RUNNER_TEMP/openblas/include" -DBLAS_LIBRARIES="$env:RUNNER_TEMP/openblas/lib/openblas.lib"'
  620. - build: 'vulkan-x64'
  621. arch: 'x64'
  622. defines: '-DCMAKE_BUILD_TYPE=Release -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DGGML_VULKAN=ON'
  623. - build: 'llvm-arm64'
  624. arch: 'arm64'
  625. defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-llvm.cmake -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON'
  626. - build: 'llvm-arm64-opencl-adreno'
  627. arch: 'arm64'
  628. defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-llvm.cmake -DCMAKE_PREFIX_PATH="$env:RUNNER_TEMP/opencl-arm64-release" -DGGML_OPENCL=ON -DGGML_OPENCL_USE_ADRENO_KERNELS=ON'
  629. steps:
  630. - name: Clone
  631. id: checkout
  632. uses: actions/checkout@v4
  633. - name: ccache
  634. uses: hendrikmuhs/ccache-action@v1.2.16
  635. with:
  636. key: windows-latest-cmake-${{ matrix.build }}
  637. variant: ccache
  638. evict-old-files: 1d
  639. - name: Download OpenBLAS
  640. id: get_openblas
  641. if: ${{ matrix.build == 'openblas-x64' }}
  642. run: |
  643. curl.exe -o $env:RUNNER_TEMP/openblas.zip -L "https://github.com/xianyi/OpenBLAS/releases/download/v${env:OPENBLAS_VERSION}/OpenBLAS-${env:OPENBLAS_VERSION}-x64.zip"
  644. curl.exe -o $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt -L "https://github.com/xianyi/OpenBLAS/raw/v${env:OPENBLAS_VERSION}/LICENSE"
  645. mkdir $env:RUNNER_TEMP/openblas
  646. tar.exe -xvf $env:RUNNER_TEMP/openblas.zip -C $env:RUNNER_TEMP/openblas
  647. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  648. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  649. $lib = $(join-path $msvc 'bin\Hostx64\x64\lib.exe')
  650. & $lib /machine:x64 "/def:${env:RUNNER_TEMP}/openblas/lib/libopenblas.def" "/out:${env:RUNNER_TEMP}/openblas/lib/openblas.lib" /name:openblas.dll
  651. - name: Install Vulkan SDK
  652. id: get_vulkan
  653. if: ${{ matrix.build == 'vulkan-x64' }}
  654. run: |
  655. curl.exe -o $env:RUNNER_TEMP/VulkanSDK-Installer.exe -L "https://sdk.lunarg.com/sdk/download/${env:VULKAN_VERSION}/windows/vulkansdk-windows-X64-${env:VULKAN_VERSION}.exe"
  656. & "$env:RUNNER_TEMP\VulkanSDK-Installer.exe" --accept-licenses --default-answer --confirm-command install
  657. Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${env:VULKAN_VERSION}"
  658. Add-Content $env:GITHUB_PATH "C:\VulkanSDK\${env:VULKAN_VERSION}\bin"
  659. - name: Install Ninja
  660. id: install_ninja
  661. run: |
  662. choco install ninja
  663. - name: Install OpenCL Headers and Libs
  664. id: install_opencl
  665. if: ${{ matrix.build == 'llvm-arm64-opencl-adreno' }}
  666. run: |
  667. git clone https://github.com/KhronosGroup/OpenCL-Headers
  668. cd OpenCL-Headers
  669. cmake -B build `
  670. -DBUILD_TESTING=OFF `
  671. -DOPENCL_HEADERS_BUILD_TESTING=OFF `
  672. -DOPENCL_HEADERS_BUILD_CXX_TESTS=OFF `
  673. -DCMAKE_INSTALL_PREFIX="$env:RUNNER_TEMP/opencl-arm64-release"
  674. cmake --build build --target install
  675. git clone https://github.com/KhronosGroup/OpenCL-ICD-Loader
  676. cd OpenCL-ICD-Loader
  677. cmake -B build-arm64-release `
  678. -A arm64 `
  679. -DCMAKE_PREFIX_PATH="$env:RUNNER_TEMP/opencl-arm64-release" `
  680. -DCMAKE_INSTALL_PREFIX="$env:RUNNER_TEMP/opencl-arm64-release"
  681. cmake --build build-arm64-release --target install --config release
  682. - name: libCURL
  683. id: get_libcurl
  684. uses: ./.github/actions/windows-setup-curl
  685. with:
  686. architecture: ${{ matrix.arch == 'x64' && 'win64' || 'win64a' }}
  687. - name: Build
  688. id: cmake_build
  689. env:
  690. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  691. run: |
  692. cmake -S . -B build ${{ matrix.defines }} `
  693. -DCURL_LIBRARY="$env:CURL_PATH/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:CURL_PATH/include"
  694. cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS}
  695. cp $env:CURL_PATH/bin/libcurl-*.dll build/bin/Release
  696. - name: Add libopenblas.dll
  697. id: add_libopenblas_dll
  698. if: ${{ matrix.build == 'openblas-x64' }}
  699. run: |
  700. cp $env:RUNNER_TEMP/openblas/bin/libopenblas.dll ./build/bin/Release/openblas.dll
  701. cp $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt ./build/bin/Release/OpenBLAS-${env:OPENBLAS_VERSION}.txt
  702. - name: Test
  703. id: cmake_test
  704. if: ${{ matrix.arch == 'x64' }}
  705. run: |
  706. cd build
  707. ctest -L main -C Release --verbose --timeout 900
  708. # TODO: disabled for now, consider adding tests for all CPU variants instead
  709. # - name: Test (Intel SDE)
  710. # id: cmake_test_sde
  711. # if: ${{ matrix.build == 'avx512-x64' && env.HAS_AVX512F == '0' }} # use Intel SDE for AVX-512 emulation
  712. # run: |
  713. # curl.exe -o $env:RUNNER_TEMP/sde.tar.xz -L "https://downloadmirror.intel.com/813591/sde-external-${env:SDE_VERSION}-win.tar.xz"
  714. # # for some weird reason windows tar doesn't like sde tar.xz
  715. # 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar.xz
  716. # 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar
  717. # $sde = $(join-path $env:RUNNER_TEMP sde-external-${env:SDE_VERSION}-win/sde.exe)
  718. # cd build
  719. # $env:LLAMA_SKIP_TESTS_SLOW_ON_EMULATOR = 1
  720. # & $sde -future -- ctest -L main -C Release --verbose --timeout 900
  721. ubuntu-latest-cmake-cuda:
  722. runs-on: ubuntu-latest
  723. container: nvidia/cuda:12.6.2-devel-ubuntu24.04
  724. steps:
  725. - name: Clone
  726. id: checkout
  727. uses: actions/checkout@v4
  728. - name: Install dependencies
  729. env:
  730. DEBIAN_FRONTEND: noninteractive
  731. run: |
  732. apt update
  733. apt install -y cmake build-essential ninja-build libgomp1 git libcurl4-openssl-dev
  734. - name: ccache
  735. uses: hendrikmuhs/ccache-action@v1.2.16
  736. with:
  737. key: ubuntu-latest-cmake-cuda
  738. evict-old-files: 1d
  739. - name: Build with CMake
  740. run: |
  741. cmake -S . -B build -G Ninja \
  742. -DCMAKE_BUILD_TYPE=Release \
  743. -DCMAKE_CUDA_ARCHITECTURES=89-real \
  744. -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined \
  745. -DLLAMA_FATAL_WARNINGS=ON \
  746. -DGGML_NATIVE=OFF \
  747. -DGGML_CUDA=ON
  748. cmake --build build
  749. windows-2022-cmake-cuda:
  750. runs-on: windows-2022
  751. strategy:
  752. matrix:
  753. cuda: ['12.4']
  754. steps:
  755. - name: Clone
  756. id: checkout
  757. uses: actions/checkout@v4
  758. - name: Install ccache
  759. uses: hendrikmuhs/ccache-action@v1.2.16
  760. with:
  761. key: windows-cuda-${{ matrix.cuda }}
  762. variant: ccache
  763. evict-old-files: 1d
  764. - name: Install Cuda Toolkit
  765. uses: ./.github/actions/windows-setup-cuda
  766. with:
  767. cuda_version: ${{ matrix.cuda }}
  768. - name: Install Ninja
  769. id: install_ninja
  770. run: |
  771. choco install ninja
  772. - name: libCURL
  773. id: get_libcurl
  774. uses: ./.github/actions/windows-setup-curl
  775. - name: Build
  776. id: cmake_build
  777. shell: cmd
  778. env:
  779. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  780. run: |
  781. call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
  782. cmake -S . -B build -G "Ninja Multi-Config" ^
  783. -DLLAMA_BUILD_SERVER=ON ^
  784. -DGGML_NATIVE=OFF ^
  785. -DGGML_BACKEND_DL=ON ^
  786. -DGGML_CPU_ALL_VARIANTS=ON ^
  787. -DGGML_CUDA=ON ^
  788. -DGGML_RPC=ON ^
  789. -DCURL_LIBRARY="%CURL_PATH%/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="%CURL_PATH%/include"
  790. set /A NINJA_JOBS=%NUMBER_OF_PROCESSORS%-1
  791. cmake --build build --config Release -j %NINJA_JOBS% -t ggml
  792. cmake --build build --config Release
  793. windows-latest-cmake-sycl:
  794. runs-on: windows-2022
  795. defaults:
  796. run:
  797. shell: bash
  798. env:
  799. WINDOWS_BASEKIT_URL: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/7cd9bba0-7aab-4e30-b3ae-2221006a4a05/intel-oneapi-base-toolkit-2025.1.1.34_offline.exe
  800. WINDOWS_DPCPP_MKL: intel.oneapi.win.cpp-dpcpp-common:intel.oneapi.win.mkl.devel:intel.oneapi.win.dnnl:intel.oneapi.win.tbb.devel
  801. ONEAPI_ROOT: "C:/Program Files (x86)/Intel/oneAPI"
  802. steps:
  803. - name: Clone
  804. id: checkout
  805. uses: actions/checkout@v4
  806. - name: ccache
  807. uses: hendrikmuhs/ccache-action@v1.2.16
  808. with:
  809. key: windows-latest-cmake-sycl
  810. variant: ccache
  811. evict-old-files: 1d
  812. - name: Install
  813. run: |
  814. scripts/install-oneapi.bat $WINDOWS_BASEKIT_URL $WINDOWS_DPCPP_MKL
  815. # TODO: add libcurl support ; we will also need to modify win-build-sycl.bat to accept user-specified args
  816. - name: Build
  817. id: cmake_build
  818. run: examples/sycl/win-build-sycl.bat
  819. windows-latest-cmake-hip:
  820. if: ${{ github.event.inputs.create_release != 'true' }}
  821. runs-on: windows-2022
  822. steps:
  823. - name: Clone
  824. id: checkout
  825. uses: actions/checkout@v4
  826. - name: Clone rocWMMA repository
  827. id: clone_rocwmma
  828. run: |
  829. git clone https://github.com/rocm/rocwmma --branch rocm-6.2.4 --depth 1
  830. - name: Install
  831. id: depends
  832. run: |
  833. $ErrorActionPreference = "Stop"
  834. write-host "Downloading AMD HIP SDK Installer"
  835. Invoke-WebRequest -Uri "https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-24.Q3-WinSvr2022-For-HIP.exe" -OutFile "${env:RUNNER_TEMP}\rocm-install.exe"
  836. write-host "Installing AMD HIP SDK"
  837. Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
  838. write-host "Completed AMD HIP SDK installation"
  839. - name: Verify ROCm
  840. id: verify
  841. run: |
  842. & 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
  843. - name: Install ccache
  844. uses: hendrikmuhs/ccache-action@v1.2.16
  845. with:
  846. key: ${{ github.job }}
  847. evict-old-files: 1d
  848. - name: libCURL
  849. id: get_libcurl
  850. uses: ./.github/actions/windows-setup-curl
  851. - name: Build
  852. id: cmake_build
  853. env:
  854. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  855. run: |
  856. $env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
  857. $env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
  858. cmake -G "Unix Makefiles" -B build -S . `
  859. -DCMAKE_C_COMPILER="${env:HIP_PATH}\bin\clang.exe" `
  860. -DCMAKE_CXX_COMPILER="${env:HIP_PATH}\bin\clang++.exe" `
  861. -DCMAKE_CXX_FLAGS="-I$($PWD.Path.Replace('\', '/'))/rocwmma/library/include/" `
  862. -DCMAKE_BUILD_TYPE=Release `
  863. -DGGML_HIP=ON `
  864. -DGGML_HIP_ROCWMMA_FATTN=ON `
  865. -DGGML_RPC=ON `
  866. -DCURL_LIBRARY="$env:CURL_PATH/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:CURL_PATH/include"
  867. cmake --build build -j ${env:NUMBER_OF_PROCESSORS}
  868. ios-xcode-build:
  869. runs-on: macos-latest
  870. steps:
  871. - name: Checkout code
  872. uses: actions/checkout@v4
  873. - name: Build
  874. id: cmake_build
  875. run: |
  876. sysctl -a
  877. cmake -B build -G Xcode \
  878. -DGGML_METAL_USE_BF16=ON \
  879. -DGGML_METAL_EMBED_LIBRARY=ON \
  880. -DLLAMA_CURL=OFF \
  881. -DLLAMA_BUILD_EXAMPLES=OFF \
  882. -DLLAMA_BUILD_TOOLS=OFF \
  883. -DLLAMA_BUILD_TESTS=OFF \
  884. -DLLAMA_BUILD_SERVER=OFF \
  885. -DCMAKE_SYSTEM_NAME=iOS \
  886. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
  887. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  888. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  889. - name: xcodebuild for swift package
  890. id: xcodebuild
  891. run: |
  892. ./build-xcframework.sh
  893. - name: Build Xcode project
  894. run: xcodebuild -project examples/llama.swiftui/llama.swiftui.xcodeproj -scheme llama.swiftui -sdk iphoneos CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= -destination 'generic/platform=iOS' FRAMEWORK_FOLDER_PATH=./build-ios build
  895. android-build:
  896. runs-on: ubuntu-latest
  897. steps:
  898. - name: Clone
  899. uses: actions/checkout@v4
  900. - name: ccache
  901. uses: hendrikmuhs/ccache-action@v1.2.16
  902. with:
  903. key: android-build
  904. evict-old-files: 1d
  905. - name: Set up JDK
  906. uses: actions/setup-java@v3
  907. with:
  908. java-version: 17
  909. distribution: zulu
  910. - name: Setup Android SDK
  911. uses: android-actions/setup-android@v3
  912. with:
  913. log-accepted-android-sdk-licenses: false
  914. - name: Build
  915. run: |
  916. cd examples/llama.android
  917. ./gradlew build --no-daemon
  918. openEuler-latest-cmake-cann:
  919. if: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'Ascend NPU') }}
  920. defaults:
  921. run:
  922. shell: bash -el {0}
  923. strategy:
  924. matrix:
  925. arch: [x86, aarch64]
  926. cann:
  927. - '8.1.RC1.alpha001-910b-openeuler22.03-py3.10'
  928. device:
  929. - 'ascend910b3'
  930. build:
  931. - 'Release'
  932. runs-on: ${{ matrix.arch == 'aarch64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
  933. container: ascendai/cann:${{ matrix.cann }}
  934. steps:
  935. - name: Checkout
  936. uses: actions/checkout@v4
  937. - name: Dependencies
  938. run: |
  939. yum update -y
  940. yum install -y git gcc gcc-c++ make cmake libcurl-devel
  941. - name: Build
  942. run: |
  943. export LD_LIBRARY_PATH=${ASCEND_TOOLKIT_HOME}/lib64:${ASCEND_TOOLKIT_HOME}/$(uname -m)-linux/devlib/:${LD_LIBRARY_PATH}
  944. cmake -S . -B build \
  945. -DCMAKE_BUILD_TYPE=${{ matrix.build }} \
  946. -DGGML_CANN=on \
  947. -DSOC_TYPE=${{ matrix.device }}
  948. cmake --build build -j $(nproc)