Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ fn model_fit_settings(
),
basic_setting(&format!("{prefix}.kv_offload"), bool_or_auto_schema()),
basic_setting(&format!("{prefix}.kv_unified"), bool_or_auto_schema()),
unwired_setting(
basic_setting(
&format!("{prefix}.cache_ram_mib"),
ConfigValueSchema::Integer,
),
Expand Down
8 changes: 4 additions & 4 deletions crates/mesh-llm-config/src/wiring_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,10 +622,10 @@ pub const WIRING_MANIFEST: &[WiringEntry] = &[
},
WiringEntry {
path: "model_fit.cache_ram_mib",
status: WiringStatus::Unwired,
owner: "PR2",
reason: "Any positive value fails at model load",
behavior: WiringBehavior::BailsDownstream,
status: WiringStatus::Wired,
owner: "n/a",
reason: "",
behavior: WiringBehavior::None,
},
WiringEntry {
path: "model_fit.cache_idle_slots",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ impl FamilyPolicy {
payload: StageKvCachePayload::Auto,
max_entries: bounded_entries,
max_bytes,
l2_max_bytes: 0,
min_tokens,
shared_prefix_stride_tokens: 128,
shared_prefix_record_limit: derive_shared_prefix_record_limit(bounded_entries),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use super::types::{
BUILTIN_BATCH, BUILTIN_CTX_SIZE, BUILTIN_PARALLEL, BUILTIN_PREFILL_CHUNK_SIZE,
BUILTIN_SAFETY_MARGIN_GB, BUILTIN_UBATCH, ResolvedHardwareConfig, ResolvedModelFitConfig,
ResolvedMultimodalConfig, ResolvedSkippyConfig, ResolvedSkippyExecutionConfig,
ResolvedThroughputConfig, SkippyConfigResolveRequest,
ResolvedStageKvCache, ResolvedThroughputConfig, SkippyConfigResolveRequest,
};
use crate::plugin::{
BoolOrAuto, ModelConfigDefaults, ModelConfigEntry, ModelFitConfig, ThroughputConfig,
Expand Down Expand Up @@ -266,6 +266,16 @@ fn resolve_model_fit_config(
.or(context.global_model_fit.and_then(|fit| fit.flash_attention))
.unwrap_or_else(|| effective_flash_attention(&cache_type_v));
let prefix_cache = resolve_prefix_cache(context.model_fit, context.global_model_fit)?;
let l2_max_bytes = pick_owned(
context.model_fit.and_then(|fit| fit.cache_ram_mib),
context.global_model_fit.and_then(|fit| fit.cache_ram_mib),
)
.unwrap_or(0)
.checked_mul(1024 * 1024)
.ok_or_else(|| anyhow::anyhow!("model_fit.cache_ram_mib exceeds the byte range"))?;
if l2_max_bytes > 0 && matches!(prefix_cache, ResolvedStageKvCache::Disabled) {
anyhow::bail!("model_fit.cache_ram_mib requires prefix caching to be enabled");
}

Ok(ResolvedModelFitConfig {
ctx_size,
Expand All @@ -275,6 +285,7 @@ fn resolve_model_fit_config(
cache_type_v,
kv_cache_policy: kv.effective_policy,
prefix_cache,
l2_max_bytes,
kv_offload,
kv_offload_resolved,
kv_unified,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ pub(super) fn reject_unsupported_model_fit_controls(
let Some(config) = config else {
return Ok(());
};
if config.cache_ram_mib.unwrap_or(0) > 0 {
bail!("skippy model_fit.cache_ram_mib is not supported by the pinned runtime");
}
if config.keep_tokens.unwrap_or(0) > 0 {
bail!("skippy model_fit.keep_tokens is not supported by the pinned runtime");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2033,6 +2033,7 @@ fn staged_controls_propagate_into_stage_config_and_embedded_openai_args() {
r#"
[defaults.model_fit]
prompt_cache = true
cache_ram_mib = 64

[defaults.model_fit.prefix_cache]
enabled = true
Expand Down Expand Up @@ -2080,6 +2081,7 @@ draft_max_tokens = 8
assert_eq!(kv_cache.shared_prefix_stride_tokens, 48);
assert_eq!(kv_cache.shared_prefix_record_limit, 3);
assert_eq!(kv_cache.payload, StageKvCachePayload::ResidentKv);
assert_eq!(kv_cache.l2_max_bytes, 64 * 1024 * 1024);

let openai = resolved
.to_embedded_openai_args(4096, true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,23 +472,25 @@ impl ResolvedSkippyConfig {
&self,
family_default: Option<StageKvCacheConfig>,
) -> Result<Option<StageKvCacheConfig>> {
match &self.model_fit.prefix_cache {
ResolvedStageKvCache::FamilyDefault => Ok(family_default),
ResolvedStageKvCache::Disabled => Ok(Some(StageKvCacheConfig {
let mut resolved = match &self.model_fit.prefix_cache {
ResolvedStageKvCache::FamilyDefault => family_default,
ResolvedStageKvCache::Disabled => Some(StageKvCacheConfig {
mode: StageKvCacheMode::Disabled,
payload: StageKvCachePayload::Auto,
max_entries: 0,
max_bytes: 0,
l2_max_bytes: 0,
min_tokens: 0,
shared_prefix_stride_tokens: 0,
shared_prefix_record_limit: 0,
})),
}),
ResolvedStageKvCache::Explicit(template) => {
let mut cache = family_default.unwrap_or(StageKvCacheConfig {
mode: template.mode.clone(),
payload: StageKvCachePayload::Auto,
max_entries: 128,
max_bytes: 0,
l2_max_bytes: 0,
min_tokens: 256,
shared_prefix_stride_tokens: 128,
shared_prefix_record_limit: 2,
Expand All @@ -510,9 +512,18 @@ impl ResolvedSkippyConfig {
if let Some(value) = template.shared_prefix_record_limit {
cache.shared_prefix_record_limit = value as u64;
}
Ok(Some(cache))
Some(cache)
}
};
if self.model_fit.l2_max_bytes > 0 && resolved.is_none() {
anyhow::bail!(
"model_fit.cache_ram_mib requires an executable prefix-cache configuration"
);
}
if let Some(cache) = resolved.as_mut() {
cache.l2_max_bytes = self.model_fit.l2_max_bytes;
}
Ok(resolved)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ pub(crate) struct ResolvedModelFitConfig {
pub(crate) cache_type_v: String,
pub(crate) kv_cache_policy: String,
pub(crate) prefix_cache: ResolvedStageKvCache,
pub(crate) l2_max_bytes: u64,
pub(crate) kv_offload: String,
/// Parsed `kv_offload` for the native tri-state control. `None` covers
/// both "auto" and any value that did not parse to a bool.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ mod tests {
payload: StageKvCachePayload::Auto,
max_entries: 8,
max_bytes: 0,
l2_max_bytes: 0,
min_tokens: 8,
shared_prefix_stride_tokens: 8,
shared_prefix_record_limit: 2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@
"kind": "built_in"
}
},
{
"canonical_path": "defaults.model_fit.cache_ram_mib",
"support": "supported",
"source": {
"kind": "built_in"
}
},
{
"canonical_path": "defaults.model_fit.cache_type_k",
"support": "supported",
Expand Down
Loading
Loading