build.yml 64 KB

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