build.yml 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316
  1. name: CI
  2. on:
  3. workflow_dispatch: # allows manual triggering
  4. inputs:
  5. create_release:
  6. description: 'Create new release'
  7. required: true
  8. type: boolean
  9. push:
  10. branches:
  11. - master
  12. paths: ['.github/workflows/build.yml', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cuh', '**/*.swift', '**/*.m', '**/*.metal']
  13. pull_request:
  14. types: [opened, synchronize, reopened]
  15. paths: ['.github/workflows/build.yml', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cuh', '**/*.swift', '**/*.m', '**/*.metal']
  16. concurrency:
  17. group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
  18. cancel-in-progress: true
  19. env:
  20. BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
  21. GGML_NLOOP: 3
  22. GGML_N_THREADS: 1
  23. jobs:
  24. macOS-latest-cmake-arm64:
  25. runs-on: macos-14
  26. steps:
  27. - name: Clone
  28. id: checkout
  29. uses: actions/checkout@v4
  30. with:
  31. fetch-depth: 0
  32. - name: Dependencies
  33. id: depends
  34. continue-on-error: true
  35. run: |
  36. brew update
  37. - name: Build
  38. id: cmake_build
  39. run: |
  40. sysctl -a
  41. mkdir build
  42. cd build
  43. cmake -DLLAMA_FATAL_WARNINGS=ON -DGGML_METAL_EMBED_LIBRARY=ON -DLLAMA_CURL=ON -DBUILD_SHARED_LIBS=OFF ..
  44. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu)
  45. - name: Test
  46. id: cmake_test
  47. run: |
  48. cd build
  49. ctest -L 'main|curl' --verbose --timeout 900
  50. - name: Determine tag name
  51. id: tag
  52. shell: bash
  53. run: |
  54. BUILD_NUMBER="$(git rev-list --count HEAD)"
  55. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  56. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  57. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  58. else
  59. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  60. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  61. fi
  62. - name: Pack artifacts
  63. id: pack_artifacts
  64. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  65. run: |
  66. cp LICENSE ./build/bin/
  67. zip -r llama-${{ steps.tag.outputs.name }}-bin-macos-arm64.zip ./build/bin/*
  68. - name: Upload artifacts
  69. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  70. uses: actions/upload-artifact@v4
  71. with:
  72. path: llama-${{ steps.tag.outputs.name }}-bin-macos-arm64.zip
  73. name: llama-bin-macos-arm64.zip
  74. macOS-latest-cmake-x64:
  75. runs-on: macos-12
  76. steps:
  77. - name: Clone
  78. id: checkout
  79. uses: actions/checkout@v4
  80. with:
  81. fetch-depth: 0
  82. - name: Dependencies
  83. id: depends
  84. continue-on-error: true
  85. run: |
  86. brew update
  87. - name: Build
  88. id: cmake_build
  89. run: |
  90. sysctl -a
  91. # Metal is disabled due to intermittent failures with Github runners not having a GPU:
  92. # https://github.com/ggerganov/llama.cpp/actions/runs/8635935781/job/23674807267#step:5:2313
  93. cmake -B build -DLLAMA_FATAL_WARNINGS=ON -DGGML_METAL=OFF -DLLAMA_CURL=ON -DBUILD_SHARED_LIBS=OFF
  94. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
  95. - name: Test
  96. id: cmake_test
  97. run: |
  98. cd build
  99. ctest -L main --verbose --timeout 900
  100. - name: Determine tag name
  101. id: tag
  102. shell: bash
  103. run: |
  104. BUILD_NUMBER="$(git rev-list --count HEAD)"
  105. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  106. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  107. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  108. else
  109. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  110. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  111. fi
  112. - name: Pack artifacts
  113. id: pack_artifacts
  114. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  115. run: |
  116. cp LICENSE ./build/bin/
  117. zip -r llama-${{ steps.tag.outputs.name }}-bin-macos-x64.zip ./build/bin/*
  118. - name: Upload artifacts
  119. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  120. uses: actions/upload-artifact@v4
  121. with:
  122. path: llama-${{ steps.tag.outputs.name }}-bin-macos-x64.zip
  123. name: llama-bin-macos-x64.zip
  124. ubuntu-focal-make:
  125. runs-on: ubuntu-20.04
  126. env:
  127. LLAMA_NODE_AVAILABLE: true
  128. LLAMA_PYTHON_AVAILABLE: true
  129. steps:
  130. - name: Clone
  131. id: checkout
  132. uses: actions/checkout@v4
  133. - name: Dependencies
  134. id: depends
  135. run: |
  136. sudo apt-get update
  137. sudo apt-get install build-essential gcc-8
  138. - uses: actions/setup-node@v4
  139. with:
  140. node-version: "20"
  141. - uses: actions/setup-python@v5
  142. with:
  143. python-version: "3.11"
  144. - name: Build
  145. id: make_build
  146. env:
  147. LLAMA_FATAL_WARNINGS: 1
  148. run: |
  149. CC=gcc-8 make -j $(nproc)
  150. - name: Test
  151. id: make_test
  152. run: |
  153. CC=gcc-8 make tests -j $(nproc)
  154. make test -j $(nproc)
  155. ubuntu-focal-make-curl:
  156. runs-on: ubuntu-20.04
  157. steps:
  158. - name: Clone
  159. id: checkout
  160. uses: actions/checkout@v4
  161. - name: Dependencies
  162. id: depends
  163. run: |
  164. sudo apt-get update
  165. sudo apt-get install build-essential gcc-8 libcurl4-openssl-dev
  166. - name: Build
  167. id: make_build
  168. env:
  169. LLAMA_FATAL_WARNINGS: 1
  170. LLAMA_CURL: 1
  171. run: |
  172. CC=gcc-8 make -j $(nproc)
  173. ubuntu-latest-cmake:
  174. runs-on: ubuntu-latest
  175. steps:
  176. - name: Clone
  177. id: checkout
  178. uses: actions/checkout@v4
  179. with:
  180. fetch-depth: 0
  181. - name: Dependencies
  182. id: depends
  183. run: |
  184. sudo apt-get update
  185. sudo apt-get install build-essential libcurl4-openssl-dev
  186. - name: Build
  187. id: cmake_build
  188. run: |
  189. mkdir build
  190. cd build
  191. cmake .. -DLLAMA_FATAL_WARNINGS=ON -DLLAMA_CURL=ON -DBUILD_SHARED_LIBS=OFF
  192. cmake --build . --config Release -j $(nproc)
  193. - name: Test
  194. id: cmake_test
  195. run: |
  196. cd build
  197. ctest -L 'main|curl' --verbose --timeout 900
  198. - name: Test llama2c conversion
  199. id: llama2c_test
  200. run: |
  201. cd build
  202. echo "Fetch tokenizer"
  203. wget https://huggingface.co/karpathy/tinyllamas/resolve/main/stories260K/tok512.bin
  204. echo "Fetch llama2c model"
  205. wget https://huggingface.co/karpathy/tinyllamas/resolve/main/stories260K/stories260K.bin
  206. ./bin/llama-convert-llama2c-to-ggml --copy-vocab-from-model ./tok512.bin --llama2c-model stories260K.bin --llama2c-output-model stories260K.gguf
  207. ./bin/llama-cli -m stories260K.gguf -p "One day, Lily met a Shoggoth" -n 500 -c 256
  208. - name: Determine tag name
  209. id: tag
  210. shell: bash
  211. run: |
  212. BUILD_NUMBER="$(git rev-list --count HEAD)"
  213. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  214. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  215. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  216. else
  217. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  218. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  219. fi
  220. - name: Pack artifacts
  221. id: pack_artifacts
  222. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  223. run: |
  224. cp LICENSE ./build/bin/
  225. zip -r llama-${{ steps.tag.outputs.name }}-bin-ubuntu-x64.zip ./build/bin/*
  226. - name: Upload artifacts
  227. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  228. uses: actions/upload-artifact@v4
  229. with:
  230. path: llama-${{ steps.tag.outputs.name }}-bin-ubuntu-x64.zip
  231. name: llama-bin-ubuntu-x64.zip
  232. ubuntu-latest-cmake-sanitizer:
  233. runs-on: ubuntu-latest
  234. continue-on-error: true
  235. strategy:
  236. matrix:
  237. sanitizer: [ADDRESS, THREAD, UNDEFINED]
  238. build_type: [Debug, Release]
  239. steps:
  240. - name: Clone
  241. id: checkout
  242. uses: actions/checkout@v4
  243. - name: Dependencies
  244. id: depends
  245. run: |
  246. sudo apt-get update
  247. sudo apt-get install build-essential
  248. - name: Build
  249. id: cmake_build
  250. if: ${{ matrix.sanitizer != 'THREAD' }}
  251. run: |
  252. mkdir build
  253. cd build
  254. cmake .. -DLLAMA_FATAL_WARNINGS=ON -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
  255. cmake --build . --config ${{ matrix.build_type }} -j $(nproc)
  256. - name: Build (no OpenMP)
  257. id: cmake_build_no_openmp
  258. if: ${{ matrix.sanitizer == 'THREAD' }}
  259. run: |
  260. mkdir build
  261. cd build
  262. cmake .. -DLLAMA_FATAL_WARNINGS=ON -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DGGML_OPENMP=OFF
  263. cmake --build . --config ${{ matrix.build_type }} -j $(nproc)
  264. - name: Test
  265. id: cmake_test
  266. run: |
  267. cd build
  268. ctest -L main --verbose --timeout 900
  269. ubuntu-latest-cmake-rpc:
  270. runs-on: ubuntu-latest
  271. continue-on-error: true
  272. steps:
  273. - name: Clone
  274. id: checkout
  275. uses: actions/checkout@v4
  276. - name: Dependencies
  277. id: depends
  278. run: |
  279. sudo apt-get update
  280. sudo apt-get install build-essential
  281. - name: Build
  282. id: cmake_build
  283. run: |
  284. mkdir build
  285. cd build
  286. cmake -DGGML_RPC=ON ..
  287. cmake --build . --config Release -j $(nproc)
  288. - name: Test
  289. id: cmake_test
  290. run: |
  291. cd build
  292. ctest -L main --verbose
  293. ubuntu-22-cmake-vulkan:
  294. runs-on: ubuntu-22.04
  295. steps:
  296. - name: Clone
  297. id: checkout
  298. uses: actions/checkout@v4
  299. - name: Dependencies
  300. id: depends
  301. run: |
  302. wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add -
  303. sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
  304. sudo apt-get update -y
  305. sudo apt-get install -y build-essential vulkan-sdk
  306. - name: Build
  307. id: cmake_build
  308. run: |
  309. mkdir build
  310. cd build
  311. cmake -DGGML_VULKAN=ON ..
  312. cmake --build . --config Release -j $(nproc)
  313. ubuntu-22-cmake-hip:
  314. runs-on: ubuntu-22.04
  315. container: rocm/dev-ubuntu-22.04:6.0.2
  316. steps:
  317. - name: Clone
  318. id: checkout
  319. uses: actions/checkout@v3
  320. - name: Dependencies
  321. id: depends
  322. run: |
  323. sudo apt-get update
  324. sudo apt-get install -y build-essential git cmake rocblas-dev hipblas-dev
  325. - name: Build with native CMake HIP support
  326. id: cmake_build
  327. run: |
  328. cmake -B build -S . -DCMAKE_HIP_COMPILER="$(hipconfig -l)/clang" -DGGML_HIPBLAS=ON
  329. cmake --build build --config Release -j $(nproc)
  330. - name: Build with legacy HIP support
  331. id: cmake_build_legacy_hip
  332. run: |
  333. cmake -B build2 -S . -DCMAKE_C_COMPILER=hipcc -DCMAKE_CXX_COMPILER=hipcc -DGGML_HIPBLAS=ON
  334. cmake --build build2 --config Release -j $(nproc)
  335. ubuntu-22-cmake-sycl:
  336. runs-on: ubuntu-22.04
  337. continue-on-error: true
  338. steps:
  339. - uses: actions/checkout@v2
  340. - name: add oneAPI to apt
  341. shell: bash
  342. run: |
  343. cd /tmp
  344. wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  345. sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  346. rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  347. sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
  348. - name: install oneAPI dpcpp compiler
  349. shell: bash
  350. run: |
  351. sudo apt update
  352. sudo apt install intel-oneapi-compiler-dpcpp-cpp
  353. - name: install oneAPI MKL library
  354. shell: bash
  355. run: |
  356. sudo apt install intel-oneapi-mkl-devel
  357. - name: Clone
  358. id: checkout
  359. uses: actions/checkout@v4
  360. - name: Build
  361. id: cmake_build
  362. run: |
  363. source /opt/intel/oneapi/setvars.sh
  364. mkdir build
  365. cd build
  366. cmake -DGGML_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx ..
  367. cmake --build . --config Release -j $(nproc)
  368. ubuntu-22-cmake-sycl-fp16:
  369. runs-on: ubuntu-22.04
  370. continue-on-error: true
  371. steps:
  372. - uses: actions/checkout@v2
  373. - name: add oneAPI to apt
  374. shell: bash
  375. run: |
  376. cd /tmp
  377. wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  378. sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  379. rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  380. sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
  381. - name: install oneAPI dpcpp compiler
  382. shell: bash
  383. run: |
  384. sudo apt update
  385. sudo apt install intel-oneapi-compiler-dpcpp-cpp
  386. - name: install oneAPI MKL library
  387. shell: bash
  388. run: |
  389. sudo apt install intel-oneapi-mkl-devel
  390. - name: Clone
  391. id: checkout
  392. uses: actions/checkout@v4
  393. - name: Build
  394. id: cmake_build
  395. run: |
  396. source /opt/intel/oneapi/setvars.sh
  397. mkdir build
  398. cd build
  399. cmake -DGGML_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DGGML_SYCL_F16=ON ..
  400. cmake --build . --config Release -j $(nproc)
  401. # TODO: build with GGML_NO_METAL because test-backend-ops fail on "Apple Paravirtual device" and I don't know
  402. # how to debug it.
  403. # ref: https://github.com/ggerganov/llama.cpp/actions/runs/7131777249/job/19420981052#step:5:1124
  404. macOS-latest-make:
  405. runs-on: macos-latest
  406. steps:
  407. - name: Clone
  408. id: checkout
  409. uses: actions/checkout@v4
  410. - name: Dependencies
  411. id: depends
  412. continue-on-error: true
  413. run: |
  414. brew update
  415. - name: Build
  416. id: make_build
  417. env:
  418. LLAMA_FATAL_WARNINGS: 1
  419. run: |
  420. GGML_NO_METAL=1 make -j $(sysctl -n hw.logicalcpu)
  421. - name: Test
  422. id: make_test
  423. run: |
  424. GGML_NO_METAL=1 make tests -j $(sysctl -n hw.logicalcpu)
  425. GGML_NO_METAL=1 make test -j $(sysctl -n hw.logicalcpu)
  426. # TODO: build with GGML_METAL=OFF because test-backend-ops fail on "Apple Paravirtual device" and I don't know
  427. # how to debug it.
  428. # ref: https://github.com/ggerganov/llama.cpp/actions/runs/7132125951/job/19422043567?pr=4359#step:5:6584
  429. # would be great if we fix these
  430. macOS-latest-cmake:
  431. runs-on: macos-latest
  432. steps:
  433. - name: Clone
  434. id: checkout
  435. uses: actions/checkout@v4
  436. - name: Dependencies
  437. id: depends
  438. continue-on-error: true
  439. run: |
  440. brew update
  441. - name: Build
  442. id: cmake_build
  443. run: |
  444. sysctl -a
  445. mkdir build
  446. cd build
  447. cmake -DLLAMA_FATAL_WARNINGS=ON -DGGML_METAL=OFF ..
  448. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu)
  449. - name: Test
  450. id: cmake_test
  451. run: |
  452. cd build
  453. ctest -L main --verbose --timeout 900
  454. macOS-latest-cmake-ios:
  455. runs-on: macos-latest
  456. steps:
  457. - name: Clone
  458. id: checkout
  459. uses: actions/checkout@v1
  460. - name: Dependencies
  461. id: depends
  462. continue-on-error: true
  463. run: |
  464. brew update
  465. - name: Build
  466. id: cmake_build
  467. run: |
  468. sysctl -a
  469. mkdir build
  470. cd build
  471. cmake -G Xcode .. \
  472. -DGGML_METAL_EMBED_LIBRARY=ON \
  473. -DLLAMA_BUILD_EXAMPLES=OFF \
  474. -DLLAMA_BUILD_TESTS=OFF \
  475. -DLLAMA_BUILD_SERVER=OFF \
  476. -DCMAKE_SYSTEM_NAME=iOS \
  477. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
  478. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  479. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  480. macOS-latest-cmake-tvos:
  481. runs-on: macos-latest
  482. steps:
  483. - name: Clone
  484. id: checkout
  485. uses: actions/checkout@v1
  486. - name: Dependencies
  487. id: depends
  488. continue-on-error: true
  489. run: |
  490. brew update
  491. - name: Build
  492. id: cmake_build
  493. run: |
  494. sysctl -a
  495. mkdir build
  496. cd build
  497. cmake -G Xcode .. \
  498. -DGGML_METAL_EMBED_LIBRARY=ON \
  499. -DLLAMA_BUILD_EXAMPLES=OFF \
  500. -DLLAMA_BUILD_TESTS=OFF \
  501. -DLLAMA_BUILD_SERVER=OFF \
  502. -DCMAKE_SYSTEM_NAME=tvOS \
  503. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
  504. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  505. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  506. macOS-latest-swift:
  507. runs-on: macos-latest
  508. strategy:
  509. matrix:
  510. destination: ['generic/platform=macOS', 'generic/platform=iOS', 'generic/platform=tvOS']
  511. steps:
  512. - name: Clone
  513. id: checkout
  514. uses: actions/checkout@v1
  515. - name: Dependencies
  516. id: depends
  517. continue-on-error: true
  518. run: |
  519. brew update
  520. - name: xcodebuild for swift package
  521. id: xcodebuild
  522. run: |
  523. xcodebuild -scheme llama -destination "${{ matrix.destination }}"
  524. - name: Build Swift Example
  525. id: make_build_swift_example
  526. run: |
  527. make swift
  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: Setup ${{ matrix.sys }}
  540. uses: msys2/setup-msys2@v2
  541. with:
  542. update: true
  543. msystem: ${{matrix.sys}}
  544. install: >-
  545. base-devel
  546. mingw-w64-${{matrix.env}}-toolchain
  547. mingw-w64-${{matrix.env}}-cmake
  548. mingw-w64-${{matrix.env}}-openblas
  549. - name: Build using make
  550. shell: msys2 {0}
  551. run: |
  552. make -j $(nproc)
  553. - name: Clean after building using make
  554. shell: msys2 {0}
  555. run: |
  556. make clean
  557. - name: Build using make w/ OpenBLAS
  558. shell: msys2 {0}
  559. run: |
  560. make GGML_OPENBLAS=1 -j $(nproc)
  561. - name: Build using CMake
  562. shell: msys2 {0}
  563. run: |
  564. cmake -B build
  565. cmake --build build --config ${{ matrix.build }} -j $(nproc)
  566. - name: Clean after building using CMake
  567. shell: msys2 {0}
  568. run: |
  569. rm -rf build
  570. - name: Build using CMake w/ OpenBLAS
  571. shell: msys2 {0}
  572. run: |
  573. cmake -B build -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS
  574. cmake --build build --config ${{ matrix.build }} -j $(nproc)
  575. windows-latest-cmake:
  576. runs-on: windows-2019
  577. env:
  578. OPENBLAS_VERSION: 0.3.23
  579. SDE_VERSION: 9.33.0-2024-01-07
  580. VULKAN_VERSION: 1.3.261.1
  581. strategy:
  582. matrix:
  583. include:
  584. - build: 'rpc-x64'
  585. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DBUILD_SHARED_LIBS=ON'
  586. - build: 'noavx-x64'
  587. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_FMA=OFF -DBUILD_SHARED_LIBS=ON'
  588. - build: 'avx2-x64'
  589. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DBUILD_SHARED_LIBS=ON'
  590. - build: 'avx-x64'
  591. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_AVX2=OFF -DBUILD_SHARED_LIBS=ON'
  592. - build: 'avx512-x64'
  593. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_AVX512=ON -DBUILD_SHARED_LIBS=ON'
  594. - build: 'openblas-x64'
  595. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_BLAS=ON -DBUILD_SHARED_LIBS=ON -DGGML_BLAS_VENDOR=OpenBLAS -DBLAS_INCLUDE_DIRS="$env:RUNNER_TEMP/openblas/include" -DBLAS_LIBRARIES="$env:RUNNER_TEMP/openblas/lib/openblas.lib"'
  596. - build: 'kompute-x64'
  597. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_KOMPUTE=ON -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON -DBUILD_SHARED_LIBS=ON'
  598. - build: 'vulkan-x64'
  599. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_VULKAN=ON -DBUILD_SHARED_LIBS=ON'
  600. - build: 'llvm-arm64'
  601. defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-llvm.cmake -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DBUILD_SHARED_LIBS=ON'
  602. - build: 'msvc-arm64'
  603. defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-msvc.cmake -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DBUILD_SHARED_LIBS=ON'
  604. steps:
  605. - name: Clone
  606. id: checkout
  607. uses: actions/checkout@v4
  608. with:
  609. fetch-depth: 0
  610. - name: Clone Kompute submodule
  611. id: clone_kompute
  612. if: ${{ matrix.build == 'kompute-x64' }}
  613. run: |
  614. git submodule update --init ggml/src/kompute
  615. - name: Download OpenBLAS
  616. id: get_openblas
  617. if: ${{ matrix.build == 'openblas-x64' }}
  618. run: |
  619. 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"
  620. curl.exe -o $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt -L "https://github.com/xianyi/OpenBLAS/raw/v${env:OPENBLAS_VERSION}/LICENSE"
  621. mkdir $env:RUNNER_TEMP/openblas
  622. tar.exe -xvf $env:RUNNER_TEMP/openblas.zip -C $env:RUNNER_TEMP/openblas
  623. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  624. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  625. $lib = $(join-path $msvc 'bin\Hostx64\x64\lib.exe')
  626. & $lib /machine:x64 "/def:${env:RUNNER_TEMP}/openblas/lib/libopenblas.def" "/out:${env:RUNNER_TEMP}/openblas/lib/openblas.lib" /name:openblas.dll
  627. - name: Install Vulkan SDK
  628. id: get_vulkan
  629. if: ${{ matrix.build == 'kompute-x64' || matrix.build == 'vulkan-x64' }}
  630. run: |
  631. 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"
  632. & "$env:RUNNER_TEMP\VulkanSDK-Installer.exe" --accept-licenses --default-answer --confirm-command install
  633. Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${env:VULKAN_VERSION}"
  634. Add-Content $env:GITHUB_PATH "C:\VulkanSDK\${env:VULKAN_VERSION}\bin"
  635. - name: Install Ninja
  636. id: install_ninja
  637. run: |
  638. choco install ninja
  639. - name: Build
  640. id: cmake_build
  641. run: |
  642. cmake -S . -B build ${{ matrix.defines }}
  643. cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS}
  644. - name: Add libopenblas.dll
  645. id: add_libopenblas_dll
  646. if: ${{ matrix.build == 'openblas-x64' }}
  647. run: |
  648. cp $env:RUNNER_TEMP/openblas/bin/libopenblas.dll ./build/bin/Release/openblas.dll
  649. cp $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt ./build/bin/Release/OpenBLAS-${env:OPENBLAS_VERSION}.txt
  650. - name: Check AVX512F support
  651. id: check_avx512f
  652. if: ${{ matrix.build == 'avx512-x64' }}
  653. continue-on-error: true
  654. run: |
  655. cd build
  656. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  657. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  658. $cl = $(join-path $msvc 'bin\Hostx64\x64\cl.exe')
  659. echo 'int main(void){unsigned int a[4];__cpuid(a,7);return !(a[1]&65536);}' >> avx512f.c
  660. & $cl /O2 /GS- /kernel avx512f.c /link /nodefaultlib /entry:main
  661. .\avx512f.exe && echo "AVX512F: YES" && ( echo HAS_AVX512F=1 >> $env:GITHUB_ENV ) || echo "AVX512F: NO"
  662. - name: Test
  663. id: cmake_test
  664. # not all machines have native AVX-512
  665. if: ${{ matrix.build != 'msvc-arm64' && matrix.build != 'llvm-arm64' && matrix.build != 'kompute-x64' && matrix.build != 'vulkan-x64' && (matrix.build != 'avx512-x64' || env.HAS_AVX512F == '1') }}
  666. run: |
  667. cd build
  668. ctest -L main -C Release --verbose --timeout 900
  669. - name: Test (Intel SDE)
  670. id: cmake_test_sde
  671. if: ${{ matrix.build == 'avx512-x64' && env.HAS_AVX512F == '0' }} # use Intel SDE for AVX-512 emulation
  672. run: |
  673. curl.exe -o $env:RUNNER_TEMP/sde.tar.xz -L "https://downloadmirror.intel.com/813591/sde-external-${env:SDE_VERSION}-win.tar.xz"
  674. # for some weird reason windows tar doesn't like sde tar.xz
  675. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar.xz
  676. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar
  677. $sde = $(join-path $env:RUNNER_TEMP sde-external-${env:SDE_VERSION}-win/sde.exe)
  678. cd build
  679. $env:LLAMA_SKIP_TESTS_SLOW_ON_EMULATOR = 1
  680. & $sde -future -- ctest -L main -C Release --verbose --timeout 900
  681. - name: Determine tag name
  682. id: tag
  683. shell: bash
  684. run: |
  685. BUILD_NUMBER="$(git rev-list --count HEAD)"
  686. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  687. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  688. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  689. else
  690. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  691. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  692. fi
  693. - name: Pack artifacts
  694. id: pack_artifacts
  695. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  696. run: |
  697. Copy-Item LICENSE .\build\bin\Release\llama.cpp.txt
  698. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip .\build\bin\Release\*
  699. - name: Upload artifacts
  700. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  701. uses: actions/upload-artifact@v4
  702. with:
  703. path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip
  704. name: llama-bin-win-${{ matrix.build }}.zip
  705. windows-latest-cmake-cuda:
  706. runs-on: windows-2019
  707. strategy:
  708. matrix:
  709. cuda: ['12.2.0', '11.7.1']
  710. build: ['cuda']
  711. steps:
  712. - name: Clone
  713. id: checkout
  714. uses: actions/checkout@v4
  715. with:
  716. fetch-depth: 0
  717. - name: Install CUDA toolkit
  718. id: cuda-toolkit
  719. uses: Jimver/cuda-toolkit@v0.2.15
  720. with:
  721. cuda: ${{ matrix.cuda }}
  722. method: 'network'
  723. sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]'
  724. - name: Build
  725. id: cmake_build
  726. run: |
  727. mkdir build
  728. cd build
  729. cmake .. -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_CUDA=ON -DBUILD_SHARED_LIBS=ON
  730. cmake --build . --config Release -j $((${env:NUMBER_OF_PROCESSORS} - 1)) -t ggml
  731. cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS}
  732. - name: Determine tag name
  733. id: tag
  734. shell: bash
  735. run: |
  736. BUILD_NUMBER="$(git rev-list --count HEAD)"
  737. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  738. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  739. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  740. else
  741. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  742. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  743. fi
  744. - name: Pack artifacts
  745. id: pack_artifacts
  746. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  747. run: |
  748. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip .\build\bin\Release\*
  749. - name: Upload artifacts
  750. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  751. uses: actions/upload-artifact@v4
  752. with:
  753. path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip
  754. name: llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  755. - name: Copy and pack Cuda runtime
  756. run: |
  757. echo "Cuda install location: ${{steps.cuda-toolkit.outputs.CUDA_PATH}}"
  758. $dst='.\build\bin\cudart\'
  759. robocopy "${{steps.cuda-toolkit.outputs.CUDA_PATH}}\bin" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
  760. 7z a cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip $dst\*
  761. - name: Upload Cuda runtime
  762. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  763. uses: actions/upload-artifact@v4
  764. with:
  765. path: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  766. name: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  767. windows-latest-cmake-sycl:
  768. runs-on: windows-latest
  769. defaults:
  770. run:
  771. shell: bash
  772. env:
  773. WINDOWS_BASEKIT_URL: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/7dff44ba-e3af-4448-841c-0d616c8da6e7/w_BaseKit_p_2024.1.0.595_offline.exe
  774. WINDOWS_DPCPP_MKL: intel.oneapi.win.cpp-dpcpp-common:intel.oneapi.win.mkl.devel
  775. ONEAPI_ROOT: "C:/Program Files (x86)/Intel/oneAPI"
  776. steps:
  777. - name: Clone
  778. id: checkout
  779. uses: actions/checkout@v4
  780. with:
  781. fetch-depth: 0
  782. - name: Install
  783. run: scripts/install-oneapi.bat $WINDOWS_BASEKIT_URL $WINDOWS_DPCPP_MKL
  784. - name: Build
  785. id: cmake_build
  786. run: examples/sycl/win-build-sycl.bat
  787. - name: Determine tag name
  788. id: tag
  789. shell: bash
  790. run: |
  791. BUILD_NUMBER="$(git rev-list --count HEAD)"
  792. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  793. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  794. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  795. else
  796. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  797. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  798. fi
  799. - name: Pack artifacts
  800. id: pack_artifacts
  801. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  802. run: |
  803. echo "cp oneAPI running time dll files in ${{ env.ONEAPI_ROOT }} to ./build/bin"
  804. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_sycl_blas.4.dll" ./build/bin
  805. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_core.2.dll" ./build/bin
  806. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_tbb_thread.2.dll" ./build/bin
  807. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/pi_win_proxy_loader.dll" ./build/bin
  808. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/pi_level_zero.dll" ./build/bin
  809. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/sycl7.dll" ./build/bin
  810. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/svml_dispmd.dll" ./build/bin
  811. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/libmmd.dll" ./build/bin
  812. echo "cp oneAPI running time dll files to ./build/bin done"
  813. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip ./build/bin/*
  814. - name: Upload artifacts
  815. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  816. uses: actions/upload-artifact@v4
  817. with:
  818. path: llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip
  819. name: llama-bin-win-sycl-x64.zip
  820. windows-latest-cmake-hip:
  821. runs-on: windows-latest
  822. steps:
  823. - name: Clone
  824. id: checkout
  825. uses: actions/checkout@v3
  826. - name: Install
  827. id: depends
  828. run: |
  829. $ErrorActionPreference = "Stop"
  830. write-host "Downloading AMD HIP SDK Installer"
  831. Invoke-WebRequest -Uri "https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-23.Q4-WinSvr2022-For-HIP.exe" -OutFile "${env:RUNNER_TEMP}\rocm-install.exe"
  832. write-host "Installing AMD HIP SDK"
  833. Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
  834. write-host "Completed AMD HIP SDK installation"
  835. - name: Verify ROCm
  836. id: verify
  837. run: |
  838. & 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
  839. - name: Build
  840. id: cmake_build
  841. run: |
  842. $env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
  843. $env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
  844. cmake -G "Unix Makefiles" -B build -S . -DCMAKE_C_COMPILER="${env:HIP_PATH}\bin\clang.exe" -DCMAKE_CXX_COMPILER="${env:HIP_PATH}\bin\clang++.exe" -DGGML_HIPBLAS=ON
  845. cmake --build build --config Release
  846. ios-xcode-build:
  847. runs-on: macos-latest
  848. steps:
  849. - name: Checkout code
  850. uses: actions/checkout@v4
  851. - name: Build Xcode project
  852. 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' build
  853. android-build:
  854. runs-on: ubuntu-latest
  855. steps:
  856. - name: Clone
  857. uses: actions/checkout@v4
  858. - name: Set up JDK
  859. uses: actions/setup-java@v3
  860. with:
  861. java-version: 17
  862. distribution: zulu
  863. - name: Setup Android SDK
  864. uses: android-actions/setup-android@v3
  865. with:
  866. log-accepted-android-sdk-licenses: false
  867. - name: Build
  868. run: |
  869. cd examples/llama.android
  870. ./gradlew build --no-daemon
  871. # freeBSD-latest:
  872. # runs-on: macos-12
  873. # steps:
  874. # - name: Clone
  875. # uses: actions/checkout@v4
  876. #
  877. # - name: Build
  878. # uses: cross-platform-actions/action@v0.19.0
  879. # with:
  880. # operating_system: freebsd
  881. # version: '13.2'
  882. # hypervisor: 'qemu'
  883. # run: |
  884. # sudo pkg update
  885. # sudo pkg install -y gmake automake autoconf pkgconf llvm15 openblas
  886. # gmake CC=/usr/local/bin/clang15 CXX=/usr/local/bin/clang++15 -j `sysctl -n hw.ncpu`
  887. release:
  888. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  889. runs-on: ubuntu-latest
  890. needs:
  891. - ubuntu-focal-make
  892. - ubuntu-latest-cmake
  893. - macOS-latest-make
  894. - macOS-latest-cmake
  895. - windows-latest-cmake
  896. - windows-latest-cmake-cuda
  897. - macOS-latest-cmake-arm64
  898. - macOS-latest-cmake-x64
  899. steps:
  900. - name: Clone
  901. id: checkout
  902. uses: actions/checkout@v4
  903. with:
  904. fetch-depth: 0
  905. - name: Determine tag name
  906. id: tag
  907. shell: bash
  908. run: |
  909. BUILD_NUMBER="$(git rev-list --count HEAD)"
  910. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  911. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  912. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  913. else
  914. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  915. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  916. fi
  917. - name: Download artifacts
  918. id: download-artifact
  919. uses: actions/download-artifact@v4
  920. with:
  921. path: ./artifact
  922. - name: Move artifacts
  923. id: move_artifacts
  924. run: mkdir -p ./artifact/release && mv ./artifact/*/*.zip ./artifact/release
  925. - name: Create release
  926. id: create_release
  927. uses: anzz1/action-create-release@v1
  928. env:
  929. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  930. with:
  931. tag_name: ${{ steps.tag.outputs.name }}
  932. - name: Upload release
  933. id: upload_release
  934. uses: actions/github-script@v3
  935. with:
  936. github-token: ${{secrets.GITHUB_TOKEN}}
  937. script: |
  938. const path = require('path');
  939. const fs = require('fs');
  940. const release_id = '${{ steps.create_release.outputs.id }}';
  941. for (let file of await fs.readdirSync('./artifact/release')) {
  942. if (path.extname(file) === '.zip') {
  943. console.log('uploadReleaseAsset', file);
  944. await github.repos.uploadReleaseAsset({
  945. owner: context.repo.owner,
  946. repo: context.repo.repo,
  947. release_id: release_id,
  948. name: file,
  949. data: await fs.readFileSync(`./artifact/release/${file}`)
  950. });
  951. }
  952. }
  953. # ubuntu-latest-gcc:
  954. # runs-on: ubuntu-latest
  955. #
  956. # strategy:
  957. # matrix:
  958. # build: [Debug, Release]
  959. #
  960. # steps:
  961. # - name: Clone
  962. # uses: actions/checkout@v4
  963. #
  964. # - name: Dependencies
  965. # run: |
  966. # sudo apt-get update
  967. # sudo apt-get install build-essential
  968. # sudo apt-get install cmake
  969. #
  970. # - name: Configure
  971. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  972. #
  973. # - name: Build
  974. # run: |
  975. # make
  976. #
  977. # ubuntu-latest-clang:
  978. # runs-on: ubuntu-latest
  979. #
  980. # strategy:
  981. # matrix:
  982. # build: [Debug, Release]
  983. #
  984. # steps:
  985. # - name: Clone
  986. # uses: actions/checkout@v4
  987. #
  988. # - name: Dependencies
  989. # run: |
  990. # sudo apt-get update
  991. # sudo apt-get install build-essential
  992. # sudo apt-get install cmake
  993. #
  994. # - name: Configure
  995. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
  996. #
  997. # - name: Build
  998. # run: |
  999. # make
  1000. #
  1001. # ubuntu-latest-gcc-sanitized:
  1002. # runs-on: ubuntu-latest
  1003. #
  1004. # strategy:
  1005. # matrix:
  1006. # sanitizer: [ADDRESS, THREAD, UNDEFINED]
  1007. #
  1008. # steps:
  1009. # - name: Clone
  1010. # uses: actions/checkout@v4
  1011. #
  1012. # - name: Dependencies
  1013. # run: |
  1014. # sudo apt-get update
  1015. # sudo apt-get install build-essential
  1016. # sudo apt-get install cmake
  1017. #
  1018. # - name: Configure
  1019. # run: cmake . -DCMAKE_BUILD_TYPE=Debug -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON
  1020. #
  1021. # - name: Build
  1022. # run: |
  1023. # make
  1024. #
  1025. # windows:
  1026. # runs-on: windows-latest
  1027. #
  1028. # strategy:
  1029. # matrix:
  1030. # build: [Release]
  1031. # arch: [Win32, x64]
  1032. # include:
  1033. # - arch: Win32
  1034. # s2arc: x86
  1035. # - arch: x64
  1036. # s2arc: x64
  1037. #
  1038. # steps:
  1039. # - name: Clone
  1040. # uses: actions/checkout@v4
  1041. #
  1042. # - name: Add msbuild to PATH
  1043. # uses: microsoft/setup-msbuild@v1
  1044. #
  1045. # - name: Configure
  1046. # run: >
  1047. # cmake -S . -B ./build -A ${{ matrix.arch }}
  1048. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1049. #
  1050. # - name: Build
  1051. # run: |
  1052. # cd ./build
  1053. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  1054. #
  1055. # - name: Upload binaries
  1056. # uses: actions/upload-artifact@v4
  1057. # with:
  1058. # name: llama-bin-${{ matrix.arch }}
  1059. # path: build/bin/${{ matrix.build }}
  1060. #
  1061. # windows-blas:
  1062. # runs-on: windows-latest
  1063. #
  1064. # strategy:
  1065. # matrix:
  1066. # build: [Release]
  1067. # arch: [Win32, x64]
  1068. # blas: [ON]
  1069. # include:
  1070. # - arch: Win32
  1071. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x86.zip
  1072. # s2arc: x86
  1073. # - arch: x64
  1074. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x64.zip
  1075. # s2arc: x64
  1076. #
  1077. # steps:
  1078. # - name: Clone
  1079. # uses: actions/checkout@v4
  1080. #
  1081. # - name: Add msbuild to PATH
  1082. # uses: microsoft/setup-msbuild@v1
  1083. #
  1084. # - name: Fetch OpenBLAS
  1085. # if: matrix.blas == 'ON'
  1086. # run: |
  1087. # C:/msys64/usr/bin/wget.exe -qO blas.zip ${{ matrix.obzip }}
  1088. # 7z x blas.zip -oblas -y
  1089. # copy blas/include/cblas.h .
  1090. # copy blas/include/openblas_config.h .
  1091. # echo "blasdir=$env:GITHUB_WORKSPACE/blas" >> $env:GITHUB_ENV
  1092. #
  1093. # - name: Configure
  1094. # run: >
  1095. # cmake -S . -B ./build -A ${{ matrix.arch }}
  1096. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1097. # -DLLAMA_SUPPORT_OPENBLAS=${{ matrix.blas }}
  1098. # -DCMAKE_LIBRARY_PATH="$env:blasdir/lib"
  1099. #
  1100. # - name: Build
  1101. # run: |
  1102. # cd ./build
  1103. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  1104. #
  1105. # - name: Copy libopenblas.dll
  1106. # if: matrix.blas == 'ON'
  1107. # run: copy "$env:blasdir/bin/libopenblas.dll" build/bin/${{ matrix.build }}
  1108. #
  1109. # - name: Upload binaries
  1110. # if: matrix.blas == 'ON'
  1111. # uses: actions/upload-artifact@v4
  1112. # with:
  1113. # name: llama-blas-bin-${{ matrix.arch }}
  1114. # path: build/bin/${{ matrix.build }}
  1115. #
  1116. # emscripten:
  1117. # runs-on: ubuntu-latest
  1118. #
  1119. # strategy:
  1120. # matrix:
  1121. # build: [Release]
  1122. #
  1123. # steps:
  1124. # - name: Clone
  1125. # uses: actions/checkout@v4
  1126. #
  1127. # - name: Dependencies
  1128. # run: |
  1129. # wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz
  1130. # tar -xvf master.tar.gz
  1131. # emsdk-master/emsdk update
  1132. # emsdk-master/emsdk install latest
  1133. # emsdk-master/emsdk activate latest
  1134. #
  1135. # - name: Configure
  1136. # run: echo "tmp"
  1137. #
  1138. # - name: Build
  1139. # run: |
  1140. # pushd emsdk-master
  1141. # source ./emsdk_env.sh
  1142. # popd
  1143. # emcmake cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1144. # make