build.yml 30 KB

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