test(serve): long-context smoke serves a list of prompt lengths on one stack

LELEKA_ORIGINAL_SERVE_LONG_TOKENS=8000,16000 loads the model once; every
shorter prompt takes a prefix of the same filler, so each is the prompt a
single-length run builds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pavlo Ratushnyi
2026-10-16 12:50:41 +02:00
co-authored by Claude Opus 5.5
parent cffbf88e31
commit bbb5b2deab
@@ -243,7 +243,8 @@ fn original_serve_smoke_prompt_decode_mtp_verify_commit_reset_cancel_sample() {
/// `long-smoke output ids` (one process per window: the window is fixed per process).
///
/// * `LELEKA_ORIGINAL_SERVE_LONG_SMOKE=yes` explicit opt-in, plus the model inputs of the smoke above;
/// * `LELEKA_ORIGINAL_SERVE_LONG_TOKENS` prompt length in tokens (default 40000);
/// * `LELEKA_ORIGINAL_SERVE_LONG_TOKENS` prompt length in tokens (default 40000), or a comma-separated
/// list served in order on one stack (each a prefix-filler prompt identical to a single-length run);
/// * `LELEKA_ORIGINAL_SERVE_KV_RESIDENT` resident cells per QSA layer (default 20480; 0 = all);
/// * `LELEKA_ORIGINAL_SERVE_MAX_CONTEXT` request ceiling (default 65536);
/// * `LELEKA_ORIGINAL_SERVE_LONG_MAX_NEW` generated tokens (default 32);
@@ -264,11 +265,15 @@ fn original_serve_long_context_streamed_kv_smoke() {
let number = |name: &str, default: usize| -> usize {
env::var(name).ok().map(|v| v.parse().unwrap_or_else(|_| panic!("{name} must be a count"))).unwrap_or(default)
};
let target = number("LELEKA_ORIGINAL_SERVE_LONG_TOKENS", 40_000);
// one prompt length, or a comma-separated list served in order on the same stack
let targets: Vec<usize> = env::var("LELEKA_ORIGINAL_SERVE_LONG_TOKENS")
.map(|v| v.split(',').map(|t| t.trim().parse().expect("LELEKA_ORIGINAL_SERVE_LONG_TOKENS must be counts")).collect())
.unwrap_or_else(|_| vec![40_000]);
let target = targets.iter().copied().max().expect("at least one prompt length");
let resident = number("LELEKA_ORIGINAL_SERVE_KV_RESIDENT", 20_480);
let max_context = number("LELEKA_ORIGINAL_SERVE_MAX_CONTEXT", 65_536);
let max_new = number("LELEKA_ORIGINAL_SERVE_LONG_MAX_NEW", 32);
assert!(target >= 64 && target + max_new + 8 <= max_context, "the prompt and the answer must fit the ceiling");
assert!(targets.iter().all(|&t| t >= 64) && target + max_new + 8 <= max_context, "the prompt and the answer must fit the ceiling");
let fd: u32 = env::var("LELEKA_STRA169_KAR_FD").expect("missing inherited sealed archive descriptor").parse().expect("invalid descriptor");
let shard0 = VerifiedGgufFile::open(&required_path("LELEKA_STRA169_IQ3S_SHARD0"), SHARD0).expect("pinned shard0 verification failed");
let shard1 = VerifiedGgufFile::open(&required_path("LELEKA_STRA169_IQ3S_SHARD1"), SHARD1).expect("pinned shard1 verification failed");
@@ -328,8 +333,14 @@ fn original_serve_long_context_streamed_kv_smoke() {
filler.extend(tokenizer.encode(&sentences, false).expect("tokenization failed"));
}
filler.truncate(budget);
let prompt: Vec<u32> = head.iter().chain(&filler).chain(&question).copied().collect();
eprintln!("long-smoke prompt tokens={} kv-resident={resident} max-context={max_context}", prompt.len());
// every shorter prompt takes a prefix of the same filler (what a single-length run builds)
let prompts: Vec<Vec<u32>> = targets
.iter()
.map(|&t| {
let budget = t.saturating_sub(head.len() + question.len());
head.iter().chain(&filler[..budget]).chain(&question).copied().collect()
})
.collect();
let mut config = StackConfig::new(max_context as i64);
config.capacity = number("LELEKA_ORIGINAL_SERVE_CAPACITY", 2048);
@@ -343,11 +354,14 @@ fn original_serve_long_context_streamed_kv_smoke() {
Ok(stack) => stack,
Err(failure) => panic!("the Original serve stack did not open: {}", failure.describe()),
};
for prompt in &prompts {
let prompt = prompt.as_slice();
eprintln!("long-smoke prompt tokens={} kv-resident={resident} max-context={max_context}", prompt.len());
for pass in 0..repeat {
let started = std::time::Instant::now();
let mut tokens = Vec::new();
let outcome = stack
.serve(&request(&prompt, max_new, None, eos), &mut |round| {
.serve(&request(prompt, max_new, None, eos), &mut |round| {
tokens.extend_from_slice(round);
Ok(())
}, &mut || false)
@@ -373,6 +387,7 @@ fn original_serve_long_context_streamed_kv_smoke() {
text.contains("4817")
);
}
}
stack.close().expect("stack cleanup failed");
Rc::try_unwrap(context).ok().expect("context still borrowed").close().expect("context cleanup failed");
}