build.yml 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079
  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. BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
  16. GGML_NLOOP: 3
  17. GGML_N_THREADS: 1
  18. LLAMA_LOG_COLORS: 1
  19. LLAMA_LOG_PREFIX: 1
  20. LLAMA_LOG_TIMESTAMPS: 1
  21. jobs:
  22. macOS-latest-cmake-arm64:
  23. runs-on: macos-14
  24. steps:
  25. - name: Clone
  26. id: checkout
  27. uses: actions/checkout@v4
  28. - name: ccache
  29. uses: hendrikmuhs/ccache-action@v1.2.16
  30. with:
  31. key: macOS-latest-cmake-arm64
  32. evict-old-files: 1d
  33. - name: Dependencies
  34. id: depends
  35. continue-on-error: true
  36. run: |
  37. brew update
  38. brew install curl
  39. - name: Build
  40. id: cmake_build
  41. run: |
  42. sysctl -a
  43. cmake -B build \
  44. -DCMAKE_BUILD_RPATH="@loader_path" \
  45. -DLLAMA_FATAL_WARNINGS=ON \
  46. -DGGML_METAL_USE_BF16=ON \
  47. -DGGML_METAL_EMBED_LIBRARY=ON \
  48. -DGGML_RPC=ON
  49. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
  50. - name: Test
  51. id: cmake_test
  52. run: |
  53. cd build
  54. ctest -L 'main|curl' --verbose --timeout 900
  55. macOS-latest-cmake-x64:
  56. runs-on: macos-13
  57. steps:
  58. - name: Clone
  59. id: checkout
  60. uses: actions/checkout@v4
  61. - name: ccache
  62. uses: hendrikmuhs/ccache-action@v1.2.16
  63. with:
  64. key: macOS-latest-cmake-x64
  65. evict-old-files: 1d
  66. - name: Dependencies
  67. id: depends
  68. continue-on-error: true
  69. run: |
  70. brew update
  71. brew install curl
  72. - name: Build
  73. id: cmake_build
  74. run: |
  75. sysctl -a
  76. # Metal is disabled due to intermittent failures with Github runners not having a GPU:
  77. # https://github.com/ggml-org/llama.cpp/actions/runs/8635935781/job/23674807267#step:5:2313
  78. cmake -B build \
  79. -DCMAKE_BUILD_RPATH="@loader_path" \
  80. -DLLAMA_FATAL_WARNINGS=ON \
  81. -DGGML_METAL=OFF \
  82. -DGGML_RPC=ON
  83. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
  84. - name: Test
  85. id: cmake_test
  86. run: |
  87. cd build
  88. ctest -L main --verbose --timeout 900
  89. ubuntu-cpu-cmake:
  90. strategy:
  91. matrix:
  92. include:
  93. - build: 'x64'
  94. os: ubuntu-22.04
  95. - build: 'arm64'
  96. os: ubuntu-22.04-arm
  97. runs-on: ${{ matrix.os }}
  98. steps:
  99. - name: Clone
  100. id: checkout
  101. uses: actions/checkout@v4
  102. - name: ccache
  103. uses: hendrikmuhs/ccache-action@v1.2.16
  104. with:
  105. key: ubuntu-cpu-cmake
  106. evict-old-files: 1d
  107. - name: Dependencies
  108. id: depends
  109. run: |
  110. sudo apt-get update
  111. sudo apt-get install build-essential libcurl4-openssl-dev
  112. - name: Build
  113. id: cmake_build
  114. run: |
  115. cmake -B build \
  116. -DLLAMA_FATAL_WARNINGS=ON \
  117. -DGGML_RPC=ON
  118. cmake --build build --config Release -j $(nproc)
  119. - name: Test
  120. id: cmake_test
  121. run: |
  122. cd build
  123. ctest -L 'main|curl' --verbose --timeout 900
  124. - name: Test llama2c conversion
  125. id: llama2c_test
  126. run: |
  127. cd build
  128. echo "Fetch tokenizer"
  129. wget https://huggingface.co/karpathy/tinyllamas/resolve/main/stories260K/tok512.bin
  130. echo "Fetch llama2c model"
  131. wget https://huggingface.co/karpathy/tinyllamas/resolve/main/stories260K/stories260K.bin
  132. ./bin/llama-convert-llama2c-to-ggml --copy-vocab-from-model ./tok512.bin --llama2c-model stories260K.bin --llama2c-output-model stories260K.gguf
  133. ./bin/llama-cli -m stories260K.gguf -p "One day, Lily met a Shoggoth" -n 500 -c 256
  134. ubuntu-latest-cmake-sanitizer:
  135. runs-on: ubuntu-latest
  136. continue-on-error: true
  137. strategy:
  138. matrix:
  139. sanitizer: [ADDRESS, THREAD, UNDEFINED]
  140. build_type: [Debug]
  141. steps:
  142. - name: Clone
  143. id: checkout
  144. uses: actions/checkout@v4
  145. - name: ccache
  146. uses: hendrikmuhs/ccache-action@v1.2.16
  147. with:
  148. key: ubuntu-latest-cmake-sanitizer-${{ matrix.sanitizer }}
  149. evict-old-files: 1d
  150. - name: Dependencies
  151. id: depends
  152. run: |
  153. sudo apt-get update
  154. sudo apt-get install build-essential libcurl4-openssl-dev
  155. - name: Build
  156. id: cmake_build
  157. if: ${{ matrix.sanitizer != 'THREAD' }}
  158. run: |
  159. cmake -B build \
  160. -DLLAMA_FATAL_WARNINGS=ON \
  161. -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON \
  162. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
  163. cmake --build build --config ${{ matrix.build_type }} -j $(nproc)
  164. - name: Build (no OpenMP)
  165. id: cmake_build_no_openmp
  166. if: ${{ matrix.sanitizer == 'THREAD' }}
  167. run: |
  168. cmake -B build \
  169. -DLLAMA_FATAL_WARNINGS=ON \
  170. -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON \
  171. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
  172. -DGGML_OPENMP=OFF
  173. cmake --build build --config ${{ matrix.build_type }} -j $(nproc)
  174. - name: Test
  175. id: cmake_test
  176. run: |
  177. cd build
  178. ctest -L main --verbose --timeout 900
  179. ubuntu-latest-llguidance:
  180. runs-on: ubuntu-latest
  181. steps:
  182. - name: Clone
  183. id: checkout
  184. uses: actions/checkout@v4
  185. - name: Dependencies
  186. id: depends
  187. run: |
  188. sudo apt-get update
  189. sudo apt-get install build-essential libcurl4-openssl-dev
  190. - name: Build
  191. id: cmake_build
  192. run: |
  193. mkdir build
  194. cd build
  195. cmake .. \
  196. -DLLAMA_FATAL_WARNINGS=ON \
  197. -DLLAMA_LLGUIDANCE=ON
  198. cmake --build . --config Release -j $(nproc)
  199. - name: Test
  200. id: cmake_test
  201. run: |
  202. cd build
  203. ctest -L main --verbose --timeout 900
  204. ubuntu-latest-cmake-rpc:
  205. runs-on: ubuntu-latest
  206. continue-on-error: true
  207. steps:
  208. - name: Clone
  209. id: checkout
  210. uses: actions/checkout@v4
  211. - name: ccache
  212. uses: hendrikmuhs/ccache-action@v1.2.16
  213. with:
  214. key: ubuntu-latest-cmake-rpc
  215. evict-old-files: 1d
  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. cmake -B build \
  225. -DGGML_RPC=ON
  226. cmake --build build --config Release -j $(nproc)
  227. - name: Test
  228. id: cmake_test
  229. run: |
  230. cd build
  231. ctest -L main --verbose
  232. ubuntu-22-cmake-vulkan:
  233. runs-on: ubuntu-22.04
  234. steps:
  235. - name: Clone
  236. id: checkout
  237. uses: actions/checkout@v4
  238. - name: ccache
  239. uses: hendrikmuhs/ccache-action@v1.2.16
  240. with:
  241. key: ubuntu-22-cmake-vulkan
  242. evict-old-files: 1d
  243. - name: Dependencies
  244. id: depends
  245. run: |
  246. wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add -
  247. sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
  248. sudo apt-get update -y
  249. sudo apt-get install -y build-essential mesa-vulkan-drivers vulkan-sdk libcurl4-openssl-dev
  250. - name: Build
  251. id: cmake_build
  252. run: |
  253. cmake -B build \
  254. -DGGML_VULKAN=ON
  255. cmake --build build --config Release -j $(nproc)
  256. - name: Test
  257. id: cmake_test
  258. run: |
  259. cd build
  260. # This is using llvmpipe and runs slower than other backends
  261. ctest -L main --verbose --timeout 2700
  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:rc3.1.1-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'
  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 -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DGGML_OPENMP=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: '-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. - name: Add libopenblas.dll
  661. id: add_libopenblas_dll
  662. if: ${{ matrix.build == 'openblas-x64' }}
  663. run: |
  664. cp $env:RUNNER_TEMP/openblas/bin/libopenblas.dll ./build/bin/Release/openblas.dll
  665. cp $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt ./build/bin/Release/OpenBLAS-${env:OPENBLAS_VERSION}.txt
  666. - name: Test
  667. id: cmake_test
  668. if: ${{ matrix.build != 'llvm-arm64' && matrix.build != 'llvm-arm64-opencl-adreno' }}
  669. run: |
  670. cd build
  671. ctest -L main -C Release --verbose --timeout 900
  672. # TODO: disabled for now, consider adding tests for all CPU variants instead
  673. # - name: Test (Intel SDE)
  674. # id: cmake_test_sde
  675. # if: ${{ matrix.build == 'avx512-x64' && env.HAS_AVX512F == '0' }} # use Intel SDE for AVX-512 emulation
  676. # run: |
  677. # curl.exe -o $env:RUNNER_TEMP/sde.tar.xz -L "https://downloadmirror.intel.com/813591/sde-external-${env:SDE_VERSION}-win.tar.xz"
  678. # # for some weird reason windows tar doesn't like sde tar.xz
  679. # 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar.xz
  680. # 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar
  681. # $sde = $(join-path $env:RUNNER_TEMP sde-external-${env:SDE_VERSION}-win/sde.exe)
  682. # cd build
  683. # $env:LLAMA_SKIP_TESTS_SLOW_ON_EMULATOR = 1
  684. # & $sde -future -- ctest -L main -C Release --verbose --timeout 900
  685. ubuntu-latest-cmake-cuda:
  686. runs-on: ubuntu-latest
  687. container: nvidia/cuda:12.6.2-devel-ubuntu24.04
  688. steps:
  689. - name: Clone
  690. id: checkout
  691. uses: actions/checkout@v4
  692. - name: Install dependencies
  693. env:
  694. DEBIAN_FRONTEND: noninteractive
  695. run: |
  696. apt update
  697. apt install -y cmake build-essential ninja-build libgomp1 git libcurl4-openssl-dev
  698. - name: ccache
  699. uses: hendrikmuhs/ccache-action@v1.2.16
  700. with:
  701. key: ubuntu-latest-cmake-cuda
  702. evict-old-files: 1d
  703. - name: Build with CMake
  704. run: |
  705. cmake -S . -B build -G Ninja \
  706. -DCMAKE_BUILD_TYPE=Release \
  707. -DCMAKE_CUDA_ARCHITECTURES=89-real \
  708. -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined \
  709. -DLLAMA_FATAL_WARNINGS=ON \
  710. -DGGML_NATIVE=OFF \
  711. -DGGML_CUDA=ON
  712. cmake --build build
  713. windows-2019-cmake-cuda:
  714. runs-on: windows-2019
  715. strategy:
  716. matrix:
  717. cuda: ['12.4', '11.7']
  718. steps:
  719. - name: Clone
  720. id: checkout
  721. uses: actions/checkout@v4
  722. - name: Install ccache
  723. uses: hendrikmuhs/ccache-action@v1.2.16
  724. with:
  725. key: windows-cuda-${{ matrix.cuda }}
  726. variant: ccache
  727. evict-old-files: 1d
  728. - name: Install Cuda Toolkit
  729. uses: ./.github/actions/windows-setup-cuda
  730. with:
  731. cuda_version: ${{ matrix.cuda }}
  732. - name: Install Ninja
  733. id: install_ninja
  734. run: |
  735. choco install ninja
  736. - name: libCURL
  737. id: get_libcurl
  738. uses: ./.github/actions/windows-setup-curl
  739. - name: Build
  740. id: cmake_build
  741. shell: cmd
  742. env:
  743. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  744. run: |
  745. call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
  746. cmake -S . -B build -G "Ninja Multi-Config" ^
  747. -DLLAMA_BUILD_SERVER=ON ^
  748. -DGGML_NATIVE=OFF ^
  749. -DGGML_BACKEND_DL=ON ^
  750. -DGGML_CPU_ALL_VARIANTS=ON ^
  751. -DGGML_CUDA=ON ^
  752. -DGGML_RPC=ON ^
  753. -DCURL_LIBRARY="%CURL_PATH%/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="%CURL_PATH%/include"
  754. set /A NINJA_JOBS=%NUMBER_OF_PROCESSORS%-1
  755. cmake --build build --config Release -j %NINJA_JOBS% -t ggml
  756. cmake --build build --config Release
  757. windows-latest-cmake-sycl:
  758. runs-on: windows-latest
  759. defaults:
  760. run:
  761. shell: bash
  762. env:
  763. 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
  764. WINDOWS_DPCPP_MKL: intel.oneapi.win.cpp-dpcpp-common:intel.oneapi.win.mkl.devel:intel.oneapi.win.dnnl:intel.oneapi.win.tbb.devel
  765. ONEAPI_ROOT: "C:/Program Files (x86)/Intel/oneAPI"
  766. steps:
  767. - name: Clone
  768. id: checkout
  769. uses: actions/checkout@v4
  770. - name: ccache
  771. uses: hendrikmuhs/ccache-action@v1.2.16
  772. with:
  773. key: windows-latest-cmake-sycl
  774. variant: ccache
  775. evict-old-files: 1d
  776. - name: Install
  777. run: |
  778. scripts/install-oneapi.bat $WINDOWS_BASEKIT_URL $WINDOWS_DPCPP_MKL
  779. # TODO: add libcurl support ; we will also need to modify win-build-sycl.bat to accept user-specified args
  780. - name: Build
  781. id: cmake_build
  782. run: examples/sycl/win-build-sycl.bat
  783. windows-latest-cmake-hip:
  784. if: ${{ github.event.inputs.create_release != 'true' }}
  785. runs-on: windows-latest
  786. steps:
  787. - name: Clone
  788. id: checkout
  789. uses: actions/checkout@v4
  790. - name: Clone rocWMMA repository
  791. id: clone_rocwmma
  792. run: |
  793. git clone https://github.com/rocm/rocwmma --branch rocm-6.2.4 --depth 1
  794. - name: Install
  795. id: depends
  796. run: |
  797. $ErrorActionPreference = "Stop"
  798. write-host "Downloading AMD HIP SDK Installer"
  799. 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"
  800. write-host "Installing AMD HIP SDK"
  801. Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
  802. write-host "Completed AMD HIP SDK installation"
  803. - name: Verify ROCm
  804. id: verify
  805. run: |
  806. & 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
  807. - name: Install ccache
  808. uses: hendrikmuhs/ccache-action@v1.2.16
  809. with:
  810. key: ${{ github.job }}
  811. evict-old-files: 1d
  812. - name: libCURL
  813. id: get_libcurl
  814. uses: ./.github/actions/windows-setup-curl
  815. - name: Build
  816. id: cmake_build
  817. env:
  818. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  819. run: |
  820. $env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
  821. $env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
  822. cmake -G "Unix Makefiles" -B build -S . `
  823. -DCMAKE_C_COMPILER="${env:HIP_PATH}\bin\clang.exe" `
  824. -DCMAKE_CXX_COMPILER="${env:HIP_PATH}\bin\clang++.exe" `
  825. -DCMAKE_CXX_FLAGS="-I$($PWD.Path.Replace('\', '/'))/rocwmma/library/include/" `
  826. -DCMAKE_BUILD_TYPE=Release `
  827. -DGGML_HIP=ON `
  828. -DGGML_HIP_ROCWMMA_FATTN=ON `
  829. -DGGML_RPC=ON `
  830. -DCURL_LIBRARY="$env:CURL_PATH/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:CURL_PATH/include"
  831. cmake --build build -j ${env:NUMBER_OF_PROCESSORS}
  832. ios-xcode-build:
  833. runs-on: macos-latest
  834. steps:
  835. - name: Checkout code
  836. uses: actions/checkout@v4
  837. - name: Build
  838. id: cmake_build
  839. run: |
  840. sysctl -a
  841. cmake -B build -G Xcode \
  842. -DGGML_METAL_USE_BF16=ON \
  843. -DGGML_METAL_EMBED_LIBRARY=ON \
  844. -DLLAMA_CURL=OFF \
  845. -DLLAMA_BUILD_EXAMPLES=OFF \
  846. -DLLAMA_BUILD_TOOLS=OFF \
  847. -DLLAMA_BUILD_TESTS=OFF \
  848. -DLLAMA_BUILD_SERVER=OFF \
  849. -DCMAKE_SYSTEM_NAME=iOS \
  850. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
  851. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  852. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  853. - name: xcodebuild for swift package
  854. id: xcodebuild
  855. run: |
  856. ./build-xcframework.sh
  857. - name: Build Xcode project
  858. 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
  859. android-build:
  860. runs-on: ubuntu-latest
  861. steps:
  862. - name: Clone
  863. uses: actions/checkout@v4
  864. - name: ccache
  865. uses: hendrikmuhs/ccache-action@v1.2.16
  866. with:
  867. key: android-build
  868. evict-old-files: 1d
  869. - name: Set up JDK
  870. uses: actions/setup-java@v3
  871. with:
  872. java-version: 17
  873. distribution: zulu
  874. - name: Setup Android SDK
  875. uses: android-actions/setup-android@v3
  876. with:
  877. log-accepted-android-sdk-licenses: false
  878. - name: Build
  879. run: |
  880. cd examples/llama.android
  881. ./gradlew build --no-daemon
  882. openEuler-latest-cmake-cann:
  883. if: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'Ascend NPU') }}
  884. defaults:
  885. run:
  886. shell: bash -el {0}
  887. strategy:
  888. matrix:
  889. arch: [x86, aarch64]
  890. cann:
  891. - '8.1.RC1.alpha001-910b-openeuler22.03-py3.10'
  892. device:
  893. - 'ascend910b3'
  894. build:
  895. - 'Release'
  896. runs-on: ${{ matrix.arch == 'aarch64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
  897. container: ascendai/cann:${{ matrix.cann }}
  898. steps:
  899. - name: Checkout
  900. uses: actions/checkout@v4
  901. - name: Dependencies
  902. run: |
  903. yum update -y
  904. yum install -y git gcc gcc-c++ make cmake libcurl-devel
  905. - name: Build
  906. run: |
  907. export LD_LIBRARY_PATH=${ASCEND_TOOLKIT_HOME}/lib64:${ASCEND_TOOLKIT_HOME}/$(uname -m)-linux/devlib/:${LD_LIBRARY_PATH}
  908. cmake -S . -B build \
  909. -DCMAKE_BUILD_TYPE=${{ matrix.build }} \
  910. -DGGML_CANN=on \
  911. -DSOC_TYPE=${{ matrix.device }}
  912. cmake --build build -j $(nproc)