Skip to content

Commit ada21d3

Browse files
committed
Merge branch 'master' into pr/19493
2 parents 66e0c9a + 23b8cc4 commit ada21d3

73 files changed

Lines changed: 1437 additions & 1355 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-android.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
distribution: zulu
5252

5353
- name: Setup Android SDK
54-
uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407 # v3
54+
uses: android-actions/setup-android@40fd30fb8d7440372e1316f5d1809ec01dcd3699 # v4.0.1
5555
with:
5656
log-accepted-android-sdk-licenses: false
5757

.github/workflows/build-self-hosted.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,36 @@ jobs:
9797
vulkaninfo --summary
9898
GG_BUILD_VULKAN=1 bash ./ci/run.sh ~/results/llama.cpp /mnt/llama.cpp
9999
100+
# TODO: investigate slight precision issues in some operations for test-backend-ops on the WebGPU backend.
101+
#ggml-ci-nvidia-webgpu:
102+
# runs-on: [self-hosted, Linux, NVIDIA]
103+
104+
# steps:
105+
# - name: Clone
106+
# id: checkout
107+
# uses: actions/checkout@v6
108+
109+
# - name: Dawn Dependency
110+
# id: dawn-depends
111+
# run: |
112+
# DAWN_VERSION="v20260317.182325"
113+
# DAWN_OWNER="google"
114+
# DAWN_REPO="dawn"
115+
# DAWN_ASSET_NAME="Dawn-18eb229ef5f707c1464cc581252e7603c73a3ef0-ubuntu-latest-Release"
116+
# echo "Fetching release asset from https://github.com/google/dawn/releases/download/${DAWN_VERSION}/${DAWN_ASSET_NAME}.tar.gz"
117+
# curl -L -o artifact.tar.gz \
118+
# "https://github.com/google/dawn/releases/download/${DAWN_VERSION}/${DAWN_ASSET_NAME}.tar.gz"
119+
# mkdir dawn
120+
# tar -xvf artifact.tar.gz -C dawn --strip-components=1
121+
122+
# - name: Test
123+
# id: ggml-ci
124+
# run: |
125+
# GG_BUILD_WEBGPU=1 \
126+
# GG_BUILD_WEBGPU_DAWN_PREFIX="$GITHUB_WORKSPACE/dawn" \
127+
# GG_BUILD_WEBGPU_DAWN_DIR="$GITHUB_WORKSPACE/dawn/lib64/cmake/Dawn" \
128+
# bash ./ci/run.sh ~/results/llama.cpp /mnt/llama.cpp
129+
100130
# TODO: provision AMX-compatible machine
101131
#ggml-ci-cpu-amx:
102132
# runs-on: [self-hosted, Linux, CPU, AMX]

.github/workflows/build.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,56 @@ jobs:
267267
wget https://huggingface.co/ggml-org/models/resolve/main/tinyllamas/stories260K-be.gguf
268268
./bin/llama-completion -m stories260K-be.gguf -p "One day, Lily met a Shoggoth" -n 500 -c 256
269269
270+
android-arm64:
271+
runs-on: ubuntu-latest
272+
273+
env:
274+
NDK_VERSION: "29.0.14206865"
275+
276+
steps:
277+
- name: Clone
278+
id: checkout
279+
uses: actions/checkout@v6
280+
281+
- name: ccache
282+
uses: ggml-org/ccache-action@v1.2.21
283+
with:
284+
key: android-arm64
285+
evict-old-files: 1d
286+
save: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
287+
288+
- name: Set up JDK
289+
uses: actions/setup-java@v5
290+
with:
291+
java-version: 17
292+
distribution: temurin
293+
294+
- name: Setup Android SDK
295+
uses: android-actions/setup-android@40fd30fb8d7440372e1316f5d1809ec01dcd3699 # v4.0.1
296+
with:
297+
log-accepted-android-sdk-licenses: false
298+
299+
- name: Install NDK
300+
run: |
301+
sdkmanager "ndk;${{ env.NDK_VERSION }}"
302+
echo "ANDROID_NDK=${ANDROID_SDK_ROOT}/ndk/${{ env.NDK_VERSION }}" >> $GITHUB_ENV
303+
304+
- name: Build
305+
id: cmake_build
306+
run: |
307+
cmake -B build \
308+
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \
309+
-DANDROID_ABI=arm64-v8a \
310+
-DANDROID_PLATFORM=android-28 \
311+
-DLLAMA_FATAL_WARNINGS=ON \
312+
-DGGML_BACKEND_DL=ON \
313+
-DGGML_NATIVE=OFF \
314+
-DGGML_CPU_ALL_VARIANTS=ON \
315+
-DGGML_OPENMP=OFF \
316+
-DLLAMA_BUILD_BORINGSSL=ON \
317+
-DGGML_RPC=ON
318+
time cmake --build build --config Release -j $(nproc)
319+
270320
ubuntu-latest-rpc:
271321
runs-on: ubuntu-latest
272322

.github/workflows/release.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,75 @@ jobs:
236236
path: llama-${{ steps.tag.outputs.name }}-bin-ubuntu-vulkan-${{ matrix.build }}.tar.gz
237237
name: llama-bin-ubuntu-vulkan-${{ matrix.build }}.tar.gz
238238

239+
android-arm64:
240+
runs-on: ubuntu-latest
241+
242+
env:
243+
NDK_VERSION: "29.0.14206865"
244+
245+
steps:
246+
- name: Clone
247+
id: checkout
248+
uses: actions/checkout@v6
249+
with:
250+
fetch-depth: 0
251+
252+
- name: ccache
253+
uses: ggml-org/ccache-action@v1.2.21
254+
with:
255+
key: android-arm64
256+
evict-old-files: 1d
257+
258+
- name: Set up JDK
259+
uses: actions/setup-java@v5
260+
with:
261+
java-version: 17
262+
distribution: temurin
263+
264+
- name: Setup Android SDK
265+
uses: android-actions/setup-android@40fd30fb8d7440372e1316f5d1809ec01dcd3699 # v4.0.1
266+
with:
267+
log-accepted-android-sdk-licenses: false
268+
269+
- name: Install NDK
270+
run: |
271+
sdkmanager "ndk;${{ env.NDK_VERSION }}"
272+
echo "ANDROID_NDK=${ANDROID_SDK_ROOT}/ndk/${{ env.NDK_VERSION }}" >> $GITHUB_ENV
273+
274+
- name: Build
275+
id: cmake_build
276+
run: |
277+
cmake -B build \
278+
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \
279+
-DANDROID_ABI=arm64-v8a \
280+
-DANDROID_PLATFORM=android-28 \
281+
-DCMAKE_INSTALL_RPATH='$ORIGIN' \
282+
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
283+
-DGGML_BACKEND_DL=ON \
284+
-DGGML_NATIVE=OFF \
285+
-DGGML_CPU_ALL_VARIANTS=ON \
286+
-DLLAMA_FATAL_WARNINGS=ON \
287+
-DGGML_OPENMP=OFF \
288+
-DLLAMA_BUILD_BORINGSSL=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-android-arm64.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-android-arm64.tar.gz
306+
name: llama-bin-android-arm64.tar.gz
307+
239308
ubuntu-24-openvino:
240309
runs-on: ubuntu-24.04
241310

@@ -618,6 +687,11 @@ jobs:
618687
with:
619688
fetch-depth: 0
620689

690+
- name: Free up disk space
691+
uses: ggml-org/free-disk-space@v1.3.1
692+
with:
693+
tool-cache: true
694+
621695
- name: ccache
622696
uses: ggml-org/ccache-action@v1.2.21
623697
with:
@@ -971,6 +1045,7 @@ jobs:
9711045
- ubuntu-cpu
9721046
- ubuntu-vulkan
9731047
- ubuntu-24-openvino
1048+
- android-arm64
9741049
- macOS-cpu
9751050
- ios-xcode-build
9761051
- openEuler-cann
@@ -1059,6 +1134,9 @@ jobs:
10591134
- [Ubuntu x64 (ROCm 7.2)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-ubuntu-rocm-7.2-x64.tar.gz)
10601135
- [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)
10611136
1137+
**Android:**
1138+
- [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)
1139+
10621140
**Windows:**
10631141
- [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)
10641142
- [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)

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ foreach(FILE_PATH ${EXTRA_LICENSES})
225225
endforeach()
226226

227227
if (LLAMA_BUILD_COMMON)
228-
license_generate(common)
228+
license_generate(llama-common)
229229
endif()
230230

231231
#
@@ -249,6 +249,10 @@ set_target_properties(llama
249249

250250
install(TARGETS llama LIBRARY PUBLIC_HEADER)
251251

252+
if (LLAMA_BUILD_COMMON)
253+
install(TARGETS llama-common LIBRARY)
254+
endif()
255+
252256
configure_package_config_file(
253257
${CMAKE_CURRENT_SOURCE_DIR}/cmake/llama-config.cmake.in
254258
${CMAKE_CURRENT_BINARY_DIR}/llama-config.cmake

common/CMakeLists.txt

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
# common
2-
31
find_package(Threads REQUIRED)
42

53
llama_add_compile_flags()
64

5+
#
6+
# llama-common-base
7+
#
8+
79
# Build info header
810

911
if(EXISTS "${PROJECT_SOURCE_DIR}/.git")
@@ -33,17 +35,25 @@ endif()
3335

3436
set(TEMPLATE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/build-info.cpp.in")
3537
set(OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/build-info.cpp")
38+
3639
configure_file(${TEMPLATE_FILE} ${OUTPUT_FILE})
3740

38-
set(TARGET build_info)
39-
add_library(${TARGET} OBJECT ${OUTPUT_FILE})
41+
set(TARGET llama-common-base)
42+
add_library(${TARGET} STATIC ${OUTPUT_FILE})
43+
44+
target_include_directories(${TARGET} PUBLIC .)
45+
4046
if (BUILD_SHARED_LIBS)
4147
set_target_properties(${TARGET} PROPERTIES POSITION_INDEPENDENT_CODE ON)
4248
endif()
4349

44-
set(TARGET common)
50+
#
51+
# llama-common
52+
#
4553

46-
add_library(${TARGET} STATIC
54+
set(TARGET llama-common)
55+
56+
add_library(${TARGET}
4757
arg.cpp
4858
arg.h
4959
base64.hpp
@@ -106,17 +116,24 @@ add_library(${TARGET} STATIC
106116
jinja/caps.h
107117
)
108118

119+
set_target_properties(${TARGET} PROPERTIES
120+
VERSION ${LLAMA_INSTALL_VERSION}
121+
SOVERSION 0
122+
MACHO_CURRENT_VERSION 0 # keep macOS linker from seeing oversized version number
123+
)
124+
109125
target_include_directories(${TARGET} PUBLIC . ../vendor)
110126
target_compile_features (${TARGET} PUBLIC cxx_std_17)
111127

112128
if (BUILD_SHARED_LIBS)
113129
set_target_properties(${TARGET} PROPERTIES POSITION_INDEPENDENT_CODE ON)
130+
131+
# TODO: make fine-grained exports in the future
132+
set_target_properties(${TARGET} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
114133
endif()
115134

116-
target_link_libraries(${TARGET} PRIVATE
117-
build_info
118-
cpp-httplib
119-
)
135+
target_link_libraries(${TARGET} PUBLIC llama-common-base)
136+
target_link_libraries(${TARGET} PRIVATE cpp-httplib)
120137

121138
if (LLAMA_LLGUIDANCE)
122139
include(ExternalProject)

common/arg.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "arg.h"
22

3+
#include "build-info.h"
34
#include "chat.h"
45
#include "common.h"
56
#include "download.h"
@@ -1044,8 +1045,8 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
10441045
{"--version"},
10451046
"show version and build info",
10461047
[](common_params &) {
1047-
fprintf(stderr, "version: %d (%s)\n", LLAMA_BUILD_NUMBER, LLAMA_COMMIT);
1048-
fprintf(stderr, "built with %s for %s\n", LLAMA_COMPILER, LLAMA_BUILD_TARGET);
1048+
fprintf(stderr, "version: %d (%s)\n", llama_build_number(), llama_commit());
1049+
fprintf(stderr, "built with %s for %s\n", llama_compiler(), llama_build_target());
10491050
exit(0);
10501051
}
10511052
));

common/build-info.cpp.in

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,35 @@
1+
#include "build-info.h"
2+
3+
#include <cstdio>
4+
#include <string>
5+
16
int LLAMA_BUILD_NUMBER = @LLAMA_BUILD_NUMBER@;
2-
char const *LLAMA_COMMIT = "@LLAMA_BUILD_COMMIT@";
3-
char const *LLAMA_COMPILER = "@BUILD_COMPILER@";
4-
char const *LLAMA_BUILD_TARGET = "@BUILD_TARGET@";
7+
char const * LLAMA_COMMIT = "@LLAMA_BUILD_COMMIT@";
8+
char const * LLAMA_COMPILER = "@BUILD_COMPILER@";
9+
char const * LLAMA_BUILD_TARGET = "@BUILD_TARGET@";
10+
11+
int llama_build_number(void) {
12+
return LLAMA_BUILD_NUMBER;
13+
}
14+
15+
const char * llama_commit(void) {
16+
return LLAMA_COMMIT;
17+
}
18+
19+
const char * llama_compiler(void) {
20+
return LLAMA_COMPILER;
21+
}
22+
23+
const char * llama_build_target(void) {
24+
return LLAMA_BUILD_TARGET;
25+
}
26+
27+
const char * llama_build_info(void) {
28+
static std::string s = "b" + std::to_string(LLAMA_BUILD_NUMBER) + "-" + LLAMA_COMMIT;
29+
return s.c_str();
30+
}
31+
32+
void llama_print_build_info(void) {
33+
fprintf(stderr, "%s: build = %d (%s)\n", __func__, llama_build_number(), llama_commit());
34+
fprintf(stderr, "%s: built with %s for %s\n", __func__, llama_compiler(), llama_build_target());
35+
}

common/build-info.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#pragma once
2+
3+
int llama_build_number(void);
4+
5+
const char * llama_commit(void);
6+
const char * llama_compiler(void);
7+
8+
const char * llama_build_target(void);
9+
const char * llama_build_info(void);
10+
11+
void llama_print_build_info(void);

common/common.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "ggml.h"
22
#include "gguf.h"
33

4+
#include "build-info.h"
45
#include "common.h"
56
#include "log.h"
67
#include "llama.h"
@@ -372,7 +373,7 @@ void common_init() {
372373
const char * build_type = " (debug)";
373374
#endif
374375

375-
LOG_DBG("build: %d (%s) with %s for %s%s\n", LLAMA_BUILD_NUMBER, LLAMA_COMMIT, LLAMA_COMPILER, LLAMA_BUILD_TARGET, build_type);
376+
LOG_DBG("build: %d (%s) with %s for %s%s\n", llama_build_number(), llama_commit(), llama_compiler(), llama_build_target(), build_type);
376377
}
377378

378379
std::string common_params_get_system_info(const common_params & params) {

0 commit comments

Comments
 (0)