build.yml 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402
  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_HIPBLAS=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_HIPBLAS=ON
  352. cmake --build build2 --config Release -j $(nproc)
  353. ubuntu-22-cmake-sycl:
  354. runs-on: ubuntu-22.04
  355. continue-on-error: true
  356. steps:
  357. - uses: actions/checkout@v4
  358. - name: add oneAPI to apt
  359. shell: bash
  360. run: |
  361. cd /tmp
  362. wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  363. sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  364. rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  365. sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
  366. - name: install oneAPI dpcpp compiler
  367. shell: bash
  368. run: |
  369. sudo apt update
  370. sudo apt install intel-oneapi-compiler-dpcpp-cpp
  371. - name: install oneAPI MKL library
  372. shell: bash
  373. run: |
  374. sudo apt install intel-oneapi-mkl-devel
  375. - name: Clone
  376. id: checkout
  377. uses: actions/checkout@v4
  378. - name: Build
  379. id: cmake_build
  380. run: |
  381. source /opt/intel/oneapi/setvars.sh
  382. mkdir build
  383. cd build
  384. cmake -DGGML_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx ..
  385. cmake --build . --config Release -j $(nproc)
  386. ubuntu-22-cmake-sycl-fp16:
  387. runs-on: ubuntu-22.04
  388. continue-on-error: true
  389. steps:
  390. - uses: actions/checkout@v4
  391. - name: add oneAPI to apt
  392. shell: bash
  393. run: |
  394. cd /tmp
  395. wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  396. sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  397. rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
  398. sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
  399. - name: install oneAPI dpcpp compiler
  400. shell: bash
  401. run: |
  402. sudo apt update
  403. sudo apt install intel-oneapi-compiler-dpcpp-cpp
  404. - name: install oneAPI MKL library
  405. shell: bash
  406. run: |
  407. sudo apt install intel-oneapi-mkl-devel
  408. - name: Clone
  409. id: checkout
  410. uses: actions/checkout@v4
  411. - name: Build
  412. id: cmake_build
  413. run: |
  414. source /opt/intel/oneapi/setvars.sh
  415. mkdir build
  416. cd build
  417. cmake -DGGML_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DGGML_SYCL_F16=ON ..
  418. cmake --build . --config Release -j $(nproc)
  419. # TODO: build with GGML_NO_METAL because test-backend-ops fail on "Apple Paravirtual device" and I don't know
  420. # how to debug it.
  421. # ref: https://github.com/ggerganov/llama.cpp/actions/runs/7131777249/job/19420981052#step:5:1124
  422. macOS-latest-make:
  423. runs-on: macos-latest
  424. steps:
  425. - name: Clone
  426. id: checkout
  427. uses: actions/checkout@v4
  428. - name: Dependencies
  429. id: depends
  430. continue-on-error: true
  431. run: |
  432. brew update
  433. - name: Build
  434. id: make_build
  435. env:
  436. LLAMA_FATAL_WARNINGS: 1
  437. run: |
  438. GGML_NO_METAL=1 make -j $(sysctl -n hw.logicalcpu)
  439. - name: Test
  440. id: make_test
  441. run: |
  442. GGML_NO_METAL=1 make tests -j $(sysctl -n hw.logicalcpu)
  443. GGML_NO_METAL=1 make test -j $(sysctl -n hw.logicalcpu)
  444. # TODO: build with GGML_METAL=OFF because test-backend-ops fail on "Apple Paravirtual device" and I don't know
  445. # how to debug it.
  446. # ref: https://github.com/ggerganov/llama.cpp/actions/runs/7132125951/job/19422043567?pr=4359#step:5:6584
  447. # would be great if we fix these
  448. macOS-latest-cmake:
  449. runs-on: macos-latest
  450. steps:
  451. - name: Clone
  452. id: checkout
  453. uses: actions/checkout@v4
  454. - name: Dependencies
  455. id: depends
  456. continue-on-error: true
  457. run: |
  458. brew update
  459. - name: Build
  460. id: cmake_build
  461. run: |
  462. sysctl -a
  463. mkdir build
  464. cd build
  465. cmake -DLLAMA_FATAL_WARNINGS=ON -DGGML_METAL=OFF ..
  466. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu)
  467. - name: Test
  468. id: cmake_test
  469. run: |
  470. cd build
  471. ctest -L main --verbose --timeout 900
  472. macOS-latest-cmake-ios:
  473. runs-on: macos-latest
  474. steps:
  475. - name: Clone
  476. id: checkout
  477. uses: actions/checkout@v4
  478. - name: Dependencies
  479. id: depends
  480. continue-on-error: true
  481. run: |
  482. brew update
  483. - name: Build
  484. id: cmake_build
  485. run: |
  486. sysctl -a
  487. mkdir build
  488. cd build
  489. cmake -G Xcode .. \
  490. -DGGML_METAL_USE_BF16=ON \
  491. -DGGML_METAL_EMBED_LIBRARY=ON \
  492. -DLLAMA_BUILD_EXAMPLES=OFF \
  493. -DLLAMA_BUILD_TESTS=OFF \
  494. -DLLAMA_BUILD_SERVER=OFF \
  495. -DCMAKE_SYSTEM_NAME=iOS \
  496. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
  497. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  498. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  499. macOS-latest-cmake-tvos:
  500. runs-on: macos-latest
  501. steps:
  502. - name: Clone
  503. id: checkout
  504. uses: actions/checkout@v4
  505. - name: Dependencies
  506. id: depends
  507. continue-on-error: true
  508. run: |
  509. brew update
  510. - name: Build
  511. id: cmake_build
  512. run: |
  513. sysctl -a
  514. mkdir build
  515. cd build
  516. cmake -G Xcode .. \
  517. -DGGML_METAL_USE_BF16=ON \
  518. -DGGML_METAL_EMBED_LIBRARY=ON \
  519. -DLLAMA_BUILD_EXAMPLES=OFF \
  520. -DLLAMA_BUILD_TESTS=OFF \
  521. -DLLAMA_BUILD_SERVER=OFF \
  522. -DCMAKE_SYSTEM_NAME=tvOS \
  523. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
  524. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  525. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  526. macOS-latest-swift:
  527. runs-on: macos-latest
  528. strategy:
  529. matrix:
  530. destination: ['generic/platform=macOS', 'generic/platform=iOS', 'generic/platform=tvOS']
  531. steps:
  532. - name: Clone
  533. id: checkout
  534. uses: actions/checkout@v4
  535. - name: Dependencies
  536. id: depends
  537. continue-on-error: true
  538. run: |
  539. brew update
  540. - name: xcodebuild for swift package
  541. id: xcodebuild
  542. run: |
  543. xcodebuild -scheme llama -destination "${{ matrix.destination }}"
  544. - name: Build Swift Example
  545. id: make_build_swift_example
  546. run: |
  547. make swift
  548. windows-msys2:
  549. runs-on: windows-latest
  550. strategy:
  551. fail-fast: false
  552. matrix:
  553. include:
  554. - { sys: UCRT64, env: ucrt-x86_64, build: Release }
  555. - { sys: CLANG64, env: clang-x86_64, build: Release }
  556. steps:
  557. - name: Clone
  558. uses: actions/checkout@v4
  559. - name: Setup ${{ matrix.sys }}
  560. uses: msys2/setup-msys2@v2
  561. with:
  562. update: true
  563. msystem: ${{matrix.sys}}
  564. install: >-
  565. base-devel
  566. mingw-w64-${{matrix.env}}-toolchain
  567. mingw-w64-${{matrix.env}}-cmake
  568. mingw-w64-${{matrix.env}}-openblas
  569. - name: Build using make
  570. shell: msys2 {0}
  571. run: |
  572. make -j $(nproc)
  573. - name: Clean after building using make
  574. shell: msys2 {0}
  575. run: |
  576. make clean
  577. - name: Build using make w/ OpenBLAS
  578. shell: msys2 {0}
  579. run: |
  580. make GGML_OPENBLAS=1 -j $(nproc)
  581. - name: Build using CMake
  582. shell: msys2 {0}
  583. run: |
  584. cmake -B build
  585. cmake --build build --config ${{ matrix.build }} -j $(nproc)
  586. - name: Clean after building using CMake
  587. shell: msys2 {0}
  588. run: |
  589. rm -rf build
  590. - name: Build using CMake w/ OpenBLAS
  591. shell: msys2 {0}
  592. run: |
  593. cmake -B build -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS
  594. cmake --build build --config ${{ matrix.build }} -j $(nproc)
  595. windows-latest-cmake:
  596. runs-on: windows-2019
  597. env:
  598. OPENBLAS_VERSION: 0.3.23
  599. SDE_VERSION: 9.33.0-2024-01-07
  600. VULKAN_VERSION: 1.3.261.1
  601. strategy:
  602. matrix:
  603. include:
  604. - build: 'noavx-x64'
  605. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_FMA=OFF -DBUILD_SHARED_LIBS=ON'
  606. - build: 'avx2-x64'
  607. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DBUILD_SHARED_LIBS=ON'
  608. - build: 'avx-x64'
  609. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_AVX2=OFF -DBUILD_SHARED_LIBS=ON'
  610. - build: 'avx512-x64'
  611. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_AVX512=ON -DBUILD_SHARED_LIBS=ON'
  612. - build: 'openblas-x64'
  613. 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"'
  614. - build: 'kompute-x64'
  615. 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'
  616. - build: 'vulkan-x64'
  617. defines: '-DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DGGML_VULKAN=ON -DBUILD_SHARED_LIBS=ON'
  618. - build: 'llvm-arm64'
  619. 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'
  620. - build: 'msvc-arm64'
  621. 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'
  622. steps:
  623. - name: Clone
  624. id: checkout
  625. uses: actions/checkout@v4
  626. with:
  627. fetch-depth: 0
  628. - name: Clone Kompute submodule
  629. id: clone_kompute
  630. if: ${{ matrix.build == 'kompute-x64' }}
  631. run: |
  632. git submodule update --init ggml/src/kompute
  633. - name: Download OpenBLAS
  634. id: get_openblas
  635. if: ${{ matrix.build == 'openblas-x64' }}
  636. run: |
  637. 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"
  638. curl.exe -o $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt -L "https://github.com/xianyi/OpenBLAS/raw/v${env:OPENBLAS_VERSION}/LICENSE"
  639. mkdir $env:RUNNER_TEMP/openblas
  640. tar.exe -xvf $env:RUNNER_TEMP/openblas.zip -C $env:RUNNER_TEMP/openblas
  641. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  642. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  643. $lib = $(join-path $msvc 'bin\Hostx64\x64\lib.exe')
  644. & $lib /machine:x64 "/def:${env:RUNNER_TEMP}/openblas/lib/libopenblas.def" "/out:${env:RUNNER_TEMP}/openblas/lib/openblas.lib" /name:openblas.dll
  645. - name: Install Vulkan SDK
  646. id: get_vulkan
  647. if: ${{ matrix.build == 'kompute-x64' || matrix.build == 'vulkan-x64' }}
  648. run: |
  649. 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"
  650. & "$env:RUNNER_TEMP\VulkanSDK-Installer.exe" --accept-licenses --default-answer --confirm-command install
  651. Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${env:VULKAN_VERSION}"
  652. Add-Content $env:GITHUB_PATH "C:\VulkanSDK\${env:VULKAN_VERSION}\bin"
  653. - name: Install Ninja
  654. id: install_ninja
  655. run: |
  656. choco install ninja
  657. - name: Build
  658. id: cmake_build
  659. run: |
  660. cmake -S . -B build ${{ matrix.defines }}
  661. cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS}
  662. - name: Add libopenblas.dll
  663. id: add_libopenblas_dll
  664. if: ${{ matrix.build == 'openblas-x64' }}
  665. run: |
  666. cp $env:RUNNER_TEMP/openblas/bin/libopenblas.dll ./build/bin/Release/openblas.dll
  667. cp $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt ./build/bin/Release/OpenBLAS-${env:OPENBLAS_VERSION}.txt
  668. - name: Check AVX512F support
  669. id: check_avx512f
  670. if: ${{ matrix.build == 'avx512-x64' }}
  671. continue-on-error: true
  672. run: |
  673. cd build
  674. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  675. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  676. $cl = $(join-path $msvc 'bin\Hostx64\x64\cl.exe')
  677. echo 'int main(void){unsigned int a[4];__cpuid(a,7);return !(a[1]&65536);}' >> avx512f.c
  678. & $cl /O2 /GS- /kernel avx512f.c /link /nodefaultlib /entry:main
  679. .\avx512f.exe && echo "AVX512F: YES" && ( echo HAS_AVX512F=1 >> $env:GITHUB_ENV ) || echo "AVX512F: NO"
  680. - name: Test
  681. id: cmake_test
  682. # not all machines have native AVX-512
  683. 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') }}
  684. run: |
  685. cd build
  686. ctest -L main -C Release --verbose --timeout 900
  687. - name: Test (Intel SDE)
  688. id: cmake_test_sde
  689. if: ${{ matrix.build == 'avx512-x64' && env.HAS_AVX512F == '0' }} # use Intel SDE for AVX-512 emulation
  690. run: |
  691. curl.exe -o $env:RUNNER_TEMP/sde.tar.xz -L "https://downloadmirror.intel.com/813591/sde-external-${env:SDE_VERSION}-win.tar.xz"
  692. # for some weird reason windows tar doesn't like sde tar.xz
  693. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar.xz
  694. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar
  695. $sde = $(join-path $env:RUNNER_TEMP sde-external-${env:SDE_VERSION}-win/sde.exe)
  696. cd build
  697. $env:LLAMA_SKIP_TESTS_SLOW_ON_EMULATOR = 1
  698. & $sde -future -- ctest -L main -C Release --verbose --timeout 900
  699. - name: Determine tag name
  700. id: tag
  701. shell: bash
  702. run: |
  703. BUILD_NUMBER="$(git rev-list --count HEAD)"
  704. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  705. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  706. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  707. else
  708. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  709. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  710. fi
  711. - name: Pack artifacts
  712. id: pack_artifacts
  713. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  714. run: |
  715. Copy-Item LICENSE .\build\bin\Release\llama.cpp.txt
  716. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip .\build\bin\Release\*
  717. - name: Upload artifacts
  718. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  719. uses: actions/upload-artifact@v4
  720. with:
  721. path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip
  722. name: llama-bin-win-${{ matrix.build }}.zip
  723. windows-latest-cmake-cuda:
  724. runs-on: windows-2019
  725. strategy:
  726. matrix:
  727. cuda: ['12.2.0', '11.7.1']
  728. build: ['cuda']
  729. steps:
  730. - name: Clone
  731. id: checkout
  732. uses: actions/checkout@v4
  733. with:
  734. fetch-depth: 0
  735. - name: Install CUDA toolkit
  736. id: cuda-toolkit
  737. uses: Jimver/cuda-toolkit@v0.2.15
  738. with:
  739. cuda: ${{ matrix.cuda }}
  740. method: 'network'
  741. sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]'
  742. - name: Build
  743. id: cmake_build
  744. run: |
  745. mkdir build
  746. cd build
  747. cmake .. -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_CUDA=ON -DBUILD_SHARED_LIBS=ON -DGGML_RPC=ON
  748. cmake --build . --config Release -j $((${env:NUMBER_OF_PROCESSORS} - 1)) -t ggml
  749. cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS}
  750. - name: Determine tag name
  751. id: tag
  752. shell: bash
  753. run: |
  754. BUILD_NUMBER="$(git rev-list --count HEAD)"
  755. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  756. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  757. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  758. else
  759. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  760. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  761. fi
  762. - name: Pack artifacts
  763. id: pack_artifacts
  764. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  765. run: |
  766. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip .\build\bin\Release\*
  767. - name: Upload artifacts
  768. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  769. uses: actions/upload-artifact@v4
  770. with:
  771. path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip
  772. name: llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  773. - name: Copy and pack Cuda runtime
  774. run: |
  775. echo "Cuda install location: ${{steps.cuda-toolkit.outputs.CUDA_PATH}}"
  776. $dst='.\build\bin\cudart\'
  777. robocopy "${{steps.cuda-toolkit.outputs.CUDA_PATH}}\bin" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
  778. 7z a cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip $dst\*
  779. - name: Upload Cuda runtime
  780. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  781. uses: actions/upload-artifact@v4
  782. with:
  783. path: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  784. name: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  785. windows-latest-cmake-sycl:
  786. runs-on: windows-latest
  787. defaults:
  788. run:
  789. shell: bash
  790. env:
  791. WINDOWS_BASEKIT_URL: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/7dff44ba-e3af-4448-841c-0d616c8da6e7/w_BaseKit_p_2024.1.0.595_offline.exe
  792. WINDOWS_DPCPP_MKL: intel.oneapi.win.cpp-dpcpp-common:intel.oneapi.win.mkl.devel
  793. ONEAPI_ROOT: "C:/Program Files (x86)/Intel/oneAPI"
  794. steps:
  795. - name: Clone
  796. id: checkout
  797. uses: actions/checkout@v4
  798. with:
  799. fetch-depth: 0
  800. - name: Install
  801. run: scripts/install-oneapi.bat $WINDOWS_BASEKIT_URL $WINDOWS_DPCPP_MKL
  802. - name: Build
  803. id: cmake_build
  804. run: examples/sycl/win-build-sycl.bat
  805. - name: Determine tag name
  806. id: tag
  807. shell: bash
  808. run: |
  809. BUILD_NUMBER="$(git rev-list --count HEAD)"
  810. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  811. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  812. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  813. else
  814. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  815. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  816. fi
  817. - name: Pack artifacts
  818. id: pack_artifacts
  819. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  820. run: |
  821. echo "cp oneAPI running time dll files in ${{ env.ONEAPI_ROOT }} to ./build/bin"
  822. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_sycl_blas.4.dll" ./build/bin
  823. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_core.2.dll" ./build/bin
  824. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_tbb_thread.2.dll" ./build/bin
  825. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/pi_win_proxy_loader.dll" ./build/bin
  826. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/pi_level_zero.dll" ./build/bin
  827. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/sycl7.dll" ./build/bin
  828. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/svml_dispmd.dll" ./build/bin
  829. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/libmmd.dll" ./build/bin
  830. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/libiomp5md.dll" ./build/bin
  831. echo "cp oneAPI running time dll files to ./build/bin done"
  832. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip ./build/bin/*
  833. - name: Upload artifacts
  834. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  835. uses: actions/upload-artifact@v4
  836. with:
  837. path: llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip
  838. name: llama-bin-win-sycl-x64.zip
  839. windows-latest-cmake-hip:
  840. if: ${{ github.event.inputs.create_release != 'true' }}
  841. runs-on: windows-latest
  842. steps:
  843. - name: Clone
  844. id: checkout
  845. uses: actions/checkout@v4
  846. - name: Install
  847. id: depends
  848. run: |
  849. $ErrorActionPreference = "Stop"
  850. write-host "Downloading AMD HIP SDK Installer"
  851. 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"
  852. write-host "Installing AMD HIP SDK"
  853. Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
  854. write-host "Completed AMD HIP SDK installation"
  855. - name: Verify ROCm
  856. id: verify
  857. run: |
  858. & 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
  859. - name: Build
  860. id: cmake_build
  861. run: |
  862. $env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
  863. $env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
  864. 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_HIPBLAS=ON -DCMAKE_BUILD_TYPE=Release -DGGML_RPC=ON
  865. cmake --build build -j ${env:NUMBER_OF_PROCESSORS}
  866. windows-latest-cmake-hip-release:
  867. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  868. runs-on: windows-latest
  869. strategy:
  870. matrix:
  871. gpu_target: [gfx1100, gfx1101, gfx1030]
  872. steps:
  873. - name: Clone
  874. id: checkout
  875. uses: actions/checkout@v4
  876. - name: Install
  877. id: depends
  878. run: |
  879. $ErrorActionPreference = "Stop"
  880. write-host "Downloading AMD HIP SDK Installer"
  881. 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"
  882. write-host "Installing AMD HIP SDK"
  883. Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
  884. write-host "Completed AMD HIP SDK installation"
  885. - name: Verify ROCm
  886. id: verify
  887. run: |
  888. & 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
  889. - name: Build
  890. id: cmake_build
  891. run: |
  892. $env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
  893. $env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
  894. 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_HIPBLAS=ON -DCMAKE_BUILD_TYPE=Release -DAMDGPU_TARGETS=${{ matrix.gpu_target }} -DGGML_RPC=ON
  895. cmake --build build -j ${env:NUMBER_OF_PROCESSORS}
  896. md "build\bin\rocblas\library\"
  897. cp "${env:HIP_PATH}\bin\hipblas.dll" "build\bin\"
  898. cp "${env:HIP_PATH}\bin\rocblas.dll" "build\bin\"
  899. cp "${env:HIP_PATH}\bin\rocblas\library\*" "build\bin\rocblas\library\"
  900. - name: Determine tag name
  901. id: tag
  902. shell: bash
  903. run: |
  904. BUILD_NUMBER="$(git rev-list --count HEAD)"
  905. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  906. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  907. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  908. else
  909. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  910. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  911. fi
  912. - name: Pack artifacts
  913. id: pack_artifacts
  914. run: |
  915. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-hip-x64-${{ matrix.gpu_target }}.zip .\build\bin\*
  916. - name: Upload artifacts
  917. uses: actions/upload-artifact@v4
  918. with:
  919. path: llama-${{ steps.tag.outputs.name }}-bin-win-hip-x64-${{ matrix.gpu_target }}.zip
  920. name: llama-bin-win-hip-x64-${{ matrix.gpu_target }}.zip
  921. ios-xcode-build:
  922. runs-on: macos-latest
  923. steps:
  924. - name: Checkout code
  925. uses: actions/checkout@v4
  926. - name: Build Xcode project
  927. 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
  928. android-build:
  929. runs-on: ubuntu-latest
  930. steps:
  931. - name: Clone
  932. uses: actions/checkout@v4
  933. - name: Set up JDK
  934. uses: actions/setup-java@v3
  935. with:
  936. java-version: 17
  937. distribution: zulu
  938. - name: Setup Android SDK
  939. uses: android-actions/setup-android@v3
  940. with:
  941. log-accepted-android-sdk-licenses: false
  942. - name: Build
  943. run: |
  944. cd examples/llama.android
  945. ./gradlew build --no-daemon
  946. # freeBSD-latest:
  947. # runs-on: macos-12
  948. # steps:
  949. # - name: Clone
  950. # uses: actions/checkout@v4
  951. #
  952. # - name: Build
  953. # uses: cross-platform-actions/action@v0.19.0
  954. # with:
  955. # operating_system: freebsd
  956. # version: '13.2'
  957. # hypervisor: 'qemu'
  958. # run: |
  959. # sudo pkg update
  960. # sudo pkg install -y gmake automake autoconf pkgconf llvm15 openblas
  961. # gmake CC=/usr/local/bin/clang15 CXX=/usr/local/bin/clang++15 -j `sysctl -n hw.ncpu`
  962. release:
  963. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  964. runs-on: ubuntu-latest
  965. needs:
  966. - ubuntu-focal-make
  967. - ubuntu-latest-cmake
  968. - macOS-latest-make
  969. - macOS-latest-cmake
  970. - windows-latest-cmake
  971. - windows-latest-cmake-cuda
  972. - windows-latest-cmake-hip-release
  973. - macOS-latest-cmake-arm64
  974. - macOS-latest-cmake-x64
  975. steps:
  976. - name: Clone
  977. id: checkout
  978. uses: actions/checkout@v4
  979. with:
  980. fetch-depth: 0
  981. - name: Determine tag name
  982. id: tag
  983. shell: bash
  984. run: |
  985. BUILD_NUMBER="$(git rev-list --count HEAD)"
  986. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  987. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  988. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  989. else
  990. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  991. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  992. fi
  993. - name: Download artifacts
  994. id: download-artifact
  995. uses: actions/download-artifact@v4
  996. with:
  997. path: ./artifact
  998. - name: Move artifacts
  999. id: move_artifacts
  1000. run: mkdir -p ./artifact/release && mv ./artifact/*/*.zip ./artifact/release
  1001. - name: Create release
  1002. id: create_release
  1003. uses: anzz1/action-create-release@v1
  1004. env:
  1005. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  1006. with:
  1007. tag_name: ${{ steps.tag.outputs.name }}
  1008. - name: Upload release
  1009. id: upload_release
  1010. uses: actions/github-script@v3
  1011. with:
  1012. github-token: ${{secrets.GITHUB_TOKEN}}
  1013. script: |
  1014. const path = require('path');
  1015. const fs = require('fs');
  1016. const release_id = '${{ steps.create_release.outputs.id }}';
  1017. for (let file of await fs.readdirSync('./artifact/release')) {
  1018. if (path.extname(file) === '.zip') {
  1019. console.log('uploadReleaseAsset', file);
  1020. await github.repos.uploadReleaseAsset({
  1021. owner: context.repo.owner,
  1022. repo: context.repo.repo,
  1023. release_id: release_id,
  1024. name: file,
  1025. data: await fs.readFileSync(`./artifact/release/${file}`)
  1026. });
  1027. }
  1028. }
  1029. # ubuntu-latest-gcc:
  1030. # runs-on: ubuntu-latest
  1031. #
  1032. # strategy:
  1033. # matrix:
  1034. # build: [Debug, Release]
  1035. #
  1036. # steps:
  1037. # - name: Clone
  1038. # uses: actions/checkout@v4
  1039. #
  1040. # - name: Dependencies
  1041. # run: |
  1042. # sudo apt-get update
  1043. # sudo apt-get install build-essential
  1044. # sudo apt-get install cmake
  1045. #
  1046. # - name: Configure
  1047. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1048. #
  1049. # - name: Build
  1050. # run: |
  1051. # make
  1052. #
  1053. # ubuntu-latest-clang:
  1054. # runs-on: ubuntu-latest
  1055. #
  1056. # strategy:
  1057. # matrix:
  1058. # build: [Debug, Release]
  1059. #
  1060. # steps:
  1061. # - name: Clone
  1062. # uses: actions/checkout@v4
  1063. #
  1064. # - name: Dependencies
  1065. # run: |
  1066. # sudo apt-get update
  1067. # sudo apt-get install build-essential
  1068. # sudo apt-get install cmake
  1069. #
  1070. # - name: Configure
  1071. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
  1072. #
  1073. # - name: Build
  1074. # run: |
  1075. # make
  1076. #
  1077. # ubuntu-latest-gcc-sanitized:
  1078. # runs-on: ubuntu-latest
  1079. #
  1080. # strategy:
  1081. # matrix:
  1082. # sanitizer: [ADDRESS, THREAD, UNDEFINED]
  1083. #
  1084. # steps:
  1085. # - name: Clone
  1086. # uses: actions/checkout@v4
  1087. #
  1088. # - name: Dependencies
  1089. # run: |
  1090. # sudo apt-get update
  1091. # sudo apt-get install build-essential
  1092. # sudo apt-get install cmake
  1093. #
  1094. # - name: Configure
  1095. # run: cmake . -DCMAKE_BUILD_TYPE=Debug -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON
  1096. #
  1097. # - name: Build
  1098. # run: |
  1099. # make
  1100. #
  1101. # windows:
  1102. # runs-on: windows-latest
  1103. #
  1104. # strategy:
  1105. # matrix:
  1106. # build: [Release]
  1107. # arch: [Win32, x64]
  1108. # include:
  1109. # - arch: Win32
  1110. # s2arc: x86
  1111. # - arch: x64
  1112. # s2arc: x64
  1113. #
  1114. # steps:
  1115. # - name: Clone
  1116. # uses: actions/checkout@v4
  1117. #
  1118. # - name: Add msbuild to PATH
  1119. # uses: microsoft/setup-msbuild@v1
  1120. #
  1121. # - name: Configure
  1122. # run: >
  1123. # cmake -S . -B ./build -A ${{ matrix.arch }}
  1124. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1125. #
  1126. # - name: Build
  1127. # run: |
  1128. # cd ./build
  1129. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  1130. #
  1131. # - name: Upload binaries
  1132. # uses: actions/upload-artifact@v4
  1133. # with:
  1134. # name: llama-bin-${{ matrix.arch }}
  1135. # path: build/bin/${{ matrix.build }}
  1136. #
  1137. # windows-blas:
  1138. # runs-on: windows-latest
  1139. #
  1140. # strategy:
  1141. # matrix:
  1142. # build: [Release]
  1143. # arch: [Win32, x64]
  1144. # blas: [ON]
  1145. # include:
  1146. # - arch: Win32
  1147. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x86.zip
  1148. # s2arc: x86
  1149. # - arch: x64
  1150. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x64.zip
  1151. # s2arc: x64
  1152. #
  1153. # steps:
  1154. # - name: Clone
  1155. # uses: actions/checkout@v4
  1156. #
  1157. # - name: Add msbuild to PATH
  1158. # uses: microsoft/setup-msbuild@v1
  1159. #
  1160. # - name: Fetch OpenBLAS
  1161. # if: matrix.blas == 'ON'
  1162. # run: |
  1163. # C:/msys64/usr/bin/wget.exe -qO blas.zip ${{ matrix.obzip }}
  1164. # 7z x blas.zip -oblas -y
  1165. # copy blas/include/cblas.h .
  1166. # copy blas/include/openblas_config.h .
  1167. # echo "blasdir=$env:GITHUB_WORKSPACE/blas" >> $env:GITHUB_ENV
  1168. #
  1169. # - name: Configure
  1170. # run: >
  1171. # cmake -S . -B ./build -A ${{ matrix.arch }}
  1172. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1173. # -DLLAMA_SUPPORT_OPENBLAS=${{ matrix.blas }}
  1174. # -DCMAKE_LIBRARY_PATH="$env:blasdir/lib"
  1175. #
  1176. # - name: Build
  1177. # run: |
  1178. # cd ./build
  1179. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  1180. #
  1181. # - name: Copy libopenblas.dll
  1182. # if: matrix.blas == 'ON'
  1183. # run: copy "$env:blasdir/bin/libopenblas.dll" build/bin/${{ matrix.build }}
  1184. #
  1185. # - name: Upload binaries
  1186. # if: matrix.blas == 'ON'
  1187. # uses: actions/upload-artifact@v4
  1188. # with:
  1189. # name: llama-blas-bin-${{ matrix.arch }}
  1190. # path: build/bin/${{ matrix.build }}
  1191. #
  1192. # emscripten:
  1193. # runs-on: ubuntu-latest
  1194. #
  1195. # strategy:
  1196. # matrix:
  1197. # build: [Release]
  1198. #
  1199. # steps:
  1200. # - name: Clone
  1201. # uses: actions/checkout@v4
  1202. #
  1203. # - name: Dependencies
  1204. # run: |
  1205. # wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz
  1206. # tar -xvf master.tar.gz
  1207. # emsdk-master/emsdk update
  1208. # emsdk-master/emsdk install latest
  1209. # emsdk-master/emsdk activate latest
  1210. #
  1211. # - name: Configure
  1212. # run: echo "tmp"
  1213. #
  1214. # - name: Build
  1215. # run: |
  1216. # pushd emsdk-master
  1217. # source ./emsdk_env.sh
  1218. # popd
  1219. # emcmake cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  1220. # make