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. 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. - 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-2022-cmake-cuda:
  714. runs-on: windows-2022
  715. strategy:
  716. matrix:
  717. cuda: ['12.4']
  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\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
  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/7cd9bba0-7aab-4e30-b3ae-2221006a4a05/intel-oneapi-base-toolkit-2025.1.1.34_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)