Skip to content

Commit 0f9a001

Browse files
Merge branch 'master' into feat/dllm-backend
2 parents 6e75e2e + 49ef40a commit 0f9a001

48 files changed

Lines changed: 4907 additions & 491 deletions

Some content is hidden

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

.docker/llama-cpp-compile.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ if [ -z "${BUILD_TYPE:-}" ]; then
2828
# variants with it (the host never *selects* SME unless it has it, but every variant must
2929
# still compile).
3030
if [ "${TARGETARCH}" = "arm64" ]; then
31+
# The prebuilt base inherits default ports.ubuntu.com sources; honor the
32+
# APT_*_MIRROR build args here like the from-source path does, so this
33+
# apt step survives a mirror outage.
34+
sh /LocalAI/.docker/apt-mirror.sh || true
3135
apt-get update -qq && apt-get install -y -qq gcc-14 g++-14
3236
export CC=gcc-14 CXX=g++-14
3337
fi

backend/Dockerfile.llama-cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ RUN make -BC /LocalAI/backend/cpp/llama-cpp package
111111
# ============================================================================
112112
FROM ${BUILDER_BASE_IMAGE} AS builder-prebuilt
113113

114+
ARG APT_MIRROR
115+
ENV APT_MIRROR=${APT_MIRROR}
116+
ARG APT_PORTS_MIRROR
117+
ENV APT_PORTS_MIRROR=${APT_PORTS_MIRROR}
114118
ARG BUILD_TYPE
115119
ENV BUILD_TYPE=${BUILD_TYPE}
116120
ARG CUDA_DOCKER_ARCH

backend/backend.proto

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,13 @@ message ScoreRequest {
181181
// PredictOptions.ModelIdentity for the full rationale. Empty means "no
182182
// identity supplied" and backends MUST skip the check.
183183
string ModelIdentity = 5;
184+
// Byte length of the prompt prefix that stays identical across
185+
// repeated scoring calls (e.g. a classifier's option-list system
186+
// prompt — everything before the per-turn probe text). Backends that
187+
// snapshot state (hybrid/recurrent models cannot rewind otherwise)
188+
// use it to place a reuse point exactly at the boundary, so the next
189+
// call re-processes only the tokens after it. 0 means unknown.
190+
int32 stable_prefix_len = 6;
184191
}
185192

186193
// CandidateScore is one row in the ScoreResponse, matching by index
@@ -493,6 +500,11 @@ message ModelOptions {
493500
// Proxy carries the cloud-proxy backend's per-model configuration.
494501
// Empty for non-proxy backends.
495502
ProxyOptions Proxy = 74;
503+
504+
// EnableScore reserves backend resources for the Score RPC. It is derived
505+
// from the model's explicit `known_usecases: [score]` declaration so models
506+
// that never score retain their ordinary serving footprint.
507+
bool EnableScore = 75;
496508
}
497509

498510
// ProxyOptions configures the cloud-proxy backend. UpstreamURL and

backend/cpp/bonsai/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ define bonsai-build
4141
# and are applied by apply-patches.sh below.
4242
rm -rf $(CURRENT_MAKEFILE_DIR)/../bonsai-$(1)-build/patches
4343
$(MAKE) -C $(CURRENT_MAKEFILE_DIR)/../bonsai-$(1)-build purge
44+
bash $(LLAMA_CPP_DIR)/disable-score-task.sh $(CURRENT_MAKEFILE_DIR)/../bonsai-$(1)-build/grpc-server.cpp
4445
$(info $(GREEN)I bonsai build info:$(1)$(RESET))
4546
LLAMA_REPO=$(LLAMA_REPO) LLAMA_VERSION=$(BONSAI_VERSION) \
4647
$(MAKE) -C $(CURRENT_MAKEFILE_DIR)/../bonsai-$(1)-build llama.cpp
@@ -77,6 +78,7 @@ bonsai-cpu-all:
7778
# and are applied by apply-patches.sh below.
7879
rm -rf $(CURRENT_MAKEFILE_DIR)/../bonsai-cpu-all-build/patches
7980
$(MAKE) -C $(CURRENT_MAKEFILE_DIR)/../bonsai-cpu-all-build purge
81+
bash $(LLAMA_CPP_DIR)/disable-score-task.sh $(CURRENT_MAKEFILE_DIR)/../bonsai-cpu-all-build/grpc-server.cpp
8082
$(info $(GREEN)I bonsai build info:cpu-all-variants$(RESET))
8183
LLAMA_REPO=$(LLAMA_REPO) LLAMA_VERSION=$(BONSAI_VERSION) \
8284
$(MAKE) -C $(CURRENT_MAKEFILE_DIR)/../bonsai-cpu-all-build llama.cpp
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
# Mark a copied gRPC server as targeting a llama.cpp fork that does not carry
3+
# LocalAI's slot-based Score patches. The RPC remains present in the shared
4+
# protobuf service, but responds with UNIMPLEMENTED instead of referencing
5+
# server task types and common_params fields absent from those forks.
6+
7+
set -euo pipefail
8+
9+
if [[ $# -ne 1 ]]; then
10+
echo "usage: $0 <grpc-server.cpp>" >&2
11+
exit 2
12+
fi
13+
14+
SRC=$1
15+
16+
if [[ ! -f "$SRC" ]]; then
17+
echo "grpc-server.cpp not found at $SRC" >&2
18+
exit 2
19+
fi
20+
21+
if grep -q '^#define LOCALAI_LLAMA_CPP_NO_SCORE_TASK' "$SRC"; then
22+
echo "==> $SRC already disables the LocalAI score task, skipping"
23+
exit 0
24+
fi
25+
26+
awk '
27+
!done && /^#include/ {
28+
print "#define LOCALAI_LLAMA_CPP_NO_SCORE_TASK 1"
29+
print "// ^ injected by disable-score-task.sh for an unpatched llama.cpp fork"
30+
print ""
31+
done = 1
32+
}
33+
{ print }
34+
END {
35+
if (!done) {
36+
print "disable-score-task.sh: no #include anchor found" > "/dev/stderr"
37+
exit 1
38+
}
39+
}
40+
' "$SRC" > "$SRC.tmp"
41+
mv "$SRC.tmp" "$SRC"
42+
43+
echo "==> LocalAI score task disabled in $SRC"

0 commit comments

Comments
 (0)