char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Oliver Simonsci : add ubuntu-cuda builds to release (#28186)391fac164

char/aliceai-t5-moe
72.7 KiB1911 linesraw
1name: Release
2
3on:
4  workflow_dispatch: # allows manual triggering
5    inputs:
6      create_release:
7        description: 'Create new release'
8        required: true
9        type: boolean
10  push:
11    branches:
12      - master
13    paths: [
14      '.github/workflows/release.yml',
15      '**/CMakeLists.txt',
16      '**/.cmake',
17      '**/*.h',
18      '**/*.hpp',
19      '**/*.c',
20      '**/*.cpp',
21      '**/*.cu',
22      '**/*.cuh',
23      '**/*.swift',
24      '**/*.m',
25      '**/*.metal',
26      '**/*.comp',
27      '**/*.glsl'
28    ]
29
30env:
31  GH_TOKEN: ${{ github.token }}
32  BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
33  CMAKE_ARGS: "-DLLAMA_BUILD_EXAMPLES=OFF -DLLAMA_BUILD_TESTS=OFF -DLLAMA_BUILD_TOOLS=ON -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON"
34
35# note: run this workflow one at a time for better cache reuse
36concurrency:
37  group: release
38  queue: max
39
40jobs:
41  check-release:
42    runs-on: ubuntu-slim
43
44    outputs:
45      should_release: ${{ steps.check.outputs.should_release }}
46
47    steps:
48      - id: check
49        env:
50          COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
51        run: |
52          if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
53            echo "should_release=true" >> $GITHUB_OUTPUT
54          elif [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/master" ]]; then
55            if echo "$COMMIT_MESSAGE" | grep -q '\[no release\]'; then
56              echo "should_release=false" >> $GITHUB_OUTPUT
57            else
58              echo "should_release=true" >> $GITHUB_OUTPUT
59            fi
60          else
61            echo "should_release=false" >> $GITHUB_OUTPUT
62          fi
63
64  macos-cpu:
65    needs: [check-release, ui-build]
66    if: ${{ needs.check-release.outputs.should_release == 'true' }}
67    strategy:
68      matrix:
69        include:
70          - build: 'arm64'
71            arch: 'arm64'
72            os: macos-26
73            defines: "-DGGML_METAL_EMBED_LIBRARY=ON -DCMAKE_OSX_DEPLOYMENT_TARGET=13.3"
74          # TODO: this build is disabled to save Github Actions resources (https://github.com/ggml-org/llama.cpp/pull/23780)
75          #       in order to enable it again, we have to provision dedicated runners  to run it
76          #- build: 'arm64-kleidiai'
77          #  arch: 'arm64'
78          #  os: macos-14
79          #  defines: "-DGGML_METAL_EMBED_LIBRARY=ON -DCMAKE_OSX_DEPLOYMENT_TARGET=13.3 -DGGML_CPU_KLEIDIAI=ON"
80          - build: 'x64'
81            arch: 'x64'
82            os: macos-15-intel
83            # Metal is disabled on x64 due to intermittent failures with Github runners not having a GPU:
84            # https://github.com/ggml-org/llama.cpp/actions/runs/8635935781/job/23674807267#step:5:2313
85            defines: "-DGGML_METAL=OFF -DCMAKE_OSX_DEPLOYMENT_TARGET=13.3"
86
87    runs-on: ${{ matrix.os }}
88
89    permissions:
90      actions: write
91
92    steps:
93      - name: Clone
94        id: checkout
95        uses: actions/checkout@v6
96        with:
97          fetch-depth: 0
98
99      - name: Download UI build
100        uses: actions/download-artifact@v7
101        with:
102          name: llama-ui.zip
103          path: tools/ui/dist
104
105      - name: ccache
106        uses: ggml-org/ccache-action@v1.2.24
107        with:
108          key: release-${{ matrix.os }}-${{ matrix.arch }}
109
110      - name: Build
111        id: cmake_build
112        run: |
113          sysctl -a
114          cmake -B build \
115            ${{ matrix.defines }} \
116            -DCMAKE_INSTALL_RPATH='@loader_path' \
117            -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
118            -DLLAMA_FATAL_WARNINGS=ON \
119            -DLLAMA_BUILD_BORINGSSL=ON \
120            ${{ env.CMAKE_ARGS }}
121          cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
122
123      - name: Determine tag name
124        id: tag
125        uses: ./.github/actions/get-tag-name
126
127      - name: Pack artifacts
128        id: pack_artifacts
129        run: |
130          cp LICENSE ./build/bin/
131          tar -czvf llama-${{ steps.tag.outputs.name }}-bin-macos-${{ matrix.build }}.tar.gz -s ",^\.,llama-${{ steps.tag.outputs.name }}," -C ./build/bin .
132
133      - name: Upload artifacts
134        uses: actions/upload-artifact@v6
135        with:
136          path: llama-${{ steps.tag.outputs.name }}-bin-macos-${{ matrix.build }}.tar.gz
137          name: llama-bin-macos-${{ matrix.build }}.tar.gz
138
139      - name: ccache-clear
140        uses: ./.github/actions/ccache-clear
141        with:
142          key: release-${{ matrix.os }}-${{ matrix.arch }}
143
144  ubuntu-cpu:
145    needs: [check-release, ui-build]
146    if: ${{ needs.check-release.outputs.should_release == 'true' }}
147    strategy:
148      matrix:
149        include:
150          - build: 'x64'
151            os: ubuntu-22.04
152          - build: 'arm64'
153            os: ubuntu-24.04-arm
154          - build: 's390x'
155            os: ubuntu-24.04-s390x
156
157    runs-on: ${{ matrix.os }}
158
159    permissions:
160      actions: write
161
162    steps:
163      - name: Clone
164        id: checkout
165        uses: actions/checkout@v6
166        with:
167          fetch-depth: 0
168
169      - name: Download UI build
170        uses: actions/download-artifact@v7
171        with:
172          name: llama-ui.zip
173          path: tools/ui/dist
174
175      - name: Dependencies
176        id: depends
177        run: |
178          sudo apt-get update
179          sudo apt-get install build-essential libssl-dev
180
181      - name: Toolchain workaround (GCC 14)
182        if: ${{ contains(matrix.os, 'ubuntu-24.04') }}
183        run: |
184          sudo apt-get install -y gcc-14 g++-14
185          echo "CC=gcc-14" >> "$GITHUB_ENV"
186          echo "CXX=g++-14" >> "$GITHUB_ENV"
187
188      - name: ccache
189        if: ${{ matrix.build != 's390x' }}
190        uses: ggml-org/ccache-action@v1.2.24
191        with:
192          key: release-${{ matrix.os }}-cpu
193
194      - name: Build
195        id: cmake_build
196        run: |
197          cmake -B build \
198            -DCMAKE_INSTALL_RPATH='$ORIGIN' \
199            -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
200            -DGGML_BACKEND_DL=ON \
201            -DGGML_NATIVE=OFF \
202            -DGGML_CPU_ALL_VARIANTS=ON \
203            -DLLAMA_FATAL_WARNINGS=ON \
204            ${{ env.CMAKE_ARGS }}
205          cmake --build build --config Release -j $(nproc)
206
207      - name: Determine tag name
208        id: tag
209        uses: ./.github/actions/get-tag-name
210
211      - name: Pack artifacts
212        id: pack_artifacts
213        run: |
214          cp LICENSE ./build/bin/
215          tar -czvf llama-${{ steps.tag.outputs.name }}-bin-ubuntu-${{ matrix.build }}.tar.gz --transform "s,^\.,llama-${{ steps.tag.outputs.name }}," -C ./build/bin .
216
217      - name: Upload artifacts
218        uses: actions/upload-artifact@v6
219        with:
220          path: llama-${{ steps.tag.outputs.name }}-bin-ubuntu-${{ matrix.build }}.tar.gz
221          name: llama-bin-ubuntu-${{ matrix.build }}.tar.gz
222
223      - name: ccache-clear
224        if: ${{ matrix.build != 's390x' }}
225        uses: ./.github/actions/ccache-clear
226        with:
227          key: release-${{ matrix.os }}-cpu
228
229  ubuntu-vulkan:
230    needs: [check-release, ui-build]
231    if: ${{ needs.check-release.outputs.should_release == 'true' }}
232
233    strategy:
234      matrix:
235        include:
236          - build: 'x64'
237            os: ubuntu-22.04
238          - build: 'arm64'
239            os: ubuntu-24.04-arm
240
241    runs-on: ${{ matrix.os }}
242
243    permissions:
244      actions: write
245
246    steps:
247      - name: Clone
248        id: checkout
249        uses: actions/checkout@v6
250        with:
251          fetch-depth: 0
252
253      - name: Download UI build
254        uses: actions/download-artifact@v7
255        with:
256          name: llama-ui.zip
257          path: tools/ui/dist
258
259      - name: Dependencies
260        id: depends
261        run: |
262          if [[ "${{ matrix.os }}" =~ "ubuntu-22.04" ]]; then
263            wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add -
264            sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
265            sudo apt-get update -y
266            sudo apt-get install -y build-essential mesa-vulkan-drivers vulkan-sdk libssl-dev
267          else
268            sudo apt-get update -y
269            sudo apt-get install -y gcc-14 g++-14 build-essential glslc libvulkan-dev spirv-headers libssl-dev ninja-build
270            echo "CC=gcc-14" >> "$GITHUB_ENV"
271            echo "CXX=g++-14" >> "$GITHUB_ENV"
272          fi
273
274      - name: ccache
275        uses: ggml-org/ccache-action@v1.2.24
276        with:
277          key: release-${{ matrix.os }}-vulkan
278
279      - name: Build
280        id: cmake_build
281        run: |
282          cmake -B build \
283            -DCMAKE_INSTALL_RPATH='$ORIGIN' \
284            -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
285            -DGGML_BACKEND_DL=ON \
286            -DGGML_NATIVE=OFF \
287            -DGGML_CPU_ALL_VARIANTS=ON \
288            -DGGML_VULKAN=ON \
289            ${{ env.CMAKE_ARGS }}
290          cmake --build build --config Release -j $(nproc)
291
292      - name: Determine tag name
293        id: tag
294        uses: ./.github/actions/get-tag-name
295
296      - name: Pack artifacts
297        id: pack_artifacts
298        run: |
299          cp LICENSE ./build/bin/
300          tar -czvf llama-${{ steps.tag.outputs.name }}-bin-ubuntu-vulkan-${{ matrix.build }}.tar.gz --transform "s,^\.,llama-${{ steps.tag.outputs.name }}," -C ./build/bin .
301
302      - name: Upload artifacts
303        uses: actions/upload-artifact@v6
304        with:
305          path: llama-${{ steps.tag.outputs.name }}-bin-ubuntu-vulkan-${{ matrix.build }}.tar.gz
306          name: llama-bin-ubuntu-vulkan-${{ matrix.build }}.tar.gz
307
308      - name: ccache-clear
309        uses: ./.github/actions/ccache-clear
310        with:
311          key: release-${{ matrix.os }}-vulkan
312
313  ubuntu-cuda:
314    name: ubuntu-cuda (${{ matrix.label }}, ${{ matrix.build }})
315    needs: [check-release, ui-build]
316    if: ${{ needs.check-release.outputs.should_release == 'true' }}
317
318    strategy:
319      matrix:
320        include:
321          # label = short version used in artifact names / release body
322          # cuda  = full container image tag
323          - build: 'x64'
324            os: ubuntu-24.04
325            cuda: '12.8.2'
326            label: '12.8'
327            defines: '-DGGML_CUDA_CUB_3DOT2=ON'
328          - build: 'x64'
329            os: ubuntu-24.04
330            cuda: '13.3.1'
331            label: '13.3'
332            defines: ''
333          - build: 'arm64'
334            os: ubuntu-24.04-arm
335            cuda: '13.3.1'
336            label: '13.3'
337            defines: ''
338
339    runs-on: ${{ matrix.os }}
340    container: nvidia/cuda:${{ matrix.cuda }}-devel-ubuntu24.04
341
342    permissions:
343      actions: write
344
345    steps:
346      # the container has no git; install it before checkout so that a real git
347      # repository is created (the get-tag-name action and the build both need it)
348      - name: Install git
349        run: |
350          apt-get update
351          apt-get install -y --no-install-recommends git
352
353      - name: Clone
354        id: checkout
355        uses: actions/checkout@v6
356        with:
357          fetch-depth: 0
358
359      # checkout runs as the host user; in-container steps run as root, so git
360      # refuses to touch a repo it does not own. Mark the workspace as safe.
361      # use the env var: the github.workspace context holds the HOST path,
362      # GITHUB_WORKSPACE the container path
363      - name: Git safe directory
364        run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
365
366      - name: Download UI build
367        uses: actions/download-artifact@v7
368        with:
369          name: llama-ui.zip
370          path: tools/ui/dist
371
372      - name: Dependencies
373        id: depends
374        # container jobs default to sh (dash); need bash for the [[ ]] below
375        shell: bash
376        run: |
377          apt-get update
378          apt-get install -y --no-install-recommends build-essential cmake ninja-build libssl-dev jq python3-venv
379          # the container ships GCC 13, which does not know the 'sme' march
380          # feature used by the armv9.2 CPU variant of GGML_CPU_ALL_VARIANTS
381          if [[ "${{ matrix.build }}" == "arm64" ]]; then
382            apt-get install -y --no-install-recommends gcc-14 g++-14
383            echo "CC=gcc-14" >> "$GITHUB_ENV"
384            echo "CXX=g++-14" >> "$GITHUB_ENV"
385          fi
386
387      - name: ccache
388        uses: ggml-org/ccache-action@v1.2.24
389        with:
390          key: release-ubuntu-${{ matrix.os }}-cuda-${{ matrix.label }}-${{ matrix.build }}
391          evict-old-files: 1d
392          max-size: "1G"
393
394      - name: Build
395        id: cmake_build
396        # no CMAKE_CUDA_ARCHITECTURES: use the broad default arch set from
397        # ggml/src/ggml-cuda/CMakeLists.txt so the release binary covers many GPUs
398        run: |
399          cmake -B build \
400            -DCMAKE_INSTALL_RPATH='$ORIGIN' \
401            -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
402            -DGGML_BACKEND_DL=ON \
403            -DGGML_NATIVE=OFF \
404            -DGGML_CPU_ALL_VARIANTS=ON \
405            -DGGML_CUDA=ON \
406            -DGGML_CUDA_NCCL=OFF \
407            ${{ env.CMAKE_ARGS }} ${{ matrix.defines }}
408          cmake --build build --config Release -j $(nproc)
409
410      - name: Determine tag name
411        id: tag
412        uses: ./.github/actions/get-tag-name
413
414      - name: Pack artifacts
415        id: pack_artifacts
416        run: |
417          cp LICENSE ./build/bin/
418          tar -czvf llama-${{ steps.tag.outputs.name }}-bin-ubuntu-cuda-${{ matrix.label }}-${{ matrix.build }}.tar.gz --transform "s,^\.,llama-${{ steps.tag.outputs.name }}," -C ./build/bin .
419
420      - name: Upload artifacts
421        uses: actions/upload-artifact@v6
422        with:
423          path: llama-${{ steps.tag.outputs.name }}-bin-ubuntu-cuda-${{ matrix.label }}-${{ matrix.build }}.tar.gz
424          name: llama-bin-ubuntu-cuda-${{ matrix.label }}-${{ matrix.build }}.tar.gz
425
426      # ship the CUDA runtime libraries the backend links against, mirroring
427      # the windows-cuda cudart zip - extract next to the binaries ($ORIGIN rpath)
428      - name: Pack CUDA runtime
429        id: pack_cuda_runtime
430        run: |
431          major="${{ matrix.label }}"
432          major="${major%%.*}"
433          mkdir -p ./cudart
434          # cp -L dereferences the SONAME symlinks into plain files, so the
435          # tarball holds exactly 3 files with no versioned duplicates
436          cp -L /usr/local/cuda/lib64/libcudart.so.${major} ./cudart/
437          cp -L /usr/local/cuda/lib64/libcublas.so.${major} ./cudart/
438          cp -L /usr/local/cuda/lib64/libcublasLt.so.${major} ./cudart/
439          tar -czvf cudart-llama-${{ steps.tag.outputs.name }}-bin-ubuntu-cuda-${{ matrix.label }}-${{ matrix.build }}.tar.gz --transform "s,^\.,cudart-llama-${{ steps.tag.outputs.name }}-bin-ubuntu-cuda-${{ matrix.label }}-${{ matrix.build }}," -C ./cudart .
440
441      - name: Upload CUDA runtime
442        uses: actions/upload-artifact@v6
443        with:
444          path: cudart-llama-${{ steps.tag.outputs.name }}-bin-ubuntu-cuda-${{ matrix.label }}-${{ matrix.build }}.tar.gz
445          name: cudart-llama-bin-ubuntu-cuda-${{ matrix.label }}-${{ matrix.build }}.tar.gz
446
447      - name: ccache-clear
448        uses: ./.github/actions/ccache-clear
449        with:
450          key: release-ubuntu-${{ matrix.os }}-cuda-${{ matrix.label }}-${{ matrix.build }}
451
452  android-arm64:
453    needs: [check-release, ui-build]
454    if: ${{ needs.check-release.outputs.should_release == 'true' }}
455
456    runs-on: ubuntu-latest
457
458    #permissions:
459    #  actions: write
460
461    env:
462      NDK_VERSION: "29.0.14206865"
463
464    steps:
465      - name: Clone
466        id: checkout
467        uses: actions/checkout@v6
468        with:
469          fetch-depth: 0
470
471      - name: Download UI build
472        uses: actions/download-artifact@v7
473        with:
474          name: llama-ui.zip
475          path: tools/ui/dist
476
477      - name: Set up JDK
478        uses: actions/setup-java@v5
479        with:
480          java-version: 17
481          distribution: temurin
482
483      - name: Setup Android SDK
484        uses: android-actions/setup-android@40fd30fb8d7440372e1316f5d1809ec01dcd3699 # v4.0.1
485        with:
486          log-accepted-android-sdk-licenses: false
487
488      - name: Install NDK
489        run: |
490          sdkmanager "ndk;${{ env.NDK_VERSION }}"
491          echo "ANDROID_NDK=${ANDROID_SDK_ROOT}/ndk/${{ env.NDK_VERSION }}" >> $GITHUB_ENV
492
493      # note : disabled to spare some cache space (https://github.com/ggml-org/llama.cpp/pull/23789)
494      #        for some reason, the ccache does not improve the build time in this case
495      # example:
496      #   cache off: https://github.com/ggerganov/tmp2/actions/runs/26534713799/job/78160400831
497      #   cache on:  https://github.com/ggerganov/tmp2/actions/runs/26534713799/job/78224189394
498      #
499      #- name: ccache
500      #  uses: ggml-org/ccache-action@v1.2.24
501      #  with:
502      #    key: release-android-arm64
503
504      - name: Build
505        id: cmake_build
506        run: |
507          cmake -B build \
508            -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \
509            -DANDROID_ABI=arm64-v8a \
510            -DANDROID_PLATFORM=android-28 \
511            -DCMAKE_INSTALL_RPATH='$ORIGIN' \
512            -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
513            -DGGML_BACKEND_DL=ON \
514            -DGGML_NATIVE=OFF \
515            -DGGML_CPU_ALL_VARIANTS=ON \
516            -DLLAMA_FATAL_WARNINGS=ON \
517            -DGGML_OPENMP=OFF \
518            -DLLAMA_BUILD_BORINGSSL=ON \
519            ${{ env.CMAKE_ARGS }}
520          cmake --build build --config Release -j $(nproc)
521
522      #- name: ccache-clear
523      #  uses: ./.github/actions/ccache-clear
524      #  with:
525      #    key: release-android-arm64
526
527      - name: Determine tag name
528        id: tag
529        uses: ./.github/actions/get-tag-name
530
531      - name: Pack artifacts
532        id: pack_artifacts
533        run: |
534          cp LICENSE ./build/bin/
535          tar -czvf llama-${{ steps.tag.outputs.name }}-bin-android-arm64.tar.gz --transform "s,^\.,llama-${{ steps.tag.outputs.name }}," -C ./build/bin .
536
537      - name: Upload artifacts
538        uses: actions/upload-artifact@v6
539        with:
540          path: llama-${{ steps.tag.outputs.name }}-bin-android-arm64.tar.gz
541          name: llama-bin-android-arm64.tar.gz
542
543  ubuntu-24-openvino:
544    needs: [check-release, ui-build]
545    if: ${{ needs.check-release.outputs.should_release == 'true' }}
546
547    runs-on: ubuntu-24.04
548
549    permissions:
550      actions: write
551
552    outputs:
553      openvino_version: ${{ steps.openvino_version.outputs.value }}
554
555    env:
556      # Sync versions in build-openvino.yml, build-self-hosted.yml, release.yml, build-cache.yml, .devops/openvino.Dockerfile
557      OPENVINO_VERSION_MAJOR: "2026.3.1"
558      OPENVINO_VERSION_FULL: "2026.3.1.22476.56d9685302d"
559
560    steps:
561      - name: Set OpenVINO version output
562        id: openvino_version
563        run: echo "value=${{ env.OPENVINO_VERSION_MAJOR }}" >> $GITHUB_OUTPUT
564
565      - name: Clone
566        id: checkout
567        uses: actions/checkout@v6
568        with:
569          fetch-depth: 0
570
571      - name: Download UI build
572        uses: actions/download-artifact@v7
573        with:
574          name: llama-ui.zip
575          path: tools/ui/dist
576
577      - name: ccache
578        uses: ggml-org/ccache-action@v1.2.24
579        with:
580          key: release-ubuntu-24.04-openvino-release-no-preset-v1
581
582      - name: Dependencies
583        run: |
584          sudo apt-get update
585          sudo apt-get install -y build-essential libssl-dev libtbb12 cmake ninja-build python3-pip
586          sudo apt install ocl-icd-opencl-dev opencl-headers opencl-clhpp-headers intel-opencl-icd
587
588      - name: Use OpenVINO Toolkit Cache
589        uses: actions/cache@v5
590        id: cache-openvino
591        with:
592          path: ./openvino_toolkit
593          key: cache-gha-openvino-toolkit-v${{ env.OPENVINO_VERSION_FULL }}-${{ runner.os }}
594
595      - name: Setup OpenVINO Toolkit
596        if: steps.cache-openvino.outputs.cache-hit != 'true'
597        uses: ./.github/actions/linux-setup-openvino
598        with:
599          path: ./openvino_toolkit
600          version_major: ${{ env.OPENVINO_VERSION_MAJOR }}
601          version_full: ${{ env.OPENVINO_VERSION_FULL }}
602
603      - name: Install OpenVINO dependencies
604        run: |
605          cd ./openvino_toolkit
606          chmod +x ./install_dependencies/install_openvino_dependencies.sh
607          echo "Y" | sudo -E ./install_dependencies/install_openvino_dependencies.sh
608
609      - name: Build
610        id: cmake_build
611        run: |
612          source ./openvino_toolkit/setupvars.sh
613          cmake -B build/ReleaseOV -G Ninja \
614            -DCMAKE_BUILD_TYPE=Release \
615            -DGGML_OPENVINO=ON \
616            -DCMAKE_INSTALL_RPATH='$ORIGIN' \
617            -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
618            ${{ env.CMAKE_ARGS }}
619          cmake --build build/ReleaseOV --config Release --parallel
620
621      - name: Determine tag name
622        id: tag
623        uses: ./.github/actions/get-tag-name
624
625      - name: Pack artifacts
626        id: pack_artifacts
627        run: |
628          dest=./build/ReleaseOV/bin
629          OPENVINO_ROOT=./openvino_toolkit
630          ov_lib="$OPENVINO_ROOT/runtime/lib/intel64"
631
632          # Bundle OpenVINO runtime libs + TBB. Binaries built with RPATH=$ORIGIN
633          # load these siblings without setupvars.sh / LD_LIBRARY_PATH.
634          cp -P "$ov_lib"/libopenvino.so* \
635                "$ov_lib"/libopenvino_c.so* \
636                "$ov_lib"/libopenvino_*_plugin.so \
637                "$ov_lib"/libopenvino_intel_npu_compiler*.so \
638                "$OPENVINO_ROOT"/runtime/3rdparty/tbb/lib/*.so* \
639                "$dest"
640          cp -P /usr/lib/x86_64-linux-gnu/libOpenCL.so.1* "$dest" 2>/dev/null || true
641          cp "$ov_lib"/cache.json "$dest" 2>/dev/null || true
642
643          # OpenVINO licensing
644          cp -r "$OPENVINO_ROOT"/docs/licensing "$dest"/openvino-licensing
645
646          cp LICENSE "$dest"
647          tar -czvf llama-${{ steps.tag.outputs.name }}-bin-ubuntu-openvino-${{ env.OPENVINO_VERSION_MAJOR }}-x64.tar.gz --transform "s,^\.,llama-${{ steps.tag.outputs.name }}," -C "$dest" .
648
649      - name: Upload artifacts
650        uses: actions/upload-artifact@v6
651        with:
652          path: llama-${{ steps.tag.outputs.name }}-bin-ubuntu-openvino-${{ env.OPENVINO_VERSION_MAJOR }}-x64.tar.gz
653          name: llama-bin-ubuntu-openvino-${{ env.OPENVINO_VERSION_MAJOR }}-x64.tar.gz
654
655      - name: ccache-clear
656        uses: ./.github/actions/ccache-clear
657        with:
658          key: release-ubuntu-24.04-openvino-release-no-preset-v1
659
660  windows-openvino:
661    needs: [check-release, ui-build]
662    if: ${{ needs.check-release.outputs.should_release == 'true' }}
663
664    runs-on: windows-2022
665
666    outputs:
667      openvino_version: ${{ steps.openvino_version.outputs.value }}
668
669    env:
670      # Sync versions in build-openvino.yml, build-self-hosted.yml, release.yml, build-cache.yml, .devops/openvino.Dockerfile
671      OPENVINO_VERSION_MAJOR: "2026.3.1"
672      OPENVINO_VERSION_FULL: "2026.3.1.22476.56d9685302d"
673
674    steps:
675      - name: Set OpenVINO version output
676        id: openvino_version
677        shell: bash
678        run: echo "value=${{ env.OPENVINO_VERSION_MAJOR }}" >> $GITHUB_OUTPUT
679
680      - name: Clone
681        id: checkout
682        uses: actions/checkout@v6
683        with:
684            fetch-depth: 0
685
686      - name: Download UI build
687        uses: actions/download-artifact@v7
688        with:
689          name: llama-ui.zip
690          path: tools/ui/dist
691
692      - name: ccache
693        uses: ggml-org/ccache-action@v1.2.24
694        with:
695          key: release-windows-2022-openvino
696          variant: ccache
697          evict-old-files: 1d
698
699      - name: Setup Cache
700        uses: actions/cache@v5
701        id: cache-openvino
702        with:
703          path: ./openvino_toolkit
704          key: cache-gha-openvino-toolkit-v${{ env.OPENVINO_VERSION_FULL }}-${{ runner.os }}
705
706      - name: Setup OpenVINO Toolkit
707        if: steps.cache-openvino.outputs.cache-hit != 'true'
708        uses: ./.github/actions/windows-setup-openvino
709        with:
710          path: ./openvino_toolkit
711          version_major: ${{ env.OPENVINO_VERSION_MAJOR }}
712          version_full: ${{ env.OPENVINO_VERSION_FULL }}
713
714      - name: Install OpenCL using vcpkg
715        shell: powershell
716        run: |
717          git clone https://github.com/microsoft/vcpkg C:\vcpkg
718          C:\vcpkg\bootstrap-vcpkg.bat
719          C:\vcpkg\vcpkg install opencl
720
721      - name: Build
722        id: cmake_build
723        shell: cmd
724        run: |
725          REM Find extracted OpenVINO folder dynamically
726          for /d %%i in (openvino_toolkit\*) do set OPENVINO_ROOT=%%i
727
728          if not exist "%OPENVINO_ROOT%\runtime\cmake\OpenVINOConfig.cmake" (
729              echo ERROR: OpenVINOConfig.cmake not found
730              exit /b 1
731          )
732
733          call "%OPENVINO_ROOT%\setupvars.bat"
734
735          cmake -B build\ReleaseOV -G "Visual Studio 17 2022" ^
736            -A x64 ^
737            -DCMAKE_BUILD_TYPE=Release ^
738            -DGGML_OPENVINO=ON ^
739            -DLLAMA_BUILD_BORINGSSL=ON ^
740            -DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake ^
741            ${{ env.CMAKE_ARGS }}
742
743          cmake --build build\ReleaseOV --config Release -- /m
744
745      - name: Determine tag name
746        id: tag
747        uses: ./.github/actions/get-tag-name
748
749      - name: Pack artifacts
750        id: pack_artifacts
751        shell: powershell
752        run: |
753          # Locate the extracted OpenVINO toolkit root (same pattern as the Build step).
754          $OPENVINO_ROOT = (Get-ChildItem -Directory openvino_toolkit | Select-Object -First 1).FullName
755          if (-not $OPENVINO_ROOT) {
756            Write-Error "OpenVINO toolkit folder not found under .\openvino_toolkit"
757            exit 1
758          }
759
760          $dest = ".\build\ReleaseOV\bin\Release"
761
762          $ovBin = Join-Path $OPENVINO_ROOT 'runtime\bin\intel64\Release'
763          Copy-Item -Path (Join-Path $ovBin '*.dll')       -Destination $dest -Force
764          Copy-Item -Path (Join-Path $ovBin 'cache.json')  -Destination $dest -Force
765
766          $tbbBin = Join-Path $OPENVINO_ROOT 'runtime\3rdparty\tbb\bin'
767          Copy-Item -Path (Join-Path $tbbBin 'tbb*.dll') -Destination $dest -Force
768
769          # OpenVINO licensing
770          $licensingDest = Join-Path $dest 'openvino-licensing'
771          New-Item -ItemType Directory -Force -Path $licensingDest | Out-Null
772          Copy-Item -Path (Join-Path $OPENVINO_ROOT 'docs\licensing\*') -Destination $licensingDest -Recurse -Force
773
774          Copy-Item LICENSE $dest
775          7z a -snl llama-${{ steps.tag.outputs.name }}-bin-win-openvino-${{ env.OPENVINO_VERSION_MAJOR }}-x64.zip $dest\*
776
777      - name: Upload artifacts
778        uses: actions/upload-artifact@v6
779        with:
780          path: llama-${{ steps.tag.outputs.name }}-bin-win-openvino-${{ env.OPENVINO_VERSION_MAJOR }}-x64.zip
781          name: llama-bin-win-openvino-${{ env.OPENVINO_VERSION_MAJOR }}-x64.zip
782
783      - name: ccache-clear
784        uses: ./.github/actions/ccache-clear
785        with:
786          key: release-windows-2022-openvino
787
788  windows-cpu:
789    name: windows-cpu / ${{ matrix.arch }}
790    needs: [check-release, ui-build]
791    if: ${{ needs.check-release.outputs.should_release == 'true' }}
792
793    runs-on: windows-2025-vs2026
794
795    permissions:
796      actions: write
797
798    strategy:
799      matrix:
800        include:
801          - arch: 'x64'
802          - arch: 'arm64'
803
804    steps:
805      - name: Clone
806        uses: actions/checkout@v6
807        with:
808          fetch-depth: 0
809
810      - name: Download UI build
811        uses: actions/download-artifact@v7
812        with:
813          name: llama-ui.zip
814          path: tools/ui/dist
815
816      - name: Install Ninja
817        run: |
818          choco install ninja
819
820      - name: ccache
821        uses: ggml-org/ccache-action@v1.2.24
822        with:
823          key: release-windows-2025-vs2026-${{ matrix.arch }}-cpu
824
825      - name: Build
826        shell: cmd
827        run: |
828          call "C:\Program Files\Microsoft Visual Studio\18\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.arch == 'x64' && 'x64' || 'amd64_arm64' }}
829          cmake -S . -B build -G "Ninja Multi-Config" ^
830            -D CMAKE_TOOLCHAIN_FILE=cmake/${{ matrix.arch }}-windows-llvm.cmake ^
831            -DLLAMA_BUILD_BORINGSSL=ON ^
832            -DGGML_NATIVE=OFF ^
833            -DGGML_BACKEND_DL=ON ^
834            -DGGML_CPU_ALL_VARIANTS=${{ matrix.arch == 'x64' && 'ON' || 'OFF' }} ^
835            -DGGML_OPENMP=ON ^
836            -DGGML_OPENMP_FETCH=ON ^
837            ${{ env.CMAKE_ARGS }}
838          cmake --build build --config Release
839
840      - name: Pack artifacts
841        id: pack_artifacts
842        run: |
843          7z a -snl llama-bin-win-cpu-${{ matrix.arch }}.zip .\build\bin\Release\*
844
845      - name: Upload artifacts
846        uses: actions/upload-artifact@v6
847        with:
848          path: llama-bin-win-cpu-${{ matrix.arch }}.zip
849          name: llama-bin-win-cpu-${{ matrix.arch }}.zip
850
851      - name: ccache-clear
852        uses: ./.github/actions/ccache-clear
853        with:
854          key: release-windows-2025-vs2026-${{ matrix.arch }}-cpu
855
856  # note: builds only the ggml-hip backend - llama-server is injected from the
857  #       windows-cpu zip during the release "Merge artifacts" step
858  windows-rocm:
859    needs: [check-release]
860    if: ${{ needs.check-release.outputs.should_release == 'true' }}
861
862    runs-on: windows-2022
863
864    strategy:
865      matrix:
866        include:
867          - ROCM_VERSION: "10.0.0"
868            gpu_targets: "gfx1010;gfx1011;gfx1012;gfx1030;gfx1031;gfx1032;gfx1033;gfx1034;gfx1035;gfx1036;gfx1100;gfx1101;gfx1102;gfx1103;gfx1150;gfx1151;gfx1152;gfx1153;gfx1200;gfx1201"
869            build: x64
870
871    steps:
872      - name: Clone
873        id: checkout
874        uses: actions/checkout@v6
875        with:
876          fetch-depth: 0
877
878      - name: Install Ninja
879        run: |
880          choco install ninja
881
882      - name: ccache
883        uses: ggml-org/ccache-action@v1.2.24
884        with:
885          key: windows-rocm-${{ matrix.ROCM_VERSION }}-${{ matrix.build }}
886          evict-old-files: 1d
887          max-size: "1G"
888
889      # - name: Cache ROCm Installation
890      #   id: cache-rocm
891      #   uses: actions/cache@v5
892      #   with:
893      #     path: C:\TheRock\build
894      #     key: rocm-wheels-${{ matrix.ROCM_VERSION }}-multi-arch-${{ runner.os }}
895
896      - name: Setup ROCm
897        # if: steps.cache-rocm.outputs.cache-hit != 'true'
898        uses: ./.github/actions/windows-setup-rocm
899        with:
900          version: ${{ matrix.ROCM_VERSION }}
901
902      - name: Setup ROCm Environment
903        run: |
904          $ErrorActionPreference = "Stop"
905
906          # Activate venv from cache or fresh install
907          & C:\TheRock\build\.venv\Scripts\Activate.ps1
908
909          # Expand the devel tree (idempotent; no-op if already done during install)
910          rocm-sdk init
911          if ($LASTEXITCODE -ne 0) { throw "rocm-sdk init failed with exit code $LASTEXITCODE" }
912
913          # Get ROCm installation paths using the rocm-sdk CLI tool
914          $rocmPath = (rocm-sdk path --root)
915          if (-not $rocmPath) { throw "rocm-sdk path --root returned empty - devel package may not be installed" }
916          $rocmPath = $rocmPath.Trim()
917          $cmakePath = (rocm-sdk path --cmake).Trim()
918          $binPath = (rocm-sdk path --bin).Trim()
919          write-host "ROCm root: $rocmPath"
920          write-host "CMake path: $cmakePath"
921          write-host "Bin path: $binPath"
922
923          echo "HIP_PATH=$rocmPath" >> $env:GITHUB_ENV
924          echo "CMAKE_PREFIX_PATH=$cmakePath" >> $env:GITHUB_ENV
925          echo "HIP_DEVICE_LIB_PATH=$rocmPath\lib\llvm\amdgcn\bitcode" >> $env:GITHUB_ENV
926          echo "HIP_PLATFORM=amd" >> $env:GITHUB_ENV
927          echo "LLVM_PATH=$rocmPath\lib\llvm" >> $env:GITHUB_ENV
928          echo "$binPath" >> $env:GITHUB_PATH
929
930          # Keep venv in PATH for subsequent steps
931          echo "C:\TheRock\build\.venv\Scripts" >> $env:GITHUB_PATH
932
933      - name: Build
934        run: |
935          cmake -S . -B build `
936            -G "Ninja Multi-Config" `
937            -DCMAKE_PREFIX_PATH="${env:HIP_PATH}" `
938            -DGGML_BACKEND_DL=ON `
939            -DGGML_NATIVE=OFF `
940            -DGGML_CPU=OFF `
941            -DGGML_HIP=ON `
942            -DCMAKE_C_COMPILER="${env:HIP_PATH}\lib\llvm\bin\clang.exe" `
943            -DCMAKE_CXX_COMPILER="${env:HIP_PATH}\lib\llvm\bin\clang++.exe" `
944            -DCMAKE_C_FLAGS="-Wno-error=incompatible-pointer-types" `
945            -DCMAKE_HIP_COMPILER="${env:HIP_PATH}\lib\llvm\bin\clang.exe" `
946            -DHIP_PATH="${env:HIP_PATH}" `
947            -DAMDGPU_TARGETS="${{ matrix.gpu_targets }}"
948          cmake --build build --config Release --parallel ${env:NUMBER_OF_PROCESSORS} --target ggml-hip
949
950      - name: Verify HIP backend was built
951        run: |
952          $hipDll = Get-ChildItem -Path build\bin\Release -Filter "ggml-hip*.dll" -ErrorAction SilentlyContinue
953          if (-not $hipDll) {
954            Write-Host "##[error]ggml-hip*.dll was NOT produced. The HIP backend silently failed to build."
955            Write-Host "Contents of build\bin\Release:"
956            Get-ChildItem build\bin\Release | Format-Table -AutoSize
957            exit 1
958          }
959          Write-Host "HIP backend artifact found:"
960          $hipDll | Format-Table FullName, Length -AutoSize
961
962      - name: Determine tag name
963        id: tag
964        uses: ./.github/actions/get-tag-name
965
966      - name: Get ROCm short version
967        run: |
968          $rocmVersionShort = ('${{ matrix.ROCM_VERSION }}'.Split('.')[0..1] -join '.')
969          echo "ROCM_VERSION_SHORT=$rocmVersionShort" >> $env:GITHUB_ENV
970
971      - name: Bundle HIP runtime DLLs (amdhip64_7.dll, rocm_kpack.dll, amd_comgr.dll)
972        run: |
973          $ErrorActionPreference = "Stop"
974          # See issue https://github.com/ggml-org/llama.cpp/issues/26929.
975          # ggml-hip.dll loads amdhip64_7.dll at run time. The Adrenalin driver
976          # ships an amdhip64_7.dll in System32, which the loader searches before PATH,
977          # so a matching DLL from PATH cannot win. Copy amdhip64 next to the
978          # binaries (exe directory is searched before System32) so the correct
979          # runtime is used. rocm_kpack.dll is amdhip64_7's direct dependency, so
980          # copy the matching version too. amd_comgr is copied as well to keep it
981          # in sync with the bundled amdhip64, avoiding a version mismatch with a
982          # amd_comgr from System32.
983          # rocblas/hipblaslt kernels resolve fine via PATH and are not copied.
984          $binPath = (rocm-sdk path --bin).Trim()
985          if (-not $binPath) { throw "rocm-sdk path --bin returned empty" }
986          write-host "ROCm bin path: $binPath"
987
988          $patterns = @("amdhip64_7.dll", "rocm_kpack.dll", "amd_comgr.dll")
989          foreach ($pattern in $patterns) {
990            $files = Get-ChildItem -Path $binPath -Filter $pattern -ErrorAction SilentlyContinue
991            if (-not $files) { throw "no match for $pattern in $binPath" }
992            foreach ($f in $files) {
993              Copy-Item $f.FullName -Destination build\bin\Release -Force
994              write-host "  copied $($f.Name)"
995            }
996          }
997
998      - name: Pack artifacts
999        run: |
1000          7z a -snl llama-bin-win-rocm-${{ env.ROCM_VERSION_SHORT }}-${{ matrix.build }}.zip `
1001            .\build\bin\Release\ggml-hip.dll `
1002            .\build\bin\Release\amdhip64_7.dll `
1003            .\build\bin\Release\rocm_kpack.dll `
1004            .\build\bin\Release\amd_comgr.dll
1005
1006      - name: Upload artifacts
1007        uses: actions/upload-artifact@v6
1008        with:
1009          path: llama-bin-win-rocm-${{ env.ROCM_VERSION_SHORT }}-${{ matrix.build }}.zip
1010          name: llama-bin-win-rocm-${{ env.ROCM_VERSION_SHORT }}-${{ matrix.build }}.zip
1011
1012      - name: ccache-clear
1013        uses: ./.github/actions/ccache-clear
1014        with:
1015          key: windows-rocm-${{ matrix.ROCM_VERSION }}-${{ matrix.build }}
1016
1017  # note: builds only the backend library - llama-server (with the embedded UI)
1018  #       is injected from the windows-cpu zip during the release "Merge artifacts" step
1019  windows:
1020    needs: [check-release]
1021    if: ${{ needs.check-release.outputs.should_release == 'true' }}
1022
1023    runs-on: windows-2025
1024
1025    permissions:
1026      actions: write
1027
1028    env:
1029      OPENBLAS_VERSION: 0.3.23
1030      VULKAN_VERSION: 1.4.357.0
1031
1032    strategy:
1033      matrix:
1034        include:
1035          - backend: 'vulkan'
1036            arch: 'x64'
1037            defines: '-DGGML_VULKAN=ON'
1038            target: 'ggml-vulkan'
1039          - backend: 'opencl-adreno'
1040            arch: 'arm64'
1041            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'
1042            target: 'ggml-opencl'
1043
1044    steps:
1045      - name: Clone
1046        id: checkout
1047        uses: actions/checkout@v6
1048
1049      - name: Install Vulkan SDK
1050        id: get_vulkan
1051        if: ${{ matrix.backend == 'vulkan' }}
1052        run: |
1053          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"
1054          & "$env:RUNNER_TEMP\VulkanSDK-Installer.exe" --accept-licenses --default-answer --confirm-command install
1055          Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${env:VULKAN_VERSION}"
1056          Add-Content $env:GITHUB_PATH "C:\VulkanSDK\${env:VULKAN_VERSION}\bin"
1057
1058      - name: Install Ninja
1059        id: install_ninja
1060        run: |
1061          choco install ninja
1062
1063      # TODO: these jobs need to use llvm toolchain in order to utilize the ccache
1064      #- name: ccache
1065      #  uses: ggml-org/ccache-action@v1.2.24
1066      #  with:
1067      #    key: release-windows-2025-${{ matrix.arch }}-${{ matrix.backend }}
1068
1069      - name: Install OpenCL Headers and Libs
1070        id: install_opencl
1071        if: ${{ matrix.backend == 'opencl-adreno' && matrix.arch == 'arm64' }}
1072        run: |
1073          git clone https://github.com/KhronosGroup/OpenCL-Headers
1074          cd OpenCL-Headers
1075          cmake -B build `
1076            -DBUILD_TESTING=OFF `
1077            -DOPENCL_HEADERS_BUILD_TESTING=OFF `
1078            -DOPENCL_HEADERS_BUILD_CXX_TESTS=OFF `
1079            -DCMAKE_INSTALL_PREFIX="$env:RUNNER_TEMP/opencl-arm64-release"
1080          cmake --build build --target install
1081          git clone https://github.com/KhronosGroup/OpenCL-ICD-Loader
1082          cd OpenCL-ICD-Loader
1083          cmake -B build-arm64-release `
1084            -A arm64 `
1085            -DCMAKE_PREFIX_PATH="$env:RUNNER_TEMP/opencl-arm64-release" `
1086            -DCMAKE_INSTALL_PREFIX="$env:RUNNER_TEMP/opencl-arm64-release"
1087          cmake --build build-arm64-release --target install --config release
1088
1089      - name: Build
1090        id: cmake_build
1091        run: |
1092          cmake -S . -B build ${{ matrix.defines }} -DGGML_NATIVE=OFF -DGGML_CPU=OFF -DGGML_BACKEND_DL=ON -DLLAMA_BUILD_BORINGSSL=ON
1093          cmake --build build --config Release --target ${{ matrix.target }}
1094
1095      #- name: ccache-clear
1096      #  uses: ./.github/actions/ccache-clear
1097      #  with:
1098      #    key: release-windows-2025-${{ matrix.arch }}-${{ matrix.backend }}
1099
1100      - name: Pack artifacts
1101        id: pack_artifacts
1102        run: |
1103          7z a -snl llama-bin-win-${{ matrix.backend }}-${{ matrix.arch }}.zip .\build\bin\Release\${{ matrix.target }}.dll
1104
1105      - name: Upload artifacts
1106        uses: actions/upload-artifact@v6
1107        with:
1108          path: llama-bin-win-${{ matrix.backend }}-${{ matrix.arch }}.zip
1109          name: llama-bin-win-${{ matrix.backend }}-${{ matrix.arch }}.zip
1110
1111  # note: builds only the ggml-cuda backend - llama-server is injected from the
1112  #       windows-cpu zip during the release "Merge artifacts" step
1113  windows-cuda:
1114    name: windows-cuda (${{ matrix.cuda }}, ${{ matrix.arch }})
1115    needs: [check-release]
1116    if: ${{ needs.check-release.outputs.should_release == 'true' }}
1117
1118    runs-on: windows-2022
1119
1120    permissions:
1121      actions: write
1122
1123    strategy:
1124      matrix:
1125        include:
1126          - cuda: '12.4'
1127            arch: x64
1128            defines: '-DGGML_CUDA_CUB_3DOT2=ON'
1129          - cuda: '13.3'
1130            arch: x64
1131            defines: ''
1132          - cuda: '13.4'
1133            arch: arm64
1134            defines: '-DCMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-msvc-cuda.cmake'
1135
1136    steps:
1137      - name: Clone
1138        id: checkout
1139        uses: actions/checkout@v6
1140
1141      - name: Install Cuda Toolkit
1142        uses: ./.github/actions/windows-setup-cuda
1143        with:
1144          cuda_version: ${{ matrix.cuda }}
1145          cuda_arch: ${{ matrix.arch }}
1146
1147      - name: Install Ninja
1148        id: install_ninja
1149        run: |
1150          choco install ninja
1151
1152      - name: ccache
1153        uses: ggml-org/ccache-action@v1.2.24
1154        with:
1155          key: release-windows-2022-${{ matrix.arch }}-cuda-${{ matrix.cuda }}
1156
1157      - name: Build
1158        id: cmake_build
1159        shell: cmd
1160        # TODO: Remove GGML_CUDA_CUB_3DOT2 flag once CCCL 3.2 is bundled within CTK and that CTK version is used in this project
1161        run: |
1162          call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.arch == 'x64' && 'x64' || 'amd64_arm64' }}
1163          cmake -S . -B build -G "Ninja Multi-Config" ^
1164            -DGGML_BACKEND_DL=ON ^
1165            -DGGML_NATIVE=OFF ^
1166            -DGGML_CPU=OFF ^
1167            -DGGML_CUDA=ON ^
1168            -DLLAMA_BUILD_BORINGSSL=ON ${{ matrix.defines }}
1169          set /A NINJA_JOBS=%NUMBER_OF_PROCESSORS%-1
1170          cmake --build build --config Release -j %NINJA_JOBS% --target ggml-cuda
1171
1172      - name: Pack artifacts
1173        id: pack_artifacts
1174        run: |
1175          7z a -snl llama-bin-win-cuda-${{ matrix.cuda }}-${{ matrix.arch }}.zip .\build\bin\Release\ggml-cuda.dll
1176
1177      - name: Upload artifacts
1178        uses: actions/upload-artifact@v6
1179        with:
1180          path: llama-bin-win-cuda-${{ matrix.cuda }}-${{ matrix.arch }}.zip
1181          name: llama-bin-win-cuda-${{ matrix.cuda }}-${{ matrix.arch }}.zip
1182
1183      - name: Copy and pack Cuda runtime (x64)
1184        if: ${{ matrix.arch == 'x64' }}
1185        run: |
1186          echo "Cuda install location: ${{ env.CUDA_PATH }}"
1187          $dst='.\build\bin\cudart\'
1188          robocopy "${{env.CUDA_PATH}}\bin" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
1189          robocopy "${{env.CUDA_PATH}}\lib" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
1190          robocopy "${{env.CUDA_PATH}}\bin\x64" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
1191          7z a cudart-llama-bin-win-cuda-${{ matrix.cuda }}-${{ matrix.arch }}.zip $dst\*
1192
1193      - name: Copy and pack Cuda runtime (ARM64)
1194        if: ${{ matrix.arch == 'arm64' }}
1195        run: |
1196          echo "Cuda install location: ${{ env.CUDA_PATH }}"
1197          $dst='.\build\bin\cudart\'
1198          robocopy "${{env.CUDA_PATH}}\bin\arm64" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
1199          7z a cudart-llama-bin-win-cuda-${{ matrix.cuda }}-${{ matrix.arch }}.zip $dst\*
1200
1201      - name: Upload Cuda runtime
1202        uses: actions/upload-artifact@v6
1203        with:
1204          path: cudart-llama-bin-win-cuda-${{ matrix.cuda }}-${{ matrix.arch }}.zip
1205          name: cudart-llama-bin-win-cuda-${{ matrix.cuda }}-${{ matrix.arch }}.zip
1206
1207      - name: ccache-clear
1208        uses: ./.github/actions/ccache-clear
1209        with:
1210          key: release-windows-2022-${{ matrix.arch }}-cuda-${{ matrix.cuda }}
1211
1212  # note: builds only the ggml-sycl backend - llama-server is injected from the
1213  #       windows-cpu zip during the release "Merge artifacts" step
1214  windows-sycl:
1215    needs: [check-release]
1216    if: ${{ needs.check-release.outputs.should_release == 'true' }}
1217
1218    runs-on: windows-2022
1219
1220    defaults:
1221      run:
1222        shell: bash
1223
1224    env:
1225      WINDOWS_BASEKIT_URL: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/b60765d1-2b85-4e85-86b6-cb0e9563a699/intel-deep-learning-essentials-2025.3.3.18_offline.exe
1226      WINDOWS_DPCPP_MKL: intel.oneapi.win.cpp-dpcpp-common:intel.oneapi.win.mkl.devel:intel.oneapi.win.dnnl:intel.oneapi.win.tbb.devel
1227      LEVEL_ZERO_SDK_URL: https://github.com/oneapi-src/level-zero/releases/download/v1.28.2/level-zero-win-sdk-1.28.2.zip
1228      ONEAPI_ROOT: "C:/Program Files (x86)/Intel/oneAPI"
1229      ONEAPI_INSTALLER_VERSION: "2025.3.3"
1230
1231    steps:
1232      - name: Clone
1233        id: checkout
1234        uses: actions/checkout@v6
1235
1236      - name: Download & Install oneAPI
1237        shell: bash
1238        run: |
1239          scripts/install-oneapi.bat $WINDOWS_BASEKIT_URL $WINDOWS_DPCPP_MKL
1240
1241      - name: Install Level Zero SDK
1242        shell: pwsh
1243        run: |
1244          Invoke-WebRequest -Uri "${{ env.LEVEL_ZERO_SDK_URL }}" -OutFile "level-zero-win-sdk.zip"
1245          Expand-Archive -Path "level-zero-win-sdk.zip" -DestinationPath "C:/level-zero-sdk" -Force
1246          "LEVEL_ZERO_V1_SDK_PATH=C:/level-zero-sdk" | Out-File -FilePath $env:GITHUB_ENV -Append
1247
1248      - name: ccache
1249        uses: ggml-org/ccache-action@v1.2.24
1250        with:
1251          key: release-windows-2022-x64-sycl
1252
1253      - name: Build
1254        id: cmake_build
1255        shell: cmd
1256        run: |
1257          call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat" intel64 --force
1258          cmake -G "Ninja" -B build ^
1259            -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=icx ^
1260            -DCMAKE_BUILD_TYPE=Release ^
1261            -DGGML_BACKEND_DL=ON -DBUILD_SHARED_LIBS=ON ^
1262            -DGGML_CPU=OFF -DGGML_SYCL=ON ^
1263            -DLLAMA_BUILD_BORINGSSL=ON
1264          cmake --build build --target ggml-sycl -j %NUMBER_OF_PROCESSORS%
1265
1266      - name: Build the release package
1267        id: pack_artifacts
1268        run: |
1269          echo "cp oneAPI running time dll files in ${{ env.ONEAPI_ROOT }} to ./build/bin"
1270
1271          cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_sycl_blas.5.dll" ./build/bin
1272          cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_core.2.dll" ./build/bin
1273          cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_tbb_thread.2.dll" ./build/bin
1274
1275          cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_adapter_level_zero.dll" ./build/bin
1276          cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_adapter_level_zero_v2.dll" ./build/bin
1277          cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_adapter_opencl.dll" ./build/bin
1278          cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_loader.dll" ./build/bin
1279          cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_win_proxy_loader.dll" ./build/bin
1280          ZE_LOADER_DLL=$(find "${{ env.ONEAPI_ROOT }}" "$LEVEL_ZERO_V1_SDK_PATH" -iname ze_loader.dll -print -quit 2>/dev/null || true)
1281          if [ -n "$ZE_LOADER_DLL" ]; then
1282            echo "Using Level Zero loader: $ZE_LOADER_DLL"
1283            cp "$ZE_LOADER_DLL" ./build/bin
1284          else
1285            echo "Level Zero loader DLL not found in oneAPI or SDK; relying on system driver/runtime"
1286          fi
1287
1288          cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/sycl8.dll" ./build/bin
1289          cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/svml_dispmd.dll" ./build/bin
1290          cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/libmmd.dll" ./build/bin
1291          cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/libiomp5md.dll" ./build/bin
1292          cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/sycl-ls.exe" ./build/bin
1293          cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/libsycl-fallback-bfloat16.spv" ./build/bin
1294          cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/libsycl-native-bfloat16.spv" ./build/bin
1295
1296          cp "${{ env.ONEAPI_ROOT }}/dnnl/latest/bin/dnnl.dll" ./build/bin
1297          cp "${{ env.ONEAPI_ROOT }}/tbb/latest/bin/tbb12.dll" ./build/bin
1298
1299          cp "${{ env.ONEAPI_ROOT }}/tcm/latest/bin/tcm.dll" ./build/bin
1300          cp "${{ env.ONEAPI_ROOT }}/tcm/latest/bin/libhwloc-15.dll" ./build/bin
1301          cp "${{ env.ONEAPI_ROOT }}/umf/latest/bin/umf.dll" ./build/bin
1302
1303          echo "cp oneAPI running time dll files to ./build/bin done"
1304          7z a -snl llama-bin-win-sycl-x64.zip ./build/bin/*
1305
1306      - name: Upload the release package
1307        uses: actions/upload-artifact@v6
1308        with:
1309          path: llama-bin-win-sycl-x64.zip
1310          name: llama-bin-win-sycl-x64.zip
1311
1312      - name: ccache-clear
1313        uses: ./.github/actions/ccache-clear
1314        with:
1315          key: release-windows-2022-x64-sycl
1316
1317  ubuntu-24-sycl:
1318    needs: [check-release, ui-build]
1319    if: ${{ needs.check-release.outputs.should_release == 'true' }}
1320
1321    strategy:
1322      matrix:
1323        build: [fp32, fp16]
1324        include:
1325          - build: fp32
1326            fp16: OFF
1327          - build: fp16
1328            fp16: ON
1329
1330    runs-on: ubuntu-24.04
1331
1332    env:
1333      ONEAPI_ROOT: /opt/intel/oneapi/
1334      ONEAPI_INSTALLER_VERSION: "2025.3.3"
1335      LEVEL_ZERO_VERSION: "1.28.2"
1336      LEVEL_ZERO_UBUNTU_VERSION: "u24.04"
1337
1338    steps:
1339      - name: Clone
1340        id: checkout
1341        uses: actions/checkout@v6
1342        with:
1343          fetch-depth: 0
1344
1345      - name: Download & Install oneAPI
1346        shell: bash
1347        run: |
1348          cd /tmp
1349          wget https://registrationcenter-download.intel.com/akdlm/IRC_NAS/56f7923a-adb8-43f3-8b02-2b60fcac8cab/intel-deep-learning-essentials-2025.3.3.16_offline.sh -O intel-deep-learning-essentials_offline.sh
1350          sudo bash intel-deep-learning-essentials_offline.sh -s -a --silent --eula accept
1351
1352      - name: Install Level Zero SDK
1353        shell: bash
1354        run: |
1355          cd /tmp
1356          wget -q "https://github.com/oneapi-src/level-zero/releases/download/v${LEVEL_ZERO_VERSION}/level-zero_${LEVEL_ZERO_VERSION}%2B${LEVEL_ZERO_UBUNTU_VERSION}_amd64.deb" -O level-zero.deb
1357          wget -q "https://github.com/oneapi-src/level-zero/releases/download/v${LEVEL_ZERO_VERSION}/level-zero-devel_${LEVEL_ZERO_VERSION}%2B${LEVEL_ZERO_UBUNTU_VERSION}_amd64.deb" -O level-zero-devel.deb
1358          sudo apt-get install -y ./level-zero.deb ./level-zero-devel.deb
1359
1360      - name: Download UI build
1361        uses: actions/download-artifact@v7
1362        with:
1363          name: llama-ui.zip
1364          path: tools/ui/dist
1365
1366      - name: ccache
1367        uses: ggml-org/ccache-action@v1.2.24
1368        with:
1369          key: release-ubuntu-24.04-sycl-${{ matrix.build }}
1370
1371      - name: Build
1372        id: cmake_build
1373        run: |
1374          source /opt/intel/oneapi/setvars.sh
1375          cmake -B build \
1376            -G "Ninja" \
1377            -DCMAKE_BUILD_TYPE=Release \
1378            -DGGML_SYCL=ON \
1379            -DCMAKE_C_COMPILER=icx \
1380            -DCMAKE_CXX_COMPILER=icpx \
1381            -DCMAKE_INSTALL_RPATH='$ORIGIN' \
1382            -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
1383            -DLLAMA_OPENSSL=OFF \
1384            -DGGML_NATIVE=OFF \
1385            -DGGML_SYCL_F16=${{ matrix.fp16 }}
1386          time cmake --build build --config Release -j $(nproc)
1387
1388      - name: Determine tag name
1389        id: tag
1390        uses: ./.github/actions/get-tag-name
1391
1392      - name: Pack artifacts
1393        id: pack_artifacts
1394        run: |
1395          cp LICENSE ./build/bin/
1396          tar -czvf llama-${{ steps.tag.outputs.name }}-bin-ubuntu-sycl-${{ matrix.build }}-x64.tar.gz --transform "s,^\.,llama-${{ steps.tag.outputs.name }}," -C ./build/bin .
1397
1398      - name: Upload artifacts
1399        uses: actions/upload-artifact@v6
1400        with:
1401          path: llama-${{ steps.tag.outputs.name }}-bin-ubuntu-sycl-${{ matrix.build }}-x64.tar.gz
1402          name: llama-bin-ubuntu-sycl-${{ matrix.build }}-x64.tar.gz
1403
1404      - name: ccache-clear
1405        uses: ./.github/actions/ccache-clear
1406        with:
1407          key: release-ubuntu-24.04-sycl-${{ matrix.build }}
1408
1409  ubuntu-24-rocm:
1410    needs: [check-release, ui-build]
1411    if: ${{ needs.check-release.outputs.should_release == 'true' }}
1412
1413    runs-on: ubuntu-24.04
1414
1415    permissions:
1416      actions: write
1417
1418    strategy:
1419      matrix:
1420        include:
1421          - ROCM_VERSION: "10.0.0"
1422            gpu_targets: "gfx908;gfx90a;gfx942;gfx950;gfx1010;gfx1011;gfx1012;gfx1030;gfx1031;gfx1032;gfx1033;gfx1034;gfx1035;gfx1036;gfx1100;gfx1101;gfx1102;gfx1103;gfx1150;gfx1151;gfx1152;gfx1200;gfx1201"
1423            build: 'x64'
1424
1425    steps:
1426      - name: Clone
1427        id: checkout
1428        uses: actions/checkout@v6
1429        with:
1430          fetch-depth: 0
1431
1432      - name: Download UI build
1433        uses: actions/download-artifact@v7
1434        with:
1435          name: llama-ui.zip
1436          path: tools/ui/dist
1437
1438      - name: Free up disk space
1439        uses: ggml-org/free-disk-space@v1.3.1
1440        with:
1441          tool-cache: true
1442
1443      - name: ccache
1444        uses: ggml-org/ccache-action@v1.2.24
1445        with:
1446          key: release-ubuntu-24.04-rocm-${{ matrix.ROCM_VERSION }}-${{ matrix.build }}
1447          evict-old-files: 1d
1448          max-size: "1G"
1449
1450      - name: Tune ccache for reinstalled ROCm toolchain
1451        run: |
1452          # ROCm is pip-installed fresh each run, so the clang binary's mtime
1453          # changes every time. With the default compiler_check=mtime that
1454          # invalidates the cache; hash compiler contents instead so warm
1455          # builds hit.
1456          ccache --set-config=compiler_check=content
1457          ccache --set-config=sloppiness=time_macros,include_file_mtime,include_file_ctime
1458
1459      - name: Dependencies
1460        id: depends
1461        run: |
1462          sudo apt install -y build-essential git cmake wget
1463
1464      - name: Setup TheRock with Wheels
1465        id: therock_env
1466        run: |
1467          # Create Python virtual environment
1468          python3 -m venv .venv
1469          source .venv/bin/activate
1470
1471          # Install ROCm wheels for build
1472          # libraries = HIP runtime and CMake configs needed for linking
1473          # devel = compilers, headers, static libs
1474          python -m pip install --upgrade pip
1475          python -m pip install --index-url https://stable.repo.amd.com/rocm/whl-next/ "rocm[libraries,devel]==${{ matrix.ROCM_VERSION }}"
1476
1477          # Get ROCm installation paths using the rocm-sdk CLI tool
1478          ROCM_PATH=$(rocm-sdk path --root)
1479          CMAKE_PATH=$(rocm-sdk path --cmake)
1480          BIN_PATH=$(rocm-sdk path --bin)
1481          echo "ROCM_PATH=$ROCM_PATH"
1482          echo "CMAKE_PATH=$CMAKE_PATH"
1483          echo "BIN_PATH=$BIN_PATH"
1484
1485          # Set environment variables
1486          echo "ROCM_PATH=$ROCM_PATH" >> $GITHUB_ENV
1487          echo "CMAKE_PREFIX_PATH=$CMAKE_PATH" >> $GITHUB_ENV
1488          echo "HIP_PATH=$ROCM_PATH" >> $GITHUB_ENV
1489          echo "PATH=$BIN_PATH:${PATH}" >> $GITHUB_ENV
1490          echo "LD_LIBRARY_PATH=$ROCM_PATH/lib:${LD_LIBRARY_PATH:-}" >> $GITHUB_ENV
1491
1492          # Keep venv activated for subsequent steps
1493          echo "$(pwd)/.venv/bin" >> $GITHUB_PATH
1494
1495      - name: Build with native CMake HIP support
1496        id: cmake_build
1497        run: |
1498          cmake -B build -S . \
1499            -DCMAKE_HIP_COMPILER="$(hipconfig -l)/clang" \
1500            -DCMAKE_BUILD_TYPE=Release \
1501            -DGGML_BACKEND_DL=ON \
1502            -DGGML_NATIVE=OFF \
1503            -DCMAKE_INSTALL_RPATH='$ORIGIN' \
1504            -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
1505            -DGGML_CPU_ALL_VARIANTS=ON \
1506            -DGPU_TARGETS="${{ matrix.gpu_targets }}" \
1507            -DGGML_HIP=ON \
1508            -DHIP_PLATFORM=amd \
1509            ${{ env.CMAKE_ARGS }}
1510          cmake --build build --config Release -j $(nproc)
1511
1512      - name: Determine tag name
1513        id: tag
1514        uses: ./.github/actions/get-tag-name
1515
1516      - name: Get ROCm short version
1517        run: echo "ROCM_VERSION_SHORT=$(echo '${{ matrix.ROCM_VERSION }}' | cut -d '.' -f 1,2)" >> $GITHUB_ENV
1518
1519      - name: Pack artifacts
1520        id: pack_artifacts
1521        run: |
1522          cp LICENSE ./build/bin/
1523          tar -czvf llama-${{ steps.tag.outputs.name }}-bin-ubuntu-rocm-${{ env.ROCM_VERSION_SHORT }}-${{ matrix.build }}.tar.gz --transform "s,^\.,llama-${{ steps.tag.outputs.name }}," -C ./build/bin .
1524
1525      - name: Upload artifacts
1526        uses: actions/upload-artifact@v6
1527        with:
1528          path: llama-${{ steps.tag.outputs.name }}-bin-ubuntu-rocm-${{ env.ROCM_VERSION_SHORT }}-${{ matrix.build }}.tar.gz
1529          name: llama-bin-ubuntu-rocm-${{ env.ROCM_VERSION_SHORT }}-${{ matrix.build }}.tar.gz
1530
1531      - name: ccache-clear
1532        uses: ./.github/actions/ccache-clear
1533        with:
1534          key: release-ubuntu-24.04-rocm-${{ matrix.ROCM_VERSION }}-${{ matrix.build }}
1535
1536  ios-xcode:
1537    needs: [check-release]
1538    if: ${{ needs.check-release.outputs.should_release == 'true' }}
1539    runs-on: macos-26
1540
1541    steps:
1542      - name: Checkout code
1543        uses: actions/checkout@v6
1544        with:
1545          fetch-depth: 0
1546
1547      - name: Setup Xcode
1548        run: |
1549          sudo xcode-select -s /Applications/Xcode_26.4.app
1550
1551      - name: Build
1552        id: cmake_build
1553        run: |
1554          sysctl -a
1555          cmake -B build -G Xcode \
1556            -DGGML_METAL_EMBED_LIBRARY=ON \
1557            -DLLAMA_OPENSSL=OFF \
1558            -DLLAMA_BUILD_APP=OFF \
1559            -DLLAMA_BUILD_EXAMPLES=OFF \
1560            -DLLAMA_BUILD_TOOLS=OFF \
1561            -DLLAMA_BUILD_TESTS=OFF \
1562            -DLLAMA_BUILD_SERVER=OFF \
1563            -DCMAKE_SYSTEM_NAME=iOS \
1564            -DCMAKE_OSX_DEPLOYMENT_TARGET=16.0 \
1565            -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
1566          cmake --build build --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
1567
1568      - name: xcodebuild for swift package
1569        id: xcodebuild
1570        run: |
1571          # note: only macos and ios-device due to long build time
1572          # ref: https://github.com/ggml-org/llama.cpp/pull/27252
1573          ./build-xcframework.sh macos ios-device
1574
1575      - name: Build Xcode project
1576        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
1577
1578      - name: Determine tag name
1579        id: tag
1580        uses: ./.github/actions/get-tag-name
1581
1582      - name: Pack artifacts
1583        id: pack_artifacts
1584        run: |
1585          # Zip file is required for Swift Package Manager, which does not support tar.gz for binary targets.
1586          # For more details, see https://developer.apple.com/documentation/xcode/distributing-binary-frameworks-as-swift-packages
1587          zip -r -y llama-${{ steps.tag.outputs.name }}-xcframework.zip build-apple/llama.xcframework
1588
1589      - name: Upload artifacts
1590        uses: actions/upload-artifact@v6
1591        with:
1592          path: llama-${{ steps.tag.outputs.name }}-xcframework.zip
1593          name: llama-${{ steps.tag.outputs.name }}-xcframework.zip
1594
1595# TODO: this build is disabled to save Github Actions resources (https://github.com/ggml-org/llama.cpp/pull/23705)
1596#       in order to enable it again, we have to provision dedicated runners  to run it
1597#  openEuler-cann:
1598#    strategy:
1599#      matrix:
1600#        include:
1601#          # 910b with aclgraph (both architectures)
1602#          - arch: x86
1603#            chip_type: '910b'
1604#            build: 'Release'
1605#            use_acl_graph: 'on'
1606#          - arch: aarch64
1607#            chip_type: '910b'
1608#            build: 'Release'
1609#            use_acl_graph: 'on'
1610#          # 310p without aclgraph (both architectures)
1611#          - arch: x86
1612#            chip_type: '310p'
1613#            build: 'Release'
1614#            use_acl_graph: 'off'
1615#          - arch: aarch64
1616#            chip_type: '310p'
1617#            build: 'Release'
1618#            use_acl_graph: 'off'
1619#    runs-on: ${{ matrix.arch == 'aarch64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
1620#    steps:
1621#      - name: Checkout
1622#        uses: actions/checkout@v6
1623#        with:
1624#          fetch-depth: 0
1625#
1626#      - name: Free up disk space
1627#        uses: ggml-org/free-disk-space@v1.3.1
1628#        with:
1629#          tool-cache: true
1630#
1631#      - name: Set container image
1632#        id: cann-image
1633#        run: |
1634#          image="ascendai/cann:${{ matrix.chip_type == '910b' &&  '8.5.0-910b-openeuler24.03-py3.11' || '8.5.0-310p-openeuler24.03-py3.11' }}"
1635#          echo "image=${image}" >> "${GITHUB_OUTPUT}"
1636#
1637#      - name: Pull container image
1638#        run: docker pull "${{ steps.cann-image.outputs.image }}"
1639#
1640#      - name: Build
1641#        env:
1642#          BUILD_TYPE: ${{ matrix.build }}
1643#          SOC_TYPE: ascend${{ matrix.chip_type }}
1644#          USE_ACL_GRAPH: ${{ matrix.use_acl_graph }}
1645#        run: |
1646#          HOST_UID=$(id -u)
1647#          HOST_GID=$(id -g)
1648#
1649#          docker run --rm \
1650#            -v "${PWD}:/workspace" \
1651#            -w /workspace \
1652#            -e SOC_TYPE=${SOC_TYPE} \
1653#            -e BUILD_TYPE=${BUILD_TYPE} \
1654#            -e USE_ACL_GRAPH=${USE_ACL_GRAPH} \
1655#            "${{ steps.cann-image.outputs.image }}" \
1656#            bash -lc '
1657#              set -e
1658#              yum install -y --setopt=install_weak_deps=False --setopt=tsflags=nodocs git gcc gcc-c++ make cmake openssl-devel
1659#              yum clean all && rm -rf /var/cache/yum
1660#              git config --global --add safe.directory "/workspace"
1661#              export LD_LIBRARY_PATH=${ASCEND_TOOLKIT_HOME}/lib64:${ASCEND_TOOLKIT_HOME}/$(uname -m)-linux/devlib/:${LD_LIBRARY_PATH}
1662#              cmake -S . -B build \
1663#                  -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
1664#                  -DGGML_CANN=on \
1665#                  -DSOC_TYPE=${SOC_TYPE} \
1666#                  -DUSE_ACL_GRAPH=${USE_ACL_GRAPH}
1667#              cmake --build build -j $(nproc)
1668#
1669#              chown -R '"${HOST_UID}"':'"${HOST_GID}"' /workspace/build
1670#            '
1671#
1672#      - name: Determine tag name
1673#        id: tag
1674#        uses: ./.github/actions/get-tag-name
1675#
1676#      - name: Pack artifacts
1677#        run: |
1678#          cp LICENSE ./build/bin/
1679#          tar -czvf llama-${{ steps.tag.outputs.name }}-bin-${{ matrix.chip_type }}-openEuler-${{ matrix.arch }}${{ matrix.use_acl_graph == 'on' && '-aclgraph' || '' }}.tar.gz --transform "s,^\.,llama-${{ steps.tag.outputs.name }}," -C ./build/bin .
1680#
1681#      - name: Upload artifacts
1682#        uses: actions/upload-artifact@v6
1683#        with:
1684#          path: llama-${{ steps.tag.outputs.name }}-bin-${{ matrix.chip_type }}-openEuler-${{ matrix.arch }}${{ matrix.use_acl_graph == 'on' && '-aclgraph' || '' }}.tar.gz
1685#          name: llama-bin-${{ matrix.chip_type }}-openEuler-${{ matrix.arch }}${{ matrix.use_acl_graph == 'on' && '-aclgraph' || '' }}.tar.gz
1686
1687  ui-build:
1688    needs: [check-release]
1689    if: ${{ needs.check-release.outputs.should_release == 'true' }}
1690    uses: ./.github/workflows/ui-build.yml
1691
1692  release:
1693    if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
1694
1695    # Fine-grant permission
1696    # https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
1697    permissions:
1698        contents: write # for creating release
1699        id-token: write
1700        attestations: write
1701
1702    runs-on: ubuntu-slim
1703
1704    needs:
1705      - windows
1706      - windows-cpu
1707      - windows-cuda
1708      - windows-sycl
1709      - windows-rocm
1710      - windows-openvino
1711      - ubuntu-24-rocm
1712      - ubuntu-cpu
1713      - ubuntu-vulkan
1714      - ubuntu-cuda
1715      - ubuntu-24-openvino
1716      - ubuntu-24-sycl
1717      - android-arm64
1718      - macos-cpu
1719      - ios-xcode
1720      #- openEuler-cann
1721      - ui-build
1722
1723    outputs:
1724      tag_name: ${{ steps.tag.outputs.name }}
1725
1726    steps:
1727      - name: Clone
1728        id: checkout
1729        uses: actions/checkout@v6
1730        with:
1731          fetch-depth: 0
1732          ssh-key: ${{ secrets.DEPLOY_KEY_RELEASE }}
1733
1734      - name: Determine tag name
1735        id: tag
1736        uses: ./.github/actions/get-tag-name
1737
1738      - name: Download artifacts
1739        id: download-artifact
1740        uses: actions/download-artifact@v7
1741        with:
1742          path: ./artifact
1743          merge-multiple: true
1744
1745      - name: Merge artifacts
1746        id: move_artifacts
1747        run: |
1748          mkdir -p release
1749
1750          # the windows-cpu zip contains the full toolset (llama-server with the embedded
1751          # UI, ggml-cpu) - inject it into the other windows zips so that every archive
1752          # ships the same binaries, only with a different backend library on top
1753          echo "Injecting windows-cpu binaries (llama-server + CPU backend) into the backend zips..."
1754          for arch in x64 arm64; do
1755            cpu_zip="artifact/llama-bin-win-cpu-${arch}.zip"
1756            temp_dir=$(mktemp -d)
1757            echo "Extracting windows-cpu-${arch} package..."
1758            unzip "$cpu_zip" -d "$temp_dir"
1759
1760            echo "Merging into $arch zips..."
1761            for target_zip in artifact/llama-bin-win-*-${arch}.zip; do
1762              if [[ "$target_zip" == "$cpu_zip" ]]; then
1763                continue
1764              fi
1765              echo "Injecting into $(basename "$target_zip")"
1766              realpath_target_zip=$(realpath "$target_zip")
1767              (cd "$temp_dir" && zip -r "$realpath_target_zip" .)
1768            done
1769
1770            rm -rf "$temp_dir"
1771          done
1772
1773          echo "Renaming and moving zips to release..."
1774          for zip_file in artifact/llama-bin-win-*.zip; do
1775            base_name=$(basename "$zip_file" .zip)
1776            zip_name="llama-${{ steps.tag.outputs.name }}-${base_name#llama-}.zip"
1777            echo "Moving $zip_file to release/$zip_name"
1778            mv "$zip_file" "release/$zip_name"
1779          done
1780
1781          echo "Moving other artifacts..."
1782          mv -v artifact/*.zip release
1783          mv -v artifact/*.tar.gz release
1784
1785      - name: Download UI build
1786        id: download_ui
1787        uses: actions/download-artifact@v7
1788        with:
1789          name: llama-ui.zip
1790          path: ./ui-dist
1791
1792      - name: Package UI
1793        id: package_ui
1794        run: |
1795          tar -czvf release/llama-${{ steps.tag.outputs.name }}-ui.tar.gz --transform "s,^\.,llama-${{ steps.tag.outputs.name }}," -C ./ui-dist .
1796
1797      - name: Attest release artifacts
1798        id: attest
1799        uses: actions/attest@v4
1800        with:
1801          subject-path: 'release/*'
1802
1803      - name: Create and push git tag
1804        run: |
1805          TAG="${{ steps.tag.outputs.name }}"
1806          if git rev-parse -q --verify "refs/tags/${TAG}" >/dev/null 2>&1; then
1807            echo "Tag ${TAG} already exists, skipping creation"
1808          else
1809            git tag "${TAG}"
1810            git push origin "${TAG}"
1811          fi
1812
1813      - name: Create release
1814        id: create_release
1815        uses: ggml-org/action-create-release@v1
1816        env:
1817          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1818        with:
1819          tag_name: ${{ steps.tag.outputs.name }}
1820          prerelease: true
1821          body: |
1822            <details open>
1823
1824            ${{ github.event.head_commit.message }}
1825
1826            </details>
1827
1828            **Website:**
1829            - <https://llama.app>
1830
1831            **Attestations:**
1832            - <${{ steps.attest.outputs.attestation-url }}>
1833
1834            **macOS/iOS:**
1835            - [macOS Apple Silicon (arm64)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-macos-arm64.tar.gz)
1836            - macOS Apple Silicon (arm64, KleidiAI enabled) [DISABLED](https://github.com/ggml-org/llama.cpp/pull/23780)
1837            - [macOS Intel (x64)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-macos-x64.tar.gz)
1838            - [iOS XCFramework](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-xcframework.zip)
1839
1840            **Linux:**
1841            - [Ubuntu x64 (CPU)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-ubuntu-x64.tar.gz)
1842            - [Ubuntu arm64 (CPU)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-ubuntu-arm64.tar.gz)
1843            - [Ubuntu s390x (CPU)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-ubuntu-s390x.tar.gz)
1844            - [Ubuntu x64 (Vulkan)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-ubuntu-vulkan-x64.tar.gz)
1845            - [Ubuntu arm64 (Vulkan)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-ubuntu-vulkan-arm64.tar.gz)
1846            - [Ubuntu x64 (CUDA 12)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-ubuntu-cuda-12.8-x64.tar.gz) - [CUDA 12.8 libraries](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/cudart-llama-${{ steps.tag.outputs.name }}-bin-ubuntu-cuda-12.8-x64.tar.gz)
1847            - [Ubuntu x64 (CUDA 13)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-ubuntu-cuda-13.3-x64.tar.gz) - [CUDA 13.3 libraries](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/cudart-llama-${{ steps.tag.outputs.name }}-bin-ubuntu-cuda-13.3-x64.tar.gz)
1848            - [Ubuntu arm64 (CUDA 13)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-ubuntu-cuda-13.3-arm64.tar.gz) - [CUDA 13.3 libraries](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/cudart-llama-${{ steps.tag.outputs.name }}-bin-ubuntu-cuda-13.3-arm64.tar.gz)
1849            - [Ubuntu x64 (ROCm 10.0)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-ubuntu-rocm-10.0-x64.tar.gz)
1850            - [Ubuntu x64 (OpenVINO)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-ubuntu-openvino-${{ needs.ubuntu-24-openvino.outputs.openvino_version }}-x64.tar.gz)
1851            - [Ubuntu x64 (SYCL FP32)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-ubuntu-sycl-fp32-x64.tar.gz)
1852            - [Ubuntu x64 (SYCL FP16)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-ubuntu-sycl-fp16-x64.tar.gz)
1853
1854            **Android:**
1855            - [Android arm64 (CPU)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-android-arm64.tar.gz)
1856
1857            **Windows:**
1858            - [Windows x64 (CPU)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-win-cpu-x64.zip)
1859            - [Windows arm64 (CPU)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-win-cpu-arm64.zip)
1860            - [Windows arm64 (OpenCL Adreno)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-win-opencl-adreno-arm64.zip)
1861            - [Windows x64 (CUDA 12)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-win-cuda-12.4-x64.zip) - [CUDA 12.4 DLLs](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/cudart-llama-bin-win-cuda-12.4-x64.zip)
1862            - [Windows x64 (CUDA 13)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-win-cuda-13.3-x64.zip) - [CUDA 13.3 DLLs](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/cudart-llama-bin-win-cuda-13.3-x64.zip)
1863            - [Windows arm64 (CUDA 13)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-win-cuda-13.4-arm64.zip) - [CUDA 13.4 DLLs](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/cudart-llama-bin-win-cuda-13.4-arm64.zip)
1864            - [Windows x64 (Vulkan)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-win-vulkan-x64.zip)
1865            - [Windows x64 (OpenVINO)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-win-openvino-${{ needs.windows-openvino.outputs.openvino_version }}-x64.zip)
1866            - [Windows x64 (SYCL)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip)
1867            - [Windows x64 (ROCm 10.0)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-win-rocm-10.0-x64.zip)
1868
1869            **openEuler:**
1870            - [DISABLED](https://github.com/ggml-org/llama.cpp/pull/23705)
1871            - openEuler x86 (310p)
1872            - openEuler x86 (910b, ACL Graph)
1873            - openEuler aarch64 (310p)
1874            - openEuler aarch64 (910b, ACL Graph)
1875
1876            **UI:**
1877            - [UI](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-ui.tar.gz)
1878
1879      - name: Upload release
1880        id: upload_release
1881        uses: actions/github-script@v8
1882        with:
1883          github-token: ${{secrets.GITHUB_TOKEN}}
1884          script: |
1885            const path = require('path');
1886            const fs = require('fs');
1887            const release_id = '${{ steps.create_release.outputs.id }}';
1888            for (let file of await fs.readdirSync('./release')) {
1889              if (path.extname(file) === '.zip' || file.endsWith('.tar.gz')) {
1890                console.log('uploadReleaseAsset', file);
1891                await github.rest.repos.uploadReleaseAsset({
1892                  owner: context.repo.owner,
1893                  repo: context.repo.repo,
1894                  release_id: release_id,
1895                  name: file,
1896                  data: await fs.readFileSync(`./release/${file}`)
1897                });
1898              }
1899            }
1900
1901  ui-publish:
1902    if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
1903
1904    needs:
1905      - release
1906
1907    uses: ./.github/workflows/ui-publish.yml
1908    with:
1909      version_tag: ${{ needs.release.outputs.tag_name }}
1910    secrets:
1911      hf_token: ${{ secrets.HF_TOKEN_UI_STATIC_OUTPUT }}