Manage the KV cache disc usage from preferences and stats

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Georg Bauer
2026-07-26 09:10:18 +02:00
parent b182e7007c
commit 63e2a74ad5
14 changed files with 794 additions and 35 deletions

View File

@@ -37,6 +37,10 @@ pub(super) struct PreferenceDraft {
pub(super) directional_steering_attn: String,
pub(super) simulated_used_memory_gib: String,
pub(super) expert_profile_path: String,
pub(super) kv_budget_gib: String,
pub(super) kv_min_tokens: String,
pub(super) kv_cold_max_tokens: String,
pub(super) kv_continued_interval_tokens: String,
}
impl PreferenceDraft {
@@ -121,6 +125,22 @@ impl PreferenceDraft {
.simulated_used_memory_gib
.map_or_else(String::new, |value| value.to_string()),
expert_profile_path: runtime.diagnostics.expert_profile_path.unwrap_or_default(),
kv_budget_gib: runtime
.kv_cache
.budget_gib
.map_or_else(String::new, |value| value.to_string()),
kv_min_tokens: runtime
.kv_cache
.min_tokens
.map_or_else(String::new, |value| value.to_string()),
kv_cold_max_tokens: runtime
.kv_cache
.cold_max_tokens
.map_or_else(String::new, |value| value.to_string()),
kv_continued_interval_tokens: runtime
.kv_cache
.continued_interval_tokens
.map_or_else(String::new, |value| value.to_string()),
})
}
@@ -182,6 +202,10 @@ impl PreferenceDraft {
self.directional_steering_attn.clear();
self.simulated_used_memory_gib.clear();
self.expert_profile_path.clear();
self.kv_budget_gib.clear();
self.kv_min_tokens.clear();
self.kv_cold_max_tokens.clear();
self.kv_continued_interval_tokens.clear();
}
pub(super) fn execution(&self) -> Result<ExecutionPreferences, String> {
@@ -241,6 +265,18 @@ impl PreferenceDraft {
)?,
expert_profile_path: optional_text(&self.expert_profile_path),
},
kv_cache: KvCachePreferences {
budget_gib: parse_optional_gib("KV cache budget", &self.kv_budget_gib)?,
min_tokens: parse_optional_u32("KV cache minimum tokens", &self.kv_min_tokens)?,
cold_max_tokens: parse_optional_u32(
"KV cache cold maximum",
&self.kv_cold_max_tokens,
)?,
continued_interval_tokens: parse_optional_u32(
"KV cache continued interval",
&self.kv_continued_interval_tokens,
)?,
},
})
}
}