Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

studio: fix cancel to actually kill llama-server during loading

Daniel Han226ece0c9e0e
diff --git a/studio/backend/core/inference/llama_cpp.py b/studio/backend/core/inference/llama_cpp.py
index c222b43a9f5..d1c943ee16a 100644
--- a/studio/backend/core/inference/llama_cpp.py
+++ b/studio/backend/core/inference/llama_cpp.py
@@ -58,6 +58,11 @@ class LlamaCppBackend:
def is_loaded(self) -> bool:
return self._process is not None and self._healthy
+ @property
+ def is_active(self) -> bool:
+ """True if a llama-server process exists (loading or loaded)."""
+ return self._process is not None
+
@property
def base_url(self) -> str:
return f"http://127.0.0.1:{self._port}"
diff --git a/studio/backend/routes/inference.py b/studio/backend/routes/inference.py
index e9ad9a69958..5299d168f5c 100644
--- a/studio/backend/routes/inference.py
+++ b/studio/backend/routes/inference.py
@@ -343,11 +343,11 @@ async def unload_model(
Routes to the correct backend (llama-server for GGUF, Unsloth otherwise).
"""
try:
- # Check if the GGUF backend has this model loaded
+ # Check if the GGUF backend has this model loaded or is loading it
llama_backend = get_llama_cpp_backend()
- if (
- llama_backend.is_loaded
- and llama_backend.model_identifier == request.model_path
+ if llama_backend.is_active and (
+ llama_backend.model_identifier == request.model_path
+ or not llama_backend.is_loaded
):
llama_backend.unload_model()
logger.info(f"Unloaded GGUF model: {request.model_path}")