build.yml 30 KB

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