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: make llama-fit-params executable after the macOS prebuilt install (#12917)
Jay Zhou6a25e672f50e
diff --git a/studio/install_llama_prebuilt.py b/studio/install_llama_prebuilt.pyindex 5712deb22ad..3059dcaa5c9 100644--- a/studio/install_llama_prebuilt.py+++ b/studio/install_llama_prebuilt.py@@ -5441,6 +5441,17 @@ def activate_install_tree(staging_dir: Path, install_dir: Path, host: HostInfo)prune_install_staging_root(install_dir)+def ensure_fit_params_executable(install_dir: Path) -> None:+ """The guarded extractor leaves the optional Metal probe 0644 (#12901); reuse paths repair old installs."""+ helper = install_dir / "build" / "bin" / "llama-fit-params"+ try:+ if helper.is_file() and not helper.is_symlink():+ if stat.S_IMODE(helper.stat().st_mode) & 0o111 != 0o111:+ os.chmod(helper, 0o755)+ except OSError:+ pass++def install_from_archives(choice: AssetChoice, host: HostInfo, install_dir: Path, work_dir: Path) -> tuple[Path, Path]:@@ -5527,6 +5538,7 @@ def install_from_archives(raise PrebuiltFallback("unix executables were not installed correctly into build/bin")os.chmod(source_server, 0o755)os.chmod(source_quantize, 0o755)+ ensure_fit_params_executable(install_dir)root_server = install_dir / "llama-server"root_quantize = install_dir / "llama-quantize"@@ -11309,6 +11321,7 @@ def install_prebuilt(# honour; a request read back off the marker retries when something moves.backend_request_mandatory = backend_mandatory,):+ ensure_fit_params_executable(install_dir)return# A request detection had to replace; kept so the marker records the CHOICE.unhonoured_request: str | None = None@@ -11345,6 +11358,7 @@ def install_prebuilt(plan: InstallReleasePlan, reused: AssetChoice, used_fallback: bool) -> None:"""Update selection fields when the existing bundle is reused."""+ ensure_fit_params_executable(install_dir)sync_marker_selection(install_dir,choice = reused,@@ -11511,6 +11525,7 @@ def install_prebuilt():log("prebuilt update unavailable; keeping the existing complete install")log(f"prebuilt update reason: {exc}")+ ensure_fit_params_executable(install_dir)returnlog("prebuilt install failed; preserving the selected backend"diff --git a/tests/studio/install/test_install_llama_prebuilt_logic.py b/tests/studio/install/test_install_llama_prebuilt_logic.pyindex ea7a1fae6a3..d9a4a9246af 100644--- a/tests/studio/install/test_install_llama_prebuilt_logic.py+++ b/tests/studio/install/test_install_llama_prebuilt_logic.py@@ -4089,6 +4089,112 @@ def test_linux_runtime_overlay_copies_llama_tool_impl_libraries(tmp_path: Path)assert not (runtime_dir / "llama-cli").exists()[email protected](os.name == "nt", reason = "Windows st_mode carries no POSIX mode bits")[email protected]("bundles_fit_params", [True, False])+def test_macos_install_makes_llama_fit_params_executable(+ tmp_path: Path, bundles_fit_params: bool+) -> None:+ """#12901: the guarded extractor drops archive modes, so the optional Metal+ probe must be chmod'ed like llama-server, and bundles without it still install."""+ install_from_archives = INSTALL_LLAMA_PREBUILT.install_from_archives++ work = tmp_path / "work"+ install = tmp_path / "install"+ archives = tmp_path / "archives"+ work.mkdir()+ install.mkdir()+ archives.mkdir()++ names = ["llama-server", "llama-quantize", "libllama.dylib", "libggml.dylib"]+ if bundles_fit_params:+ names.append("llama-fit-params")+ bundle = archives / "llama-b9001-bin-macos-arm64.tar.gz"+ with tarfile.open(bundle, "w:gz") as archive:+ for name in names:+ add_bytes_to_tar(archive, name, f"{name}\n".encode(), mode = 0o755)++ import hashlib++ choice = asset_choice(+ name = bundle.name,+ source_label = "published",+ install_kind = "macos-arm64",+ expected_sha256 = hashlib.sha256(bundle.read_bytes()).hexdigest(),+ )++ orig_download = INSTALL_LLAMA_PREBUILT.download_file_verified++ def fake_download(url, target_path, **kw):+ shutil.copy2(bundle, target_path)++ INSTALL_LLAMA_PREBUILT.download_file_verified = fake_download+ try:+ install_from_archives(choice, macos_host(), install, work)+ finally:+ INSTALL_LLAMA_PREBUILT.download_file_verified = orig_download++ fit_params = install / "build" / "bin" / "llama-fit-params"+ if bundles_fit_params:+ assert stat.S_IMODE(fit_params.stat().st_mode) == 0o755+ else:+ assert not fit_params.exists()++[email protected](os.name == "nt", reason = "Windows st_mode carries no POSIX mode bits")[email protected]("skip_path", ["no_network_check", "plan_match"])+def test_a_reused_install_repairs_a_non_executable_llama_fit_params(+ tmp_path: Path, monkeypatch, skip_path: str+) -> None:+ """#12901: installs made before the fix keep a 0644 probe, and an update on the same+ release returns before any extraction, so the skip paths must restore the bit."""+ M = INSTALL_LLAMA_PREBUILT+ install_dir = tmp_path / "llama.cpp"+ helper = install_dir / "build" / "bin" / "llama-fit-params"+ helper.parent.mkdir(parents = True)+ helper.write_bytes(b"probe\n")+ helper.chmod(0o644)++ host = macos_host()+ choice = asset_choice(name = "llama-b9001-bin-macos-arm64.tar.gz", install_kind = "macos-arm64")+ release_plan = M.InstallReleasePlan(+ requested_tag = "latest",+ llama_tag = "b9001",+ release_tag = "release-1",+ attempts = [choice],+ approved_checksums = release_checksums((choice.name, choice.expected_sha256, UPSTREAM)),+ )+ route = types.SimpleNamespace(+ host = host, backend = "auto", published_repo = "unslothai/llama.cpp", published_release_tag = ""+ )+ monkeypatch.setattr(M, "route_backend_request", lambda **_k: route)+ monkeypatch.setattr(+ M,+ "existing_install_current_without_plan",+ lambda *_a, **_k: skip_path == "no_network_check",+ )+ monkeypatch.setattr(+ M,+ "select_backend_install",+ lambda **_k: M.BackendSelection(+ backend = "auto",+ host = host,+ published_repo = "unslothai/llama.cpp",+ published_release_tag = "",+ requested_tag = "latest",+ release_plans = [release_plan],+ persist_llama_backend = None,+ persist_rocm_gfx = None,+ ),+ )+ monkeypatch.setattr(M, "existing_install_matches_plan", lambda *_a, **_k: True)+ monkeypatch.setattr(M, "diffusion_visual_server_backfill_needed", lambda *_a, **_k: False)+ monkeypatch.setattr(M, "sync_marker_selection", lambda *_a, **_k: None)++ M.install_prebuilt(install_dir, "latest", "unslothai/llama.cpp", "")++ assert stat.S_IMODE(helper.stat().st_mode) == 0o755++def test_python_runtime_dirs_covers_cu13_and_library_bin(monkeypatch, tmp_path: Path) -> None:"""Installer DLL discovery must scan the same path set as the backend (cu12/cu13/conda layouts + torch/lib)."""import site as _site@@ -5121,6 +5227,26 @@ def test_release_listing_failure_keeps_a_complete_existing_install(tmp_path, monassert (install_dir / "llama-server").exists()[email protected](os.name == "nt", reason = "Windows st_mode carries no POSIX mode bits")+def test_an_offline_keep_repairs_a_non_executable_llama_fit_params(tmp_path, monkeypatch):+ """#12901: an update that cannot reach the release keeps the tree, so it must repair the probe too."""++ def boom(*args, **kwargs):+ raise urllib.error.URLError("connection reset")++ monkeypatch.setattr(INSTALL_LLAMA_PREBUILT, "_fork_manifest_release_plans", boom)+ monkeypatch.setattr(INSTALL_LLAMA_PREBUILT, "detect_host", linux_host)++ install_dir = _complete_existing_llama_install(tmp_path)+ helper = install_dir / "build" / "bin" / "llama-fit-params"+ helper.write_bytes(b"probe\n")+ helper.chmod(0o644)++ install_prebuilt(install_dir, "latest", "unslothai/llama.cpp", "")++ assert stat.S_IMODE(helper.stat().st_mode) == 0o755++def test_release_listing_failure_does_not_keep_a_non_executable_install(tmp_path, monkeypatch):"""Do not keep a tree that fails setup.sh's executable reuse gate."""