build.yml 34 KB

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