build.yml 44 KB

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