From 0798c54bfec764cf9a7d9844d70f689c08c30727 Mon Sep 17 00:00:00 2001 From: Mateusz Charytoniuk Date: Sun, 19 Jul 2026 05:38:28 +0200 Subject: [PATCH 1/6] Upgrade vendored llama.cpp to b10068 --- llama-cpp-bindings-sys/llama.cpp | 2 +- llama-cpp-bindings/src/mtmd/mtmd_context.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/llama-cpp-bindings-sys/llama.cpp b/llama-cpp-bindings-sys/llama.cpp index d73cd0767..571d0d540 160000 --- a/llama-cpp-bindings-sys/llama.cpp +++ b/llama-cpp-bindings-sys/llama.cpp @@ -1 +1 @@ -Subproject commit d73cd076740db9c111d0e58ddd4486904469e75e +Subproject commit 571d0d540df04f25298d0e159e520d9fc62ed121 diff --git a/llama-cpp-bindings/src/mtmd/mtmd_context.rs b/llama-cpp-bindings/src/mtmd/mtmd_context.rs index c552ff82b..edb0b9e50 100644 --- a/llama-cpp-bindings/src/mtmd/mtmd_context.rs +++ b/llama-cpp-bindings/src/mtmd/mtmd_context.rs @@ -178,6 +178,7 @@ impl MtmdContext { let text_cstring = CString::new(text.text)?; let input_text = llama_cpp_bindings_sys::mtmd_input_text { text: text_cstring.as_ptr(), + text_len: text_cstring.as_bytes().len(), add_special: text.add_special, parse_special: text.parse_special, }; From 56fc182757e41704007f970956c94b970c4e6a1f Mon Sep 17 00:00:00 2001 From: Mateusz Charytoniuk Date: Sun, 19 Jul 2026 05:38:28 +0200 Subject: [PATCH 2/6] Mirror all live ggml quant types in KvCacheType --- .../src/context/kv_cache_type.rs | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/llama-cpp-bindings/src/context/kv_cache_type.rs b/llama-cpp-bindings/src/context/kv_cache_type.rs index 3ffc7f117..150b5625c 100644 --- a/llama-cpp-bindings/src/context/kv_cache_type.rs +++ b/llama-cpp-bindings/src/context/kv_cache_type.rs @@ -43,6 +43,9 @@ pub enum KvCacheType { TQ1_0, TQ2_0, MXFP4, + NVFP4, + Q1_0, + Q2_0, } impl From for llama_cpp_bindings_sys::ggml_type { @@ -81,6 +84,9 @@ impl From for llama_cpp_bindings_sys::ggml_type { KvCacheType::TQ1_0 => llama_cpp_bindings_sys::GGML_TYPE_TQ1_0, KvCacheType::TQ2_0 => llama_cpp_bindings_sys::GGML_TYPE_TQ2_0, KvCacheType::MXFP4 => llama_cpp_bindings_sys::GGML_TYPE_MXFP4, + KvCacheType::NVFP4 => llama_cpp_bindings_sys::GGML_TYPE_NVFP4, + KvCacheType::Q1_0 => llama_cpp_bindings_sys::GGML_TYPE_Q1_0, + KvCacheType::Q2_0 => llama_cpp_bindings_sys::GGML_TYPE_Q2_0, } } } @@ -120,6 +126,9 @@ impl From for KvCacheType { x if x == llama_cpp_bindings_sys::GGML_TYPE_TQ1_0 => Self::TQ1_0, x if x == llama_cpp_bindings_sys::GGML_TYPE_TQ2_0 => Self::TQ2_0, x if x == llama_cpp_bindings_sys::GGML_TYPE_MXFP4 => Self::MXFP4, + x if x == llama_cpp_bindings_sys::GGML_TYPE_NVFP4 => Self::NVFP4, + x if x == llama_cpp_bindings_sys::GGML_TYPE_Q1_0 => Self::Q1_0, + x if x == llama_cpp_bindings_sys::GGML_TYPE_Q2_0 => Self::Q2_0, _ => Self::Unknown(value), } } @@ -127,8 +136,34 @@ impl From for KvCacheType { #[cfg(test)] mod tests { + use std::ffi::CStr; + use super::KvCacheType; + fn is_retired_upstream_slot(raw: llama_cpp_bindings_sys::ggml_type) -> bool { + unsafe { llama_cpp_bindings_sys::ggml_blck_size(raw) == 0 } + } + + #[test] + fn every_upstream_ggml_type_maps_to_a_known_variant() { + for raw in 0..llama_cpp_bindings_sys::GGML_TYPE_COUNT { + if is_retired_upstream_slot(raw) { + continue; + } + + let upstream_name = + unsafe { CStr::from_ptr(llama_cpp_bindings_sys::ggml_type_name(raw)) } + .to_string_lossy(); + + assert_ne!( + KvCacheType::from(raw), + KvCacheType::Unknown(raw), + "ggml type {raw} (\"{upstream_name}\") has no matching KvCacheType variant, so it \ + silently degrades to Unknown; add the variant to keep the mirror complete" + ); + } + } + #[test] fn kv_cache_type_unknown_preserves_raw_value() { let unknown_raw: llama_cpp_bindings_sys::ggml_type = 99999; @@ -176,6 +211,9 @@ mod tests { KvCacheType::TQ1_0, KvCacheType::TQ2_0, KvCacheType::MXFP4, + KvCacheType::NVFP4, + KvCacheType::Q1_0, + KvCacheType::Q2_0, ]; for variant in all_variants { From 6807547f3a98f6d198eb2a44b43239ccd1389b83 Mon Sep 17 00:00:00 2001 From: Mateusz Charytoniuk Date: Sun, 19 Jul 2026 05:38:28 +0200 Subject: [PATCH 3/6] Guard the device array against the upstream device limit --- llama-cpp-bindings/src/model/params.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/llama-cpp-bindings/src/model/params.rs b/llama-cpp-bindings/src/model/params.rs index 1506b5641..ebf864b04 100644 --- a/llama-cpp-bindings/src/model/params.rs +++ b/llama-cpp-bindings/src/model/params.rs @@ -397,7 +397,18 @@ impl Default for LlamaModelParams { mod tests { use crate::model::split_mode::LlamaSplitMode; - use super::LlamaModelParams; + use super::{LLAMA_CPP_MAX_DEVICES, LlamaModelParams}; + + #[test] + fn device_capacity_is_not_smaller_than_the_upstream_limit() { + let upstream_limit = crate::max_devices(); + assert!( + LLAMA_CPP_MAX_DEVICES >= upstream_limit, + "LLAMA_CPP_MAX_DEVICES ({LLAMA_CPP_MAX_DEVICES}) backs a fixed-size device array and is \ + clamped against llama_max_devices() ({upstream_limit}); once upstream reports more \ + devices than the array can hold, the extra devices are dropped without any error" + ); + } #[test] fn default_params_have_expected_values() { From b66ef4ac61d6fbc2a08694e48cd405e51b4306bd Mon Sep 17 00:00:00 2001 From: Mateusz Charytoniuk Date: Sun, 19 Jul 2026 05:38:28 +0200 Subject: [PATCH 4/6] Drop stale source paths from the sys crate package list --- llama-cpp-bindings-sys/Cargo.toml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/llama-cpp-bindings-sys/Cargo.toml b/llama-cpp-bindings-sys/Cargo.toml index 352130a58..7a8342938 100644 --- a/llama-cpp-bindings-sys/Cargo.toml +++ b/llama-cpp-bindings-sys/Cargo.toml @@ -37,10 +37,6 @@ include = [ "/llama.cpp/convert_hf_to_gguf.py", # Yes, it's required "/llama.cpp/common/build-info.cpp.in", - "/llama.cpp/ggml/src/ggml-cuda.cu", - "/llama.cpp/ggml/src/ggml-metal.m", - "/llama.cpp/ggml/src/ggml-metal.metal", - "/llama.cpp/include/llama.h", "/llama.cpp/include/llama-cpp.h", @@ -50,9 +46,6 @@ include = [ "/llama.cpp/ggml/src/ggml-vulkan/**/*", "/llama.cpp/ggml/src/ggml-hip/**/*", - "/llama.cpp/ggml/src/llamafile/sgemm.h", - "/llama.cpp/ggml/src/llamafile/sgemm.cpp", - "/llama.cpp/pocs", "/llama.cpp/vendor", From 6c4239915da3e2b162c30346313a71a1ac925c21 Mon Sep 17 00:00:00 2001 From: Mateusz Charytoniuk Date: Sun, 19 Jul 2026 05:38:28 +0200 Subject: [PATCH 5/6] Track gemma-4 multimodal recognition as alpaca --- .../tests/multimodal_image_and_audio.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/llama-cpp-bindings-tests/tests/multimodal_image_and_audio.rs b/llama-cpp-bindings-tests/tests/multimodal_image_and_audio.rs index f50c4b8a4..3505a96ef 100644 --- a/llama-cpp-bindings-tests/tests/multimodal_image_and_audio.rs +++ b/llama-cpp-bindings-tests/tests/multimodal_image_and_audio.rs @@ -149,10 +149,9 @@ fn image_and_audio_together(fixture: &LlamaFixture<'_>) -> Result<()> { "model should generate a description from combined image and audio input" ); assert!( - description.contains("sheep"), - "the gemma-4 vision encoder recognizes the image animals as \"sheep\" (a borderline \ - llama/sheep call the b9585 clip-encoder update tipped); the assertion tracks the \ - model's actual recognition so it still proves the image reached the output; \ + description.contains("alpaca"), + "the gemma-4 vision encoder recognizes the image animals as \"alpaca\"; the assertion \ + tracks the model's actual recognition so it still proves the image reached the output; \ got: {description:?}" ); assert!( From 6901b10bd5149c5a72f5067f15380f88ffd2ff62 Mon Sep 17 00:00:00 2001 From: Mateusz Charytoniuk Date: Sun, 19 Jul 2026 05:38:28 +0200 Subject: [PATCH 6/6] Bump workspace to 0.11.0 --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e0eaa2da9..55397f1f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1163,7 +1163,7 @@ checksum = "11d3d7f243d5c5a8b9bb5d6dd2b1602c0cb0b9db1621bafc7ed66e35ff9fe092" [[package]] name = "llama-cpp-bindings" -version = "0.10.0" +version = "0.11.0" dependencies = [ "encoding_rs", "enumflags2", @@ -1182,7 +1182,7 @@ dependencies = [ [[package]] name = "llama-cpp-bindings-build" -version = "0.10.0" +version = "0.11.0" dependencies = [ "bindgen", "cc", @@ -1195,14 +1195,14 @@ dependencies = [ [[package]] name = "llama-cpp-bindings-sys" -version = "0.10.0" +version = "0.11.0" dependencies = [ "llama-cpp-bindings-build", ] [[package]] name = "llama-cpp-bindings-tests" -version = "0.10.0" +version = "0.11.0" dependencies = [ "anyhow", "encoding_rs", @@ -1214,7 +1214,7 @@ dependencies = [ [[package]] name = "llama-cpp-bindings-types" -version = "0.10.0" +version = "0.11.0" dependencies = [ "serde", "serde_json", @@ -1223,11 +1223,11 @@ dependencies = [ [[package]] name = "llama-cpp-error-recorder" -version = "0.10.0" +version = "0.11.0" [[package]] name = "llama-cpp-gbnf" -version = "0.10.0" +version = "0.11.0" dependencies = [ "llama-cpp-bindings-sys", "thiserror", @@ -1235,11 +1235,11 @@ dependencies = [ [[package]] name = "llama-cpp-log-decoder" -version = "0.10.0" +version = "0.11.0" [[package]] name = "llama-cpp-test-harness" -version = "0.10.0" +version = "0.11.0" dependencies = [ "anyhow", "hf-hub", @@ -1252,7 +1252,7 @@ dependencies = [ [[package]] name = "llama-cpp-test-harness-macros" -version = "0.10.0" +version = "0.11.0" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index cdb7c2a47..7e3e3af30 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ members = [ [workspace.package] edition = "2024" -version = "0.10.0" +version = "0.11.0" license = "Apache-2.0" repository = "https://github.com/intentee/llama-cpp-bindings" @@ -31,15 +31,15 @@ glob = "=0.3.3" hf-hub = "=0.5.0" inventory = "=0.3.24" libtest-mimic = "=0.8.2" -llama-cpp-bindings = { path = "llama-cpp-bindings", version = "=0.10.0" } -llama-cpp-bindings-build = { path = "llama-cpp-bindings-build", version = "=0.10.0" } -llama-cpp-bindings-sys = { path = "llama-cpp-bindings-sys", version = "=0.10.0" } -llama-cpp-bindings-types = { path = "llama-cpp-bindings-types", version = "=0.10.0" } -llama-cpp-error-recorder = { path = "llama-cpp-error-recorder", version = "=0.10.0" } -llama-cpp-gbnf = { path = "llama-cpp-gbnf", version = "=0.10.0" } -llama-cpp-log-decoder = { path = "llama-cpp-log-decoder", version = "=0.10.0" } -llama-cpp-test-harness = { path = "llama-cpp-test-harness", version = "=0.10.0" } -llama-cpp-test-harness-macros = { path = "llama-cpp-test-harness-macros", version = "=0.10.0" } +llama-cpp-bindings = { path = "llama-cpp-bindings", version = "=0.11.0" } +llama-cpp-bindings-build = { path = "llama-cpp-bindings-build", version = "=0.11.0" } +llama-cpp-bindings-sys = { path = "llama-cpp-bindings-sys", version = "=0.11.0" } +llama-cpp-bindings-types = { path = "llama-cpp-bindings-types", version = "=0.11.0" } +llama-cpp-error-recorder = { path = "llama-cpp-error-recorder", version = "=0.11.0" } +llama-cpp-gbnf = { path = "llama-cpp-gbnf", version = "=0.11.0" } +llama-cpp-log-decoder = { path = "llama-cpp-log-decoder", version = "=0.11.0" } +llama-cpp-test-harness = { path = "llama-cpp-test-harness", version = "=0.11.0" } +llama-cpp-test-harness-macros = { path = "llama-cpp-test-harness-macros", version = "=0.11.0" } llguidance = "=1.7.0" log = "=0.4.29" nom = "=8.0.0"