release.yml 25 KB

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