build.yml 43 KB

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