build.yml 34 KB

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