Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.
llama: update llama.cpp to b9637 (#16609)
Jeffrey Morgan7ea692cb2b97
diff --git a/LLAMA_CPP_VERSION b/LLAMA_CPP_VERSIONindex 7f559d931..38e2f8571 100644--- a/LLAMA_CPP_VERSION+++ b/LLAMA_CPP_VERSION@@ -1 +1 @@-b9509+b9626diff --git a/llama/compat/llama-cpp-hooks.patch b/llama/compat/001-llama-cpp-hooks.patchsimilarity index 100%rename from llama/compat/llama-cpp-hooks.patchrename to llama/compat/001-llama-cpp-hooks.patchdiff --git a/llama/compat/002-llama-cpp-ui-empty-assets.patch b/llama/compat/002-llama-cpp-ui-empty-assets.patchnew file mode 100644index 000000000..31e90898f--- /dev/null+++ b/llama/compat/002-llama-cpp-ui-empty-assets.patch@@ -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;diff --git a/llama/compat/README.md b/llama/compat/README.mdindex 8c356a7dd..a944c89bf 100644--- a/llama/compat/README.md+++ b/llama/compat/README.md@@ -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 forKV edits, tensor renames, skip-prefix tracking, tensor load operations, andsmall 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 ofarchitectures llama.cpp doesn't support yet, each added via a smallregistration patch. (Those files *add* archs; the files above *translate*@@ -116,7 +119,7 @@ cd /path/to/llama.cppgit 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 Notesdiff --git a/llama/compat/apply-patch.cmake b/llama/compat/apply-patch.cmakeindex e7ca91af3..1f557c2cc 100644--- a/llama/compat/apply-patch.cmake+++ b/llama/compat/apply-patch.cmake@@ -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()diff --git a/llama/compat/compat.cmake b/llama/compat/compat.cmakeindex d3da98154..02a5b56ee 100644--- a/llama/compat/compat.cmake+++ b/llama/compat/compat.cmake@@ -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_SOURCESdiff --git a/llama/compat/models/llama-cpp-laguna.patch b/llama/compat/models/003-llama-cpp-laguna.patchsimilarity index 98%rename from llama/compat/models/llama-cpp-laguna.patchrename to llama/compat/models/003-llama-cpp-laguna.patchindex 30b161702..13e162bf1 100644--- a/llama/compat/models/llama-cpp-laguna.patch+++ b/llama/compat/models/003-llama-cpp-laguna.patch@@ -16,8 +16,8 @@ diff --git a/src/llama-arch.cpp b/src/llama-arch.cppdiff --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 {diff --git a/llama/compat/models/laguna.cpp b/llama/compat/models/laguna.cppindex 04947432d..5a41142ae 100644--- a/llama/compat/models/laguna.cpp+++ b/llama/compat/models/laguna.cpp@@ -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);