build.yml 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310
  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: ['.github/workflows/build.yml', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cuh', '**/*.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. # 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 -DLLAMA_METAL=OFF -DLLAMA_CURL=ON
  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
  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 }} -DLLAMA_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 -DLLAMA_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. sudo apt-get update
  303. sudo apt-get install build-essential libvulkan-dev
  304. - name: Build
  305. id: cmake_build
  306. run: |
  307. mkdir build
  308. cd build
  309. cmake -DLLAMA_VULKAN=ON ..
  310. cmake --build . --config Release -j $(nproc)
  311. ubuntu-22-cmake-hip:
  312. runs-on: ubuntu-22.04
  313. container: rocm/dev-ubuntu-22.04:6.0.2
  314. steps:
  315. - name: Clone
  316. id: checkout
  317. uses: actions/checkout@v3
  318. - name: Dependencies
  319. id: depends
  320. run: |
  321. sudo apt-get update
  322. sudo apt-get install -y build-essential git cmake rocblas-dev hipblas-dev
  323. - name: Build with native CMake HIP support
  324. id: cmake_build
  325. run: |
  326. cmake -B build -S . -DCMAKE_HIP_COMPILER="$(hipconfig -l)/clang" -DLLAMA_HIPBLAS=ON
  327. cmake --build build --config Release -j $(nproc)
  328. - name: Build with legacy HIP support
  329. id: cmake_build_legacy_hip
  330. run: |
  331. cmake -B build2 -S . -DCMAKE_C_COMPILER=hipcc -DCMAKE_CXX_COMPILER=hipcc -DLLAMA_HIPBLAS=ON
  332. cmake --build build2 --config Release -j $(nproc)
  333. ubuntu-22-cmake-sycl:
  334. runs-on: ubuntu-22.04
  335. continue-on-error: true
  336. steps:
  337. - uses: actions/checkout@v2
  338. - name: add oneAPI to apt
  339. shell: bash
  340. run: |
  341. cd /tmp
  342. wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  343. sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  344. rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  345. sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
  346. - name: install oneAPI dpcpp compiler
  347. shell: bash
  348. run: |
  349. sudo apt update
  350. sudo apt install intel-oneapi-compiler-dpcpp-cpp
  351. - name: install oneAPI MKL library
  352. shell: bash
  353. run: |
  354. sudo apt install intel-oneapi-mkl-devel
  355. - name: Clone
  356. id: checkout
  357. uses: actions/checkout@v4
  358. - name: Build
  359. id: cmake_build
  360. run: |
  361. source /opt/intel/oneapi/setvars.sh
  362. mkdir build
  363. cd build
  364. cmake -DLLAMA_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx ..
  365. cmake --build . --config Release -j $(nproc)
  366. ubuntu-22-cmake-sycl-fp16:
  367. runs-on: ubuntu-22.04
  368. continue-on-error: true
  369. steps:
  370. - uses: actions/checkout@v2
  371. - name: add oneAPI to apt
  372. shell: bash
  373. run: |
  374. cd /tmp
  375. wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  376. sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  377. rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  378. sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
  379. - name: install oneAPI dpcpp compiler
  380. shell: bash
  381. run: |
  382. sudo apt update
  383. sudo apt install intel-oneapi-compiler-dpcpp-cpp
  384. - name: install oneAPI MKL library
  385. shell: bash
  386. run: |
  387. sudo apt install intel-oneapi-mkl-devel
  388. - name: Clone
  389. id: checkout
  390. uses: actions/checkout@v4
  391. - name: Build
  392. id: cmake_build
  393. run: |
  394. source /opt/intel/oneapi/setvars.sh
  395. mkdir build
  396. cd build
  397. cmake -DLLAMA_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DLLAMA_SYCL_F16=ON ..
  398. cmake --build . --config Release -j $(nproc)
  399. # TODO: build with LLAMA_NO_METAL because test-backend-ops fail on "Apple Paravirtual device" and I don't know
  400. # how to debug it.
  401. # ref: https://github.com/ggerganov/llama.cpp/actions/runs/7131777249/job/19420981052#step:5:1124
  402. macOS-latest-make:
  403. runs-on: macos-latest
  404. steps:
  405. - name: Clone
  406. id: checkout
  407. uses: actions/checkout@v4
  408. - name: Dependencies
  409. id: depends
  410. continue-on-error: true
  411. run: |
  412. brew update
  413. - name: Build
  414. id: make_build
  415. env:
  416. LLAMA_FATAL_WARNINGS: 1
  417. run: |
  418. LLAMA_NO_METAL=1 make -j $(sysctl -n hw.logicalcpu)
  419. - name: Test
  420. id: make_test
  421. run: |
  422. LLAMA_NO_METAL=1 make tests -j $(sysctl -n hw.logicalcpu)
  423. LLAMA_NO_METAL=1 make test -j $(sysctl -n hw.logicalcpu)
  424. # TODO: build with LLAMA_METAL=OFF because test-backend-ops fail on "Apple Paravirtual device" and I don't know
  425. # how to debug it.
  426. # ref: https://github.com/ggerganov/llama.cpp/actions/runs/7132125951/job/19422043567?pr=4359#step:5:6584
  427. # would be great if we fix these
  428. macOS-latest-cmake:
  429. runs-on: macos-latest
  430. steps:
  431. - name: Clone
  432. id: checkout
  433. uses: actions/checkout@v4
  434. - name: Dependencies
  435. id: depends
  436. continue-on-error: true
  437. run: |
  438. brew update
  439. - name: Build
  440. id: cmake_build
  441. run: |
  442. sysctl -a
  443. mkdir build
  444. cd build
  445. cmake -DLLAMA_FATAL_WARNINGS=ON -DLLAMA_METAL=OFF ..
  446. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu)
  447. - name: Test
  448. id: cmake_test
  449. run: |
  450. cd build
  451. ctest -L main --verbose --timeout 900
  452. macOS-latest-cmake-ios:
  453. runs-on: macos-latest
  454. steps:
  455. - name: Clone
  456. id: checkout
  457. uses: actions/checkout@v1
  458. - name: Dependencies
  459. id: depends
  460. continue-on-error: true
  461. run: |
  462. brew update
  463. - name: Build
  464. id: cmake_build
  465. run: |
  466. sysctl -a
  467. mkdir build
  468. cd build
  469. cmake -G Xcode .. \
  470. -DLLAMA_METAL_EMBED_LIBRARY=ON \
  471. -DLLAMA_BUILD_EXAMPLES=OFF \
  472. -DLLAMA_BUILD_TESTS=OFF \
  473. -DLLAMA_BUILD_SERVER=OFF \
  474. -DCMAKE_SYSTEM_NAME=iOS \
  475. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0
  476. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu)
  477. macOS-latest-cmake-tvos:
  478. runs-on: macos-latest
  479. steps:
  480. - name: Clone
  481. id: checkout
  482. uses: actions/checkout@v1
  483. - name: Dependencies
  484. id: depends
  485. continue-on-error: true
  486. run: |
  487. brew update
  488. - name: Build
  489. id: cmake_build
  490. run: |
  491. sysctl -a
  492. mkdir build
  493. cd build
  494. cmake -G Xcode .. \
  495. -DLLAMA_METAL_EMBED_LIBRARY=ON \
  496. -DLLAMA_BUILD_EXAMPLES=OFF \
  497. -DLLAMA_BUILD_TESTS=OFF \
  498. -DLLAMA_BUILD_SERVER=OFF \
  499. -DCMAKE_SYSTEM_NAME=tvOS \
  500. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0
  501. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu)
  502. macOS-latest-swift:
  503. runs-on: macos-latest
  504. strategy:
  505. matrix:
  506. destination: ['generic/platform=macOS', 'generic/platform=iOS', 'generic/platform=tvOS']
  507. steps:
  508. - name: Clone
  509. id: checkout
  510. uses: actions/checkout@v1
  511. - name: Dependencies
  512. id: depends
  513. continue-on-error: true
  514. run: |
  515. brew update
  516. - name: xcodebuild for swift package
  517. id: xcodebuild
  518. run: |
  519. xcodebuild -scheme llama -destination "${{ matrix.destination }}"
  520. - name: Build Swift Example
  521. id: make_build_swift_example
  522. run: |
  523. make swift
  524. windows-msys2:
  525. runs-on: windows-latest
  526. strategy:
  527. fail-fast: false
  528. matrix:
  529. include:
  530. - { sys: UCRT64, env: ucrt-x86_64, build: Release }
  531. - { sys: CLANG64, env: clang-x86_64, build: Release }
  532. steps:
  533. - name: Clone
  534. uses: actions/checkout@v4
  535. - name: Setup ${{ matrix.sys }}
  536. uses: msys2/setup-msys2@v2
  537. with:
  538. update: true
  539. msystem: ${{matrix.sys}}
  540. install: >-
  541. base-devel
  542. mingw-w64-${{matrix.env}}-toolchain
  543. mingw-w64-${{matrix.env}}-cmake
  544. mingw-w64-${{matrix.env}}-openblas
  545. - name: Build using make
  546. shell: msys2 {0}
  547. run: |
  548. make -j $(nproc)
  549. - name: Clean after building using make
  550. shell: msys2 {0}
  551. run: |
  552. make clean
  553. - name: Build using make w/ OpenBLAS
  554. shell: msys2 {0}
  555. run: |
  556. make LLAMA_OPENBLAS=1 -j $(nproc)
  557. - name: Build using CMake
  558. shell: msys2 {0}
  559. run: |
  560. cmake -B build
  561. cmake --build build --config ${{ matrix.build }} -j $(nproc)
  562. - name: Clean after building using CMake
  563. shell: msys2 {0}
  564. run: |
  565. rm -rf build
  566. - name: Build using CMake w/ OpenBLAS
  567. shell: msys2 {0}
  568. run: |
  569. cmake -B build -DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS
  570. cmake --build build --config ${{ matrix.build }} -j $(nproc)
  571. windows-latest-cmake:
  572. runs-on: windows-2019
  573. env:
  574. OPENBLAS_VERSION: 0.3.23
  575. SDE_VERSION: 9.33.0-2024-01-07
  576. VULKAN_VERSION: 1.3.261.1
  577. strategy:
  578. matrix:
  579. include:
  580. - build: 'rpc-x64'
  581. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_RPC=ON -DBUILD_SHARED_LIBS=ON'
  582. - build: 'noavx-x64'
  583. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_AVX=OFF -DLLAMA_AVX2=OFF -DLLAMA_FMA=OFF -DBUILD_SHARED_LIBS=ON'
  584. - build: 'avx2-x64'
  585. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DBUILD_SHARED_LIBS=ON'
  586. - build: 'avx-x64'
  587. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_AVX2=OFF -DBUILD_SHARED_LIBS=ON'
  588. - build: 'avx512-x64'
  589. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_AVX512=ON -DBUILD_SHARED_LIBS=ON'
  590. - build: 'openblas-x64'
  591. 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"'
  592. - build: 'kompute-x64'
  593. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_KOMPUTE=ON -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON -DBUILD_SHARED_LIBS=ON'
  594. - build: 'vulkan-x64'
  595. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_VULKAN=ON -DBUILD_SHARED_LIBS=ON'
  596. - build: 'llvm-arm64'
  597. defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-llvm.cmake -DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DBUILD_SHARED_LIBS=ON'
  598. - build: 'msvc-arm64'
  599. defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-msvc.cmake -DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DBUILD_SHARED_LIBS=ON'
  600. steps:
  601. - name: Clone
  602. id: checkout
  603. uses: actions/checkout@v4
  604. with:
  605. fetch-depth: 0
  606. - name: Clone Kompute submodule
  607. id: clone_kompute
  608. if: ${{ matrix.build == 'kompute-x64' }}
  609. run: |
  610. git submodule update --init kompute
  611. - name: Download OpenBLAS
  612. id: get_openblas
  613. if: ${{ matrix.build == 'openblas-x64' }}
  614. run: |
  615. 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"
  616. curl.exe -o $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt -L "https://github.com/xianyi/OpenBLAS/raw/v${env:OPENBLAS_VERSION}/LICENSE"
  617. mkdir $env:RUNNER_TEMP/openblas
  618. tar.exe -xvf $env:RUNNER_TEMP/openblas.zip -C $env:RUNNER_TEMP/openblas
  619. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  620. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  621. $lib = $(join-path $msvc 'bin\Hostx64\x64\lib.exe')
  622. & $lib /machine:x64 "/def:${env:RUNNER_TEMP}/openblas/lib/libopenblas.def" "/out:${env:RUNNER_TEMP}/openblas/lib/openblas.lib" /name:openblas.dll
  623. - name: Install Vulkan SDK
  624. id: get_vulkan
  625. if: ${{ matrix.build == 'kompute-x64' || matrix.build == 'vulkan-x64' }}
  626. run: |
  627. 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"
  628. & "$env:RUNNER_TEMP\VulkanSDK-Installer.exe" --accept-licenses --default-answer --confirm-command install
  629. Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${env:VULKAN_VERSION}"
  630. Add-Content $env:GITHUB_PATH "C:\VulkanSDK\${env:VULKAN_VERSION}\bin"
  631. - name: Install Ninja
  632. id: install_ninja
  633. run: |
  634. choco install ninja
  635. - name: Build
  636. id: cmake_build
  637. run: |
  638. cmake -S . -B build ${{ matrix.defines }}
  639. cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS}
  640. - name: Add libopenblas.dll
  641. id: add_libopenblas_dll
  642. if: ${{ matrix.build == 'openblas-x64' }}
  643. run: |
  644. cp $env:RUNNER_TEMP/openblas/bin/libopenblas.dll ./build/bin/Release/openblas.dll
  645. cp $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt ./build/bin/Release/OpenBLAS-${env:OPENBLAS_VERSION}.txt
  646. - name: Check AVX512F support
  647. id: check_avx512f
  648. if: ${{ matrix.build == 'avx512-x64' }}
  649. continue-on-error: true
  650. run: |
  651. cd build
  652. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  653. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  654. $cl = $(join-path $msvc 'bin\Hostx64\x64\cl.exe')
  655. echo 'int main(void){unsigned int a[4];__cpuid(a,7);return !(a[1]&65536);}' >> avx512f.c
  656. & $cl /O2 /GS- /kernel avx512f.c /link /nodefaultlib /entry:main
  657. .\avx512f.exe && echo "AVX512F: YES" && ( echo HAS_AVX512F=1 >> $env:GITHUB_ENV ) || echo "AVX512F: NO"
  658. - name: Test
  659. id: cmake_test
  660. # not all machines have native AVX-512
  661. 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') }}
  662. run: |
  663. cd build
  664. ctest -L main -C Release --verbose --timeout 900
  665. - name: Test (Intel SDE)
  666. id: cmake_test_sde
  667. if: ${{ matrix.build == 'avx512-x64' && env.HAS_AVX512F == '0' }} # use Intel SDE for AVX-512 emulation
  668. run: |
  669. curl.exe -o $env:RUNNER_TEMP/sde.tar.xz -L "https://downloadmirror.intel.com/813591/sde-external-${env:SDE_VERSION}-win.tar.xz"
  670. # for some weird reason windows tar doesn't like sde tar.xz
  671. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar.xz
  672. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar
  673. $sde = $(join-path $env:RUNNER_TEMP sde-external-${env:SDE_VERSION}-win/sde.exe)
  674. cd build
  675. & $sde -future -- ctest -L main -C Release --verbose --timeout 900
  676. - name: Determine tag name
  677. id: tag
  678. shell: bash
  679. run: |
  680. BUILD_NUMBER="$(git rev-list --count HEAD)"
  681. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  682. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  683. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  684. else
  685. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  686. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  687. fi
  688. - name: Pack artifacts
  689. id: pack_artifacts
  690. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  691. run: |
  692. Copy-Item LICENSE .\build\bin\Release\llama.cpp.txt
  693. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip .\build\bin\Release\*
  694. - name: Upload artifacts
  695. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  696. uses: actions/upload-artifact@v4
  697. with:
  698. path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip
  699. name: llama-bin-win-${{ matrix.build }}.zip
  700. windows-latest-cmake-cuda:
  701. runs-on: windows-2019
  702. strategy:
  703. matrix:
  704. cuda: ['12.2.0', '11.7.1']
  705. build: ['cuda']
  706. steps:
  707. - name: Clone
  708. id: checkout
  709. uses: actions/checkout@v4
  710. with:
  711. fetch-depth: 0
  712. - name: Install CUDA toolkit
  713. id: cuda-toolkit
  714. uses: Jimver/cuda-toolkit@v0.2.15
  715. with:
  716. cuda: ${{ matrix.cuda }}
  717. method: 'network'
  718. sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]'
  719. - name: Build
  720. id: cmake_build
  721. run: |
  722. mkdir build
  723. cd build
  724. cmake .. -DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_CUDA=ON -DBUILD_SHARED_LIBS=ON
  725. cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS}
  726. - name: Determine tag name
  727. id: tag
  728. shell: bash
  729. run: |
  730. BUILD_NUMBER="$(git rev-list --count HEAD)"
  731. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  732. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  733. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  734. else
  735. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  736. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  737. fi
  738. - name: Pack artifacts
  739. id: pack_artifacts
  740. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  741. run: |
  742. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip .\build\bin\Release\*
  743. - name: Upload artifacts
  744. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  745. uses: actions/upload-artifact@v4
  746. with:
  747. path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip
  748. name: llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  749. - name: Copy and pack Cuda runtime
  750. run: |
  751. echo "Cuda install location: ${{steps.cuda-toolkit.outputs.CUDA_PATH}}"
  752. $dst='.\build\bin\cudart\'
  753. robocopy "${{steps.cuda-toolkit.outputs.CUDA_PATH}}\bin" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
  754. 7z a cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip $dst\*
  755. - name: Upload Cuda runtime
  756. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  757. uses: actions/upload-artifact@v4
  758. with:
  759. path: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  760. name: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  761. windows-latest-cmake-sycl:
  762. runs-on: windows-latest
  763. defaults:
  764. run:
  765. shell: bash
  766. env:
  767. 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
  768. WINDOWS_DPCPP_MKL: intel.oneapi.win.cpp-dpcpp-common:intel.oneapi.win.mkl.devel
  769. ONEAPI_ROOT: "C:/Program Files (x86)/Intel/oneAPI"
  770. steps:
  771. - name: Clone
  772. id: checkout
  773. uses: actions/checkout@v4
  774. with:
  775. fetch-depth: 0
  776. - name: Install
  777. run: scripts/install-oneapi.bat $WINDOWS_BASEKIT_URL $WINDOWS_DPCPP_MKL
  778. - name: Build
  779. id: cmake_build
  780. run: examples/sycl/win-build-sycl.bat
  781. - name: Determine tag name
  782. id: tag
  783. shell: bash
  784. run: |
  785. BUILD_NUMBER="$(git rev-list --count HEAD)"
  786. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  787. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  788. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  789. else
  790. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  791. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  792. fi
  793. - name: Pack artifacts
  794. id: pack_artifacts
  795. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  796. run: |
  797. echo "cp oneAPI running time dll files in ${{ env.ONEAPI_ROOT }} to ./build/bin"
  798. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_sycl_blas.4.dll" ./build/bin
  799. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_core.2.dll" ./build/bin
  800. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_tbb_thread.2.dll" ./build/bin
  801. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/pi_win_proxy_loader.dll" ./build/bin
  802. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/pi_level_zero.dll" ./build/bin
  803. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/sycl7.dll" ./build/bin
  804. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/svml_dispmd.dll" ./build/bin
  805. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/libmmd.dll" ./build/bin
  806. echo "cp oneAPI running time dll files to ./build/bin done"
  807. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip ./build/bin/*
  808. - name: Upload artifacts
  809. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  810. uses: actions/upload-artifact@v4
  811. with:
  812. path: llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip
  813. name: llama-bin-win-sycl-x64.zip
  814. windows-latest-cmake-hip:
  815. runs-on: windows-latest
  816. steps:
  817. - name: Clone
  818. id: checkout
  819. uses: actions/checkout@v3
  820. - name: Install
  821. id: depends
  822. run: |
  823. $ErrorActionPreference = "Stop"
  824. write-host "Downloading AMD HIP SDK Installer"
  825. 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"
  826. write-host "Installing AMD HIP SDK"
  827. Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
  828. write-host "Completed AMD HIP SDK installation"
  829. - name: Verify ROCm
  830. id: verify
  831. run: |
  832. & 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
  833. - name: Build
  834. id: cmake_build
  835. run: |
  836. $env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
  837. $env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
  838. 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" -DLLAMA_HIPBLAS=ON
  839. cmake --build build --config Release
  840. ios-xcode-build:
  841. runs-on: macos-latest
  842. steps:
  843. - name: Checkout code
  844. uses: actions/checkout@v4
  845. - name: Build Xcode project
  846. 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
  847. android-build:
  848. runs-on: ubuntu-latest
  849. steps:
  850. - name: Clone
  851. uses: actions/checkout@v4
  852. - name: Set up JDK
  853. uses: actions/setup-java@v3
  854. with:
  855. java-version: 17
  856. distribution: zulu
  857. - name: Setup Android SDK
  858. uses: android-actions/setup-android@v3
  859. with:
  860. log-accepted-android-sdk-licenses: false
  861. - name: Build
  862. run: |
  863. cd examples/llama.android
  864. ./gradlew build --no-daemon
  865. # freeBSD-latest:
  866. # runs-on: macos-12
  867. # steps:
  868. # - name: Clone
  869. # uses: actions/checkout@v4
  870. #
  871. # - name: Build
  872. # uses: cross-platform-actions/action@v0.19.0
  873. # with:
  874. # operating_system: freebsd
  875. # version: '13.2'
  876. # hypervisor: 'qemu'
  877. # run: |
  878. # sudo pkg update
  879. # sudo pkg install -y gmake automake autoconf pkgconf llvm15 openblas
  880. # gmake CC=/usr/local/bin/clang15 CXX=/usr/local/bin/clang++15 -j `sysctl -n hw.ncpu`
  881. release:
  882. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  883. runs-on: ubuntu-latest
  884. needs:
  885. - ubuntu-focal-make
  886. - ubuntu-latest-cmake
  887. - macOS-latest-make
  888. - macOS-latest-cmake
  889. - windows-latest-cmake
  890. - windows-latest-cmake-cuda
  891. - macOS-latest-cmake-arm64
  892. - macOS-latest-cmake-x64
  893. steps:
  894. - name: Clone
  895. id: checkout
  896. uses: actions/checkout@v4
  897. with:
  898. fetch-depth: 0
  899. - name: Determine tag name
  900. id: tag
  901. shell: bash
  902. run: |
  903. BUILD_NUMBER="$(git rev-list --count HEAD)"
  904. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  905. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  906. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  907. else
  908. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  909. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  910. fi
  911. - name: Download artifacts
  912. id: download-artifact
  913. uses: actions/download-artifact@v4
  914. with:
  915. path: ./artifact
  916. - name: Move artifacts
  917. id: move_artifacts
  918. run: mkdir -p ./artifact/release && mv ./artifact/*/*.zip ./artifact/release
  919. - name: Create release
  920. id: create_release
  921. uses: anzz1/action-create-release@v1
  922. env:
  923. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  924. with:
  925. tag_name: ${{ steps.tag.outputs.name }}
  926. - name: Upload release
  927. id: upload_release
  928. uses: actions/github-script@v3
  929. with:
  930. github-token: ${{secrets.GITHUB_TOKEN}}
  931. script: |
  932. const path = require('path');
  933. const fs = require('fs');
  934. const release_id = '${{ steps.create_release.outputs.id }}';
  935. for (let file of await fs.readdirSync('./artifact/release')) {
  936. if (path.extname(file) === '.zip') {
  937. console.log('uploadReleaseAsset', file);
  938. await github.repos.uploadReleaseAsset({
  939. owner: context.repo.owner,
  940. repo: context.repo.repo,
  941. release_id: release_id,
  942. name: file,
  943. data: await fs.readFileSync(`./artifact/release/${file}`)
  944. });
  945. }
  946. }
  947. # ubuntu-latest-gcc:
  948. # runs-on: ubuntu-latest
  949. #
  950. # strategy:
  951. # matrix:
  952. # build: [Debug, Release]
  953. #
  954. # steps:
  955. # - name: Clone
  956. # uses: actions/checkout@v4
  957. #
  958. # - name: Dependencies
  959. # run: |
  960. # sudo apt-get update
  961. # sudo apt-get install build-essential
  962. # sudo apt-get install cmake
  963. #
  964. # - name: Configure
  965. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  966. #
  967. # - name: Build
  968. # run: |
  969. # make
  970. #
  971. # ubuntu-latest-clang:
  972. # runs-on: ubuntu-latest
  973. #
  974. # strategy:
  975. # matrix:
  976. # build: [Debug, Release]
  977. #
  978. # steps:
  979. # - name: Clone
  980. # uses: actions/checkout@v4
  981. #
  982. # - name: Dependencies
  983. # run: |
  984. # sudo apt-get update
  985. # sudo apt-get install build-essential
  986. # sudo apt-get install cmake
  987. #
  988. # - name: Configure
  989. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
  990. #
  991. # - name: Build
  992. # run: |
  993. # make
  994. #
  995. # ubuntu-latest-gcc-sanitized:
  996. # runs-on: ubuntu-latest
  997. #
  998. # strategy:
  999. # matrix:
  1000. # sanitizer: [ADDRESS, THREAD, UNDEFINED]
  1001. #
  1002. # steps:
  1003. # - name: Clone
  1004. # uses: actions/checkout@v4
  1005. #
  1006. # - name: Dependencies
  1007. # run: |
  1008. # sudo apt-get update
  1009. # sudo apt-get install build-essential
  1010. # sudo apt-get install cmake
  1011. #
  1012. # - name: Configure
  1013. # run: cmake . -DCMAKE_BUILD_TYPE=Debug -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON
  1014. #
  1015. # - name: Build
  1016. # run: |
  1017. # make
  1018. #
  1019. # windows:
  1020. # runs-on: windows-latest
  1021. #
  1022. # strategy:
  1023. # matrix:
  1024. # build: [Release]
  1025. # arch: [Win32, x64]
  1026. # include:
  1027. # - arch: Win32
  1028. # s2arc: x86
  1029. # - arch: x64
  1030. # s2arc: x64
  1031. #
  1032. # steps:
  1033. # - name: Clone
  1034. # uses: actions/checkout@v4
  1035. #
  1036. # - name: Add msbuild to PATH
  1037. # uses: microsoft/setup-msbuild@v1
  1038. #
  1039. # - name: Configure
  1040. # run: >
  1041. # cmake -S . -B ./build -A ${{ matrix.arch }}
  1042. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1043. #
  1044. # - name: Build
  1045. # run: |
  1046. # cd ./build
  1047. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  1048. #
  1049. # - name: Upload binaries
  1050. # uses: actions/upload-artifact@v4
  1051. # with:
  1052. # name: llama-bin-${{ matrix.arch }}
  1053. # path: build/bin/${{ matrix.build }}
  1054. #
  1055. # windows-blas:
  1056. # runs-on: windows-latest
  1057. #
  1058. # strategy:
  1059. # matrix:
  1060. # build: [Release]
  1061. # arch: [Win32, x64]
  1062. # blas: [ON]
  1063. # include:
  1064. # - arch: Win32
  1065. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x86.zip
  1066. # s2arc: x86
  1067. # - arch: x64
  1068. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x64.zip
  1069. # s2arc: x64
  1070. #
  1071. # steps:
  1072. # - name: Clone
  1073. # uses: actions/checkout@v4
  1074. #
  1075. # - name: Add msbuild to PATH
  1076. # uses: microsoft/setup-msbuild@v1
  1077. #
  1078. # - name: Fetch OpenBLAS
  1079. # if: matrix.blas == 'ON'
  1080. # run: |
  1081. # C:/msys64/usr/bin/wget.exe -qO blas.zip ${{ matrix.obzip }}
  1082. # 7z x blas.zip -oblas -y
  1083. # copy blas/include/cblas.h .
  1084. # copy blas/include/openblas_config.h .
  1085. # echo "blasdir=$env:GITHUB_WORKSPACE/blas" >> $env:GITHUB_ENV
  1086. #
  1087. # - name: Configure
  1088. # run: >
  1089. # cmake -S . -B ./build -A ${{ matrix.arch }}
  1090. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1091. # -DLLAMA_SUPPORT_OPENBLAS=${{ matrix.blas }}
  1092. # -DCMAKE_LIBRARY_PATH="$env:blasdir/lib"
  1093. #
  1094. # - name: Build
  1095. # run: |
  1096. # cd ./build
  1097. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  1098. #
  1099. # - name: Copy libopenblas.dll
  1100. # if: matrix.blas == 'ON'
  1101. # run: copy "$env:blasdir/bin/libopenblas.dll" build/bin/${{ matrix.build }}
  1102. #
  1103. # - name: Upload binaries
  1104. # if: matrix.blas == 'ON'
  1105. # uses: actions/upload-artifact@v4
  1106. # with:
  1107. # name: llama-blas-bin-${{ matrix.arch }}
  1108. # path: build/bin/${{ matrix.build }}
  1109. #
  1110. # emscripten:
  1111. # runs-on: ubuntu-latest
  1112. #
  1113. # strategy:
  1114. # matrix:
  1115. # build: [Release]
  1116. #
  1117. # steps:
  1118. # - name: Clone
  1119. # uses: actions/checkout@v4
  1120. #
  1121. # - name: Dependencies
  1122. # run: |
  1123. # wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz
  1124. # tar -xvf master.tar.gz
  1125. # emsdk-master/emsdk update
  1126. # emsdk-master/emsdk install latest
  1127. # emsdk-master/emsdk activate latest
  1128. #
  1129. # - name: Configure
  1130. # run: echo "tmp"
  1131. #
  1132. # - name: Build
  1133. # run: |
  1134. # pushd emsdk-master
  1135. # source ./emsdk_env.sh
  1136. # popd
  1137. # emcmake cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1138. # make