Mayo commited on
feat: update llama.cpp to b8665
Browse files- .cargo/config.toml +1 -1
- koharu-llm/build.rs +22 -4
- koharu-llm/src/safe/mtmd.rs +2 -2
- koharu-runtime/src/llama.rs +9 -8
.cargo/config.toml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
[env]
|
| 2 |
# refer: https://stackoverflow.com/questions/43577885/is-there-a-cargo-environment-variable-for-the-workspace-directory
|
| 3 |
CARGO_WORKSPACE_DIR = { value = "", relative = true }
|
| 4 |
-
LLAMA_CPP_TAG = "
|
| 5 |
# CUDA 13.1 requires C++17
|
| 6 |
NVCC_PREPEND_FLAGS = "-std=c++17"
|
|
|
|
| 1 |
[env]
|
| 2 |
# refer: https://stackoverflow.com/questions/43577885/is-there-a-cargo-environment-variable-for-the-workspace-directory
|
| 3 |
CARGO_WORKSPACE_DIR = { value = "", relative = true }
|
| 4 |
+
LLAMA_CPP_TAG = "b8665"
|
| 5 |
# CUDA 13.1 requires C++17
|
| 6 |
NVCC_PREPEND_FLAGS = "-std=c++17"
|
koharu-llm/build.rs
CHANGED
|
@@ -155,9 +155,25 @@ fn ensure_source_tree(out_dir: &Path, llama_cpp_tag: &str) -> Result<PathBuf> {
|
|
| 155 |
fs::File::open(&tarball_path).context("failed to reopen downloaded source tarball")?;
|
| 156 |
let decoder = GzDecoder::new(tarball);
|
| 157 |
let mut archive = Archive::new(decoder);
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
|
| 162 |
if !source_root.join("include/llama.h").exists() {
|
| 163 |
bail!(
|
|
@@ -230,7 +246,9 @@ fn generate_loader(
|
|
| 230 |
spec: LoaderSpec<'_>,
|
| 231 |
) -> Result<()> {
|
| 232 |
let builder = spec.function_patterns.iter().fold(
|
| 233 |
-
base_builder(header_path, include_dirs)
|
|
|
|
|
|
|
| 234 |
|builder, pattern| builder.allowlist_function(pattern),
|
| 235 |
);
|
| 236 |
|
|
|
|
| 155 |
fs::File::open(&tarball_path).context("failed to reopen downloaded source tarball")?;
|
| 156 |
let decoder = GzDecoder::new(tarball);
|
| 157 |
let mut archive = Archive::new(decoder);
|
| 158 |
+
// Extract selectively: skip benchmarks and other non-essential paths that
|
| 159 |
+
// contain very long filenames which exceed Windows' 260-char path limit.
|
| 160 |
+
for entry in archive
|
| 161 |
+
.entries()
|
| 162 |
+
.context("failed to read tarball entries")?
|
| 163 |
+
{
|
| 164 |
+
let mut entry = entry.context("failed to read tarball entry")?;
|
| 165 |
+
let path_str = entry
|
| 166 |
+
.path()
|
| 167 |
+
.context("failed to read entry path")?
|
| 168 |
+
.to_string_lossy()
|
| 169 |
+
.into_owned();
|
| 170 |
+
if path_str.contains("/benches/") || path_str.contains("/bench/") {
|
| 171 |
+
continue;
|
| 172 |
+
}
|
| 173 |
+
entry
|
| 174 |
+
.unpack_in(&cache_dir)
|
| 175 |
+
.with_context(|| format!("failed to unpack `{path_str}`"))?;
|
| 176 |
+
}
|
| 177 |
|
| 178 |
if !source_root.join("include/llama.h").exists() {
|
| 179 |
bail!(
|
|
|
|
| 246 |
spec: LoaderSpec<'_>,
|
| 247 |
) -> Result<()> {
|
| 248 |
let builder = spec.function_patterns.iter().fold(
|
| 249 |
+
base_builder(header_path, include_dirs)
|
| 250 |
+
// Block functions using C FILE* which has no Rust equivalent in bindgen.
|
| 251 |
+
.blocklist_function("llama_model_load_from_file_ptr"),
|
| 252 |
|builder, pattern| builder.allowlist_function(pattern),
|
| 253 |
);
|
| 254 |
|
koharu-llm/src/safe/mtmd.rs
CHANGED
|
@@ -217,8 +217,8 @@ impl MtmdContext {
|
|
| 217 |
/// Get audio bitrate in Hz (e.g., 16000 for Whisper).
|
| 218 |
/// Returns None if audio is not supported.
|
| 219 |
#[must_use]
|
| 220 |
-
pub fn
|
| 221 |
-
let rate = unsafe { crate::sys::
|
| 222 |
(rate > 0).then_some(rate.unsigned_abs())
|
| 223 |
}
|
| 224 |
|
|
|
|
| 217 |
/// Get audio bitrate in Hz (e.g., 16000 for Whisper).
|
| 218 |
/// Returns None if audio is not supported.
|
| 219 |
#[must_use]
|
| 220 |
+
pub fn get_audio_sample_rate(&self) -> Option<u32> {
|
| 221 |
+
let rate = unsafe { crate::sys::mtmd_get_audio_sample_rate(self.context.as_ptr()) };
|
| 222 |
(rate > 0).then_some(rate.unsigned_abs())
|
| 223 |
}
|
| 224 |
|
koharu-runtime/src/llama.rs
CHANGED
|
@@ -56,15 +56,16 @@ impl LlamaDistribution {
|
|
| 56 |
}
|
| 57 |
}
|
| 58 |
|
| 59 |
-
fn assets(self) ->
|
|
|
|
| 60 |
match self {
|
| 61 |
-
Self::WindowsCuda13X64 =>
|
| 62 |
-
"llama-
|
| 63 |
-
"cudart-llama-bin-win-cuda-13.1-x64.zip",
|
| 64 |
],
|
| 65 |
-
Self::WindowsVulkanX64 =>
|
| 66 |
-
Self::LinuxVulkanX64 =>
|
| 67 |
-
Self::MacosArm64 =>
|
| 68 |
}
|
| 69 |
}
|
| 70 |
|
|
@@ -200,7 +201,7 @@ pub(crate) async fn ensure_ready(runtime: &Runtime) -> Result<()> {
|
|
| 200 |
if !install.is_current() {
|
| 201 |
install.reset()?;
|
| 202 |
|
| 203 |
-
for asset in distribution.assets() {
|
| 204 |
let url = format!("{RELEASE_BASE_URL}/{LLAMA_CPP_TAG}/{asset}");
|
| 205 |
let archive = runtime
|
| 206 |
.downloads()
|
|
|
|
| 56 |
}
|
| 57 |
}
|
| 58 |
|
| 59 |
+
fn assets(self) -> Vec<String> {
|
| 60 |
+
let tag = LLAMA_CPP_TAG;
|
| 61 |
match self {
|
| 62 |
+
Self::WindowsCuda13X64 => vec![
|
| 63 |
+
format!("llama-{tag}-bin-win-cuda-13.1-x64.zip"),
|
| 64 |
+
"cudart-llama-bin-win-cuda-13.1-x64.zip".to_string(),
|
| 65 |
],
|
| 66 |
+
Self::WindowsVulkanX64 => vec![format!("llama-{tag}-bin-win-vulkan-x64.zip")],
|
| 67 |
+
Self::LinuxVulkanX64 => vec![format!("llama-{tag}-bin-ubuntu-vulkan-x64.tar.gz")],
|
| 68 |
+
Self::MacosArm64 => vec![format!("llama-{tag}-bin-macos-arm64.tar.gz")],
|
| 69 |
}
|
| 70 |
}
|
| 71 |
|
|
|
|
| 201 |
if !install.is_current() {
|
| 202 |
install.reset()?;
|
| 203 |
|
| 204 |
+
for asset in &distribution.assets() {
|
| 205 |
let url = format!("{RELEASE_BASE_URL}/{LLAMA_CPP_TAG}/{asset}");
|
| 206 |
let archive = runtime
|
| 207 |
.downloads()
|