build.yml 63 KB

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