build.yml 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312
  1. name: CI
  2. on:
  3. workflow_dispatch: # allows manual triggering
  4. inputs:
  5. create_release:
  6. description: 'Create new release'
  7. required: true
  8. type: boolean
  9. push:
  10. branches:
  11. - master
  12. paths: ['.github/workflows/build.yml', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cuh', '**/*.swift', '**/*.m', '**/*.metal']
  13. pull_request:
  14. types: [opened, synchronize, reopened]
  15. paths: ['.github/workflows/build.yml', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cuh', '**/*.swift', '**/*.m', '**/*.metal']
  16. concurrency:
  17. group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
  18. cancel-in-progress: true
  19. env:
  20. BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
  21. GGML_NLOOP: 3
  22. GGML_N_THREADS: 1
  23. jobs:
  24. macOS-latest-cmake-arm64:
  25. runs-on: macos-14
  26. steps:
  27. - name: Clone
  28. id: checkout
  29. uses: actions/checkout@v4
  30. with:
  31. fetch-depth: 0
  32. - name: Dependencies
  33. id: depends
  34. continue-on-error: true
  35. run: |
  36. brew update
  37. - name: Build
  38. id: cmake_build
  39. run: |
  40. sysctl -a
  41. mkdir build
  42. cd build
  43. cmake -DLLAMA_FATAL_WARNINGS=ON -DGGML_METAL_EMBED_LIBRARY=ON -DLLAMA_CURL=ON ..
  44. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu)
  45. - name: Test
  46. id: cmake_test
  47. run: |
  48. cd build
  49. ctest -L 'main|curl' --verbose --timeout 900
  50. - name: Determine tag name
  51. id: tag
  52. shell: bash
  53. run: |
  54. BUILD_NUMBER="$(git rev-list --count HEAD)"
  55. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  56. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  57. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  58. else
  59. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  60. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  61. fi
  62. - name: Pack artifacts
  63. id: pack_artifacts
  64. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  65. run: |
  66. cp LICENSE ./build/bin/
  67. zip -r llama-${{ steps.tag.outputs.name }}-bin-macos-arm64.zip ./build/bin/*
  68. - name: Upload artifacts
  69. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  70. uses: actions/upload-artifact@v4
  71. with:
  72. path: llama-${{ steps.tag.outputs.name }}-bin-macos-arm64.zip
  73. name: llama-bin-macos-arm64.zip
  74. macOS-latest-cmake-x64:
  75. runs-on: macos-12
  76. steps:
  77. - name: Clone
  78. id: checkout
  79. uses: actions/checkout@v4
  80. with:
  81. fetch-depth: 0
  82. - name: Dependencies
  83. id: depends
  84. continue-on-error: true
  85. run: |
  86. brew update
  87. - name: Build
  88. id: cmake_build
  89. run: |
  90. sysctl -a
  91. # Metal is disabled due to intermittent failures with Github runners not having a GPU:
  92. # https://github.com/ggerganov/llama.cpp/actions/runs/8635935781/job/23674807267#step:5:2313
  93. cmake -B build -DLLAMA_FATAL_WARNINGS=ON -DGGML_METAL=OFF -DLLAMA_CURL=ON
  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 }} -DGGML_OPENMP=OFF
  263. cmake --build . --config ${{ matrix.build_type }} -j $(nproc)
  264. - name: Test
  265. id: cmake_test
  266. run: |
  267. cd build
  268. ctest -L main --verbose --timeout 900
  269. ubuntu-latest-cmake-rpc:
  270. runs-on: ubuntu-latest
  271. continue-on-error: true
  272. steps:
  273. - name: Clone
  274. id: checkout
  275. uses: actions/checkout@v4
  276. - name: Dependencies
  277. id: depends
  278. run: |
  279. sudo apt-get update
  280. sudo apt-get install build-essential
  281. - name: Build
  282. id: cmake_build
  283. run: |
  284. mkdir build
  285. cd build
  286. cmake -DGGML_RPC=ON ..
  287. cmake --build . --config Release -j $(nproc)
  288. - name: Test
  289. id: cmake_test
  290. run: |
  291. cd build
  292. ctest -L main --verbose
  293. ubuntu-22-cmake-vulkan:
  294. runs-on: ubuntu-22.04
  295. steps:
  296. - name: Clone
  297. id: checkout
  298. uses: actions/checkout@v4
  299. - name: Dependencies
  300. id: depends
  301. run: |
  302. 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 -DGGML_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" -DGGML_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 -DGGML_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 -DGGML_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 -DGGML_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DGGML_SYCL_F16=ON ..
  398. cmake --build . --config Release -j $(nproc)
  399. # TODO: build with GGML_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. GGML_NO_METAL=1 make -j $(sysctl -n hw.logicalcpu)
  419. - name: Test
  420. id: make_test
  421. run: |
  422. GGML_NO_METAL=1 make tests -j $(sysctl -n hw.logicalcpu)
  423. GGML_NO_METAL=1 make test -j $(sysctl -n hw.logicalcpu)
  424. # TODO: build with GGML_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 -DGGML_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. -DGGML_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. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  477. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  478. macOS-latest-cmake-tvos:
  479. runs-on: macos-latest
  480. steps:
  481. - name: Clone
  482. id: checkout
  483. uses: actions/checkout@v1
  484. - name: Dependencies
  485. id: depends
  486. continue-on-error: true
  487. run: |
  488. brew update
  489. - name: Build
  490. id: cmake_build
  491. run: |
  492. sysctl -a
  493. mkdir build
  494. cd build
  495. cmake -G Xcode .. \
  496. -DGGML_METAL_EMBED_LIBRARY=ON \
  497. -DLLAMA_BUILD_EXAMPLES=OFF \
  498. -DLLAMA_BUILD_TESTS=OFF \
  499. -DLLAMA_BUILD_SERVER=OFF \
  500. -DCMAKE_SYSTEM_NAME=tvOS \
  501. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
  502. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  503. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  504. macOS-latest-swift:
  505. runs-on: macos-latest
  506. strategy:
  507. matrix:
  508. destination: ['generic/platform=macOS', 'generic/platform=iOS', 'generic/platform=tvOS']
  509. steps:
  510. - name: Clone
  511. id: checkout
  512. uses: actions/checkout@v1
  513. - name: Dependencies
  514. id: depends
  515. continue-on-error: true
  516. run: |
  517. brew update
  518. - name: xcodebuild for swift package
  519. id: xcodebuild
  520. run: |
  521. xcodebuild -scheme llama -destination "${{ matrix.destination }}"
  522. - name: Build Swift Example
  523. id: make_build_swift_example
  524. run: |
  525. make swift
  526. windows-msys2:
  527. runs-on: windows-latest
  528. strategy:
  529. fail-fast: false
  530. matrix:
  531. include:
  532. - { sys: UCRT64, env: ucrt-x86_64, build: Release }
  533. - { sys: CLANG64, env: clang-x86_64, build: Release }
  534. steps:
  535. - name: Clone
  536. uses: actions/checkout@v4
  537. - name: Setup ${{ matrix.sys }}
  538. uses: msys2/setup-msys2@v2
  539. with:
  540. update: true
  541. msystem: ${{matrix.sys}}
  542. install: >-
  543. base-devel
  544. mingw-w64-${{matrix.env}}-toolchain
  545. mingw-w64-${{matrix.env}}-cmake
  546. mingw-w64-${{matrix.env}}-openblas
  547. - name: Build using make
  548. shell: msys2 {0}
  549. run: |
  550. make -j $(nproc)
  551. - name: Clean after building using make
  552. shell: msys2 {0}
  553. run: |
  554. make clean
  555. - name: Build using make w/ OpenBLAS
  556. shell: msys2 {0}
  557. run: |
  558. make GGML_OPENBLAS=1 -j $(nproc)
  559. - name: Build using CMake
  560. shell: msys2 {0}
  561. run: |
  562. cmake -B build
  563. cmake --build build --config ${{ matrix.build }} -j $(nproc)
  564. - name: Clean after building using CMake
  565. shell: msys2 {0}
  566. run: |
  567. rm -rf build
  568. - name: Build using CMake w/ OpenBLAS
  569. shell: msys2 {0}
  570. run: |
  571. cmake -B build -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS
  572. cmake --build build --config ${{ matrix.build }} -j $(nproc)
  573. windows-latest-cmake:
  574. runs-on: windows-2019
  575. env:
  576. OPENBLAS_VERSION: 0.3.23
  577. SDE_VERSION: 9.33.0-2024-01-07
  578. VULKAN_VERSION: 1.3.261.1
  579. strategy:
  580. matrix:
  581. include:
  582. - build: 'rpc-x64'
  583. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DBUILD_SHARED_LIBS=ON'
  584. - build: 'noavx-x64'
  585. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_FMA=OFF -DBUILD_SHARED_LIBS=ON'
  586. - build: 'avx2-x64'
  587. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DBUILD_SHARED_LIBS=ON'
  588. - build: 'avx-x64'
  589. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_AVX2=OFF -DBUILD_SHARED_LIBS=ON'
  590. - build: 'avx512-x64'
  591. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_AVX512=ON -DBUILD_SHARED_LIBS=ON'
  592. - build: 'openblas-x64'
  593. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_BLAS=ON -DBUILD_SHARED_LIBS=ON -DGGML_BLAS_VENDOR=OpenBLAS -DBLAS_INCLUDE_DIRS="$env:RUNNER_TEMP/openblas/include" -DBLAS_LIBRARIES="$env:RUNNER_TEMP/openblas/lib/openblas.lib"'
  594. - build: 'kompute-x64'
  595. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_KOMPUTE=ON -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON -DBUILD_SHARED_LIBS=ON'
  596. - build: 'vulkan-x64'
  597. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_VULKAN=ON -DBUILD_SHARED_LIBS=ON'
  598. - build: 'llvm-arm64'
  599. defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-llvm.cmake -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DBUILD_SHARED_LIBS=ON'
  600. - build: 'msvc-arm64'
  601. defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-msvc.cmake -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DBUILD_SHARED_LIBS=ON'
  602. steps:
  603. - name: Clone
  604. id: checkout
  605. uses: actions/checkout@v4
  606. with:
  607. fetch-depth: 0
  608. - name: Clone Kompute submodule
  609. id: clone_kompute
  610. if: ${{ matrix.build == 'kompute-x64' }}
  611. run: |
  612. git submodule update --init ggml/src/kompute
  613. - name: Download OpenBLAS
  614. id: get_openblas
  615. if: ${{ matrix.build == 'openblas-x64' }}
  616. run: |
  617. 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"
  618. curl.exe -o $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt -L "https://github.com/xianyi/OpenBLAS/raw/v${env:OPENBLAS_VERSION}/LICENSE"
  619. mkdir $env:RUNNER_TEMP/openblas
  620. tar.exe -xvf $env:RUNNER_TEMP/openblas.zip -C $env:RUNNER_TEMP/openblas
  621. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  622. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  623. $lib = $(join-path $msvc 'bin\Hostx64\x64\lib.exe')
  624. & $lib /machine:x64 "/def:${env:RUNNER_TEMP}/openblas/lib/libopenblas.def" "/out:${env:RUNNER_TEMP}/openblas/lib/openblas.lib" /name:openblas.dll
  625. - name: Install Vulkan SDK
  626. id: get_vulkan
  627. if: ${{ matrix.build == 'kompute-x64' || matrix.build == 'vulkan-x64' }}
  628. run: |
  629. 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"
  630. & "$env:RUNNER_TEMP\VulkanSDK-Installer.exe" --accept-licenses --default-answer --confirm-command install
  631. Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${env:VULKAN_VERSION}"
  632. Add-Content $env:GITHUB_PATH "C:\VulkanSDK\${env:VULKAN_VERSION}\bin"
  633. - name: Install Ninja
  634. id: install_ninja
  635. run: |
  636. choco install ninja
  637. - name: Build
  638. id: cmake_build
  639. run: |
  640. cmake -S . -B build ${{ matrix.defines }}
  641. cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS}
  642. - name: Add libopenblas.dll
  643. id: add_libopenblas_dll
  644. if: ${{ matrix.build == 'openblas-x64' }}
  645. run: |
  646. cp $env:RUNNER_TEMP/openblas/bin/libopenblas.dll ./build/bin/Release/openblas.dll
  647. cp $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt ./build/bin/Release/OpenBLAS-${env:OPENBLAS_VERSION}.txt
  648. - name: Check AVX512F support
  649. id: check_avx512f
  650. if: ${{ matrix.build == 'avx512-x64' }}
  651. continue-on-error: true
  652. run: |
  653. cd build
  654. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  655. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  656. $cl = $(join-path $msvc 'bin\Hostx64\x64\cl.exe')
  657. echo 'int main(void){unsigned int a[4];__cpuid(a,7);return !(a[1]&65536);}' >> avx512f.c
  658. & $cl /O2 /GS- /kernel avx512f.c /link /nodefaultlib /entry:main
  659. .\avx512f.exe && echo "AVX512F: YES" && ( echo HAS_AVX512F=1 >> $env:GITHUB_ENV ) || echo "AVX512F: NO"
  660. - name: Test
  661. id: cmake_test
  662. # not all machines have native AVX-512
  663. 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') }}
  664. run: |
  665. cd build
  666. ctest -L main -C Release --verbose --timeout 900
  667. - name: Test (Intel SDE)
  668. id: cmake_test_sde
  669. if: ${{ matrix.build == 'avx512-x64' && env.HAS_AVX512F == '0' }} # use Intel SDE for AVX-512 emulation
  670. run: |
  671. curl.exe -o $env:RUNNER_TEMP/sde.tar.xz -L "https://downloadmirror.intel.com/813591/sde-external-${env:SDE_VERSION}-win.tar.xz"
  672. # for some weird reason windows tar doesn't like sde tar.xz
  673. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar.xz
  674. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar
  675. $sde = $(join-path $env:RUNNER_TEMP sde-external-${env:SDE_VERSION}-win/sde.exe)
  676. cd build
  677. & $sde -future -- ctest -L main -C Release --verbose --timeout 900
  678. - name: Determine tag name
  679. id: tag
  680. shell: bash
  681. run: |
  682. BUILD_NUMBER="$(git rev-list --count HEAD)"
  683. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  684. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  685. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  686. else
  687. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  688. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  689. fi
  690. - name: Pack artifacts
  691. id: pack_artifacts
  692. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  693. run: |
  694. Copy-Item LICENSE .\build\bin\Release\llama.cpp.txt
  695. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip .\build\bin\Release\*
  696. - name: Upload artifacts
  697. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  698. uses: actions/upload-artifact@v4
  699. with:
  700. path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip
  701. name: llama-bin-win-${{ matrix.build }}.zip
  702. windows-latest-cmake-cuda:
  703. runs-on: windows-2019
  704. strategy:
  705. matrix:
  706. cuda: ['12.2.0', '11.7.1']
  707. build: ['cuda']
  708. steps:
  709. - name: Clone
  710. id: checkout
  711. uses: actions/checkout@v4
  712. with:
  713. fetch-depth: 0
  714. - name: Install CUDA toolkit
  715. id: cuda-toolkit
  716. uses: Jimver/cuda-toolkit@v0.2.15
  717. with:
  718. cuda: ${{ matrix.cuda }}
  719. method: 'network'
  720. sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]'
  721. - name: Build
  722. id: cmake_build
  723. run: |
  724. mkdir build
  725. cd build
  726. cmake .. -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_CUDA=ON -DBUILD_SHARED_LIBS=ON
  727. cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS}
  728. - name: Determine tag name
  729. id: tag
  730. shell: bash
  731. run: |
  732. BUILD_NUMBER="$(git rev-list --count HEAD)"
  733. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  734. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  735. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  736. else
  737. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  738. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  739. fi
  740. - name: Pack artifacts
  741. id: pack_artifacts
  742. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  743. run: |
  744. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip .\build\bin\Release\*
  745. - name: Upload artifacts
  746. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  747. uses: actions/upload-artifact@v4
  748. with:
  749. path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip
  750. name: llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  751. - name: Copy and pack Cuda runtime
  752. run: |
  753. echo "Cuda install location: ${{steps.cuda-toolkit.outputs.CUDA_PATH}}"
  754. $dst='.\build\bin\cudart\'
  755. robocopy "${{steps.cuda-toolkit.outputs.CUDA_PATH}}\bin" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
  756. 7z a cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip $dst\*
  757. - name: Upload Cuda runtime
  758. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  759. uses: actions/upload-artifact@v4
  760. with:
  761. path: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  762. name: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  763. windows-latest-cmake-sycl:
  764. runs-on: windows-latest
  765. defaults:
  766. run:
  767. shell: bash
  768. env:
  769. 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
  770. WINDOWS_DPCPP_MKL: intel.oneapi.win.cpp-dpcpp-common:intel.oneapi.win.mkl.devel
  771. ONEAPI_ROOT: "C:/Program Files (x86)/Intel/oneAPI"
  772. steps:
  773. - name: Clone
  774. id: checkout
  775. uses: actions/checkout@v4
  776. with:
  777. fetch-depth: 0
  778. - name: Install
  779. run: scripts/install-oneapi.bat $WINDOWS_BASEKIT_URL $WINDOWS_DPCPP_MKL
  780. - name: Build
  781. id: cmake_build
  782. run: examples/sycl/win-build-sycl.bat
  783. - name: Determine tag name
  784. id: tag
  785. shell: bash
  786. run: |
  787. BUILD_NUMBER="$(git rev-list --count HEAD)"
  788. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  789. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  790. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  791. else
  792. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  793. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  794. fi
  795. - name: Pack artifacts
  796. id: pack_artifacts
  797. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  798. run: |
  799. echo "cp oneAPI running time dll files in ${{ env.ONEAPI_ROOT }} to ./build/bin"
  800. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_sycl_blas.4.dll" ./build/bin
  801. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_core.2.dll" ./build/bin
  802. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_tbb_thread.2.dll" ./build/bin
  803. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/pi_win_proxy_loader.dll" ./build/bin
  804. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/pi_level_zero.dll" ./build/bin
  805. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/sycl7.dll" ./build/bin
  806. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/svml_dispmd.dll" ./build/bin
  807. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/libmmd.dll" ./build/bin
  808. echo "cp oneAPI running time dll files to ./build/bin done"
  809. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip ./build/bin/*
  810. - name: Upload artifacts
  811. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  812. uses: actions/upload-artifact@v4
  813. with:
  814. path: llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip
  815. name: llama-bin-win-sycl-x64.zip
  816. windows-latest-cmake-hip:
  817. runs-on: windows-latest
  818. steps:
  819. - name: Clone
  820. id: checkout
  821. uses: actions/checkout@v3
  822. - name: Install
  823. id: depends
  824. run: |
  825. $ErrorActionPreference = "Stop"
  826. write-host "Downloading AMD HIP SDK Installer"
  827. 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"
  828. write-host "Installing AMD HIP SDK"
  829. Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
  830. write-host "Completed AMD HIP SDK installation"
  831. - name: Verify ROCm
  832. id: verify
  833. run: |
  834. & 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
  835. - name: Build
  836. id: cmake_build
  837. run: |
  838. $env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
  839. $env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
  840. cmake -G "Unix Makefiles" -B build -S . -DCMAKE_C_COMPILER="${env:HIP_PATH}\bin\clang.exe" -DCMAKE_CXX_COMPILER="${env:HIP_PATH}\bin\clang++.exe" -DGGML_HIPBLAS=ON
  841. cmake --build build --config Release
  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 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