Skip to content

Commit 02d5316

Browse files
ggerganovdanbev
andauthored
ci : refactor + optimize (#3847)
* ci : add ccache clear action * ci : split self-hosted GPU jobs into build-self-hosted.yml Extract self-hosted runner jobs from build.yml into a dedicated build-self-hosted.yml following the llama.cpp pattern: - gpu-cuda (NVIDIA Linux) - gpu-vulkan-nvidia-cm (NVIDIA Linux) - gpu-vulkan-nvidia-cm2 (NVIDIA Linux + COOPMAT2) - gpu-metal (macOS ARM64) - gpu-vulkan (macOS ARM64) GitHub-hosted CPU jobs remain in build.yml. Assisted-by: llama.cpp:local pi * ci : split release jobs into release.yml Extract release-related jobs from build.yml into a dedicated release.yml following the llama.cpp pattern: - determine-tag - windows (Win32/x64, SDL2) - windows-blas (Win32/x64, OpenBLAS) - windows-cublas (x64, CUDA 11.8/12.4) - ios-xcode-build - bindings-java (depends on windows) - release (artifact aggregation + GitHub release) CoreML job stays in build.yml with its own local tag calculation. Assisted-by: llama.cpp:local pi * ci : remove bindings-java job from release.yml Assisted-by: llama.cpp:local pi * cont : add manual trigger for build.yml * cont : remove obsolete ifs * ci : extract sanitizer job to bild-sanitize.yml * ci : extract linux jobs into build-linux.yml * ci : extract macos jobs to build-macos.yml * ci : extract gcc jobs to build-gcc.yml * ci : extract clang jobs to build-clang.yml * ci : extract sycl jobs to build-sycl.yml * ci : extract windows jobs to build-windows.yml * ci : extract emscripten job to build-wasm.yml * ci : extract android jobs into build-android.yml * ci : extract quantize job to quantize.yml * ci : extract coreml job into coreml.yml * ci : extract vad job to vad.yml * ci : extract cpu jobs to build-cpu.yml * ci : make naming of yml files consistent * ci : add --fail to curl download and propagate This commit adds the --fail option to the model download scripts so that if the model download returns a server error this is picked up. This is then detected in run.sh and a error message is displayed and the script stops and returns an error. The motivation for this is that currently it is possible for the model download to fail but this script proceeds and instead of a model file the contents will be an html page probably with the error. This will then cause the model to not be able to load due to a missing magic number. I'm not sure we can do much about the downloading failing, perhaps a retry but at least this will give a clearer error message. Refs: https://github.com/danbev/whisper.cpp/actions/runs/26866349389/job/79230794512 * ci : enable command traces to see download command in use * ci : add retry functionality to download model script This commit adds curl retry options to the model download script. The motivation is that currently when CI jobs run huggingface rate limit the requests and return: ```console curl: (22) The requested URL returned error: 429 ``` This is an attempt to work around this and if it does not work then we can an authorization token. * ci : extract freebsd job to build-freebsd.yml This job has been commented out as it has been flaky in the past. I'll monitor this and if it continues to be unreliable we can disable it in the github actions GUI instead of commenting it out like we did before. * ci : add ccache to jobs (non-docker builds) The ccache will only be saved on pushed to master. * ci : bump ccache-action version to v1.2.21 The motivation for this is that the save parameter does not seem to work with the current version. * ci : add ccache to docker jobs in build-linux.yml * ci : add debug statements to linux docker build * ci : set CCACHE_DIR for build-linux.yml * ci : add ccache to the remaining docker jobs * ci : remove build-linux.yml This commit remove build-linux.yml as the same jobs are also run by build-gcc.yml, with the exception that build-gcc.yml also run ctest). So keeping build-gcc.yml and removing the redundant build-linux.yml. * ci : add linux build artifacts to release * ci : revert to hendrikmuhs/ccache-action for win job This is currently causing the following failure: ```console sccache C:\PROGRA~1\NVIDIA~1\CUDA\v\bin\nvcc.exe -forward-unknown-to-host-compiler -DGGML_BACKEND_BUILD -DGGML_BACKEND_SHARED -DGGML_CUDA_PEER_MAX_BATCH_SIZE=128 -DGGML_SCHED_MAX_COPIES=4 -DGGML_SHARED -D_CRT_SECURE_NO_WARNINGS -D_XOPEN_SOURCE=600 -Dggml_cuda_EXPORTS -DCMAKE_INTDIR=\"Release\" -ID:\a\whisper.cpp\whisper.cpp\ggml\src\ggml-cuda\.. -ID:\a\whisper.cpp\whisper.cpp\ggml\src\..\include -isystem "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v\include" -Xcompiler="-MD -O2 -Ob2" -DNDEBUG -std=c++17 -arch=native -use_fast_math -extended-lambda -Xcompiler /Zc:preprocessor -MD -MT ggml\src\ggml-cuda\CMakeFiles\ggml-cuda.dir\Release\allreduce.cu.obj -MF ggml\src\ggml-cuda\CMakeFiles\ggml-cuda.dir\Release\allreduce.cu.obj.d -x cu -c D:\a\whisper.cpp\whisper.cpp\ggml\src\ggml-cuda\allreduce.cu -o ggml\src\ggml-cuda\CMakeFiles\ggml-cuda.dir\Release\allreduce.cu.obj -Xcompiler=-Fdggml\src\ggml-cuda\CMakeFiles\ggml-cuda.dir\Release\,-FS sccache: encountered fatal error sccache: error: Could not parse shell line sccache: caused by: Could not parse shell line ``` Refs: https://github.com/danbev/whisper.cpp/actions/runs/26883673904/job/79290017353 * ci : make static linux artifacts * ci : make linux release artifact names consistent This commit removes the tag form the linux release artifacts to be consistent with the existing artifacts. If we want to include the tag then we can do that in a follow-up PR. * ci : fix linux zip files to have a directory * ci : add HF_TOKEN secret for HF download authorization This is to avoid the HR rate limiting when downloading model. --------- Co-authored-by: Daniel Bevenius <daniel.bevenius@gmail.com>
1 parent 610e664 commit 02d5316

20 files changed

Lines changed: 1952 additions & 1574 deletions
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: "ccache-clear"
2+
description: "Delete all GitHub Actions caches matching a key prefix"
3+
inputs:
4+
key:
5+
description: "Cache key prefix to match and delete"
6+
required: true
7+
8+
runs:
9+
using: "composite"
10+
steps:
11+
- name: Clear caches
12+
shell: bash
13+
run: |
14+
CACHES=$(gh cache list --key "ccache-${{ inputs.key }}" --json id,key --jq '.[] | "\(.id) \(.key)"' 2>/dev/null)
15+
if [ -z "$CACHES" ]; then
16+
echo "No caches found with key prefix: ${{ inputs.key }}"
17+
exit 0
18+
fi
19+
while read -r id key; do
20+
echo "Deleting cache: $id ($key)"
21+
gh cache delete "$id"
22+
done <<< "$CACHES"
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: CI (android)
2+
3+
on:
4+
workflow_dispatch: # allows manual triggering
5+
push:
6+
branches:
7+
- master
8+
paths: ['.github/workflows/build-android.yml',
9+
'**/CMakeLists.txt',
10+
'**/*.h',
11+
'**/*.hpp',
12+
'**/*.c',
13+
'**/*.cpp',
14+
'**/*.java']
15+
16+
pull_request:
17+
types: [opened, synchronize, reopened]
18+
paths-ignore:
19+
- 'bindings/ruby/**' # handled by bindings-ruby.yml
20+
- 'bindings/go/**' # handled by bindings-go.yml
21+
- 'examples/addon.node/**' # handled by examples.yml
22+
23+
concurrency:
24+
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
25+
cancel-in-progress: true
26+
27+
jobs:
28+
android:
29+
runs-on: ubuntu-22.04
30+
31+
steps:
32+
- name: Clone
33+
uses: actions/checkout@v6
34+
with:
35+
path: whisper
36+
37+
- name: Install Java
38+
uses: actions/setup-java@v5
39+
with:
40+
distribution: zulu
41+
java-version: 21
42+
43+
- name: Setup Android SDK
44+
uses: android-actions/setup-android@v3
45+
46+
- name: Build
47+
run: |
48+
cd whisper/examples/whisper.android
49+
./gradlew assembleRelease --no-daemon
50+
51+
- name: Build with external ggml
52+
run: |
53+
export PATH_TO_GGML=$PWD/ggml
54+
cd whisper/examples/whisper.android
55+
./gradlew assembleRelease --no-daemon
56+
57+
android_java:
58+
runs-on: ubuntu-22.04
59+
60+
steps:
61+
- name: Clone
62+
uses: actions/checkout@v6
63+
64+
- name: set up JDK 11
65+
uses: actions/setup-java@v5
66+
with:
67+
java-version: '11'
68+
distribution: 'temurin'
69+
cache: gradle
70+
71+
- name: Setup Android SDK
72+
uses: android-actions/setup-android@v3
73+
with:
74+
cmdline-tools-version: 9.0
75+
76+
- name: Build
77+
run: |
78+
cd examples/whisper.android.java
79+
chmod +x ./gradlew
80+
./gradlew assembleRelease

.github/workflows/build-clang.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: CI (clang)
2+
3+
on:
4+
workflow_dispatch: # allows manual triggering
5+
push:
6+
branches:
7+
- master
8+
paths: ['.github/workflows/build-clang.yml',
9+
'**/CMakeLists.txt',
10+
'**/Makefile',
11+
'**/*.mk',
12+
'**/*.cmake',
13+
'**/*.in',
14+
'**/*.h',
15+
'**/*.hpp',
16+
'**/*.c',
17+
'**/*.cpp',
18+
'**/*.cu',
19+
'**/*.cuh',
20+
'**/*.cl']
21+
22+
pull_request:
23+
types: [opened, synchronize, reopened]
24+
paths-ignore:
25+
- 'bindings/ruby/**' # handled by bindings-ruby.yml
26+
- 'bindings/go/**' # handled by bindings-go.yml
27+
- 'examples/addon.node/**' # handled by examples.yml
28+
29+
concurrency:
30+
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
31+
cancel-in-progress: true
32+
33+
env:
34+
ubuntu_image: "ubuntu:22.04"
35+
36+
jobs:
37+
ubuntu-22-clang:
38+
runs-on: ubuntu-22.04
39+
40+
strategy:
41+
fail-fast: false
42+
matrix:
43+
build: [Debug, Release]
44+
#arch: [linux/amd64, linux/arm64, linux/arm/v7, linux/ppc64le]
45+
# TODO: arm/v7 disabled due to clang bug
46+
# https://github.com/ggerganov/whisper.cpp/actions/runs/9657764109/job/26637633042?pr=2256#step:4:1990
47+
arch: [linux/amd64, linux/ppc64le]
48+
49+
steps:
50+
- name: Clone
51+
uses: actions/checkout@v6
52+
53+
- name: Set CCACHE_DIR
54+
run: echo "CCACHE_DIR=${{ runner.temp }}/ccache" >> $GITHUB_ENV
55+
56+
- name: ccache
57+
uses: ggml-org/ccache-action@v1.2.21
58+
with:
59+
key: clang-${{ matrix.arch }}-${{ matrix.build }}
60+
evict-old-files: 1d
61+
save: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
62+
63+
- name: Set up QEMU
64+
uses: docker/setup-qemu-action@v3
65+
66+
- name: Build ${{ matrix.arch }}
67+
run: |
68+
docker run --platform ${{ matrix.arch }} --rm \
69+
-v ${{ github.workspace }}:/workspace \
70+
-v ${CCACHE_DIR}:${CCACHE_DIR} \
71+
-e CCACHE_DIR=${CCACHE_DIR} \
72+
-w /workspace ${{ env.ubuntu_image }} /bin/sh -c '
73+
set -e
74+
export DEBIAN_FRONTEND=noninteractive
75+
sed -i "s|archive.ubuntu.com|mirrors.kernel.org|g" /etc/apt/sources.list
76+
sed -i "s|security.ubuntu.com|mirrors.kernel.org|g" /etc/apt/sources.list
77+
78+
apt update
79+
apt install -y clang build-essential cmake libsdl2-dev git ccache
80+
cmake . -DWHISPER_SDL2=ON -DCMAKE_BUILD_TYPE=${{ matrix.build }} \
81+
-DCMAKE_CXX_COMPILER=clang++ \
82+
-DCMAKE_C_COMPILER=clang \
83+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
84+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
85+
make
86+
ctest -L gh --output-on-failure'
87+
88+
ubuntu-22-clang-arm64:
89+
runs-on: ubuntu-22.04-arm
90+
91+
strategy:
92+
fail-fast: false
93+
matrix:
94+
build: [Debug, Release]
95+
96+
steps:
97+
- name: Clone
98+
uses: actions/checkout@v6
99+
100+
- name: ccache
101+
uses: ggml-org/ccache-action@v1.2.21
102+
with:
103+
key: clang-arm64-${{ matrix.build }}
104+
evict-old-files: 1d
105+
save: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
106+
107+
- name: Install dependencies
108+
run: |
109+
sudo apt-get update
110+
sudo apt-get install -y clang build-essential cmake libsdl2-dev git
111+
112+
- name: Build and Test
113+
run: |
114+
cmake . -DWHISPER_SDL2=ON \
115+
-DCMAKE_BUILD_TYPE=${{ matrix.build }} \
116+
-DCMAKE_CXX_COMPILER=clang++ \
117+
-DCMAKE_C_COMPILER=clang \
118+
-DGGML_NATIVE=OFF \
119+
-DGGML_CPU_ARM_ARCH=armv8-a
120+
make
121+
ctest -L gh --output-on-failure

.github/workflows/build-coreml.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: CI (coreml)
2+
3+
on:
4+
workflow_dispatch: # allows manual triggering
5+
push:
6+
branches:
7+
- master
8+
tags:
9+
- 'v*'
10+
paths: ['.github/workflows/build-coreml.yml',
11+
'**/CMakeLists.txt',
12+
'**/*.h',
13+
'**/*.hpp',
14+
'**/*.c',
15+
'**/*.cpp',
16+
'**/*.swift',
17+
'**/*.m',
18+
'**/*.mm',
19+
'**/*.metal']
20+
21+
concurrency:
22+
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
23+
cancel-in-progress: true
24+
25+
env:
26+
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
27+
28+
jobs:
29+
coreml-base-en:
30+
runs-on: macos-latest
31+
32+
steps:
33+
- name: Checkout with full history
34+
uses: actions/checkout@v6
35+
with:
36+
fetch-depth: 0
37+
38+
- name: Set environment variables
39+
id: set_vars
40+
run: |
41+
BUILD_NUMBER=$(git rev-list --count HEAD)
42+
SHORT_HASH=$(git rev-parse --short=7 HEAD)
43+
if [[ "${{ github.ref_type }}" == "tag" ]]; then
44+
TAG_NAME="${{ github.ref_name }}"
45+
elif [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
46+
TAG_NAME="b${BUILD_NUMBER}"
47+
else
48+
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
49+
TAG_NAME="${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}"
50+
fi
51+
echo "MODEL_NAME=base.en" >> $GITHUB_ENV
52+
echo "GEN_MODEL_NAME=whisper-${TAG_NAME}-ggml-base.en-encoder.mlmodelc" >> $GITHUB_ENV
53+
54+
- name: Download model
55+
env:
56+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
57+
run: |
58+
./models/download-ggml-model.sh ${{ env.MODEL_NAME }}
59+
60+
- name: Generate CoreML model
61+
run: |
62+
python3.11 -m venv venv
63+
source venv/bin/activate
64+
pip install ane_transformers openai-whisper coremltools
65+
./models/generate-coreml-model.sh ${{ env.MODEL_NAME }}

0 commit comments

Comments
 (0)