build.yml 62 KB

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