build.yml 41 KB

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