build.yml 31 KB

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