build.yml 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309
  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-x64'
  587. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_RPC=ON -DBUILD_SHARED_LIBS=ON'
  588. - build: 'noavx-x64'
  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-x64'
  591. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DBUILD_SHARED_LIBS=ON'
  592. - build: 'avx-x64'
  593. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_AVX2=OFF -DBUILD_SHARED_LIBS=ON'
  594. - build: 'avx512-x64'
  595. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_AVX512=ON -DBUILD_SHARED_LIBS=ON'
  596. - build: 'clblast-x64'
  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-x64'
  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-x64'
  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-x64'
  603. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_VULKAN=ON -DBUILD_SHARED_LIBS=ON'
  604. - build: 'llvm-arm64'
  605. 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'
  606. - build: 'msvc-arm64'
  607. 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'
  608. steps:
  609. - name: Clone
  610. id: checkout
  611. uses: actions/checkout@v4
  612. with:
  613. fetch-depth: 0
  614. - name: Clone Kompute submodule
  615. id: clone_kompute
  616. if: ${{ matrix.build == 'kompute-x64' }}
  617. run: |
  618. git submodule update --init kompute
  619. - name: Download OpenCL SDK
  620. id: get_opencl
  621. if: ${{ matrix.build == 'clblast-x64' }}
  622. run: |
  623. 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"
  624. mkdir $env:RUNNER_TEMP/opencl
  625. tar.exe -xvf $env:RUNNER_TEMP/opencl.zip --strip-components=1 -C $env:RUNNER_TEMP/opencl
  626. - name: Download CLBlast
  627. id: get_clblast
  628. if: ${{ matrix.build == 'clblast-x64' }}
  629. run: |
  630. 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"
  631. curl.exe -o $env:RUNNER_TEMP/CLBlast.LICENSE.txt -L "https://github.com/CNugteren/CLBlast/raw/${env:CLBLAST_VERSION}/LICENSE"
  632. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/clblast.7z
  633. rename-item $env:RUNNER_TEMP/CLBlast-${env:CLBLAST_VERSION}-windows-x64 clblast
  634. foreach ($f in (gci -Recurse -Path "$env:RUNNER_TEMP/clblast" -Filter '*.cmake')) {
  635. $txt = Get-Content -Path $f -Raw
  636. $txt.Replace('C:/vcpkg/packages/opencl_x64-windows/', "$($env:RUNNER_TEMP.Replace('\','/'))/opencl/") | Set-Content -Path $f -Encoding UTF8
  637. }
  638. - name: Download OpenBLAS
  639. id: get_openblas
  640. if: ${{ matrix.build == 'openblas-x64' }}
  641. run: |
  642. 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"
  643. curl.exe -o $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt -L "https://github.com/xianyi/OpenBLAS/raw/v${env:OPENBLAS_VERSION}/LICENSE"
  644. mkdir $env:RUNNER_TEMP/openblas
  645. tar.exe -xvf $env:RUNNER_TEMP/openblas.zip -C $env:RUNNER_TEMP/openblas
  646. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  647. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  648. $lib = $(join-path $msvc 'bin\Hostx64\x64\lib.exe')
  649. & $lib /machine:x64 "/def:${env:RUNNER_TEMP}/openblas/lib/libopenblas.def" "/out:${env:RUNNER_TEMP}/openblas/lib/openblas.lib" /name:openblas.dll
  650. - name: Install Vulkan SDK
  651. id: get_vulkan
  652. if: ${{ matrix.build == 'kompute-x64' || matrix.build == 'vulkan-x64' }}
  653. run: |
  654. 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"
  655. & "$env:RUNNER_TEMP\VulkanSDK-Installer.exe" --accept-licenses --default-answer --confirm-command install
  656. Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${env:VULKAN_VERSION}"
  657. Add-Content $env:GITHUB_PATH "C:\VulkanSDK\${env:VULKAN_VERSION}\bin"
  658. - name: Install Ninja
  659. id: install_ninja
  660. run: |
  661. choco install ninja
  662. - name: Build
  663. id: cmake_build
  664. run: |
  665. cmake -S . -B build ${{ matrix.defines }}
  666. cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS}
  667. - name: Add clblast.dll
  668. id: add_clblast_dll
  669. if: ${{ matrix.build == 'clblast-x64' }}
  670. run: |
  671. cp $env:RUNNER_TEMP/clblast/lib/clblast.dll ./build/bin/Release
  672. cp $env:RUNNER_TEMP/CLBlast.LICENSE.txt ./build/bin/Release/CLBlast-${env:CLBLAST_VERSION}.txt
  673. - name: Add libopenblas.dll
  674. id: add_libopenblas_dll
  675. if: ${{ matrix.build == 'openblas-x64' }}
  676. run: |
  677. cp $env:RUNNER_TEMP/openblas/bin/libopenblas.dll ./build/bin/Release/openblas.dll
  678. cp $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt ./build/bin/Release/OpenBLAS-${env:OPENBLAS_VERSION}.txt
  679. - name: Check AVX512F support
  680. id: check_avx512f
  681. if: ${{ matrix.build == 'avx512-x64' }}
  682. continue-on-error: true
  683. run: |
  684. cd build
  685. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  686. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  687. $cl = $(join-path $msvc 'bin\Hostx64\x64\cl.exe')
  688. echo 'int main(void){unsigned int a[4];__cpuid(a,7);return !(a[1]&65536);}' >> avx512f.c
  689. & $cl /O2 /GS- /kernel avx512f.c /link /nodefaultlib /entry:main
  690. .\avx512f.exe && echo "AVX512F: YES" && ( echo HAS_AVX512F=1 >> $env:GITHUB_ENV ) || echo "AVX512F: NO"
  691. - name: Test
  692. id: cmake_test
  693. # not all machines have native AVX-512
  694. if: ${{ matrix.build != 'msvc-arm64' && matrix.build != 'llvm-arm64' && matrix.build != 'clblast-x64' && matrix.build != 'kompute-x64' && matrix.build != 'vulkan-x64' && (matrix.build != 'avx512-x64' || env.HAS_AVX512F == '1') }}
  695. run: |
  696. cd build
  697. ctest -L main -C Release --verbose --timeout 900
  698. - name: Test (Intel SDE)
  699. id: cmake_test_sde
  700. if: ${{ matrix.build == 'avx512-x64' && env.HAS_AVX512F == '0' }} # use Intel SDE for AVX-512 emulation
  701. run: |
  702. curl.exe -o $env:RUNNER_TEMP/sde.tar.xz -L "https://downloadmirror.intel.com/813591/sde-external-${env:SDE_VERSION}-win.tar.xz"
  703. # for some weird reason windows tar doesn't like sde tar.xz
  704. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar.xz
  705. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar
  706. $sde = $(join-path $env:RUNNER_TEMP sde-external-${env:SDE_VERSION}-win/sde.exe)
  707. cd build
  708. & $sde -future -- ctest -L main -C Release --verbose --timeout 900
  709. - name: Determine tag name
  710. id: tag
  711. shell: bash
  712. run: |
  713. BUILD_NUMBER="$(git rev-list --count HEAD)"
  714. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  715. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  716. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  717. else
  718. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  719. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  720. fi
  721. - name: Pack artifacts
  722. id: pack_artifacts
  723. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  724. run: |
  725. Copy-Item LICENSE .\build\bin\Release\llama.cpp.txt
  726. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip .\build\bin\Release\*
  727. - name: Upload artifacts
  728. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  729. uses: actions/upload-artifact@v4
  730. with:
  731. path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip
  732. name: llama-bin-win-${{ matrix.build }}.zip
  733. windows-latest-cmake-cuda:
  734. runs-on: windows-latest
  735. strategy:
  736. matrix:
  737. cuda: ['12.2.0', '11.7.1']
  738. build: ['cuda']
  739. steps:
  740. - name: Clone
  741. id: checkout
  742. uses: actions/checkout@v4
  743. with:
  744. fetch-depth: 0
  745. - uses: Jimver/cuda-toolkit@v0.2.11
  746. id: cuda-toolkit
  747. with:
  748. cuda: ${{ matrix.cuda }}
  749. method: 'network'
  750. sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]'
  751. - name: Build
  752. id: cmake_build
  753. run: |
  754. mkdir build
  755. cd build
  756. cmake .. -DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_CUDA=ON -DBUILD_SHARED_LIBS=ON
  757. cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS}
  758. - name: Determine tag name
  759. id: tag
  760. shell: bash
  761. run: |
  762. BUILD_NUMBER="$(git rev-list --count HEAD)"
  763. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  764. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  765. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  766. else
  767. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  768. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  769. fi
  770. - name: Pack artifacts
  771. id: pack_artifacts
  772. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  773. run: |
  774. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip .\build\bin\Release\*
  775. - name: Upload artifacts
  776. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  777. uses: actions/upload-artifact@v4
  778. with:
  779. path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip
  780. name: llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  781. - name: Copy and pack Cuda runtime
  782. run: |
  783. echo "Cuda install location: ${{steps.cuda-toolkit.outputs.CUDA_PATH}}"
  784. $dst='.\build\bin\cudart\'
  785. robocopy "${{steps.cuda-toolkit.outputs.CUDA_PATH}}\bin" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
  786. 7z a cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip $dst\*
  787. - name: Upload Cuda runtime
  788. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  789. uses: actions/upload-artifact@v4
  790. with:
  791. path: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  792. name: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  793. windows-latest-cmake-sycl:
  794. runs-on: windows-latest
  795. defaults:
  796. run:
  797. shell: bash
  798. env:
  799. 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
  800. WINDOWS_DPCPP_MKL: intel.oneapi.win.cpp-dpcpp-common:intel.oneapi.win.mkl.devel
  801. ONEAPI_ROOT: "C:/Program Files (x86)/Intel/oneAPI"
  802. steps:
  803. - name: Clone
  804. id: checkout
  805. uses: actions/checkout@v4
  806. with:
  807. fetch-depth: 0
  808. - name: Install
  809. run: scripts/install-oneapi.bat $WINDOWS_BASEKIT_URL $WINDOWS_DPCPP_MKL
  810. - name: Build
  811. id: cmake_build
  812. run: examples/sycl/win-build-sycl.bat
  813. - name: Determine tag name
  814. id: tag
  815. shell: bash
  816. run: |
  817. BUILD_NUMBER="$(git rev-list --count HEAD)"
  818. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  819. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  820. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  821. else
  822. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  823. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  824. fi
  825. - name: Pack artifacts
  826. id: pack_artifacts
  827. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  828. run: |
  829. echo "cp oneAPI running time dll files in ${{ env.ONEAPI_ROOT }} to ./build/bin"
  830. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_sycl_blas.4.dll" ./build/bin
  831. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_core.2.dll" ./build/bin
  832. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_tbb_thread.2.dll" ./build/bin
  833. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/pi_win_proxy_loader.dll" ./build/bin
  834. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/pi_level_zero.dll" ./build/bin
  835. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/sycl7.dll" ./build/bin
  836. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/svml_dispmd.dll" ./build/bin
  837. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/libmmd.dll" ./build/bin
  838. echo "cp oneAPI running time dll files to ./build/bin done"
  839. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip ./build/bin/*
  840. - name: Upload artifacts
  841. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  842. uses: actions/upload-artifact@v4
  843. with:
  844. path: llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip
  845. name: llama-bin-win-sycl-x64.zip
  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 clinfo clover opencl clblast 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