llama: update llama.cpp to b9637 (#16609)

This commit is contained in:
Jeffrey Morgan
2026-06-14 20:05:08 -07:00
committed by GitHub
parent 12e04379cd
commit 7ea692cb2b
8 changed files with 45 additions and 17 deletions
@@ -0,0 +1,15 @@
diff --git a/tools/ui/embed.cpp b/tools/ui/embed.cpp
--- a/tools/ui/embed.cpp
+++ b/tools/ui/embed.cpp
@@ -147,9 +147,9 @@ int main(int argc, char ** argv) {
const std::string out_cpp = argv[1];
const std::string out_h = argv[2];
- const std::string asset_dir = argv[3];
+ const std::string asset_dir = argc == 4 ? argv[3] : "";
- const bool use_gzip = std::filesystem::exists(asset_dir + "/_gzip");
+ const bool use_gzip = !asset_dir.empty() && std::filesystem::exists(asset_dir + "/_gzip");
const std::string in_dir = use_gzip ? (asset_dir + "/_gzip") : asset_dir;
std::vector<asset_entry> assets;
+6 -3
View File
@@ -23,11 +23,14 @@ intentionally skipped so a developer can iterate on a local llama.cpp tree.
- `llama-ollama-compat-util.h`, `llama-ollama-compat-util.cpp` - helpers for
KV edits, tensor renames, skip-prefix tracking, tensor load operations, and
small tensor repacking primitives.
- `llama-cpp-hooks.patch` - small additive call-site edits in llama.cpp files.
- `001-llama-cpp-hooks.patch` - small additive call-site edits in llama.cpp files.
It currently touches `src/llama-model-loader.cpp` and `tools/mtmd/clip.cpp`.
- `002-llama-cpp-ui-empty-assets.patch` - lets the llama.cpp UI embed helper
generate an empty asset table when no UI assets are present.
- `compat.cmake`, `apply-patch.cmake` - CMake glue and an idempotent applier
(used by `llama/server/CMakeLists.txt`) that applies every `*.patch` under
this directory — the hooks patch plus each `models/` architecture patch.
this directory by numeric filename order — the hooks patch plus each
`models/` architecture patch.
- `models/` - the sibling **new-architecture** layer: implementations of
architectures llama.cpp doesn't support yet, each added via a small
registration patch. (Those files *add* archs; the files above *translate*
@@ -116,7 +119,7 @@ cd /path/to/llama.cpp
git diff -- \
src/llama-model-loader.cpp \
tools/mtmd/clip.cpp \
> /path/to/ollama/llama/compat/llama-cpp-hooks.patch
> /path/to/ollama/llama/compat/001-llama-cpp-hooks.patch
```
## Implementation Notes
+18 -8
View File
@@ -3,10 +3,11 @@
# Invocation (from a CMake PATCH_COMMAND):
# cmake -DPATCH_DIR=<dir of *.patch> -P apply-patch.cmake
#
# Every *.patch under PATCH_DIR is applied in the current working directory
# (which ExternalProject / FetchContent sets to the fetched source's
# SOURCE_DIR). A patch already applied — detected via `git apply --reverse
# --check` — is skipped. This makes re-configuring and re-building safe.
# Every *.patch under PATCH_DIR is applied in numeric filename order in the
# current working directory (which ExternalProject / FetchContent sets to the
# fetched source's SOURCE_DIR). A patch already applied — detected via
# `git apply --reverse --check` — is skipped. This makes re-configuring and
# re-building safe.
if(NOT DEFINED PATCH_DIR)
message(FATAL_ERROR "apply-patch.cmake: PATCH_DIR not set")
@@ -19,8 +20,17 @@ get_filename_component(_git_ceiling "${_patch_workdir}" DIRECTORY)
set(_git_apply_env GIT_CEILING_DIRECTORIES=${_git_ceiling})
file(GLOB_RECURSE _patches "${PATCH_DIR}/*.patch")
list(SORT _patches)
set(_patch_entries)
foreach(PATCH_FILE IN LISTS _patches)
get_filename_component(_patch_name "${PATCH_FILE}" NAME)
list(APPEND _patch_entries "${_patch_name}|${PATCH_FILE}")
endforeach()
list(SORT _patch_entries)
foreach(_patch_entry IN LISTS _patch_entries)
string(REGEX REPLACE "^[^|]*\\|" "" PATCH_FILE "${_patch_entry}")
file(RELATIVE_PATH _patch_rel "${PATCH_DIR}" "${PATCH_FILE}")
# If the patch can be REVERSED cleanly, it's already applied. Skip.
execute_process(
COMMAND ${CMAKE_COMMAND} -E env ${_git_apply_env}
@@ -29,7 +39,7 @@ foreach(PATCH_FILE IN LISTS _patches)
OUTPUT_QUIET ERROR_QUIET
)
if(_reverse_check EQUAL 0)
message(STATUS "llama/compat: patch already applied, skipping")
message(STATUS "llama/compat: ${_patch_rel} already applied, skipping")
continue()
endif()
@@ -41,10 +51,10 @@ foreach(PATCH_FILE IN LISTS _patches)
)
if(NOT _apply_result EQUAL 0)
message(FATAL_ERROR
"llama/compat: failed to apply ${PATCH_FILE}\n"
"llama/compat: failed to apply ${_patch_rel}\n"
"This usually means the pinned llama.cpp source has changed. "
"Regenerate the patch against the pinned LLAMA_CPP_VERSION and retry.")
endif()
message(STATUS "llama/compat: applied patch")
message(STATUS "llama/compat: applied ${_patch_rel}")
endforeach()
+2 -2
View File
@@ -18,7 +18,7 @@
# The compat layer consists of:
# 1. Ollama-owned compat source files linked into the fetched llama.cpp
# targets from this directory.
# 2. A small patch file that adds call-sites in llama.cpp loaders.
# 2. A small ordered patch set that adds call-sites in llama.cpp loaders.
set(_compat_dir ${CMAKE_CURRENT_LIST_DIR})
@@ -46,7 +46,7 @@ set(OLLAMA_LLAMA_CPP_COMPAT_DIR
# Also export the individual paths in case callers want to do something
# custom (e.g. emit a dependency on the patch so reconfigures re-apply).
set(OLLAMA_LLAMA_CPP_COMPAT_PATCH_FILE
"${_compat_dir}/llama-cpp-hooks.patch"
"${_compat_dir}/001-llama-cpp-hooks.patch"
CACHE INTERNAL "Path to the llama.cpp compat patch")
set(OLLAMA_LLAMA_CPP_COMPAT_SOURCES
@@ -16,8 +16,8 @@ diff --git a/src/llama-arch.cpp b/src/llama-arch.cpp
diff --git a/src/llama-arch.h b/src/llama-arch.h
--- a/src/llama-arch.h
+++ b/src/llama-arch.h
@@ -140,2 +140,3 @@ enum llm_arch {
LLM_ARCH_MELLUM,
@@ -145,2 +145,3 @@ enum llm_arch {
LLM_ARCH_EAGLE3,
+ LLM_ARCH_LAGUNA,
LLM_ARCH_UNKNOWN,
@@ -382,2 +383,3 @@ enum llm_tensor {
+1 -1
View File
@@ -14,7 +14,7 @@ void llama_model_laguna::load_arch_hparams(llama_model_loader & ml) {
ml.get_key(LLM_KV_ATTENTION_SLIDING_WINDOW, hparams.n_swa, false);
hparams.swa_type = LLAMA_SWA_TYPE_STANDARD;
ml.get_key_or_arr("laguna.attention.layer_types", hparams.is_swa_impl, hparams.n_layer, false);
ml.get_key_or_arr("laguna.attention.layer_types", hparams.is_swa_impl, hparams.n_layer(), false);
ml.get_key("laguna.rope.swa.dimension_count", hparams.n_rot_swa, false);
ml.get_key("laguna.rope.swa.freq_base", hparams.rope_freq_base_train_swa, false);