mirror of
https://github.com/mudler/LocalAI.git
synced 2026-05-16 20:52:08 -04:00
* ci(bump-deps): register ds4 + move version pin into the Makefile The initial ds4 PR (#9758) put the upstream commit pin in backend/cpp/ds4/prepare.sh as a shell variable. The auto-bump bot at .github/bump_deps.sh greps for ^$VAR?= in a Makefile, so DS4_VERSION was invisible to it - other backends (llama-cpp, ik-llama-cpp, turboquant, voxtral, etc.) all pin in their Makefile. This change: - Moves DS4_VERSION?= and DS4_REPO?= to the top of backend/cpp/ds4/Makefile. - Inlines the git init/fetch/checkout recipe into the 'ds4:' target (matches llama-cpp's 'llama.cpp:' target pattern). Directory acts as the target so make only re-clones when missing. - Deletes the now-redundant prepare.sh. - Adds antirez/ds4 + DS4_VERSION + main + backend/cpp/ds4/Makefile to the .github/workflows/bump_deps.yaml matrix so the daily bot opens PRs against this pin. - Updates .agents/ds4-backend.md to point at the Makefile. Verified: $ grep -m1 '^DS4_VERSION?=' backend/cpp/ds4/Makefile DS4_VERSION?=ae302c2fa18cc6d9aefc021d0f27ae03c9ad2fc0 $ make -C backend/cpp/ds4 ds4 # clones into ds4/ at the pin $ make -C backend/cpp/ds4 ds4 # no-op on second invocation make: 'ds4' is up to date. Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * ci: route backend/cpp/ds4/ changes through changed-backends.js scripts/changed-backends.js:inferBackendPath has an explicit branch per cpp dockerfile suffix (ik-llama-cpp, turboquant, llama-cpp). Without a matching branch the function returns null, the backend never lands in the path map, and PR change-detection cannot map "backend/cpp/ds4/X changed" -> "rebuild ds4 image". This is why PR #9761 produced zero ds4 jobs even though it directly edits backend/cpp/ds4/Makefile. Adds the missing branch (Dockerfile.ds4 -> backend/cpp/ds4/), placed before the llama-cpp branch (since both share the .cpp ancestry but ds4 is more specific - same ordering rule documented in .agents/adding-backends.md). Verified with a local Node simulation of the script against this PR's diff: the path map now contains 'ds4 -> backend/cpp/ds4/' and a 'backend/cpp/ds4/Makefile' change correctly triggers the ds4 backend in the rebuild set. Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * docs(adding-backends): harden the two gotchas that bit ds4 Both omissions are silent at the time you ADD a backend - the failure mode only appears later (the bump bot stays silent forever, or the path filter shows up on the next PR that touches your backend with zero CI jobs and looks broken for unrelated reasons). Expanding the `scripts/changed-backends.js` paragraph from a one-liner to a fully worked example, and adding a new sibling paragraph for the `bump_deps.yaml` + Makefile-pin contract. Both call out the specific mistakes from the ds4 timeline (#9758 → #9761) so future contributors can pattern-match on the cause. Signed-off-by: Ettore Di Giacinto <mudler@localai.io> --------- Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Co-authored-by: Ettore Di Giacinto <mudler@localai.io>
79 lines
2.2 KiB
Makefile
79 lines
2.2 KiB
Makefile
# ds4 backend Makefile.
|
|
#
|
|
# Upstream pin lives below as DS4_VERSION?= so the bump-deps bot
|
|
# (.github/bump_deps.sh) can find and update it - matches the
|
|
# llama-cpp / ik-llama-cpp / turboquant convention.
|
|
|
|
DS4_VERSION?=ae302c2fa18cc6d9aefc021d0f27ae03c9ad2fc0
|
|
DS4_REPO?=https://github.com/antirez/ds4
|
|
|
|
CURRENT_MAKEFILE_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
|
BUILD_DIR := build
|
|
|
|
BUILD_TYPE ?=
|
|
NATIVE ?= false
|
|
JOBS ?= $(shell nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 4)
|
|
|
|
UNAME_S := $(shell uname -s)
|
|
|
|
CMAKE_ARGS ?= -DCMAKE_BUILD_TYPE=Release
|
|
|
|
ifeq ($(BUILD_TYPE),cublas)
|
|
CMAKE_ARGS += -DDS4_GPU=cuda
|
|
DS4_OBJ_TARGET := ds4.o ds4_cuda.o
|
|
else ifeq ($(UNAME_S),Darwin)
|
|
CMAKE_ARGS += -DDS4_GPU=metal
|
|
DS4_OBJ_TARGET := ds4.o ds4_metal.o
|
|
else
|
|
# CPU reference path (Linux only - macOS CPU path is broken by VM bug per ds4 README).
|
|
CMAKE_ARGS += -DDS4_GPU=cpu
|
|
DS4_OBJ_TARGET := ds4_cpu.o
|
|
endif
|
|
|
|
ifneq ($(NATIVE),true)
|
|
CMAKE_ARGS += -DDS4_NATIVE=OFF
|
|
endif
|
|
|
|
.PHONY: grpc-server package clean purge test all
|
|
all: grpc-server
|
|
|
|
# Clone the upstream ds4 source at the pinned commit. Directory acts as the
|
|
# target so make only re-clones when missing. After a DS4_VERSION bump,
|
|
# run 'make purge && make' to refetch (or rely on CI's clean build).
|
|
ds4:
|
|
mkdir -p ds4
|
|
cd ds4 && \
|
|
git init -q && \
|
|
git remote add origin $(DS4_REPO) && \
|
|
git fetch --depth 1 origin $(DS4_VERSION) && \
|
|
git checkout FETCH_HEAD
|
|
|
|
# Build ds4's engine object files via its own Makefile, which already encodes
|
|
# the right per-platform compile flags (Objective-C/Metal on Darwin, nvcc on Linux+CUDA).
|
|
ds4/ds4.o: ds4
|
|
ifeq ($(BUILD_TYPE),cublas)
|
|
+$(MAKE) -C ds4 ds4.o ds4_cuda.o
|
|
else ifeq ($(UNAME_S),Darwin)
|
|
+$(MAKE) -C ds4 ds4.o ds4_metal.o
|
|
else
|
|
+$(MAKE) -C ds4 ds4_cpu.o
|
|
endif
|
|
|
|
grpc-server: ds4/ds4.o
|
|
mkdir -p $(BUILD_DIR)
|
|
cd $(BUILD_DIR) && cmake $(CMAKE_ARGS) $(CURRENT_MAKEFILE_DIR) && cmake --build . --config Release -j $(JOBS)
|
|
cp $(BUILD_DIR)/grpc-server grpc-server
|
|
|
|
package: grpc-server
|
|
bash package.sh
|
|
|
|
test:
|
|
@echo "ds4 backend: e2e coverage at tests/e2e-backends/ (BACKEND_BINARY mode)"
|
|
|
|
clean:
|
|
rm -rf $(BUILD_DIR) grpc-server package
|
|
if [ -d ds4 ]; then $(MAKE) -C ds4 clean; fi
|
|
|
|
purge: clean
|
|
rm -rf ds4
|