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.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
studio: stop the MiniMax-H3 refusal telling users to delete /usr/bin (#8569)
Daniel Hanfe37ed02e71b
diff --git a/studio/backend/core/inference/sd_cpp_backend.py b/studio/backend/core/inference/sd_cpp_backend.pyindex 84335a9394c..f0c3b92f9a8 100644--- a/studio/backend/core/inference/sd_cpp_backend.py+++ b/studio/backend/core/inference/sd_cpp_backend.py@@ -72,6 +72,7 @@ from core.inference.sd_cpp_engine import (find_sd_cpp_binary,find_sd_server_binary,is_managed_binary,+ legacy_sibling_install_root,managed_install_root,owning_managed_root,runtime_env,@@ -319,6 +320,35 @@ def sd_cpp_lists_accelerator_device(binary: Optional[str]) -> bool:return any(name.upper() != "CPU" for name in names)+def _h3_replacement_hint(binary: str) -> str:+ """The trailing "or delete it" clause of the H3 refusal, or "" when there is nothing to delete.++ Only a binary in a layout the installer writes to can be recovered by clearing that layout:+ ``install()`` refuses a non-empty unmarked target, so an empty one is what lets the next load+ put the pinned prebuilt there. Anything PATH or an env var named is elsewhere entirely. The+ refusal used to end with "or remove that directory" whatever the binary was, which for the+ ``/usr/bin/sd`` PATH discovery picks up read as "remove /usr/bin".++ MOVE, never remove. Only the caller's unowned branch reaches this, so a root that matches here+ necessarily carries no ownership marker -- it is the user's own build sitting at the path the+ installer would use, which ``is_managed_binary`` documents as a supported thing to do, and+ which a ``git clone`` of leejet's repo produces verbatim. Moving it aside frees the path+ without destroying anything, and the user can put it back.++ ``in_tree_install_root`` is not consulted at all: the installer never writes to+ ``<repo_root>/stable-diffusion.cpp``, so clearing it would buy nothing."""+ roots = [managed_install_root(), legacy_sibling_install_root()]+ for root in roots:+ if root is None:+ continue+ try:+ Path(binary).resolve().relative_to(root.resolve())+ except (OSError, ValueError):+ continue+ return f", or move {root} aside so Studio can install the pinned prebuilt there"+ return ""++def ensure_h3_sd_cpp_binary(*, allow_install: bool = True, accelerator: str = "cpu") -> Optional[str]:@@ -340,11 +370,11 @@ def ensure_h3_sd_cpp_binary(return binaryif not is_managed_binary(binary):raise RuntimeError(- f"The stable-diffusion.cpp build at {binary} predates MiniMax-H3 support (its --help "- f"does not list the H3 options), so generation would fail after the whole H3 bundle "- f"has downloaded. Point SD_CLI_PATH / UNSLOTH_SD_CPP_PATH at a build from "- f"master-812-ea7f0c8 or newer, or remove that directory so Studio installs the "- f"pinned prebuilt."+ f"The stable-diffusion.cpp binary at {binary} does not advertise MiniMax-H3 support "+ f"(its --help does not list the H3 options), so generation would fail after the whole "+ f"H3 bundle has downloaded. Point SD_CLI_PATH at a build from master-812-ea7f0c8 or "+ f"newer, or UNSLOTH_SD_CPP_PATH at the directory holding one"+ f"{_h3_replacement_hint(binary)}.")if not allow_install:# Ours, but replacing it is exactly what auto-install is switched off for.diff --git a/studio/backend/tests/test_sd_cpp_backend.py b/studio/backend/tests/test_sd_cpp_backend.pyindex ca2d507fd5d..779a04a86e3 100644--- a/studio/backend/tests/test_sd_cpp_backend.py+++ b/studio/backend/tests/test_sd_cpp_backend.py@@ -1034,9 +1034,55 @@ def test_h3_binary_gate_refuses_but_keeps_a_user_supplied_build(monkeypatch, tmpmonkeypatch.setattr(bk, "is_managed_binary", lambda _b: False)monkeypatch.setattr(bk, "_sd_cpp_probe_output", lambda *_args: _PRE_H3_HELP)- with pytest.raises(RuntimeError, match = "predates MiniMax-H3"):+ with pytest.raises(RuntimeError, match = "does not advertise MiniMax-H3") as excinfo:bk.ensure_h3_sd_cpp_binary()assert own.exists()+ # Not Studio's to delete, so the refusal must not ask for anything to be removed. The old+ # wording said "remove that directory" whatever the binary was, and PATH discovery hands this+ # branch /usr/bin/sd, i.e. it read as "remove /usr/bin".+ assert "remove" not in str(excinfo.value)+ assert str(own) in str(excinfo.value)+++def test_h3_binary_gate_offers_to_clear_an_unmarked_install_directory(monkeypatch, tmp_path):+ # The one case where clearing the path IS the fix: a build in a layout the installer writes to.+ # It has no ownership marker (or the branch above would own it), so it is the user's own build+ # at the installer's path: offer to MOVE it, never to delete it.+ root = tmp_path / "studio" / "stable-diffusion.cpp"+ own = root / "sd-cli"+ root.mkdir(parents = True)+ own.write_text("binary")+ monkeypatch.setattr(bk, "managed_install_root", lambda: root)+ monkeypatch.setattr(bk, "ensure_sd_cpp_binary", lambda **_kwargs: str(own))+ monkeypatch.setattr(bk, "is_managed_binary", lambda _b: False)+ monkeypatch.setattr(bk, "_sd_cpp_probe_output", lambda *_args: _PRE_H3_HELP)++ with pytest.raises(RuntimeError, match = "does not advertise MiniMax-H3") as excinfo:+ bk.ensure_h3_sd_cpp_binary()+ assert f"move {root} aside" in str(excinfo.value)+ assert "remove" not in str(excinfo.value)+ assert own.exists()+++def test_h3_binary_gate_never_offers_to_delete_the_in_tree_developer_build(monkeypatch, tmp_path):+ # <repo_root>/stable-diffusion.cpp is the developer-build fallback, and a git clone of+ # leejet's repo lands exactly there. Deleting it takes the user's source checkout and no+ # reinstall follows, so it is never offered.+ root = tmp_path / "repo" / "stable-diffusion.cpp"+ own = root / "build" / "bin" / "sd-cli"+ own.parent.mkdir(parents = True)+ own.write_text("binary")+ # raising = False because the hint does not import it. The patch is what makes this a+ # regression guard: re-add the root to _h3_replacement_hint and it resolves to this tree.+ monkeypatch.setattr(bk, "in_tree_install_root", lambda: root, raising = False)+ monkeypatch.setattr(bk, "ensure_sd_cpp_binary", lambda **_kwargs: str(own))+ monkeypatch.setattr(bk, "is_managed_binary", lambda _b: False)+ monkeypatch.setattr(bk, "_sd_cpp_probe_output", lambda *_args: _PRE_H3_HELP)++ with pytest.raises(RuntimeError, match = "does not advertise MiniMax-H3") as excinfo:+ bk.ensure_h3_sd_cpp_binary()+ assert "remove" not in str(excinfo.value)+ assert own.exists()def test_h3_binary_gate_keeps_a_binary_it_cannot_probe(monkeypatch):diff --git a/studio/backend/tests/test_video_backend.py b/studio/backend/tests/test_video_backend.pyindex c27ed8999c4..a06986a178e 100644--- a/studio/backend/tests/test_video_backend.py+++ b/studio/backend/tests/test_video_backend.py@@ -3597,7 +3597,7 @@ def test_h3_native_load_refuses_a_binary_that_predates_h3(monkeypatch, tmp_path)backend = VideoBackend()fam = _detect_load_family("leejet/MiniMax-H3-GGUF", None, "minimax-h3")assert fam is not None- with pytest.raises(RuntimeError, match = "predates MiniMax-H3"):+ with pytest.raises(RuntimeError, match = "does not advertise MiniMax-H3"):backend._run_load_h3_native(fam = fam,token = None,