build.yml 35 KB

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