release.yml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. name: Create Release
  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/release.yml', '**/CMakeLists.txt', '**/.cmake', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cuh', '**/*.swift', '**/*.m', '**/*.metal', '**/*.comp']
  13. concurrency:
  14. group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
  15. cancel-in-progress: true
  16. env:
  17. BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
  18. CMAKE_ARGS: "-DLLAMA_BUILD_EXAMPLES=OFF -DLLAMA_BUILD_TESTS=OFF -DLLAMA_BUILD_TOOLS=ON -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON"
  19. jobs:
  20. macOS-arm64:
  21. runs-on: macos-14
  22. steps:
  23. - name: Clone
  24. id: checkout
  25. uses: actions/checkout@v4
  26. with:
  27. fetch-depth: 0
  28. - name: ccache
  29. uses: hendrikmuhs/ccache-action@v1.2.16
  30. with:
  31. key: macOS-latest-cmake-arm64
  32. evict-old-files: 1d
  33. - name: Dependencies
  34. id: depends
  35. continue-on-error: true
  36. run: |
  37. brew update
  38. brew install curl
  39. - name: Build
  40. id: cmake_build
  41. run: |
  42. sysctl -a
  43. cmake -B build \
  44. -DCMAKE_BUILD_RPATH="@loader_path" \
  45. -DLLAMA_FATAL_WARNINGS=ON \
  46. -DGGML_METAL_USE_BF16=ON \
  47. -DGGML_METAL_EMBED_LIBRARY=ON \
  48. -DGGML_RPC=ON \
  49. ${{ env.CMAKE_ARGS }}
  50. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
  51. - name: Determine tag name
  52. id: tag
  53. uses: ./.github/actions/get-tag-name
  54. - name: Pack artifacts
  55. id: pack_artifacts
  56. run: |
  57. cp LICENSE ./build/bin/
  58. zip -r llama-${{ steps.tag.outputs.name }}-bin-macos-arm64.zip ./build/bin/*
  59. - name: Upload artifacts
  60. uses: actions/upload-artifact@v4
  61. with:
  62. path: llama-${{ steps.tag.outputs.name }}-bin-macos-arm64.zip
  63. name: llama-bin-macos-arm64.zip
  64. macOS-x64:
  65. runs-on: macos-13
  66. steps:
  67. - name: Clone
  68. id: checkout
  69. uses: actions/checkout@v4
  70. with:
  71. fetch-depth: 0
  72. - name: ccache
  73. uses: hendrikmuhs/ccache-action@v1.2.16
  74. with:
  75. key: macOS-latest-cmake-x64
  76. evict-old-files: 1d
  77. - name: Dependencies
  78. id: depends
  79. continue-on-error: true
  80. run: |
  81. brew update
  82. brew install curl
  83. - name: Build
  84. id: cmake_build
  85. run: |
  86. sysctl -a
  87. # Metal is disabled due to intermittent failures with Github runners not having a GPU:
  88. # https://github.com/ggml-org/llama.cpp/actions/runs/8635935781/job/23674807267#step:5:2313
  89. cmake -B build \
  90. -DCMAKE_BUILD_RPATH="@loader_path" \
  91. -DLLAMA_FATAL_WARNINGS=ON \
  92. -DGGML_METAL=OFF \
  93. -DGGML_RPC=ON
  94. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
  95. - name: Determine tag name
  96. id: tag
  97. uses: ./.github/actions/get-tag-name
  98. - name: Pack artifacts
  99. id: pack_artifacts
  100. run: |
  101. cp LICENSE ./build/bin/
  102. zip -r llama-${{ steps.tag.outputs.name }}-bin-macos-x64.zip ./build/bin/*
  103. - name: Upload artifacts
  104. uses: actions/upload-artifact@v4
  105. with:
  106. path: llama-${{ steps.tag.outputs.name }}-bin-macos-x64.zip
  107. name: llama-bin-macos-x64.zip
  108. ubuntu-22-cpu:
  109. strategy:
  110. matrix:
  111. include:
  112. - build: 'x64'
  113. os: ubuntu-22.04
  114. - build: 'arm64'
  115. os: ubuntu-22.04-arm
  116. runs-on: ${{ matrix.os }}
  117. steps:
  118. - name: Clone
  119. id: checkout
  120. uses: actions/checkout@v4
  121. with:
  122. fetch-depth: 0
  123. - name: ccache
  124. uses: hendrikmuhs/ccache-action@v1.2.16
  125. with:
  126. key: ubuntu-cpu-cmake
  127. evict-old-files: 1d
  128. - name: Dependencies
  129. id: depends
  130. run: |
  131. sudo apt-get update
  132. sudo apt-get install build-essential libcurl4-openssl-dev
  133. - name: Build
  134. id: cmake_build
  135. run: |
  136. cmake -B build \
  137. -DLLAMA_FATAL_WARNINGS=ON \
  138. ${{ env.CMAKE_ARGS }}
  139. cmake --build build --config Release -j $(nproc)
  140. - name: Determine tag name
  141. id: tag
  142. uses: ./.github/actions/get-tag-name
  143. - name: Pack artifacts
  144. id: pack_artifacts
  145. run: |
  146. cp LICENSE ./build/bin/
  147. zip -r llama-${{ steps.tag.outputs.name }}-bin-ubuntu-${{ matrix.build }}.zip ./build/bin/*
  148. - name: Upload artifacts
  149. uses: actions/upload-artifact@v4
  150. with:
  151. path: llama-${{ steps.tag.outputs.name }}-bin-ubuntu-${{ matrix.build }}.zip
  152. name: llama-bin-ubuntu-${{ matrix.build }}.zip
  153. ubuntu-22-vulkan:
  154. runs-on: ubuntu-22.04
  155. steps:
  156. - name: Clone
  157. id: checkout
  158. uses: actions/checkout@v4
  159. with:
  160. fetch-depth: 0
  161. - name: ccache
  162. uses: hendrikmuhs/ccache-action@v1.2.16
  163. with:
  164. key: ubuntu-22-cmake-vulkan
  165. evict-old-files: 1d
  166. - name: Dependencies
  167. id: depends
  168. run: |
  169. wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add -
  170. sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
  171. sudo apt-get update -y
  172. sudo apt-get install -y build-essential mesa-vulkan-drivers vulkan-sdk libcurl4-openssl-dev
  173. - name: Build
  174. id: cmake_build
  175. run: |
  176. cmake -B build \
  177. -DGGML_VULKAN=ON \
  178. ${{ env.CMAKE_ARGS }}
  179. cmake --build build --config Release -j $(nproc)
  180. - name: Determine tag name
  181. id: tag
  182. uses: ./.github/actions/get-tag-name
  183. - name: Pack artifacts
  184. id: pack_artifacts
  185. run: |
  186. cp LICENSE ./build/bin/
  187. zip -r llama-${{ steps.tag.outputs.name }}-bin-ubuntu-vulkan-x64.zip ./build/bin/*
  188. - name: Upload artifacts
  189. uses: actions/upload-artifact@v4
  190. with:
  191. path: llama-${{ steps.tag.outputs.name }}-bin-ubuntu-vulkan-x64.zip
  192. name: llama-bin-ubuntu-vulkan-x64.zip
  193. windows:
  194. runs-on: windows-latest
  195. env:
  196. OPENBLAS_VERSION: 0.3.23
  197. VULKAN_VERSION: 1.4.309.0
  198. strategy:
  199. matrix:
  200. include:
  201. - build: 'cpu-x64'
  202. defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/x64-windows-llvm.cmake -DGGML_NATIVE=OFF -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DGGML_OPENMP=OFF'
  203. #- build: 'openblas-x64'
  204. # defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/x64-windows-llvm.cmake -DGGML_NATIVE=OFF -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DGGML_OPENMP=OFF -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS -DBLAS_INCLUDE_DIRS="$env:RUNNER_TEMP/openblas/include" -DBLAS_LIBRARIES="$env:RUNNER_TEMP/openblas/lib/openblas.lib"'
  205. - build: 'vulkan-x64'
  206. defines: '-DGGML_NATIVE=OFF -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DGGML_VULKAN=ON'
  207. - build: 'cpu-arm64'
  208. defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-llvm.cmake -DGGML_NATIVE=OFF'
  209. - build: 'opencl-adreno-arm64'
  210. defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-llvm.cmake -DCMAKE_PREFIX_PATH="$env:RUNNER_TEMP/opencl-arm64-release" -DGGML_OPENCL=ON -DGGML_OPENCL_USE_ADRENO_KERNELS=ON'
  211. steps:
  212. - name: Clone
  213. id: checkout
  214. uses: actions/checkout@v4
  215. with:
  216. fetch-depth: 0
  217. - name: ccache
  218. uses: hendrikmuhs/ccache-action@v1.2.16
  219. with:
  220. key: windows-latest-cmake-${{ matrix.build }}
  221. variant: ccache
  222. evict-old-files: 1d
  223. - name: Download OpenBLAS
  224. id: get_openblas
  225. if: ${{ matrix.build == 'openblas-x64' }}
  226. run: |
  227. 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"
  228. curl.exe -o $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt -L "https://github.com/xianyi/OpenBLAS/raw/v${env:OPENBLAS_VERSION}/LICENSE"
  229. mkdir $env:RUNNER_TEMP/openblas
  230. tar.exe -xvf $env:RUNNER_TEMP/openblas.zip -C $env:RUNNER_TEMP/openblas
  231. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  232. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  233. $lib = $(join-path $msvc 'bin\Hostx64\x64\lib.exe')
  234. & $lib /machine:x64 "/def:${env:RUNNER_TEMP}/openblas/lib/libopenblas.def" "/out:${env:RUNNER_TEMP}/openblas/lib/openblas.lib" /name:openblas.dll
  235. - name: Install Vulkan SDK
  236. id: get_vulkan
  237. if: ${{ matrix.build == 'vulkan-x64' }}
  238. run: |
  239. 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"
  240. & "$env:RUNNER_TEMP\VulkanSDK-Installer.exe" --accept-licenses --default-answer --confirm-command install
  241. Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${env:VULKAN_VERSION}"
  242. Add-Content $env:GITHUB_PATH "C:\VulkanSDK\${env:VULKAN_VERSION}\bin"
  243. - name: Install Ninja
  244. id: install_ninja
  245. run: |
  246. choco install ninja
  247. - name: Install OpenCL Headers and Libs
  248. id: install_opencl
  249. if: ${{ matrix.build == 'opencl-adreno-arm64' }}
  250. run: |
  251. git clone https://github.com/KhronosGroup/OpenCL-Headers
  252. cd OpenCL-Headers
  253. cmake -B build `
  254. -DBUILD_TESTING=OFF `
  255. -DOPENCL_HEADERS_BUILD_TESTING=OFF `
  256. -DOPENCL_HEADERS_BUILD_CXX_TESTS=OFF `
  257. -DCMAKE_INSTALL_PREFIX="$env:RUNNER_TEMP/opencl-arm64-release"
  258. cmake --build build --target install
  259. git clone https://github.com/KhronosGroup/OpenCL-ICD-Loader
  260. cd OpenCL-ICD-Loader
  261. cmake -B build-arm64-release `
  262. -A arm64 `
  263. -DCMAKE_PREFIX_PATH="$env:RUNNER_TEMP/opencl-arm64-release" `
  264. -DCMAKE_INSTALL_PREFIX="$env:RUNNER_TEMP/opencl-arm64-release"
  265. cmake --build build-arm64-release --target install --config release
  266. - name: libCURL
  267. id: get_libcurl
  268. uses: ./.github/actions/windows-setup-curl
  269. - name: Build
  270. id: cmake_build
  271. env:
  272. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  273. run: |
  274. cmake -S . -B build ${{ matrix.defines }} `
  275. -DCURL_LIBRARY="$env:CURL_PATH/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:CURL_PATH/include" `
  276. ${{ env.CMAKE_ARGS }}
  277. cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS}
  278. - name: Add libopenblas.dll
  279. id: add_libopenblas_dll
  280. if: ${{ matrix.build == 'openblas-x64' }}
  281. run: |
  282. cp $env:RUNNER_TEMP/openblas/bin/libopenblas.dll ./build/bin/Release/openblas.dll
  283. cp $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt ./build/bin/Release/OpenBLAS-${env:OPENBLAS_VERSION}.txt
  284. - name: Determine tag name
  285. id: tag
  286. uses: ./.github/actions/get-tag-name
  287. - name: Pack artifacts
  288. id: pack_artifacts
  289. env:
  290. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  291. run: |
  292. Copy-Item $env:CURL_PATH\bin\libcurl-x64.dll .\build\bin\Release\libcurl-x64.dll
  293. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip .\build\bin\Release\*
  294. - name: Upload artifacts
  295. uses: actions/upload-artifact@v4
  296. with:
  297. path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip
  298. name: llama-bin-win-${{ matrix.build }}.zip
  299. windows-cuda:
  300. runs-on: windows-2019
  301. strategy:
  302. matrix:
  303. cuda: ['12.4', '11.7']
  304. steps:
  305. - name: Clone
  306. id: checkout
  307. uses: actions/checkout@v4
  308. with:
  309. fetch-depth: 0
  310. - name: Install ccache
  311. uses: hendrikmuhs/ccache-action@v1.2.16
  312. with:
  313. key: windows-cuda-${{ matrix.cuda }}
  314. variant: ccache
  315. evict-old-files: 1d
  316. - name: Install Cuda Toolkit
  317. uses: ./.github/actions/windows-setup-cuda
  318. with:
  319. cuda_version: ${{ matrix.cuda }}
  320. - name: Install Ninja
  321. id: install_ninja
  322. run: |
  323. choco install ninja
  324. - name: libCURL
  325. id: get_libcurl
  326. uses: ./.github/actions/windows-setup-curl
  327. - name: Build
  328. id: cmake_build
  329. shell: cmd
  330. env:
  331. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  332. run: |
  333. call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
  334. cmake -S . -B build -G "Ninja Multi-Config" ^
  335. -DGGML_NATIVE=OFF ^
  336. -DGGML_BACKEND_DL=ON ^
  337. -DGGML_CPU_ALL_VARIANTS=ON ^
  338. -DGGML_CUDA=ON ^
  339. -DCURL_LIBRARY="%CURL_PATH%/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="%CURL_PATH%/include" ^
  340. ${{ env.CMAKE_ARGS }}
  341. set /A NINJA_JOBS=%NUMBER_OF_PROCESSORS%-1
  342. cmake --build build --config Release -j %NINJA_JOBS% -t ggml
  343. cmake --build build --config Release
  344. - name: Determine tag name
  345. id: tag
  346. uses: ./.github/actions/get-tag-name
  347. - name: Pack artifacts
  348. id: pack_artifacts
  349. env:
  350. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  351. run: |
  352. cp $env:CURL_PATH\bin\libcurl-x64.dll .\build\bin\Release\libcurl-x64.dll
  353. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-cuda${{ matrix.cuda }}-x64.zip .\build\bin\Release\*
  354. - name: Upload artifacts
  355. uses: actions/upload-artifact@v4
  356. with:
  357. path: llama-${{ steps.tag.outputs.name }}-bin-win-cuda${{ matrix.cuda }}-x64.zip
  358. name: llama-bin-win-cuda${{ matrix.cuda }}-x64.zip
  359. - name: Copy and pack Cuda runtime
  360. run: |
  361. echo "Cuda install location: ${{ env.CUDA_PATH }}"
  362. $dst='.\build\bin\cudart\'
  363. robocopy "${{env.CUDA_PATH}}\bin" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
  364. robocopy "${{env.CUDA_PATH}}\lib" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
  365. 7z a cudart-llama-bin-win-cuda${{ matrix.cuda }}-x64.zip $dst\*
  366. - name: Upload Cuda runtime
  367. uses: actions/upload-artifact@v4
  368. with:
  369. path: cudart-llama-bin-win-cuda${{ matrix.cuda }}-x64.zip
  370. name: cudart-llama-bin-win-cuda${{ matrix.cuda }}-x64.zip
  371. windows-sycl:
  372. runs-on: windows-latest
  373. defaults:
  374. run:
  375. shell: bash
  376. env:
  377. 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
  378. WINDOWS_DPCPP_MKL: intel.oneapi.win.cpp-dpcpp-common:intel.oneapi.win.mkl.devel:intel.oneapi.win.dnnl:intel.oneapi.win.tbb.devel
  379. ONEAPI_ROOT: "C:/Program Files (x86)/Intel/oneAPI"
  380. steps:
  381. - name: Clone
  382. id: checkout
  383. uses: actions/checkout@v4
  384. with:
  385. fetch-depth: 0
  386. - name: ccache
  387. uses: hendrikmuhs/ccache-action@v1.2.16
  388. with:
  389. key: windows-latest-cmake-sycl
  390. variant: ccache
  391. evict-old-files: 1d
  392. - name: Install
  393. run: |
  394. scripts/install-oneapi.bat $WINDOWS_BASEKIT_URL $WINDOWS_DPCPP_MKL
  395. # TODO: add libcurl support ; we will also need to modify win-build-sycl.bat to accept user-specified args
  396. - name: Build
  397. id: cmake_build
  398. run: examples/sycl/win-build-sycl.bat
  399. - name: Determine tag name
  400. id: tag
  401. uses: ./.github/actions/get-tag-name
  402. - name: Build the release package
  403. id: pack_artifacts
  404. run: |
  405. echo "cp oneAPI running time dll files in ${{ env.ONEAPI_ROOT }} to ./build/bin"
  406. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_sycl_blas.5.dll" ./build/bin
  407. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_core.2.dll" ./build/bin
  408. cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_tbb_thread.2.dll" ./build/bin
  409. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_adapter_level_zero.dll" ./build/bin
  410. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_adapter_opencl.dll" ./build/bin
  411. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_loader.dll" ./build/bin
  412. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_win_proxy_loader.dll" ./build/bin
  413. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/sycl8.dll" ./build/bin
  414. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/svml_dispmd.dll" ./build/bin
  415. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/libmmd.dll" ./build/bin
  416. cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/libiomp5md.dll" ./build/bin
  417. cp "${{ env.ONEAPI_ROOT }}/dnnl/latest/bin/dnnl.dll" ./build/bin
  418. cp "${{ env.ONEAPI_ROOT }}/tbb/latest/bin/tbb12.dll" ./build/bin
  419. echo "cp oneAPI running time dll files to ./build/bin done"
  420. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip ./build/bin/*
  421. - name: Upload the release package
  422. uses: actions/upload-artifact@v4
  423. with:
  424. path: llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip
  425. name: llama-bin-win-sycl-x64.zip
  426. windows-hip:
  427. runs-on: windows-latest
  428. strategy:
  429. matrix:
  430. gpu_target: [gfx1100, gfx1101, gfx1030]
  431. steps:
  432. - name: Clone
  433. id: checkout
  434. uses: actions/checkout@v4
  435. with:
  436. fetch-depth: 0
  437. - name: Clone rocWMMA repository
  438. id: clone_rocwmma
  439. run: |
  440. git clone https://github.com/rocm/rocwmma --branch rocm-6.2.4 --depth 1
  441. - name: ccache
  442. uses: hendrikmuhs/ccache-action@v1.2.16
  443. with:
  444. key: windows-latest-cmake-hip-release
  445. evict-old-files: 1d
  446. - name: Install
  447. id: depends
  448. run: |
  449. $ErrorActionPreference = "Stop"
  450. write-host "Downloading AMD HIP SDK Installer"
  451. 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"
  452. write-host "Installing AMD HIP SDK"
  453. Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
  454. write-host "Completed AMD HIP SDK installation"
  455. - name: Verify ROCm
  456. id: verify
  457. run: |
  458. & 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
  459. - name: libCURL
  460. id: get_libcurl
  461. uses: ./.github/actions/windows-setup-curl
  462. - name: Build
  463. id: cmake_build
  464. env:
  465. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  466. run: |
  467. $env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
  468. $env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
  469. cmake -G "Unix Makefiles" -B build -S . `
  470. -DCMAKE_C_COMPILER="${env:HIP_PATH}\bin\clang.exe" `
  471. -DCMAKE_CXX_COMPILER="${env:HIP_PATH}\bin\clang++.exe" `
  472. -DCMAKE_CXX_FLAGS="-I$($PWD.Path.Replace('\', '/'))/rocwmma/library/include/" `
  473. -DCMAKE_BUILD_TYPE=Release `
  474. -DAMDGPU_TARGETS=${{ matrix.gpu_target }} `
  475. -DGGML_HIP_ROCWMMA_FATTN=ON `
  476. -DGGML_HIP=ON `
  477. -DCURL_LIBRARY="$env:CURL_PATH/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:CURL_PATH/include" `
  478. ${{ env.CMAKE_ARGS }}
  479. cmake --build build -j ${env:NUMBER_OF_PROCESSORS}
  480. md "build\bin\rocblas\library\"
  481. cp "${env:HIP_PATH}\bin\hipblas.dll" "build\bin\"
  482. cp "${env:HIP_PATH}\bin\rocblas.dll" "build\bin\"
  483. cp "${env:HIP_PATH}\bin\rocblas\library\*" "build\bin\rocblas\library\"
  484. - name: Determine tag name
  485. id: tag
  486. uses: ./.github/actions/get-tag-name
  487. - name: Pack artifacts
  488. id: pack_artifacts
  489. env:
  490. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  491. run: |
  492. cp $env:CURL_PATH\bin\libcurl-x64.dll .\build\bin\libcurl-x64.dll
  493. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-hip-x64-${{ matrix.gpu_target }}.zip .\build\bin\*
  494. - name: Upload artifacts
  495. uses: actions/upload-artifact@v4
  496. with:
  497. path: llama-${{ steps.tag.outputs.name }}-bin-win-hip-x64-${{ matrix.gpu_target }}.zip
  498. name: llama-bin-win-hip-x64-${{ matrix.gpu_target }}.zip
  499. ios-xcode-build:
  500. runs-on: macos-latest
  501. steps:
  502. - name: Checkout code
  503. uses: actions/checkout@v4
  504. with:
  505. fetch-depth: 0
  506. - name: Build
  507. id: cmake_build
  508. run: |
  509. sysctl -a
  510. cmake -B build -G Xcode \
  511. -DGGML_METAL_USE_BF16=ON \
  512. -DGGML_METAL_EMBED_LIBRARY=ON \
  513. -DLLAMA_CURL=OFF \
  514. -DLLAMA_BUILD_EXAMPLES=OFF \
  515. -DLLAMA_BUILD_TOOLS=OFF \
  516. -DLLAMA_BUILD_TESTS=OFF \
  517. -DLLAMA_BUILD_SERVER=OFF \
  518. -DCMAKE_SYSTEM_NAME=iOS \
  519. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
  520. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  521. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  522. - name: xcodebuild for swift package
  523. id: xcodebuild
  524. run: |
  525. ./build-xcframework.sh
  526. - name: Build Xcode project
  527. run: xcodebuild -project examples/llama.swiftui/llama.swiftui.xcodeproj -scheme llama.swiftui -sdk iphoneos CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= -destination 'generic/platform=iOS' FRAMEWORK_FOLDER_PATH=./build-ios build
  528. - name: Determine tag name
  529. id: tag
  530. uses: ./.github/actions/get-tag-name
  531. - name: Pack artifacts
  532. id: pack_artifacts
  533. run: |
  534. zip --symlinks -r llama-${{ steps.tag.outputs.name }}-xcframework.zip build-apple/llama.xcframework
  535. - name: Upload artifacts
  536. uses: actions/upload-artifact@v4
  537. with:
  538. path: llama-${{ steps.tag.outputs.name }}-xcframework.zip
  539. name: llama-${{ steps.tag.outputs.name }}-xcframework
  540. release:
  541. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  542. # Fine-grant permission
  543. # https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
  544. permissions:
  545. contents: write # for creating release
  546. runs-on: ubuntu-latest
  547. needs:
  548. - ubuntu-22-cpu
  549. - ubuntu-22-vulkan
  550. - windows
  551. - windows-cuda
  552. - windows-sycl
  553. - windows-hip
  554. - macOS-arm64
  555. - macOS-x64
  556. steps:
  557. - name: Clone
  558. id: checkout
  559. uses: actions/checkout@v4
  560. with:
  561. fetch-depth: 0
  562. - name: Determine tag name
  563. id: tag
  564. uses: ./.github/actions/get-tag-name
  565. - name: Download artifacts
  566. id: download-artifact
  567. uses: actions/download-artifact@v4
  568. with:
  569. path: ./artifact
  570. - name: Move artifacts
  571. id: move_artifacts
  572. run: mkdir -p ./artifact/release && mv ./artifact/*/*.zip ./artifact/release
  573. - name: Create release
  574. id: create_release
  575. uses: ggml-org/action-create-release@v1
  576. env:
  577. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  578. with:
  579. tag_name: ${{ steps.tag.outputs.name }}
  580. - name: Upload release
  581. id: upload_release
  582. uses: actions/github-script@v3
  583. with:
  584. github-token: ${{secrets.GITHUB_TOKEN}}
  585. script: |
  586. const path = require('path');
  587. const fs = require('fs');
  588. const release_id = '${{ steps.create_release.outputs.id }}';
  589. for (let file of await fs.readdirSync('./artifact/release')) {
  590. if (path.extname(file) === '.zip') {
  591. console.log('uploadReleaseAsset', file);
  592. await github.repos.uploadReleaseAsset({
  593. owner: context.repo.owner,
  594. repo: context.repo.repo,
  595. release_id: release_id,
  596. name: file,
  597. data: await fs.readFileSync(`./artifact/release/${file}`)
  598. });
  599. }
  600. }