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