Distribute and run LLMs with a single file.
C++ cross-platformggufllama-cpplocal-ailocal-inferencelocal-llmopen-source-aisingle-file-executablespeech-to-text
Update llama.cpp to b10441 (#1043)
Davide Eynard435512658cad
diff --git a/llama.cpp b/llama.cppindex c588c4f4..0177dcc7 160000--- a/llama.cpp+++ b/llama.cpp@@ -1 +1 @@-Subproject commit c588c4f47683e73ad2d69f50480bec6cc85fd0f7+Subproject commit 0177dcc7300bad8914bb838baabce87899812491diff --git a/llama.cpp.patches/README.md b/llama.cpp.patches/README.mdindex 0dfd2150..f7ee834f 100644--- a/llama.cpp.patches/README.md+++ b/llama.cpp.patches/README.md@@ -74,8 +74,9 @@ These patches address compatibility issues when building with Cosmopolitan libc| Patch | Description ||-------|-------------|| `common_arg.cpp.patch` | Adds `COSMOCC` platform detection for `PATH_MAX` (includes `linux/limits.h`) |-| `common_common.cpp.patch` | Adds platform-aware cache directory detection for Cosmopolitan (checks `LOCALAPPDATA`, `XDG_CACHE_HOME`, falls back to `~/.cache/`); also adds mmproj model size estimation to GPU fit params so the fit algorithm reserves enough VRAM for multimodal projectors |+| `common_common.cpp.patch` | Adds platform-aware cache directory detection for Cosmopolitan (`fs_get_cache_directory`: checks `LOCALAPPDATA`, `XDG_CACHE_HOME`, falls back to `~/.cache/`) and the same for the config directory (`fs_get_config_directory`, new in b10441: `APPDATA`, `XDG_CONFIG_HOME`, `~/.config/`) — both `#else` out to `#error Unknown architecture` upstream, since cosmocc defines none of `__linux__`/`__APPLE__`/`_WIN32`; also adds mmproj model size estimation to GPU fit params so the fit algorithm reserves enough VRAM for multimodal projectors || `common_download.cpp.patch` | Adds `COSMOCC` platform detection for `PATH_MAX` |+| `vendor_sheredom_subprocess.h.patch` | Under `__COSMOPOLITAN__`, rewrites `subprocess_error_from_errno()`'s `switch` over `E*` values as an `if`/`else` chain. Cosmopolitan resolves errno at runtime (one binary, every host OS), so those are not constant expressions and cannot be case labels — upstream's version fails with `case value is not a constant expression`. Same mapping, no behavior change. Needed since b10441, which added this function; the header only enters the build when `LLAMA_SUBPROCESS` is set (see Server Integration) |### Threading and Signal Handling@@ -85,7 +86,8 @@ Cosmopolitan libc has specific behaviors with condition variables and signals th|-------|-------------|| `common_log.cpp.patch` | Adds `#include <csignal>`; blocks `SIGINT`/`SIGTERM` on logger thread via `pthread_sigmask` to prevent `EINTR` exceptions; replaces `cv.wait()` with `wait_for(30s)` loop to work around XNU futex timeout bug (~72 minute expiry) || `tools_server_server-models.cpp.patch` | Adds `#include <csignal>`; blocks signals on the stopping thread via `pthread_sigmask`; replaces untimed `cv.wait()` with `wait_for(30s)` loops on every model-lifecycle wait (`unload_lru`, the reload-drain wait, `stopping_thread`, the `is_reloading` guard in `load`, and the generic `wait()` predicate helper) to work around the XNU futex timeout bug |-| `tools_server_server-queue.cpp.patch` | Adds missing includes (`<cerrno>`, `<system_error>`, `<csignal>`); blocks `SIGINT`/`SIGTERM` on queue thread; replaces `wait()` with `wait_for()` loops in three locations (`wait_until_no_sleep`, main loop, `recv`) |+| `tools_server_server-queue.cpp.patch` | Adds missing includes (`<cerrno>`, `<system_error>`, `<csignal>`); blocks `SIGINT`/`SIGTERM` on queue thread (the `yield_to_queue` worker thread is spawned after this, so it inherits the mask); replaces `wait()` with `wait_for(30s)` loops in five locations (`wait_until_no_sleep`, main loop, `recv`, plus `worker_loop` and `yield_to_queue`, both new upstream in b10441); runs `yield_to_queue()` inline when a GPU backend is loaded (see "GPU decode must stay on the main thread" below) |+| `tools_server_server-stream.cpp.patch` | Adds `#include <csignal>`; blocks signals on the stream-session GC thread via `pthread_sigmask`. Without it, Ctrl+C on `llama-server` aborts with *"libc++abi: terminating due to uncaught exception ... condition_variable timed_wait failed: Interrupted system call"* instead of shutting down: `SIGINT` is delivered to that thread while it sits in `gc_wake_cv.wait_for(60s)`, `pthread_cond_timedwait()` returns `EINTR`, and libcxx rethrows it as `std::system_error` that nothing catches. This thread was the last one in the server with a condition-variable wait and no signal mask (the log worker, task queue, model-stopping thread and httplib pool were already covered). Pre-existing, not introduced by b10441; combined TUI mode is unaffected || `vendor_cpp-httplib_httplib.cpp.patch` | Fixes httplib thread pool with `wait_for()` instead of `wait()` for XNU futex compatibility; also see HTTPS / TLS Support below |### HTTPS / TLS Support@@ -103,6 +105,14 @@ layouts, so all TUs must agree) and links `mbedtls.a` into `llama-server`.This enables HTTPS model downloads (`-hf`, `--model-url`), https clientsin server-models, and TLS serving via `--ssl-cert-file`/`--ssl-key-file`.+**Keep-in-sync on a bump:** `third_party/mbedtls/include/mbedtls/` holds one+forwarding header per `<mbedtls/*.h>` that the vendored `httplib.h` includes.+When upstream refreshes cpp-httplib and it reaches for a new one, the build+fails with `fatal error: 'mbedtls/<x>.h' file not found` — add the matching+one-line forwarder (b10441 needed `version.h`, which httplib now uses to gate+its 2.x/3.x/4.x API branches; the vendored fork is 2.26, so+`MBEDTLS_VERSION_MAJOR` is 2 and the 2.x path stays selected).+| Patch | Description ||-------|-------------|| `common_http.h.patch` | `#ifndef CPPHTTPLIB_OPENSSL_SUPPORT` -> `#ifndef CPPHTTPLIB_SSL_ENABLED` for the "HTTPS is not supported" guard, so any cpp-httplib TLS backend counts (candidate for upstreaming) |@@ -158,6 +168,58 @@ These patches integrate llamafile's file handling APIs for loading models from b|-------|-------------|| `tools_server_server.cpp.patch` | Renames upstream's `llama_server()` to `server_main()` and adds `on_ready`/`on_shutdown_available` callbacks for combined TUI+server mode; adds Metal/GPU backend trigger before `common_init()`; installs the sandbox (`llamafile_sandbox_server()`, issue #930) — the mechanism lives in `llamafile/sandbox.c`; the patch fills a `llamafile_sandbox_spec` with the on-disk paths the loader opens after the lock (model, mmproj, media dir, LoRA, draft model, control vectors, public path as read; slot-save and prompt cache as read-write), detects outbound-needing features (`--rpc` via argv/env, MCP proxy, server tools) to relax `anet`→`inet`, passes `FLAG_confine_reads` for opt-in unveil(), quiesces the log worker (`common_log_pause`/`resume`, so no thread escapes the per-thread filter) around the call, before the HTTP listener spawns and before model load, and skips it in combined/GPU modes; adds Cosmopolitan-specific standalone `main()` with `cosmo_args`, verbose flag handling, `--unsecure` consumption (`llamafile_consume_flag`), and GPU pre-initialization; handles `LLAMAFILE_TUI` exit to avoid Metal cleanup crashes |+**GPU decode must stay on the main thread** (`tools_server_server-queue.cpp.patch`).+b10441 moved `llama_decode()` off the main thread: `update_slots()` now hands+each batch to `queue_tasks.yield_to_queue()`, which runs it on a worker thread+created in `start_loop()`. Under Cosmopolitan that is fatal for every GPU+backend, because they are host ELFs loaded with `cosmo_dlopen()` and their libc+reaches thread-local state through `%fs`:++| thread | `fs_base` | `gs_base` | `*(fs+0x10)` (glibc TCB `self`) |+|--------|-----------|-----------|-------------------------------|+| main (created by the host) | `0x7ffff7e54740` | `0x7ffff7ff8000` | valid, points to itself |+| cosmo-spawned worker | `0x7fffe83ca880` | *same as fs* | `0` |++Cosmo gives its own threads cosmo TLS in **both** `%fs` and `%gs`; there is no+glibc TCB. `cosmo_dlopen`'s `foreign_tramp` does swap in a host TLS block+(`__foreign`, set up once via `cosmo_once`), but only for pointers obtained+through `cosmo_dlsym` — ggml's `ggml_backend_i` vtable holds raw DSO pointers+that ggml core calls directly. So the first CUDA decode on the worker lands in+host `pthread_getspecific`, which reads `%fs:0x10` as the TCB self-pointer, gets+`0`, and segfaults at `0x328` (verified on an L40S: deterministic, any model+size, `dmesg` shows `segfault at 328 ... in libc.so.6`).++The patch therefore runs the work inline on the calling thread whenever+`llamafile_has_gpu()` — restoring exactly where decode ran before b10441.+CPU-only runs keep upstream's worker. The cost is narrow: the yield wraps a+single `llama_decode(batch_view)`, and only `SERVER_TASK_TYPE_METRICS` is+serviced during it, so the sole effect is that `/metrics` and `/slots` wait for+the in-flight batch (~29 ms while generating; up to a few seconds for a full+prompt batch). This will recur whenever upstream moves work onto a new thread.++**Subprocess support needs `-DLLAMA_SUBPROCESS`** (set in `BUILD.mk`, not a+patch). b10441 moved child-process spawning into `common_subproc`+(`common/subproc.*`, wrapping the vendored `sheredom/subprocess.h`) and put it+behind a build gate; before that `server-models.cpp` included `subprocess.h`+unconditionally, so the cosmocc build got it for free. Upstream's CMake+defaults the option ON except on iOS/Android/WASM. It gates three server+features, all reachable from llamafile since `args.cpp` strips only+llamafile's own flags and passes the rest to `common_params_parse`:++- **MCP stdio servers** (`--mcp-servers-config`, `--mcp-servers-json`) —+ `server-mcp.cpp` spawns them and, unlike the other two, does **not** check+ `common_subproc::is_supported()`, so without the define they fail silently+ rather than reporting an error.+- **`--server-tools`** — `server-tools.cpp` throws *"subprocess is not enabled+ on this build"*, caught into a clean `return 1`.+- **Router mode** — `llama-server` with no model; `init_routes()` throws the+ same message, and the server exits at startup.++The macro also switches `subprocess_s` between its real and dummy definition+in `subproc.h`, so every object that can reach that header must be compiled+with it. Enabling it pulls `subprocess.h` into the build, which needs the+Cosmopolitan fix in the patch table above.+The web UI moved upstream from prebuilt `tools/server/public/*` assets toa Svelte/PWA project under `tools/ui/`, embedded at CMake time via`tools/ui/embed.cpp`. cosmocc has no JS toolchain, so `fetch-ui-assets.sh`@@ -187,8 +249,8 @@ API still works.Note that `embed.cpp` only takes that graceful no-asset path when `dist/` is*empty*: once the directory is non-empty it enforces a required-asset set-(its `required_check[]` table — `index.html`, `loading.html`,-`manifest.webmanifest`, `sw.js`, `build.json`, `version.json`, and the hashed+(its `required_check[]` table — `index.html`, `manifest.webmanifest`, `sw.js`,+`build.json`, `version.json`, and the hashed`bundle*.js`/`bundle*.css`/`workbox*.js`) and returns a hard error if any ismissing. So `fetch-ui-assets.sh` validates the *same* set after extracting(`ui_missing_assets`); if a downloaded tarball is partial or has drifted, it@@ -205,7 +267,7 @@ can change on a llama.cpp bump — when it does, the asset list in| `ggml_src_ggml-vulkan_ggml-vulkan.cpp.patch` | Fixes unsigned integer underflow in `ggml_backend_vk_get_device_memory` where Vulkan's `heapUsage` can exceed `heapBudget` (clamps to zero instead of wrapping) || `src_models_t5.cpp.patch` | Forward-declares the `graph<false>`/`graph<true>` explicit specializations before `build_arch_graph` so clang's `-std=gnu++23` doesn't reject them as specializations after implicit instantiation || `src_models_eagle3.cpp.patch` | Moves `build_arch_graph` to the end of the file, after the `graph<true>`/`graph<false>` constructor specializations, so clang's `-std=gnu++23` doesn't reject them as explicit specializations appearing after the `make_unique<graph<...>>` implicit instantiation point |-| `src_models_dflash.cpp.patch` | Same fix as `eagle3` for the DFlash model (new in b10052): moves `build_arch_graph` to the end of the file, after the `graph<true>`/`graph<false>` specializations, so clang's `-std=gnu++23` doesn't reject them as explicit specializations after the `make_unique<graph<...>>` implicit instantiation point |+| `src_models_dflash.cpp.patch` | Same fix as `eagle3` for the DFlash model (new in b10052): moves `build_arch_graph` to the end of the file, after the `graph<true>`/`graph<false>`/`graph_dsv4` specializations, so clang's `-std=gnu++23` doesn't reject them as explicit specializations after the `make_unique<graph<...>>` implicit instantiation point |## Creating New Patchesdiff --git a/llama.cpp.patches/llamafile-files/BUILD.mk b/llama.cpp.patches/llamafile-files/BUILD.mkindex 532781e1..3b3ccbdb 100644--- a/llama.cpp.patches/llamafile-files/BUILD.mk+++ b/llama.cpp.patches/llamafile-files/BUILD.mk@@ -65,6 +65,7 @@ LLAMA_SRCS_CPP := \llama.cpp/src/models/bloom.cpp \llama.cpp/src/models/chameleon.cpp \llama.cpp/src/models/chatglm.cpp \+ llama.cpp/src/models/clip.cpp \llama.cpp/src/models/codeshell.cpp \llama.cpp/src/models/cogvlm.cpp \llama.cpp/src/models/cohere2.cpp \@@ -104,6 +105,7 @@ LLAMA_SRCS_CPP := \llama.cpp/src/models/gptneox.cpp \llama.cpp/src/models/granite-hybrid.cpp \llama.cpp/src/models/granite-moe.cpp \+ llama.cpp/src/models/granite-switch.cpp \llama.cpp/src/models/granite.cpp \llama.cpp/src/models/mamba-base.cpp \llama.cpp/src/models/grok.cpp \@@ -134,11 +136,15 @@ LLAMA_SRCS_CPP := \llama.cpp/src/models/mimo2.cpp \llama.cpp/src/models/minicpm.cpp \llama.cpp/src/models/minicpm3.cpp \+ llama.cpp/src/models/minimax-01.cpp \llama.cpp/src/models/minimax-m2.cpp \+ llama.cpp/src/models/minimax-m3.cpp \llama.cpp/src/models/mistral3.cpp \llama.cpp/src/models/mistral4.cpp \llama.cpp/src/models/modern-bert.cpp \llama.cpp/src/models/mpt.cpp \+ llama.cpp/src/models/muse-glimmer.cpp \+ llama.cpp/src/models/nanbeige.cpp \llama.cpp/src/models/nemotron-h-moe.cpp \llama.cpp/src/models/nemotron-h.cpp \llama.cpp/src/models/nemotron.cpp \@@ -160,6 +166,7 @@ LLAMA_SRCS_CPP := \llama.cpp/src/models/plamo2.cpp \llama.cpp/src/models/plamo3.cpp \llama.cpp/src/models/plm.cpp \+ llama.cpp/src/models/pockettts.cpp \llama.cpp/src/models/qwen.cpp \llama.cpp/src/models/qwen2.cpp \llama.cpp/src/models/qwen2moe.cpp \@@ -167,6 +174,7 @@ LLAMA_SRCS_CPP := \llama.cpp/src/models/qwen3.cpp \llama.cpp/src/models/qwen3moe.cpp \llama.cpp/src/models/qwen3next.cpp \+ llama.cpp/src/models/qwen3tts.cpp \llama.cpp/src/models/qwen35.cpp \llama.cpp/src/models/qwen35moe.cpp \llama.cpp/src/models/qwen3vl.cpp \@@ -204,6 +212,7 @@ LLAMA_SRCS_CPP := \llama.cpp/src/llama-kv-cache-dsa.cpp \llama.cpp/src/llama-kv-cache-dsv4.cpp \llama.cpp/src/llama-kv-cache-iswa.cpp \+ llama.cpp/src/llama-kv-cache-msa.cpp \llama.cpp/src/llama-kv-cache.cpp \llama.cpp/src/llama-memory-hybrid.cpp \llama.cpp/src/llama-memory-hybrid-iswa.cpp \@@ -257,6 +266,8 @@ COMMON_SRCS_CPP := \llama.cpp/common/reasoning-budget.cpp \llama.cpp/common/sampling.cpp \llama.cpp/common/speculative.cpp \+ llama.cpp/common/subproc.cpp \+ llama.cpp/common/trie.cpp \llama.cpp/common/unicode.cpp# Build info generation@@ -308,6 +319,7 @@ MTMD_SRCS_CPP := \llama.cpp/tools/mtmd/clip.cpp \llama.cpp/tools/mtmd/mtmd.cpp \llama.cpp/tools/mtmd/mtmd-helper.cpp \+ llama.cpp/tools/mtmd/mtmd-helper-gen.cpp \llama.cpp/tools/mtmd/mtmd-audio.cpp \llama.cpp/tools/mtmd/mtmd-image.cpp \llama.cpp/tools/mtmd/models/cogvlm.cpp \@@ -329,14 +341,23 @@ MTMD_SRCS_CPP := \llama.cpp/tools/mtmd/models/kimivl.cpp \llama.cpp/tools/mtmd/models/llama4.cpp \llama.cpp/tools/mtmd/models/llava.cpp \+ llama.cpp/tools/mtmd/models/mimo-audio.cpp \llama.cpp/tools/mtmd/models/mimovl.cpp \llama.cpp/tools/mtmd/models/minicpmv.cpp \+ llama.cpp/tools/mtmd/models/minimax-m3.cpp \llama.cpp/tools/mtmd/models/mobilenetv5.cpp \+ llama.cpp/tools/mtmd/models/muse-glimmer.cpp \llama.cpp/tools/mtmd/models/nemotron-v2-vl.cpp \llama.cpp/tools/mtmd/models/paddleocr.cpp \+ llama.cpp/tools/mtmd/models/parakeet.cpp \llama.cpp/tools/mtmd/models/pixtral.cpp \+ llama.cpp/tools/mtmd/models/pockettts-gen.cpp \+ llama.cpp/tools/mtmd/models/pockettts-seanet.cpp \+ llama.cpp/tools/mtmd/models/pockettts-spkenc.cpp \llama.cpp/tools/mtmd/models/qwen2vl.cpp \llama.cpp/tools/mtmd/models/qwen3a.cpp \+ llama.cpp/tools/mtmd/models/qwen3tts-gen.cpp \+ llama.cpp/tools/mtmd/models/qwen3tts-spkenc.cpp \llama.cpp/tools/mtmd/models/qwen3vl.cpp \llama.cpp/tools/mtmd/models/siglip.cpp \llama.cpp/tools/mtmd/models/step3vl.cpp \@@ -420,6 +441,7 @@ TOOL_SERVER_SRCS := \llama.cpp/tools/server/server-common.cpp \llama.cpp/tools/server/server-context.cpp \llama.cpp/tools/server/server-http.cpp \+ llama.cpp/tools/server/server-mcp.cpp \llama.cpp/tools/server/server-models.cpp \llama.cpp/tools/server/server-queue.cpp \llama.cpp/tools/server/server-schema.cpp \@@ -512,6 +534,15 @@ $(LLAMA_CPP_OBJS) $(TOOL_SERVER_OBJS): private CCFLAGS += \# Common library needs httplib support$(COMMON_OBJS): private CCFLAGS += -DLLAMA_USE_HTTPLIB+# Subprocess spawning (common/subproc.*, wrapping vendored+# sheredom/subprocess.h). Gates MCP stdio servers, --server-tools, and router+# mode; b10441 added the gate, before which server-models.cpp used+# subprocess.h unconditionally. Upstream's CMake defaults it ON except on+# iOS/Android/WASM. The macro switches subprocess_s between its real and dummy+# definition in common/subproc.h, so every object reaching that header must+# agree on it.+$(LLAMA_CPP_OBJS) $(TOOL_SERVER_OBJS): private CPPFLAGS += -DLLAMA_SUBPROCESS+# Optimization flags for specific components$(LLAMA_OBJS) $(COMMON_OBJS): private CCFLAGS += -DNDEBUGdiff --git a/llama.cpp.patches/patches/common_arg.cpp.patch b/llama.cpp.patches/patches/common_arg.cpp.patchindex 7b3bab50..2e371ba7 100644--- a/llama.cpp.patches/patches/common_arg.cpp.patch+++ b/llama.cpp.patches/patches/common_arg.cpp.patch@@ -1,7 +1,7 @@diff --git a/common/arg.cpp b/common/arg.cpp--- a/llama.cpp/common/arg.cpp+++ b/llama.cpp/common/arg.cpp-@@ -39,6 +39,8 @@+@@ -42,6 +42,8 @@#ifndef __EMSCRIPTEN__#ifdef __linux__#include <linux/limits.h>diff --git a/llama.cpp.patches/patches/common_common.cpp.patch b/llama.cpp.patches/patches/common_common.cpp.patchindex c4772ae6..226ea76b 100644--- a/llama.cpp.patches/patches/common_common.cpp.patch+++ b/llama.cpp.patches/patches/common_common.cpp.patch@@ -52,24 +52,49 @@ diff --git a/common/common.cpp b/common/common.cppint32_t logical_cpus = _system_configuration.ncpus;int32_t smt_threads = _system_configuration.smt_threads;if (smt_threads > 0) {-@@ -1033,6 +1068,16 @@ std::string fs_get_cache_directory() {- cache_directory = std::getenv("HOME") + std::string("/Library/Caches/");- #elif defined(_WIN32)- cache_directory = std::getenv("LOCALAPPDATA");+@@ -1058,6 +1093,20 @@ std::string fs_get_cache_directory() {+ if (cache_directory.empty()) {+ throw std::runtime_error("Failed to find %LOCALAPPDATA% directory");+ }+#elif defined(COSMOCC)-+ // We don't know what OS we are running on at compile time, just CPU architecture.-+ // try various environment variables, fall back to ~/.cache.-+ if (std::getenv("LOCALAPPDATA")) {-+ cache_directory = std::getenv("LOCALAPPDATA");-+ } else if (std::getenv("XDG_CACHE_HOME")) {-+ cache_directory = std::getenv("XDG_CACHE_HOME");-+ } else {-+ cache_directory = std::getenv("HOME") + std::string("/.cache/");++ // We don't know what OS we are running on at compile time, just CPU++ // architecture. Try various environment variables, fall back to ~/.cache.++ cache_directory = common_get_env("LOCALAPPDATA");++ if (cache_directory.empty()) {++ cache_directory = common_get_env("XDG_CACHE_HOME");++ }++ if (cache_directory.empty()) {++ const std::string home = common_get_env("HOME");++ if (home.empty()) {++ throw std::runtime_error("Failed to find $HOME directory");++ }++ cache_directory = home + "/.cache/";+ }#elif defined(__EMSCRIPTEN__)GGML_ABORT("not implemented on this platform");#else-@@ -1222,10 +1267,31 @@ common_init_result::common_init_result(common_params & params, bool model_only)+@@ -1103,6 +1152,20 @@ std::string fs_get_config_directory() {+ if (config_directory.empty()) {+ throw std::runtime_error("Failed to find %APPDATA% directory");+ }++#elif defined(COSMOCC)++ // We don't know what OS we are running on at compile time, just CPU++ // architecture. Try various environment variables, fall back to ~/.config.++ config_directory = common_get_env("APPDATA");++ if (config_directory.empty()) {++ config_directory = common_get_env("XDG_CONFIG_HOME");++ }++ if (config_directory.empty()) {++ const std::string home = common_get_env("HOME");++ if (home.empty()) {++ throw std::runtime_error("Failed to find $HOME directory");++ }++ config_directory = home + "/.config/";++ }+ #elif defined(__EMSCRIPTEN__)+ // caller decides what to do when there is no config directory+ throw std::runtime_error("not implemented on this platform");+@@ -1294,10 +1357,31 @@ common_init_result::common_init_result(common_params & params, bool model_only)if (params.fit_params) {COM_TRC("%s", "fitting params to device memory ...\n");COM_TRC("%s", "(for bugs during this step try to reproduce them with -fit off, or provide --verbose logs if the bug only occurs with -fit on)\n");diff --git a/llama.cpp.patches/patches/ggml_include_ggml-backend.h.patch b/llama.cpp.patches/patches/ggml_include_ggml-backend.h.patchindex d0443c58..013b0f23 100644--- a/llama.cpp.patches/patches/ggml_include_ggml-backend.h.patch+++ b/llama.cpp.patches/patches/ggml_include_ggml-backend.h.patch@@ -18,7 +18,7 @@ diff --git a/ggml/include/ggml-backend.h b/ggml/include/ggml-backend.h#ifdef __cplusplusextern "C" {#endif-@@ -208,19 +218,19 @@ extern "C" {+@@ -210,19 +220,19 @@ extern "C" {typedef bool (*ggml_backend_comm_allreduce_tensor_t)(void * comm_ctx, struct ggml_tensor ** tensors);// Split buffer type for tensor parallelism (old)diff --git a/llama.cpp.patches/patches/ggml_src_ggml-backend-meta.cpp.patch b/llama.cpp.patches/patches/ggml_src_ggml-backend-meta.cpp.patchindex d1c703af..85503cea 100644--- a/llama.cpp.patches/patches/ggml_src_ggml-backend-meta.cpp.patch+++ b/llama.cpp.patches/patches/ggml_src_ggml-backend-meta.cpp.patch@@ -40,7 +40,7 @@ diff --git a/ggml/src/ggml-backend-meta.cpp b/ggml/src/ggml-backend-meta.cppGGML_ASSERT(ggml_backend_dev_is_meta(dev));const ggml_backend_meta_device_context * meta_dev_ctx = (const ggml_backend_meta_device_context *) dev->context;-@@ -143,20 +143,20 @@ static void ggml_backend_meta_device_get_props(ggml_backend_dev_t dev, ggml_back+@@ -145,20 +145,20 @@ static void ggml_backend_meta_device_get_props(ggml_backend_dev_t dev, ggml_back}}@@ -66,7 +66,7 @@ diff --git a/ggml/src/ggml-backend-meta.cpp b/ggml/src/ggml-backend-meta.cppGGML_ASSERT(ggml_backend_dev_is_meta(dev));ggml_backend_dev_t dev_buft = ggml_backend_buft_get_device(buft);if (!ggml_backend_dev_is_meta(dev_buft)) {-@@ -273,7 +273,7 @@ static size_t ggml_backend_meta_buft_n_bufts(ggml_backend_buffer_type_t meta_buf+@@ -275,7 +275,7 @@ static size_t ggml_backend_meta_buft_n_bufts(ggml_backend_buffer_type_t meta_bufreturn meta_buft_ctx->simple_bufts.size();}@@ -75,7 +75,7 @@ diff --git a/ggml/src/ggml-backend-meta.cpp b/ggml/src/ggml-backend-meta.cppGGML_ASSERT(ggml_backend_buft_is_meta(buft));const ggml_backend_meta_buffer_type_context * meta_buft_ctx = (const ggml_backend_meta_buffer_type_context *) buft->context;return meta_buft_ctx->name.c_str();-@@ -286,9 +286,9 @@ static ggml_backend_buffer_type_t ggml_backend_meta_buft_simple_buft(ggml_backen+@@ -288,9 +288,9 @@ static ggml_backend_buffer_type_t ggml_backend_meta_buft_simple_buft(ggml_backenreturn meta_buft_ctx->simple_bufts[index];}@@ -87,7 +87,7 @@ diff --git a/ggml/src/ggml-backend-meta.cpp b/ggml/src/ggml-backend-meta.cppconst size_t n_simple_bufts = ggml_backend_meta_buft_n_bufts(buft);size_t max_alignment = 1;for (size_t i = 0; i < n_simple_bufts; i++) {-@@ -299,7 +299,7 @@ static size_t ggml_backend_meta_buffer_type_get_alignment(ggml_backend_buffer_ty+@@ -301,7 +301,7 @@ static size_t ggml_backend_meta_buffer_type_get_alignment(ggml_backend_buffer_tyreturn max_alignment;}@@ -96,7 +96,7 @@ diff --git a/ggml/src/ggml-backend-meta.cpp b/ggml/src/ggml-backend-meta.cppconst size_t n_simple_bufts = ggml_backend_meta_buft_n_bufts(buft);size_t max_size = SIZE_MAX;for (size_t i = 0; i < n_simple_bufts; i++) {-@@ -308,7 +308,7 @@ static size_t ggml_backend_meta_buffer_type_get_max_size(ggml_backend_buffer_typ+@@ -310,7 +310,7 @@ static size_t ggml_backend_meta_buffer_type_get_max_size(ggml_backend_buffer_typreturn max_size;}@@ -105,7 +105,7 @@ diff --git a/ggml/src/ggml-backend-meta.cpp b/ggml/src/ggml-backend-meta.cppconst size_t n_simple_bufts = ggml_backend_meta_buft_n_bufts(buft);size_t max_alloc_size = 0;for (size_t i = 0; i < n_simple_bufts; i++) {-@@ -318,7 +318,7 @@ static size_t ggml_backend_meta_buffer_type_get_alloc_size(ggml_backend_buffer_t+@@ -320,7 +320,7 @@ static size_t ggml_backend_meta_buffer_type_get_alloc_size(ggml_backend_buffer_treturn max_alloc_size;}@@ -114,7 +114,7 @@ diff --git a/ggml/src/ggml-backend-meta.cpp b/ggml/src/ggml-backend-meta.cppconst size_t n_simple_bufts = ggml_backend_meta_buft_n_bufts(buft);for (size_t i = 0; i < n_simple_bufts; i++) {if (!ggml_backend_buft_is_host(ggml_backend_meta_buft_simple_buft(buft, i))) {-@@ -341,7 +341,7 @@ bool ggml_backend_buft_is_meta(ggml_backend_buffer_type_t buft) {+@@ -343,7 +343,7 @@ bool ggml_backend_buft_is_meta(ggml_backend_buffer_type_t buft) {return buft != nullptr && buft->iface.get_name == ggml_backend_meta_buffer_type_iface.get_name;}@@ -123,7 +123,7 @@ diff --git a/ggml/src/ggml-backend-meta.cpp b/ggml/src/ggml-backend-meta.cppstatic std::map<ggml_backend_dev_t, struct ggml_backend_buffer_type> meta_bufts;GGML_ASSERT(ggml_backend_dev_is_meta(dev));{-@@ -368,7 +368,7 @@ static ggml_backend_buffer_type_t ggml_backend_meta_device_get_buffer_type(ggml_+@@ -370,7 +370,7 @@ static ggml_backend_buffer_type_t ggml_backend_meta_device_get_buffer_type(ggml_return &result.first->second;}@@ -132,7 +132,7 @@ diff --git a/ggml/src/ggml-backend-meta.cpp b/ggml/src/ggml-backend-meta.cppGGML_ASSERT(ggml_backend_dev_is_meta(dev));const ggml_backend_meta_device_context * meta_dev_ctx = (const ggml_backend_meta_device_context *) dev->context;-@@ -451,7 +451,7 @@ struct ggml_backend_meta_buffer_context {+@@ -453,7 +453,7 @@ struct ggml_backend_meta_buffer_context {}};@@ -141,7 +141,7 @@ diff --git a/ggml/src/ggml-backend-meta.cpp b/ggml/src/ggml-backend-meta.cppGGML_ASSERT(ggml_backend_buffer_is_meta(buffer));ggml_backend_meta_buffer_context * buf_ctx = (ggml_backend_meta_buffer_context *) buffer->context;delete buf_ctx;-@@ -1121,7 +1121,7 @@ static struct ggml_backend_meta_split_state ggml_backend_meta_get_split_state(co+@@ -1123,7 +1123,7 @@ static struct ggml_backend_meta_split_state ggml_backend_meta_get_split_state(coreturn ggml_backend_meta_get_split_state(buf_ctx->get_simple_tensor_container(tensor), tensor, assume_sync);}@@ -150,7 +150,7 @@ diff --git a/ggml/src/ggml-backend-meta.cpp b/ggml/src/ggml-backend-meta.cppGGML_UNUSED(buffer);return (void *) 0x1000000000000000; // FIXME}-@@ -1246,14 +1246,14 @@ static enum ggml_status ggml_backend_meta_buffer_init_tensor_impl(ggml_backend_m+@@ -1248,14 +1248,14 @@ static enum ggml_status ggml_backend_meta_buffer_init_tensor_impl(ggml_backend_mreturn GGML_STATUS_SUCCESS;}@@ -167,7 +167,7 @@ diff --git a/ggml/src/ggml-backend-meta.cpp b/ggml/src/ggml-backend-meta.cppconst size_t n_bufs = ggml_backend_meta_buffer_n_bufs(buffer);const ggml_backend_meta_split_state split_state = ggml_backend_meta_get_split_state(tensor, /*assume_sync =*/ false);GGML_ASSERT(ggml_is_contiguous(tensor) || split_state.axis == GGML_BACKEND_SPLIT_AXIS_MIRRORED);-@@ -1367,7 +1367,7 @@ static void ggml_backend_meta_buffer_set_tensor(ggml_backend_buffer_t buffer, gg+@@ -1369,7 +1369,7 @@ static void ggml_backend_meta_buffer_set_tensor(ggml_backend_buffer_t buffer, gg}}@@ -176,7 +176,7 @@ diff --git a/ggml/src/ggml-backend-meta.cpp b/ggml/src/ggml-backend-meta.cppconst size_t n_bufs = ggml_backend_meta_buffer_n_bufs(buffer);const ggml_backend_meta_split_state split_state = ggml_backend_meta_get_split_state(tensor, /*assume_sync =*/ false);GGML_ASSERT(ggml_is_contiguous(tensor) || split_state.axis == GGML_BACKEND_SPLIT_AXIS_MIRRORED);-@@ -1467,14 +1467,14 @@ static void ggml_backend_meta_buffer_get_tensor(ggml_backend_buffer_t buffer, co+@@ -1469,14 +1469,14 @@ static void ggml_backend_meta_buffer_get_tensor(ggml_backend_buffer_t buffer, co}}@@ -193,7 +193,7 @@ diff --git a/ggml/src/ggml-backend-meta.cpp b/ggml/src/ggml-backend-meta.cppGGML_ASSERT(ggml_backend_buffer_is_meta(buffer));ggml_backend_meta_buffer_context * buf_ctx = (ggml_backend_meta_buffer_context *) buffer->context;for (size_t i = 0; i < buf_ctx->bufs.size(); i++) {-@@ -1500,7 +1500,7 @@ bool ggml_backend_buffer_is_meta(ggml_backend_buffer_t buf) {+@@ -1502,7 +1502,7 @@ bool ggml_backend_buffer_is_meta(ggml_backend_buffer_t buf) {return buf != nullptr && buf->iface.free_buffer == ggml_backend_meta_buffer_iface.free_buffer;}@@ -202,7 +202,7 @@ diff --git a/ggml/src/ggml-backend-meta.cpp b/ggml/src/ggml-backend-meta.cppconst size_t n_simple_bufts = ggml_backend_meta_buft_n_bufts(buft);const ggml_init_params params = {-@@ -1667,20 +1667,20 @@ struct ggml_backend_meta_context {+@@ -1669,20 +1669,20 @@ struct ggml_backend_meta_context {}};@@ -226,7 +226,7 @@ diff --git a/ggml/src/ggml-backend-meta.cpp b/ggml/src/ggml-backend-meta.cppconst size_t n_backends = ggml_backend_meta_n_backends(backend);GGML_ASSERT(offset == 0);GGML_ASSERT(ggml_is_contiguous(tensor));-@@ -1725,7 +1725,7 @@ static void ggml_backend_meta_set_tensor_async(ggml_backend_t backend, ggml_tens+@@ -1727,7 +1727,7 @@ static void ggml_backend_meta_set_tensor_async(ggml_backend_t backend, ggml_tens}}@@ -235,7 +235,7 @@ diff --git a/ggml/src/ggml-backend-meta.cpp b/ggml/src/ggml-backend-meta.cppconst size_t n_backends = ggml_backend_meta_n_backends(backend);GGML_ASSERT(offset == 0);GGML_ASSERT(ggml_is_contiguous(tensor));-@@ -1770,14 +1770,14 @@ static void ggml_backend_meta_get_tensor_async(ggml_backend_t backend, const ggm+@@ -1772,14 +1772,14 @@ static void ggml_backend_meta_get_tensor_async(ggml_backend_t backend, const ggm}}@@ -252,7 +252,7 @@ diff --git a/ggml/src/ggml-backend-meta.cpp b/ggml/src/ggml-backend-meta.cppGGML_ASSERT(cgraph->grads == nullptr);const size_t n_backends = ggml_backend_meta_n_backends(backend);ggml_backend_meta_context * backend_ctx = (ggml_backend_meta_context *) backend->context;-@@ -2247,7 +2247,7 @@ bool ggml_backend_is_meta(ggml_backend_t backend) {+@@ -2249,7 +2249,7 @@ bool ggml_backend_is_meta(ggml_backend_t backend) {return backend != nullptr && backend->iface.get_name == ggml_backend_meta_i.get_name;}diff --git a/llama.cpp.patches/patches/ggml_src_ggml-backend.cpp.patch b/llama.cpp.patches/patches/ggml_src_ggml-backend.cpp.patchindex ba7bc249..5b1f9bfa 100644--- a/llama.cpp.patches/patches/ggml_src_ggml-backend.cpp.patch+++ b/llama.cpp.patches/patches/ggml_src_ggml-backend.cpp.patch@@ -43,7 +43,7 @@ diff --git a/ggml/src/ggml-backend.cpp b/ggml/src/ggml-backend.cpp};ggml_backend_buffer_t ggml_backend_multi_buffer_alloc_buffer(ggml_backend_buffer_t * buffers, size_t n_buffers) {-@@ -2210,7 +2218,7 @@ bool ggml_backend_compare_graph_backend(ggml_backend_t backend1, ggml_backend_t+@@ -2270,7 +2278,7 @@ bool ggml_backend_compare_graph_backend(ggml_backend_t backend1, ggml_backend_t// CPU backend - buffer@@ -52,7 +52,7 @@ diff --git a/ggml/src/ggml-backend.cpp b/ggml/src/ggml-backend.cppGGML_ASSERT(buffer);uintptr_t data = (uintptr_t)buffer->context;-@@ -2222,33 +2230,33 @@ static void * ggml_backend_cpu_buffer_get_base(ggml_backend_buffer_t buffer) {+@@ -2282,33 +2290,33 @@ static void * ggml_backend_cpu_buffer_get_base(ggml_backend_buffer_t buffer) {return (void *)data;}@@ -91,7 +91,7 @@ diff --git a/ggml/src/ggml-backend.cpp b/ggml/src/ggml-backend.cppGGML_ASSERT(src);if (ggml_backend_buffer_is_host(src->buffer)) {memcpy(dst->data, src->data, ggml_nbytes(src));-@@ -2259,7 +2267,7 @@ static bool ggml_backend_cpu_buffer_cpy_tensor(ggml_backend_buffer_t buffer, con+@@ -2319,7 +2327,7 @@ static bool ggml_backend_cpu_buffer_cpy_tensor(ggml_backend_buffer_t buffer, conGGML_UNUSED(buffer);}@@ -100,7 +100,7 @@ diff --git a/ggml/src/ggml-backend.cpp b/ggml/src/ggml-backend.cppGGML_ASSERT(buffer);memset(buffer->context, value, buffer->size);}-@@ -2276,6 +2284,7 @@ static const struct ggml_backend_buffer_i ggml_backend_cpu_buffer_i = {+@@ -2336,6 +2344,7 @@ static const struct ggml_backend_buffer_i ggml_backend_cpu_buffer_i = {/* .cpy_tensor = */ ggml_backend_cpu_buffer_cpy_tensor,/* .clear = */ ggml_backend_cpu_buffer_clear,/* .reset = */ NULL,@@ -108,7 +108,7 @@ diff --git a/ggml/src/ggml-backend.cpp b/ggml/src/ggml-backend.cpp};static const struct ggml_backend_buffer_i ggml_backend_cpu_buffer_from_ptr_i = {-@@ -2290,19 +2299,20 @@ static const struct ggml_backend_buffer_i ggml_backend_cpu_buffer_from_ptr_i = {+@@ -2350,19 +2359,20 @@ static const struct ggml_backend_buffer_i ggml_backend_cpu_buffer_from_ptr_i = {/* .cpy_tensor = */ ggml_backend_cpu_buffer_cpy_tensor,/* .clear = */ ggml_backend_cpu_buffer_clear,/* .reset = */ NULL,@@ -131,7 +131,7 @@ diff --git a/ggml/src/ggml-backend.cpp b/ggml/src/ggml-backend.cppvoid * data = ggml_aligned_malloc(size);if (data == NULL) {-@@ -2313,13 +2323,13 @@ static ggml_backend_buffer_t ggml_backend_cpu_buffer_type_alloc_buffer(ggml_back+@@ -2373,13 +2383,13 @@ static ggml_backend_buffer_t ggml_backend_cpu_buffer_type_alloc_buffer(ggml_backreturn ggml_backend_buffer_init(buft, ggml_backend_cpu_buffer_i, data, size);}@@ -147,7 +147,7 @@ diff --git a/ggml/src/ggml-backend.cpp b/ggml/src/ggml-backend.cppreturn true;GGML_UNUSED(buft);-@@ -2342,7 +2352,7 @@ ggml_backend_buffer_type_t ggml_backend_cpu_buffer_type(void) {+@@ -2402,7 +2412,7 @@ ggml_backend_buffer_type_t ggml_backend_cpu_buffer_type(void) {return &ggml_backend_cpu_buffer_type;}diff --git a/llama.cpp.patches/patches/ggml_src_ggml-cpu_ggml-cpu.c.patch b/llama.cpp.patches/patches/ggml_src_ggml-cpu_ggml-cpu.c.patchindex 21ed99f9..370aedc3 100644--- a/llama.cpp.patches/patches/ggml_src_ggml-cpu_ggml-cpu.c.patch+++ b/llama.cpp.patches/patches/ggml_src_ggml-cpu_ggml-cpu.c.patch@@ -53,7 +53,7 @@ diff --git a/ggml/src/ggml-cpu/ggml-cpu.c b/ggml/src/ggml-cpu/ggml-cpu.cint chunk_size = 16;if (nr0 == 1 || nr1 == 1) {chunk_size = 64;-@@ -2871,6 +2909,19 @@ struct ggml_cplan ggml_graph_plan(+@@ -2876,6 +2914,19 @@ struct ggml_cplan ggml_graph_plan(cur += n_as*ids->ne[0]*ids->ne[1]*sizeof(struct mmid_row_mapping) + sizeof(int64_t);// atomic_current_chunkcur += CACHE_LINE_SIZE*n_as + CACHE_LINE_SIZE;diff --git a/llama.cpp.patches/patches/ggml_src_ggml-cpu_ggml-cpu.cpp.patch b/llama.cpp.patches/patches/ggml_src_ggml-cpu_ggml-cpu.cpp.patchindex c413711e..4993e680 100644--- a/llama.cpp.patches/patches/ggml_src_ggml-cpu_ggml-cpu.cpp.patch+++ b/llama.cpp.patches/patches/ggml_src_ggml-cpu_ggml-cpu.cpp.patch@@ -119,7 +119,7 @@ diff --git a/ggml/src/ggml-cpu/ggml-cpu.cpp b/ggml/src/ggml-cpu/ggml-cpu.cppprops->name = ggml_backend_cpu_device_get_name(dev);props->description = ggml_backend_cpu_device_get_description(dev);props->type = ggml_backend_cpu_device_get_type(dev);-@@ -400,27 +400,27 @@ static void ggml_backend_cpu_device_get_props(ggml_backend_dev_t dev, struct ggm+@@ -401,27 +401,27 @@ static void ggml_backend_cpu_device_get_props(ggml_backend_dev_t dev, struct ggm};}@@ -151,7 +151,7 @@ diff --git a/ggml/src/ggml-cpu/ggml-cpu.cpp b/ggml/src/ggml-cpu/ggml-cpu.cppconst struct ggml_tensor * src0 = op->src[0];const struct ggml_tensor * src1 = op->src[1];-@@ -474,7 +474,7 @@ static bool ggml_backend_cpu_device_supports_op(ggml_backend_dev_t dev, const st+@@ -479,7 +479,7 @@ static bool ggml_backend_cpu_device_supports_op(ggml_backend_dev_t dev, const st}}@@ -160,7 +160,7 @@ diff --git a/ggml/src/ggml-cpu/ggml-cpu.cpp b/ggml/src/ggml-cpu/ggml-cpu.cppreturn ggml_backend_buft_is_host(buft) || ggml_backend_cpu_is_extra_buffer_type(buft);GGML_UNUSED(dev);}-@@ -499,19 +499,19 @@ static const struct ggml_backend_device_i ggml_backend_cpu_device_i = {+@@ -504,19 +504,19 @@ static const struct ggml_backend_device_i ggml_backend_cpu_device_i = {// CPU backend - backend (reg)@@ -183,7 +183,7 @@ diff --git a/ggml/src/ggml-cpu/ggml-cpu.cpp b/ggml/src/ggml-cpu/ggml-cpu.cppGGML_ASSERT(index == 0);static ggml_backend_cpu_device_context ctx;-@@ -526,7 +526,7 @@ static ggml_backend_dev_t ggml_backend_cpu_reg_get_device(ggml_backend_reg_t reg+@@ -531,7 +531,7 @@ static ggml_backend_dev_t ggml_backend_cpu_reg_get_device(ggml_backend_reg_t reg// This is intended to replace the the ggml_cpu_has_* functions when loading the CPU backend dynamically,// and additionally to allow other backends to expose their own list of features that applications can query using the same API@@ -192,7 +192,7 @@ diff --git a/ggml/src/ggml-cpu/ggml-cpu.cpp b/ggml/src/ggml-cpu/ggml-cpu.cppstatic std::vector<ggml_backend_feature> features = []() {ggml_cpu_init();-@@ -643,7 +643,7 @@ static ggml_backend_feature * ggml_backend_cpu_get_features(ggml_backend_reg_t r+@@ -648,7 +648,7 @@ static ggml_backend_feature * ggml_backend_cpu_get_features(ggml_backend_reg_t rGGML_UNUSED(reg);}diff --git a/llama.cpp.patches/patches/ggml_src_ggml-cpu_ops.cpp.patch b/llama.cpp.patches/patches/ggml_src_ggml-cpu_ops.cpp.patchindex 4bb02060..2d5db121 100644--- a/llama.cpp.patches/patches/ggml_src_ggml-cpu_ops.cpp.patch+++ b/llama.cpp.patches/patches/ggml_src_ggml-cpu_ops.cpp.patch@@ -200,10 +200,10 @@ diff --git a/ggml/src/ggml-cpu/ops.cpp b/ggml/src/ggml-cpu/ops.cpp+ // [jart] llamafile #975: route through optimized AVX-512+ // dequant when available; fall back to upstream's helper.+ if (!llamafile_fa_fp16_to_fp32_row((const ggml_fp16_t *)v_data, V32 + tk * DV, DV)) {-+ ggml_fp16_to_fp32_row((const ggml_fp16_t *)v_data, V32 + tk * DV, DV);++ ggml_cpu_fp16_to_fp32((const ggml_fp16_t *)v_data, V32 + tk * DV, DV);+ }+#else- ggml_fp16_to_fp32_row((const ggml_fp16_t *)v_data, V32 + tk * DV, DV);+ ggml_cpu_fp16_to_fp32((const ggml_fp16_t *)v_data, V32 + tk * DV, DV);+#endif} else {memcpy(V32 + tk * DV, v_data, DV * sizeof(float));diff --git a/llama.cpp.patches/patches/ggml_src_ggml-cuda_convert.cu.patch b/llama.cpp.patches/patches/ggml_src_ggml-cuda_convert.cu.patchindex 6c50add6..c945f000 100644--- a/llama.cpp.patches/patches/ggml_src_ggml-cuda_convert.cu.patch+++ b/llama.cpp.patches/patches/ggml_src_ggml-cuda_convert.cu.patch@@ -1,7 +1,7 @@diff --git a/ggml/src/ggml-cuda/convert.cu b/ggml/src/ggml-cuda/convert.cu--- a/llama.cpp/ggml/src/ggml-cuda/convert.cu+++ b/llama.cpp/ggml/src/ggml-cuda/convert.cu-@@ -479,6 +479,7 @@ to_bf16_cuda_t ggml_get_to_bf16_cuda(ggml_type type) {+@@ -481,6 +481,7 @@ to_bf16_cuda_t ggml_get_to_bf16_cuda(ggml_type type) {return dequantize_row_q5_K_cuda;case GGML_TYPE_Q6_K:return dequantize_row_q6_K_cuda;@@ -9,7 +9,7 @@ diff --git a/ggml/src/ggml-cuda/convert.cu b/ggml/src/ggml-cuda/convert.cucase GGML_TYPE_IQ2_XXS:return dequantize_row_iq2_xxs_cuda;case GGML_TYPE_IQ2_XS:-@@ -497,6 +498,7 @@ to_bf16_cuda_t ggml_get_to_bf16_cuda(ggml_type type) {+@@ -499,6 +500,7 @@ to_bf16_cuda_t ggml_get_to_bf16_cuda(ggml_type type) {return dequantize_row_iq4_xs_cuda;case GGML_TYPE_IQ3_S:return dequantize_row_iq3_s_cuda;@@ -17,7 +17,7 @@ diff --git a/ggml/src/ggml-cuda/convert.cu b/ggml/src/ggml-cuda/convert.cucase GGML_TYPE_MXFP4:return dequantize_row_mxfp4_cuda;case GGML_TYPE_NVFP4:-@@ -537,6 +539,7 @@ to_fp16_cuda_t ggml_get_to_fp16_cuda(ggml_type type) {+@@ -541,6 +543,7 @@ to_fp16_cuda_t ggml_get_to_fp16_cuda(ggml_type type) {return dequantize_row_q5_K_cuda;case GGML_TYPE_Q6_K:return dequantize_row_q6_K_cuda;@@ -25,7 +25,7 @@ diff --git a/ggml/src/ggml-cuda/convert.cu b/ggml/src/ggml-cuda/convert.cucase GGML_TYPE_IQ2_XXS:return dequantize_row_iq2_xxs_cuda;case GGML_TYPE_IQ2_XS:-@@ -555,6 +558,7 @@ to_fp16_cuda_t ggml_get_to_fp16_cuda(ggml_type type) {+@@ -559,6 +562,7 @@ to_fp16_cuda_t ggml_get_to_fp16_cuda(ggml_type type) {return dequantize_row_iq4_xs_cuda;case GGML_TYPE_IQ3_S:return dequantize_row_iq3_s_cuda;diff --git a/llama.cpp.patches/patches/ggml_src_ggml-cuda_cpy.cu.patch b/llama.cpp.patches/patches/ggml_src_ggml-cuda_cpy.cu.patchindex 34840be0..01dd1f39 100644--- a/llama.cpp.patches/patches/ggml_src_ggml-cuda_cpy.cu.patch+++ b/llama.cpp.patches/patches/ggml_src_ggml-cuda_cpy.cu.patch@@ -10,7 +10,7 @@ diff --git a/ggml/src/ggml-cuda/cpy.cu b/ggml/src/ggml-cuda/cpy.cuconst char * cx, char * cdst, const int64_t ne,const int64_t ne00, const int64_t ne01, const int64_t ne02, const int64_t nb00, const int64_t nb01, const int64_t nb02,@@ -385,6 +386,7 @@ static void ggml_cpy_f32_iq4_nl_cuda(- cpy_f32_q<cpy_blck_f32_iq4_nl, QK4_NL><<<num_blocks, 1, 0, stream>>>+ cpy_f32_q<cpy_blck_f32_iq4_nl, QK4_NL><<<num_blocks, CUDA_CPY_BLOCK_SIZE, 0, stream>>>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13);}+#endif // GGML_CUDA_NO_IQ_QUANTSdiff --git a/llama.cpp.patches/patches/ggml_src_ggml-cuda_ggml-cuda.cu.patch b/llama.cpp.patches/patches/ggml_src_ggml-cuda_ggml-cuda.cu.patchindex 36a9f9be..acef87f6 100644--- a/llama.cpp.patches/patches/ggml_src_ggml-cuda_ggml-cuda.cu.patch+++ b/llama.cpp.patches/patches/ggml_src_ggml-cuda_ggml-cuda.cu.patch@@ -206,7 +206,7 @@ diff --git a/ggml/src/ggml-cuda/ggml-cuda.cu b/ggml/src/ggml-cuda/ggml-cuda.cuswitch (compute_type) {case GGML_TYPE_F32:ggml_cuda_mul_mat_cublas_impl<GGML_TYPE_F32>(ctx, src0, src1, dst);-@@ -2367,20 +2392,20 @@ static bool ggml_cuda_compute_forward(ggml_backend_cuda_context & ctx, struct gg+@@ -2412,20 +2437,20 @@ static bool ggml_cuda_compute_forward(ggml_backend_cuda_context & ctx, struct gg// backend@@ -230,7 +230,7 @@ diff --git a/ggml/src/ggml-cuda/ggml-cuda.cu b/ggml/src/ggml-cuda/ggml-cuda.cuggml_backend_cuda_context * cuda_ctx = (ggml_backend_cuda_context *) backend->context;ggml_backend_buffer_t buf = tensor->view_src ? tensor->view_src->buffer : tensor->buffer;-@@ -2389,7 +2414,7 @@ static void ggml_backend_cuda_set_tensor_async(ggml_backend_t backend, ggml_tens+@@ -2434,7 +2459,7 @@ static void ggml_backend_cuda_set_tensor_async(ggml_backend_t backend, ggml_tensCUDA_CHECK(cudaMemcpyAsync((char *) tensor->data + offset, data, size, cudaMemcpyHostToDevice, cuda_ctx->stream()));}@@ -239,7 +239,7 @@ diff --git a/ggml/src/ggml-cuda/ggml-cuda.cu b/ggml/src/ggml-cuda/ggml-cuda.cuggml_backend_cuda_context * cuda_ctx = (ggml_backend_cuda_context *) backend->context;ggml_backend_buffer_t buf = tensor->view_src ? tensor->view_src->buffer : tensor->buffer;-@@ -2398,7 +2423,7 @@ static void ggml_backend_cuda_get_tensor_async(ggml_backend_t backend, const ggm+@@ -2443,7 +2468,7 @@ static void ggml_backend_cuda_get_tensor_async(ggml_backend_t backend, const ggmCUDA_CHECK(cudaMemcpyAsync(data, (const char *) tensor->data + offset, size, cudaMemcpyDeviceToHost, cuda_ctx->stream()));}@@ -248,7 +248,7 @@ diff --git a/ggml/src/ggml-cuda/ggml-cuda.cu b/ggml/src/ggml-cuda/ggml-cuda.cusize_t offset, size_t size, size_t n_copies, size_t stride_tensor, size_t stride_data) {ggml_backend_cuda_context * cuda_ctx = (ggml_backend_cuda_context *) backend->context;ggml_backend_buffer_t buf = tensor->view_src ? tensor->view_src->buffer : tensor->buffer;-@@ -2409,7 +2434,7 @@ static void ggml_backend_cuda_set_tensor_2d_async(ggml_backend_t backend, struct+@@ -2454,7 +2479,7 @@ static void ggml_backend_cuda_set_tensor_2d_async(ggml_backend_t backend, struct(char *) tensor->data + offset, stride_tensor, data, stride_data, size, n_copies, cudaMemcpyHostToDevice, cuda_ctx->stream()));}@@ -257,7 +257,7 @@ diff --git a/ggml/src/ggml-cuda/ggml-cuda.cu b/ggml/src/ggml-cuda/ggml-cuda.cusize_t offset, size_t size, size_t n_copies, size_t stride_tensor, size_t stride_data) {ggml_backend_cuda_context * cuda_ctx = (ggml_backend_cuda_context *) backend->context;ggml_backend_buffer_t buf = tensor->view_src ? tensor->view_src->buffer : tensor->buffer;-@@ -2420,7 +2445,7 @@ static void ggml_backend_cuda_get_tensor_2d_async(ggml_backend_t backend, const+@@ -2465,7 +2490,7 @@ static void ggml_backend_cuda_get_tensor_2d_async(ggml_backend_t backend, constdata, stride_data, (const char *) tensor->data + offset, stride_tensor, size, n_copies, cudaMemcpyDeviceToHost, cuda_ctx->stream()));}@@ -266,7 +266,7 @@ diff --git a/ggml/src/ggml-cuda/ggml-cuda.cu b/ggml/src/ggml-cuda/ggml-cuda.cuggml_backend_buffer_t buf_src = src->view_src ? src->view_src->buffer : src->buffer;ggml_backend_buffer_t buf_dst = dst->view_src ? dst->view_src->buffer : dst->buffer;-@@ -2479,7 +2504,7 @@ static bool ggml_backend_cuda_cpy_tensor_async(ggml_backend_t backend_src, ggml_+@@ -2524,7 +2549,7 @@ static bool ggml_backend_cuda_cpy_tensor_async(ggml_backend_t backend_src, ggml_return true;}@@ -275,7 +275,7 @@ diff --git a/ggml/src/ggml-cuda/ggml-cuda.cu b/ggml/src/ggml-cuda/ggml-cuda.cuggml_backend_cuda_context * cuda_ctx = (ggml_backend_cuda_context *)backend->context;CUDA_CHECK(cudaStreamSynchronize(cuda_ctx->stream()));-@@ -4097,7 +4122,7 @@ static bool ggml_cuda_graph_set_enabled(ggml_backend_cuda_context * cuda_ctx, co+@@ -4231,7 +4256,7 @@ static bool ggml_cuda_graph_set_enabled(ggml_backend_cuda_context * cuda_ctx, co}#endif // USE_CUDA_GRAPH@@ -284,7 +284,7 @@ diff --git a/ggml/src/ggml-cuda/ggml-cuda.cu b/ggml/src/ggml-cuda/ggml-cuda.cuggml_backend_cuda_context * cuda_ctx = (ggml_backend_cuda_context *) backend->context;ggml_cuda_set_device(cuda_ctx->device);-@@ -4156,13 +4181,13 @@ static enum ggml_status ggml_backend_cuda_graph_compute(ggml_backend_t backend,+@@ -4290,13 +4315,13 @@ static enum ggml_status ggml_backend_cuda_graph_compute(ggml_backend_t backend,return GGML_STATUS_SUCCESS;}@@ -300,7 +300,7 @@ diff --git a/ggml/src/ggml-cuda/ggml-cuda.cu b/ggml/src/ggml-cuda/ggml-cuda.cuggml_backend_cuda_context * cuda_ctx = (ggml_backend_cuda_context *)backend->context;if (ggml_backend_is_cuda(backend)) {-@@ -4181,7 +4206,7 @@ static void ggml_backend_cuda_event_wait(ggml_backend_t backend, ggml_backend_ev+@@ -4315,7 +4340,7 @@ static void ggml_backend_cuda_event_wait(ggml_backend_t backend, ggml_backend_ev}}@@ -309,7 +309,7 @@ diff --git a/ggml/src/ggml-cuda/ggml-cuda.cu b/ggml/src/ggml-cuda/ggml-cuda.cuggml_backend_cuda_context * cuda_ctx = (ggml_backend_cuda_context *) backend->context;#ifdef USE_CUDA_GRAPH-@@ -4491,7 +4516,7 @@ void ggml_backend_cuda_get_device_memory(int device, size_t * free, size_t * tot+@@ -4625,7 +4650,7 @@ void ggml_backend_cuda_get_device_memory(int device, size_t * free, size_t * tot*total /= share_count;}@@ -318,7 +318,7 @@ diff --git a/ggml/src/ggml-cuda/ggml-cuda.cu b/ggml/src/ggml-cuda/ggml-cuda.cuif (getenv("GGML_CUDA_REGISTER_HOST") == nullptr) {return false;}-@@ -4514,7 +4539,7 @@ bool ggml_backend_cuda_register_host_buffer(void * buffer, size_t size) {+@@ -4648,7 +4673,7 @@ bool ggml_backend_cuda_register_host_buffer(void * buffer, size_t size) {#endif // CUDART_VERSION >= 11010 || defined(GGML_USE_MUSA)}@@ -327,7 +327,7 @@ diff --git a/ggml/src/ggml-cuda/ggml-cuda.cu b/ggml/src/ggml-cuda/ggml-cuda.cuif (getenv("GGML_CUDA_REGISTER_HOST") == nullptr) {return;}-@@ -4537,12 +4562,12 @@ struct ggml_backend_cuda_device_context {+@@ -4671,12 +4696,12 @@ struct ggml_backend_cuda_device_context {int op_offload_min_batch_size;};@@ -342,7 +342,7 @@ diff --git a/ggml/src/ggml-cuda/ggml-cuda.cu b/ggml/src/ggml-cuda/ggml-cuda.cuggml_backend_cuda_device_context * ctx = (ggml_backend_cuda_device_context *)dev->context;return ctx->description.c_str();}-@@ -4623,7 +4648,7 @@ static bool ggml_backend_cuda_get_available_uma_memory(long * available_memory_k+@@ -4757,7 +4782,7 @@ static bool ggml_backend_cuda_get_available_uma_memory(long * available_memory_k}#endif // defined(__linux__)@@ -351,7 +351,7 @@ diff --git a/ggml/src/ggml-cuda/ggml-cuda.cu b/ggml/src/ggml-cuda/ggml-cuda.cuggml_backend_cuda_device_context * ctx = (ggml_backend_cuda_device_context *)dev->context;ggml_cuda_set_device(ctx->device);cudaError_t err = cudaMemGetInfo(free, total);-@@ -4664,7 +4689,7 @@ static void ggml_backend_cuda_device_get_memory(ggml_backend_dev_t dev, size_t *+@@ -4798,7 +4823,7 @@ static void ggml_backend_cuda_device_get_memory(ggml_backend_dev_t dev, size_t **total /= share_count;}@@ -360,7 +360,7 @@ diff --git a/ggml/src/ggml-cuda/ggml-cuda.cu b/ggml/src/ggml-cuda/ggml-cuda.cuggml_backend_cuda_device_context * ctx = (ggml_backend_cuda_device_context *) dev->context;cudaDeviceProp prop;-@@ -4675,7 +4700,7 @@ static enum ggml_backend_dev_type ggml_backend_cuda_device_get_type(ggml_backend+@@ -4809,7 +4834,7 @@ static enum ggml_backend_dev_type ggml_backend_cuda_device_get_type(ggml_backend: GGML_BACKEND_DEVICE_TYPE_GPU;}@@ -369,7 +369,7 @@ diff --git a/ggml/src/ggml-cuda/ggml-cuda.cu b/ggml/src/ggml-cuda/ggml-cuda.cuggml_backend_cuda_device_context * ctx = (ggml_backend_cuda_device_context *)dev->context;props->name = ggml_backend_cuda_device_get_name(dev);-@@ -4699,24 +4724,24 @@ static void ggml_backend_cuda_device_get_props(ggml_backend_dev_t dev, ggml_back+@@ -4834,24 +4859,24 @@ static void ggml_backend_cuda_device_get_props(ggml_backend_dev_t dev, ggml_back};}@@ -398,7 +398,7 @@ diff --git a/ggml/src/ggml-cuda/ggml-cuda.cu b/ggml/src/ggml-cuda/ggml-cuda.cuggml_backend_cuda_device_context * dev_ctx = (ggml_backend_cuda_device_context *) dev->context;// check if all the sources are allocated on this device-@@ -4815,6 +4840,13 @@ static bool ggml_backend_cuda_device_supports_op(ggml_backend_dev_t dev, const g+@@ -4951,6 +4976,13 @@ static bool ggml_backend_cuda_device_supports_op(ggml_backend_dev_t dev, const gcase GGML_TYPE_Q5_K:case GGML_TYPE_Q6_K:case GGML_TYPE_Q8_K:@@ -412,7 +412,7 @@ diff --git a/ggml/src/ggml-cuda/ggml-cuda.cu b/ggml/src/ggml-cuda/ggml-cuda.cucase GGML_TYPE_IQ1_M:case GGML_TYPE_IQ1_S:case GGML_TYPE_IQ2_S:-@@ -4824,6 +4856,7 @@ static bool ggml_backend_cuda_device_supports_op(ggml_backend_dev_t dev, const g+@@ -4960,6 +4992,7 @@ static bool ggml_backend_cuda_device_supports_op(ggml_backend_dev_t dev, const gcase GGML_TYPE_IQ3_XXS:case GGML_TYPE_IQ4_NL:case GGML_TYPE_IQ4_XS:@@ -420,7 +420,7 @@ diff --git a/ggml/src/ggml-cuda/ggml-cuda.cu b/ggml/src/ggml-cuda/ggml-cuda.cucase GGML_TYPE_BF16:return true;default:-@@ -4932,9 +4965,14 @@ static bool ggml_backend_cuda_device_supports_op(ggml_backend_dev_t dev, const g+@@ -5069,9 +5102,14 @@ static bool ggml_backend_cuda_device_supports_op(ggml_backend_dev_t dev, const gif (src0_type == GGML_TYPE_Q5_1 && src1_type == GGML_TYPE_F32) {return true;}@@ -435,7 +435,7 @@ diff --git a/ggml/src/ggml-cuda/ggml-cuda.cu b/ggml/src/ggml-cuda/ggml-cuda.cuif (src0_type == GGML_TYPE_F32 && src1_type == GGML_TYPE_I32) {return true;}-@@ -5160,7 +5198,7 @@ static bool ggml_backend_cuda_device_supports_op(ggml_backend_dev_t dev, const g+@@ -5303,7 +5341,7 @@ static bool ggml_backend_cuda_device_supports_op(ggml_backend_dev_t dev, const g}}@@ -444,7 +444,7 @@ diff --git a/ggml/src/ggml-cuda/ggml-cuda.cu b/ggml/src/ggml-cuda/ggml-cuda.cuggml_backend_cuda_device_context * dev_ctx = (ggml_backend_cuda_device_context *) dev->context;const bool integrated = ggml_cuda_info().devices[dev_ctx->device].integrated;return (ggml_backend_buft_is_cuda(buft) && buft->device == dev) || (integrated && ggml_backend_buft_is_cuda_host(buft));-@@ -5181,13 +5219,13 @@ static int64_t get_op_batch_size(const ggml_tensor * op) {+@@ -5324,13 +5362,13 @@ static int64_t get_op_batch_size(const ggml_tensor * op) {}}@@ -458,9 +458,9 @@ diff --git a/ggml/src/ggml-cuda/ggml-cuda.cu b/ggml/src/ggml-cuda/ggml-cuda.cu-static ggml_backend_event_t ggml_backend_cuda_device_event_new(ggml_backend_dev_t dev) {+static ggml_backend_event_t GGML_CALL ggml_backend_cuda_device_event_new(ggml_backend_dev_t dev) {#ifdef GGML_CUDA_NO_PEER_COPY+ GGML_UNUSED(dev);return nullptr;- #else-@@ -5205,14 +5243,14 @@ static ggml_backend_event_t ggml_backend_cuda_device_event_new(ggml_backend_dev_+@@ -5349,14 +5387,14 @@ static ggml_backend_event_t ggml_backend_cuda_device_event_new(ggml_backend_dev_#endif}@@ -477,7 +477,7 @@ diff --git a/ggml/src/ggml-cuda/ggml-cuda.cu b/ggml/src/ggml-cuda/ggml-cuda.cuGGML_UNUSED(dev);CUDA_CHECK(cudaEventSynchronize((cudaEvent_t)event->context));}-@@ -5241,23 +5279,23 @@ struct ggml_backend_cuda_reg_context {+@@ -5385,23 +5423,23 @@ struct ggml_backend_cuda_reg_context {std::vector<ggml_backend_dev_t> devices;};@@ -505,7 +505,7 @@ diff --git a/ggml/src/ggml-cuda/ggml-cuda.cu b/ggml/src/ggml-cuda/ggml-cuda.custatic std::vector<ggml_backend_feature> features = []() {std::vector<ggml_backend_feature> features;#define _STRINGIFY(...) #__VA_ARGS__-@@ -5314,7 +5352,7 @@ static ggml_backend_feature * ggml_backend_cuda_get_features(ggml_backend_reg_t+@@ -5458,7 +5496,7 @@ static ggml_backend_feature * ggml_backend_cuda_get_features(ggml_backend_reg_tGGML_UNUSED(reg);}diff --git a/llama.cpp.patches/patches/ggml_src_ggml-cuda_mmq.cu.patch b/llama.cpp.patches/patches/ggml_src_ggml-cuda_mmq.cu.patchindex 5743045a..baab0e7b 100644--- a/llama.cpp.patches/patches/ggml_src_ggml-cuda_mmq.cu.patch+++ b/llama.cpp.patches/patches/ggml_src_ggml-cuda_mmq.cu.patch@@ -1,39 +1,39 @@diff --git a/ggml/src/ggml-cuda/mmq.cu b/ggml/src/ggml-cuda/mmq.cu--- a/llama.cpp/ggml/src/ggml-cuda/mmq.cu+++ b/llama.cpp/ggml/src/ggml-cuda/mmq.cu-@@ -46,6 +46,7 @@ static void ggml_cuda_mul_mat_q_switch_type(ggml_backend_cuda_context & ctx, con- case GGML_TYPE_Q6_K:+@@ -45,6 +45,7 @@ static void ggml_cuda_mul_mat_q_switch_type(ggml_backend_cuda_context & ctx, conmul_mat_q_case<GGML_TYPE_Q6_K>(ctx, args, stream);break;+ // -----------------------------------------------------------------------+#ifndef GGML_CUDA_NO_IQ_QUANTS- case GGML_TYPE_IQ2_XXS:- mul_mat_q_case<GGML_TYPE_IQ2_XXS>(ctx, args, stream);+ case GGML_TYPE_IQ1_S:+ mul_mat_q_case<GGML_TYPE_IQ1_S>(ctx, args, stream);break;-@@ -70,6 +71,7 @@ static void ggml_cuda_mul_mat_q_switch_type(ggml_backend_cuda_context & ctx, con+@@ -69,6 +70,7 @@ static void ggml_cuda_mul_mat_q_switch_type(ggml_backend_cuda_context & ctx, concase GGML_TYPE_IQ4_NL:mul_mat_q_case<GGML_TYPE_IQ4_NL>(ctx, args, stream);break;+#endif // GGML_CUDA_NO_IQ_QUANTS- default:- GGML_ABORT("fatal error");- break;-@@ -271,6 +273,7 @@ bool ggml_cuda_should_use_mmq(enum ggml_type type, int cc, int64_t ne11, int64_t- case GGML_TYPE_Q4_K:+ // -----------------------------------------------------------------------+ case GGML_TYPE_MXFP4:+ mul_mat_q_case<GGML_TYPE_MXFP4>(ctx, args, stream);+@@ -278,6 +280,7 @@ bool ggml_cuda_should_use_mmq(enum ggml_type type, int cc, int64_t ne11, int64_tcase GGML_TYPE_Q5_K:case GGML_TYPE_Q6_K:+ // -------------------------------------------------+#ifndef GGML_CUDA_NO_IQ_QUANTS+ case GGML_TYPE_IQ1_S:case GGML_TYPE_IQ2_XXS:case GGML_TYPE_IQ2_XS:- case GGML_TYPE_IQ2_S:-@@ -279,6 +282,7 @@ bool ggml_cuda_should_use_mmq(enum ggml_type type, int cc, int64_t ne11, int64_t- case GGML_TYPE_IQ1_S:+@@ -286,6 +289,7 @@ bool ggml_cuda_should_use_mmq(enum ggml_type type, int cc, int64_t ne11, int64_t+ case GGML_TYPE_IQ3_S:case GGML_TYPE_IQ4_XS:case GGML_TYPE_IQ4_NL:+#endif // GGML_CUDA_NO_IQ_QUANTS- mmq_supported = true;- break;- default:-@@ -341,9 +345,11 @@ bool ggml_cuda_should_use_mmq(enum ggml_type type, int cc, int64_t ne11, int64_t+ // -------------------------------------------------+ case GGML_TYPE_MXFP4:+ case GGML_TYPE_NVFP4:+@@ -360,9 +364,11 @@ bool ggml_cuda_should_use_mmq(enum ggml_type type, int cc, int64_t ne11, int64_treturn ne11 <= 128;case GGML_TYPE_Q6_K:return ne11 <= (GGML_CUDA_CC_IS_RDNA3_0(cc) ? 128 : 256);diff --git a/llama.cpp.patches/patches/ggml_src_ggml-cuda_mmq.cuh.patch b/llama.cpp.patches/patches/ggml_src_ggml-cuda_mmq.cuh.patchindex 995c52dc..9bda9b59 100644--- a/llama.cpp.patches/patches/ggml_src_ggml-cuda_mmq.cuh.patch+++ b/llama.cpp.patches/patches/ggml_src_ggml-cuda_mmq.cuh.patch@@ -1,19 +1,19 @@diff --git a/ggml/src/ggml-cuda/mmq.cuh b/ggml/src/ggml-cuda/mmq.cuh--- a/llama.cpp/ggml/src/ggml-cuda/mmq.cuh+++ b/llama.cpp/ggml/src/ggml-cuda/mmq.cuh-@@ -1549,6 +1549,7 @@ extern DECL_MMQ_CASE(GGML_TYPE_Q3_K);- extern DECL_MMQ_CASE(GGML_TYPE_Q4_K);+@@ -1577,6 +1577,7 @@ extern DECL_MMQ_CASE(GGML_TYPE_Q4_K);extern DECL_MMQ_CASE(GGML_TYPE_Q5_K);extern DECL_MMQ_CASE(GGML_TYPE_Q6_K);+ // -----------------------------------------+#ifndef GGML_CUDA_NO_IQ_QUANTS+ extern DECL_MMQ_CASE(GGML_TYPE_IQ1_S);extern DECL_MMQ_CASE(GGML_TYPE_IQ2_XXS);extern DECL_MMQ_CASE(GGML_TYPE_IQ2_XS);- extern DECL_MMQ_CASE(GGML_TYPE_IQ2_S);-@@ -1557,6 +1558,7 @@ extern DECL_MMQ_CASE(GGML_TYPE_IQ3_S);- extern DECL_MMQ_CASE(GGML_TYPE_IQ1_S);+@@ -1585,6 +1586,7 @@ extern DECL_MMQ_CASE(GGML_TYPE_IQ3_XXS);+ extern DECL_MMQ_CASE(GGML_TYPE_IQ3_S);extern DECL_MMQ_CASE(GGML_TYPE_IQ4_NL);extern DECL_MMQ_CASE(GGML_TYPE_IQ4_XS);+#endif // GGML_CUDA_NO_IQ_QUANTS-- // --------------------------------------------------------------------------------------------------------------------------+ // -----------------------------------------+ extern DECL_MMQ_CASE(GGML_TYPE_MXFP4);+ extern DECL_MMQ_CASE(GGML_TYPE_NVFP4);diff --git a/llama.cpp.patches/patches/ggml_src_ggml-cuda_mmvq.cu.patch b/llama.cpp.patches/patches/ggml_src_ggml-cuda_mmvq.cu.patchindex 4c3fe11e..a7dbc1c7 100644--- a/llama.cpp.patches/patches/ggml_src_ggml-cuda_mmvq.cu.patch+++ b/llama.cpp.patches/patches/ggml_src_ggml-cuda_mmvq.cu.patch@@ -1,7 +1,7 @@diff --git a/ggml/src/ggml-cuda/mmvq.cu b/ggml/src/ggml-cuda/mmvq.cu--- a/llama.cpp/ggml/src/ggml-cuda/mmvq.cu+++ b/llama.cpp/ggml/src/ggml-cuda/mmvq.cu-@@ -22,6 +22,7 @@ static constexpr __device__ vec_dot_q_cuda_t get_vec_dot_q_cuda(ggml_type type)+@@ -23,6 +23,7 @@ static constexpr __device__ vec_dot_q_cuda_t get_vec_dot_q_cuda(ggml_type type)case GGML_TYPE_Q4_K: return vec_dot_q4_K_q8_1;case GGML_TYPE_Q5_K: return vec_dot_q5_K_q8_1;case GGML_TYPE_Q6_K: return vec_dot_q6_K_q8_1;@@ -9,7 +9,7 @@ diff --git a/ggml/src/ggml-cuda/mmvq.cu b/ggml/src/ggml-cuda/mmvq.cucase GGML_TYPE_IQ2_XXS: return vec_dot_iq2_xxs_q8_1;case GGML_TYPE_IQ2_XS: return vec_dot_iq2_xs_q8_1;case GGML_TYPE_IQ2_S: return vec_dot_iq2_s_q8_1;-@@ -31,6 +32,7 @@ static constexpr __device__ vec_dot_q_cuda_t get_vec_dot_q_cuda(ggml_type type)+@@ -32,6 +33,7 @@ static constexpr __device__ vec_dot_q_cuda_t get_vec_dot_q_cuda(ggml_type type)case GGML_TYPE_IQ4_NL: return vec_dot_iq4_nl_q8_1;case GGML_TYPE_IQ4_XS: return vec_dot_iq4_xs_q8_1;case GGML_TYPE_IQ3_S: return vec_dot_iq3_s_q8_1;@@ -17,7 +17,7 @@ diff --git a/ggml/src/ggml-cuda/mmvq.cu b/ggml/src/ggml-cuda/mmvq.cudefault: return nullptr;}}-@@ -50,6 +52,7 @@ static constexpr __host__ __device__ int get_vdr_mmvq(ggml_type type) {+@@ -52,6 +54,7 @@ static constexpr __host__ __device__ int get_vdr_mmvq(ggml_type type) {case GGML_TYPE_Q4_K: return VDR_Q4_K_Q8_1_MMVQ;case GGML_TYPE_Q5_K: return VDR_Q5_K_Q8_1_MMVQ;case GGML_TYPE_Q6_K: return VDR_Q6_K_Q8_1_MMVQ;@@ -25,7 +25,7 @@ diff --git a/ggml/src/ggml-cuda/mmvq.cu b/ggml/src/ggml-cuda/mmvq.cucase GGML_TYPE_IQ2_XXS: return VDR_IQ2_XXS_Q8_1_MMVQ;case GGML_TYPE_IQ2_XS: return VDR_IQ2_XS_Q8_1_MMVQ;case GGML_TYPE_IQ2_S: return VDR_IQ2_S_Q8_1_MMVQ;-@@ -57,6 +60,7 @@ static constexpr __host__ __device__ int get_vdr_mmvq(ggml_type type) {+@@ -59,6 +62,7 @@ static constexpr __host__ __device__ int get_vdr_mmvq(ggml_type type) {case GGML_TYPE_IQ3_S: return VDR_IQ3_S_Q8_1_MMVQ;case GGML_TYPE_IQ4_NL: return VDR_IQ4_NL_Q8_1_MMVQ;case GGML_TYPE_IQ4_XS: return VDR_IQ4_XS_Q8_1_MMVQ;diff --git a/llama.cpp.patches/patches/ggml_src_ggml-metal_ggml-metal.cpp.patch b/llama.cpp.patches/patches/ggml_src_ggml-metal_ggml-metal.cpp.patchindex 2d44eee0..0473ca6b 100644--- a/llama.cpp.patches/patches/ggml_src_ggml-metal_ggml-metal.cpp.patch+++ b/llama.cpp.patches/patches/ggml_src_ggml-metal_ggml-metal.cpp.patch@@ -393,7 +393,7 @@ diff --git a/ggml/src/ggml-metal/ggml-metal.cpp b/ggml/src/ggml-metal/ggml-metalprops->name = ggml_backend_metal_device_get_name(dev);props->description = ggml_backend_metal_device_get_description(dev);props->type = ggml_backend_metal_device_get_type(dev);-@@ -684,7 +694,7 @@ static void ggml_backend_metal_device_get_props(ggml_backend_dev_t dev, ggml_bac+@@ -685,7 +695,7 @@ static void ggml_backend_metal_device_get_props(ggml_backend_dev_t dev, ggml_bac};}@@ -402,7 +402,7 @@ diff --git a/ggml/src/ggml-metal/ggml-metal.cpp b/ggml/src/ggml-metal/ggml-metalggml_metal_device_t ctx_dev = (ggml_metal_device_t)dev->context;ggml_metal_t ctx = ggml_metal_init(ctx_dev);-@@ -709,7 +719,7 @@ static ggml_backend_t ggml_backend_metal_device_init_backend(ggml_backend_dev_t+@@ -710,7 +720,7 @@ static ggml_backend_t ggml_backend_metal_device_init_backend(ggml_backend_dev_tGGML_UNUSED(params);}@@ -411,7 +411,7 @@ diff --git a/ggml/src/ggml-metal/ggml-metal.cpp b/ggml/src/ggml-metal/ggml-metalggml_metal_device_t ctx_dev = (ggml_metal_device_t)dev->context;const ggml_metal_device_props * props_dev = ggml_metal_device_get_props(ctx_dev);-@@ -717,7 +727,7 @@ static ggml_backend_buffer_type_t ggml_backend_metal_device_get_buffer_type(ggml+@@ -718,7 +728,7 @@ static ggml_backend_buffer_type_t ggml_backend_metal_device_get_buffer_type(ggmlreturn props_dev->use_shared_buffers ? ggml_backend_metal_buffer_type_shared(props_dev->device) : ggml_backend_metal_buffer_type_private(props_dev->device);}@@ -420,7 +420,7 @@ diff --git a/ggml/src/ggml-metal/ggml-metal.cpp b/ggml/src/ggml-metal/ggml-metalggml_metal_device_t ctx_dev = (ggml_metal_device_t)dev->context;ggml_metal_buffer_t res = ggml_metal_buffer_map(ctx_dev, ptr, size, max_tensor_size);-@@ -727,13 +737,13 @@ static ggml_backend_buffer_t ggml_backend_metal_device_buffer_mapped(ggml_backen+@@ -728,13 +738,13 @@ static ggml_backend_buffer_t ggml_backend_metal_device_buffer_mapped(ggml_backenreturn ggml_backend_buffer_init(ggml_backend_metal_buffer_type_mapped(props_dev->device), ggml_backend_metal_buffer_shared_i, res, size);}@@ -436,7 +436,7 @@ diff --git a/ggml/src/ggml-metal/ggml-metal.cpp b/ggml/src/ggml-metal/ggml-metalreturnbuft->device == dev && (buft->iface.get_name == ggml_backend_metal_buffer_type_shared_get_name ||-@@ -754,7 +764,7 @@ static int64_t get_op_batch_size(const ggml_tensor * op) {+@@ -755,7 +765,7 @@ static int64_t get_op_batch_size(const ggml_tensor * op) {}}@@ -445,7 +445,7 @@ diff --git a/ggml/src/ggml-metal/ggml-metal.cpp b/ggml/src/ggml-metal/ggml-metalggml_metal_device_t ctx_dev = (ggml_metal_device_t)dev->context;return (op->op == GGML_OP_MUL_MAT ||-@@ -762,7 +772,7 @@ static bool ggml_backend_metal_device_offload_op(ggml_backend_dev_t dev, const g+@@ -763,7 +773,7 @@ static bool ggml_backend_metal_device_offload_op(ggml_backend_dev_t dev, const gget_op_batch_size(op) >= ggml_metal_device_get_props(ctx_dev)->op_offload_min_batch_size;}@@ -454,7 +454,7 @@ diff --git a/ggml/src/ggml-metal/ggml-metal.cpp b/ggml/src/ggml-metal/ggml-metalggml_metal_device_t ctx_dev = (ggml_metal_device_t)dev->context;ggml_metal_event_t event = ggml_metal_device_event_init(ctx_dev);-@@ -776,7 +786,7 @@ static ggml_backend_event_t ggml_backend_metal_device_event_new(ggml_backend_dev+@@ -777,7 +787,7 @@ static ggml_backend_event_t ggml_backend_metal_device_event_new(ggml_backend_devreturn ev;}@@ -463,7 +463,7 @@ diff --git a/ggml/src/ggml-metal/ggml-metal.cpp b/ggml/src/ggml-metal/ggml-metalggml_metal_device_t ctx_dev = (ggml_metal_device_t)dev->context;ggml_metal_event_t ev = (ggml_metal_event_t)event->context;-@@ -786,7 +796,7 @@ static void ggml_backend_metal_device_event_free(ggml_backend_dev_t dev, ggml_ba+@@ -787,7 +797,7 @@ static void ggml_backend_metal_device_event_free(ggml_backend_dev_t dev, ggml_badelete event;}@@ -472,7 +472,7 @@ diff --git a/ggml/src/ggml-metal/ggml-metal.cpp b/ggml/src/ggml-metal/ggml-metalggml_metal_device_t ctx_dev = (ggml_metal_device_t)dev->context;ggml_metal_event_t evt = (ggml_metal_event_t)event->context;-@@ -838,18 +848,18 @@ struct ggml_backend_metal_reg_deleter {+@@ -839,18 +849,18 @@ struct ggml_backend_metal_reg_deleter {typedef std::unique_ptr<struct ggml_backend_metal_reg, ggml_backend_metal_reg_deleter> ggml_backend_metal_reg_ptr;@@ -494,7 +494,7 @@ diff --git a/ggml/src/ggml-metal/ggml-metal.cpp b/ggml/src/ggml-metal/ggml-metalggml_backend_metal_reg_t ctx = (ggml_backend_metal_reg_t)reg->context;GGML_ASSERT(index < ctx->devices.size());return ctx->devices[index];-@@ -862,13 +872,13 @@ static ggml_backend_feature g_ggml_backend_metal_features[] = {+@@ -863,13 +873,13 @@ static ggml_backend_feature g_ggml_backend_metal_features[] = {{ NULL, NULL },};diff --git a/llama.cpp.patches/patches/ggml_src_ggml-vulkan_ggml-vulkan.cpp.patch b/llama.cpp.patches/patches/ggml_src_ggml-vulkan_ggml-vulkan.cpp.patchindex fa7ad94d..05a75537 100644--- a/llama.cpp.patches/patches/ggml_src_ggml-vulkan_ggml-vulkan.cpp.patch+++ b/llama.cpp.patches/patches/ggml_src_ggml-vulkan_ggml-vulkan.cpp.patch@@ -1,7 +1,7 @@diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vulkan.cpp--- a/llama.cpp/ggml/src/ggml-vulkan/ggml-vulkan.cpp+++ b/llama.cpp/ggml/src/ggml-vulkan/ggml-vulkan.cpp-@@ -340,11 +340,11 @@ struct vk_queue {+@@ -367,11 +367,11 @@ struct vk_queue {bool transfer_only;};@@ -18,7 +18,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vustatic ggml_backend_buffer_type_i ggml_backend_vk_buffer_type_interface = {/* .get_name = */ ggml_backend_vk_buffer_type_name,/* .alloc_buffer = */ ggml_backend_vk_buffer_type_alloc_buffer,-@@ -2374,7 +2374,7 @@ static void ggml_vk_check_results_1(ggml_backend_vk_context * ctx, ggml_cgraph *+@@ -2576,7 +2576,7 @@ static void ggml_vk_check_results_1(ggml_backend_vk_context * ctx, ggml_cgraph *typedef void (*ggml_vk_func_t)(ggml_backend_vk_context * ctx, vk_context& subctx, const ggml_tensor * src0, const ggml_tensor * src1, ggml_tensor * dst);@@ -27,7 +27,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vustatic VkDeviceSize ggml_vk_get_max_buffer_range(const ggml_backend_vk_context * ctx, const vk_buffer &buf, const VkDeviceSize offset) {const VkDeviceSize range = std::min(VkDeviceSize{buf->size - offset},-@@ -15477,20 +15477,28 @@ static bool ggml_backend_buffer_is_vk(ggml_backend_buffer_t buffer) {+@@ -15864,20 +15864,28 @@ static bool ggml_backend_buffer_is_vk(ggml_backend_buffer_t buffer) {return buffer->buft->iface.get_name == ggml_backend_vk_buffer_type_name;}@@ -59,7 +59,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vuVK_LOG_DEBUG("ggml_backend_vk_buffer_init_tensor(" << buffer << " (" << buffer->context << "), " << tensor << ")");if (tensor->view_src != nullptr) {GGML_ASSERT(tensor->view_src->buffer->buft == buffer->buft);-@@ -15498,7 +15506,7 @@ static enum ggml_status ggml_backend_vk_buffer_init_tensor(ggml_backend_buffer_t+@@ -15885,7 +15893,7 @@ static enum ggml_status ggml_backend_vk_buffer_init_tensor(ggml_backend_buffer_treturn GGML_STATUS_SUCCESS;}@@ -68,7 +68,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vuVK_LOG_DEBUG("ggml_backend_vk_buffer_memset_tensor(" << buffer << ", " << tensor << ", " << value << ", " << offset << ", " << size << ")");ggml_backend_vk_buffer_context * buf_ctx = (ggml_backend_vk_buffer_context *)buffer->context;vk_buffer buf = buf_ctx->dev_buffer;-@@ -15511,7 +15519,7 @@ static void ggml_backend_vk_buffer_memset_tensor(ggml_backend_buffer_t buffer, g+@@ -15898,7 +15906,7 @@ static void ggml_backend_vk_buffer_memset_tensor(ggml_backend_buffer_t buffer, gggml_vk_buffer_memset(buf, vk_tensor_offset(tensor) + tensor->view_offs + offset, val32, size);}@@ -77,7 +77,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vuVK_LOG_DEBUG("ggml_backend_vk_buffer_set_tensor(" << buffer << ", " << tensor << ", " << data << ", " << offset << ", " << size << ")");ggml_backend_vk_buffer_context * buf_ctx = (ggml_backend_vk_buffer_context *)buffer->context;vk_buffer buf = buf_ctx->dev_buffer;-@@ -15523,7 +15531,7 @@ static void ggml_backend_vk_buffer_set_tensor(ggml_backend_buffer_t buffer, ggml+@@ -15910,7 +15918,7 @@ static void ggml_backend_vk_buffer_set_tensor(ggml_backend_buffer_t buffer, ggmlggml_vk_buffer_write(buf, vk_tensor_offset(tensor) + tensor->view_offs + offset, data, size);}@@ -86,7 +86,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vusize_t size, size_t n_copies, size_t stride_tensor, size_t stride_data) {VK_LOG_DEBUG("ggml_backend_vk_buffer_set_tensor_2d(" << buffer << ", " << tensor << ", " << data << ", " << offset << ", " << size << ", " <<n_copies << ", " << stride_tensor << ", " << stride_data << ")");-@@ -15537,7 +15545,7 @@ static void ggml_backend_vk_buffer_set_tensor_2d(ggml_backend_buffer_t buffer, g+@@ -15924,7 +15932,7 @@ static void ggml_backend_vk_buffer_set_tensor_2d(ggml_backend_buffer_t buffer, gggml_vk_buffer_write_2d(buf, vk_tensor_offset(tensor) + tensor->view_offs + offset, data, stride_data, stride_tensor, size, n_copies);}@@ -95,7 +95,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vuVK_LOG_DEBUG("ggml_backend_vk_buffer_get_tensor(" << buffer << ", " << tensor << ", " << data << ", " << offset << ", " << size << ")");ggml_backend_vk_buffer_context * buf_ctx = (ggml_backend_vk_buffer_context *)buffer->context;-@@ -15550,7 +15558,7 @@ static void ggml_backend_vk_buffer_get_tensor(ggml_backend_buffer_t buffer, cons+@@ -15937,7 +15945,7 @@ static void ggml_backend_vk_buffer_get_tensor(ggml_backend_buffer_t buffer, consggml_vk_buffer_read(buf, vk_tensor_offset(tensor) + tensor->view_offs + offset, data, size);}@@ -104,7 +104,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vusize_t size, size_t n_copies, size_t stride_tensor, size_t stride_data) {VK_LOG_DEBUG("ggml_backend_vk_buffer_get_tensor_2d(" << buffer << ", " << tensor << ", " << data << ", " << offset << ", " << size << ", " <<n_copies << ", " << stride_tensor << ", " << stride_data << ")");-@@ -15565,7 +15573,7 @@ static void ggml_backend_vk_buffer_get_tensor_2d(ggml_backend_buffer_t buffer, c+@@ -15952,7 +15960,7 @@ static void ggml_backend_vk_buffer_get_tensor_2d(ggml_backend_buffer_t buffer, cggml_vk_buffer_read_2d(buf, vk_tensor_offset(tensor) + tensor->view_offs + offset, data, stride_tensor, stride_data, size, n_copies);}@@ -113,7 +113,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vuif (ggml_nbytes(src) == 0) {return true;}-@@ -15586,7 +15594,7 @@ static bool ggml_backend_vk_buffer_cpy_tensor(ggml_backend_buffer_t buffer, cons+@@ -15973,7 +15981,7 @@ static bool ggml_backend_vk_buffer_cpy_tensor(ggml_backend_buffer_t buffer, consUNUSED(buffer);}@@ -122,7 +122,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vuggml_backend_vk_buffer_context * ctx = (ggml_backend_vk_buffer_context *)buffer->context;ggml_vk_buffer_memset(ctx->dev_buffer, 0, value, buffer->size);-@@ -15604,16 +15612,17 @@ static ggml_backend_buffer_i ggml_backend_vk_buffer_interface = {+@@ -15991,16 +15999,17 @@ static ggml_backend_buffer_i ggml_backend_vk_buffer_interface = {/* .cpy_tensor = */ ggml_backend_vk_buffer_cpy_tensor,/* .clear = */ ggml_backend_vk_buffer_clear,/* .reset = */ NULL,@@ -142,7 +142,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vuVK_LOG_MEMORY("ggml_backend_vk_buffer_type_alloc_buffer(" << size << ")");ggml_backend_vk_buffer_type_context * ctx = (ggml_backend_vk_buffer_type_context *) buft->context;-@@ -15629,17 +15638,17 @@ static ggml_backend_buffer_t ggml_backend_vk_buffer_type_alloc_buffer(ggml_backe+@@ -16016,17 +16025,17 @@ static ggml_backend_buffer_t ggml_backend_vk_buffer_type_alloc_buffer(ggml_backereturn ggml_backend_buffer_init(buft, ggml_backend_vk_buffer_interface, bufctx, size);}@@ -163,7 +163,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vureturn ggml_nbytes(tensor);UNUSED(buft);-@@ -15657,18 +15666,18 @@ ggml_backend_buffer_type_t ggml_backend_vk_buffer_type(size_t dev_num) {+@@ -16044,18 +16053,18 @@ ggml_backend_buffer_type_t ggml_backend_vk_buffer_type(size_t dev_num) {// host buffer type@@ -185,7 +185,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vuVK_LOG_MEMORY("ggml_backend_vk_host_buffer_type_alloc_buffer(" << size << ")");size += 32; // Behave like the CPU buffer type-@@ -15684,19 +15693,20 @@ static ggml_backend_buffer_t ggml_backend_vk_host_buffer_type_alloc_buffer(ggml_+@@ -16071,19 +16080,20 @@ static ggml_backend_buffer_t ggml_backend_vk_host_buffer_type_alloc_buffer(ggml_ggml_backend_buffer_t buffer = ggml_backend_cpu_buffer_from_ptr(ptr, size);buffer->buft = buft;buffer->iface.free_buffer = ggml_backend_vk_host_buffer_free_buffer;@@ -208,7 +208,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vureturn vk_instance.devices[0]->suballocation_block_size;UNUSED(buft);-@@ -15728,13 +15738,13 @@ ggml_backend_buffer_type_t ggml_backend_vk_host_buffer_type() {+@@ -16115,13 +16125,13 @@ ggml_backend_buffer_type_t ggml_backend_vk_host_buffer_type() {// backend@@ -224,7 +224,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vuggml_backend_vk_context * ctx = (ggml_backend_vk_context *)backend->context;VK_LOG_DEBUG("ggml_backend_vk_free(" << ctx->name << ")");-@@ -15750,7 +15760,7 @@ static ggml_backend_buffer_type_t ggml_backend_vk_get_default_buffer_type(ggml_b+@@ -16137,7 +16147,7 @@ static ggml_backend_buffer_type_t ggml_backend_vk_get_default_buffer_type(ggml_breturn &ctx->device->buffer_type;}@@ -233,7 +233,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vusize_t size, size_t n_copies, size_t stride_tensor, size_t stride_data) {VK_LOG_DEBUG("ggml_backend_vk_set_tensor_2d_async(" << size << ", " << n_copies << ")");ggml_backend_vk_context * ctx = (ggml_backend_vk_context *)backend->context;-@@ -15808,12 +15818,12 @@ static void ggml_backend_vk_set_tensor_2d_async(ggml_backend_t backend, ggml_ten+@@ -16195,12 +16205,12 @@ static void ggml_backend_vk_set_tensor_2d_async(ggml_backend_t backend, ggml_ten}}@@ -248,7 +248,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vusize_t size, size_t n_copies, size_t stride_tensor, size_t stride_data) {VK_LOG_DEBUG("ggml_backend_vk_get_tensor_2d_async(" << size << ", " << n_copies << ")");ggml_backend_vk_context * ctx = (ggml_backend_vk_context *)backend->context;-@@ -15864,12 +15874,12 @@ static void ggml_backend_vk_get_tensor_2d_async(ggml_backend_t backend, const gg+@@ -16251,12 +16261,12 @@ static void ggml_backend_vk_get_tensor_2d_async(ggml_backend_t backend, const gg}}@@ -263,7 +263,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vuVK_LOG_DEBUG("ggml_backend_vk_cpy_tensor_async(" << src << " -> " << dst << ", size=" << ggml_nbytes(src) << ")");ggml_backend_vk_context * ctx = (ggml_backend_vk_context *)backend_dst->context;-@@ -15986,7 +15996,7 @@ static void ggml_vk_synchronize(ggml_backend_vk_context * ctx) {+@@ -16383,7 +16393,7 @@ static void ggml_vk_synchronize(ggml_backend_vk_context * ctx) {}}@@ -272,7 +272,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vuVK_LOG_DEBUG("ggml_backend_vk_synchronize()");ggml_backend_vk_context * ctx = (ggml_backend_vk_context *)backend->context;-@@ -16522,7 +16532,7 @@ static int32_t find_first_set(uint32_t x) {+@@ -16935,7 +16945,7 @@ static int32_t find_first_set(uint32_t x) {return ret;}@@ -281,7 +281,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vuVK_LOG_DEBUG("ggml_backend_vk_graph_compute(" << cgraph->n_nodes << " nodes)");ggml_backend_vk_context * ctx = (ggml_backend_vk_context *)backend->context;-@@ -16938,7 +16948,7 @@ static ggml_status ggml_backend_vk_graph_compute(ggml_backend_t backend, ggml_cg+@@ -17400,7 +17410,7 @@ static ggml_status ggml_backend_vk_graph_compute(ggml_backend_t backend, ggml_cg}// Sort the graph for improved parallelism.@@ -290,7 +290,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vu{VK_LOG_DEBUG("ggml_vk_graph_optimize(" << graph->n_nodes << " nodes)");ggml_backend_vk_context * ctx = (ggml_backend_vk_context *)backend->context;-@@ -17195,7 +17205,7 @@ static void ggml_vk_graph_optimize(ggml_backend_t backend, struct ggml_cgraph *+@@ -17661,7 +17671,7 @@ static void ggml_vk_graph_optimize(ggml_backend_t backend, struct ggml_cgraph *}}@@ -299,7 +299,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vuVK_LOG_DEBUG("ggml_backend_vk_event_record(backend=" << backend << ", event=" << event << ")");ggml_backend_vk_context * ctx = (ggml_backend_vk_context *)backend->context;vk_event *vkev = (vk_event *)event->context;-@@ -17233,7 +17243,7 @@ static void ggml_backend_vk_event_record(ggml_backend_t backend, ggml_backend_ev+@@ -17699,7 +17709,7 @@ static void ggml_backend_vk_event_record(ggml_backend_t backend, ggml_backend_evctx->compute_ctx.reset();}@@ -308,7 +308,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vuVK_LOG_DEBUG("ggml_backend_vk_event_wait(backend=" << backend << ", event=" << event << ")");ggml_backend_vk_context * ctx = (ggml_backend_vk_context *)backend->context;vk_event *vkev = (vk_event *)event->context;-@@ -17335,7 +17345,10 @@ void ggml_backend_vk_get_device_memory(int device, size_t * free, size_t * total+@@ -17801,7 +17811,10 @@ void ggml_backend_vk_get_device_memory(int device, size_t * free, size_t * total*total += heap.size;if (membudget_supported && i < budgetprops.heapUsage.size()) {@@ -320,7 +320,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vu} else {*free += heap.size;}-@@ -17403,38 +17416,38 @@ struct ggml_backend_vk_device_context {+@@ -17869,38 +17882,38 @@ struct ggml_backend_vk_device_context {int op_offload_min_batch_size;};@@ -366,7 +366,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vuggml_backend_vk_device_context * ctx = (ggml_backend_vk_device_context *)dev->context;props->name = ggml_backend_vk_device_get_name(dev);-@@ -17450,13 +17463,13 @@ static void ggml_backend_vk_device_get_props(ggml_backend_dev_t dev, struct ggml+@@ -17917,13 +17930,13 @@ static void ggml_backend_vk_device_get_props(ggml_backend_dev_t dev, struct ggml};}@@ -382,7 +382,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vuggml_backend_vk_device_context * ctx = (ggml_backend_vk_device_context *)dev->context;const vk_device& device = ggml_vk_get_device(ctx->device);-@@ -18029,7 +18042,7 @@ static bool ggml_backend_vk_device_supports_op(ggml_backend_dev_t dev, const ggm+@@ -18504,7 +18517,7 @@ static bool ggml_backend_vk_device_supports_op(ggml_backend_dev_t dev, const ggmUNUSED(dev);}@@ -391,7 +391,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vuif (buft->iface.get_name != ggml_backend_vk_buffer_type_name) {return false;}-@@ -18055,13 +18068,13 @@ static int64_t ggml_vk_get_op_batch_size(const ggml_tensor * op) {+@@ -18530,13 +18543,13 @@ static int64_t ggml_vk_get_op_batch_size(const ggml_tensor * op) {}}@@ -407,7 +407,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vuggml_backend_vk_device_context * ctx = (ggml_backend_vk_device_context *)dev->context;auto device = ggml_vk_get_device(ctx->device);-@@ -18084,7 +18097,7 @@ static ggml_backend_event_t ggml_backend_vk_device_event_new(ggml_backend_dev_t+@@ -18559,7 +18572,7 @@ static ggml_backend_event_t ggml_backend_vk_device_event_new(ggml_backend_dev_t};}@@ -416,7 +416,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vuggml_backend_vk_device_context * ctx = (ggml_backend_vk_device_context *)dev->context;auto device = ggml_vk_get_device(ctx->device);-@@ -18104,7 +18117,7 @@ static void ggml_backend_vk_device_event_free(ggml_backend_dev_t dev, ggml_backe+@@ -18579,7 +18592,7 @@ static void ggml_backend_vk_device_event_free(ggml_backend_dev_t dev, ggml_backedelete event;}@@ -425,7 +425,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vuVK_LOG_DEBUG("ggml_backend_vk_device_event_synchronize(backend=" << dev << ", event=" << event << ")");ggml_backend_vk_device_context * ctx = (ggml_backend_vk_device_context *)dev->context;auto device = ggml_vk_get_device(ctx->device);-@@ -18161,7 +18174,7 @@ static vk_buffer ggml_vk_buffer_from_host_ptr(vk_device & device, void * ptr, si+@@ -18636,7 +18649,7 @@ static vk_buffer ggml_vk_buffer_from_host_ptr(vk_device & device, void * ptr, sireturn buf;}@@ -434,7 +434,7 @@ diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vuVK_LOG_DEBUG("ggml_backend_vk_device_buffer_from_host_ptr(backend=" << dev << ", ptr=" << ptr << ", size=" << size << ")");GGML_UNUSED(max_tensor_size);-@@ -18199,17 +18212,17 @@ static const struct ggml_backend_device_i ggml_backend_vk_device_i = {+@@ -18674,17 +18687,17 @@ static const struct ggml_backend_device_i ggml_backend_vk_device_i = {/* .event_synchronize = */ ggml_backend_vk_device_event_synchronize,};diff --git a/llama.cpp.patches/patches/ggml_src_gguf.cpp.patch b/llama.cpp.patches/patches/ggml_src_gguf.cpp.patchindex 9c528b2b..1707e908 100644--- a/llama.cpp.patches/patches/ggml_src_gguf.cpp.patch+++ b/llama.cpp.patches/patches/ggml_src_gguf.cpp.patch@@ -12,7 +12,7 @@ diff --git a/ggml/src/gguf.cpp b/ggml/src/gguf.cpp#include <cinttypes>#include <cstddef>#include <cstdint>-@@ -980,7 +984,54 @@ struct gguf_context * gguf_init_from_buffer(const void * data, size_t size, stru+@@ -989,7 +993,54 @@ struct gguf_context * gguf_init_from_buffer(const void * data, size_t size, strureturn gguf_init_from_reader(gr, params);}@@ -67,7 +67,7 @@ diff --git a/ggml/src/gguf.cpp b/ggml/src/gguf.cppFILE * file = ggml_fopen(fname, "rb");if (!file) {-@@ -991,6 +1042,7 @@ struct gguf_context * gguf_init_from_file(const char * fname, struct gguf_init_p+@@ -1000,6 +1051,7 @@ struct gguf_context * gguf_init_from_file(const char * fname, struct gguf_init_pstruct gguf_context * result = gguf_init_from_file_ptr(file, params);fclose(file);return result;diff --git a/llama.cpp.patches/patches/src_llama-context.cpp.patch b/llama.cpp.patches/patches/src_llama-context.cpp.patchindex 334e9662..d6906466 100644--- a/llama.cpp.patches/patches/src_llama-context.cpp.patch+++ b/llama.cpp.patches/patches/src_llama-context.cpp.patch@@ -1,7 +1,7 @@diff --git a/src/llama-context.cpp b/src/llama-context.cpp--- a/llama.cpp/src/llama-context.cpp+++ b/llama.cpp/src/llama-context.cpp-@@ -543,6 +543,16 @@ void llama_context::resolve_fused_ops(const llama_memory_context_i * mctx, uint3+@@ -551,6 +551,16 @@ void llama_context::resolve_fused_ops(const llama_memory_context_i * mctx, uint3}};diff --git a/llama.cpp.patches/patches/src_models_dflash.cpp.patch b/llama.cpp.patches/patches/src_models_dflash.cpp.patchindex a4bf4d44..b9d6e9ac 100644--- a/llama.cpp.patches/patches/src_models_dflash.cpp.patch+++ b/llama.cpp.patches/patches/src_models_dflash.cpp.patch@@ -1,7 +1,7 @@diff --git a/src/models/dflash.cpp b/src/models/dflash.cpp--- a/llama.cpp/src/models/dflash.cpp+++ b/llama.cpp/src/models/dflash.cpp-@@ -61,18 +61,6 @@ void llama_model_dflash::load_arch_tensors(llama_model_loader &) {+@@ -177,21 +177,6 @@ void llama_model_dflash::load_arch_tensors(llama_model_loader &) {}}@@ -11,6 +11,9 @@ diff --git a/src/models/dflash.cpp b/src/models/dflash.cpp- return std::make_unique<graph<true>>(*this, params);- case LLM_GRAPH_TYPE_DEFAULT:- case LLM_GRAPH_TYPE_DECODER:+- if (hparams.dsv4_hc_mult > 0) {+- return std::make_unique<graph_dsv4>(*this, params);+- }- return std::make_unique<graph<false>>(*this, params);- default:- GGML_ABORT("invalid graph type");@@ -20,20 +23,24 @@ diff --git a/src/models/dflash.cpp b/src/models/dflash.cpptemplate <>ggml_tensor * llama_model_dflash::graph<true>::build_inp_embd_enc() const {auto inp_target = std::make_unique<llm_graph_input_embd>(hparams.n_embd_inp_enc());-@@ -291,3 +279,18 @@ llama_model_dflash::graph<false>::graph(const llama_model & model, const llm_gra-- ggml_build_forward_expand(gf, cur);+@@ -684,3 +669,22 @@ llama_model_dflash::graph_dsv4::graph_dsv4(const llama_model & model, const llm_+ build_dspark_markov_head(*this, model, inp_tokens);+ }}+-+// Defined after the graph<true>/graph<false> constructor specializations above:-+// cosmocc's clang rejects an explicit specialization that appears after the-+// point where make_unique<graph<...>> would implicitly instantiate it.++// Defined after the graph<true>/graph<false>/graph_dsv4 constructor++// specializations above: cosmocc's clang rejects an explicit specialization++// that appears after the point where make_unique<graph<...>> would implicitly++// instantiate it.+std::unique_ptr<llm_graph_context> llama_model_dflash::build_arch_graph(const llm_graph_params & params) const {+ switch (params.gtype) {+ case LLM_GRAPH_TYPE_ENCODER:+ return std::make_unique<graph<true>>(*this, params);+ case LLM_GRAPH_TYPE_DEFAULT:+ case LLM_GRAPH_TYPE_DECODER:++ if (hparams.dsv4_hc_mult > 0) {++ return std::make_unique<graph_dsv4>(*this, params);++ }+ return std::make_unique<graph<false>>(*this, params);+ default:+ GGML_ABORT("invalid graph type");diff --git a/llama.cpp.patches/patches/src_models_eagle3.cpp.patch b/llama.cpp.patches/patches/src_models_eagle3.cpp.patchindex 1ff9ce7c..35f204e1 100644--- a/llama.cpp.patches/patches/src_models_eagle3.cpp.patch+++ b/llama.cpp.patches/patches/src_models_eagle3.cpp.patch@@ -1,7 +1,7 @@diff --git a/src/models/eagle3.cpp b/src/models/eagle3.cpp--- a/llama.cpp/src/models/eagle3.cpp+++ b/llama.cpp/src/models/eagle3.cpp-@@ -91,18 +91,6 @@ void llama_model_eagle3::load_arch_tensors(llama_model_loader &) {+@@ -100,18 +100,6 @@ void llama_model_eagle3::load_arch_tensors(llama_model_loader &) {}}@@ -20,7 +20,7 @@ diff --git a/src/models/eagle3.cpp b/src/models/eagle3.cpptemplate <>ggml_tensor * llama_model_eagle3::graph<true>::build_inp_embd_enc() const {ggml_tensor * cur = nullptr;-@@ -321,3 +309,18 @@ llama_model_eagle3::graph<false>::graph(const llama_model & model, const llm_gra+@@ -336,3 +324,18 @@ llama_model_eagle3::graph<false>::graph(const llama_model & model, const llm_graggml_build_forward_expand(gf, cur);}diff --git a/llama.cpp.patches/patches/tools_server_server-models.cpp.patch b/llama.cpp.patches/patches/tools_server_server-models.cpp.patchindex 80bfdd5a..f9ef1320 100644--- a/llama.cpp.patches/patches/tools_server_server-models.cpp.patch+++ b/llama.cpp.patches/patches/tools_server_server-models.cpp.patch@@ -9,7 +9,7 @@ diff --git a/tools/server/server-models.cpp b/tools/server/server-models.cppextern char **environ;#endif-@@ -508,13 +509,19 @@ void server_models::load_models() {+@@ -675,13 +676,19 @@ void server_models::load_models() {}// wait for all targeted models to reach UNLOADED; cv.wait handles unlock/relock@@ -31,7 +31,7 @@ diff --git a/tools/server/server-models.cpp b/tools/server/server-models.cpp// collect all threads to join in one pass while the lock is held:// - monitoring threads from just-unloaded models (to_unload)-@@ -765,9 +772,12 @@ void server_models::unload_lru() {+@@ -913,9 +920,12 @@ void server_models::unload_lru() {// wait for unload to complete{std::unique_lock<std::mutex> lk(mutex);@@ -47,7 +47,7 @@ diff --git a/tools/server/server-models.cpp b/tools/server/server-models.cpp}}}-@@ -787,7 +797,12 @@ void server_models::load(const std::string & name, const load_options & opts) {+@@ -940,7 +950,12 @@ void server_models::load(const std::string & name, const load_options & opts) {std::unique_lock<std::mutex> lk(mutex);// edge case: block until any in-progress reload has finished so we always load// against the freshest preset and a consistent mapping state@@ -61,7 +61,7 @@ diff --git a/tools/server/server-models.cpp b/tools/server/server-models.cppauto meta = opts.custom_meta.has_value() ? *opts.custom_meta : mapping[name].meta;if (meta.status != SERVER_MODEL_STATUS_UNLOADED) {-@@ -889,15 +904,34 @@ void server_models::load(const std::string & name, const load_options & opts) {+@@ -1037,15 +1052,34 @@ void server_models::load(const std::string & name, const load_options & opts) {});std::thread stopping_thread([&]() {@@ -99,7 +99,7 @@ diff --git a/tools/server/server-models.cpp b/tools/server/server-models.cpp}// child crashed or finished on its own, skip graceful shutdown sequenceif (child_proc->stopped.load(std::memory_order_acquire)) {-@@ -1164,16 +1198,22 @@ void server_models::wait(const std::string & name, std::function<bool(const serv+@@ -1310,16 +1344,22 @@ void server_models::wait(const std::string & name, std::function<bool(const serv}void server_models::wait(std::unique_lock<std::mutex> & lk, const std::string & name, std::function<bool(const server_model_meta &)> predicate) {@@ -128,9 +128,9 @@ diff --git a/tools/server/server-models.cpp b/tools/server/server-models.cpp+ }}- bool server_models::ensure_model_ready(const std::string & name) {-@@ -2103,10 +2143,10 @@ server_http_proxy::server_http_proxy(- auto pipe = std::make_shared<pipe_t<msg_t>>();+ bool server_models::ensure_model_ready(const std::string & name, const std::function<bool()> & should_stop) {+@@ -2347,10 +2387,10 @@ server_http_proxy::server_http_proxy(+ auto pipe = std::make_shared<server_pipe<msg_t>>();if (scheme == "https") {-#ifdef CPPHTTPLIB_OPENSSL_SUPPORTdiff --git a/llama.cpp.patches/patches/tools_server_server-queue.cpp.patch b/llama.cpp.patches/patches/tools_server_server-queue.cpp.patchindex e8a6e25c..236bd692 100644--- a/llama.cpp.patches/patches/tools_server_server-queue.cpp.patch+++ b/llama.cpp.patches/patches/tools_server_server-queue.cpp.patch@@ -1,17 +1,21 @@diff --git a/tools/server/server-queue.cpp b/tools/server/server-queue.cpp--- a/llama.cpp/tools/server/server-queue.cpp+++ b/llama.cpp/tools/server/server-queue.cpp-@@ -4,6 +4,9 @@- #include "log.h"+@@ -5,6 +5,13 @@#include <chrono>+ #include <thread>+#include <cerrno>+#include <system_error>+#include <csignal>++++#ifdef COSMOCC++#include "llamafile.h"++#endif#define QUE_INF(fmt, ...) LOG_INF("que %12.*s: " fmt, 12, __func__, __VA_ARGS__)#define QUE_WRN(fmt, ...) LOG_WRN("que %12.*s: " fmt, 12, __func__, __VA_ARGS__)-@@ -110,9 +113,13 @@ void server_queue::wait_until_no_sleep() {+@@ -111,9 +118,13 @@ void server_queue::wait_until_no_sleep() {condition_tasks.notify_one(); // only main thread is waiting on this}QUE_DBG("%s", "waiting until no sleep\n");@@ -28,7 +32,63 @@ diff --git a/tools/server/server-queue.cpp b/tools/server/server-queue.cpp}}-@@ -123,6 +130,21 @@ void server_queue::terminate() {+@@ -153,9 +164,13 @@ void server_queue::worker_loop() {+ std::function<void()> work;+ {+ std::unique_lock<std::mutex> lock(mutex_tasks);+- worker.cv.wait(lock, [&]{+- return worker.stop || worker.work != nullptr;+- });++ // Use wait_for() instead of wait() to work around a++ // Cosmopolitan libc bug where untimed futex waits on XNU++ // (macOS) expire after ~72 minutes, causing++ // condition_variable::wait() to throw ETIMEDOUT.++ while (!worker.stop && worker.work == nullptr) {++ worker.cv.wait_for(lock, std::chrono::seconds(30));++ }+ if (worker.stop) {+ return;+ }+@@ -192,6 +207,21 @@ void server_queue::worker_stop() {+ }++ void server_queue::yield_to_queue(std::function<void()> && work) {++#ifdef COSMOCC++ // Run inline on the calling thread whenever a GPU backend is loaded.++ // The backends are host ELFs brought in with cosmo_dlopen(), and their++ // libc reaches thread-local state through %fs. Cosmo gives its own++ // threads only cosmo TLS (fs_base == gs_base, no glibc TCB), so host libc++ // called from this worker faults: pthread_getspecific() dereferences a++ // NULL TCB self-pointer on the very first CUDA decode. The main thread++ // does have a real host TCB, and it is where decode ran until b10441++ // introduced this worker. CPU-only runs keep upstream's behaviour; the++ // cost here is that /slots and /metrics wait for the in-flight batch.++ if (llamafile_has_gpu()) {++ work();++ return;++ }++#endif+ GGML_ASSERT(worker.thread.joinable() && "yield_to_queue() requires start_loop() to be running");++ QUE_DBG("%s", "yielding to queue\n");+@@ -210,9 +240,13 @@ void server_queue::yield_to_queue(std::function<void()> && work) {++ std::unique_lock<std::mutex> lock(mutex_tasks);+ // declined tasks are moved to queue_tasks_unhandled, so a non-empty queue always has something new+- condition_tasks.wait(lock, [&]{+- return !worker.busy || (running && !queue_tasks.empty());+- });++ // Use wait_for() instead of wait() to work around a++ // Cosmopolitan libc bug where untimed futex waits on XNU++ // (macOS) expire after ~72 minutes, causing++ // condition_variable::wait() to throw ETIMEDOUT.++ while (worker.busy && !(running && !queue_tasks.empty())) {++ condition_tasks.wait_for(lock, std::chrono::seconds(30));++ }+ if (!worker.busy) {+ break;+ }+@@ -244,6 +278,21 @@ void server_queue::yield_to_queue(std::function<void()> && work) {}void server_queue::start_loop(int64_t idle_sleep_ms) {@@ -50,7 +110,7 @@ diff --git a/tools/server/server-queue.cpp b/tools/server/server-queue.cpprunning = true;time_last_task = ggml_time_ms();-@@ -181,9 +203,13 @@ void server_queue::start_loop(int64_t idle_sleep_ms) {+@@ -293,9 +342,13 @@ void server_queue::start_loop(int64_t idle_sleep_ms) {callback_sleeping_state(true);req_stop_sleeping = false;// wait until we are requested to exit sleeping state@@ -67,7 +127,7 @@ diff --git a/tools/server/server-queue.cpp b/tools/server/server-queue.cppif (!running) { // may changed during sleepbreak; // terminate}-@@ -266,13 +292,17 @@ void server_response::remove_waiting_task_ids(const std::unordered_set<int> & id+@@ -384,13 +437,17 @@ void server_response::remove_waiting_task_ids(const std::unordered_set<int> & idserver_task_result_ptr server_response::recv(const std::unordered_set<int> & id_tasks) {while (true) {std::unique_lock<std::mutex> lock(mutex_results);diff --git a/llama.cpp.patches/patches/tools_server_server-stream.cpp.patch b/llama.cpp.patches/patches/tools_server_server-stream.cpp.patchnew file mode 100644index 00000000..3ce83c9e--- /dev/null+++ b/llama.cpp.patches/patches/tools_server_server-stream.cpp.patch@@ -0,0 +1,37 @@+diff --git a/tools/server/server-stream.cpp b/tools/server/server-stream.cpp+--- a/llama.cpp/tools/server/server-stream.cpp++++ b/llama.cpp/tools/server/server-stream.cpp+@@ -7,6 +7,7 @@+ #include <memory>+ #include <utility>+ #include <shared_mutex>++#include <csignal>++ enum class stream_read_status {+ OK,+@@ -354,6 +355,25 @@ void stream_session_manager::stop_gc() {+ }++ void stream_session_manager::gc_loop() {++ // Block every signal on this thread so pthread_cond_timedwait() can't be++ // interrupted with EINTR (libcxx rethrows EINTR as std::system_error, and++ // nothing here catches it, so the process std::terminate()s). Without this,++ // Ctrl+C on `llama-server` aborts with "condition_variable timed_wait++ // failed: Interrupted system call" instead of shutting down: SIGINT lands++ // on this thread while it sits in the 60s GC wait. Keep synchronous fault++ // signals deliverable so real crashes still surface. Same treatment as the++ // log worker, the task queue and the model-stopping thread.++ sigset_t block_mask;++ sigfillset(&block_mask);++ sigdelset(&block_mask, SIGSEGV);++ sigdelset(&block_mask, SIGBUS);++ sigdelset(&block_mask, SIGILL);++ sigdelset(&block_mask, SIGFPE);++ sigdelset(&block_mask, SIGABRT);++ sigdelset(&block_mask, SIGSYS);++ sigdelset(&block_mask, SIGTRAP);++ pthread_sigmask(SIG_BLOCK, &block_mask, nullptr);+++ while (true) {+ {+ std::unique_lock<std::mutex> lock(gc_wake_mu);diff --git a/llama.cpp.patches/patches/tools_server_server.cpp.patch b/llama.cpp.patches/patches/tools_server_server.cpp.patchindex 300915fc..bdc752d9 100644--- a/llama.cpp.patches/patches/tools_server_server.cpp.patch+++ b/llama.cpp.patches/patches/tools_server_server.cpp.patch@@ -44,7 +44,7 @@ diff --git a/tools/server/server.cpp b/tools/server/server.cppvoid llama_server_terminate();void llama_server_terminate() {if (shutdown_handler) {-@@ -86,11 +106,23 @@ static server_http_context::handler_t ex_wrapper(server_http_context::handler_t+@@ -86,6 +106,14 @@ static server_http_context::handler_t ex_wrapper(server_http_context::handler_t}int llama_server(int argc, char ** argv) {@@ -58,6 +58,8 @@ diff --git a/tools/server/server.cpp b/tools/server/server.cpp+ std::function<void(std::function<void()>)> on_shutdown_available) {std::setlocale(LC_NUMERIC, "C");+ #ifndef _WIN32+@@ -96,6 +124,10 @@ int llama_server(int argc, char ** argv) {// own arguments required by this examplecommon_params params;@@ -68,7 +70,7 @@ diff --git a/tools/server/server.cpp b/tools/server/server.cppcommon_init();// start the stream session manager GC right after common init, before any HTTP route can-@@ -104,10 +136,12 @@ int llama_server(int argc, char ** argv) {+@@ -109,10 +141,12 @@ int llama_server(int argc, char ** argv) {llama_backend_init();llama_numa_init(params.numa);@@ -83,7 +85,7 @@ diff --git a/tools/server/server.cpp b/tools/server/server.cppbool is_run_by_cli = (argv == nullptr);common_models_handler models_handler;-@@ -415,6 +449,92 @@ int llama_server(common_params & params, int argc, char ** argv) {+@@ -435,6 +469,92 @@ int llama_server(common_params & params, int argc, char ** argv) {llama_backend_free();};@@ -176,7 +178,7 @@ diff --git a/tools/server/server.cpp b/tools/server/server.cpp// start the HTTP server before loading the model to be able to serve /health requestsif (!ctx_http.start()) {clean_up();-@@ -447,6 +567,13 @@ int llama_server(common_params & params, int argc, char ** argv) {+@@ -468,6 +588,13 @@ int llama_server(common_params & params, int argc, char ** argv) {// this will unblock start_loop()ctx_server.terminate();};@@ -190,7 +192,7 @@ diff --git a/tools/server/server.cpp b/tools/server/server.cpp}// register signal handler if not running by CLI-@@ -481,6 +608,11 @@ int llama_server(common_params & params, int argc, char ** argv) {+@@ -509,6 +636,11 @@ int llama_server(common_params & params, int argc, char ** argv) {// when the HTTP server stops, clean up and exitclean_up();} else {@@ -202,7 +204,7 @@ diff --git a/tools/server/server.cpp b/tools/server/server.cpp// optionally, notify router server that this instance is readystd::thread monitor_thread;if (child.is_child()) {-@@ -505,5 +637,56 @@ int llama_server(common_params & params, int argc, char ** argv) {+@@ -533,5 +665,56 @@ int llama_server(common_params & params, int argc, char ** argv) {}}diff --git a/llama.cpp.patches/patches/vendor_cpp-httplib_httplib.cpp.patch b/llama.cpp.patches/patches/vendor_cpp-httplib_httplib.cpp.patchindex d280b3d5..e00d1b68 100644--- a/llama.cpp.patches/patches/vendor_cpp-httplib_httplib.cpp.patch+++ b/llama.cpp.patches/patches/vendor_cpp-httplib_httplib.cpp.patch@@ -1,7 +1,7 @@diff --git a/vendor/cpp-httplib/httplib.cpp b/vendor/cpp-httplib/httplib.cpp--- a/llama.cpp/vendor/cpp-httplib/httplib.cpp+++ b/llama.cpp/vendor/cpp-httplib/httplib.cpp-@@ -6416,6 +6416,22 @@ void ThreadPool::cleanup_finished_threads() {+@@ -6847,6 +6847,22 @@ void ThreadPool::cleanup_finished_threads() {}void ThreadPool::worker(bool is_dynamic) {@@ -24,7 +24,7 @@ diff --git a/vendor/cpp-httplib/httplib.cpp b/vendor/cpp-httplib/httplib.cppfor (;;) {std::function<void()> fn;{-@@ -6433,7 +6449,13 @@ void ThreadPool::worker(bool is_dynamic) {+@@ -6864,7 +6880,13 @@ void ThreadPool::worker(bool is_dynamic) {break;}} else {@@ -39,7 +39,7 @@ diff --git a/vendor/cpp-httplib/httplib.cpp b/vendor/cpp-httplib/httplib.cpp}idle_thread_count_--;-@@ -12733,6 +12755,13 @@ bool enumerate_macos_keychain_certs(Callback cb) {+@@ -13151,6 +13173,13 @@ bool enumerate_macos_keychain_certs(Callback cb) {#if !defined(_WIN32) && !(defined(__APPLE__) && \defined(CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN))@@ -53,7 +53,7 @@ diff --git a/vendor/cpp-httplib/httplib.cpp b/vendor/cpp-httplib/httplib.cpp// Common CA certificate file paths on Linux/Unixconst char **system_ca_paths() {static const char *paths[] = {-@@ -12750,6 +12779,10 @@ const char **system_ca_dirs() {+@@ -13168,6 +13197,10 @@ const char **system_ca_dirs() {static const char *dirs[] = {"/etc/ssl/certs", // Debian/Ubuntu"/etc/pki/tls/certs", // RHEL/CentOS"/usr/share/ca-certificates", // Otherdiff --git a/llama.cpp.patches/patches/vendor_sheredom_subprocess.h.patch b/llama.cpp.patches/patches/vendor_sheredom_subprocess.h.patchnew file mode 100644index 00000000..f8083354--- /dev/null+++ b/llama.cpp.patches/patches/vendor_sheredom_subprocess.h.patch@@ -0,0 +1,37 @@+diff --git a/vendor/sheredom/subprocess.h b/vendor/sheredom/subprocess.h+--- a/llama.cpp/vendor/sheredom/subprocess.h++++ b/llama.cpp/vendor/sheredom/subprocess.h+@@ -562,6 +562,25 @@ int subprocess_error_from_windows_error(unsigned long error) {+ #else+ subprocess_weak int subprocess_error_from_errno(int error);+ int subprocess_error_from_errno(int error) {++#if defined(__COSMOPOLITAN__)++ /* Cosmopolitan builds one binary for every host OS, so the E* values are++ runtime symbols rather than compile-time constants and cannot be used as++ case labels ("case value is not a constant expression"). Same mapping,++ expressed as comparisons. */++ if (error == ENOENT || error == ENOTDIR) {++ return subprocess_error_not_found;++ }++ if (error == EACCES || error == EPERM) {++ return subprocess_error_permission_denied;++ }++ if (error == EMFILE || error == ENFILE || error == ENOMEM) {++ return subprocess_error_no_memory;++ }++ if (error == ENOSYS) {++ return subprocess_error_not_supported;++ }++ return subprocess_error_unknown;++#else+ switch (error) {+ case ENOENT:+ case ENOTDIR:+@@ -578,6 +597,7 @@ int subprocess_error_from_errno(int error) {+ default:+ return subprocess_error_unknown;+ }++#endif+ }+ #endif+diff --git a/llamafile/BUILD.mk b/llamafile/BUILD.mkindex d7a995f2..5a9d584b 100644--- a/llamafile/BUILD.mk+++ b/llamafile/BUILD.mk@@ -247,6 +247,7 @@ LLAMAFILE_SERVER_SUPPORT_OBJS := \o/$(MODE)/llama.cpp/tools/server/server-common.cpp.o \o/$(MODE)/llama.cpp/tools/server/server-context.cpp.o \o/$(MODE)/llama.cpp/tools/server/server-http.cpp.o \+ o/$(MODE)/llama.cpp/tools/server/server-mcp.cpp.o \o/$(MODE)/llama.cpp/tools/server/server-models.cpp.o \o/$(MODE)/llama.cpp/tools/server/server-queue.cpp.o \o/$(MODE)/llama.cpp/tools/server/server-schema.cpp.o \diff --git a/llamafile/release.sh b/llamafile/release.shindex 9805d187..18c651e3 100644--- a/llamafile/release.sh+++ b/llamafile/release.sh@@ -1,5 +1,5 @@# update LLAMAFILE_VERSION for a new release-LLAMAFILE_VERSION="0.10.4"+LLAMAFILE_VERSION="0.10.6"# this is where the precompiled GPU libraries are storedGPU_LIBS_DIR="/home/mala/gpulibs/${LLAMAFILE_VERSION}"diff --git a/llamafile/version.h b/llamafile/version.hindex be75b44e..ca3c9a6d 100644--- a/llamafile/version.h+++ b/llamafile/version.h@@ -20,7 +20,7 @@#define LLAMAFILE_MAJOR 0#define LLAMAFILE_MINOR 10-#define LLAMAFILE_PATCH 5+#define LLAMAFILE_PATCH 6#define LLAMAFILE_VERSION \(100000000 * LLAMAFILE_MAJOR + 1000000 * LLAMAFILE_MINOR + LLAMAFILE_PATCH)diff --git a/tests/run_integration_tests.sh b/tests/run_integration_tests.shindex 8ff4601f..d2cd2bd2 100755--- a/tests/run_integration_tests.sh+++ b/tests/run_integration_tests.sh@@ -7,7 +7,6 @@ TESTS=("Bonsai-1.7B.llamafile;not thinking and not multimodal""Bonsai-4B.llamafile;not thinking and not multimodal and not tool_calling" # upstream llama.cpp peg-native parser fails to convert <tool_call> output to tool_calls for this model"Bonsai-8B.llamafile;not thinking and not multimodal"- "LFM2-24B-A2B-Q5_K_M.llamafile;not thinking and not multimodal""Ministral-3-3B-Instruct-2512-BF16.llamafile;not thinking""Ministral-3-3B-Instruct-2512-Q4_K_M.llamafile;not thinking""Qwen3.5-0.8B-Q8_0.llamafile;not thinking"@@ -15,6 +14,7 @@ TESTS=("Qwen3.5-4B-Q5_K_S.llamafile;not thinking""Qwen3.5-9B-Q5_K_S.llamafile;""Qwen3.6-27B-Q4_K_M.llamafile;not cpu"+ "Qwen3.8-27B-UD-Q4_K_XL.llamafile;not cpu""gemma-4-E2B-it-Q5_K_M.llamafile;""gemma-4-E4B-it-Q5_K_M.llamafile;""gemma-4-26B-A4B-it-MXFP4_MOE.llamafile;not cpu"@@ -27,15 +27,18 @@ TESTS=("gpt-oss-20b-mxfp4.llamafile;not cpu and not multimodal and not thinking and not determinism""llava-v1.6-mistral-7b-Q4_K_M.llamafile;not thinking and not tool_calling""llava-v1.6-mistral-7b-Q8_0.llamafile;not thinking and not tool_calling"+ "Laguna-S-2.1-UD-Q2_K_XL.llamafile;not thinking and not multimodal and not cpu"+ "Muse-Glimmer-30B-UD-Q4_K_XL.llamafile;not cpu")LLAMAFILE_EXE=~/llamafile/o/llamafile/llamafileRUNNER=~/llamafile/tests/integration/run_tests.shMODELS_DIR=~/llamafiles+GGUFS_DIR=~/ggufs# Model used for the ssl serving tests (any small .gguf works; content is irrelevant).# Override via SSL_TEST_MODEL env var if you have a different one available.-SSL_TEST_MODEL="${SSL_TEST_MODEL:-${MODELS_DIR}/Qwen3.5-0.8B-Q8_0.gguf}"+SSL_TEST_MODEL="${SSL_TEST_MODEL:-${GGUFS_DIR}/Qwen3.5-0.8B-Q8_0.gguf}"for entry in "${TESTS[@]}"; domodel="${entry%%;*}"diff --git a/third_party/mbedtls/include/mbedtls/version.h b/third_party/mbedtls/include/mbedtls/version.hnew file mode 100644index 00000000..fe443966--- /dev/null+++ b/third_party/mbedtls/include/mbedtls/version.h@@ -0,0 +1,4 @@+// Maps the canonical <mbedtls/version.h> include path onto llamafile's+// vendored copy, for third-party code (e.g. cpp-httplib's Mbed TLS+// backend) that expects standard Mbed TLS include paths.+#include "third_party/mbedtls/version.h"