Skip to content

Commit f1c213b

Browse files
Merge branch 'master' into feat/vllm-cpp-darwin-mlx
2 parents 40675f3 + 84972cb commit f1c213b

119 files changed

Lines changed: 7779 additions & 1294 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/backend-matrix.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,34 @@ include:
6666
dockerfile: "./backend/Dockerfile.python"
6767
context: "./"
6868
ubuntu-version: '2404'
69+
- build-type: ''
70+
cuda-major-version: ""
71+
cuda-minor-version: ""
72+
platforms: 'linux/amd64'
73+
platform-tag: 'amd64'
74+
tag-latest: 'auto'
75+
tag-suffix: '-cpu-kokoro'
76+
runs-on: 'ubuntu-latest'
77+
base-image: "ubuntu:24.04"
78+
skip-drivers: 'true'
79+
backend: "kokoro"
80+
dockerfile: "./backend/Dockerfile.python"
81+
context: "./"
82+
ubuntu-version: '2404'
83+
- build-type: ''
84+
cuda-major-version: ""
85+
cuda-minor-version: ""
86+
platforms: 'linux/arm64'
87+
platform-tag: 'arm64'
88+
tag-latest: 'auto'
89+
tag-suffix: '-cpu-kokoro'
90+
runs-on: 'ubuntu-24.04-arm'
91+
base-image: "ubuntu:24.04"
92+
skip-drivers: 'true'
93+
backend: "kokoro"
94+
dockerfile: "./backend/Dockerfile.python"
95+
context: "./"
96+
ubuntu-version: '2404'
6997
- build-type: ''
7098
cuda-major-version: ""
7199
cuda-minor-version: ""

.github/workflows/image-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
tag-latest: 'false'
5353
tag-suffix: '-gpu-nvidia-cuda-13'
5454
runs-on: 'ubuntu-latest'
55-
base-image: "ubuntu:22.04"
55+
base-image: "ubuntu:24.04"
5656
makeflags: "--jobs=3 --output-sync=target"
5757
ubuntu-version: '2404'
5858
- build-type: 'hipblas'

.github/workflows/image.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
tag-latest: 'auto'
114114
tag-suffix: '-gpu-nvidia-cuda-13'
115115
runs-on: 'ubuntu-latest'
116-
base-image: "ubuntu:22.04"
116+
base-image: "ubuntu:24.04"
117117
skip-drivers: 'false'
118118
makeflags: "--jobs=4 --output-sync=target"
119119
ubuntu-version: '2404'

backend/Dockerfile.golang

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,33 @@ RUN if [ "${BACKEND}" = "crispasr" ]; then \
221221
apt-get clean && rm -rf /var/lib/apt/lists/*; \
222222
fi
223223

224+
# sherpa-onnx links onnxruntime's CUDA execution provider, and
225+
# libonnxruntime_providers_cuda.so has cuDNN as a hard DT_NEEDED. The
226+
# onnxruntime GPU tarball does not ship cuDNN itself, so without this the
227+
# builder has none (the arm64 + CUDA 13 branch above is the only other place
228+
# that installs it) and package-gpu-libs.sh correctly refuses to produce a
229+
# package that references cuDNN with no cuDNN available to it.
230+
#
231+
# Installed per-backend rather than for every cublas build: the auto-detection
232+
# in package-gpu-libs.sh bundles only what a package actually references, so
233+
# the ggml backends would not grow either way, but they would all pay ~1.1 GB
234+
# of builder layer and registry cache for a library they never call.
235+
#
236+
# Runtime package only, no -dev: sherpa-onnx consumes onnxruntime's prebuilt
237+
# CUDA provider and never compiles against cuDNN headers. libcudnn9-cuda-N
238+
# carries the dispatcher plus all seven dlopen()ed sublibraries, which is what
239+
# complete_cudnn_family needs to assemble a whole bundle.
240+
RUN <<EOT bash
241+
if [ "${BACKEND}" = "sherpa-onnx" ] && [ "${BUILD_TYPE}" = "cublas" ] && [ "${SKIP_DRIVERS}" = "false" ]; then
242+
apt-get update && \
243+
apt-get install -y --no-install-recommends \
244+
libcudnn9-cuda-${CUDA_MAJOR_VERSION} && \
245+
ldconfig && \
246+
apt-get clean && \
247+
rm -rf /var/lib/apt/lists/*
248+
fi
249+
EOT
250+
224251
COPY . /LocalAI
225252

226253
RUN git config --global --add safe.directory /LocalAI

backend/backend.proto

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,12 @@ message ProxyOptions {
508508
string api_key_file = 5;
509509
string upstream_model = 6;
510510
int32 request_timeout_seconds = 7;
511+
// cache_prompt enables automatic Anthropic prompt-cache breakpoints
512+
// (cache_control: ephemeral) on the stable prefix — system, tools, and
513+
// the last message block — when translating to the Anthropic provider.
514+
// Cuts input cost on repeated/agentic calls (cache read = 0.1x). Only
515+
// meaningful for mode=translate + provider=anthropic; ignored otherwise.
516+
bool cache_prompt = 8;
511517
}
512518

513519
message Result {

backend/cpp/ik-llama-cpp/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
IK_LLAMA_VERSION?=0a4e10c7fb65d2dd5a4afb78339c7d373a8cdfaa
2+
IK_LLAMA_VERSION?=5f063b7bbae8f9a34dfc5c704aa77939e76494a9
33
LLAMA_REPO?=https://github.com/ikawrakow/ik_llama.cpp
44

55
CMAKE_ARGS?=

backend/cpp/llama-cpp/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
LLAMA_VERSION?=571d0d540df04f25298d0e159e520d9fc62ed121
2+
LLAMA_VERSION?=1cbfd1988311775425d36c0ce066590f7d3049cf
33
LLAMA_REPO?=https://github.com/ggerganov/llama.cpp
44

55
CMAKE_ARGS?=

backend/cpp/llama-cpp/grpc-server.cpp

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#include "common.h"
5353
#include "arg.h"
5454
#include "chat-auto-parser.h"
55+
#include "llama_compat.h" // fork-skew switches, generated by prepare.sh
5556
#include "message_content.h"
5657
#include <getopt.h>
5758
#include <grpcpp/ext/proto_server_reflection_plugin.h>
@@ -613,6 +614,13 @@ static void params_parse(server_context& /*ctx_server*/, const backend::ModelOpt
613614
// starts with '-'. Applied once after the loop via common_params_parse.
614615
std::vector<std::string> extra_argv;
615616

617+
// O_DIRECT intent from the `direct_io` option. Upstream folded
618+
// use_mmap/use_mlock/use_direct_io into a single common_params::load_mode
619+
// enum (ggml-org/llama.cpp#20834), so the three independent LocalAI settings
620+
// can only be reduced to one value once all of them have been read, held
621+
// here until the mmap/mlock fields arrive further down.
622+
bool want_direct_io = false;
623+
616624
auto add_device_options = [&](const std::string & devices) {
617625
const std::regex regex{ R"([,]+)" };
618626
std::sregex_token_iterator it{ devices.begin(), devices.end(), regex, -1 };
@@ -868,9 +876,9 @@ static void params_parse(server_context& /*ctx_server*/, const backend::ModelOpt
868876
// --- O_DIRECT model loading (upstream --direct-io) ---
869877
} else if (!strcmp(optname, "direct_io") || !strcmp(optname, "use_direct_io")) {
870878
if (optval_str == "true" || optval_str == "1" || optval_str == "yes" || optval_str == "on" || optval_str == "enabled") {
871-
params.use_direct_io = true;
879+
want_direct_io = true;
872880
} else if (optval_str == "false" || optval_str == "0" || optval_str == "no" || optval_str == "off" || optval_str == "disabled") {
873-
params.use_direct_io = false;
881+
want_direct_io = false;
874882
}
875883

876884
// --- embedding normalization (upstream --embd-normalize) ---
@@ -1278,8 +1286,28 @@ static void params_parse(server_context& /*ctx_server*/, const backend::ModelOpt
12781286
lora_info.ptr = nullptr;
12791287
params.lora_adapters.push_back(std::move(lora_info));
12801288
}
1281-
params.use_mlock = request->mlock();
1282-
params.use_mmap = request->mmap();
1289+
// LocalAI keeps mmap, mlock and direct-I/O as three independent settings,
1290+
// while upstream now carries a single load mode. Fold them with the
1291+
// precedence the separate booleans used to give: direct I/O bypasses the
1292+
// page cache entirely, mlock implies mmap, and everything off is a plain
1293+
// buffered read. Forks that branched before ggml-org/llama.cpp#20834 still
1294+
// expose the booleans; prepare.sh probes the checkout and sets
1295+
// LOCALAI_LEGACY_LOAD_MODE in the generated llama_compat.h accordingly.
1296+
#if LOCALAI_LEGACY_LOAD_MODE
1297+
params.use_mlock = request->mlock();
1298+
params.use_mmap = request->mmap();
1299+
params.use_direct_io = want_direct_io;
1300+
#else
1301+
if (want_direct_io) {
1302+
params.load_mode = LLAMA_LOAD_MODE_DIRECT_IO;
1303+
} else if (request->mlock()) {
1304+
params.load_mode = LLAMA_LOAD_MODE_MLOCK;
1305+
} else if (request->mmap()) {
1306+
params.load_mode = LLAMA_LOAD_MODE_MMAP;
1307+
} else {
1308+
params.load_mode = LLAMA_LOAD_MODE_NONE;
1309+
}
1310+
#endif
12831311

12841312
if (request->flashattention() == "on" || request->flashattention() == "enabled") {
12851313
params.flash_attn_type = LLAMA_FLASH_ATTN_TYPE_ENABLED;

0 commit comments

Comments
 (0)