fix: feste GPUs durch Startprofil anzeigen, Hilfetext zum Speicherbedarf richtigstellen (#1272)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -103,6 +103,8 @@ struct ModelRow {
|
||||
embedding_modell: bool,
|
||||
/// Wer die GPUs bestimmt (#1272).
|
||||
gpu_wahl: GpuWahl,
|
||||
/// Das Startprofil hält das Modell fest; `gpu_wahl` ist dann ohne Wirkung.
|
||||
durch_profil: bool,
|
||||
/// Ergebnis des Embedding-Tests (#1184) und Vektorgröße.
|
||||
embedding: String,
|
||||
embedding_dim: Option<i64>,
|
||||
@ -166,6 +168,8 @@ fn model_rows(state: &AppState) -> Vec<ModelRow> {
|
||||
.ok()
|
||||
.flatten()
|
||||
.map_or(GpuWahl::Fest, |(wahl, _)| wahl),
|
||||
durch_profil: details.as_ref().is_some_and(|d| d.engine == "llama.cpp")
|
||||
&& store.startprofil_haelt_gpus_fest(&m.name).unwrap_or(false),
|
||||
systemprompt: store
|
||||
.model_systemprompt(&m.name)
|
||||
.ok()
|
||||
@ -423,6 +427,9 @@ fn models_table(state: &AppState, viewer: &Viewer, art: &str) -> String {
|
||||
} else {
|
||||
let symbole = super::faehigkeiten::gpu_symbole(&m.gpus);
|
||||
match m.gpu_wahl {
|
||||
_ if m.durch_profil => {
|
||||
format!("<span class=\"klein\">fest durch Startprofil</span> {symbole}")
|
||||
}
|
||||
GpuWahl::Fest => symbole,
|
||||
GpuWahl::Auto => format!("<span class=\"klein\">wählt</span> {symbole}"),
|
||||
GpuWahl::Alle => "<span class=\"klein\">automatisch</span>".to_string(),
|
||||
@ -492,7 +499,7 @@ fn modellkopf_block(state: &AppState, m: &ModelRow) -> String {
|
||||
.iter()
|
||||
.map(|g| (g.index, g.memory_total_mb))
|
||||
.collect();
|
||||
let gpus = if m.gpu_wahl == GpuWahl::Alle && !gesamt.is_empty() {
|
||||
let gpus = if m.gpu_wahl == GpuWahl::Alle && !m.durch_profil && !gesamt.is_empty() {
|
||||
gesamt.iter().map(|(index, _)| *index).collect()
|
||||
} else {
|
||||
eingetragen
|
||||
@ -520,9 +527,14 @@ fn gpu_felder(m: &ModelRow) -> String {
|
||||
if m.gpu_wahl == wahl { " selected" } else { "" }
|
||||
)
|
||||
};
|
||||
let ohne_wirkung = if m.durch_profil {
|
||||
"<b>Zurzeit ohne Wirkung:</b> Das Startprofil legt die Verteilung fest, deshalb gilt das Modell als fest. "
|
||||
} else {
|
||||
""
|
||||
};
|
||||
format!(
|
||||
"<label class=\"feld\"><span class=\"titel\">Wahl der Grafikkarten</span><select name=\"gpu_wahl\">{}{}{}</select>\
|
||||
<span class=\"hilfe\">Automatisch: Nexus nimmt beim Laden eine freie Karte, sonst mehrere, und verdrängt erst dann. \
|
||||
<span class=\"hilfe\">{ohne_wirkung}Automatisch: Nexus nimmt beim Laden eine freie Karte, sonst mehrere, und verdrängt erst dann. \
|
||||
Verteilungsangaben in den Startparametern halten das Modell fest. Gilt ab dem nächsten Laden.</span></label>\
|
||||
<label class=\"feld\"><span class=\"titel\">Grafikkarten</span><input name=\"gpus\" value=\"{}\" pattern=\"[0-9]+(, ?[0-9]+)*\" required>\
|
||||
<span class=\"hilfe\">Fest: genau diese. Automatisch unter diesen: die erlaubten. Bei „alle“ ohne Wirkung.</span></label>",
|
||||
@ -607,7 +619,7 @@ fn edit_dialog(state: &AppState, viewer: &Viewer, m: &ModelRow) -> String {
|
||||
<input type=\"hidden\" name=\"name\" value=\"{name}\">\
|
||||
<label class=\"feld\"><span class=\"titel\">Speicherbedarf (VRAM) in MB</span>\
|
||||
<input name=\"vram_mb\" type=\"number\" min=\"1\" max=\"1000000\" value=\"{vram}\" placeholder=\"unverändert\">\
|
||||
<span class=\"hilfe\">So viel reserviert der Scheduler je GPU, bis das Modell gemessen ist ({measured}). \
|
||||
<span class=\"hilfe\">So viel reserviert der Scheduler für das ganze Modell, bis es gemessen ist, auf mehreren Grafikkarten zu gleichen Teilen ({measured}). \
|
||||
Eine neue Angabe verwirft die Messung.</span></label>{gpu_felder}\
|
||||
<label class=\"feld\"><span class=\"titel\">Leerlauf bis zum Entladen in Minuten</span>\
|
||||
<input name=\"idle_min\" type=\"number\" min=\"0\" max=\"100000\" value=\"{idle}\" placeholder=\"Standard\">\
|
||||
@ -664,7 +676,14 @@ fn edit_dialog(state: &AppState, viewer: &Viewer, m: &ModelRow) -> String {
|
||||
.split(',')
|
||||
.filter_map(|g| g.trim().parse().ok())
|
||||
.collect();
|
||||
esc(&m.gpu_wahl.beschreibung(&liste))
|
||||
if m.durch_profil {
|
||||
esc(&format!(
|
||||
"{} (durch Startprofil)",
|
||||
GpuWahl::Fest.beschreibung(&liste)
|
||||
))
|
||||
} else {
|
||||
esc(&m.gpu_wahl.beschreibung(&liste))
|
||||
}
|
||||
},
|
||||
context = m
|
||||
.context
|
||||
|
||||
@ -946,6 +946,27 @@ async fn gpu_wahl_ist_in_oberflaeche_sichtbar_und_aenderbar() {
|
||||
assert_eq!((plan.gpu_wahl.as_str(), plan.gpus), ("fest", vec![1]));
|
||||
}
|
||||
|
||||
/// Verteilungsangaben im Startprofil halten das Modell fest; die Oberfläche darf dann nicht „automatisch“ sagen.
|
||||
#[tokio::test]
|
||||
async fn startprofil_mit_gpu_angabe_wird_als_fest_angezeigt() {
|
||||
let gw = gateway(0, false).await;
|
||||
waehlbares_modell(&gw, "waehlt", "/m/waehlt.gguf".into(), None);
|
||||
let (cookie, _) = ui_session(&gw, &gw.key_admin).await;
|
||||
let parameter = [("main_gpu".to_string(), "1".to_string())].into();
|
||||
gw.state
|
||||
.store()
|
||||
.save_start_parameters("waehlt", ¶meter, "test", false)
|
||||
.unwrap();
|
||||
let (_, _, seite) = ui_get(&gw, "/ui/modelle", Some(&cookie)).await;
|
||||
assert!(seite.contains("fest 0, 1 (durch Startprofil)"), "{seite}");
|
||||
assert!(seite.contains("fest durch Startprofil"), "{seite}");
|
||||
assert!(seite.contains("Zurzeit ohne Wirkung"), "{seite}");
|
||||
assert!(!seite.contains("automatisch unter 0, 1"), "{seite}");
|
||||
// Die gespeicherte Wahl bleibt für später erhalten.
|
||||
assert!(seite.contains("value=\"auto\" selected"), "{seite}");
|
||||
assert!(seite.contains("für das ganze Modell"), "{seite}");
|
||||
}
|
||||
|
||||
fn error_code(body: &Value) -> &str {
|
||||
body["error"]["code"].as_str().unwrap_or("")
|
||||
}
|
||||
|
||||
@ -93,6 +93,12 @@ impl GpuWahl {
|
||||
/// Modell als fest.
|
||||
const GPU_PARAMETER: [&str; 4] = ["gpu", "split_mode", "tensor_split", "main_gpu"];
|
||||
|
||||
fn haelt_gpus_fest(parameter: &std::collections::BTreeMap<String, String>) -> bool {
|
||||
GPU_PARAMETER
|
||||
.iter()
|
||||
.any(|name| parameter.contains_key(*name))
|
||||
}
|
||||
|
||||
/// Alles, was zum Starten einer Instanz nötig ist.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct StartPlan {
|
||||
@ -694,10 +700,7 @@ impl Store {
|
||||
gpus.len(),
|
||||
)
|
||||
.map_err(|e| Error::Config(e.into()))?;
|
||||
let gpu_wahl = if GPU_PARAMETER
|
||||
.iter()
|
||||
.any(|name| start_parameters.contains_key(*name))
|
||||
{
|
||||
let gpu_wahl = if haelt_gpus_fest(&start_parameters) {
|
||||
GpuWahl::Fest
|
||||
} else {
|
||||
GpuWahl::parse(&wahl)
|
||||
@ -726,6 +729,14 @@ impl Store {
|
||||
}))
|
||||
}
|
||||
|
||||
/// `true`, wenn das Startprofil Angaben zu bestimmten Karten enthält: Das Modell gilt dann als fest,
|
||||
/// gleich welche GPU-Wahl gespeichert ist.
|
||||
pub fn startprofil_haelt_gpus_fest(&self, model: &str) -> Result<bool> {
|
||||
Ok(self
|
||||
.start_parameters(model)?
|
||||
.is_some_and(|p| haelt_gpus_fest(&p)))
|
||||
}
|
||||
|
||||
/// Setzt oder entfernt die Angabe zum Arbeitsspeicher für alle Profile des Modells.
|
||||
pub fn set_profile_ram(&self, model: &str, ram_mb: Option<i64>) -> Result<bool> {
|
||||
let changed = self
|
||||
|
||||
@ -420,10 +420,24 @@ fn model_list(args: &[String]) -> Result<(), String> {
|
||||
Some(0) => "nie".to_string(),
|
||||
Some(secs) => format!("{} min", secs / 60),
|
||||
};
|
||||
let gpu = store
|
||||
.gpu_wahl(&m.name)
|
||||
let engine = store
|
||||
.model_details(&m.name)
|
||||
.map_err(|e| e.to_string())?
|
||||
.map_or("–".to_string(), |(wahl, gpus)| wahl.beschreibung(&gpus));
|
||||
.map(|d| d.engine);
|
||||
let durch_profil = engine.as_deref() == Some("llama.cpp")
|
||||
&& store
|
||||
.startprofil_haelt_gpus_fest(&m.name)
|
||||
.map_err(|e| e.to_string())?;
|
||||
let gpu = store.gpu_wahl(&m.name).map_err(|e| e.to_string())?.map_or(
|
||||
"–".to_string(),
|
||||
|(wahl, gpus)| {
|
||||
if durch_profil {
|
||||
format!("{} (durch Startprofil)", GpuWahl::Fest.beschreibung(&gpus))
|
||||
} else {
|
||||
wahl.beschreibung(&gpus)
|
||||
}
|
||||
},
|
||||
);
|
||||
println!(
|
||||
"{:<30} {:<10} {:<12} {:>10} {:>10} {:>9} {gpu}",
|
||||
m.name,
|
||||
|
||||
Reference in New Issue
Block a user