build.yml 46 KB

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