build.yml 65 KB

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