1
0

build.yml 65 KB

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