Skip to content

Commit 9e3cb3e

Browse files
committed
CI: EDGE-161: Migration of lfm2 audio workflow from inference-engine (ggml-org#48)
To trigger the pipeline, add the audio-release label to the PR. PR must target tarek/feat/audio2
1 parent 83596d9 commit 9e3cb3e

6 files changed

Lines changed: 348 additions & 0 deletions

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: "Build llama-lfm2-audio (Docker Cross-Compilation)"
2+
description: "Cross-compiles llama-lfm2-audio using Docker and uploads artifacts"
3+
4+
inputs:
5+
platform:
6+
description: "Platform identifier (e.g., ubuntu-arm64)"
7+
required: true
8+
docker_image:
9+
description: "Docker image name from docker-images directory"
10+
required: true
11+
docker_user_name:
12+
description: "Username for Docker container"
13+
required: false
14+
default: "docker-user"
15+
16+
runs:
17+
using: "composite"
18+
steps:
19+
- name: Setup Docker cache paths
20+
id: docker-params
21+
shell: bash
22+
run: |
23+
echo "cache_path=$PWD/.cache-${{ inputs.platform }}-user-$(id -u)" >> $GITHUB_OUTPUT
24+
echo "docker_cache_path=/home/${{ inputs.docker_user_name }}/.cache" >> $GITHUB_OUTPUT
25+
echo "docker_image_name=liquid-${{ inputs.platform }}-$(id -u)" >> $GITHUB_OUTPUT
26+
27+
- name: Build Docker image for cross-compilation
28+
shell: bash
29+
run: |
30+
docker build \
31+
--build-arg GROUP_ID=$(id -g) \
32+
--build-arg USER_ID=$(id -u) \
33+
--build-arg USER_NAME=${{ inputs.docker_user_name }} \
34+
-t ${{ steps.docker-params.outputs.docker_image_name }} .github/docker/${{ inputs.docker_image }}
35+
36+
- name: Configure and build llama-lfm2-audio
37+
shell: bash
38+
run: |
39+
cp .github/cmake/llama-lfm2-audio-presets.json ./CMakeUserPresets.json
40+
41+
mkdir -p ${{ steps.docker-params.outputs.cache_path }}
42+
docker run \
43+
--rm \
44+
-v $PWD:/workdir \
45+
-v ${{ steps.docker-params.outputs.cache_path }}:${{ steps.docker-params.outputs.docker_cache_path }} \
46+
-w /workdir \
47+
${{ steps.docker-params.outputs.docker_image_name }} \
48+
bash --login -c "
49+
rm -rf build-${{ inputs.platform }} \
50+
&& cmake --preset lfm2-audio-${{ inputs.platform }} \
51+
&& cmake --build build-${{ inputs.platform }} --config Release --target llama-lfm2-audio -j \$(nproc 2>/dev/null || echo 4) \
52+
&& cmake --build build-${{ inputs.platform }} --config Release --target llama-mtmd-cli -j \$(nproc 2>/dev/null || echo 4) \
53+
&& cd build-${{ inputs.platform }}/bin \
54+
&& aarch64-linux-gnu-strip --strip-all llama-lfm2-audio llama-mtmd-cli \
55+
&& find . -type f -name '*.so' -exec aarch64-linux-gnu-strip --strip-all {} \;
56+
"
57+
58+
- name: Create release package
59+
shell: bash
60+
run: |
61+
mkdir -p artifacts
62+
cd build-${{ inputs.platform }}
63+
cp ../LICENSE bin
64+
mv bin lfm2-audio-${{ inputs.platform }}
65+
mv lfm2-audio-${{ inputs.platform }} ../artifacts/
66+
67+
- name: Upload to GitHub Artifacts
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: lfm2-audio-${{ inputs.platform }}
71+
path: artifacts/
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: "Build llama-lfm2-audio (Native)"
2+
description: "Builds llama-lfm2-audio natively and uploads artifacts"
3+
4+
inputs:
5+
platform:
6+
description: "Platform identifier (e.g., ubuntu-x64, macos-arm64, android-arm64)"
7+
required: true
8+
setup_ndk:
9+
description: "Whether to setup Android NDK"
10+
required: false
11+
default: "false"
12+
ndk_version:
13+
description: "Android NDK version to install"
14+
required: false
15+
default: "29.0.14206865"
16+
17+
runs:
18+
using: "composite"
19+
steps:
20+
- name: Setup Java for Android
21+
if: inputs.setup_ndk == 'true'
22+
uses: actions/setup-java@v3
23+
with:
24+
java-version: "17"
25+
distribution: "temurin"
26+
27+
- name: Setup Android SDK
28+
if: inputs.setup_ndk == 'true'
29+
uses: android-actions/setup-android@v3
30+
31+
- name: Install Android NDK
32+
if: inputs.setup_ndk == 'true'
33+
shell: bash
34+
run: |
35+
sdkmanager "ndk;${{ inputs.ndk_version }}"
36+
NDK_PATH="${ANDROID_HOME}/ndk/${{ inputs.ndk_version }}"
37+
echo "ANDROID_NDK_ROOT=${NDK_PATH}" >> $GITHUB_ENV
38+
echo "Android NDK installed at: ${NDK_PATH}"
39+
ls -la "${NDK_PATH}/build/cmake/" || echo "Toolchain path not found"
40+
41+
- name: Configure and build llama-lfm2-audio
42+
shell: bash
43+
run: |
44+
cp .github/cmake/llama-lfm2-audio-presets.json ./CMakeUserPresets.json
45+
46+
rm -rf build-${{ inputs.platform }}
47+
cmake --preset lfm2-audio-${{ inputs.platform }}
48+
cmake --build build-${{ inputs.platform }} --config Release --target llama-lfm2-audio -j $(nproc 2>/dev/null || sysctl -n hw.logicalcpu 2>/dev/null || echo 4)
49+
cmake --build build-${{ inputs.platform }} --config Release --target llama-mtmd-cli -j $(nproc 2>/dev/null || sysctl -n hw.logicalcpu 2>/dev/null || echo 4)
50+
51+
- name: Strip debug symbols
52+
shell: bash
53+
run: |
54+
# Note: Linker flags (--strip-all) work on Linux but not on macOS.
55+
# Using the strip command to minimize divergence between platforms.
56+
cd build-${{ inputs.platform }}/bin
57+
58+
if [[ "${{ inputs.platform }}" == "macos-arm64" ]]; then
59+
strip llama-lfm2-audio llama-mtmd-cli
60+
find . -type f -name "*.dylib" -exec strip {} \;
61+
elif [[ "${{ inputs.platform }}" == "android-arm64" ]]; then
62+
${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip --strip-all llama-lfm2-audio llama-mtmd-cli
63+
find . -type f -name "*.so" -exec ${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip --strip-all {} \;
64+
else
65+
# Linux
66+
strip --strip-all llama-lfm2-audio llama-mtmd-cli
67+
find . -type f -name "*.so" -exec strip --strip-all {} \;
68+
fi
69+
70+
- name: Create release package
71+
shell: bash
72+
run: |
73+
mkdir -p artifacts
74+
cd build-${{ inputs.platform }}
75+
cp ../LICENSE bin
76+
mv bin lfm2-audio-${{ inputs.platform }}
77+
mv lfm2-audio-${{ inputs.platform }} ../artifacts/
78+
79+
- name: Upload to GitHub Artifacts
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: lfm2-audio-${{ inputs.platform }}
83+
path: artifacts/
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
set(CMAKE_SYSTEM_NAME Linux)
2+
set(CMAKE_SYSTEM_PROCESSOR aarch64)
3+
4+
set(triple aarch64-linux-gnu)
5+
6+
set(CMAKE_ASM_COMPILER clang)
7+
set(CMAKE_ASM_COMPILER_TARGET ${triple})
8+
set(CMAKE_C_COMPILER clang)
9+
set(CMAKE_C_COMPILER_TARGET ${triple})
10+
set(CMAKE_CXX_COMPILER clang++)
11+
set(CMAKE_CXX_COMPILER_TARGET ${triple})
12+
13+
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
14+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
15+
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
16+
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"version": 4,
3+
"configurePresets": [
4+
{
5+
"name": "lfm2-audio-base",
6+
"hidden": true,
7+
"cacheVariables": {
8+
"CMAKE_BUILD_TYPE": "Release",
9+
"CMAKE_BUILD_WITH_INSTALL_RPATH": "ON",
10+
"LLAMA_BUILD_TOOLS": "ON",
11+
"LLAMA_BUILD_EXAMPLES": "OFF",
12+
"LLAMA_BUILD_TESTS": "OFF",
13+
"LLAMA_BUILD_SERVER": "OFF",
14+
"LLAMA_CURL": "OFF",
15+
"GGML_RPC": "OFF",
16+
"GGML_NATIVE": "OFF",
17+
"GGML_BACKEND_DL": "ON",
18+
"GGML_CPU_ALL_VARIANTS": "ON"
19+
}
20+
},
21+
{
22+
"name": "lfm2-audio-ubuntu-x64",
23+
"inherits": ["lfm2-audio-base"],
24+
"binaryDir": "${sourceDir}/build-ubuntu-x64",
25+
"cacheVariables": {
26+
"CMAKE_INSTALL_RPATH": "$ORIGIN",
27+
"GGML_OPENMP": "OFF"
28+
}
29+
},
30+
{
31+
"name": "lfm2-audio-ubuntu-arm64",
32+
"inherits": ["lfm2-audio-base"],
33+
"binaryDir": "${sourceDir}/build-ubuntu-arm64",
34+
"cacheVariables": {
35+
"CMAKE_TOOLCHAIN_FILE": "/workdir/.github/cmake/aarch64-linux-gnu.toolchain.cmake",
36+
"CMAKE_INSTALL_RPATH": "$ORIGIN",
37+
"GGML_OPENMP": "OFF"
38+
}
39+
},
40+
{
41+
"name": "lfm2-audio-macos-arm64",
42+
"inherits": ["lfm2-audio-base"],
43+
"binaryDir": "${sourceDir}/build-macos-arm64",
44+
"cacheVariables": {
45+
"CMAKE_INSTALL_RPATH": "@loader_path",
46+
"GGML_METAL": "ON",
47+
"GGML_METAL_EMBED_LIBRARY": "ON"
48+
}
49+
},
50+
{
51+
"name": "lfm2-audio-android-arm64",
52+
"inherits": ["lfm2-audio-base"],
53+
"binaryDir": "${sourceDir}/build-android-arm64",
54+
"cacheVariables": {
55+
"CMAKE_TOOLCHAIN_FILE": "$env{ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake",
56+
"ANDROID_ABI": "arm64-v8a",
57+
"ANDROID_PLATFORM": "android-28",
58+
"CMAKE_INSTALL_RPATH": "",
59+
"GGML_OPENMP": "OFF",
60+
"GGML_LLAMAFILE": "OFF"
61+
}
62+
}
63+
]
64+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
ARG GROUP_ID=1000
2+
ARG USER_ID=1000
3+
ARG USER_NAME=docker-user
4+
5+
FROM amd64/ubuntu:24.04
6+
# https://bugs.launchpad.net/cloud-images/+bug/2005129
7+
RUN userdel -r ubuntu
8+
9+
ENV DEBIAN_FRONTEND=noninteractive
10+
11+
ARG GROUP_ID
12+
ARG USER_ID
13+
ARG USER_NAME
14+
15+
RUN apt-get -y update \
16+
&& apt-get install --no-install-recommends -y \
17+
cmake \
18+
ccache \
19+
curl \
20+
git \
21+
make \
22+
ninja-build \
23+
patch \
24+
lld \
25+
clang \
26+
gcc-aarch64-linux-gnu \
27+
g++-aarch64-linux-gnu \
28+
libstdc++-13-dev-arm64-cross \
29+
&& rm -rf /var/lib/apt/lists/*
30+
31+
# -----------------------------------------------------------------------------
32+
# user
33+
# -----------------------------------------------------------------------------
34+
RUN groupadd --gid $GROUP_ID docker-user && \
35+
useradd --uid $USER_ID --gid docker-user --create-home $USER_NAME
36+
37+
USER $USER_NAME
38+
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Release llama-lfm2-audio
2+
3+
on:
4+
push:
5+
branches:
6+
- tarek/feat/audio2
7+
pull_request:
8+
branches:
9+
- tarek/feat/audio2
10+
types: [labeled]
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
build-lfm2-audio:
18+
if: |
19+
github.event_name == 'push' ||
20+
(github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'audio-release'))
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
include:
25+
# Ubuntu x86_64 with CPU variant support for compatibility
26+
- platform: ubuntu-x64
27+
runner: ubuntu-24.04
28+
setup_ndk: false
29+
use_docker: false
30+
31+
# Ubuntu ARM64 (cross-compiled via Docker)
32+
- platform: ubuntu-arm64
33+
runner: ubuntu-24.04
34+
setup_ndk: false
35+
use_docker: true
36+
docker_image: aarch64-linux-gnu
37+
docker_user: docker-user
38+
39+
# macOS ARM64
40+
# NOTE: -DGGML_BACKEND_DL=ON is very bad for UX on macOS due to the
41+
# system policy of not allowing loading unsigned dylibs. Mimics behavior for llama.cpp releases.
42+
- platform: macos-arm64
43+
runner: macos-latest
44+
setup_ndk: false
45+
use_docker: false
46+
47+
# Android ARM64
48+
# NOTE: Android seems to ignore RPATH. Use LD_LIBRARY_PATH at runtime.
49+
- platform: android-arm64
50+
runner: ubuntu-24.04
51+
setup_ndk: true
52+
use_docker: false
53+
54+
runs-on: ${{ matrix.runner }}
55+
56+
steps:
57+
- name: Checkout repository
58+
uses: actions/checkout@v5
59+
with:
60+
persist-credentials: false
61+
fetch-depth: 0
62+
63+
- name: Build llama-lfm2-audio (Docker)
64+
if: matrix.use_docker == true
65+
uses: ./.github/actions/build_lfm2_audio_docker_cross
66+
with:
67+
platform: ${{ matrix.platform }}
68+
docker_image: ${{ matrix.docker_image }}
69+
docker_user_name: ${{ matrix.docker_user }}
70+
71+
- name: Build llama-lfm2-audio (Native)
72+
if: matrix.use_docker == false
73+
uses: ./.github/actions/build_lfm2_audio_native
74+
with:
75+
platform: ${{ matrix.platform }}
76+
setup_ndk: ${{ matrix.setup_ndk }}

0 commit comments

Comments
 (0)