build.yml 30 KB

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