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