build.yml 35 KB

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