build.yml 43 KB

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