build.yml 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078
  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. # This is using llvmpipe and runs slower than other backends
  260. ctest -L main --verbose --timeout 2700
  261. ubuntu-22-cmake-hip:
  262. runs-on: ubuntu-22.04
  263. container: rocm/dev-ubuntu-22.04:6.0.2
  264. steps:
  265. - name: Clone
  266. id: checkout
  267. uses: actions/checkout@v4
  268. - name: Dependencies
  269. id: depends
  270. run: |
  271. sudo apt-get update
  272. sudo apt-get install -y build-essential git cmake rocblas-dev hipblas-dev libcurl4-openssl-dev
  273. - name: ccache
  274. uses: hendrikmuhs/ccache-action@v1.2.16
  275. with:
  276. key: ubuntu-22-cmake-hip
  277. evict-old-files: 1d
  278. - name: Build with native CMake HIP support
  279. id: cmake_build
  280. run: |
  281. cmake -B build -S . \
  282. -DCMAKE_HIP_COMPILER="$(hipconfig -l)/clang" \
  283. -DGGML_HIP_ROCWMMA_FATTN=ON \
  284. -DGGML_HIP=ON
  285. cmake --build build --config Release -j $(nproc)
  286. - name: Build with legacy HIP support
  287. id: cmake_build_legacy_hip
  288. run: |
  289. cmake -B build2 -S . \
  290. -DCMAKE_C_COMPILER=hipcc \
  291. -DCMAKE_CXX_COMPILER=hipcc \
  292. -DGGML_HIP_ROCWMMA_FATTN=ON \
  293. -DGGML_HIP=ON
  294. cmake --build build2 --config Release -j $(nproc)
  295. ubuntu-22-cmake-musa:
  296. runs-on: ubuntu-22.04
  297. container: mthreads/musa:rc3.1.1-devel-ubuntu22.04
  298. steps:
  299. - name: Clone
  300. id: checkout
  301. uses: actions/checkout@v4
  302. - name: Dependencies
  303. id: depends
  304. run: |
  305. apt-get update
  306. apt-get install -y build-essential git cmake libcurl4-openssl-dev
  307. - name: ccache
  308. uses: hendrikmuhs/ccache-action@v1.2.16
  309. with:
  310. key: ubuntu-22-cmake-musa
  311. evict-old-files: 1d
  312. - name: Build with native CMake MUSA support
  313. id: cmake_build
  314. run: |
  315. cmake -B build -S . \
  316. -DGGML_MUSA=ON
  317. cmake --build build --config Release -j $(nproc)
  318. ubuntu-22-cmake-sycl:
  319. runs-on: ubuntu-22.04
  320. continue-on-error: true
  321. steps:
  322. - uses: actions/checkout@v4
  323. - name: add oneAPI to apt
  324. shell: bash
  325. run: |
  326. cd /tmp
  327. wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  328. sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  329. rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  330. sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
  331. - name: install oneAPI dpcpp compiler
  332. shell: bash
  333. run: |
  334. sudo apt update
  335. sudo apt install intel-oneapi-compiler-dpcpp-cpp libcurl4-openssl-dev
  336. - name: install oneAPI MKL library
  337. shell: bash
  338. run: |
  339. sudo apt install intel-oneapi-mkl-devel
  340. - name: Clone
  341. id: checkout
  342. uses: actions/checkout@v4
  343. - name: ccache
  344. uses: hendrikmuhs/ccache-action@v1.2.16
  345. with:
  346. key: ubuntu-22-cmake-sycl
  347. evict-old-files: 1d
  348. - name: Build
  349. id: cmake_build
  350. run: |
  351. source /opt/intel/oneapi/setvars.sh
  352. cmake -B build \
  353. -DGGML_SYCL=ON \
  354. -DCMAKE_C_COMPILER=icx \
  355. -DCMAKE_CXX_COMPILER=icpx
  356. cmake --build build --config Release -j $(nproc)
  357. ubuntu-22-cmake-sycl-fp16:
  358. runs-on: ubuntu-22.04
  359. continue-on-error: true
  360. steps:
  361. - uses: actions/checkout@v4
  362. - name: add oneAPI to apt
  363. shell: bash
  364. run: |
  365. cd /tmp
  366. wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  367. sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  368. rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  369. sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
  370. - name: install oneAPI dpcpp compiler
  371. shell: bash
  372. run: |
  373. sudo apt update
  374. sudo apt install intel-oneapi-compiler-dpcpp-cpp libcurl4-openssl-dev
  375. - name: install oneAPI MKL library
  376. shell: bash
  377. run: |
  378. sudo apt install intel-oneapi-mkl-devel
  379. - name: Clone
  380. id: checkout
  381. uses: actions/checkout@v4
  382. - name: ccache
  383. uses: hendrikmuhs/ccache-action@v1.2.16
  384. with:
  385. key: ubuntu-22-cmake-sycl-fp16
  386. evict-old-files: 1d
  387. - name: Build
  388. id: cmake_build
  389. run: |
  390. source /opt/intel/oneapi/setvars.sh
  391. cmake -B build \
  392. -DGGML_SYCL=ON \
  393. -DCMAKE_C_COMPILER=icx \
  394. -DCMAKE_CXX_COMPILER=icpx \
  395. -DGGML_SYCL_F16=ON
  396. cmake --build build --config Release -j $(nproc)
  397. build-linux-cross:
  398. uses: ./.github/workflows/build-linux-cross.yml
  399. macOS-latest-cmake-ios:
  400. runs-on: macos-latest
  401. steps:
  402. - name: Clone
  403. id: checkout
  404. uses: actions/checkout@v4
  405. - name: ccache
  406. uses: hendrikmuhs/ccache-action@v1.2.16
  407. with:
  408. key: macOS-latest-cmake-ios
  409. evict-old-files: 1d
  410. - name: Dependencies
  411. id: depends
  412. continue-on-error: true
  413. run: |
  414. brew update
  415. - name: Build
  416. id: cmake_build
  417. run: |
  418. sysctl -a
  419. cmake -B build -G Xcode \
  420. -DGGML_METAL_USE_BF16=ON \
  421. -DGGML_METAL_EMBED_LIBRARY=ON \
  422. -DLLAMA_BUILD_COMMON=OFF \
  423. -DLLAMA_BUILD_EXAMPLES=OFF \
  424. -DLLAMA_BUILD_TOOLS=OFF \
  425. -DLLAMA_BUILD_TESTS=OFF \
  426. -DLLAMA_BUILD_SERVER=OFF \
  427. -DCMAKE_SYSTEM_NAME=iOS \
  428. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
  429. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  430. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  431. macOS-latest-cmake-tvos:
  432. runs-on: macos-latest
  433. steps:
  434. - name: Clone
  435. id: checkout
  436. uses: actions/checkout@v4
  437. - name: ccache
  438. uses: hendrikmuhs/ccache-action@v1.2.16
  439. with:
  440. key: macOS-latest-cmake-tvos
  441. evict-old-files: 1d
  442. - name: Dependencies
  443. id: depends
  444. continue-on-error: true
  445. run: |
  446. brew update
  447. - name: Build
  448. id: cmake_build
  449. run: |
  450. sysctl -a
  451. cmake -B build -G Xcode \
  452. -DGGML_METAL_USE_BF16=ON \
  453. -DGGML_METAL_EMBED_LIBRARY=ON \
  454. -DLLAMA_BUILD_COMMON=OFF \
  455. -DLLAMA_BUILD_EXAMPLES=OFF \
  456. -DLLAMA_BUILD_TOOLS=OFF \
  457. -DLLAMA_BUILD_TESTS=OFF \
  458. -DLLAMA_BUILD_SERVER=OFF \
  459. -DCMAKE_SYSTEM_NAME=tvOS \
  460. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
  461. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  462. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  463. macOS-latest-cmake-visionos:
  464. runs-on: macos-latest
  465. steps:
  466. - name: Clone
  467. id: checkout
  468. uses: actions/checkout@v4
  469. - name: Dependencies
  470. id: depends
  471. continue-on-error: true
  472. run: |
  473. brew update
  474. - name: Build
  475. id: cmake_build
  476. run: |
  477. sysctl -a
  478. cmake -B build -G Xcode \
  479. -DGGML_METAL_USE_BF16=ON \
  480. -DGGML_METAL_EMBED_LIBRARY=ON \
  481. -DLLAMA_BUILD_COMMON=OFF \
  482. -DLLAMA_BUILD_EXAMPLES=OFF \
  483. -DLLAMA_BUILD_TOOLS=OFF \
  484. -DLLAMA_BUILD_TESTS=OFF \
  485. -DLLAMA_BUILD_SERVER=OFF \
  486. -DCMAKE_SYSTEM_NAME=visionOS \
  487. -DCMAKE_OSX_DEPLOYMENT_TARGET=1.0 \
  488. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  489. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  490. macOS-latest-swift:
  491. runs-on: macos-latest
  492. strategy:
  493. matrix:
  494. destination: ['generic/platform=macOS', 'generic/platform=iOS', 'generic/platform=tvOS']
  495. steps:
  496. - name: Clone
  497. id: checkout
  498. uses: actions/checkout@v4
  499. - name: ccache
  500. uses: hendrikmuhs/ccache-action@v1.2.16
  501. with:
  502. key: macOS-latest-swift
  503. evict-old-files: 1d
  504. - name: Dependencies
  505. id: depends
  506. continue-on-error: true
  507. run: |
  508. brew update
  509. - name: Build llama.cpp with CMake
  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_CURL=OFF \
  517. -DLLAMA_BUILD_EXAMPLES=OFF \
  518. -DLLAMA_BUILD_TOOLS=OFF \
  519. -DLLAMA_BUILD_TESTS=OFF \
  520. -DLLAMA_BUILD_SERVER=OFF \
  521. -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
  522. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
  523. - name: xcodebuild for swift package
  524. id: xcodebuild
  525. run: |
  526. ./build-xcframework.sh
  527. windows-msys2:
  528. runs-on: windows-latest
  529. strategy:
  530. fail-fast: false
  531. matrix:
  532. include:
  533. - { sys: UCRT64, env: ucrt-x86_64, build: Release }
  534. - { sys: CLANG64, env: clang-x86_64, build: Release }
  535. steps:
  536. - name: Clone
  537. uses: actions/checkout@v4
  538. - name: ccache
  539. uses: hendrikmuhs/ccache-action@v1.2.16
  540. with:
  541. key: windows-msys2
  542. variant: ccache
  543. evict-old-files: 1d
  544. - name: Setup ${{ matrix.sys }}
  545. uses: msys2/setup-msys2@v2
  546. with:
  547. update: true
  548. msystem: ${{matrix.sys}}
  549. install: >-
  550. base-devel
  551. git
  552. mingw-w64-${{matrix.env}}-toolchain
  553. mingw-w64-${{matrix.env}}-cmake
  554. mingw-w64-${{matrix.env}}-openblas
  555. - name: Build using CMake
  556. shell: msys2 {0}
  557. run: |
  558. cmake -B build
  559. cmake --build build --config ${{ matrix.build }} -j $(nproc)
  560. - name: Clean after building using CMake
  561. shell: msys2 {0}
  562. run: |
  563. rm -rf build
  564. - name: Build using CMake w/ OpenBLAS
  565. shell: msys2 {0}
  566. run: |
  567. cmake -B build -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS
  568. cmake --build build --config ${{ matrix.build }} -j $(nproc)
  569. windows-latest-cmake:
  570. runs-on: windows-latest
  571. env:
  572. OPENBLAS_VERSION: 0.3.23
  573. SDE_VERSION: 9.33.0-2024-01-07
  574. VULKAN_VERSION: 1.4.309.0
  575. strategy:
  576. matrix:
  577. include:
  578. - build: 'cpu-x64'
  579. 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'
  580. - build: 'openblas-x64'
  581. 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"'
  582. - build: 'vulkan-x64'
  583. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DGGML_VULKAN=ON'
  584. - build: 'llvm-arm64'
  585. defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-llvm.cmake -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON'
  586. - build: 'llvm-arm64-opencl-adreno'
  587. 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'
  588. # - build: 'kompute-x64'
  589. # 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'
  590. steps:
  591. - name: Clone
  592. id: checkout
  593. uses: actions/checkout@v4
  594. - name: ccache
  595. uses: hendrikmuhs/ccache-action@v1.2.16
  596. with:
  597. key: windows-latest-cmake-${{ matrix.build }}
  598. variant: ccache
  599. evict-old-files: 1d
  600. - name: Clone Kompute submodule
  601. id: clone_kompute
  602. if: ${{ matrix.build == 'kompute-x64' }}
  603. run: |
  604. git submodule update --init ggml/src/ggml-kompute/kompute
  605. - name: Download OpenBLAS
  606. id: get_openblas
  607. if: ${{ matrix.build == 'openblas-x64' }}
  608. run: |
  609. 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"
  610. curl.exe -o $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt -L "https://github.com/xianyi/OpenBLAS/raw/v${env:OPENBLAS_VERSION}/LICENSE"
  611. mkdir $env:RUNNER_TEMP/openblas
  612. tar.exe -xvf $env:RUNNER_TEMP/openblas.zip -C $env:RUNNER_TEMP/openblas
  613. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  614. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  615. $lib = $(join-path $msvc 'bin\Hostx64\x64\lib.exe')
  616. & $lib /machine:x64 "/def:${env:RUNNER_TEMP}/openblas/lib/libopenblas.def" "/out:${env:RUNNER_TEMP}/openblas/lib/openblas.lib" /name:openblas.dll
  617. - name: Install Vulkan SDK
  618. id: get_vulkan
  619. if: ${{ matrix.build == 'kompute-x64' || matrix.build == 'vulkan-x64' }}
  620. run: |
  621. 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"
  622. & "$env:RUNNER_TEMP\VulkanSDK-Installer.exe" --accept-licenses --default-answer --confirm-command install
  623. Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${env:VULKAN_VERSION}"
  624. Add-Content $env:GITHUB_PATH "C:\VulkanSDK\${env:VULKAN_VERSION}\bin"
  625. - name: Install Ninja
  626. id: install_ninja
  627. run: |
  628. choco install ninja
  629. - name: Install OpenCL Headers and Libs
  630. id: install_opencl
  631. if: ${{ matrix.build == 'llvm-arm64-opencl-adreno' }}
  632. run: |
  633. git clone https://github.com/KhronosGroup/OpenCL-Headers
  634. cd OpenCL-Headers
  635. cmake -B build `
  636. -DBUILD_TESTING=OFF `
  637. -DOPENCL_HEADERS_BUILD_TESTING=OFF `
  638. -DOPENCL_HEADERS_BUILD_CXX_TESTS=OFF `
  639. -DCMAKE_INSTALL_PREFIX="$env:RUNNER_TEMP/opencl-arm64-release"
  640. cmake --build build --target install
  641. git clone https://github.com/KhronosGroup/OpenCL-ICD-Loader
  642. cd OpenCL-ICD-Loader
  643. cmake -B build-arm64-release `
  644. -A arm64 `
  645. -DCMAKE_PREFIX_PATH="$env:RUNNER_TEMP/opencl-arm64-release" `
  646. -DCMAKE_INSTALL_PREFIX="$env:RUNNER_TEMP/opencl-arm64-release"
  647. cmake --build build-arm64-release --target install --config release
  648. - name: libCURL
  649. id: get_libcurl
  650. uses: ./.github/actions/windows-setup-curl
  651. - name: Build
  652. id: cmake_build
  653. env:
  654. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  655. run: |
  656. cmake -S . -B build ${{ matrix.defines }} `
  657. -DCURL_LIBRARY="$env:CURL_PATH/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:CURL_PATH/include"
  658. cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS}
  659. - name: Add libopenblas.dll
  660. id: add_libopenblas_dll
  661. if: ${{ matrix.build == 'openblas-x64' }}
  662. run: |
  663. cp $env:RUNNER_TEMP/openblas/bin/libopenblas.dll ./build/bin/Release/openblas.dll
  664. cp $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt ./build/bin/Release/OpenBLAS-${env:OPENBLAS_VERSION}.txt
  665. - name: Test
  666. id: cmake_test
  667. if: ${{ matrix.build != 'llvm-arm64' && matrix.build != 'llvm-arm64-opencl-adreno' }}
  668. run: |
  669. cd build
  670. ctest -L main -C Release --verbose --timeout 900
  671. # TODO: disabled for now, consider adding tests for all CPU variants instead
  672. # - name: Test (Intel SDE)
  673. # id: cmake_test_sde
  674. # if: ${{ matrix.build == 'avx512-x64' && env.HAS_AVX512F == '0' }} # use Intel SDE for AVX-512 emulation
  675. # run: |
  676. # curl.exe -o $env:RUNNER_TEMP/sde.tar.xz -L "https://downloadmirror.intel.com/813591/sde-external-${env:SDE_VERSION}-win.tar.xz"
  677. # # for some weird reason windows tar doesn't like sde tar.xz
  678. # 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar.xz
  679. # 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar
  680. # $sde = $(join-path $env:RUNNER_TEMP sde-external-${env:SDE_VERSION}-win/sde.exe)
  681. # cd build
  682. # $env:LLAMA_SKIP_TESTS_SLOW_ON_EMULATOR = 1
  683. # & $sde -future -- ctest -L main -C Release --verbose --timeout 900
  684. ubuntu-latest-cmake-cuda:
  685. runs-on: ubuntu-latest
  686. container: nvidia/cuda:12.6.2-devel-ubuntu24.04
  687. steps:
  688. - name: Clone
  689. id: checkout
  690. uses: actions/checkout@v4
  691. - name: Install dependencies
  692. env:
  693. DEBIAN_FRONTEND: noninteractive
  694. run: |
  695. apt update
  696. apt install -y cmake build-essential ninja-build libgomp1 git libcurl4-openssl-dev
  697. - name: ccache
  698. uses: hendrikmuhs/ccache-action@v1.2.16
  699. with:
  700. key: ubuntu-latest-cmake-cuda
  701. evict-old-files: 1d
  702. - name: Build with CMake
  703. run: |
  704. cmake -S . -B build -G Ninja \
  705. -DCMAKE_BUILD_TYPE=Release \
  706. -DCMAKE_CUDA_ARCHITECTURES=89-real \
  707. -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined \
  708. -DLLAMA_FATAL_WARNINGS=ON \
  709. -DGGML_NATIVE=OFF \
  710. -DGGML_CUDA=ON
  711. cmake --build build
  712. windows-2019-cmake-cuda:
  713. runs-on: windows-2019
  714. strategy:
  715. matrix:
  716. cuda: ['12.4', '11.7']
  717. steps:
  718. - name: Clone
  719. id: checkout
  720. uses: actions/checkout@v4
  721. - name: Install ccache
  722. uses: hendrikmuhs/ccache-action@v1.2.16
  723. with:
  724. key: windows-cuda-${{ matrix.cuda }}
  725. variant: ccache
  726. evict-old-files: 1d
  727. - name: Install Cuda Toolkit
  728. uses: ./.github/actions/windows-setup-cuda
  729. with:
  730. cuda_version: ${{ matrix.cuda }}
  731. - name: Install Ninja
  732. id: install_ninja
  733. run: |
  734. choco install ninja
  735. - name: libCURL
  736. id: get_libcurl
  737. uses: ./.github/actions/windows-setup-curl
  738. - name: Build
  739. id: cmake_build
  740. shell: cmd
  741. env:
  742. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  743. run: |
  744. call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
  745. cmake -S . -B build -G "Ninja Multi-Config" ^
  746. -DLLAMA_BUILD_SERVER=ON ^
  747. -DGGML_NATIVE=OFF ^
  748. -DGGML_BACKEND_DL=ON ^
  749. -DGGML_CPU_ALL_VARIANTS=ON ^
  750. -DGGML_CUDA=ON ^
  751. -DGGML_RPC=ON ^
  752. -DCURL_LIBRARY="%CURL_PATH%/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="%CURL_PATH%/include"
  753. set /A NINJA_JOBS=%NUMBER_OF_PROCESSORS%-1
  754. cmake --build build --config Release -j %NINJA_JOBS% -t ggml
  755. cmake --build build --config Release
  756. windows-latest-cmake-sycl:
  757. runs-on: windows-latest
  758. defaults:
  759. run:
  760. shell: bash
  761. env:
  762. WINDOWS_BASEKIT_URL: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/b380d914-366b-4b77-a74a-05e3c38b3514/intel-oneapi-base-toolkit-2025.0.0.882_offline.exe
  763. WINDOWS_DPCPP_MKL: intel.oneapi.win.cpp-dpcpp-common:intel.oneapi.win.mkl.devel:intel.oneapi.win.dnnl:intel.oneapi.win.tbb.devel
  764. ONEAPI_ROOT: "C:/Program Files (x86)/Intel/oneAPI"
  765. steps:
  766. - name: Clone
  767. id: checkout
  768. uses: actions/checkout@v4
  769. - name: ccache
  770. uses: hendrikmuhs/ccache-action@v1.2.16
  771. with:
  772. key: windows-latest-cmake-sycl
  773. variant: ccache
  774. evict-old-files: 1d
  775. - name: Install
  776. run: |
  777. scripts/install-oneapi.bat $WINDOWS_BASEKIT_URL $WINDOWS_DPCPP_MKL
  778. # TODO: add libcurl support ; we will also need to modify win-build-sycl.bat to accept user-specified args
  779. - name: Build
  780. id: cmake_build
  781. run: examples/sycl/win-build-sycl.bat
  782. windows-latest-cmake-hip:
  783. if: ${{ github.event.inputs.create_release != 'true' }}
  784. runs-on: windows-latest
  785. steps:
  786. - name: Clone
  787. id: checkout
  788. uses: actions/checkout@v4
  789. - name: Clone rocWMMA repository
  790. id: clone_rocwmma
  791. run: |
  792. git clone https://github.com/rocm/rocwmma --branch rocm-6.2.4 --depth 1
  793. - name: Install
  794. id: depends
  795. run: |
  796. $ErrorActionPreference = "Stop"
  797. write-host "Downloading AMD HIP SDK Installer"
  798. 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"
  799. write-host "Installing AMD HIP SDK"
  800. Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
  801. write-host "Completed AMD HIP SDK installation"
  802. - name: Verify ROCm
  803. id: verify
  804. run: |
  805. & 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
  806. - name: Install ccache
  807. uses: hendrikmuhs/ccache-action@v1.2.16
  808. with:
  809. key: ${{ github.job }}
  810. evict-old-files: 1d
  811. - name: libCURL
  812. id: get_libcurl
  813. uses: ./.github/actions/windows-setup-curl
  814. - name: Build
  815. id: cmake_build
  816. env:
  817. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  818. run: |
  819. $env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
  820. $env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
  821. cmake -G "Unix Makefiles" -B build -S . `
  822. -DCMAKE_C_COMPILER="${env:HIP_PATH}\bin\clang.exe" `
  823. -DCMAKE_CXX_COMPILER="${env:HIP_PATH}\bin\clang++.exe" `
  824. -DCMAKE_CXX_FLAGS="-I$($PWD.Path.Replace('\', '/'))/rocwmma/library/include/" `
  825. -DCMAKE_BUILD_TYPE=Release `
  826. -DGGML_HIP=ON `
  827. -DGGML_HIP_ROCWMMA_FATTN=ON `
  828. -DGGML_RPC=ON `
  829. -DCURL_LIBRARY="$env:CURL_PATH/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:CURL_PATH/include"
  830. cmake --build build -j ${env:NUMBER_OF_PROCESSORS}
  831. ios-xcode-build:
  832. runs-on: macos-latest
  833. steps:
  834. - name: Checkout code
  835. uses: actions/checkout@v4
  836. - name: Build
  837. id: cmake_build
  838. run: |
  839. sysctl -a
  840. cmake -B build -G Xcode \
  841. -DGGML_METAL_USE_BF16=ON \
  842. -DGGML_METAL_EMBED_LIBRARY=ON \
  843. -DLLAMA_CURL=OFF \
  844. -DLLAMA_BUILD_EXAMPLES=OFF \
  845. -DLLAMA_BUILD_TOOLS=OFF \
  846. -DLLAMA_BUILD_TESTS=OFF \
  847. -DLLAMA_BUILD_SERVER=OFF \
  848. -DCMAKE_SYSTEM_NAME=iOS \
  849. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
  850. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  851. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  852. - name: xcodebuild for swift package
  853. id: xcodebuild
  854. run: |
  855. ./build-xcframework.sh
  856. - name: Build Xcode project
  857. 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
  858. android-build:
  859. runs-on: ubuntu-latest
  860. steps:
  861. - name: Clone
  862. uses: actions/checkout@v4
  863. - name: ccache
  864. uses: hendrikmuhs/ccache-action@v1.2.16
  865. with:
  866. key: android-build
  867. evict-old-files: 1d
  868. - name: Set up JDK
  869. uses: actions/setup-java@v3
  870. with:
  871. java-version: 17
  872. distribution: zulu
  873. - name: Setup Android SDK
  874. uses: android-actions/setup-android@v3
  875. with:
  876. log-accepted-android-sdk-licenses: false
  877. - name: Build
  878. run: |
  879. cd examples/llama.android
  880. ./gradlew build --no-daemon
  881. openEuler-latest-cmake-cann:
  882. if: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'Ascend NPU') }}
  883. defaults:
  884. run:
  885. shell: bash -el {0}
  886. strategy:
  887. matrix:
  888. arch: [x86, aarch64]
  889. cann:
  890. - '8.1.RC1.alpha001-910b-openeuler22.03-py3.10'
  891. device:
  892. - 'ascend910b3'
  893. build:
  894. - 'Release'
  895. runs-on: ${{ matrix.arch == 'aarch64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
  896. container: ascendai/cann:${{ matrix.cann }}
  897. steps:
  898. - name: Checkout
  899. uses: actions/checkout@v4
  900. - name: Dependencies
  901. run: |
  902. yum update -y
  903. yum install -y git gcc gcc-c++ make cmake libcurl-devel
  904. - name: Build
  905. run: |
  906. export LD_LIBRARY_PATH=${ASCEND_TOOLKIT_HOME}/lib64:${ASCEND_TOOLKIT_HOME}/$(uname -m)-linux/devlib/:${LD_LIBRARY_PATH}
  907. cmake -S . -B build \
  908. -DCMAKE_BUILD_TYPE=${{ matrix.build }} \
  909. -DGGML_CANN=on \
  910. -DSOC_TYPE=${{ matrix.device }}
  911. cmake --build build -j $(nproc)