release.yml 24 KB

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