release.yml 25 KB

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