mirror of
https://github.com/R0m1k3/Loki.git
synced 2026-10-23 15:08:16 +02:00
Auto-réglage GPU : détection, num_ctx optimal et bouton Réglage auto
Backend : - agent_config : num_ctx dans la config, envoyé à Ollama (0 = défaut modèle) - ollama_client : méthode ps() (placement GPU/CPU via /api/ps) - autotune : placement() lit size vs size_vram pour savoir si le modèle est sur GPU - routes/config : POST /api/config/auto (détecte GPU + modèle, calcule et applique num_ctx/max_tokens, renvoie la détection et le placement) Frontend : - client/store : autoTune(), état tuning + résultat - SettingsView : bouton ⚡ Réglage auto, bannière de détection (GPU/VRAM, contexte, placement GPU/CPU), slider Contexte (num_ctx) Config : - GPU_VRAM_MB / GPU_NAME pour déclarer la VRAM si Ollama est distant Tests : recommandation (8B sur 12 Go -> ctx 32768), route /auto + persistance, transmission num_ctx aux options Ollama, placement via /api/ps. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SVay7z3y7q2gEe54ByAE6N
This commit is contained in:
10 files changed
+231
-5
No files matched your search
@@ -210,6 +210,31 @@ async def recommend(model: str) -> dict:
|
||||
}
|
||||
|
||||
|
||||
async def placement(model: str) -> dict:
|
||||
"""Lit /api/ps : le modèle est-il chargé sur GPU, CPU, ou un mix ?"""
|
||||
try:
|
||||
loaded = await ollama.ps()
|
||||
except (httpx.HTTPError, OSError):
|
||||
return {"loaded": False}
|
||||
|
||||
for m in loaded:
|
||||
if m.get("name") == model or m.get("model") == model:
|
||||
size = m.get("size", 0) or 0
|
||||
size_vram = m.get("size_vram", 0) or 0
|
||||
if size <= 0:
|
||||
where = "inconnu"
|
||||
elif size_vram >= size * 0.99:
|
||||
where = "gpu"
|
||||
elif size_vram <= size * 0.01:
|
||||
where = "cpu"
|
||||
else:
|
||||
where = "mixte"
|
||||
pct = int(size_vram / size * 100) if size else 0
|
||||
return {"loaded": True, "where": where, "gpu_percent": pct,
|
||||
"size_mb": size // (1024 * 1024)}
|
||||
return {"loaded": False}
|
||||
|
||||
|
||||
def _fallback_model_mb(prof: dict) -> int:
|
||||
"""Estime la taille des poids si /api/tags n'a rien donné."""
|
||||
ps = (prof.get("parameter_size") or "").upper().replace("B", "")
|
||||
|
||||
Reference in new issue
Block a user