char-fork/llama.cpp

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

Aldehir Rojascommon : implement common_schema internal representation for JSON schemas (#28736)acecd5603

char/aliceai-t5-moe
8.1 KiB234 linesraw
1name: CI (cpu)
2
3on:
4  workflow_dispatch: # allows manual triggering
5  push:
6    branches:
7      - master
8    paths: [
9      '.github/workflows/build-cpu.yml',
10      '.github/workflows/build-cmake-pkg.yml',
11      '**/CMakeLists.txt',
12      '**/.cmake',
13      '**/*.h',
14      '**/*.hpp',
15      '**/*.c',
16      '**/*.cpp',
17    ]
18
19  pull_request:
20    types: [opened, synchronize, reopened]
21    paths: [
22      '.github/workflows/build-cpu.yml',
23      '.github/workflows/build-cmake-pkg.yml',
24      'ggml/src/ggml-rpc/**',
25      '**/CMakeLists.txt',
26      '**/.cmake',
27      '**/*.h',
28      '**/*.hpp',
29      '**/*.c',
30      '**/*.cpp'
31    ]
32
33concurrency:
34  group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
35  cancel-in-progress: true
36
37env:
38  GGML_NLOOP: 3
39  GGML_N_THREADS: 1
40  LLAMA_ARG_LOG_COLORS: 1
41  LLAMA_ARG_LOG_PREFIX: 1
42  LLAMA_ARG_LOG_TIMESTAMPS: 1
43
44jobs:
45  build-cmake-pkg:
46    uses: ./.github/workflows/build-cmake-pkg.yml
47
48  ubuntu:
49    strategy:
50      matrix:
51        include:
52          - build: 'x64'
53            os: ubuntu-22.04
54          - build: 'arm64'
55            os: ubuntu-24.04-arm
56
57    runs-on: ${{ matrix.os }}
58
59    steps:
60      - name: Clone
61        id: checkout
62        uses: actions/checkout@v6
63
64      - name: ccache
65        uses: ggml-org/ccache-action@v1.2.24
66        with:
67          key: cpu-${{ matrix.os }}
68          save: false
69
70      - name: Build Dependencies
71        id: build_depends
72        run: |
73          sudo apt-get update
74          sudo apt-get install -y --no-install-recommends \
75            python3 python3-pip python3-dev python3-wheel \
76            libjpeg-dev build-essential libssl-dev \
77            git-lfs
78
79      - name: Toolchain workaround (GCC 14)
80        if: ${{ contains(matrix.os, 'ubuntu-24.04') }}
81        run: |
82          sudo apt-get install -y gcc-14 g++-14
83          echo "CC=gcc-14" >> "$GITHUB_ENV"
84          echo "CXX=g++-14" >> "$GITHUB_ENV"
85
86      - name: Python Dependencies
87        id: python_depends
88        run: |
89          export PIP_BREAK_SYSTEM_PACKAGES="1"
90          python3 -m pip install --upgrade pip setuptools
91          pip3 install ./gguf-py
92
93      - name: ccache-buckets-restore
94        uses: ./.github/actions/ccache-buckets
95        env:
96          HF_TOKEN: ${{ secrets.HF_TOKEN_CI }}
97        with:
98          key: cpu-${{ matrix.os }}
99          folder: llama.cpp
100          hf_bucket: ggml-org/cache
101
102      - name: Build
103        id: cmake_build
104        run: |
105          cmake -B build \
106            -DGGML_NATIVE=OFF \
107            -DLLAMA_FATAL_WARNINGS=ON \
108            -DGGML_RPC=ON
109          time cmake --build build --config Release -j $(nproc)
110
111      - name: ccache-buckets-save
112        if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
113        uses: ./.github/actions/ccache-buckets
114        env:
115          HF_TOKEN: ${{ secrets.HF_TOKEN_CACHE_OUTPUT }}
116        with:
117          key: cpu-${{ matrix.os }}
118          folder: llama.cpp
119          evict-old-files: 1d
120          hf_bucket: ggml-org/cache
121          save: true
122
123      - name: Test
124        id: cmake_test
125        run: |
126          cd build
127          ctest -L main --verbose --timeout 900
128
129      - name: Test llama2c conversion
130        id: llama2c_test
131        run: |
132          cd build
133          echo "Fetch tokenizer"
134          wget https://huggingface.co/karpathy/tinyllamas/resolve/main/stories260K/tok512.bin
135          echo "Fetch llama2c model"
136          wget https://huggingface.co/karpathy/tinyllamas/resolve/main/stories260K/stories260K.bin
137          ./bin/llama-convert-llama2c-to-ggml --copy-vocab-from-model ./tok512.bin --llama2c-model stories260K.bin --llama2c-output-model stories260K.gguf
138          ./bin/llama-completion -m stories260K.gguf -p "One day, Lily met a Shoggoth" -n 500 -c 256
139
140  windows:
141    name: windows / ${{ matrix.build }}
142    runs-on: windows-2025
143
144    env:
145      OPENBLAS_VERSION: 0.3.23
146      SDE_VERSION: 9.33.0-2024-01-07
147
148    strategy:
149      matrix:
150        include:
151          - build: 'x64-cpu-static'
152            arch: 'x64'
153            defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/x64-windows-llvm.cmake -DGGML_NATIVE=OFF -DGGML_OPENMP_FETCH=ON -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -DBUILD_SHARED_LIBS=OFF'
154          - build: 'x64-openblas'
155            arch: 'x64'
156            defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/x64-windows-llvm.cmake -DGGML_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON -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"'
157          - build: 'arm64'
158            arch: 'arm64'
159            defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-llvm.cmake -DGGML_NATIVE=OFF -DGGML_OPENMP_FETCH=ON -DLLAMA_BUILD_SERVER=ON'
160
161    steps:
162      - name: Clone
163        id: checkout
164        uses: actions/checkout@v6
165
166      - name: ccache
167        uses: ggml-org/ccache-action@v1.2.24
168        with:
169          key: cpu-windows-2025-${{ matrix.build }}
170          variant: ccache
171          evict-old-files: 1d
172          save: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
173
174      - name: Download OpenBLAS
175        id: get_openblas
176        if: ${{ matrix.build == 'x64-openblas' }}
177        run: |
178          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"
179          curl.exe -o $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt -L "https://github.com/xianyi/OpenBLAS/raw/v${env:OPENBLAS_VERSION}/LICENSE"
180          mkdir $env:RUNNER_TEMP/openblas
181          tar.exe -xvf $env:RUNNER_TEMP/openblas.zip -C $env:RUNNER_TEMP/openblas
182          $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
183          $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
184          $lib =  $(join-path $msvc 'bin\Hostx64\x64\lib.exe')
185          & $lib /machine:x64 "/def:${env:RUNNER_TEMP}/openblas/lib/libopenblas.def" "/out:${env:RUNNER_TEMP}/openblas/lib/openblas.lib" /name:openblas.dll
186
187      - name: Install Ninja
188        id: install_ninja
189        run: |
190          choco install ninja
191
192      - name: Build
193        id: cmake_build
194        run: |
195          cmake -S . -B build ${{ matrix.defines }} `
196            -DLLAMA_BUILD_BORINGSSL=ON
197          cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS}
198
199      - name: Add libopenblas.dll
200        id: add_libopenblas_dll
201        if: ${{ matrix.build == 'x64-openblas' }}
202        run: |
203          cp $env:RUNNER_TEMP/openblas/bin/libopenblas.dll ./build/bin/Release/openblas.dll
204          cp $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt ./build/bin/Release/OpenBLAS-${env:OPENBLAS_VERSION}.txt
205
206      - name: Test
207        id: cmake_test
208        if: ${{ matrix.arch == 'x64' }}
209        run: |
210          cd build
211          ctest -L main -C Release --verbose --timeout 900
212
213      # TODO: disabled for now, consider adding tests for all CPU variants instead
214      # - name: Test (Intel SDE)
215      #   id: cmake_test_sde
216      #   if: ${{ matrix.build == 'avx512-x64' && env.HAS_AVX512F == '0' }} # use Intel SDE for AVX-512 emulation
217      #   run: |
218      #     curl.exe -o $env:RUNNER_TEMP/sde.tar.xz -L "https://downloadmirror.intel.com/813591/sde-external-${env:SDE_VERSION}-win.tar.xz"
219      #     # for some weird reason windows tar doesn't like sde tar.xz
220      #     7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar.xz
221      #     7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar
222      #     $sde = $(join-path $env:RUNNER_TEMP sde-external-${env:SDE_VERSION}-win/sde.exe)
223      #     cd build
224      #     & $sde -future -- ctest -L main -C Release --verbose --timeout 900
225
226      - name: ccache-clear
227        uses: ./.github/actions/ccache-clear
228        env:
229          GH_TOKEN: ${{ github.token }}
230        with:
231          key: cpu-windows-2025-${{ matrix.build }}
232          older: 5m
233          min: 1
234          dry-run: ${{ github.event_name != 'push' || github.ref != 'refs/heads/master' }}