build.yml 35 KB

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