Team Ai
Modelpublic

Felipe97/llama-cpp-compiled

sourceHugging Faceupdated 21d agoView on Hugging Face
0likes1.2kdownloads
build-apple.yml288 linesDownload Raw Back to workflows
1name: CI (apple)2 3on:4  workflow_dispatch: # allows manual triggering5  push:6    branches:7      - master8    paths: [9      '.github/workflows/build-apple.yml',10      '**/CMakeLists.txt',11      '**/.cmake',12      '**/*.h',13      '**/*.hpp',14      '**/*.c',15      '**/*.cpp',16      '**/*.swift',17      '**/*.m',18      '**/*.metal'19    ]20 21  pull_request:22    types: [opened, synchronize, reopened]23    paths: [24      '.github/workflows/build-apple.yml',25      'ggml/src/ggml-metal/**',26      'ggml/src/ggml-rpc/**'27    ]28 29concurrency:30  group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}31  cancel-in-progress: true32 33env:34  GGML_NLOOP: 335  GGML_N_THREADS: 136  LLAMA_ARG_LOG_COLORS: 137  LLAMA_ARG_LOG_PREFIX: 138  LLAMA_ARG_LOG_TIMESTAMPS: 139 40jobs:41  macos-latest-arm64:42    runs-on: macos-latest43 44    steps:45      - name: Clone46        id: checkout47        uses: actions/checkout@v648 49      - name: ccache50        uses: ggml-org/ccache-action@v1.2.2451        with:52          key: apple-arm6453          save: false54 55      - name: ccache-buckets-restore56        uses: ./.github/actions/ccache-buckets57        env:58          HF_TOKEN: ${{ secrets.HF_TOKEN_CI }}59        with:60          key: apple-arm6461          folder: llama.cpp62          hf_bucket: ggml-org/cache63 64      - name: Build65        id: cmake_build66        run: |67          sysctl -a68          cmake -B build \69            -DCMAKE_BUILD_RPATH="@loader_path" \70            -DLLAMA_FATAL_WARNINGS=ON \71            -DLLAMA_BUILD_BORINGSSL=ON \72            -DGGML_METAL_EMBED_LIBRARY=OFF \73            -DGGML_METAL_SHADER_DEBUG=ON \74            -DGGML_RPC=ON \75            -DCMAKE_OSX_DEPLOYMENT_TARGET=13.376          time cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)77 78      - name: ccache-buckets-save79        if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}80        uses: ./.github/actions/ccache-buckets81        env:82          HF_TOKEN: ${{ secrets.HF_TOKEN_CACHE_OUTPUT }}83        with:84          key: apple-arm6485          folder: llama.cpp86          evict-old-files: 1d87          hf_bucket: ggml-org/cache88          save: true89 90      - name: Check for leaks91        run: |92          cmd=(./build/bin/test-thread-safety -hf ggml-org/gemma-3-270m-qat-GGUF -ngl 99 -p "$(printf 'hello %.0s' {1..128})" -n 16 -c 512 -ub 32 -np 2 -t 2 -lv 1)93          leaks -atExit -- "${cmd[@]}"94          # Graphics devices are leaked by Metal in Apple code sometimes, so we ignore those leaks95          OBJC_DEBUG_MISSING_POOLS=YES "${cmd[@]}" 2>&1 | awk '{ print } index($0, "autoreleased with no pool in place") && !/class [a-zA-Z0-9]+Device autoreleased/ { found = 1 } END { exit found }'96 97      - name: Test98        id: cmake_test99        run: |100          cd build101          ctest -L main -E "test-llama-archs" --verbose --timeout 900102 103  macos-latest-x64:104    runs-on: macos-15-intel105 106    steps:107      - name: Clone108        id: checkout109        uses: actions/checkout@v6110 111      - name: ccache112        uses: ggml-org/ccache-action@v1.2.24113        with:114          key: apple-x64115          save: false116 117      - name: ccache-buckets-restore118        uses: ./.github/actions/ccache-buckets119        env:120          HF_TOKEN: ${{ secrets.HF_TOKEN_CI }}121        with:122          key: apple-x64123          folder: llama.cpp124          hf_bucket: ggml-org/cache125 126      - name: Build127        id: cmake_build128        run: |129          sysctl -a130          # Metal is disabled due to intermittent failures with Github runners not having a GPU:131          # https://github.com/ggml-org/llama.cpp/actions/runs/8635935781/job/23674807267#step:5:2313132          cmake -B build \133            -DCMAKE_BUILD_RPATH="@loader_path" \134            -DLLAMA_FATAL_WARNINGS=ON \135            -DLLAMA_BUILD_BORINGSSL=ON \136            -DGGML_METAL=OFF \137            -DGGML_RPC=ON \138            -DCMAKE_OSX_DEPLOYMENT_TARGET=13.3139          time cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)140 141      - name: ccache-buckets-save142        if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}143        uses: ./.github/actions/ccache-buckets144        env:145          HF_TOKEN: ${{ secrets.HF_TOKEN_CACHE_OUTPUT }}146        with:147          key: apple-x64148          folder: llama.cpp149          evict-old-files: 1d150          hf_bucket: ggml-org/cache151          save: true152 153      - name: Test154        id: cmake_test155        run: |156          cd build157          ctest -L main --verbose --timeout 900158 159  macos-latest-ios-xcode:160    runs-on: macos-latest161 162    steps:163      - name: Checkout code164        uses: actions/checkout@v6165 166      - name: Setup Xcode167        uses: ggml-org/setup-xcode@v1168        with:169          xcode-version: latest-stable170 171      - name: Build172        id: cmake_build173        run: |174          sysctl -a175          cmake -B build -G Xcode \176            -DGGML_METAL_EMBED_LIBRARY=ON \177            -DLLAMA_OPENSSL=OFF \178            -DLLAMA_BUILD_APP=OFF \179            -DLLAMA_BUILD_EXAMPLES=OFF \180            -DLLAMA_BUILD_TOOLS=OFF \181            -DLLAMA_BUILD_TESTS=OFF \182            -DLLAMA_BUILD_SERVER=OFF \183            -DCMAKE_SYSTEM_NAME=iOS \184            -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \185            -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml186          cmake --build build --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO187 188      - name: xcodebuild for swift package189        id: xcodebuild190        run: |191          ./build-xcframework.sh192 193      - name: Upload xcframework artifact194        uses: actions/upload-artifact@v6195        with:196          name: llama-xcframework197          path: build-apple/llama.xcframework/198          retention-days: 1199 200      - name: Build Xcode project201        run: |202          xcodebuild -downloadPlatform iOS203          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 build204 205  macos-latest-tvos:206    runs-on: macos-latest207 208    steps:209      - name: Clone210        id: checkout211        uses: actions/checkout@v6212 213      - name: Build214        id: cmake_build215        run: |216          sysctl -a217          cmake -B build -G Xcode \218            -DGGML_METAL_EMBED_LIBRARY=ON \219            -DLLAMA_BUILD_COMMON=OFF \220            -DLLAMA_BUILD_APP=OFF \221            -DLLAMA_BUILD_EXAMPLES=OFF \222            -DLLAMA_BUILD_TOOLS=OFF \223            -DLLAMA_BUILD_TESTS=OFF \224            -DLLAMA_BUILD_SERVER=OFF \225            -DCMAKE_SYSTEM_NAME=tvOS \226            -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \227            -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml228          cmake --build build --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO229 230  macos-latest-visionos:231    runs-on: macos-latest232 233    steps:234      - name: Clone235        id: checkout236        uses: actions/checkout@v6237 238      - name: Build239        id: cmake_build240        run: |241          sysctl -a242          cmake -B build -G Xcode \243            -DGGML_METAL_EMBED_LIBRARY=ON \244            -DLLAMA_BUILD_COMMON=OFF \245            -DLLAMA_BUILD_APP=OFF \246            -DLLAMA_BUILD_EXAMPLES=OFF \247            -DLLAMA_BUILD_TOOLS=OFF \248            -DLLAMA_BUILD_TESTS=OFF \249            -DLLAMA_BUILD_SERVER=OFF \250            -DCMAKE_SYSTEM_NAME=visionOS \251            -DCMAKE_OSX_DEPLOYMENT_TARGET=1.0 \252            -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml253          cmake --build build --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO254 255  macos-latest-swift:256    runs-on: macos-latest257    needs: macos-latest-ios-xcode258 259    strategy:260      matrix:261        destination: ['generic/platform=macOS', 'generic/platform=iOS', 'generic/platform=tvOS']262 263    steps:264      - name: Clone265        id: checkout266        uses: actions/checkout@v6267 268      - name: Download xcframework artifact269        uses: actions/download-artifact@v7270        with:271          name: llama-xcframework272          path: build-apple/llama.xcframework/273 274      - name: Build llama.cpp with CMake275        id: cmake_build276        run: |277          sysctl -a278          cmake -B build -G Xcode \279            -DGGML_METAL_EMBED_LIBRARY=ON \280            -DLLAMA_OPENSSL=OFF \281            -DLLAMA_BUILD_APP=OFF \282            -DLLAMA_BUILD_EXAMPLES=OFF \283            -DLLAMA_BUILD_TOOLS=OFF \284            -DLLAMA_BUILD_TESTS=OFF \285            -DLLAMA_BUILD_SERVER=OFF \286            -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"287          cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)288