The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(motor): die Flash-Attention-Sprosse behaelt die gemessene Schichtzahl (R1-1)
purplec454d4d71d7b
diff --git a/src-tauri/src/commands/engine.rs b/src-tauri/src/commands/engine.rsindex 1f30de28..15351c9e 100644--- a/src-tauri/src/commands/engine.rs+++ b/src-tauri/src/commands/engine.rs@@ -2142,10 +2142,22 @@ fn serve_or_heal_garbled(};// A restart is a measurement thrown away: whatever `plan_offload` said// for the first start is not asked again, because the argument that is- // being changed is not the layer count. `None` for `auto_ngl` keeps the- // layer count out of the way, and the rung above puts the one value it- // cares about into the tuning.- let next_args = build_server_args(model_path, &next, port, slot_dir, mmproj, None);+ // being changed is not the layer count. So the layer count the engine+ // is actually running with is carried across instead of dropped, read+ // from the argv that was spawned, exactly as `facts.gpu_layers` above+ // reads it. `None` here would hand the sentinel to the flash attention+ // rung: a card measured at twelve layers would be asked for all of+ // them on the very restart that is meant to rescue it. On the+ // processor rung it changes nothing, `gpu_layers: 0` is a typed number+ // and outranks `auto_ngl` in `build_server_args`.+ let next_args = build_server_args(+ model_path,+ &next,+ port,+ slot_dir,+ mmproj,+ gpu_layers_in(&serving_args),+ );stop_engine_locked(state);// A restart is never an auto layer count, whatever the request said, so// the idempotence key must not remember it as one: the next start with@@ -3862,19 +3874,81 @@ mod tests {#[test]fn the_flash_attention_rung_moves_only_that_one_flag() {- // The first rung of the ladder. The card keeps every layer; the only- // difference in the argv is the `-fa` pair.+ // The first rung of the ladder. The card keeps the layer count it was+ // measured at; the only difference in the argv is the `-fa` pair.+ //+ // The rung is built the way production builds it: the layer count is+ // not typed in here a second time, it is read back out of the argv the+ // running engine got, which is what `serve_or_heal_garbled` does.let auto = EngineTuning { ctx: 4096, threads: 6, ..Default::default() };assert_eq!(auto.flash_attn, "auto");let before = build_server_args("/m.gguf", &auto, 8127, None, None, Some(12));- let after =- build_server_args("/m.gguf", &without_flash_attention(&auto), 8127, None, None, Some(12));+ let after = build_server_args(+ "/m.gguf",+ &without_flash_attention(&auto),+ 8127,+ None,+ None,+ gpu_layers_in(&before),+ );assert!(!before.iter().any(|a| a == "-fa"), "auto is not forwarded: {before:?}");assert_eq!(after.windows(2).find(|w| w[0] == "-fa").map(|w| w[1].as_str()), Some("off"));assert_eq!(gpu_layers_in(&after), Some(12));let stripped: Vec<String> =after.iter().filter(|a| *a != "-fa" && *a != "off").cloned().collect();assert_eq!(stripped, before);+ // Negative control, the two ways this can go wrong. `None` on a tuning+ // that left GPU Layers on auto is the sentinel, 999 layers on a card+ // that was just measured at twelve; and the processor rung is not+ // touched by any of it, a typed 0 outranks `auto_ngl`.+ assert_eq!(+ gpu_layers_in(&build_server_args(+ "/m.gguf",+ &without_flash_attention(&auto),+ 8127,+ None,+ None,+ None+ )),+ Some(999)+ );+ assert_eq!(+ gpu_layers_in(&build_server_args(+ "/m.gguf",+ &on_the_processor(&auto),+ 8127,+ None,+ None,+ Some(12)+ )),+ Some(0)+ );+ // Quellanker, sonst ist der Test blind: er baut die Sprosse selbst und+ // wuerde gruen bleiben, waehrend die Produktionszeile weiter `None`+ // schickt. `split` schneidet den Rumpf der echten Funktion heraus, die+ // Suchbegriffe stehen zwar auch in diesem Test, aber nicht darin.+ let leiter = include_str!("engine.rs")+ .split("fn serve_or_heal_garbled(")+ .nth(1)+ .expect("the ladder is gone")+ .split("\nfn ")+ .next()+ .unwrap();+ let sprosse = leiter+ .split("let next_args = build_server_args(")+ .nth(1)+ .expect("the rung no longer builds its own argv")+ .split(");")+ .next()+ .unwrap();+ assert!(+ sprosse.contains("gpu_layers_in(&serving_args)"),+ "the restart throws the measured layer count away: {sprosse}"+ );+ assert!(+ !sprosse.contains("None"),+ "the restart hands the sentinel to the rung again: {sprosse}"+ );}#[test]