Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use cmake instead of cc #221

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 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
24 changes: 10 additions & 14 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ hf-hub = { version = "0.3.2" }
criterion = "0.5.1"
pprof = "0.13.0"
bindgen = "0.69.4"
cc = "1.0.90"
anyhow = "1.0.81"
clap = "4.5.3"
cmake = "0.1.50"

[workspace.lints.rust]
missing_docs = { level = "warn" }
Expand Down
1 change: 1 addition & 0 deletions llama-cpp-2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ tracing = { workspace = true }

[features]
cublas = ["llama-cpp-sys-2/cublas"]
vulkan = ["llama-cpp-sys-2/vulkan"]
sampler = []

[lints]
Expand Down
2 changes: 1 addition & 1 deletion llama-cpp-2/src/context/sample/sampler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! like [`crate::context::LlamaContext`] or token history to the sampler.
//!
//! # Example
//!
//!
//! **Llama.cpp default sampler**
//!
//! ```rust
Expand Down
10 changes: 10 additions & 0 deletions llama-cpp-2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,13 @@ pub fn ggml_time_us() -> i64 {
pub fn llama_supports_mlock() -> bool {
unsafe { llama_cpp_sys_2::llama_supports_mlock() }
}

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

#[test]
fn smoke_test() {
ggml_time_us();
}
}
7 changes: 3 additions & 4 deletions llama-cpp-2/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,17 +280,16 @@ impl LlamaModel {
/// Get chat template from model.
///
/// # Errors
///
///
/// * If the model has no chat template
/// * If the chat template is not a valid [`CString`].
#[allow(clippy::missing_panics_doc)] // we statically know this will not panic as
pub fn get_chat_template(&self, buf_size: usize) -> Result<String, ChatTemplateError> {

// longest known template is about 1200 bytes from llama.cpp
let chat_temp = CString::new(vec![b'*'; buf_size]).expect("no null");
let chat_ptr = chat_temp.into_raw();
let chat_name = CString::new("tokenizer.chat_template").expect("no null bytes");

let chat_template: String = unsafe {
let ret = llama_cpp_sys_2::llama_model_meta_val_str(
self.model.as_ptr(),
Expand All @@ -305,7 +304,7 @@ impl LlamaModel {
debug_assert_eq!(usize::try_from(ret).unwrap(), template.len(), "llama.cpp guarantees that the returned int {ret} is the length of the string {} but that was not the case", template.len());
template
};

Ok(chat_template)
}

Expand Down
3 changes: 2 additions & 1 deletion llama-cpp-sys-2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ include = [

[build-dependencies]
bindgen = { workspace = true }
cc = { workspace = true, features = ["parallel"] }
cmake = { workspace = true }

[features]
cublas = []
vulkan = []

Loading
Loading