build.yml 61 KB

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