build.yml 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673
  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', '**/*.comp']
  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', '**/*.comp']
  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: ccache
  40. uses: hendrikmuhs/ccache-action@v1.2.16
  41. with:
  42. key: macOS-latest-cmake-arm64
  43. evict-old-files: 1d
  44. - name: Dependencies
  45. id: depends
  46. continue-on-error: true
  47. run: |
  48. brew update
  49. - name: Build
  50. id: cmake_build
  51. run: |
  52. sysctl -a
  53. cmake -B build \
  54. -DCMAKE_BUILD_RPATH="@loader_path" \
  55. -DLLAMA_FATAL_WARNINGS=ON \
  56. -DLLAMA_CURL=ON \
  57. -DGGML_METAL_USE_BF16=ON \
  58. -DGGML_METAL_EMBED_LIBRARY=ON \
  59. -DGGML_RPC=ON
  60. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
  61. - name: Test
  62. id: cmake_test
  63. run: |
  64. cd build
  65. ctest -L 'main|curl' --verbose --timeout 900
  66. - name: Determine tag name
  67. id: tag
  68. shell: bash
  69. run: |
  70. BUILD_NUMBER="$(git rev-list --count HEAD)"
  71. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  72. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  73. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  74. else
  75. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  76. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  77. fi
  78. - name: Pack artifacts
  79. id: pack_artifacts
  80. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  81. run: |
  82. cp LICENSE ./build/bin/
  83. cp examples/run/linenoise.cpp/LICENSE ./build/bin/LICENSE.linenoise.cpp
  84. zip -r llama-${{ steps.tag.outputs.name }}-bin-macos-arm64.zip ./build/bin/*
  85. - name: Upload artifacts
  86. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  87. uses: actions/upload-artifact@v4
  88. with:
  89. path: llama-${{ steps.tag.outputs.name }}-bin-macos-arm64.zip
  90. name: llama-bin-macos-arm64.zip
  91. macOS-latest-cmake-x64:
  92. runs-on: macos-13
  93. steps:
  94. - name: Clone
  95. id: checkout
  96. uses: actions/checkout@v4
  97. with:
  98. fetch-depth: 0
  99. - name: ccache
  100. uses: hendrikmuhs/ccache-action@v1.2.16
  101. with:
  102. key: macOS-latest-cmake-x64
  103. evict-old-files: 1d
  104. - name: Dependencies
  105. id: depends
  106. continue-on-error: true
  107. run: |
  108. brew update
  109. - name: Build
  110. id: cmake_build
  111. run: |
  112. sysctl -a
  113. # Metal is disabled due to intermittent failures with Github runners not having a GPU:
  114. # https://github.com/ggml-org/llama.cpp/actions/runs/8635935781/job/23674807267#step:5:2313
  115. cmake -B build \
  116. -DCMAKE_BUILD_RPATH="@loader_path" \
  117. -DLLAMA_FATAL_WARNINGS=ON \
  118. -DLLAMA_CURL=ON \
  119. -DGGML_METAL=OFF \
  120. -DGGML_RPC=ON
  121. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
  122. - name: Test
  123. id: cmake_test
  124. run: |
  125. cd build
  126. ctest -L main --verbose --timeout 900
  127. - name: Determine tag name
  128. id: tag
  129. shell: bash
  130. run: |
  131. BUILD_NUMBER="$(git rev-list --count HEAD)"
  132. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  133. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  134. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  135. else
  136. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  137. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  138. fi
  139. - name: Pack artifacts
  140. id: pack_artifacts
  141. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  142. run: |
  143. cp LICENSE ./build/bin/
  144. cp examples/run/linenoise.cpp/LICENSE ./build/bin/LICENSE.linenoise.cpp
  145. zip -r llama-${{ steps.tag.outputs.name }}-bin-macos-x64.zip ./build/bin/*
  146. - name: Upload artifacts
  147. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  148. uses: actions/upload-artifact@v4
  149. with:
  150. path: llama-${{ steps.tag.outputs.name }}-bin-macos-x64.zip
  151. name: llama-bin-macos-x64.zip
  152. ubuntu-cpu-cmake:
  153. runs-on: ubuntu-22.04
  154. steps:
  155. - name: Clone
  156. id: checkout
  157. uses: actions/checkout@v4
  158. with:
  159. fetch-depth: 0
  160. - name: ccache
  161. uses: hendrikmuhs/ccache-action@v1.2.16
  162. with:
  163. key: ubuntu-cpu-cmake
  164. evict-old-files: 1d
  165. - name: Dependencies
  166. id: depends
  167. run: |
  168. sudo apt-get update
  169. sudo apt-get install build-essential libcurl4-openssl-dev
  170. - name: Build
  171. id: cmake_build
  172. run: |
  173. cmake -B build \
  174. -DLLAMA_FATAL_WARNINGS=ON \
  175. -DLLAMA_CURL=ON \
  176. -DGGML_RPC=ON
  177. cmake --build build --config Release -j $(nproc)
  178. - name: Test
  179. id: cmake_test
  180. run: |
  181. cd build
  182. ctest -L 'main|curl' --verbose --timeout 900
  183. - name: Test llama2c conversion
  184. id: llama2c_test
  185. run: |
  186. cd build
  187. echo "Fetch tokenizer"
  188. wget https://huggingface.co/karpathy/tinyllamas/resolve/main/stories260K/tok512.bin
  189. echo "Fetch llama2c model"
  190. wget https://huggingface.co/karpathy/tinyllamas/resolve/main/stories260K/stories260K.bin
  191. ./bin/llama-convert-llama2c-to-ggml --copy-vocab-from-model ./tok512.bin --llama2c-model stories260K.bin --llama2c-output-model stories260K.gguf
  192. ./bin/llama-cli -m stories260K.gguf -p "One day, Lily met a Shoggoth" -n 500 -c 256
  193. - name: Determine tag name
  194. id: tag
  195. shell: bash
  196. run: |
  197. BUILD_NUMBER="$(git rev-list --count HEAD)"
  198. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  199. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  200. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  201. else
  202. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  203. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  204. fi
  205. - name: Pack artifacts
  206. id: pack_artifacts
  207. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  208. run: |
  209. cp LICENSE ./build/bin/
  210. cp examples/run/linenoise.cpp/LICENSE ./build/bin/LICENSE.linenoise.cpp
  211. zip -r llama-${{ steps.tag.outputs.name }}-bin-ubuntu-x64.zip ./build/bin/*
  212. - name: Upload artifacts
  213. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  214. uses: actions/upload-artifact@v4
  215. with:
  216. path: llama-${{ steps.tag.outputs.name }}-bin-ubuntu-x64.zip
  217. name: llama-bin-ubuntu-x64.zip
  218. ubuntu-latest-cmake-sanitizer:
  219. runs-on: ubuntu-latest
  220. continue-on-error: true
  221. strategy:
  222. matrix:
  223. sanitizer: [ADDRESS, THREAD, UNDEFINED]
  224. build_type: [Debug]
  225. steps:
  226. - name: Clone
  227. id: checkout
  228. uses: actions/checkout@v4
  229. - name: ccache
  230. uses: hendrikmuhs/ccache-action@v1.2.16
  231. with:
  232. key: ubuntu-latest-cmake-sanitizer-${{ matrix.sanitizer }}
  233. evict-old-files: 1d
  234. - name: Dependencies
  235. id: depends
  236. run: |
  237. sudo apt-get update
  238. sudo apt-get install build-essential
  239. - name: Build
  240. id: cmake_build
  241. if: ${{ matrix.sanitizer != 'THREAD' }}
  242. run: |
  243. cmake -B build \
  244. -DLLAMA_FATAL_WARNINGS=ON \
  245. -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON \
  246. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
  247. cmake --build build --config ${{ matrix.build_type }} -j $(nproc)
  248. - name: Build (no OpenMP)
  249. id: cmake_build_no_openmp
  250. if: ${{ matrix.sanitizer == 'THREAD' }}
  251. run: |
  252. cmake -B build \
  253. -DLLAMA_FATAL_WARNINGS=ON \
  254. -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON \
  255. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
  256. -DGGML_OPENMP=OFF
  257. cmake --build build --config ${{ matrix.build_type }} -j $(nproc)
  258. - name: Test
  259. id: cmake_test
  260. run: |
  261. cd build
  262. ctest -L main --verbose --timeout 900
  263. ubuntu-latest-llguidance:
  264. runs-on: ubuntu-latest
  265. steps:
  266. - name: Clone
  267. id: checkout
  268. uses: actions/checkout@v4
  269. - name: Dependencies
  270. id: depends
  271. run: |
  272. sudo apt-get update
  273. sudo apt-get install build-essential
  274. - name: Build
  275. id: cmake_build
  276. run: |
  277. mkdir build
  278. cd build
  279. cmake .. \
  280. -DLLAMA_FATAL_WARNINGS=ON \
  281. -DLLAMA_LLGUIDANCE=ON
  282. cmake --build . --config Release -j $(nproc)
  283. - name: Test
  284. id: cmake_test
  285. run: |
  286. cd build
  287. ctest -L main --verbose --timeout 900
  288. ubuntu-latest-cmake-rpc:
  289. runs-on: ubuntu-latest
  290. continue-on-error: true
  291. steps:
  292. - name: Clone
  293. id: checkout
  294. uses: actions/checkout@v4
  295. - name: ccache
  296. uses: hendrikmuhs/ccache-action@v1.2.16
  297. with:
  298. key: ubuntu-latest-cmake-rpc
  299. evict-old-files: 1d
  300. - name: Dependencies
  301. id: depends
  302. run: |
  303. sudo apt-get update
  304. sudo apt-get install build-essential
  305. - name: Build
  306. id: cmake_build
  307. run: |
  308. cmake -B build \
  309. -DGGML_RPC=ON
  310. cmake --build build --config Release -j $(nproc)
  311. - name: Test
  312. id: cmake_test
  313. run: |
  314. cd build
  315. ctest -L main --verbose
  316. ubuntu-22-cmake-vulkan:
  317. runs-on: ubuntu-22.04
  318. steps:
  319. - name: Clone
  320. id: checkout
  321. uses: actions/checkout@v4
  322. - name: ccache
  323. uses: hendrikmuhs/ccache-action@v1.2.16
  324. with:
  325. key: ubuntu-22-cmake-vulkan
  326. evict-old-files: 1d
  327. - name: Dependencies
  328. id: depends
  329. run: |
  330. wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add -
  331. sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
  332. sudo apt-get update -y
  333. sudo apt-get install -y build-essential mesa-vulkan-drivers vulkan-sdk
  334. - name: Build
  335. id: cmake_build
  336. run: |
  337. cmake -B build \
  338. -DGGML_VULKAN=ON
  339. cmake --build build --config Release -j $(nproc)
  340. - name: Test
  341. id: cmake_test
  342. run: |
  343. cd build
  344. # This is using llvmpipe and runs slower than other backends
  345. ctest -L main --verbose --timeout 2700
  346. - name: Determine tag name
  347. id: tag
  348. shell: bash
  349. run: |
  350. BUILD_NUMBER="$(git rev-list --count HEAD)"
  351. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  352. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  353. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  354. else
  355. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  356. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  357. fi
  358. - name: Pack artifacts
  359. id: pack_artifacts
  360. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  361. run: |
  362. cp LICENSE ./build/bin/
  363. cp examples/run/linenoise.cpp/LICENSE ./build/bin/LICENSE.linenoise.cpp
  364. zip -r llama-${{ steps.tag.outputs.name }}-bin-ubuntu-vulkan-x64.zip ./build/bin/*
  365. - name: Upload artifacts
  366. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  367. uses: actions/upload-artifact@v4
  368. with:
  369. path: llama-${{ steps.tag.outputs.name }}-bin-ubuntu-vulkan-x64.zip
  370. name: llama-bin-ubuntu-vulkan-x64.zip
  371. ubuntu-22-cmake-hip:
  372. runs-on: ubuntu-22.04
  373. container: rocm/dev-ubuntu-22.04:6.0.2
  374. steps:
  375. - name: Clone
  376. id: checkout
  377. uses: actions/checkout@v4
  378. - name: Dependencies
  379. id: depends
  380. run: |
  381. sudo apt-get update
  382. sudo apt-get install -y build-essential git cmake rocblas-dev hipblas-dev
  383. - name: ccache
  384. uses: hendrikmuhs/ccache-action@v1.2.16
  385. with:
  386. key: ubuntu-22-cmake-hip
  387. evict-old-files: 1d
  388. - name: Build with native CMake HIP support
  389. id: cmake_build
  390. run: |
  391. cmake -B build -S . \
  392. -DCMAKE_HIP_COMPILER="$(hipconfig -l)/clang" \
  393. -DGGML_HIP=ON
  394. cmake --build build --config Release -j $(nproc)
  395. - name: Build with legacy HIP support
  396. id: cmake_build_legacy_hip
  397. run: |
  398. cmake -B build2 -S . \
  399. -DCMAKE_C_COMPILER=hipcc \
  400. -DCMAKE_CXX_COMPILER=hipcc \
  401. -DGGML_HIP=ON
  402. cmake --build build2 --config Release -j $(nproc)
  403. ubuntu-22-cmake-musa:
  404. runs-on: ubuntu-22.04
  405. container: mthreads/musa:rc3.1.1-devel-ubuntu22.04
  406. steps:
  407. - name: Clone
  408. id: checkout
  409. uses: actions/checkout@v4
  410. - name: Dependencies
  411. id: depends
  412. run: |
  413. apt-get update
  414. apt-get install -y build-essential git cmake libcurl4-openssl-dev
  415. - name: ccache
  416. uses: hendrikmuhs/ccache-action@v1.2.16
  417. with:
  418. key: ubuntu-22-cmake-musa
  419. evict-old-files: 1d
  420. - name: Build with native CMake MUSA support
  421. id: cmake_build
  422. run: |
  423. cmake -B build -S . \
  424. -DGGML_MUSA=ON
  425. cmake --build build --config Release -j $(nproc)
  426. ubuntu-22-cmake-sycl:
  427. runs-on: ubuntu-22.04
  428. continue-on-error: true
  429. steps:
  430. - uses: actions/checkout@v4
  431. - name: add oneAPI to apt
  432. shell: bash
  433. run: |
  434. cd /tmp
  435. wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  436. sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  437. rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  438. sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
  439. - name: install oneAPI dpcpp compiler
  440. shell: bash
  441. run: |
  442. sudo apt update
  443. sudo apt install intel-oneapi-compiler-dpcpp-cpp
  444. - name: install oneAPI MKL library
  445. shell: bash
  446. run: |
  447. sudo apt install intel-oneapi-mkl-devel
  448. - name: Clone
  449. id: checkout
  450. uses: actions/checkout@v4
  451. - name: ccache
  452. uses: hendrikmuhs/ccache-action@v1.2.16
  453. with:
  454. key: ubuntu-22-cmake-sycl
  455. evict-old-files: 1d
  456. - name: Build
  457. id: cmake_build
  458. run: |
  459. source /opt/intel/oneapi/setvars.sh
  460. cmake -B build \
  461. -DGGML_SYCL=ON \
  462. -DCMAKE_C_COMPILER=icx \
  463. -DCMAKE_CXX_COMPILER=icpx
  464. cmake --build build --config Release -j $(nproc)
  465. ubuntu-22-cmake-sycl-fp16:
  466. runs-on: ubuntu-22.04
  467. continue-on-error: true
  468. steps:
  469. - uses: actions/checkout@v4
  470. - name: add oneAPI to apt
  471. shell: bash
  472. run: |
  473. cd /tmp
  474. wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  475. sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  476. rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  477. sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
  478. - name: install oneAPI dpcpp compiler
  479. shell: bash
  480. run: |
  481. sudo apt update
  482. sudo apt install intel-oneapi-compiler-dpcpp-cpp
  483. - name: install oneAPI MKL library
  484. shell: bash
  485. run: |
  486. sudo apt install intel-oneapi-mkl-devel
  487. - name: Clone
  488. id: checkout
  489. uses: actions/checkout@v4
  490. - name: ccache
  491. uses: hendrikmuhs/ccache-action@v1.2.16
  492. with:
  493. key: ubuntu-22-cmake-sycl-fp16
  494. evict-old-files: 1d
  495. - name: Build
  496. id: cmake_build
  497. run: |
  498. source /opt/intel/oneapi/setvars.sh
  499. cmake -B build \
  500. -DGGML_SYCL=ON \
  501. -DCMAKE_C_COMPILER=icx \
  502. -DCMAKE_CXX_COMPILER=icpx \
  503. -DGGML_SYCL_F16=ON
  504. cmake --build build --config Release -j $(nproc)
  505. macOS-latest-cmake-ios:
  506. runs-on: macos-latest
  507. steps:
  508. - name: Clone
  509. id: checkout
  510. uses: actions/checkout@v4
  511. - name: ccache
  512. uses: hendrikmuhs/ccache-action@v1.2.16
  513. with:
  514. key: macOS-latest-cmake-ios
  515. evict-old-files: 1d
  516. - name: Dependencies
  517. id: depends
  518. continue-on-error: true
  519. run: |
  520. brew update
  521. - name: Build
  522. id: cmake_build
  523. run: |
  524. sysctl -a
  525. cmake -B build -G Xcode \
  526. -DGGML_METAL_USE_BF16=ON \
  527. -DGGML_METAL_EMBED_LIBRARY=ON \
  528. -DLLAMA_BUILD_EXAMPLES=OFF \
  529. -DLLAMA_BUILD_TESTS=OFF \
  530. -DLLAMA_BUILD_SERVER=OFF \
  531. -DCMAKE_SYSTEM_NAME=iOS \
  532. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
  533. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  534. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  535. macOS-latest-cmake-tvos:
  536. runs-on: macos-latest
  537. steps:
  538. - name: Clone
  539. id: checkout
  540. uses: actions/checkout@v4
  541. - name: ccache
  542. uses: hendrikmuhs/ccache-action@v1.2.16
  543. with:
  544. key: macOS-latest-cmake-tvos
  545. evict-old-files: 1d
  546. - name: Dependencies
  547. id: depends
  548. continue-on-error: true
  549. run: |
  550. brew update
  551. - name: Build
  552. id: cmake_build
  553. run: |
  554. sysctl -a
  555. cmake -B build -G Xcode \
  556. -DGGML_METAL_USE_BF16=ON \
  557. -DGGML_METAL_EMBED_LIBRARY=ON \
  558. -DLLAMA_BUILD_EXAMPLES=OFF \
  559. -DLLAMA_BUILD_TESTS=OFF \
  560. -DLLAMA_BUILD_SERVER=OFF \
  561. -DCMAKE_SYSTEM_NAME=tvOS \
  562. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
  563. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  564. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  565. macOS-latest-swift:
  566. runs-on: macos-latest
  567. strategy:
  568. matrix:
  569. destination: ['generic/platform=macOS', 'generic/platform=iOS', 'generic/platform=tvOS']
  570. steps:
  571. - name: Clone
  572. id: checkout
  573. uses: actions/checkout@v4
  574. - name: ccache
  575. uses: hendrikmuhs/ccache-action@v1.2.16
  576. with:
  577. key: macOS-latest-swift
  578. evict-old-files: 1d
  579. - name: Dependencies
  580. id: depends
  581. continue-on-error: true
  582. run: |
  583. brew update
  584. - name: Build llama.cpp with CMake
  585. id: cmake_build
  586. run: |
  587. sysctl -a
  588. cmake -B build -G Xcode \
  589. -DGGML_METAL_USE_BF16=ON \
  590. -DGGML_METAL_EMBED_LIBRARY=ON \
  591. -DLLAMA_BUILD_EXAMPLES=OFF \
  592. -DLLAMA_BUILD_TESTS=OFF \
  593. -DLLAMA_BUILD_SERVER=OFF \
  594. -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
  595. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
  596. sudo cmake --install build --config Release
  597. - name: xcodebuild for swift package
  598. id: xcodebuild
  599. run: |
  600. xcodebuild -scheme llama-Package -destination "${{ matrix.destination }}"
  601. windows-msys2:
  602. runs-on: windows-latest
  603. strategy:
  604. fail-fast: false
  605. matrix:
  606. include:
  607. - { sys: UCRT64, env: ucrt-x86_64, build: Release }
  608. - { sys: CLANG64, env: clang-x86_64, build: Release }
  609. steps:
  610. - name: Clone
  611. uses: actions/checkout@v4
  612. - name: ccache
  613. uses: hendrikmuhs/ccache-action@v1.2.16
  614. with:
  615. key: windows-msys2
  616. variant: sccache
  617. evict-old-files: 1d
  618. - name: Setup ${{ matrix.sys }}
  619. uses: msys2/setup-msys2@v2
  620. with:
  621. update: true
  622. msystem: ${{matrix.sys}}
  623. install: >-
  624. base-devel
  625. git
  626. mingw-w64-${{matrix.env}}-toolchain
  627. mingw-w64-${{matrix.env}}-cmake
  628. mingw-w64-${{matrix.env}}-openblas
  629. - name: Build using CMake
  630. shell: msys2 {0}
  631. run: |
  632. cmake -B build
  633. cmake --build build --config ${{ matrix.build }} -j $(nproc)
  634. - name: Clean after building using CMake
  635. shell: msys2 {0}
  636. run: |
  637. rm -rf build
  638. - name: Build using CMake w/ OpenBLAS
  639. shell: msys2 {0}
  640. run: |
  641. cmake -B build -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS
  642. cmake --build build --config ${{ matrix.build }} -j $(nproc)
  643. windows-latest-cmake:
  644. runs-on: windows-latest
  645. env:
  646. OPENBLAS_VERSION: 0.3.23
  647. SDE_VERSION: 9.33.0-2024-01-07
  648. VULKAN_VERSION: 1.3.261.1
  649. strategy:
  650. matrix:
  651. include:
  652. - build: 'noavx-x64'
  653. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_FMA=OFF'
  654. - build: 'avx2-x64'
  655. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON'
  656. - build: 'avx-x64'
  657. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_AVX2=OFF'
  658. - build: 'avx512-x64'
  659. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_AVX512=ON'
  660. - build: 'openblas-x64'
  661. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS -DBLAS_INCLUDE_DIRS="$env:RUNNER_TEMP/openblas/include" -DBLAS_LIBRARIES="$env:RUNNER_TEMP/openblas/lib/openblas.lib"'
  662. - build: 'kompute-x64'
  663. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_KOMPUTE=ON -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON'
  664. - build: 'vulkan-x64'
  665. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_VULKAN=ON'
  666. - build: 'llvm-arm64'
  667. defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-llvm.cmake -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON'
  668. - build: 'msvc-arm64'
  669. defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-msvc.cmake -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON'
  670. - build: 'llvm-arm64-opencl-adreno'
  671. defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-llvm.cmake -DCMAKE_PREFIX_PATH="$env:RUNNER_TEMP/opencl-arm64-release" -DGGML_OPENCL=ON -DGGML_OPENCL_USE_ADRENO_KERNELS=ON'
  672. steps:
  673. - name: Clone
  674. id: checkout
  675. uses: actions/checkout@v4
  676. with:
  677. fetch-depth: 0
  678. - name: ccache
  679. uses: hendrikmuhs/ccache-action@v1.2.16
  680. with:
  681. key: windows-latest-cmake-${{ matrix.build }}
  682. variant: sccache
  683. evict-old-files: 1d
  684. - name: Clone Kompute submodule
  685. id: clone_kompute
  686. if: ${{ matrix.build == 'kompute-x64' }}
  687. run: |
  688. git submodule update --init ggml/src/ggml-kompute/kompute
  689. - name: Download OpenBLAS
  690. id: get_openblas
  691. if: ${{ matrix.build == 'openblas-x64' }}
  692. run: |
  693. 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"
  694. curl.exe -o $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt -L "https://github.com/xianyi/OpenBLAS/raw/v${env:OPENBLAS_VERSION}/LICENSE"
  695. mkdir $env:RUNNER_TEMP/openblas
  696. tar.exe -xvf $env:RUNNER_TEMP/openblas.zip -C $env:RUNNER_TEMP/openblas
  697. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  698. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  699. $lib = $(join-path $msvc 'bin\Hostx64\x64\lib.exe')
  700. & $lib /machine:x64 "/def:${env:RUNNER_TEMP}/openblas/lib/libopenblas.def" "/out:${env:RUNNER_TEMP}/openblas/lib/openblas.lib" /name:openblas.dll
  701. - name: Install Vulkan SDK
  702. id: get_vulkan
  703. if: ${{ matrix.build == 'kompute-x64' || matrix.build == 'vulkan-x64' }}
  704. run: |
  705. 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"
  706. & "$env:RUNNER_TEMP\VulkanSDK-Installer.exe" --accept-licenses --default-answer --confirm-command install
  707. Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${env:VULKAN_VERSION}"
  708. Add-Content $env:GITHUB_PATH "C:\VulkanSDK\${env:VULKAN_VERSION}\bin"
  709. - name: Install Ninja
  710. id: install_ninja
  711. run: |
  712. choco install ninja
  713. - name: Install OpenCL Headers and Libs
  714. id: install_opencl
  715. if: ${{ matrix.build == 'llvm-arm64-opencl-adreno' }}
  716. run: |
  717. git clone https://github.com/KhronosGroup/OpenCL-Headers
  718. cd OpenCL-Headers
  719. cmake -B build `
  720. -DBUILD_TESTING=OFF `
  721. -DOPENCL_HEADERS_BUILD_TESTING=OFF `
  722. -DOPENCL_HEADERS_BUILD_CXX_TESTS=OFF `
  723. -DCMAKE_INSTALL_PREFIX="$env:RUNNER_TEMP/opencl-arm64-release"
  724. cmake --build build --target install
  725. git clone https://github.com/KhronosGroup/OpenCL-ICD-Loader
  726. cd OpenCL-ICD-Loader
  727. cmake -B build-arm64-release `
  728. -A arm64 `
  729. -DCMAKE_PREFIX_PATH="$env:RUNNER_TEMP/opencl-arm64-release" `
  730. -DCMAKE_INSTALL_PREFIX="$env:RUNNER_TEMP/opencl-arm64-release"
  731. cmake --build build-arm64-release --target install --config release
  732. - name: Build
  733. id: cmake_build
  734. run: |
  735. cmake -S . -B build ${{ matrix.defines }}
  736. cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS}
  737. - name: Add libopenblas.dll
  738. id: add_libopenblas_dll
  739. if: ${{ matrix.build == 'openblas-x64' }}
  740. run: |
  741. cp $env:RUNNER_TEMP/openblas/bin/libopenblas.dll ./build/bin/Release/openblas.dll
  742. cp $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt ./build/bin/Release/OpenBLAS-${env:OPENBLAS_VERSION}.txt
  743. - name: Check AVX512F support
  744. id: check_avx512f
  745. if: ${{ matrix.build == 'avx512-x64' }}
  746. continue-on-error: true
  747. run: |
  748. cd build
  749. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  750. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  751. $cl = $(join-path $msvc 'bin\Hostx64\x64\cl.exe')
  752. echo 'int main(void){unsigned int a[4];__cpuid(a,7);return !(a[1]&65536);}' >> avx512f.c
  753. & $cl /O2 /GS- /kernel avx512f.c /link /nodefaultlib /entry:main
  754. .\avx512f.exe && echo "AVX512F: YES" && ( echo HAS_AVX512F=1 >> $env:GITHUB_ENV ) || echo "AVX512F: NO"
  755. - name: Test
  756. id: cmake_test
  757. # not all machines have native AVX-512
  758. if: ${{ matrix.build != 'msvc-arm64' && matrix.build != 'llvm-arm64' && matrix.build != 'llvm-arm64-opencl-adreno' && matrix.build != 'kompute-x64' && matrix.build != 'vulkan-x64' && (matrix.build != 'avx512-x64' || env.HAS_AVX512F == '1') }}
  759. run: |
  760. cd build
  761. ctest -L main -C Release --verbose --timeout 900
  762. - name: Test (Intel SDE)
  763. id: cmake_test_sde
  764. if: ${{ matrix.build == 'avx512-x64' && env.HAS_AVX512F == '0' }} # use Intel SDE for AVX-512 emulation
  765. run: |
  766. curl.exe -o $env:RUNNER_TEMP/sde.tar.xz -L "https://downloadmirror.intel.com/813591/sde-external-${env:SDE_VERSION}-win.tar.xz"
  767. # for some weird reason windows tar doesn't like sde tar.xz
  768. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar.xz
  769. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar
  770. $sde = $(join-path $env:RUNNER_TEMP sde-external-${env:SDE_VERSION}-win/sde.exe)
  771. cd build
  772. $env:LLAMA_SKIP_TESTS_SLOW_ON_EMULATOR = 1
  773. & $sde -future -- ctest -L main -C Release --verbose --timeout 900
  774. - name: Determine tag name
  775. id: tag
  776. shell: bash
  777. run: |
  778. BUILD_NUMBER="$(git rev-list --count HEAD)"
  779. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  780. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  781. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  782. else
  783. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  784. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  785. fi
  786. - name: Pack artifacts
  787. id: pack_artifacts
  788. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  789. run: |
  790. Copy-Item LICENSE .\build\bin\Release\llama.cpp.txt
  791. Copy-Item .\examples\run\linenoise.cpp\LICENSE .\build\bin\Release\linenoise.cpp.txt
  792. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip .\build\bin\Release\*
  793. - name: Upload artifacts
  794. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  795. uses: actions/upload-artifact@v4
  796. with:
  797. path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip
  798. name: llama-bin-win-${{ matrix.build }}.zip
  799. ubuntu-latest-cmake-cuda:
  800. runs-on: ubuntu-latest
  801. container: nvidia/cuda:12.6.2-devel-ubuntu24.04
  802. steps:
  803. - name: Clone
  804. id: checkout
  805. uses: actions/checkout@v4
  806. with:
  807. fetch-depth: 0
  808. - name: Install dependencies
  809. env:
  810. DEBIAN_FRONTEND: noninteractive
  811. run: |
  812. apt update
  813. apt install -y cmake build-essential ninja-build libgomp1 git
  814. - name: ccache
  815. uses: hendrikmuhs/ccache-action@v1.2.16
  816. with:
  817. key: ubuntu-latest-cmake-cuda
  818. evict-old-files: 1d
  819. - name: Build with CMake
  820. run: |
  821. cmake -S . -B build -G Ninja \
  822. -DCMAKE_BUILD_TYPE=Release \
  823. -DCMAKE_CUDA_ARCHITECTURES=89-real \
  824. -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined \
  825. -DLLAMA_FATAL_WARNINGS=ON \
  826. -DGGML_NATIVE=OFF \
  827. -DGGML_CUDA=ON
  828. cmake --build build
  829. windows-2019-cmake-cuda:
  830. runs-on: windows-2019
  831. strategy:
  832. matrix:
  833. cuda: ['12.4', '11.7']
  834. build: ['cuda']
  835. steps:
  836. - name: Clone
  837. id: checkout
  838. uses: actions/checkout@v4
  839. with:
  840. fetch-depth: 0
  841. - name: Install ccache
  842. uses: hendrikmuhs/ccache-action@v1.2.16
  843. with:
  844. key: ${{ github.job }}-${{ matrix.cuda }}-${{ matrix.build }}
  845. variant: sccache
  846. evict-old-files: 1d
  847. - name: Install Cuda Toolkit 11.7
  848. if: ${{ matrix.cuda == '11.7' }}
  849. run: |
  850. mkdir -p "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7"
  851. choco install unzip -y
  852. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_cudart/windows-x86_64/cuda_cudart-windows-x86_64-11.7.99-archive.zip"
  853. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvcc/windows-x86_64/cuda_nvcc-windows-x86_64-11.7.99-archive.zip"
  854. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvrtc/windows-x86_64/cuda_nvrtc-windows-x86_64-11.7.99-archive.zip"
  855. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/libcublas/windows-x86_64/libcublas-windows-x86_64-11.7.4.6-archive.zip"
  856. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvtx/windows-x86_64/cuda_nvtx-windows-x86_64-11.7.91-archive.zip"
  857. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/visual_studio_integration/windows-x86_64/visual_studio_integration-windows-x86_64-11.7.91-archive.zip"
  858. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvprof/windows-x86_64/cuda_nvprof-windows-x86_64-11.7.101-archive.zip"
  859. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_cccl/windows-x86_64/cuda_cccl-windows-x86_64-11.7.91-archive.zip"
  860. unzip '*.zip' -d "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7"
  861. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\cuda_cudart-windows-x86_64-11.7.99-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" /E /I /H /Y
  862. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\cuda_nvcc-windows-x86_64-11.7.99-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" /E /I /H /Y
  863. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\cuda_nvrtc-windows-x86_64-11.7.99-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" /E /I /H /Y
  864. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\libcublas-windows-x86_64-11.7.4.6-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" /E /I /H /Y
  865. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\cuda_nvtx-windows-x86_64-11.7.91-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" /E /I /H /Y
  866. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\visual_studio_integration-windows-x86_64-11.7.91-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" /E /I /H /Y
  867. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\cuda_nvprof-windows-x86_64-11.7.101-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" /E /I /H /Y
  868. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\cuda_cccl-windows-x86_64-11.7.91-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" /E /I /H /Y
  869. echo "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  870. echo "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\libnvvp" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  871. echo "CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
  872. echo "CUDA_PATH_V11_7=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
  873. - name: Install Cuda Toolkit 12.4
  874. if: ${{ matrix.cuda == '12.4' }}
  875. run: |
  876. mkdir -p "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4"
  877. choco install unzip -y
  878. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_cudart/windows-x86_64/cuda_cudart-windows-x86_64-12.4.127-archive.zip"
  879. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvcc/windows-x86_64/cuda_nvcc-windows-x86_64-12.4.131-archive.zip"
  880. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvrtc/windows-x86_64/cuda_nvrtc-windows-x86_64-12.4.127-archive.zip"
  881. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/libcublas/windows-x86_64/libcublas-windows-x86_64-12.4.5.8-archive.zip"
  882. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvtx/windows-x86_64/cuda_nvtx-windows-x86_64-12.4.127-archive.zip"
  883. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_profiler_api/windows-x86_64/cuda_profiler_api-windows-x86_64-12.4.127-archive.zip"
  884. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/visual_studio_integration/windows-x86_64/visual_studio_integration-windows-x86_64-12.4.127-archive.zip"
  885. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvprof/windows-x86_64/cuda_nvprof-windows-x86_64-12.4.127-archive.zip"
  886. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_cccl/windows-x86_64/cuda_cccl-windows-x86_64-12.4.127-archive.zip"
  887. unzip '*.zip' -d "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4"
  888. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\cuda_cudart-windows-x86_64-12.4.127-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" /E /I /H /Y
  889. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\cuda_nvcc-windows-x86_64-12.4.131-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" /E /I /H /Y
  890. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\cuda_nvrtc-windows-x86_64-12.4.127-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" /E /I /H /Y
  891. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\libcublas-windows-x86_64-12.4.5.8-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" /E /I /H /Y
  892. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\cuda_nvtx-windows-x86_64-12.4.127-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" /E /I /H /Y
  893. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\cuda_profiler_api-windows-x86_64-12.4.127-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" /E /I /H /Y
  894. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\visual_studio_integration-windows-x86_64-12.4.127-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" /E /I /H /Y
  895. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\cuda_nvprof-windows-x86_64-12.4.127-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" /E /I /H /Y
  896. xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\cuda_cccl-windows-x86_64-12.4.127-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" /E /I /H /Y
  897. echo "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  898. echo "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\libnvvp" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  899. echo "CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
  900. echo "CUDA_PATH_V12_4=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
  901. - name: Install Ninja
  902. id: install_ninja
  903. run: |
  904. choco install ninja
  905. - name: Build
  906. id: cmake_build
  907. shell: cmd
  908. run: |
  909. call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
  910. cmake -S . -B build -G "Ninja Multi-Config" ^
  911. -DLLAMA_BUILD_SERVER=ON ^
  912. -DGGML_NATIVE=OFF ^
  913. -DGGML_CUDA=ON ^
  914. -DGGML_RPC=ON
  915. set /A NINJA_JOBS=%NUMBER_OF_PROCESSORS%-1
  916. cmake --build build --config Release -j %NINJA_JOBS% -t ggml
  917. cmake --build build --config Release
  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. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  933. run: |
  934. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip .\build\bin\Release\*
  935. - name: Upload artifacts
  936. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  937. uses: actions/upload-artifact@v4
  938. with:
  939. path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip
  940. name: llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  941. - name: Copy and pack Cuda runtime
  942. if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
  943. run: |
  944. echo "Cuda install location: ${{ env.CUDA_PATH }}"
  945. $dst='.\build\bin\cudart\'
  946. robocopy "${{env.CUDA_PATH}}\bin" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
  947. robocopy "${{env.CUDA_PATH}}\lib" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
  948. 7z a cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip $dst\*
  949. - name: Upload Cuda runtime
  950. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  951. uses: actions/upload-artifact@v4
  952. with:
  953. path: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  954. name: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  955. windows-latest-cmake-sycl:
  956. runs-on: windows-latest
  957. defaults:
  958. run:
  959. shell: bash
  960. env:
  961. 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
  962. WINDOWS_DPCPP_MKL: intel.oneapi.win.cpp-dpcpp-common:intel.oneapi.win.mkl.devel:intel.oneapi.win.dnnl:intel.oneapi.win.tbb.devel
  963. ONEAPI_ROOT: "C:/Program Files (x86)/Intel/oneAPI"
  964. steps:
  965. - name: Clone
  966. id: checkout
  967. uses: actions/checkout@v4
  968. with:
  969. fetch-depth: 0
  970. - name: ccache
  971. uses: hendrikmuhs/ccache-action@v1.2.16
  972. with:
  973. key: windows-latest-cmake-sycl
  974. variant: sccache
  975. evict-old-files: 1d
  976. - name: Install
  977. run: |
  978. scripts/install-oneapi.bat $WINDOWS_BASEKIT_URL $WINDOWS_DPCPP_MKL
  979. - name: Build
  980. id: cmake_build
  981. run: examples/sycl/win-build-sycl.bat
  982. - name: Determine tag name
  983. id: tag
  984. shell: bash
  985. run: |
  986. BUILD_NUMBER="$(git rev-list --count HEAD)"
  987. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  988. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  989. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  990. else
  991. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  992. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  993. fi
  994. - name: Build the release package
  995. id: pack_artifacts
  996. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  997. run: |
  998. echo "cp oneAPI running time dll files in ${{ env.ONEAPI_ROOT }} to ./build/bin"
  999. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_sycl_blas.5.dll" ./build/bin
  1000. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_core.2.dll" ./build/bin
  1001. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_tbb_thread.2.dll" ./build/bin
  1002. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_adapter_level_zero.dll" ./build/bin
  1003. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_adapter_opencl.dll" ./build/bin
  1004. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_loader.dll" ./build/bin
  1005. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_win_proxy_loader.dll" ./build/bin
  1006. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/sycl8.dll" ./build/bin
  1007. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/svml_dispmd.dll" ./build/bin
  1008. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/libmmd.dll" ./build/bin
  1009. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/libiomp5md.dll" ./build/bin
  1010. cp "${{ env.ONEAPI_ROOT }}/dnnl/latest/bin/dnnl.dll" ./build/bin
  1011. cp "${{ env.ONEAPI_ROOT }}/tbb/latest/bin/tbb12.dll" ./build/bin
  1012. echo "cp oneAPI running time dll files to ./build/bin done"
  1013. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip ./build/bin/*
  1014. - name: Upload the release package
  1015. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  1016. uses: actions/upload-artifact@v4
  1017. with:
  1018. path: llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip
  1019. name: llama-bin-win-sycl-x64.zip
  1020. windows-latest-cmake-hip:
  1021. if: ${{ github.event.inputs.create_release != 'true' }}
  1022. runs-on: windows-latest
  1023. steps:
  1024. - name: Clone
  1025. id: checkout
  1026. uses: actions/checkout@v4
  1027. - name: Install
  1028. id: depends
  1029. run: |
  1030. $ErrorActionPreference = "Stop"
  1031. write-host "Downloading AMD HIP SDK Installer"
  1032. 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"
  1033. write-host "Installing AMD HIP SDK"
  1034. Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
  1035. write-host "Completed AMD HIP SDK installation"
  1036. - name: Verify ROCm
  1037. id: verify
  1038. run: |
  1039. & 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
  1040. - name: Install ccache
  1041. uses: hendrikmuhs/ccache-action@v1.2.16
  1042. with:
  1043. key: ${{ github.job }}
  1044. evict-old-files: 1d
  1045. - name: Build
  1046. id: cmake_build
  1047. run: |
  1048. $env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
  1049. $env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
  1050. cmake -G "Unix Makefiles" -B build -S . `
  1051. -DCMAKE_C_COMPILER="${env:HIP_PATH}\bin\clang.exe" `
  1052. -DCMAKE_CXX_COMPILER="${env:HIP_PATH}\bin\clang++.exe" `
  1053. -DCMAKE_BUILD_TYPE=Release `
  1054. -DGGML_HIP=ON `
  1055. -DGGML_RPC=ON
  1056. cmake --build build -j ${env:NUMBER_OF_PROCESSORS}
  1057. windows-latest-cmake-hip-release:
  1058. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  1059. runs-on: windows-latest
  1060. strategy:
  1061. matrix:
  1062. gpu_target: [gfx1100, gfx1101, gfx1030]
  1063. steps:
  1064. - name: Clone
  1065. id: checkout
  1066. uses: actions/checkout@v4
  1067. with:
  1068. fetch-depth: 0
  1069. - name: ccache
  1070. uses: hendrikmuhs/ccache-action@v1.2.16
  1071. with:
  1072. key: windows-latest-cmake-hip-release
  1073. evict-old-files: 1d
  1074. - name: Install
  1075. id: depends
  1076. run: |
  1077. $ErrorActionPreference = "Stop"
  1078. write-host "Downloading AMD HIP SDK Installer"
  1079. 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"
  1080. write-host "Installing AMD HIP SDK"
  1081. Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
  1082. write-host "Completed AMD HIP SDK installation"
  1083. - name: Verify ROCm
  1084. id: verify
  1085. run: |
  1086. & 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
  1087. - name: Build
  1088. id: cmake_build
  1089. run: |
  1090. $env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
  1091. $env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
  1092. cmake -G "Unix Makefiles" -B build -S . `
  1093. -DCMAKE_C_COMPILER="${env:HIP_PATH}\bin\clang.exe" `
  1094. -DCMAKE_CXX_COMPILER="${env:HIP_PATH}\bin\clang++.exe" `
  1095. -DCMAKE_BUILD_TYPE=Release `
  1096. -DAMDGPU_TARGETS=${{ matrix.gpu_target }} `
  1097. -DGGML_HIP=ON `
  1098. -DGGML_RPC=ON
  1099. cmake --build build -j ${env:NUMBER_OF_PROCESSORS}
  1100. md "build\bin\rocblas\library\"
  1101. cp "${env:HIP_PATH}\bin\hipblas.dll" "build\bin\"
  1102. cp "${env:HIP_PATH}\bin\rocblas.dll" "build\bin\"
  1103. cp "${env:HIP_PATH}\bin\rocblas\library\*" "build\bin\rocblas\library\"
  1104. - name: Determine tag name
  1105. id: tag
  1106. shell: bash
  1107. run: |
  1108. BUILD_NUMBER="$(git rev-list --count HEAD)"
  1109. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  1110. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  1111. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  1112. else
  1113. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  1114. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  1115. fi
  1116. - name: Pack artifacts
  1117. id: pack_artifacts
  1118. run: |
  1119. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-hip-x64-${{ matrix.gpu_target }}.zip .\build\bin\*
  1120. - name: Upload artifacts
  1121. uses: actions/upload-artifact@v4
  1122. with:
  1123. path: llama-${{ steps.tag.outputs.name }}-bin-win-hip-x64-${{ matrix.gpu_target }}.zip
  1124. name: llama-bin-win-hip-x64-${{ matrix.gpu_target }}.zip
  1125. ios-xcode-build:
  1126. runs-on: macos-latest
  1127. steps:
  1128. - name: Checkout code
  1129. uses: actions/checkout@v4
  1130. - name: Build
  1131. id: cmake_build
  1132. run: |
  1133. sysctl -a
  1134. cmake -B build -G Xcode \
  1135. -DGGML_METAL_USE_BF16=ON \
  1136. -DGGML_METAL_EMBED_LIBRARY=ON \
  1137. -DLLAMA_BUILD_EXAMPLES=OFF \
  1138. -DLLAMA_BUILD_TESTS=OFF \
  1139. -DLLAMA_BUILD_SERVER=OFF \
  1140. -DCMAKE_SYSTEM_NAME=iOS \
  1141. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
  1142. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  1143. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  1144. sudo cmake --install build --config Release
  1145. - name: xcodebuild for swift package
  1146. id: xcodebuild
  1147. run: |
  1148. xcodebuild -scheme llama-Package -destination 'generic/platform=iOS'
  1149. - name: Build Xcode project
  1150. 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
  1151. android-build:
  1152. runs-on: ubuntu-latest
  1153. steps:
  1154. - name: Clone
  1155. uses: actions/checkout@v4
  1156. - name: ccache
  1157. uses: hendrikmuhs/ccache-action@v1.2.16
  1158. with:
  1159. key: android-build
  1160. evict-old-files: 1d
  1161. - name: Set up JDK
  1162. uses: actions/setup-java@v3
  1163. with:
  1164. java-version: 17
  1165. distribution: zulu
  1166. - name: Setup Android SDK
  1167. uses: android-actions/setup-android@v3
  1168. with:
  1169. log-accepted-android-sdk-licenses: false
  1170. - name: Build
  1171. run: |
  1172. cd examples/llama.android
  1173. ./gradlew build --no-daemon
  1174. release:
  1175. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  1176. runs-on: ubuntu-latest
  1177. needs:
  1178. - ubuntu-cpu-cmake
  1179. - windows-latest-cmake
  1180. - windows-2019-cmake-cuda
  1181. - windows-latest-cmake-hip-release
  1182. - macOS-latest-cmake-arm64
  1183. - macOS-latest-cmake-x64
  1184. steps:
  1185. - name: Clone
  1186. id: checkout
  1187. uses: actions/checkout@v4
  1188. with:
  1189. fetch-depth: 0
  1190. - name: ccache
  1191. uses: hendrikmuhs/ccache-action@v1.2.16
  1192. with:
  1193. key: release
  1194. evict-old-files: 1d
  1195. - name: Determine tag name
  1196. id: tag
  1197. shell: bash
  1198. run: |
  1199. BUILD_NUMBER="$(git rev-list --count HEAD)"
  1200. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  1201. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  1202. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  1203. else
  1204. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  1205. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  1206. fi
  1207. - name: Download artifacts
  1208. id: download-artifact
  1209. uses: actions/download-artifact@v4
  1210. with:
  1211. path: ./artifact
  1212. - name: Move artifacts
  1213. id: move_artifacts
  1214. run: mkdir -p ./artifact/release && mv ./artifact/*/*.zip ./artifact/release
  1215. - name: Create release
  1216. id: create_release
  1217. uses: ggml-org/action-create-release@v1
  1218. env:
  1219. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  1220. with:
  1221. tag_name: ${{ steps.tag.outputs.name }}
  1222. - name: Upload release
  1223. id: upload_release
  1224. uses: actions/github-script@v3
  1225. with:
  1226. github-token: ${{secrets.GITHUB_TOKEN}}
  1227. script: |
  1228. const path = require('path');
  1229. const fs = require('fs');
  1230. const release_id = '${{ steps.create_release.outputs.id }}';
  1231. for (let file of await fs.readdirSync('./artifact/release')) {
  1232. if (path.extname(file) === '.zip') {
  1233. console.log('uploadReleaseAsset', file);
  1234. await github.repos.uploadReleaseAsset({
  1235. owner: context.repo.owner,
  1236. repo: context.repo.repo,
  1237. release_id: release_id,
  1238. name: file,
  1239. data: await fs.readFileSync(`./artifact/release/${file}`)
  1240. });
  1241. }
  1242. }
  1243. # ubuntu-latest-gcc:
  1244. # runs-on: ubuntu-latest
  1245. #
  1246. # strategy:
  1247. # matrix:
  1248. # build: [Debug, Release]
  1249. #
  1250. # steps:
  1251. # - name: Clone
  1252. # uses: actions/checkout@v4
  1253. #
  1254. # - name: Dependencies
  1255. # run: |
  1256. # sudo apt-get update
  1257. # sudo apt-get install build-essential
  1258. # sudo apt-get install cmake
  1259. #
  1260. # - name: Configure
  1261. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1262. #
  1263. # - name: Build
  1264. # run: |
  1265. # make
  1266. #
  1267. # ubuntu-latest-clang:
  1268. # runs-on: ubuntu-latest
  1269. #
  1270. # strategy:
  1271. # matrix:
  1272. # build: [Debug, Release]
  1273. #
  1274. # steps:
  1275. # - name: Clone
  1276. # uses: actions/checkout@v4
  1277. #
  1278. # - name: Dependencies
  1279. # run: |
  1280. # sudo apt-get update
  1281. # sudo apt-get install build-essential
  1282. # sudo apt-get install cmake
  1283. #
  1284. # - name: Configure
  1285. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
  1286. #
  1287. # - name: Build
  1288. # run: |
  1289. # make
  1290. #
  1291. # ubuntu-latest-gcc-sanitized:
  1292. # runs-on: ubuntu-latest
  1293. #
  1294. # strategy:
  1295. # matrix:
  1296. # sanitizer: [ADDRESS, THREAD, UNDEFINED]
  1297. #
  1298. # steps:
  1299. # - name: Clone
  1300. # uses: actions/checkout@v4
  1301. #
  1302. # - name: Dependencies
  1303. # run: |
  1304. # sudo apt-get update
  1305. # sudo apt-get install build-essential
  1306. # sudo apt-get install cmake
  1307. #
  1308. # - name: Configure
  1309. # run: cmake . -DCMAKE_BUILD_TYPE=Debug -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON
  1310. #
  1311. # - name: Build
  1312. # run: |
  1313. # make
  1314. #
  1315. # windows:
  1316. # runs-on: windows-latest
  1317. #
  1318. # strategy:
  1319. # matrix:
  1320. # build: [Release]
  1321. # arch: [Win32, x64]
  1322. # include:
  1323. # - arch: Win32
  1324. # s2arc: x86
  1325. # - arch: x64
  1326. # s2arc: x64
  1327. #
  1328. # steps:
  1329. # - name: Clone
  1330. # uses: actions/checkout@v4
  1331. #
  1332. # - name: Add msbuild to PATH
  1333. # uses: microsoft/setup-msbuild@v1
  1334. #
  1335. # - name: Configure
  1336. # run: >
  1337. # cmake -S . -B ./build -A ${{ matrix.arch }}
  1338. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1339. #
  1340. # - name: Build
  1341. # run: |
  1342. # cd ./build
  1343. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  1344. #
  1345. # - name: Upload binaries
  1346. # uses: actions/upload-artifact@v4
  1347. # with:
  1348. # name: llama-bin-${{ matrix.arch }}
  1349. # path: build/bin/${{ matrix.build }}
  1350. #
  1351. # windows-blas:
  1352. # runs-on: windows-latest
  1353. #
  1354. # strategy:
  1355. # matrix:
  1356. # build: [Release]
  1357. # arch: [Win32, x64]
  1358. # blas: [ON]
  1359. # include:
  1360. # - arch: Win32
  1361. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x86.zip
  1362. # s2arc: x86
  1363. # - arch: x64
  1364. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x64.zip
  1365. # s2arc: x64
  1366. #
  1367. # steps:
  1368. # - name: Clone
  1369. # uses: actions/checkout@v4
  1370. #
  1371. # - name: Add msbuild to PATH
  1372. # uses: microsoft/setup-msbuild@v1
  1373. #
  1374. # - name: Fetch OpenBLAS
  1375. # if: matrix.blas == 'ON'
  1376. # run: |
  1377. # C:/msys64/usr/bin/wget.exe -qO blas.zip ${{ matrix.obzip }}
  1378. # 7z x blas.zip -oblas -y
  1379. # copy blas/include/cblas.h .
  1380. # copy blas/include/openblas_config.h .
  1381. # echo "blasdir=$env:GITHUB_WORKSPACE/blas" >> $env:GITHUB_ENV
  1382. #
  1383. # - name: Configure
  1384. # run: >
  1385. # cmake -S . -B ./build -A ${{ matrix.arch }}
  1386. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1387. # -DLLAMA_SUPPORT_OPENBLAS=${{ matrix.blas }}
  1388. # -DCMAKE_LIBRARY_PATH="$env:blasdir/lib"
  1389. #
  1390. # - name: Build
  1391. # run: |
  1392. # cd ./build
  1393. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  1394. #
  1395. # - name: Copy libopenblas.dll
  1396. # if: matrix.blas == 'ON'
  1397. # run: copy "$env:blasdir/bin/libopenblas.dll" build/bin/${{ matrix.build }}
  1398. #
  1399. # - name: Upload binaries
  1400. # if: matrix.blas == 'ON'
  1401. # uses: actions/upload-artifact@v4
  1402. # with:
  1403. # name: llama-blas-bin-${{ matrix.arch }}
  1404. # path: build/bin/${{ matrix.build }}
  1405. #
  1406. # emscripten:
  1407. # runs-on: ubuntu-latest
  1408. #
  1409. # strategy:
  1410. # matrix:
  1411. # build: [Release]
  1412. #
  1413. # steps:
  1414. # - name: Clone
  1415. # uses: actions/checkout@v4
  1416. #
  1417. # - name: Dependencies
  1418. # run: |
  1419. # wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz
  1420. # tar -xvf master.tar.gz
  1421. # emsdk-master/emsdk update
  1422. # emsdk-master/emsdk install latest
  1423. # emsdk-master/emsdk activate latest
  1424. #
  1425. # - name: Configure
  1426. # run: echo "tmp"
  1427. #
  1428. # - name: Build
  1429. # run: |
  1430. # pushd emsdk-master
  1431. # source ./emsdk_env.sh
  1432. # popd
  1433. # emcmake cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1434. # make
  1435. openEuler-latest-cmake-cann:
  1436. if: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'Ascend NPU') }}
  1437. defaults:
  1438. run:
  1439. shell: bash -el {0}
  1440. runs-on: ubuntu-24.04-arm
  1441. strategy:
  1442. matrix:
  1443. cann:
  1444. - '8.0.rc3.beta1-910b-openeuler22.03-py3.10'
  1445. device:
  1446. - 'ascend910b3'
  1447. build:
  1448. - 'Release'
  1449. container: ascendai/cann:${{ matrix.cann }}
  1450. steps:
  1451. - name: Checkout
  1452. uses: actions/checkout@v4
  1453. - name: Dependencies
  1454. run: |
  1455. yum update -y
  1456. yum install -y git gcc gcc-c++ make cmake
  1457. - name: Build
  1458. run: |
  1459. export LD_LIBRARY_PATH=${ASCEND_TOOLKIT_HOME}/lib64:${ASCEND_TOOLKIT_HOME}/$(uname -m)-linux/devlib/:${LD_LIBRARY_PATH}
  1460. cmake -S . -B build \
  1461. -DCMAKE_BUILD_TYPE=${{ matrix.build }} \
  1462. -DGGML_CANN=on \
  1463. -DSOC_TYPE=${{ matrix.device }}
  1464. cmake --build build -j $(nproc)