Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

feat(llamacpp): upgrade the engine to 0.9.0 (b12110) (#9610)

Akarshan Biswas879e6ae9cca4
diff --git a/flatpak/ai.jan.Jan.yml b/flatpak/ai.jan.Jan.yml
index 0bad204d0..1e374b3e7 100644
--- a/flatpak/ai.jan.Jan.yml
+++ b/flatpak/ai.jan.Jan.yml
@@ -116,8 +116,8 @@ modules:
# (PINNED_TAG / PINNED_COMMIT), where build.rs looks for it by default;
# this replaces the network clone in fetch-engine-source.sh
- type: archive
- url: https://github.com/ggml-org/llama.cpp/archive/refs/tags/b11669.tar.gz
- sha256: e06ba4fa263e30fdb9f0e65f00a8965202ddaa0c51f548a67e1f9b2164d04efc
+ url: https://github.com/ggml-org/llama.cpp/archive/refs/tags/b12110.tar.gz
+ sha256: 442a8ec2c5e8b8895175abfcede851964572370f0a56b33166c94905260da008
dest: src-tauri/plugins/tauri-plugin-llamacpp/vendor/llama.cpp
- type: file
url: https://repo.yarnpkg.com/4.5.3/packages/yarnpkg-cli/bin/yarn.js
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index b16e2790a..aa9d11fb7 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -8130,7 +8130,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-llamacpp"
-version = "0.7.0"
+version = "0.9.0"
dependencies = [
"base64 0.22.1",
"byteorder",
diff --git a/src-tauri/plugins/tauri-plugin-llamacpp/Cargo.lock b/src-tauri/plugins/tauri-plugin-llamacpp/Cargo.lock
index 0556a8760..d12b88caa 100644
--- a/src-tauri/plugins/tauri-plugin-llamacpp/Cargo.lock
+++ b/src-tauri/plugins/tauri-plugin-llamacpp/Cargo.lock
@@ -3421,7 +3421,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-llamacpp"
-version = "0.7.0"
+version = "0.9.0"
dependencies = [
"base64 0.22.1",
"byteorder",
diff --git a/src-tauri/plugins/tauri-plugin-llamacpp/Cargo.toml b/src-tauri/plugins/tauri-plugin-llamacpp/Cargo.toml
index 607691981..b7f7b7e6b 100644
--- a/src-tauri/plugins/tauri-plugin-llamacpp/Cargo.toml
+++ b/src-tauri/plugins/tauri-plugin-llamacpp/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "tauri-plugin-llamacpp"
-version = "0.7.0"
+version = "0.9.0"
authors = ["Jan <[email protected]>"]
description = "Tauri plugin for managing Jan LlamaCpp server processes and model loading"
license = "Apache-2.0"
diff --git a/src-tauri/plugins/tauri-plugin-llamacpp/build.rs b/src-tauri/plugins/tauri-plugin-llamacpp/build.rs
index a5702f3b9..d4b985a59 100644
--- a/src-tauri/plugins/tauri-plugin-llamacpp/build.rs
+++ b/src-tauri/plugins/tauri-plugin-llamacpp/build.rs
@@ -13,10 +13,10 @@
// vendor/llama.cpp and with engine::PINNED_* on the Rust side; the shim
// re-exports llama_version()/llama_build_number() so a mismatch is caught at
// runtime instead of producing a silently wrong engine.
-pub const LLAMA_CPP_TAG: &str = "b11669";
-pub const LLAMA_CPP_BUILD_NUMBER: u32 = 11669;
-pub const LLAMA_CPP_COMMIT: &str = "620d2225cc436ab0b001e3200e590e3b286ef9ab";
-pub const LLAMA_CPP_VERSION: &str = "0.7.0";
+pub const LLAMA_CPP_TAG: &str = "b12110";
+pub const LLAMA_CPP_BUILD_NUMBER: u32 = 12110;
+pub const LLAMA_CPP_COMMIT: &str = "cd959bae99ff4bed22bef2604f45241c09bbb8c8";
+pub const LLAMA_CPP_VERSION: &str = "0.9.0";
const COMMANDS: &[&str] = &[
// Cleanup command
@@ -582,7 +582,7 @@ mod engine {
} else if feature_enabled("engine-cuda")
&& env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default() == "x86_64"
{
- // A foreign JAN_LLAMA_CPP_DIR tree is not the b11669 the list was
+ // A foreign JAN_LLAMA_CPP_DIR tree is not the b12110 the list was
// copied from, so only the vendored pin is held to it.
if env::var_os("JAN_LLAMA_CPP_DIR").is_none() {
check_upstream_cuda_archs(src);
@@ -954,7 +954,7 @@ mod engine {
words
}
- /// ggml/src/ggml-cuda/CMakeLists.txt's non-native default as of b11669,
+ /// ggml/src/ggml-cuda/CMakeLists.txt's non-native default as of b12110,
/// with 75-virtual changed to 75-real (see the call site).
/// check_upstream_cuda_archs fails the build if a tag bump changes it.
fn default_cuda_archs(v: (u32, u32)) -> String {
@@ -1014,7 +1014,7 @@ mod engine {
assert!(
upstream == ours,
"{} names CUDA archs {upstream:?}, but default_cuda_archs (copied from \
- b11669) covers {ours:?}. Update default_cuda_archs to the new list, \
+ b12110) covers {ours:?}. Update default_cuda_archs to the new list, \
keeping 75 as -real (#9185), or set JAN_ENGINE_CUDA_ARCHS.",
cml.display()
);
diff --git a/src-tauri/plugins/tauri-plugin-llamacpp/guest-js/types.ts b/src-tauri/plugins/tauri-plugin-llamacpp/guest-js/types.ts
index bc3c664fe..2411891ca 100644
--- a/src-tauri/plugins/tauri-plugin-llamacpp/guest-js/types.ts
+++ b/src-tauri/plugins/tauri-plugin-llamacpp/guest-js/types.ts
@@ -36,9 +36,9 @@ export interface EngineInfo {
/** Mirrors `engine::commands::EngineVersion`. */
export interface EngineVersion {
- /** llama.cpp's own version, e.g. "0.7.0". */
+ /** llama.cpp's own version, e.g. "0.9.0". */
version: string
- /** Upstream build tag the source was taken from, e.g. "b11669". */
+ /** Upstream build tag the source was taken from, e.g. "b12110". */
tag: string
/** The tag's build number, as a string. */
build_number: string
diff --git a/src-tauri/plugins/tauri-plugin-llamacpp/package.json b/src-tauri/plugins/tauri-plugin-llamacpp/package.json
index d3087d5a3..8114a2ffd 100644
--- a/src-tauri/plugins/tauri-plugin-llamacpp/package.json
+++ b/src-tauri/plugins/tauri-plugin-llamacpp/package.json
@@ -1,6 +1,6 @@
{
"name": "@janhq/tauri-plugin-llamacpp-api",
- "version": "0.7.0",
+ "version": "0.9.0",
"private": true,
"description": "",
"type": "module",
diff --git a/src-tauri/plugins/tauri-plugin-llamacpp/shim/jan_llama_shim.cpp b/src-tauri/plugins/tauri-plugin-llamacpp/shim/jan_llama_shim.cpp
index f569af720..4932e9da4 100644
--- a/src-tauri/plugins/tauri-plugin-llamacpp/shim/jan_llama_shim.cpp
+++ b/src-tauri/plugins/tauri-plugin-llamacpp/shim/jan_llama_shim.cpp
@@ -357,7 +357,8 @@ struct jan_llama_engine {
}
};
-// server-context.cpp:4897 does `res->set_req(&req)`, and server_res_spipe keeps
+// server_routes::handle_completions_impl (server-context.cpp) does
+// `res->set_req(&req)`, and server_res_spipe keeps
// that pointer for the life of the stream -- so the request, and the
// std::function its `should_stop` member references, must outlive the response.
// Declaration order here is the destruction order that guarantees it.
@@ -472,8 +473,8 @@ jan_llama_engine * jan_llama_engine_start_from_preset(const char * ini_pat
engine->params.model_alias.clear();
engine->params.model_alias.insert(preset_name);
- // common_params_parse does this at arg.cpp:886-890; apply_to_params does
- // not. Without it n_threads stays 0 and ggml_threadpool_new_impl
+ // common_params_parse does this in common_params_parse_ex (arg.cpp);
+ // apply_to_params does not. Without it n_threads stays 0 and ggml_threadpool_new_impl
// memsets a zero-length array -> SIGSEGV. The router never hits this
// because it forwards keys to a child that re-parses them.
postprocess_cpu_params(engine->params.cpuparams, nullptr);
@@ -483,8 +484,8 @@ jan_llama_engine * jan_llama_engine_start_from_preset(const char * ini_pat
postprocess_cpu_params(engine->params.speculative.draft.cpuparams_batch,
&engine->params.cpuparams_batch);
- // arg.cpp:892-896, added in 0.4.1: an unset `-mmdev` follows `--device`
- // rather than falling back to auto-placement. Without it a preset that
+ // common_params_parse_ex, added in 0.4.1: an unset `-mmdev` follows
+ // `--device` rather than falling back to auto-placement. Without it a preset that
// pins the model to one GPU would still let the projector land wherever
// ggml chose, which is the split the setting exists to prevent.
if (engine->params.mmproj_use_gpu && engine->params.mmproj_device == nullptr &&
@@ -493,8 +494,8 @@ jan_llama_engine * jan_llama_engine_start_from_preset(const char * ini_pat
engine->params.mmproj_use_gpu = engine->params.mmproj_device != nullptr;
}
- // Same omission, arg.cpp:946-954: common_params_fit needs spare slots
- // to write its overrides into and throws "did not provide buffer to
+ // Same omission, common_params_parse_ex: common_params_fit needs spare
+ // slots to write its overrides into and throws "did not provide buffer to
// set tensor_buft_overrides" without them, so auto-fit silently gave
// up and the load then asked for more VRAM than the device had.
const size_t ntbo = llama_max_tensor_buft_overrides();
@@ -505,15 +506,15 @@ jan_llama_engine * jan_llama_engine_start_from_preset(const char * ini_pat
engine->params.speculative.draft.tensor_buft_overrides.push_back({nullptr, nullptr});
}
- // arg.cpp:935-938. llama_model_params::kv_overrides is a C array walked
- // until an entry with an empty key, so a hand-edited `override-kv` in
+ // common_params_parse_ex. llama_model_params::kv_overrides is a C array
+ // walked until an entry with an empty key, so a hand-edited `override-kv` in
// the ini would otherwise be read past its end.
if (!engine->params.kv_overrides.empty()) {
engine->params.kv_overrides.emplace_back();
engine->params.kv_overrides.back().key[0] = 0;
}
- // arg.cpp:964-967, at the end of common_params_parse_ex. Since 0.4.0 the
+ // The end of common_params_parse_ex (arg.cpp). Since 0.4.0 the
// kwarg defaults to on when the user did not name it, and a template
// with `supports_preserve_reasoning` reads it -- so omitting this here
// would have the preset path preserve less reasoning than the argv path
@@ -537,8 +538,8 @@ namespace {
jan_llama_engine * finish_start(std::unique_ptr<jan_llama_engine> engine,
char * err, size_t err_len) {
try {
- // server.cpp:168-173, in llama-server's main() -- which neither entry
- // point here goes through. n_parallel = -1 is the SERVER default, and
+ // server_prepare_params (server.cpp), in llama-server's startup --
+ // which neither entry point here goes through. n_parallel = -1 is the SERVER default, and
// server_context loops `for (i = 0; i < n_parallel; i++)` to build its
// slots, so leaving the sentinel unresolved yields an engine with no
// slots at all and every request waiting forever.
@@ -547,8 +548,8 @@ jan_llama_engine * finish_start(std::unique_ptr<jan_llama_engine> engine,
engine->params.kv_unified = true;
}
- // server.cpp:176-186, immediately after the block above and dependent on
- // it: the pool is n_parallel wide, so it can only be sized once the
+ // server_prepare_params, immediately after the block above and
+ // dependent on it: the pool is n_parallel wide, so it can only be sized once the
// sentinel is resolved. Only `-c 0` (size to the model's trained
// context) leaves n_ctx at 0 for this to act on; any explicit ctx-size
// pins the pool and the cap then applies per slot inside it.
@@ -786,7 +787,7 @@ void jan_llama_load_backends(const char * dir) {
}
}
-// Mirrors common_print_available_devices (common/arg.cpp:1144-1167): load every
+// Mirrors common_print_available_devices (common/arg.cpp): load every
// backend, then report the non-CPU devices with memory in MiB. The CPU device
// is excluded there too -- "offload to CPU" is not a choice the setting offers.
char * jan_llama_devices_json(void) {
diff --git a/src-tauri/plugins/tauri-plugin-llamacpp/shim/jan_llama_shim.h b/src-tauri/plugins/tauri-plugin-llamacpp/shim/jan_llama_shim.h
index 572ea67bd..22406e020 100644
--- a/src-tauri/plugins/tauri-plugin-llamacpp/shim/jan_llama_shim.h
+++ b/src-tauri/plugins/tauri-plugin-llamacpp/shim/jan_llama_shim.h
@@ -103,8 +103,8 @@ void jan_llama_string_free(char * s);
// The llama.cpp the shim was compiled against, for the pin assertion in
// build.rs / engine::assert_pinned_version.
-const char * jan_llama_version(void); // e.g. "0.7.0"
-int jan_llama_build_number(void); // e.g. 11669
+const char * jan_llama_version(void); // e.g. "0.9.0"
+int jan_llama_build_number(void); // e.g. 12110
const char * jan_llama_commit(void);
#ifdef __cplusplus
diff --git a/src-tauri/plugins/tauri-plugin-llamacpp/src/engine/commands.rs b/src-tauri/plugins/tauri-plugin-llamacpp/src/engine/commands.rs
index 90369f4a5..dd41e1f94 100644
--- a/src-tauri/plugins/tauri-plugin-llamacpp/src/engine/commands.rs
+++ b/src-tauri/plugins/tauri-plugin-llamacpp/src/engine/commands.rs
@@ -644,9 +644,9 @@ pub async fn get_engine_info(
/// therefore no use to a settings screen that wants to name the engine.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EngineVersion {
- /// llama.cpp's own version, e.g. `0.7.0`.
+ /// llama.cpp's own version, e.g. `0.9.0`.
pub version: String,
- /// The upstream build tag the source was taken from, e.g. `b11669`.
+ /// The upstream build tag the source was taken from, e.g. `b12110`.
pub tag: String,
/// The same tag's build number, which is what the shim reports back over
/// the FFI and what a version mismatch is checked against.
diff --git a/src-tauri/plugins/tauri-plugin-llamacpp/src/engine/mod.rs b/src-tauri/plugins/tauri-plugin-llamacpp/src/engine/mod.rs
index 92706b8a2..857b4d6f3 100644
--- a/src-tauri/plugins/tauri-plugin-llamacpp/src/engine/mod.rs
+++ b/src-tauri/plugins/tauri-plugin-llamacpp/src/engine/mod.rs
@@ -213,9 +213,9 @@ mod tests {
#[test]
fn pin_constants_are_populated_from_build_rs() {
- assert_eq!(PINNED_TAG, "b11669");
- assert_eq!(PINNED_BUILD_NUMBER, "11669");
- assert_eq!(PINNED_VERSION, "0.7.0");
+ assert_eq!(PINNED_TAG, "b12110");
+ assert_eq!(PINNED_BUILD_NUMBER, "12110");
+ assert_eq!(PINNED_VERSION, "0.9.0");
assert_eq!(PINNED_COMMIT.len(), 40, "commit should be a full sha");
}
diff --git a/src-tauri/plugins/tauri-plugin-llamacpp/src/engine/preset.rs b/src-tauri/plugins/tauri-plugin-llamacpp/src/engine/preset.rs
index 34886723b..0dea3417f 100644
--- a/src-tauri/plugins/tauri-plugin-llamacpp/src/engine/preset.rs
+++ b/src-tauri/plugins/tauri-plugin-llamacpp/src/engine/preset.rs
@@ -46,8 +46,8 @@ fn section_bodies(ini: &str) -> HashMap<String, Vec<String>> {
/// Read on the Rust side as well as by the C++ loader because the worker has to
/// act on two of them before any model is loaded: `slot-save-path` names a
/// directory llama.cpp *throws* on if it does not exist
-/// (`common/arg.cpp:3635`), and the KV state store has to agree with llama.cpp
-/// on where files land.
+/// (`--slot-save-path` in `common/arg.cpp`), and the KV state store has to
+/// agree with llama.cpp on where files land.
pub fn shared_value(ini: &str, key: &str) -> Option<String> {
let mut in_shared = false;
for line in ini.lines().map(str::trim) {
diff --git a/src-tauri/plugins/tauri-plugin-llamacpp/src/engine/registry.rs b/src-tauri/plugins/tauri-plugin-llamacpp/src/engine/registry.rs
index 5bacf95cb..4e2a942ba 100644
--- a/src-tauri/plugins/tauri-plugin-llamacpp/src/engine/registry.rs
+++ b/src-tauri/plugins/tauri-plugin-llamacpp/src/engine/registry.rs
@@ -69,8 +69,8 @@ pub enum LoadSpec {
}
/// What `GET /models` reports per entry. The names match llama.cpp's router
-/// (`server-models.h:29-37`) because the plugin's polling arm
-/// (`commands::evaluate_load_poll`) already parses exactly these values, and
+/// (`server_model_status` in `server-models.h`) because the plugin's polling
+/// arm (`commands::evaluate_load_poll`) already parses exactly these values, and
/// changing them would silently turn every load into a 600s timeout.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ModelStatus {
diff --git a/src-tauri/plugins/tauri-plugin-llamacpp/src/engine/slots.rs b/src-tauri/plugins/tauri-plugin-llamacpp/src/engine/slots.rs
index 288082538..036f4643f 100644
--- a/src-tauri/plugins/tauri-plugin-llamacpp/src/engine/slots.rs
+++ b/src-tauri/plugins/tauri-plugin-llamacpp/src/engine/slots.rs
@@ -1,7 +1,8 @@
//! Persistence of a thread's KV cache across sessions.
//!
//! llama.cpp can already write a slot's KV cache to disk
-//! (`POST /slots/{id}?action=save`, `server-context.cpp:2992`), but the file it
+//! (`POST /slots/{id}?action=save`, `SERVER_TASK_TYPE_SLOT_SAVE` in
+//! `server-context.cpp`), but the file it
//! writes carries no identity: `llama_state_seq_load_file` checks a magic and a
//! version, and the restore path checks that the tokens fit the context and are
//! in the vocab. None of that notices that the file was written by a *different
@@ -281,7 +282,7 @@ impl StateStore {
}
/// Creates the directory. llama.cpp's `--slot-save-path` handler *throws*
- /// when the path is not a directory (`common/arg.cpp:3635`), and that
+ /// when the path is not a directory (`common/arg.cpp`), and that
/// unwinds out of engine startup, so a missing cache directory would take
/// the whole engine down rather than disabling one feature.
pub fn ensure_dir(&self) -> std::io::Result<()> {
diff --git a/web-app/src/services/models/types.ts b/web-app/src/services/models/types.ts
index 3c0951ed3..59d0514e4 100644
--- a/web-app/src/services/models/types.ts
+++ b/web-app/src/services/models/types.ts
@@ -205,9 +205,9 @@ export interface ModelsService {
* extension, not to the plugin.
*/
export interface EngineVersionInfo {
- /** llama.cpp's own version, e.g. "0.7.0". */
+ /** llama.cpp's own version, e.g. "0.9.0". */
version: string
- /** Upstream build tag, e.g. "b11669". */
+ /** Upstream build tag, e.g. "b12110". */
tag: string
buildNumber: string
/** Full commit sha the build is pinned to. */