Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
a30b731
Update llama.cpp to v0.8.0, decode through its ext batch API, and ref…
mcharytoniuk Oct 30, 2026
855a000
Render, constrain and parse chats through llama.cpp chat sessions and…
mcharytoniuk Oct 30, 2026
fd79de3
Disable the clang-tidy analyzer check that misreports valid bitmask e…
mcharytoniuk Oct 30, 2026
95e60ad
Cover chat session, FFI status mappings and recurrent memory edits wi…
mcharytoniuk Oct 30, 2026
a62e785
Release chat handles through temporary owners so cppcheck sees no unr…
mcharytoniuk Oct 30, 2026
291d790
Assert exact strings in tests, name the sampler correctly in Debug, a…
mcharytoniuk Oct 30, 2026
b47f827
Compile and lint the wrappers against llama.cpp and GSL as system hea…
mcharytoniuk Oct 30, 2026
6674acb
Measure the multimodal projector's memory, reserve it in the fit marg…
mcharytoniuk Oct 30, 2026
b56bd76
Validate token buffer sizes before allocating, refuse NUL paths befor…
mcharytoniuk Oct 30, 2026
5a221cb
Surface C++ exceptions from mtmd bitmap, chunk list and chunk copy al…
mcharytoniuk Oct 30, 2026
9de7103
Inject faults into the C++ wrappers in tests to cover every failure p…
mcharytoniuk Oct 30, 2026
a671034
Gate the bindings and fault injection crates at full coverage
mcharytoniuk Oct 30, 2026
b63502f
Pass the harness its command-line arguments so a conflicting thread c…
mcharytoniuk Oct 30, 2026
6265a35
Build the system include flags in one place and test the bindgen deri…
mcharytoniuk Oct 30, 2026
e90d76e
Gate the test harness at full coverage
mcharytoniuk Oct 30, 2026
a0b70cd
Give test-only error paths eager context instead of unexecuted closur…
mcharytoniuk Oct 30, 2026
a4d482c
Plan the native build as tested data and gate the build crate at full…
mcharytoniuk Oct 30, 2026
2368ad6
Take the single clang version directory of the NDK toolchain instead …
mcharytoniuk Oct 30, 2026
6b3298d
Encode and decode through one llama_process wrapper with a single sta…
mcharytoniuk Oct 30, 2026
7e25121
Name the vision and logging tests after what they verify, move shared…
mcharytoniuk Oct 30, 2026
18035f5
Hide superseded llama.cpp APIs from the bindings, drop the perf and r…
mcharytoniuk Oct 31, 2026
7908402
Apply samplers, log, time and query memory one way each, and name mem…
mcharytoniuk Oct 31, 2026
c5e4aee
Import every public item from its defining module and drop the re-exp…
mcharytoniuk Oct 31, 2026
ae0fac0
Add batch entries in one wrapper call, cache context limits and the v…
mcharytoniuk Oct 31, 2026
36da36e
Import inline paths at module scope and order imports as std, vendor,…
mcharytoniuk Oct 31, 2026
a976862
Check for a context's memory module in one place and import C types f…
mcharytoniuk Oct 31, 2026
82afcfe
Read token pieces through one probe, evaluate mtmd chunks fetched onc…
mcharytoniuk Oct 31, 2026
ad61507
Test that evaluating mtmd chunks reports a chunk llama.cpp does not r…
mcharytoniuk Oct 31, 2026
0412a0e
Drop the remaining crate-root re-exports and pub(crate) items, import…
mcharytoniuk Oct 31, 2026
cf6016b
Look up chat span roles by binary search over segments, release each …
mcharytoniuk Oct 31, 2026
40895a3
Name the GGUF key lookup and typed getter tests after what they verify
mcharytoniuk Oct 31, 2026
6ee6608
Return parsed tool call fragments and evaluated multimodal usage as n…
mcharytoniuk Oct 31, 2026
7ab3dea
Give every private helper type its own module so each file holds one …
mcharytoniuk Oct 31, 2026
4a0c157
Fix review findings: dynamic backend linking, empty token roles, live…
mcharytoniuk Nov 1, 2026
fd6b71f
Keep raw batch entries inside LlamaBatch and report undocumented llam…
mcharytoniuk Nov 1, 2026
597da6c
Name the metadata entry tests after what they check
mcharytoniuk Nov 1, 2026
3ac1d8b
Name every test after what it verifies, assert exact values, and acce…
mcharytoniuk Nov 1, 2026
1197b71
Make test helpers panic or return typed errors instead of untested er…
mcharytoniuk Nov 1, 2026
68380e7
Remove synchronize and detach_threadpool, which nothing in the bindin…
mcharytoniuk Nov 2, 2026
ac93e10
Classify with single peg parse flags and re-enable the enum range check
mcharytoniuk Nov 2, 2026
ada539d
Remove void_logs and let later send_logs_to_log calls replace the log…
mcharytoniuk Nov 2, 2026
b6054c6
Replace duck-typed tool calls with llama.cpp chat template overrides
mcharytoniuk Nov 2, 2026
680330f
Remove the NextN hidden-state API built on llama.cpp's staging header…
mcharytoniuk Nov 2, 2026
ff4dfdf
Drop the private header notes from the sys README
mcharytoniuk Nov 2, 2026
3432a4e
Report a token embedding without an output row as such, with its index
mcharytoniuk Nov 2, 2026
fc2b60b
Check in Rust that a model places one position per embedding before s…
mcharytoniuk Nov 2, 2026
0006581
Drop chat message statuses typed messages cannot trigger and refuse u…
mcharytoniuk Nov 2, 2026
f04c519
Decode a token llama.cpp renders as nothing into an empty piece inste…
mcharytoniuk Nov 2, 2026
29cdbd0
Refuse memory edits on sequence ids the context does not have
mcharytoniuk Nov 2, 2026
d9a0469
Map every llama.cpp and ggml enum value to its own variant and refuse…
mcharytoniuk Nov 2, 2026
d7f1fd1
Return no bytes for a placeholder media bitmap instead of slicing a n…
mcharytoniuk Nov 2, 2026
5798c94
Refuse token data array selections that name no candidate in either d…
mcharytoniuk Nov 2, 2026
cc11193
Read C++ error text and media ids losslessly, refusing text that is n…
mcharytoniuk Nov 2, 2026
3d7b1b0
Report an llguidance step that fails without stopping the parser as a…
mcharytoniuk Nov 2, 2026
1bcb062
Keep why tool call arguments are not JSON alongside their text
mcharytoniuk Nov 2, 2026
b1c2517
Drop session load capacity checks llama.cpp already enforces and the …
mcharytoniuk Nov 2, 2026
78263ca
Assert the exact grammar-constrained answers instead of any yes or no…
mcharytoniuk Nov 2, 2026
59c7f29
Decode reasoning classification tests greedily instead of with a tune…
mcharytoniuk Nov 2, 2026
f7fbef2
Assert the exact schema-constrained JSON each model produces and that…
mcharytoniuk Nov 2, 2026
aec66f9
Assert the exact multimodal transcripts and descriptions instead of s…
mcharytoniuk Nov 2, 2026
085eee0
Assert exact tokenization and parse results per model family
mcharytoniuk Nov 2, 2026
8e5437b
Enumerate the vocabulary as tokens with their pieces and test a known…
mcharytoniuk Nov 2, 2026
fc9b315
State the reasoning each generation prompt holds instead of deriving …
mcharytoniuk Nov 2, 2026
0233ed7
Compare exit codes exactly and fail emitter tests that cannot run the…
mcharytoniuk Nov 2, 2026
0848584
Switch every x86 ggml instruction set explicitly, set Metal explicitl…
mcharytoniuk Nov 2, 2026
9e7206d
Build llama.cpp with one Release profile constant instead of mapping …
mcharytoniuk Nov 2, 2026
969e517
Compile the wrappers with the C++ standard required rather than only …
mcharytoniuk Nov 2, 2026
8278ead
Use the C++ standard in the native build fixture
mcharytoniuk Nov 2, 2026
a38ea1c
Match Apple Silicon by the aarch64 target arch Rust actually reports
mcharytoniuk Nov 2, 2026
b1d2092
Keep the device list NULL-terminated, store KV override keys byte for…
mcharytoniuk Nov 2, 2026
6ba6ab5
Run every non-model crate's tests in test.unit and rebuild the compil…
mcharytoniuk Nov 2, 2026
f24c7f0
Request every GPU layer with -1 as llama.cpp defines and parse negati…
mcharytoniuk Nov 2, 2026
4af3315
Include ggml-backend.h where the device wrappers use it
mcharytoniuk Nov 2, 2026
ebbce47
Test template availability on the model and memory absence on valid s…
mcharytoniuk Nov 2, 2026
5b09ee4
Cover a refused copy source, removal from every sequence and backend …
mcharytoniuk Nov 2, 2026
124775c
Link the OpenMP runtime CMake resolved for ggml by its exact file nam…
mcharytoniuk Nov 2, 2026
97b8510
Query the CMake cache from an initial-cache script so a wiped build t…
mcharytoniuk Nov 2, 2026
5103e8e
Compare a CPU-only load key with one requesting every GPU layer as ll…
mcharytoniuk Nov 2, 2026
51463a6
Read CMake switches and lists on the cache itself and build test cach…
mcharytoniuk Nov 2, 2026
8831b6c
Pass test environment overrides as named variables instead of tuples
mcharytoniuk Nov 2, 2026
8bd8b55
Declare intentional test failures with their exact typed failure and …
mcharytoniuk Nov 2, 2026
dededfd
Name every trial after its model, mmproj and context sizes and refuse…
mcharytoniuk Nov 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
41 changes: 28 additions & 13 deletions Cargo.lock

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

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ members = [
"llama-cpp-bindings",
"llama-cpp-bindings-tests",
"llama-cpp-error-recorder",
"llama-cpp-fault-injection",
"llama-cpp-ffi-status",
"llama-cpp-gbnf",
"llama-cpp-log-decoder",
"llama-cpp-test-harness",
"llama-cpp-test-harness-macros",
"llama-cpp-test-model-provisioning",
"llama-cpp-wrapper-error-fixture",
"llama-cpp-wrapper-sources",
]
Expand Down Expand Up @@ -43,11 +45,12 @@ llama-cpp-gbnf = { path = "llama-cpp-gbnf", version = "=0.26.0" }
llama-cpp-log-decoder = { path = "llama-cpp-log-decoder", version = "=0.26.0" }
llama-cpp-test-harness = { path = "llama-cpp-test-harness", version = "=0.26.0" }
llama-cpp-test-harness-macros = { path = "llama-cpp-test-harness-macros", version = "=0.26.0" }
llama-cpp-test-model-provisioning = { path = "llama-cpp-test-model-provisioning", version = "=0.26.0" }
llama-cpp-fault-injection = { path = "llama-cpp-fault-injection" }
llama-cpp-wrapper-error-fixture = { path = "llama-cpp-wrapper-error-fixture" }
llama-cpp-wrapper-sources = { path = "llama-cpp-wrapper-sources", version = "=0.26.0" }
llguidance = "=1.7.0"
log = "=0.4.29"
nom = "=8.0.0"
once_cell = "1.21"
proc-macro2 = "=1.0.106"
quote = "=1.0.45"
Expand Down
22 changes: 12 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@ WRAPPER_SOURCES_RESPONSE_FILE = target/wrapper_sources.rsp
WRAPPER_SOURCES_CRATE = llama-cpp-wrapper-sources

WRAPPER_SOURCES_CRATE_FILES = \
$(WRAPPER_SOURCES_CRATE)/src/compile_commands_file.rs \
$(WRAPPER_SOURCES_CRATE)/src/cpp_standard.rs \
$(WRAPPER_SOURCES_CRATE)/src/wrapper_include_dirs.rs \
$(WRAPPER_SOURCES_CRATE)/src/wrapper_source_paths.rs \
$(WRAPPER_SOURCES_CRATE)/src/wrapper_sources.rs \
$(WRAPPER_SOURCES_CRATE)/src/wrapper_sources_response_file.rs
$(WRAPPER_SOURCES_CRATE)/Cargo.toml \
$(wildcard $(WRAPPER_SOURCES_CRATE)/src/*.rs)

EMIT_WRAPPER_BUILD_INPUTS = cargo run --quiet --package $(WRAPPER_SOURCES_CRATE) -- \
$(CURDIR)/llama-cpp-bindings-sys $(COMPILE_COMMANDS) $(WRAPPER_SOURCES_RESPONSE_FILE)
Expand Down Expand Up @@ -76,14 +72,18 @@ coverage: node_modules
cargo llvm-cov report
./node_modules/.bin/rust-coverage-check target/llvm-cov.json \
--workspace-root $(CURDIR) \
--gated llama-cpp-bindings=98 \
--gated llama-cpp-bindings=100 \
--gated llama-cpp-bindings-build=100 \
--gated llama-cpp-bindings-tests=100 \
--gated llama-cpp-bindings-types=100 \
--gated llama-cpp-error-recorder=100 \
--gated llama-cpp-fault-injection=100 \
--gated llama-cpp-ffi-status=100 \
--gated llama-cpp-gbnf=100 \
--gated llama-cpp-log-decoder=100 \
--gated llama-cpp-test-harness=99 \
--gated llama-cpp-test-harness=100 \
--gated llama-cpp-test-harness-macros=100 \
--gated llama-cpp-test-model-provisioning=100 \
--gated llama-cpp-wrapper-sources=100

.PHONY: coverage-clean
Expand Down Expand Up @@ -123,13 +123,15 @@ test: test.llms

.PHONY: test.harness
test.harness: clippy
cargo test -p llama-cpp-test-harness-macros -p llama-cpp-test-harness $(DEVICE_FEATURE)
cargo test -p llama-cpp-test-harness-macros -p llama-cpp-test-harness \
-p llama-cpp-test-model-provisioning $(DEVICE_FEATURE)

.PHONY: test.llms
test.llms: clippy test.harness test.unit
cargo test --no-fail-fast -p llama-cpp-bindings-tests $(DEVICE_FEATURE)

.PHONY: test.unit
test.unit: clippy
cargo test -p llama-cpp-bindings -p llama-cpp-bindings-build -p llama-cpp-gbnf \
cargo test -p llama-cpp-bindings -p llama-cpp-bindings-build -p llama-cpp-bindings-types \
-p llama-cpp-error-recorder -p llama-cpp-ffi-status -p llama-cpp-gbnf \
-p llama-cpp-log-decoder -p llama-cpp-wrapper-sources $(DEVICE_FEATURE)
4 changes: 4 additions & 0 deletions llama-cpp-bindings-build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ repository.workspace = true
bindgen = { workspace = true }
cc = { workspace = true }
cmake = { workspace = true }
enumflags2 = { workspace = true }
find_cuda_helper = { workspace = true }
llama-cpp-wrapper-sources = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
thiserror = { workspace = true }

[features]
Expand All @@ -20,6 +23,7 @@ cuda-no-vmm = ["cuda"]
metal = []
dynamic-link = []
dynamic-backends = ["dynamic-link"]
fault-injection = []
vulkan = []
openmp = []
rocm = []
Expand Down
1 change: 1 addition & 0 deletions llama-cpp-bindings-build/cmake/cache_query.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
file(WRITE "${CMAKE_BINARY_DIR}/.cmake/api/v1/query/cache-v2" "")
20 changes: 20 additions & 0 deletions llama-cpp-bindings-build/fixtures/bindings/llama_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once

struct llama_context_params {
float defrag_thold;
unsigned int n_ctx;
};

struct llama_token_data {
int id;
float logit;
};

struct llama_sampler_chain_params {
int no_perf;
};

enum ggml_prec {
GGML_PREC_UNDEFINED = 0,
GGML_PREC_DEFAULT = 0,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

struct llama_context_params {
unsigned int n_ctx;
};
8 changes: 8 additions & 0 deletions llama-cpp-bindings-build/fixtures/bindings/wrapper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

#include "llama_types.h"

struct mtmd_context_params {
const char * image_marker;
const char * media_marker;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"reply":{"cache-v2":{"kind":"cache","version":{"major":2,"minor":0},"jsonFile":"cache-v2-missing.json"}}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"reply":{}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"kind":"cache","version":{"major":2,"minor":0},"entries":[]}
17 changes: 17 additions & 0 deletions llama-cpp-bindings-build/fixtures/cmake_project/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cmake_minimum_required(VERSION 3.14)
project(llama_cpp_bindings_build_fixture C)

if(NOT DEFINED FIXTURE_LIBRARY_NAME)
message(FATAL_ERROR "FIXTURE_LIBRARY_NAME must be defined")
endif()

add_library(${FIXTURE_LIBRARY_NAME} STATIC fixture.c)

install(TARGETS ${FIXTURE_LIBRARY_NAME} DESTINATION lib)

set(GGML_OPENMP_ENABLED "ON" CACHE INTERNAL "")
set(OpenMP_C_LIB_NAMES "${FIXTURE_LIBRARY_NAME}" CACHE STRING "")
set(OpenMP_CXX_LIB_NAMES "${FIXTURE_LIBRARY_NAME}" CACHE STRING "")
set(OpenMP_${FIXTURE_LIBRARY_NAME}_LIBRARY
"${CMAKE_INSTALL_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}${FIXTURE_LIBRARY_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}"
CACHE FILEPATH "")
3 changes: 3 additions & 0 deletions llama-cpp-bindings-build/fixtures/cmake_project/fixture.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
int llama_cpp_bindings_build_fixture(void) {
return 0;
}
3 changes: 3 additions & 0 deletions llama-cpp-bindings-build/fixtures/wrapper/vendor/vendored.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

#define VENDORED_VALUE 7
9 changes: 9 additions & 0 deletions llama-cpp-bindings-build/fixtures/wrapper/wrapper_fixture.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <vendored.h>

#ifndef WRAPPER_FIXTURE_DEFINE
#error "WRAPPER_FIXTURE_DEFINE must be defined"
#endif

extern "C" auto llama_cpp_bindings_build_wrapper_fixture() -> int {
return VENDORED_VALUE;
}
69 changes: 69 additions & 0 deletions llama-cpp-bindings-build/src/android_architecture.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
use crate::build_error::BuildError;

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum AndroidArchitecture {
Aarch64,
Armv7,
X86_64,
X86,
}

impl AndroidArchitecture {
/// # Errors
///
/// Returns [`BuildError::UnsupportedAndroidTarget`] for an architecture the NDK does not
/// build for.
pub fn from_cargo_cfg(cargo_cfg_target_arch: &str) -> Result<Self, BuildError> {
match cargo_cfg_target_arch {
"aarch64" => Ok(Self::Aarch64),
"arm" => Ok(Self::Armv7),
"x86_64" => Ok(Self::X86_64),
"x86" => Ok(Self::X86),
unsupported => Err(BuildError::UnsupportedAndroidTarget {
cargo_cfg_target_arch: unsupported.to_owned(),
}),
}
}

#[must_use]
pub const fn abi(self) -> &'static str {
match self {
Self::Aarch64 => "arm64-v8a",
Self::Armv7 => "armeabi-v7a",
Self::X86_64 => "x86_64",
Self::X86 => "x86",
}
}

#[must_use]
pub const fn ndk_prefix(self) -> &'static str {
match self {
Self::Aarch64 => "aarch64-linux-android",
Self::Armv7 => "arm-linux-androideabi",
Self::X86_64 => "x86_64-linux-android",
Self::X86 => "i686-linux-android",
}
}
}

#[cfg(test)]
mod tests {
use super::AndroidArchitecture;

#[test]
fn every_supported_android_architecture_maps_to_its_abi_and_ndk_prefix() {
assert_eq!(
["aarch64", "arm", "x86_64", "x86"].map(|cargo_cfg_target_arch| {
AndroidArchitecture::from_cargo_cfg(cargo_cfg_target_arch)
.map(|architecture| [architecture.abi(), architecture.ndk_prefix()])
.ok()
}),
[
Some(["arm64-v8a", "aarch64-linux-android"]),
Some(["armeabi-v7a", "arm-linux-androideabi"]),
Some(["x86_64", "x86_64-linux-android"]),
Some(["x86", "i686-linux-android"]),
]
);
}
}
Loading
Loading