build.yml 29 KB

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