Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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"
Expand Down
7 changes: 0 additions & 7 deletions llama-cpp-bindings-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",

Expand All @@ -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",

Expand Down
2 changes: 1 addition & 1 deletion llama-cpp-bindings-sys/llama.cpp
Submodule llama.cpp updated 1131 files
7 changes: 3 additions & 4 deletions llama-cpp-bindings-tests/tests/multimodal_image_and_audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
38 changes: 38 additions & 0 deletions llama-cpp-bindings/src/context/kv_cache_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ pub enum KvCacheType {
TQ1_0,
TQ2_0,
MXFP4,
NVFP4,
Q1_0,
Q2_0,
}

impl From<KvCacheType> for llama_cpp_bindings_sys::ggml_type {
Expand Down Expand Up @@ -81,6 +84,9 @@ impl From<KvCacheType> 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,
}
}
}
Expand Down Expand Up @@ -120,15 +126,44 @@ impl From<llama_cpp_bindings_sys::ggml_type> 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),
}
}
}

#[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;
Expand Down Expand Up @@ -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 {
Expand Down
13 changes: 12 additions & 1 deletion llama-cpp-bindings/src/model/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Comment thread
mcharytoniuk marked this conversation as resolved.
);
}

#[test]
fn default_params_have_expected_values() {
Expand Down
1 change: 1 addition & 0 deletions llama-cpp-bindings/src/mtmd/mtmd_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
Loading