build.yml 42 KB

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