feat(app): the LLM always takes one request at a time, and only the latest call is answered by default
A chat channel answering every message no longer starts Strata with --parallel 2: on the 16 GB card that read prompts about three times slower (2026-11-16, answers took 10-20 s). Chat and voice answers now take turns at Strata. response.policy defaults to latest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -41,12 +41,6 @@ pub struct LlmStatus {
|
||||
pub note: Option<String>,
|
||||
}
|
||||
|
||||
/// Requests answered at once: one is faster on a 16 GB card (M0), two only when a chat channel
|
||||
/// answers every message (so its answers do not wait behind the voice answers).
|
||||
pub fn parallel(settings: &Settings) -> u32 {
|
||||
if settings.chat_channels.iter().any(|c| c.answer_all) { 2 } else { 1 }
|
||||
}
|
||||
|
||||
/// `strata launch` for the services: the M0 kit's normal placement, models in `models/llm`, this
|
||||
/// computer only. No pictures yet (nothing in v2 sends one; reading them takes graphics memory).
|
||||
/// `--restart` replaces a server started with other choices; the same choices are reused.
|
||||
@@ -68,8 +62,9 @@ pub fn launch_args(layout: &Layout, settings: &Settings, conf: &Conf, sets: &[St
|
||||
a
|
||||
}
|
||||
|
||||
/// The context and requests at once of a stage: the settings' in the normal stage; in a game 16K
|
||||
/// (or less when the settings ask for less) and one request at a time.
|
||||
/// The context and requests at once of a stage: the settings' context in the normal stage, in a
|
||||
/// game 16K (or less when the settings ask for less); always one request at a time (faster on a
|
||||
/// 16 GB card, M0; chat answers take turns with the voice answers).
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct Conf {
|
||||
pub context: u32,
|
||||
@@ -82,7 +77,7 @@ pub fn conf(settings: &Settings, stage: Stage) -> Conf {
|
||||
let vision = vision(stage, crate::screen::available(settings));
|
||||
match stage {
|
||||
Stage::Gaming => Conf { context: crate::placement::GAME_CONTEXT.min(settings.llm.context), parallel: 1, vision },
|
||||
_ => Conf { context: settings.llm.context, parallel: parallel(settings), vision },
|
||||
_ => Conf { context: settings.llm.context, parallel: 1, vision },
|
||||
}
|
||||
}
|
||||
|
||||
@@ -687,12 +682,12 @@ pub(crate) mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_chat_channel_answering_everything_gets_a_second_request_slot() {
|
||||
fn the_llm_takes_one_request_at_a_time_also_with_a_chat_channel_answering_everything() {
|
||||
let mut s = Settings::default();
|
||||
assert_eq!(parallel(&s), 1);
|
||||
s.chat_channels.push(ChatChannelSettings { id: 1, name: String::new(), description: String::new(), read: true,
|
||||
send: true, edit: true, react: true, delete: false, pin: false, answer_all: true, sync_discord: true });
|
||||
assert_eq!(parallel(&s), 2);
|
||||
let a = launch_args(&layout("llm-one"), &s, &conf(&s, Stage::Normal), &[]);
|
||||
assert_eq!(a[a.iter().position(|x| x == "--parallel").unwrap() + 1], "1");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -975,7 +970,7 @@ pub(crate) mod tests {
|
||||
|
||||
#[cfg(unix)]
|
||||
#[tokio::test]
|
||||
async fn the_measurement_is_kept_per_requests_at_once_and_per_card() {
|
||||
async fn the_measurement_is_kept_per_context_and_per_card() {
|
||||
let l = layout("llm-place-keys");
|
||||
let llm = Llm::with_exe(l.clone(), fake_placed(&l)).with_gpu(card(&l, "GPU-a", 0));
|
||||
let port = server_after_launch(&l, "list").await;
|
||||
@@ -983,13 +978,11 @@ pub(crate) mod tests {
|
||||
llm.start(&one).await.unwrap();
|
||||
assert_eq!(launches(&l).len(), 2, "measured once");
|
||||
llm.stop().await.unwrap();
|
||||
// A chat channel that answers everything: two requests at once, measured again.
|
||||
// Another context: measured again.
|
||||
std::fs::remove_file(l.data.join("calls")).unwrap();
|
||||
let two = parse_settings(&json!({"llm": {"port": port}, "chatChannels": [{"id": "123456789012345678", "answer": "everything"}]})).unwrap();
|
||||
assert_eq!(parallel(&two), 2);
|
||||
llm.start(&two).await.unwrap();
|
||||
assert_eq!(launches(&l).len(), 2, "measured for two at once");
|
||||
assert!(launches(&l)[0].contains("--parallel 2"));
|
||||
let short = parse_settings(&json!({"llm": {"port": port, "context": 16384}})).unwrap();
|
||||
llm.start(&short).await.unwrap();
|
||||
assert_eq!(launches(&l).len(), 2, "measured for the other context");
|
||||
llm.stop().await.unwrap();
|
||||
// Another card (same size): measured again.
|
||||
std::fs::remove_file(l.data.join("calls")).unwrap();
|
||||
@@ -997,7 +990,7 @@ pub(crate) mod tests {
|
||||
llm.start(&one).await.unwrap();
|
||||
assert_eq!(launches(&l).len(), 2, "measured for the new card");
|
||||
let probe: Value = serde_json::from_str(&std::fs::read_to_string(l.data.join("config").join("llm-probe.json")).unwrap()).unwrap();
|
||||
assert_eq!((probe["32768/1"]["gpu"].clone(), probe["32768/2"]["gpu"].clone()), (json!("GPU-b"), json!("GPU-a")));
|
||||
assert_eq!((probe["32768/1"]["gpu"].clone(), probe["16384/1"]["gpu"].clone()), (json!("GPU-b"), json!("GPU-a")));
|
||||
llm.stop().await.unwrap();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user