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
Fix Windows Whisper slim pairing on GPU llama runtimes (ROCm, CUDA, Vulkan) (#8379)
Lee Jackson86e02ebc1325
diff --git a/studio/install_whisper_prebuilt.py b/studio/install_whisper_prebuilt.pyindex 6282aa98092..6107cfcd927 100644--- a/studio/install_whisper_prebuilt.py+++ b/studio/install_whisper_prebuilt.py@@ -160,7 +160,9 @@ SLIM_BACKEND_MODULE_GLOBS = {},"cuda": {"linux": "libggml-cuda.so*", "windows": "ggml-cuda.dll"},"metal": {"macos": "libggml-metal*.dylib"},- "rocm": {"linux": "libggml-hip.so*", "windows": "*hip*.dll"},+ # Windows rocm must name the ggml module: the bundles also ship amdhip64,+ # hipblas and libhipblaslt, which a looser *hip*.dll would accept.+ "rocm": {"linux": "libggml-hip.so*", "windows": "ggml-hip*.dll"},"vulkan": {"linux": "libggml-vulkan.so*", "windows": "ggml-vulkan.dll"},}@@ -387,6 +389,18 @@ def llama_runtime_pairs(return commit is not None and commit == _llama_ggml_commit(required_tag)+def _ships_windows_gpu_ggml_module(llama_bin_dir: Path) -> bool:+ """Whether a paired Windows llama runtime carries a GPU ggml backend module.+ Only the cpu bundle links ggml against libomp, and bundle_profile cannot tell+ the two apart: it is absent on both the published rocm artifacts and every+ upstream-sourced install, so the files on disk decide."""+ for backend, per_os in SLIM_BACKEND_MODULE_GLOBS.items():+ glob = per_os.get("windows")+ if backend != "cpu" and glob and any(llama_bin_dir.glob(glob)):+ return True+ return False++def slim_pairing_for_artifact(artifact: dict[str, Any], host: HostInfo, backend: str) -> tuple[Path, str] | None:@@ -415,7 +429,21 @@ def slim_pairing_for_artifact(if not isinstance(sonames, list) or not sonames:log(f"slim_selection: {asset} skipped: manifest lists no requires_ggml_sonames")return None- missing = [str(name) for name in sonames if not (llama_bin_dir / str(name)).is_file()]+ required_sonames = [str(name) for name in sonames]+ if host.is_windows and _ships_windows_gpu_ggml_module(llama_bin_dir):+ # The shared Windows manifest lists libomp only because the cpu bundle's+ # ggml links against it; a GPU bundle neither ships nor imports it, so+ # requiring it there only mis-rejects. link_ggml_runtime still wires it.+ # This drops libomp140.aarch64.dll as readily as the x64 name, which is+ # safe only while llama publishes no Windows arm64 GPU bundle: that slice+ # is clang-built and its ggml really does need LLVM OpenMP (see+ # SLIM_GGML_LIBRARY_GLOBS). Re-check this gate before adding one.+ required_sonames = [+ name+ for name in required_sonames+ if not (name.lower().startswith("libomp") and name.lower().endswith(".dll"))+ ]+ missing = [name for name in required_sonames if not (llama_bin_dir / name).is_file()]if missing:log(f"slim_selection: {asset} skipped: llama runtime missing {', '.join(missing)}")return Nonediff --git a/tests/studio/install/test_install_whisper_prebuilt_logic.py b/tests/studio/install/test_install_whisper_prebuilt_logic.pyindex 0eba6e265f9..979df2b38f6 100644--- a/tests/studio/install/test_install_whisper_prebuilt_logic.py+++ b/tests/studio/install/test_install_whisper_prebuilt_logic.py@@ -304,7 +304,8 @@ def test_install_produces_colocated_layout_and_marker(tmp_path, monkeypatch):server = install_dir / "build" / "bin" / "whisper-server"assert server.is_file()- assert server.stat().st_mode & 0o111 # +x set on unix+ if sys.platform != "win32":+ assert server.stat().st_mode & 0o111 # +x, POSIX only# every shared lib from the archive is co-located next to the serverassert (install_dir / "build" / "bin" / "libwhisper.so").is_file()assert (install_dir / "build" / "bin" / "libggml-base.so").is_file()@@ -552,6 +553,8 @@ def _cuda_host() -> HostInfo:def test_installed_llama_runtime_reads_marker(tmp_path):root = tmp_path / "llama.cpp"bin_dir = root / "build" / "bin"+ if sys.platform == "win32":+ bin_dir = bin_dir / "Release" # the layout installed_llama_runtime resolves on ntbin_dir.mkdir(parents = True)(root / "UNSLOTH_PREBUILT_INFO.json").write_text(json.dumps({"release_tag": SLIM_LLAMA_TAG, "bundle_profile": "cuda13-newer"})@@ -667,32 +670,165 @@ def test_slim_cpu_requires_a_cpu_module(tmp_path, monkeypatch):WIN_SLIM_ASSET = "whisper-v1.9.1-unsloth.1-windows-x64-slim.zip"-def test_slim_selected_for_cpu_backend_on_windows(tmp_path, monkeypatch):- bin_dir = tmp_path / "llama.cpp" / "build" / "bin" / "Release"- bin_dir.mkdir(parents = True)- for name in ("ggml.dll", "ggml-base.dll", "ggml-cpu-haswell.dll"):- (bin_dir / name).write_bytes(b"ggml")- monkeypatch.setattr(- M, "installed_llama_runtime", lambda: (bin_dir, SLIM_LLAMA_TAG, "windows-cpu")- )- manifest = M.parse_manifest(+def _windows_slim_manifest(*, requires_ggml_sonames: list[str]) -> dict:+ return M.parse_manifest(_manifest([_slim_artifact(os = "windows",arch = "x64",asset = WIN_SLIM_ASSET,- requires_ggml_sonames = ["ggml.dll", "ggml-base.dll"],+ requires_ggml_sonames = requires_ggml_sonames,)]))+++def test_slim_selected_for_cpu_backend_on_windows(tmp_path, monkeypatch):+ bin_dir = tmp_path / "llama.cpp" / "build" / "bin" / "Release"+ bin_dir.mkdir(parents = True)+ for name in ("ggml.dll", "ggml-base.dll", "ggml-cpu-haswell.dll"):+ (bin_dir / name).write_bytes(b"ggml")+ monkeypatch.setattr(+ M, "installed_llama_runtime", lambda: (bin_dir, SLIM_LLAMA_TAG, "windows-cpu")+ )+ manifest = _windows_slim_manifest(requires_ggml_sonames = ["ggml.dll", "ggml-base.dll"])artifact, backend, _fb = M.select_artifact_with_fallback(manifest, _host("windows", "x64"), "cpu")assert artifact["asset"] == WIN_SLIM_ASSET and backend == "cpu"+WIN_LIBOMP_SONAMES = ["ggml.dll", "ggml-base.dll", "libomp140.x86_64.dll"]++WIN_GPU_BUNDLES = [+ ("rocm", "ggml-hip.dll", {"has_rocm": True, "rocm_gfx": "gfx1150"}),+ ("cuda", "ggml-cuda.dll", {"has_usable_nvidia": True}),+ ("vulkan", "ggml-vulkan.dll", {}),+ # The cpu backend on a GPU bundle: the exemption keys on what the paired bin+ # dir holds, not on the request, and that bundle's ggml-cpu.dll has no libomp+ # to find either, so this must pair outright rather than via a cpu retry.+ ("cpu", "ggml-hip.dll", {}),+]++[email protected]("backend, module, host_kwargs", WIN_GPU_BUNDLES)+def test_windows_gpu_slim_does_not_require_cpu_only_libomp(+ tmp_path, monkeypatch, backend, module, host_kwargs+):+ # The shared Windows manifest lists the OpenMP runtime only the cpu llama+ # bundle ships; the GPU bundles omit it and never import it, so they pair.+ # The empty bundle_profile is what the published rocm artifacts carry.+ bin_dir = tmp_path / "llama.cpp" / "build" / "bin" / "Release"+ bin_dir.mkdir(parents = True)+ for name in ("ggml.dll", "ggml-base.dll", "ggml-cpu.dll", module):+ (bin_dir / name).write_bytes(b"ggml")+ monkeypatch.setattr(M, "installed_llama_runtime", lambda: (bin_dir, SLIM_LLAMA_TAG, ""))+ manifest = _windows_slim_manifest(requires_ggml_sonames = WIN_LIBOMP_SONAMES)++ artifact, chosen, used_fallback = M.select_artifact_with_fallback(+ manifest, _host("windows", "x64", **host_kwargs), backend+ )++ assert artifact["asset"] == WIN_SLIM_ASSET+ assert chosen == backend and used_fallback is False+++# "" is the upstream-sourced install: install_llama_prebuilt builds those+# AssetChoices without a bundle_profile, so a real cpu bundle reports no profile.[email protected]("profile", ["windows-cpu-x64", ""])+def test_windows_cpu_bundle_still_requires_manifest_libomp(tmp_path, monkeypatch, profile):+ # A cpu bundle's ggml really does import libomp, so a runtime that lost the+ # DLL must fail the pairing rather than install a whisper that cannot load.+ bin_dir = tmp_path / "llama.cpp" / "build" / "bin" / "Release"+ bin_dir.mkdir(parents = True)+ for name in ("ggml.dll", "ggml-base.dll", "ggml-cpu-haswell.dll"):+ (bin_dir / name).write_bytes(b"ggml")+ monkeypatch.setattr(M, "installed_llama_runtime", lambda: (bin_dir, SLIM_LLAMA_TAG, profile))+ artifact = _windows_slim_manifest(requires_ggml_sonames = WIN_LIBOMP_SONAMES)["artifacts"][0]++ assert M.slim_pairing_for_artifact(artifact, _host("windows", "x64"), "cpu") is None++ (bin_dir / "libomp140.x86_64.dll").write_bytes(b"omp")+ assert M.slim_pairing_for_artifact(artifact, _host("windows", "x64"), "cpu") is not None+++def test_linux_slim_still_requires_manifest_libomp(tmp_path, monkeypatch):+ # The exemption is Windows only: llama's clang-built linux slices bundle+ # libomp beside a libggml-base that really imports it, so it stays mandatory.+ bin_dir = _fake_llama_bin(tmp_path, backend_module = "libggml-cuda.so")+ monkeypatch.setattr(+ M, "installed_llama_runtime", lambda: (bin_dir, SLIM_LLAMA_TAG, "linux-cuda")+ )+ artifact = _slim_artifact(+ requires_ggml_sonames = ["libggml.so.0", "libggml-base.so.0", "libomp.so.5"],+ )++ assert M.slim_pairing_for_artifact(artifact, _host("linux", "x64"), "cuda") is None+++ "missing_name",+ ["ggml.dll", "ggml-base.dll", "ggml-hip.dll"],+)+def test_windows_rocm_slim_still_requires_ggml_runtime(tmp_path, monkeypatch, missing_name):+ bin_dir = tmp_path / "llama.cpp" / "build" / "bin" / "Release"+ bin_dir.mkdir(parents = True)+ for name in {"ggml.dll", "ggml-base.dll", "ggml-hip.dll"} - {missing_name}:+ (bin_dir / name).write_bytes(b"ggml")+ # The HIP DLLs every published ROCm bundle also ships: none of them is the+ # ggml backend module, so their presence must not stand in for it.+ for name in ("amdhip64_7.dll", "hipblas.dll", "libhipblaslt.dll"):+ (bin_dir / name).write_bytes(b"runtime")+ monkeypatch.setattr(M, "installed_llama_runtime", lambda: (bin_dir, SLIM_LLAMA_TAG, ""))+ artifact = _windows_slim_manifest(+ requires_ggml_sonames = [+ "ggml.dll",+ "ggml-base.dll",+ "libomp140.x86_64.dll",+ ]+ )["artifacts"][0]++ assert (+ M.slim_pairing_for_artifact(+ artifact,+ _host("windows", "x64", has_rocm = True, rocm_gfx = "gfx1150"),+ "rocm",+ )+ is None+ )+++def test_windows_rocm_slim_rejects_decoy_hip_dlls_alone(tmp_path, monkeypatch):+ # Same loss, but with libomp present so the soname gate cannot do the+ # rejecting: only naming the ggml module rejects this, which is what the+ # older *hip*.dll glob could not do.+ bin_dir = tmp_path / "llama.cpp" / "build" / "bin" / "Release"+ bin_dir.mkdir(parents = True)+ for name in (+ "ggml.dll",+ "ggml-base.dll",+ "ggml-cpu.dll",+ "libomp140.x86_64.dll",+ "amdhip64_7.dll",+ "hipblas.dll",+ "libhipblaslt.dll",+ ):+ (bin_dir / name).write_bytes(b"x")+ monkeypatch.setattr(M, "installed_llama_runtime", lambda: (bin_dir, SLIM_LLAMA_TAG, ""))+ artifact = _windows_slim_manifest(requires_ggml_sonames = WIN_LIBOMP_SONAMES)["artifacts"][0]++ assert (+ M.slim_pairing_for_artifact(+ artifact,+ _host("windows", "x64", has_rocm = True, rocm_gfx = "gfx1150"),+ "rocm",+ )+ is None+ )++MAC_SLIM_ASSET = "whisper-v1.9.1-unsloth.1-macos-arm64-slim.tar.gz"@@ -1126,6 +1262,10 @@ def test_rocm_runtime_catalog_copy_fallback(tmp_path, monkeypatch):assert (whisper_bin / directory / "kernel.dat").read_bytes() == directory.encode()+ sys.platform == "win32",+ reason = "os.access(X_OK) is always true on Windows, so the guard is POSIX only",+)def test_existing_install_requires_executable_server(tmp_path, monkeypatch):# A marker-matching install with a non-executable server must reinstall:# the sidecar refuses it via os.access(X_OK), so "already matches" would