Skip to content

fix(turboquant,bonsai): do not apply vendored llama.cpp patches to fork trees#10866

Merged
mudler merged 1 commit into
masterfrom
fix/turboquant-bonsai-drop-copied-patches
Jul 16, 2026
Merged

fix(turboquant,bonsai): do not apply vendored llama.cpp patches to fork trees#10866
mudler merged 1 commit into
masterfrom
fix/turboquant-bonsai-drop-copied-patches

Conversation

@localai-bot

Copy link
Copy Markdown
Collaborator

What

Hardening exposed by #10837. That PR adds backend/cpp/llama-cpp/patches/0001-add-minimax-m3-support.patch, and the turboquant and bonsai backends copy backend/cpp/llama-cpp/ wholesale (cp -rf) into their build directories before running the copied Makefile/prepare.sh against their own llama.cpp forks (TheTom/llama-cpp-turboquant, PrismML). The copied patches/ directory got mis-applied to the fork trees: hunks rejected, and because the patch-apply loop in prepare.sh ran before set -e took effect, the build continued and died much later with a confusing compile error ('LLM_ARCH_MINIMAX_M3' was not declared in this scope). This broke tests-turboquant-grpc on #10837.

Changes

  1. turboquant/bonsai Makefiles: delete the copied patches/ directory right after the cp -rf of backend/cpp/llama-cpp/ (all four copy sites: both build defines and both cpu-all targets). Patches vendored for upstream llama.cpp must never be applied to the forks; each fork carries its own patch series under backend/cpp/<backend>/patches/, applied by its own apply-patches.sh.
  2. backend/cpp/llama-cpp/prepare.sh: moved set -e above the patch-apply loop so a rejecting patch fails fast and loudly at apply time instead of surfacing as a downstream compile error. A missing or empty patches/ directory remains a no-op success, so no existing caller changes behavior when no patches ship (ik-llama-cpp is unaffected as it ships its own prepare.sh).

Verification

Temp-dir simulation: a rejecting patch now exits non-zero at apply time; missing and empty patches/ dirs still succeed; the copied patches/ dir is confirmed removed by the new Makefile step; make -n on the affected targets confirms recipe expansion is intact. Note backend/cpp/llama-cpp/patches/ does not exist on master yet, so on this PR alone the new rm -rf is a no-op; the real proof is #10837 rebased on top of this going green on tests-turboquant-grpc.

Assisted-by: Claude:claude-opus-4-8 [Claude Code]

Ping @mudler

…rk trees

The turboquant and bonsai backends copy backend/cpp/llama-cpp/ wholesale
into their build directories and reuse its Makefile/prepare.sh against
their own llama.cpp forks. When PR #10837 added
backend/cpp/llama-cpp/patches/0001-add-minimax-m3-support.patch, the
copied patches/ directory was mis-applied to the fork checkouts: the
fork trees diverge from upstream, hunks rejected, and because the
patch-apply loop in prepare.sh ran before set -e took effect the build
kept going and died much later with a confusing compile error
("'LLM_ARCH_MINIMAX_M3' was not declared in this scope"). This broke
tests-turboquant-grpc on that PR.

Two hardening changes:

- turboquant/bonsai Makefiles: delete the copied patches/ directory
  right after the cp -rf of backend/cpp/llama-cpp/. Patches vendored
  for upstream llama.cpp must never be applied to the forks; each fork
  carries its own patch series under backend/cpp/<backend>/patches/,
  applied by its apply-patches.sh.

- llama-cpp prepare.sh: run the patch-apply loop under set -e so a
  rejecting patch fails fast and loudly at apply time instead of
  surfacing as a downstream compile error. A missing or empty patches/
  directory remains a no-op success, so all existing callers (the
  llama-cpp Makefile targets and the turboquant/bonsai copies) are
  unaffected when no patches ship.

Exposed by PR #10837.

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Assisted-by: Claude:claude-opus-4-8 [Claude Code]
@mudler
mudler merged commit 1f53dff into master Jul 16, 2026
106 of 112 checks passed
@mudler
mudler deleted the fix/turboquant-bonsai-drop-copied-patches branch July 16, 2026 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants