build.yml 49 KB

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