Studio: don't kill chat-model llama-server when spawning helper backends
This commit is contained in:
parent
aedede2f2e
commit
af7917c45a
3 changed files with 24 additions and 4 deletions
|
|
@ -608,7 +608,19 @@ class LlamaCppBackend:
|
|||
3. unload_model() — terminates llama-server subprocess
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, kill_orphans: bool = True):
|
||||
"""Construct a backend wrapper around llama-server.
|
||||
|
||||
``kill_orphans`` (default True): at construction time, reap any
|
||||
llama-server processes lingering from a prior studio crash. Safe
|
||||
for the global singleton (only one LlamaCppBackend exists at
|
||||
startup). Pass ``False`` for short-lived secondary instances
|
||||
spawned alongside an already-running chat-model server (e.g.
|
||||
the RAG captioner helper, `_run_with_helper`) — otherwise the
|
||||
constructor will kill the parent's healthy chat model because
|
||||
it can't distinguish "another instance's healthy server" from
|
||||
"a stale process".
|
||||
"""
|
||||
self._process: Optional[subprocess.Popen] = None
|
||||
self._port: Optional[int] = None
|
||||
self._model_identifier: Optional[str] = None
|
||||
|
|
@ -691,7 +703,8 @@ class LlamaCppBackend:
|
|||
# to decide whether to wait for the VRAM reclaim to finish.
|
||||
self._last_kill_monotonic: float = 0.0
|
||||
|
||||
self._kill_orphaned_servers()
|
||||
if kill_orphans:
|
||||
self._kill_orphaned_servers()
|
||||
atexit.register(self._cleanup)
|
||||
|
||||
# ── Properties ────────────────────────────────────────────────
|
||||
|
|
|
|||
|
|
@ -74,7 +74,12 @@ def _load_helper_vlm() -> Optional[tuple[Any, str, str]]:
|
|||
try:
|
||||
from core.inference.llama_cpp import LlamaCppBackend
|
||||
|
||||
backend = LlamaCppBackend()
|
||||
# kill_orphans=False is critical: the global singleton is
|
||||
# already running the user's chat-model llama-server. Killing
|
||||
# "orphans" here would reap that healthy chat process because
|
||||
# the orphan-killer can't tell two LlamaCppBackend instances
|
||||
# apart by PID ownership.
|
||||
backend = LlamaCppBackend(kill_orphans = False)
|
||||
logger.info(
|
||||
"RAG captioner: loading helper VLM %s (%s) as fallback",
|
||||
_HELPER_REPO,
|
||||
|
|
|
|||
|
|
@ -155,7 +155,9 @@ def _run_with_helper(prompt: str, max_tokens: int = 256) -> Optional[str]:
|
|||
try:
|
||||
from core.inference.llama_cpp import LlamaCppBackend
|
||||
|
||||
backend = LlamaCppBackend()
|
||||
# kill_orphans=False so the helper backend doesn't reap the
|
||||
# parent's chat-model llama-server while loading itself.
|
||||
backend = LlamaCppBackend(kill_orphans = False)
|
||||
logger.info(f"Loading helper model: {repo} ({variant})")
|
||||
|
||||
ok = backend.load_model(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue