release.yml 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716
  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. arch: 'x64'
  203. 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'
  204. #- build: 'openblas-x64'
  205. # arch: 'x64'
  206. # 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"'
  207. - build: 'vulkan-x64'
  208. arch: 'x64'
  209. defines: '-DGGML_NATIVE=OFF -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DGGML_VULKAN=ON'
  210. - build: 'cpu-arm64'
  211. arch: 'arm64'
  212. defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-llvm.cmake -DGGML_NATIVE=OFF'
  213. - build: 'opencl-adreno-arm64'
  214. arch: 'arm64'
  215. 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'
  216. steps:
  217. - name: Clone
  218. id: checkout
  219. uses: actions/checkout@v4
  220. with:
  221. fetch-depth: 0
  222. - name: ccache
  223. uses: hendrikmuhs/ccache-action@v1.2.16
  224. with:
  225. key: windows-latest-cmake-${{ matrix.build }}
  226. variant: ccache
  227. evict-old-files: 1d
  228. - name: Download OpenBLAS
  229. id: get_openblas
  230. if: ${{ matrix.build == 'openblas-x64' }}
  231. run: |
  232. 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"
  233. curl.exe -o $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt -L "https://github.com/xianyi/OpenBLAS/raw/v${env:OPENBLAS_VERSION}/LICENSE"
  234. mkdir $env:RUNNER_TEMP/openblas
  235. tar.exe -xvf $env:RUNNER_TEMP/openblas.zip -C $env:RUNNER_TEMP/openblas
  236. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  237. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  238. $lib = $(join-path $msvc 'bin\Hostx64\x64\lib.exe')
  239. & $lib /machine:x64 "/def:${env:RUNNER_TEMP}/openblas/lib/libopenblas.def" "/out:${env:RUNNER_TEMP}/openblas/lib/openblas.lib" /name:openblas.dll
  240. - name: Install Vulkan SDK
  241. id: get_vulkan
  242. if: ${{ matrix.build == 'vulkan-x64' }}
  243. run: |
  244. 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"
  245. & "$env:RUNNER_TEMP\VulkanSDK-Installer.exe" --accept-licenses --default-answer --confirm-command install
  246. Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${env:VULKAN_VERSION}"
  247. Add-Content $env:GITHUB_PATH "C:\VulkanSDK\${env:VULKAN_VERSION}\bin"
  248. - name: Install Ninja
  249. id: install_ninja
  250. run: |
  251. choco install ninja
  252. - name: Install OpenCL Headers and Libs
  253. id: install_opencl
  254. if: ${{ matrix.build == 'opencl-adreno-arm64' }}
  255. run: |
  256. git clone https://github.com/KhronosGroup/OpenCL-Headers
  257. cd OpenCL-Headers
  258. cmake -B build `
  259. -DBUILD_TESTING=OFF `
  260. -DOPENCL_HEADERS_BUILD_TESTING=OFF `
  261. -DOPENCL_HEADERS_BUILD_CXX_TESTS=OFF `
  262. -DCMAKE_INSTALL_PREFIX="$env:RUNNER_TEMP/opencl-arm64-release"
  263. cmake --build build --target install
  264. git clone https://github.com/KhronosGroup/OpenCL-ICD-Loader
  265. cd OpenCL-ICD-Loader
  266. cmake -B build-arm64-release `
  267. -A arm64 `
  268. -DCMAKE_PREFIX_PATH="$env:RUNNER_TEMP/opencl-arm64-release" `
  269. -DCMAKE_INSTALL_PREFIX="$env:RUNNER_TEMP/opencl-arm64-release"
  270. cmake --build build-arm64-release --target install --config release
  271. - name: libCURL
  272. id: get_libcurl
  273. uses: ./.github/actions/windows-setup-curl
  274. with:
  275. architecture: ${{ matrix.arch == 'x64' && 'win64' || 'win64a' }}
  276. - name: Build
  277. id: cmake_build
  278. env:
  279. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  280. run: |
  281. cmake -S . -B build ${{ matrix.defines }} `
  282. -DCURL_LIBRARY="$env:CURL_PATH/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:CURL_PATH/include" `
  283. ${{ env.CMAKE_ARGS }}
  284. cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS}
  285. - name: Add libopenblas.dll
  286. id: add_libopenblas_dll
  287. if: ${{ matrix.build == 'openblas-x64' }}
  288. run: |
  289. cp $env:RUNNER_TEMP/openblas/bin/libopenblas.dll ./build/bin/Release/openblas.dll
  290. cp $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt ./build/bin/Release/OpenBLAS-${env:OPENBLAS_VERSION}.txt
  291. - name: Determine tag name
  292. id: tag
  293. uses: ./.github/actions/get-tag-name
  294. - name: Pack artifacts
  295. id: pack_artifacts
  296. env:
  297. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  298. run: |
  299. Copy-Item $env:CURL_PATH\bin\libcurl-${{ matrix.arch }}.dll .\build\bin\Release\
  300. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip .\build\bin\Release\*
  301. - name: Upload artifacts
  302. uses: actions/upload-artifact@v4
  303. with:
  304. path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip
  305. name: llama-bin-win-${{ matrix.build }}.zip
  306. windows-cuda:
  307. runs-on: windows-2019
  308. strategy:
  309. matrix:
  310. cuda: ['12.4', '11.7']
  311. steps:
  312. - name: Clone
  313. id: checkout
  314. uses: actions/checkout@v4
  315. with:
  316. fetch-depth: 0
  317. - name: Install ccache
  318. uses: hendrikmuhs/ccache-action@v1.2.16
  319. with:
  320. key: windows-cuda-${{ matrix.cuda }}
  321. variant: ccache
  322. evict-old-files: 1d
  323. - name: Install Cuda Toolkit
  324. uses: ./.github/actions/windows-setup-cuda
  325. with:
  326. cuda_version: ${{ matrix.cuda }}
  327. - name: Install Ninja
  328. id: install_ninja
  329. run: |
  330. choco install ninja
  331. - name: libCURL
  332. id: get_libcurl
  333. uses: ./.github/actions/windows-setup-curl
  334. - name: Build
  335. id: cmake_build
  336. shell: cmd
  337. env:
  338. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  339. run: |
  340. call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
  341. cmake -S . -B build -G "Ninja Multi-Config" ^
  342. -DGGML_NATIVE=OFF ^
  343. -DGGML_BACKEND_DL=ON ^
  344. -DGGML_CPU_ALL_VARIANTS=ON ^
  345. -DGGML_CUDA=ON ^
  346. -DCURL_LIBRARY="%CURL_PATH%/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="%CURL_PATH%/include" ^
  347. ${{ env.CMAKE_ARGS }}
  348. set /A NINJA_JOBS=%NUMBER_OF_PROCESSORS%-1
  349. cmake --build build --config Release -j %NINJA_JOBS% -t ggml
  350. cmake --build build --config Release
  351. - name: Determine tag name
  352. id: tag
  353. uses: ./.github/actions/get-tag-name
  354. - name: Pack artifacts
  355. id: pack_artifacts
  356. env:
  357. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  358. run: |
  359. cp $env:CURL_PATH\bin\libcurl-x64.dll .\build\bin\Release\libcurl-x64.dll
  360. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-cuda${{ matrix.cuda }}-x64.zip .\build\bin\Release\*
  361. - name: Upload artifacts
  362. uses: actions/upload-artifact@v4
  363. with:
  364. path: llama-${{ steps.tag.outputs.name }}-bin-win-cuda${{ matrix.cuda }}-x64.zip
  365. name: llama-bin-win-cuda${{ matrix.cuda }}-x64.zip
  366. - name: Copy and pack Cuda runtime
  367. run: |
  368. echo "Cuda install location: ${{ env.CUDA_PATH }}"
  369. $dst='.\build\bin\cudart\'
  370. robocopy "${{env.CUDA_PATH}}\bin" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
  371. robocopy "${{env.CUDA_PATH}}\lib" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
  372. 7z a cudart-llama-bin-win-cuda${{ matrix.cuda }}-x64.zip $dst\*
  373. - name: Upload Cuda runtime
  374. uses: actions/upload-artifact@v4
  375. with:
  376. path: cudart-llama-bin-win-cuda${{ matrix.cuda }}-x64.zip
  377. name: cudart-llama-bin-win-cuda${{ matrix.cuda }}-x64.zip
  378. windows-sycl:
  379. runs-on: windows-latest
  380. defaults:
  381. run:
  382. shell: bash
  383. env:
  384. 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
  385. WINDOWS_DPCPP_MKL: intel.oneapi.win.cpp-dpcpp-common:intel.oneapi.win.mkl.devel:intel.oneapi.win.dnnl:intel.oneapi.win.tbb.devel
  386. ONEAPI_ROOT: "C:/Program Files (x86)/Intel/oneAPI"
  387. steps:
  388. - name: Clone
  389. id: checkout
  390. uses: actions/checkout@v4
  391. with:
  392. fetch-depth: 0
  393. - name: ccache
  394. uses: hendrikmuhs/ccache-action@v1.2.16
  395. with:
  396. key: windows-latest-cmake-sycl
  397. variant: ccache
  398. evict-old-files: 1d
  399. - name: Install
  400. run: |
  401. scripts/install-oneapi.bat $WINDOWS_BASEKIT_URL $WINDOWS_DPCPP_MKL
  402. # TODO: add libcurl support ; we will also need to modify win-build-sycl.bat to accept user-specified args
  403. - name: Build
  404. id: cmake_build
  405. run: examples/sycl/win-build-sycl.bat
  406. - name: Determine tag name
  407. id: tag
  408. uses: ./.github/actions/get-tag-name
  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-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip ./build/bin/*
  428. - name: Upload the release package
  429. uses: actions/upload-artifact@v4
  430. with:
  431. path: llama-${{ steps.tag.outputs.name }}-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. gpu_target: [gfx1100, gfx1101, gfx1030]
  438. steps:
  439. - name: Clone
  440. id: checkout
  441. uses: actions/checkout@v4
  442. with:
  443. fetch-depth: 0
  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-release
  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: libCURL
  467. id: get_libcurl
  468. uses: ./.github/actions/windows-setup-curl
  469. - name: Build
  470. id: cmake_build
  471. env:
  472. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  473. run: |
  474. $env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
  475. $env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
  476. cmake -G "Unix Makefiles" -B build -S . `
  477. -DCMAKE_C_COMPILER="${env:HIP_PATH}\bin\clang.exe" `
  478. -DCMAKE_CXX_COMPILER="${env:HIP_PATH}\bin\clang++.exe" `
  479. -DCMAKE_CXX_FLAGS="-I$($PWD.Path.Replace('\', '/'))/rocwmma/library/include/" `
  480. -DCMAKE_BUILD_TYPE=Release `
  481. -DAMDGPU_TARGETS=${{ matrix.gpu_target }} `
  482. -DGGML_HIP_ROCWMMA_FATTN=ON `
  483. -DGGML_HIP=ON `
  484. -DCURL_LIBRARY="$env:CURL_PATH/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:CURL_PATH/include" `
  485. ${{ env.CMAKE_ARGS }}
  486. cmake --build build -j ${env:NUMBER_OF_PROCESSORS}
  487. md "build\bin\rocblas\library\"
  488. cp "${env:HIP_PATH}\bin\hipblas.dll" "build\bin\"
  489. cp "${env:HIP_PATH}\bin\rocblas.dll" "build\bin\"
  490. cp "${env:HIP_PATH}\bin\rocblas\library\*" "build\bin\rocblas\library\"
  491. - name: Determine tag name
  492. id: tag
  493. uses: ./.github/actions/get-tag-name
  494. - name: Pack artifacts
  495. id: pack_artifacts
  496. env:
  497. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  498. run: |
  499. cp $env:CURL_PATH\bin\libcurl-x64.dll .\build\bin\libcurl-x64.dll
  500. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-hip-x64-${{ matrix.gpu_target }}.zip .\build\bin\*
  501. - name: Upload artifacts
  502. uses: actions/upload-artifact@v4
  503. with:
  504. path: llama-${{ steps.tag.outputs.name }}-bin-win-hip-x64-${{ matrix.gpu_target }}.zip
  505. name: llama-bin-win-hip-x64-${{ matrix.gpu_target }}.zip
  506. ios-xcode-build:
  507. runs-on: macos-latest
  508. steps:
  509. - name: Checkout code
  510. uses: actions/checkout@v4
  511. with:
  512. fetch-depth: 0
  513. - name: Build
  514. id: cmake_build
  515. run: |
  516. sysctl -a
  517. cmake -B build -G Xcode \
  518. -DGGML_METAL_USE_BF16=ON \
  519. -DGGML_METAL_EMBED_LIBRARY=ON \
  520. -DLLAMA_CURL=OFF \
  521. -DLLAMA_BUILD_EXAMPLES=OFF \
  522. -DLLAMA_BUILD_TOOLS=OFF \
  523. -DLLAMA_BUILD_TESTS=OFF \
  524. -DLLAMA_BUILD_SERVER=OFF \
  525. -DCMAKE_SYSTEM_NAME=iOS \
  526. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
  527. -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
  528. cmake --build build --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
  529. - name: xcodebuild for swift package
  530. id: xcodebuild
  531. run: |
  532. ./build-xcframework.sh
  533. - name: Build Xcode project
  534. 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
  535. - name: Determine tag name
  536. id: tag
  537. uses: ./.github/actions/get-tag-name
  538. - name: Pack artifacts
  539. id: pack_artifacts
  540. run: |
  541. zip --symlinks -r llama-${{ steps.tag.outputs.name }}-xcframework.zip build-apple/llama.xcframework
  542. - name: Upload artifacts
  543. uses: actions/upload-artifact@v4
  544. with:
  545. path: llama-${{ steps.tag.outputs.name }}-xcframework.zip
  546. name: llama-${{ steps.tag.outputs.name }}-xcframework
  547. release:
  548. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  549. # Fine-grant permission
  550. # https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
  551. permissions:
  552. contents: write # for creating release
  553. runs-on: ubuntu-latest
  554. needs:
  555. - ubuntu-22-cpu
  556. - ubuntu-22-vulkan
  557. - windows
  558. - windows-cuda
  559. - windows-sycl
  560. - windows-hip
  561. - macOS-arm64
  562. - macOS-x64
  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. - name: Move artifacts
  578. id: move_artifacts
  579. run: mkdir -p ./artifact/release && mv ./artifact/*/*.zip ./artifact/release
  580. - name: Create release
  581. id: create_release
  582. uses: ggml-org/action-create-release@v1
  583. env:
  584. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  585. with:
  586. tag_name: ${{ steps.tag.outputs.name }}
  587. - name: Upload release
  588. id: upload_release
  589. uses: actions/github-script@v3
  590. with:
  591. github-token: ${{secrets.GITHUB_TOKEN}}
  592. script: |
  593. const path = require('path');
  594. const fs = require('fs');
  595. const release_id = '${{ steps.create_release.outputs.id }}';
  596. for (let file of await fs.readdirSync('./artifact/release')) {
  597. if (path.extname(file) === '.zip') {
  598. console.log('uploadReleaseAsset', file);
  599. await github.repos.uploadReleaseAsset({
  600. owner: context.repo.owner,
  601. repo: context.repo.repo,
  602. release_id: release_id,
  603. name: file,
  604. data: await fs.readFileSync(`./artifact/release/${file}`)
  605. });
  606. }
  607. }