feat(serve): conversation cache on by default (--prompt-cache 6, as in the Original)
StackConfig::new and OriginalServeOptions now enable the cache with the Original's settings; --prompt-cache 0 turns it off. Tests pin the defaults. Real-model coverage: jobs 411/412 (and 413 for this exact tree). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
15a755cadf
commit
a9e1d0a3e6
@@ -54,8 +54,8 @@ pub struct OriginalServeOptions {
|
||||
pub kv_format: Option<crate::memory_plan::KvFormat>,
|
||||
/// `--kv-resident N`: cells per QSA layer kept in VRAM (0 = the whole context); `None` takes 32768.
|
||||
pub kv_resident: Option<usize>,
|
||||
/// `--prompt-cache N`: conversation checkpoints kept between requests (the Original's default is 6);
|
||||
/// 0 reads every request from the empty prompt. Off by default until the real-model smoke has passed.
|
||||
/// `--prompt-cache N`: conversation checkpoints kept between requests (default 6, as in the Original);
|
||||
/// 0 reads every request from the empty prompt.
|
||||
pub prompt_cache: usize,
|
||||
/// `--prompt-cache-every N`: also a checkpoint every N freshly read prompt tokens (0 = turn boundaries only).
|
||||
pub prompt_cache_every: usize,
|
||||
@@ -73,7 +73,7 @@ impl Default for OriginalServeOptions {
|
||||
spec_min_p: 0.0,
|
||||
kv_format: None,
|
||||
kv_resident: None,
|
||||
prompt_cache: 0,
|
||||
prompt_cache: 6,
|
||||
prompt_cache_every: 16_384,
|
||||
prompt_cache_root: 2048,
|
||||
turn_token: Some(crate::qwen_forward::original_serve_stack::TURN_TOKEN),
|
||||
@@ -604,9 +604,10 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_conversation_cache_is_off_by_default_and_maps_the_original_flags() {
|
||||
fn the_conversation_cache_is_on_by_default_and_maps_the_original_flags() {
|
||||
let defaults = OriginalServeOptions::default();
|
||||
assert!(defaults.conversation().is_none());
|
||||
assert_eq!(defaults.conversation().map(|c| c.prompt_cache), Some(6), "--prompt-cache 6 by default");
|
||||
assert!(OriginalServeOptions { prompt_cache: 0, ..Default::default() }.conversation().is_none(), "--prompt-cache 0 turns it off");
|
||||
let on = OriginalServeOptions { prompt_cache: 6, prompt_cache_every: 0, turn_token: None, ..Default::default() };
|
||||
assert!(on.validate().is_ok());
|
||||
let config = on.conversation().expect("--prompt-cache 6 turns the cache on");
|
||||
|
||||
@@ -84,8 +84,8 @@ pub(crate) struct StackConfig {
|
||||
/// `--kv-resident N`: cells of each QSA layer kept in VRAM, the rest streamed from pinned host memory
|
||||
/// (raised to 20480; 0 = the whole context). Default 32768, the window every earlier build used.
|
||||
pub(crate) kv_resident: usize,
|
||||
/// generate.cpp's conversation cache (`--prompt-cache` and friends). `None` (the default until the
|
||||
/// real-model smoke has passed on a GPU) reads every request from the empty prompt.
|
||||
/// generate.cpp's conversation cache (`--prompt-cache` and friends); on by default with the Original's
|
||||
/// settings (`--prompt-cache 6`). `None` reads every request from the empty prompt.
|
||||
pub(crate) conversation: Option<ConversationConfig>,
|
||||
/// The VRAM expert tier (`--expert-cache`, `--expert-cache-per-layer`, `--expert-profile`, `--pcie-frac`,
|
||||
/// `--adapt-every/--adapt-swaps`). Off by default: every routed expert on the CPU pool.
|
||||
@@ -102,7 +102,7 @@ impl StackConfig {
|
||||
settle_state: false,
|
||||
kv_format: KvFormat::Int8,
|
||||
kv_resident: leleka_cuda_driver::KV_RESIDENT_DEFAULT_CELLS,
|
||||
conversation: None,
|
||||
conversation: Some(ConversationConfig::original()),
|
||||
expert_tier: ExpertTierConfig::off(),
|
||||
}
|
||||
}
|
||||
@@ -992,6 +992,16 @@ mod tests {
|
||||
assert!(StackConfig { max_context: i64::MAX, ..config }.validate().is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_conversation_cache_is_on_by_default_with_the_original_settings() {
|
||||
let config = StackConfig::new(4096);
|
||||
let conversation = config.conversation.as_ref().expect("--prompt-cache 6 is the default, as in the Original");
|
||||
assert_eq!((conversation.prompt_cache, conversation.prompt_cache_every, conversation.prompt_cache_root), (6, 16_384, 2048));
|
||||
assert_eq!(conversation.turn_token, Some(TURN_TOKEN));
|
||||
assert!(config.validate().is_ok());
|
||||
assert!(StackConfig { conversation: None, ..config }.validate().is_ok(), "the cache can be turned off");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn kv_defaults_to_the_production_int8_window_and_refuses_unported_formats() {
|
||||
let config = StackConfig::new(4096);
|
||||
|
||||
@@ -50,7 +50,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let args: Vec<String> = std::env::args().skip(1).collect();
|
||||
if args.as_slice() == ["--help"] {
|
||||
println!(
|
||||
"leleka-inference --listen IP:PORT --token-env NAME --shard0 PATH --shard1 PATH --gpu ORDINAL --gpu-budget BYTES --context-tokens COUNT [--kar-archive PATH --kar-staging PATH | --kar-archive-fd N --kar-provenance PATH] [--mtp-pack PATH --mtp-staging PATH] [--experimental-native-integer-iq3-windowed256-retained-gr | --experimental-optimized-windowed256-mtp [--ranked-expert-profile PATH --expert-profile-sha256 DIGEST] | --experimental-optimized-windowed256-mtp-queued-owners --ranked-expert-profile PATH --expert-profile-sha256 DIGEST | --experimental-optimized-windowed256-mtp-streamed-spill --ranked-expert-profile PATH --expert-profile-sha256 DIGEST | --experimental-optimized-windowed256-mtp-retained-scratch --ranked-expert-profile PATH --expert-profile-sha256 DIGEST | --experimental-optimized-windowed256-mtp-strata-adaptive-slots --ranked-expert-profile PATH --expert-profile-sha256 DIGEST] [--public-evaluation-output /PRIVATE/measurements.jsonl (adaptive slots only; LELEKA_PUBLIC_EVALUATION=yes and LELEKA_EVALUATION_NONCE required)] [--backend-mode auto|original|preview (default auto; an --experimental-* flag selects preview unless the mode is given)] [--original-prefill-capacity 256..8192] [--mtp-rt-dir PATH] [--spec-min-p 0..1] [--kv int8 (fp16|q4_0|k8v4 are refused)] [--kv-resident CELLS (default 32768, min 20480, 0 = all in VRAM)] [--prompt-cache N (conversation checkpoints, 0 = off, default 0; the Original uses 6)] [--prompt-cache-every N] [--prompt-cache-root N] [--turn-token ID (negative = none)]"
|
||||
"leleka-inference --listen IP:PORT --token-env NAME --shard0 PATH --shard1 PATH --gpu ORDINAL --gpu-budget BYTES --context-tokens COUNT [--kar-archive PATH --kar-staging PATH | --kar-archive-fd N --kar-provenance PATH] [--mtp-pack PATH --mtp-staging PATH] [--experimental-native-integer-iq3-windowed256-retained-gr | --experimental-optimized-windowed256-mtp [--ranked-expert-profile PATH --expert-profile-sha256 DIGEST] | --experimental-optimized-windowed256-mtp-queued-owners --ranked-expert-profile PATH --expert-profile-sha256 DIGEST | --experimental-optimized-windowed256-mtp-streamed-spill --ranked-expert-profile PATH --expert-profile-sha256 DIGEST | --experimental-optimized-windowed256-mtp-retained-scratch --ranked-expert-profile PATH --expert-profile-sha256 DIGEST | --experimental-optimized-windowed256-mtp-strata-adaptive-slots --ranked-expert-profile PATH --expert-profile-sha256 DIGEST] [--public-evaluation-output /PRIVATE/measurements.jsonl (adaptive slots only; LELEKA_PUBLIC_EVALUATION=yes and LELEKA_EVALUATION_NONCE required)] [--backend-mode auto|original|preview (default auto; an --experimental-* flag selects preview unless the mode is given)] [--original-prefill-capacity 256..8192] [--mtp-rt-dir PATH] [--spec-min-p 0..1] [--kv int8 (fp16|q4_0|k8v4 are refused)] [--kv-resident CELLS (default 32768, min 20480, 0 = all in VRAM)] [--prompt-cache N (conversation checkpoints, default 6 as in the Original, 0 = off)] [--prompt-cache-every N] [--prompt-cache-root N] [--turn-token ID (negative = none)]"
|
||||
);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user