Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
feat(llamacpp): add kv_unified setting for --kv-unified
Akarshan Biswas7c026d3fb97b
diff --git a/extensions/llamacpp-extension/settings.json b/extensions/llamacpp-extension/settings.jsonindex 1c0da24cd..e5e501c1e 100644--- a/extensions/llamacpp-extension/settings.json+++ b/extensions/llamacpp-extension/settings.json@@ -387,6 +387,15 @@"value": false}},+ {+ "key": "kv_unified",+ "title": "Unified KV Cache",+ "description": "Use a single unified KV buffer shared across all slots. Saves memory when running multiple parallel slots; default is auto.",+ "controllerType": "checkbox",+ "controllerProps": {+ "value": false+ }+ },{"key": "keep","title": "Keep First N Tokens",diff --git a/extensions/llamacpp-extension/src/index.ts b/extensions/llamacpp-extension/src/index.tsindex e019ffdb8..8ba3056e4 100644--- a/extensions/llamacpp-extension/src/index.ts+++ b/extensions/llamacpp-extension/src/index.ts@@ -120,6 +120,7 @@ const PRESET_AFFECTING_KEYS = new Set<string>(['cache_reuse','swa_full','keep',+ 'kv_unified',])/**diff --git a/extensions/llamacpp-extension/src/preset.ts b/extensions/llamacpp-extension/src/preset.tsindex 64ecf14c2..24c51c5be 100644--- a/extensions/llamacpp-extension/src/preset.ts+++ b/extensions/llamacpp-extension/src/preset.ts@@ -307,6 +307,11 @@ export async function generatePreset(if (config.swa_full === true) {lines.push('swa-full = true')}+ // kv-unified default = auto (enabled when slot count is auto); explicit+ // opt-in only, since the auto default already covers the common case.+ if (config.kv_unified === true) {+ lines.push('kv-unified = true')+ }// keep default = 0if (typeof config.keep === 'number' &&diff --git a/src-tauri/plugins/tauri-plugin-llamacpp/guest-js/index.ts b/src-tauri/plugins/tauri-plugin-llamacpp/guest-js/index.tsindex 646ee0e7f..c56df0690 100644--- a/src-tauri/plugins/tauri-plugin-llamacpp/guest-js/index.ts+++ b/src-tauri/plugins/tauri-plugin-llamacpp/guest-js/index.ts@@ -116,6 +116,7 @@ export function normalizeLlamacppConfig(config: any): LlamacppConfig {cache_reuse: asI32(config.cache_reuse, 0),swa_full: asBool(config.swa_full),keep: asI32(config.keep, 0),+ kv_unified: asBool(config.kv_unified),}}diff --git a/src-tauri/plugins/tauri-plugin-llamacpp/guest-js/types.ts b/src-tauri/plugins/tauri-plugin-llamacpp/guest-js/types.tsindex e86c9fd6c..dfe11ba3f 100644--- a/src-tauri/plugins/tauri-plugin-llamacpp/guest-js/types.ts+++ b/src-tauri/plugins/tauri-plugin-llamacpp/guest-js/types.ts@@ -80,6 +80,7 @@ export type LlamacppConfig = {cache_reuse: numberswa_full: booleankeep: number+ kv_unified: boolean}export type ModelPlan = {