build.yml 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799
  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. # Disabled for now due to sporadic issue syncing.
  512. # build-linux-cross:
  513. # uses: ./.github/workflows/build-linux-cross.yml
  514. macOS-latest-cmake-ios:
  515. runs-on: macos-latest
  516. steps:
  517. - name: Clone
  518. id: checkout
  519. uses: actions/checkout@v4
  520. - name: ccache
  521. uses: hendrikmuhs/ccache-action@v1.2.16
  522. with:
  523. key: macOS-latest-cmake-ios
  524. evict-old-files: 1d
  525. - name: Dependencies
  526. id: depends
  527. continue-on-error: true
  528. run: |
  529. brew update
  530. - name: Build
  531. id: cmake_build
  532. run: |
  533. sysctl -a
  534. cmake -B build -G Xcode \
  535. -DGGML_METAL_USE_BF16=ON \
  536. -DGGML_METAL_EMBED_LIBRARY=ON \
  537. -DLLAMA_BUILD_COMMON=OFF \
  538. -DLLAMA_BUILD_EXAMPLES=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_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-cmake-visionos:
  577. runs-on: macos-latest
  578. steps:
  579. - name: Clone
  580. id: checkout
  581. uses: actions/checkout@v4
  582. - name: Dependencies
  583. id: depends
  584. continue-on-error: true
  585. run: |
  586. brew update
  587. - name: Build
  588. id: cmake_build
  589. run: |
  590. sysctl -a
  591. cmake -B build -G Xcode \
  592. -DGGML_METAL_USE_BF16=ON \
  593. -DGGML_METAL_EMBED_LIBRARY=ON \
  594. -DLLAMA_BUILD_COMMON=OFF \
  595. -DLLAMA_BUILD_EXAMPLES=OFF \
  596. -DLLAMA_BUILD_TESTS=OFF \
  597. -DLLAMA_BUILD_SERVER=OFF \
  598. -DCMAKE_SYSTEM_NAME=visionOS \
  599. -DCMAKE_OSX_DEPLOYMENT_TARGET=1.0 \
  600. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  601. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  602. macOS-latest-swift:
  603. runs-on: macos-latest
  604. strategy:
  605. matrix:
  606. destination: ['generic/platform=macOS', 'generic/platform=iOS', 'generic/platform=tvOS']
  607. steps:
  608. - name: Clone
  609. id: checkout
  610. uses: actions/checkout@v4
  611. - name: ccache
  612. uses: hendrikmuhs/ccache-action@v1.2.16
  613. with:
  614. key: macOS-latest-swift
  615. evict-old-files: 1d
  616. - name: Dependencies
  617. id: depends
  618. continue-on-error: true
  619. run: |
  620. brew update
  621. - name: Build llama.cpp with CMake
  622. id: cmake_build
  623. run: |
  624. sysctl -a
  625. cmake -B build -G Xcode \
  626. -DGGML_METAL_USE_BF16=ON \
  627. -DGGML_METAL_EMBED_LIBRARY=ON \
  628. -DLLAMA_CURL=OFF \
  629. -DLLAMA_BUILD_EXAMPLES=OFF \
  630. -DLLAMA_BUILD_TESTS=OFF \
  631. -DLLAMA_BUILD_SERVER=OFF \
  632. -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
  633. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
  634. - name: xcodebuild for swift package
  635. id: xcodebuild
  636. run: |
  637. ./build-xcframework.sh
  638. windows-msys2:
  639. runs-on: windows-latest
  640. strategy:
  641. fail-fast: false
  642. matrix:
  643. include:
  644. - { sys: UCRT64, env: ucrt-x86_64, build: Release }
  645. - { sys: CLANG64, env: clang-x86_64, build: Release }
  646. steps:
  647. - name: Clone
  648. uses: actions/checkout@v4
  649. - name: ccache
  650. uses: hendrikmuhs/ccache-action@v1.2.16
  651. with:
  652. key: windows-msys2
  653. variant: sccache
  654. evict-old-files: 1d
  655. - name: Setup ${{ matrix.sys }}
  656. uses: msys2/setup-msys2@v2
  657. with:
  658. update: true
  659. msystem: ${{matrix.sys}}
  660. install: >-
  661. base-devel
  662. git
  663. mingw-w64-${{matrix.env}}-toolchain
  664. mingw-w64-${{matrix.env}}-cmake
  665. mingw-w64-${{matrix.env}}-openblas
  666. - name: Build using CMake
  667. shell: msys2 {0}
  668. run: |
  669. cmake -B build
  670. cmake --build build --config ${{ matrix.build }} -j $(nproc)
  671. - name: Clean after building using CMake
  672. shell: msys2 {0}
  673. run: |
  674. rm -rf build
  675. - name: Build using CMake w/ OpenBLAS
  676. shell: msys2 {0}
  677. run: |
  678. cmake -B build -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS
  679. cmake --build build --config ${{ matrix.build }} -j $(nproc)
  680. windows-latest-cmake:
  681. runs-on: windows-latest
  682. env:
  683. OPENBLAS_VERSION: 0.3.23
  684. SDE_VERSION: 9.33.0-2024-01-07
  685. VULKAN_VERSION: 1.4.309.0
  686. strategy:
  687. matrix:
  688. include:
  689. - build: 'noavx-x64'
  690. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_FMA=OFF'
  691. - build: 'avx2-x64'
  692. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON'
  693. - build: 'avx-x64'
  694. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_AVX2=OFF'
  695. - build: 'avx512-x64'
  696. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_AVX512=ON'
  697. - build: 'openblas-x64'
  698. 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"'
  699. - build: 'kompute-x64'
  700. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_KOMPUTE=ON -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON'
  701. - build: 'vulkan-x64'
  702. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_VULKAN=ON'
  703. - build: 'llvm-arm64'
  704. defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-llvm.cmake -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON'
  705. - build: 'msvc-arm64'
  706. defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-msvc.cmake -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON'
  707. - build: 'llvm-arm64-opencl-adreno'
  708. 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'
  709. steps:
  710. - name: Clone
  711. id: checkout
  712. uses: actions/checkout@v4
  713. with:
  714. fetch-depth: 0
  715. - name: ccache
  716. uses: hendrikmuhs/ccache-action@v1.2.16
  717. with:
  718. key: windows-latest-cmake-${{ matrix.build }}
  719. variant: sccache
  720. evict-old-files: 1d
  721. - name: Clone Kompute submodule
  722. id: clone_kompute
  723. if: ${{ matrix.build == 'kompute-x64' }}
  724. run: |
  725. git submodule update --init ggml/src/ggml-kompute/kompute
  726. - name: Download OpenBLAS
  727. id: get_openblas
  728. if: ${{ matrix.build == 'openblas-x64' }}
  729. run: |
  730. 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"
  731. curl.exe -o $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt -L "https://github.com/xianyi/OpenBLAS/raw/v${env:OPENBLAS_VERSION}/LICENSE"
  732. mkdir $env:RUNNER_TEMP/openblas
  733. tar.exe -xvf $env:RUNNER_TEMP/openblas.zip -C $env:RUNNER_TEMP/openblas
  734. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  735. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  736. $lib = $(join-path $msvc 'bin\Hostx64\x64\lib.exe')
  737. & $lib /machine:x64 "/def:${env:RUNNER_TEMP}/openblas/lib/libopenblas.def" "/out:${env:RUNNER_TEMP}/openblas/lib/openblas.lib" /name:openblas.dll
  738. - name: Install Vulkan SDK
  739. id: get_vulkan
  740. if: ${{ matrix.build == 'kompute-x64' || matrix.build == 'vulkan-x64' }}
  741. run: |
  742. 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"
  743. & "$env:RUNNER_TEMP\VulkanSDK-Installer.exe" --accept-licenses --default-answer --confirm-command install
  744. Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${env:VULKAN_VERSION}"
  745. Add-Content $env:GITHUB_PATH "C:\VulkanSDK\${env:VULKAN_VERSION}\bin"
  746. - name: Install Ninja
  747. id: install_ninja
  748. run: |
  749. choco install ninja
  750. - name: Install OpenCL Headers and Libs
  751. id: install_opencl
  752. if: ${{ matrix.build == 'llvm-arm64-opencl-adreno' }}
  753. run: |
  754. git clone https://github.com/KhronosGroup/OpenCL-Headers
  755. cd OpenCL-Headers
  756. cmake -B build `
  757. -DBUILD_TESTING=OFF `
  758. -DOPENCL_HEADERS_BUILD_TESTING=OFF `
  759. -DOPENCL_HEADERS_BUILD_CXX_TESTS=OFF `
  760. -DCMAKE_INSTALL_PREFIX="$env:RUNNER_TEMP/opencl-arm64-release"
  761. cmake --build build --target install
  762. git clone https://github.com/KhronosGroup/OpenCL-ICD-Loader
  763. cd OpenCL-ICD-Loader
  764. cmake -B build-arm64-release `
  765. -A arm64 `
  766. -DCMAKE_PREFIX_PATH="$env:RUNNER_TEMP/opencl-arm64-release" `
  767. -DCMAKE_INSTALL_PREFIX="$env:RUNNER_TEMP/opencl-arm64-release"
  768. cmake --build build-arm64-release --target install --config release
  769. - name: libCURL
  770. id: get_libcurl
  771. uses: ./.github/actions/windows-setup-curl
  772. - name: Build
  773. id: cmake_build
  774. env:
  775. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  776. run: |
  777. cmake -S . -B build ${{ matrix.defines }} `
  778. -DCURL_LIBRARY="$env:CURL_PATH/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:CURL_PATH/include"
  779. cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS}
  780. - name: Add libopenblas.dll
  781. id: add_libopenblas_dll
  782. if: ${{ matrix.build == 'openblas-x64' }}
  783. run: |
  784. cp $env:RUNNER_TEMP/openblas/bin/libopenblas.dll ./build/bin/Release/openblas.dll
  785. cp $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt ./build/bin/Release/OpenBLAS-${env:OPENBLAS_VERSION}.txt
  786. - name: Check AVX512F support
  787. id: check_avx512f
  788. if: ${{ matrix.build == 'avx512-x64' }}
  789. continue-on-error: true
  790. run: |
  791. cd build
  792. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  793. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  794. $cl = $(join-path $msvc 'bin\Hostx64\x64\cl.exe')
  795. echo 'int main(void){unsigned int a[4];__cpuid(a,7);return !(a[1]&65536);}' >> avx512f.c
  796. & $cl /O2 /GS- /kernel avx512f.c /link /nodefaultlib /entry:main
  797. .\avx512f.exe && echo "AVX512F: YES" && ( echo HAS_AVX512F=1 >> $env:GITHUB_ENV ) || echo "AVX512F: NO"
  798. - name: Test
  799. id: cmake_test
  800. # not all machines have native AVX-512
  801. 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') }}
  802. run: |
  803. cd build
  804. ctest -L main -C Release --verbose --timeout 900
  805. - name: Test (Intel SDE)
  806. id: cmake_test_sde
  807. if: ${{ matrix.build == 'avx512-x64' && env.HAS_AVX512F == '0' }} # use Intel SDE for AVX-512 emulation
  808. run: |
  809. curl.exe -o $env:RUNNER_TEMP/sde.tar.xz -L "https://downloadmirror.intel.com/813591/sde-external-${env:SDE_VERSION}-win.tar.xz"
  810. # for some weird reason windows tar doesn't like sde tar.xz
  811. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar.xz
  812. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar
  813. $sde = $(join-path $env:RUNNER_TEMP sde-external-${env:SDE_VERSION}-win/sde.exe)
  814. cd build
  815. $env:LLAMA_SKIP_TESTS_SLOW_ON_EMULATOR = 1
  816. & $sde -future -- ctest -L main -C Release --verbose --timeout 900
  817. - name: Determine tag name
  818. id: tag
  819. shell: bash
  820. run: |
  821. BUILD_NUMBER="$(git rev-list --count HEAD)"
  822. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  823. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  824. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  825. else
  826. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  827. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  828. fi
  829. - name: Pack artifacts
  830. id: pack_artifacts
  831. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  832. env:
  833. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  834. run: |
  835. Copy-Item $env:CURL_PATH\bin\libcurl-x64.dll .\build\bin\Release\libcurl-x64.dll
  836. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip .\build\bin\Release\*
  837. - name: Upload artifacts
  838. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  839. uses: actions/upload-artifact@v4
  840. with:
  841. path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip
  842. name: llama-bin-win-${{ matrix.build }}.zip
  843. ubuntu-latest-cmake-cuda:
  844. runs-on: ubuntu-latest
  845. container: nvidia/cuda:12.6.2-devel-ubuntu24.04
  846. steps:
  847. - name: Clone
  848. id: checkout
  849. uses: actions/checkout@v4
  850. with:
  851. fetch-depth: 0
  852. - name: Install dependencies
  853. env:
  854. DEBIAN_FRONTEND: noninteractive
  855. run: |
  856. apt update
  857. apt install -y cmake build-essential ninja-build libgomp1 git libcurl4-openssl-dev
  858. - name: ccache
  859. uses: hendrikmuhs/ccache-action@v1.2.16
  860. with:
  861. key: ubuntu-latest-cmake-cuda
  862. evict-old-files: 1d
  863. - name: Build with CMake
  864. run: |
  865. cmake -S . -B build -G Ninja \
  866. -DCMAKE_BUILD_TYPE=Release \
  867. -DCMAKE_CUDA_ARCHITECTURES=89-real \
  868. -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined \
  869. -DLLAMA_FATAL_WARNINGS=ON \
  870. -DGGML_NATIVE=OFF \
  871. -DGGML_CUDA=ON
  872. cmake --build build
  873. windows-2019-cmake-cuda:
  874. runs-on: windows-2019
  875. strategy:
  876. matrix:
  877. cuda: ['12.4', '11.7']
  878. build: ['cuda']
  879. steps:
  880. - name: Clone
  881. id: checkout
  882. uses: actions/checkout@v4
  883. with:
  884. fetch-depth: 0
  885. - name: Install ccache
  886. uses: hendrikmuhs/ccache-action@v1.2.16
  887. with:
  888. key: ${{ github.job }}-${{ matrix.cuda }}-${{ matrix.build }}
  889. variant: sccache
  890. evict-old-files: 1d
  891. - name: Install Cuda Toolkit 11.7
  892. if: ${{ matrix.cuda == '11.7' }}
  893. run: |
  894. mkdir -p "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7"
  895. choco install unzip -y
  896. 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"
  897. 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"
  898. 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"
  899. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/libcublas/windows-x86_64/libcublas-windows-x86_64-11.7.4.6-archive.zip"
  900. 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"
  901. 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"
  902. 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"
  903. 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"
  904. unzip '*.zip' -d "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7"
  905. 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
  906. 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
  907. 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
  908. 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
  909. 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
  910. 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
  911. 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
  912. 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
  913. echo "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  914. echo "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\libnvvp" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  915. echo "CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
  916. echo "CUDA_PATH_V11_7=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
  917. - name: Install Cuda Toolkit 12.4
  918. if: ${{ matrix.cuda == '12.4' }}
  919. run: |
  920. mkdir -p "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4"
  921. choco install unzip -y
  922. 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"
  923. 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"
  924. 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"
  925. curl -O "https://developer.download.nvidia.com/compute/cuda/redist/libcublas/windows-x86_64/libcublas-windows-x86_64-12.4.5.8-archive.zip"
  926. 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"
  927. 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"
  928. 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"
  929. 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"
  930. 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"
  931. unzip '*.zip' -d "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4"
  932. 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
  933. 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
  934. 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
  935. 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
  936. 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
  937. 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
  938. 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
  939. 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
  940. 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
  941. echo "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  942. echo "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\libnvvp" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  943. echo "CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
  944. echo "CUDA_PATH_V12_4=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
  945. - name: Install Ninja
  946. id: install_ninja
  947. run: |
  948. choco install ninja
  949. - name: libCURL
  950. id: get_libcurl
  951. uses: ./.github/actions/windows-setup-curl
  952. - name: Build
  953. id: cmake_build
  954. shell: cmd
  955. env:
  956. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  957. run: |
  958. call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
  959. cmake -S . -B build -G "Ninja Multi-Config" ^
  960. -DLLAMA_BUILD_SERVER=ON ^
  961. -DGGML_NATIVE=OFF ^
  962. -DGGML_CUDA=ON ^
  963. -DGGML_RPC=ON ^
  964. -DCURL_LIBRARY="%CURL_PATH%/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="%CURL_PATH%/include"
  965. set /A NINJA_JOBS=%NUMBER_OF_PROCESSORS%-1
  966. cmake --build build --config Release -j %NINJA_JOBS% -t ggml
  967. cmake --build build --config Release
  968. - name: Determine tag name
  969. id: tag
  970. shell: bash
  971. run: |
  972. BUILD_NUMBER="$(git rev-list --count HEAD)"
  973. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  974. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  975. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  976. else
  977. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  978. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  979. fi
  980. - name: Pack artifacts
  981. id: pack_artifacts
  982. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  983. env:
  984. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  985. run: |
  986. cp $env:CURL_PATH\bin\libcurl-x64.dll .\build\bin\Release\libcurl-x64.dll
  987. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip .\build\bin\Release\*
  988. - name: Upload artifacts
  989. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  990. uses: actions/upload-artifact@v4
  991. with:
  992. path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip
  993. name: llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  994. - name: Copy and pack Cuda runtime
  995. if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
  996. run: |
  997. echo "Cuda install location: ${{ env.CUDA_PATH }}"
  998. $dst='.\build\bin\cudart\'
  999. robocopy "${{env.CUDA_PATH}}\bin" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
  1000. robocopy "${{env.CUDA_PATH}}\lib" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
  1001. 7z a cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip $dst\*
  1002. - name: Upload Cuda runtime
  1003. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  1004. uses: actions/upload-artifact@v4
  1005. with:
  1006. path: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  1007. name: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  1008. windows-latest-cmake-sycl:
  1009. runs-on: windows-latest
  1010. defaults:
  1011. run:
  1012. shell: bash
  1013. env:
  1014. 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
  1015. WINDOWS_DPCPP_MKL: intel.oneapi.win.cpp-dpcpp-common:intel.oneapi.win.mkl.devel:intel.oneapi.win.dnnl:intel.oneapi.win.tbb.devel
  1016. ONEAPI_ROOT: "C:/Program Files (x86)/Intel/oneAPI"
  1017. steps:
  1018. - name: Clone
  1019. id: checkout
  1020. uses: actions/checkout@v4
  1021. with:
  1022. fetch-depth: 0
  1023. - name: ccache
  1024. uses: hendrikmuhs/ccache-action@v1.2.16
  1025. with:
  1026. key: windows-latest-cmake-sycl
  1027. variant: sccache
  1028. evict-old-files: 1d
  1029. - name: Install
  1030. run: |
  1031. scripts/install-oneapi.bat $WINDOWS_BASEKIT_URL $WINDOWS_DPCPP_MKL
  1032. # TODO: add libcurl support ; we will also need to modify win-build-sycl.bat to accept user-specified args
  1033. - name: Build
  1034. id: cmake_build
  1035. run: examples/sycl/win-build-sycl.bat
  1036. - name: Determine tag name
  1037. id: tag
  1038. shell: bash
  1039. run: |
  1040. BUILD_NUMBER="$(git rev-list --count HEAD)"
  1041. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  1042. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  1043. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  1044. else
  1045. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  1046. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  1047. fi
  1048. - name: Build the release package
  1049. id: pack_artifacts
  1050. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  1051. run: |
  1052. echo "cp oneAPI running time dll files in ${{ env.ONEAPI_ROOT }} to ./build/bin"
  1053. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_sycl_blas.5.dll" ./build/bin
  1054. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_core.2.dll" ./build/bin
  1055. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_tbb_thread.2.dll" ./build/bin
  1056. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_adapter_level_zero.dll" ./build/bin
  1057. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_adapter_opencl.dll" ./build/bin
  1058. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_loader.dll" ./build/bin
  1059. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_win_proxy_loader.dll" ./build/bin
  1060. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/sycl8.dll" ./build/bin
  1061. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/svml_dispmd.dll" ./build/bin
  1062. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/libmmd.dll" ./build/bin
  1063. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/libiomp5md.dll" ./build/bin
  1064. cp "${{ env.ONEAPI_ROOT }}/dnnl/latest/bin/dnnl.dll" ./build/bin
  1065. cp "${{ env.ONEAPI_ROOT }}/tbb/latest/bin/tbb12.dll" ./build/bin
  1066. echo "cp oneAPI running time dll files to ./build/bin done"
  1067. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip ./build/bin/*
  1068. - name: Upload the release package
  1069. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  1070. uses: actions/upload-artifact@v4
  1071. with:
  1072. path: llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip
  1073. name: llama-bin-win-sycl-x64.zip
  1074. windows-latest-cmake-hip:
  1075. if: ${{ github.event.inputs.create_release != 'true' }}
  1076. runs-on: windows-latest
  1077. steps:
  1078. - name: Clone
  1079. id: checkout
  1080. uses: actions/checkout@v4
  1081. - name: Clone rocWMMA repository
  1082. id: clone_rocwmma
  1083. run: |
  1084. git clone https://github.com/rocm/rocwmma --branch rocm-6.2.4 --depth 1
  1085. - name: Install
  1086. id: depends
  1087. run: |
  1088. $ErrorActionPreference = "Stop"
  1089. write-host "Downloading AMD HIP SDK Installer"
  1090. 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"
  1091. write-host "Installing AMD HIP SDK"
  1092. Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
  1093. write-host "Completed AMD HIP SDK installation"
  1094. - name: Verify ROCm
  1095. id: verify
  1096. run: |
  1097. & 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
  1098. - name: Install ccache
  1099. uses: hendrikmuhs/ccache-action@v1.2.16
  1100. with:
  1101. key: ${{ github.job }}
  1102. evict-old-files: 1d
  1103. - name: libCURL
  1104. id: get_libcurl
  1105. uses: ./.github/actions/windows-setup-curl
  1106. - name: Build
  1107. id: cmake_build
  1108. env:
  1109. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  1110. run: |
  1111. $env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
  1112. $env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
  1113. cmake -G "Unix Makefiles" -B build -S . `
  1114. -DCMAKE_C_COMPILER="${env:HIP_PATH}\bin\clang.exe" `
  1115. -DCMAKE_CXX_COMPILER="${env:HIP_PATH}\bin\clang++.exe" `
  1116. -DCMAKE_CXX_FLAGS="-I$($PWD.Path.Replace('\', '/'))/rocwmma/library/include/" `
  1117. -DCMAKE_BUILD_TYPE=Release `
  1118. -DGGML_HIP=ON `
  1119. -DGGML_HIP_ROCWMMA_FATTN=ON `
  1120. -DGGML_RPC=ON `
  1121. -DCURL_LIBRARY="$env:CURL_PATH/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:CURL_PATH/include"
  1122. cmake --build build -j ${env:NUMBER_OF_PROCESSORS}
  1123. # TODO: reuse windows-latest-cmake-hip instead of duplicating this job
  1124. windows-latest-cmake-hip-release:
  1125. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  1126. runs-on: windows-latest
  1127. strategy:
  1128. matrix:
  1129. gpu_target: [gfx1100, gfx1101, gfx1030]
  1130. steps:
  1131. - name: Clone
  1132. id: checkout
  1133. uses: actions/checkout@v4
  1134. with:
  1135. fetch-depth: 0
  1136. - name: Clone rocWMMA repository
  1137. id: clone_rocwmma
  1138. run: |
  1139. git clone https://github.com/rocm/rocwmma --branch rocm-6.2.4 --depth 1
  1140. - name: ccache
  1141. uses: hendrikmuhs/ccache-action@v1.2.16
  1142. with:
  1143. key: windows-latest-cmake-hip-release
  1144. evict-old-files: 1d
  1145. - name: Install
  1146. id: depends
  1147. run: |
  1148. $ErrorActionPreference = "Stop"
  1149. write-host "Downloading AMD HIP SDK Installer"
  1150. 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"
  1151. write-host "Installing AMD HIP SDK"
  1152. Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
  1153. write-host "Completed AMD HIP SDK installation"
  1154. - name: Verify ROCm
  1155. id: verify
  1156. run: |
  1157. & 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
  1158. - name: libCURL
  1159. id: get_libcurl
  1160. uses: ./.github/actions/windows-setup-curl
  1161. - name: Build
  1162. id: cmake_build
  1163. env:
  1164. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  1165. run: |
  1166. $env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
  1167. $env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
  1168. cmake -G "Unix Makefiles" -B build -S . `
  1169. -DCMAKE_C_COMPILER="${env:HIP_PATH}\bin\clang.exe" `
  1170. -DCMAKE_CXX_COMPILER="${env:HIP_PATH}\bin\clang++.exe" `
  1171. -DCMAKE_CXX_FLAGS="-I$($PWD.Path.Replace('\', '/'))/rocwmma/library/include/" `
  1172. -DCMAKE_BUILD_TYPE=Release `
  1173. -DAMDGPU_TARGETS=${{ matrix.gpu_target }} `
  1174. -DGGML_HIP_ROCWMMA_FATTN=ON `
  1175. -DGGML_HIP=ON `
  1176. -DGGML_RPC=ON `
  1177. -DCURL_LIBRARY="$env:CURL_PATH/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:CURL_PATH/include"
  1178. cmake --build build -j ${env:NUMBER_OF_PROCESSORS}
  1179. md "build\bin\rocblas\library\"
  1180. cp "${env:HIP_PATH}\bin\hipblas.dll" "build\bin\"
  1181. cp "${env:HIP_PATH}\bin\rocblas.dll" "build\bin\"
  1182. cp "${env:HIP_PATH}\bin\rocblas\library\*" "build\bin\rocblas\library\"
  1183. - name: Determine tag name
  1184. id: tag
  1185. shell: bash
  1186. run: |
  1187. BUILD_NUMBER="$(git rev-list --count HEAD)"
  1188. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  1189. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  1190. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  1191. else
  1192. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  1193. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  1194. fi
  1195. - name: Pack artifacts
  1196. id: pack_artifacts
  1197. env:
  1198. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  1199. run: |
  1200. cp $env:CURL_PATH\bin\libcurl-x64.dll .\build\bin\libcurl-x64.dll
  1201. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-hip-x64-${{ matrix.gpu_target }}.zip .\build\bin\*
  1202. - name: Upload artifacts
  1203. uses: actions/upload-artifact@v4
  1204. with:
  1205. path: llama-${{ steps.tag.outputs.name }}-bin-win-hip-x64-${{ matrix.gpu_target }}.zip
  1206. name: llama-bin-win-hip-x64-${{ matrix.gpu_target }}.zip
  1207. ios-xcode-build:
  1208. runs-on: macos-latest
  1209. steps:
  1210. - name: Checkout code
  1211. uses: actions/checkout@v4
  1212. with:
  1213. fetch-depth: 0
  1214. - name: Build
  1215. id: cmake_build
  1216. run: |
  1217. sysctl -a
  1218. cmake -B build -G Xcode \
  1219. -DGGML_METAL_USE_BF16=ON \
  1220. -DGGML_METAL_EMBED_LIBRARY=ON \
  1221. -DLLAMA_CURL=OFF \
  1222. -DLLAMA_BUILD_EXAMPLES=OFF \
  1223. -DLLAMA_BUILD_TESTS=OFF \
  1224. -DLLAMA_BUILD_SERVER=OFF \
  1225. -DCMAKE_SYSTEM_NAME=iOS \
  1226. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
  1227. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  1228. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  1229. - name: xcodebuild for swift package
  1230. id: xcodebuild
  1231. run: |
  1232. ./build-xcframework.sh
  1233. - name: Build Xcode project
  1234. 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
  1235. - name: Determine tag name
  1236. id: tag
  1237. shell: bash
  1238. run: |
  1239. BUILD_NUMBER="$(git rev-list --count HEAD)"
  1240. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  1241. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  1242. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  1243. else
  1244. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  1245. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  1246. fi
  1247. - name: Pack artifacts
  1248. id: pack_artifacts
  1249. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  1250. run: |
  1251. zip --symlinks -r llama-${{ steps.tag.outputs.name }}-xcframework.zip build-apple/llama.xcframework
  1252. - name: Upload artifacts
  1253. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  1254. uses: actions/upload-artifact@v4
  1255. with:
  1256. path: llama-${{ steps.tag.outputs.name }}-xcframework.zip
  1257. name: llama-${{ steps.tag.outputs.name }}-xcframework
  1258. android-build:
  1259. runs-on: ubuntu-latest
  1260. steps:
  1261. - name: Clone
  1262. uses: actions/checkout@v4
  1263. - name: ccache
  1264. uses: hendrikmuhs/ccache-action@v1.2.16
  1265. with:
  1266. key: android-build
  1267. evict-old-files: 1d
  1268. - name: Set up JDK
  1269. uses: actions/setup-java@v3
  1270. with:
  1271. java-version: 17
  1272. distribution: zulu
  1273. - name: Setup Android SDK
  1274. uses: android-actions/setup-android@v3
  1275. with:
  1276. log-accepted-android-sdk-licenses: false
  1277. - name: Build
  1278. run: |
  1279. cd examples/llama.android
  1280. ./gradlew build --no-daemon
  1281. release:
  1282. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  1283. runs-on: ubuntu-latest
  1284. needs:
  1285. - ubuntu-cpu-cmake
  1286. - ubuntu-22-cmake-vulkan
  1287. - windows-latest-cmake
  1288. - windows-2019-cmake-cuda
  1289. - windows-latest-cmake-sycl
  1290. - windows-latest-cmake-hip-release
  1291. - macOS-latest-cmake-arm64
  1292. - macOS-latest-cmake-x64
  1293. steps:
  1294. - name: Clone
  1295. id: checkout
  1296. uses: actions/checkout@v4
  1297. with:
  1298. fetch-depth: 0
  1299. - name: ccache
  1300. uses: hendrikmuhs/ccache-action@v1.2.16
  1301. with:
  1302. key: release
  1303. evict-old-files: 1d
  1304. - name: Determine tag name
  1305. id: tag
  1306. shell: bash
  1307. run: |
  1308. BUILD_NUMBER="$(git rev-list --count HEAD)"
  1309. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  1310. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  1311. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  1312. else
  1313. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  1314. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  1315. fi
  1316. - name: Download artifacts
  1317. id: download-artifact
  1318. uses: actions/download-artifact@v4
  1319. with:
  1320. path: ./artifact
  1321. - name: Move artifacts
  1322. id: move_artifacts
  1323. run: mkdir -p ./artifact/release && mv ./artifact/*/*.zip ./artifact/release
  1324. - name: Create release
  1325. id: create_release
  1326. uses: ggml-org/action-create-release@v1
  1327. env:
  1328. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  1329. with:
  1330. tag_name: ${{ steps.tag.outputs.name }}
  1331. - name: Upload release
  1332. id: upload_release
  1333. uses: actions/github-script@v3
  1334. with:
  1335. github-token: ${{secrets.GITHUB_TOKEN}}
  1336. script: |
  1337. const path = require('path');
  1338. const fs = require('fs');
  1339. const release_id = '${{ steps.create_release.outputs.id }}';
  1340. for (let file of await fs.readdirSync('./artifact/release')) {
  1341. if (path.extname(file) === '.zip') {
  1342. console.log('uploadReleaseAsset', file);
  1343. await github.repos.uploadReleaseAsset({
  1344. owner: context.repo.owner,
  1345. repo: context.repo.repo,
  1346. release_id: release_id,
  1347. name: file,
  1348. data: await fs.readFileSync(`./artifact/release/${file}`)
  1349. });
  1350. }
  1351. }
  1352. # ubuntu-latest-gcc:
  1353. # runs-on: ubuntu-latest
  1354. #
  1355. # strategy:
  1356. # matrix:
  1357. # build: [Debug, Release]
  1358. #
  1359. # steps:
  1360. # - name: Clone
  1361. # uses: actions/checkout@v4
  1362. #
  1363. # - name: Dependencies
  1364. # run: |
  1365. # sudo apt-get update
  1366. # sudo apt-get install build-essential
  1367. # sudo apt-get install cmake
  1368. #
  1369. # - name: Configure
  1370. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1371. #
  1372. # - name: Build
  1373. # run: |
  1374. # make
  1375. #
  1376. # ubuntu-latest-clang:
  1377. # runs-on: ubuntu-latest
  1378. #
  1379. # strategy:
  1380. # matrix:
  1381. # build: [Debug, Release]
  1382. #
  1383. # steps:
  1384. # - name: Clone
  1385. # uses: actions/checkout@v4
  1386. #
  1387. # - name: Dependencies
  1388. # run: |
  1389. # sudo apt-get update
  1390. # sudo apt-get install build-essential
  1391. # sudo apt-get install cmake
  1392. #
  1393. # - name: Configure
  1394. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
  1395. #
  1396. # - name: Build
  1397. # run: |
  1398. # make
  1399. #
  1400. # ubuntu-latest-gcc-sanitized:
  1401. # runs-on: ubuntu-latest
  1402. #
  1403. # strategy:
  1404. # matrix:
  1405. # sanitizer: [ADDRESS, THREAD, UNDEFINED]
  1406. #
  1407. # steps:
  1408. # - name: Clone
  1409. # uses: actions/checkout@v4
  1410. #
  1411. # - name: Dependencies
  1412. # run: |
  1413. # sudo apt-get update
  1414. # sudo apt-get install build-essential
  1415. # sudo apt-get install cmake
  1416. #
  1417. # - name: Configure
  1418. # run: cmake . -DCMAKE_BUILD_TYPE=Debug -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON
  1419. #
  1420. # - name: Build
  1421. # run: |
  1422. # make
  1423. #
  1424. # windows:
  1425. # runs-on: windows-latest
  1426. #
  1427. # strategy:
  1428. # matrix:
  1429. # build: [Release]
  1430. # arch: [Win32, x64]
  1431. # include:
  1432. # - arch: Win32
  1433. # s2arc: x86
  1434. # - arch: x64
  1435. # s2arc: x64
  1436. #
  1437. # steps:
  1438. # - name: Clone
  1439. # uses: actions/checkout@v4
  1440. #
  1441. # - name: Add msbuild to PATH
  1442. # uses: microsoft/setup-msbuild@v1
  1443. #
  1444. # - name: Configure
  1445. # run: >
  1446. # cmake -S . -B ./build -A ${{ matrix.arch }}
  1447. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1448. #
  1449. # - name: Build
  1450. # run: |
  1451. # cd ./build
  1452. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  1453. #
  1454. # - name: Upload binaries
  1455. # uses: actions/upload-artifact@v4
  1456. # with:
  1457. # name: llama-bin-${{ matrix.arch }}
  1458. # path: build/bin/${{ matrix.build }}
  1459. #
  1460. # windows-blas:
  1461. # runs-on: windows-latest
  1462. #
  1463. # strategy:
  1464. # matrix:
  1465. # build: [Release]
  1466. # arch: [Win32, x64]
  1467. # blas: [ON]
  1468. # include:
  1469. # - arch: Win32
  1470. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x86.zip
  1471. # s2arc: x86
  1472. # - arch: x64
  1473. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x64.zip
  1474. # s2arc: x64
  1475. #
  1476. # steps:
  1477. # - name: Clone
  1478. # uses: actions/checkout@v4
  1479. #
  1480. # - name: Add msbuild to PATH
  1481. # uses: microsoft/setup-msbuild@v1
  1482. #
  1483. # - name: Fetch OpenBLAS
  1484. # if: matrix.blas == 'ON'
  1485. # run: |
  1486. # C:/msys64/usr/bin/wget.exe -qO blas.zip ${{ matrix.obzip }}
  1487. # 7z x blas.zip -oblas -y
  1488. # copy blas/include/cblas.h .
  1489. # copy blas/include/openblas_config.h .
  1490. # echo "blasdir=$env:GITHUB_WORKSPACE/blas" >> $env:GITHUB_ENV
  1491. #
  1492. # - name: Configure
  1493. # run: >
  1494. # cmake -S . -B ./build -A ${{ matrix.arch }}
  1495. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1496. # -DLLAMA_SUPPORT_OPENBLAS=${{ matrix.blas }}
  1497. # -DCMAKE_LIBRARY_PATH="$env:blasdir/lib"
  1498. #
  1499. # - name: Build
  1500. # run: |
  1501. # cd ./build
  1502. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  1503. #
  1504. # - name: Copy libopenblas.dll
  1505. # if: matrix.blas == 'ON'
  1506. # run: copy "$env:blasdir/bin/libopenblas.dll" build/bin/${{ matrix.build }}
  1507. #
  1508. # - name: Upload binaries
  1509. # if: matrix.blas == 'ON'
  1510. # uses: actions/upload-artifact@v4
  1511. # with:
  1512. # name: llama-blas-bin-${{ matrix.arch }}
  1513. # path: build/bin/${{ matrix.build }}
  1514. #
  1515. # emscripten:
  1516. # runs-on: ubuntu-latest
  1517. #
  1518. # strategy:
  1519. # matrix:
  1520. # build: [Release]
  1521. #
  1522. # steps:
  1523. # - name: Clone
  1524. # uses: actions/checkout@v4
  1525. #
  1526. # - name: Dependencies
  1527. # run: |
  1528. # wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz
  1529. # tar -xvf master.tar.gz
  1530. # emsdk-master/emsdk update
  1531. # emsdk-master/emsdk install latest
  1532. # emsdk-master/emsdk activate latest
  1533. #
  1534. # - name: Configure
  1535. # run: echo "tmp"
  1536. #
  1537. # - name: Build
  1538. # run: |
  1539. # pushd emsdk-master
  1540. # source ./emsdk_env.sh
  1541. # popd
  1542. # emcmake cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1543. # make
  1544. openEuler-latest-cmake-cann:
  1545. if: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'Ascend NPU') }}
  1546. defaults:
  1547. run:
  1548. shell: bash -el {0}
  1549. strategy:
  1550. matrix:
  1551. arch: [x86, aarch64]
  1552. cann:
  1553. - '8.1.RC1.alpha001-910b-openeuler22.03-py3.10'
  1554. device:
  1555. - 'ascend910b3'
  1556. build:
  1557. - 'Release'
  1558. runs-on: ${{ matrix.arch == 'aarch64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
  1559. container: ascendai/cann:${{ matrix.cann }}
  1560. steps:
  1561. - name: Checkout
  1562. uses: actions/checkout@v4
  1563. - name: Dependencies
  1564. run: |
  1565. yum update -y
  1566. yum install -y git gcc gcc-c++ make cmake libcurl-devel
  1567. - name: Build
  1568. run: |
  1569. export LD_LIBRARY_PATH=${ASCEND_TOOLKIT_HOME}/lib64:${ASCEND_TOOLKIT_HOME}/$(uname -m)-linux/devlib/:${LD_LIBRARY_PATH}
  1570. cmake -S . -B build \
  1571. -DCMAKE_BUILD_TYPE=${{ matrix.build }} \
  1572. -DGGML_CANN=on \
  1573. -DSOC_TYPE=${{ matrix.device }}
  1574. cmake --build build -j $(nproc)