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 whisper prebuilt pairing on linux-arm64 with a GPU llama runtime (#10278)

Daniel Hana4c815d6adff
diff --git a/studio/install_whisper_prebuilt.py b/studio/install_whisper_prebuilt.py
index c417f38b1ca..70cd0f858fb 100644
--- a/studio/install_whisper_prebuilt.py
+++ b/studio/install_whisper_prebuilt.py
@@ -446,18 +446,61 @@ 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.
+def _ships_gpu_ggml_module(llama_bin_dir: Path, os_key: str) -> bool:
+ """Whether a paired 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)):
+ glob = per_os.get(os_key)
+ # is_file(): a versioned alias still counts, a directory or dangling link does not.
+ if backend != "cpu" and glob and any(path.is_file() for path in llama_bin_dir.glob(glob)):
return True
return False
+def _ships_windows_gpu_ggml_module(llama_bin_dir: Path) -> bool:
+ """Windows spelling of _ships_gpu_ggml_module; kept for call-site clarity."""
+ return _ships_gpu_ggml_module(llama_bin_dir, "windows")
+
+
+def _is_linux_libomp_soname(name: str) -> bool:
+ """LLVM's OpenMP runtime: bundled, so it can go missing. Not host-provided libgomp,
+ and not libomptarget, which a prefix match would sweep up."""
+ lowered = name.lower()
+ return lowered == "libomp.so" or lowered.startswith("libomp.so.")
+
+
+def _ggml_stack_imports_libomp(llama_bin_dir: Path, backend: str) -> bool | None:
+ """Whether the ggml libraries whisper will load actually import LLVM's libomp.
+
+ True on the first import found; False only once every relevant library was inspected
+ and none imported it; None when any could not be inspected.
+
+ The selected backend module is inspected alongside the core: it is dlopen'd after
+ startup, so a dependency living only there is invisible to a --help smoke test.
+ """
+ patterns = ["libggml-base.so*", "libggml.so*"]
+ module_glob = SLIM_BACKEND_MODULE_GLOBS.get(backend, {}).get("linux")
+ if module_glob:
+ patterns.append(module_glob)
+
+ inspected_any = False
+ inspected_all = True
+ for pattern in patterns:
+ for path in sorted(llama_bin_dir.glob(pattern)):
+ if not path.is_file():
+ continue
+ needed = _elf_needed(path)
+ if needed is None:
+ inspected_all = False
+ continue
+ inspected_any = True
+ if any(_is_linux_libomp_soname(dep) for dep in needed):
+ return True
+ return False if inspected_any and inspected_all else None
+
+
def slim_pairing_for_artifact(
artifact: dict[str, Any], host: HostInfo, backend: str
) -> tuple[Path, str] | None:
@@ -498,6 +541,20 @@ def slim_pairing_for_artifact(
for name in required_sonames
if not (name.lower().startswith("libomp") and name.lower().endswith(".dll"))
]
+ if (
+ host.whisper_os == "linux"
+ and host.whisper_arch == "arm64"
+ and _ships_gpu_ggml_module(llama_bin_dir, "linux")
+ and _ggml_stack_imports_libomp(llama_bin_dir, backend) is False
+ ):
+ # Same shape as the Windows case above: the arm64 manifest names libomp only because
+ # the cpu bundle's ggml links it, so CUDA (GNU libgomp) was rejected for a file it
+ # never needs. Evidence, not arch -- the arm64 Vulkan bundle really does import it.
+ # `is False`, not `is not True`: dropping this on no evidence is unrecoverable, since
+ # the sidecar sends the loader error to DEVNULL and serving never falls back.
+ # arm64 only: linux-x64 ggml really imports its bundled libomp
+ # (test_linux_slim_still_requires_manifest_libomp).
+ required_sonames = [name for name in required_sonames if not _is_linux_libomp_soname(name)]
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)}")
diff --git a/tests/studio/install/test_install_whisper_prebuilt_logic.py b/tests/studio/install/test_install_whisper_prebuilt_logic.py
index 9582991e90d..722827b7098 100644
--- a/tests/studio/install/test_install_whisper_prebuilt_logic.py
+++ b/tests/studio/install/test_install_whisper_prebuilt_logic.py
@@ -785,8 +785,7 @@ def test_windows_cpu_bundle_still_requires_manifest_libomp(tmp_path, monkeypatch
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.
+ # x64 ggml really imports its bundled libomp; the arm64 exemption must not widen here.
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")
@@ -798,6 +797,180 @@ def test_linux_slim_still_requires_manifest_libomp(tmp_path, monkeypatch):
assert M.slim_pairing_for_artifact(artifact, _host("linux", "x64"), "cuda") is None
+def test_linux_arm64_gpu_slim_drops_manifest_libomp(tmp_path, monkeypatch):
+ # The manifest names libomp for the *cpu* bundle's ggml; CUDA imports GNU libgomp.
+ 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")
+ )
+ # Real CUDA bundle; without this the test would pass on "could not inspect".
+ monkeypatch.setattr(M, "_elf_needed", lambda path: {"libgomp.so.1", "libc.so.6"})
+ artifact = _slim_artifact(
+ arch = "arm64",
+ requires_ggml_sonames = ["libggml.so.0", "libggml-base.so.0", "libomp.so.5"],
+ )
+
+ assert M.slim_pairing_for_artifact(artifact, _host("linux", "arm64"), "cuda") is not None
+
+
+def test_linux_arm64_gpu_slim_keeps_libomp_when_ggml_really_imports_it(tmp_path, monkeypatch):
+ """The published arm64 Vulkan bundle really does import libomp, unlike CUDA."""
+ bin_dir = _fake_llama_bin(tmp_path, backend_module = "libggml-vulkan.so")
+ monkeypatch.setattr(
+ M, "installed_llama_runtime", lambda: (bin_dir, SLIM_LLAMA_TAG, "linux-vulkan")
+ )
+ monkeypatch.setattr(M, "_elf_needed", lambda path: {"libomp.so.5", "libc.so.6"})
+ artifact = _slim_artifact(
+ arch = "arm64",
+ requires_ggml_sonames = ["libggml.so.0", "libggml-base.so.0", "libomp.so.5"],
+ )
+
+ assert M.slim_pairing_for_artifact(artifact, _host("linux", "arm64"), "vulkan") is None
+
+
+def test_linux_arm64_gpu_slim_keeps_libomp_when_only_the_backend_module_imports_it(
+ tmp_path, monkeypatch
+):
+ """The module is dlopen'd after startup, so a core-only check calls this clean."""
+ 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")
+ )
+ monkeypatch.setattr(
+ M,
+ "_elf_needed",
+ lambda path: (
+ {"libomp.so.5", "libc.so.6"}
+ if path.name.startswith("libggml-cuda")
+ else {"libgomp.so.1", "libc.so.6"}
+ ),
+ )
+ artifact = _slim_artifact(
+ arch = "arm64",
+ requires_ggml_sonames = ["libggml.so.0", "libggml-base.so.0", "libomp.so.5"],
+ )
+
+ assert M.slim_pairing_for_artifact(artifact, _host("linux", "arm64"), "cuda") is None
+
+
+def test_linux_arm64_exemption_fails_closed_without_elf_tools(tmp_path, monkeypatch):
+ """Dropping it here is unrecoverable: the loader error goes to DEVNULL."""
+ 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")
+ )
+ monkeypatch.setattr(M, "_elf_needed", lambda path: None)
+ artifact = _slim_artifact(
+ arch = "arm64",
+ requires_ggml_sonames = ["libggml.so.0", "libggml-base.so.0", "libomp.so.5"],
+ )
+
+ assert M.slim_pairing_for_artifact(artifact, _host("linux", "arm64"), "cuda") is None
+
+
+def test_linux_arm64_exemption_fails_closed_on_partial_elf_inspection(tmp_path, monkeypatch):
+ # One unreadable library makes the answer unknown; the rest are not a clean bill.
+ 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")
+ )
+ monkeypatch.setattr(
+ M,
+ "_elf_needed",
+ lambda path: None if path.name == "libggml-base.so.0" else {"libgomp.so.1"},
+ )
+ artifact = _slim_artifact(
+ arch = "arm64",
+ requires_ggml_sonames = ["libggml.so.0", "libggml-base.so.0", "libomp.so.5"],
+ )
+
+ assert M.slim_pairing_for_artifact(artifact, _host("linux", "arm64"), "cuda") is None
+
+
+def test_linux_arm64_libomptarget_is_not_llvm_openmp(tmp_path, monkeypatch):
+ # libomptarget is a different library; a prefix match would read it as libomp.
+ 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")
+ )
+ monkeypatch.setattr(M, "_elf_needed", lambda path: {"libomptarget.so.1"})
+ artifact = _slim_artifact(
+ arch = "arm64",
+ requires_ggml_sonames = ["libggml.so.0", "libggml-base.so.0", "libomp.so.5"],
+ )
+
+ assert M.slim_pairing_for_artifact(artifact, _host("linux", "arm64"), "cuda") is not None
+
+
+def test_linux_arm64_exemption_does_not_drop_libomptarget_requirement(tmp_path, monkeypatch):
+ 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")
+ )
+ monkeypatch.setattr(M, "_elf_needed", lambda path: {"libgomp.so.1"})
+ artifact = _slim_artifact(
+ arch = "arm64",
+ requires_ggml_sonames = [
+ "libggml.so.0",
+ "libggml-base.so.0",
+ "libomptarget.so.1",
+ ],
+ )
+
+ assert M.slim_pairing_for_artifact(artifact, _host("linux", "arm64"), "cuda") is None
+
+
+def test_linux_arm64_gpu_module_must_be_a_file(tmp_path, monkeypatch):
+ bin_dir = _fake_llama_bin(tmp_path, backend_module = None)
+ (bin_dir / "libggml-cuda.so").mkdir()
+ monkeypatch.setattr(M, "installed_llama_runtime", lambda: (bin_dir, SLIM_LLAMA_TAG, ""))
+ monkeypatch.setattr(M, "_elf_needed", lambda path: {"libgomp.so.1"})
+ artifact = _slim_artifact(
+ arch = "arm64",
+ requires_ggml_sonames = ["libggml.so.0", "libggml-base.so.0", "libomp.so.5"],
+ )
+
+ assert M.slim_pairing_for_artifact(artifact, _host("linux", "arm64"), "cpu") is None
+
+
+ ("os_key", "arch"),
+ [("windows", "x64"), ("windows", "arm64"), ("macos", "arm64"), ("linux", "x64")],
+)
+def test_elf_inspection_never_runs_off_linux_arm64(tmp_path, monkeypatch, os_key, arch):
+ # readelf/objdump are usually absent off linux; this pins the short circuit.
+ bin_dir = _fake_llama_bin(tmp_path, backend_module = "libggml-cuda.so")
+ monkeypatch.setattr(M, "installed_llama_runtime", lambda: (bin_dir, SLIM_LLAMA_TAG, ""))
+ calls = []
+
+ def _spy(path):
+ calls.append(path)
+ return {"libgomp.so.1"}
+
+ monkeypatch.setattr(M, "_elf_needed", _spy)
+ artifact = _slim_artifact(
+ os = os_key,
+ arch = arch,
+ requires_ggml_sonames = ["libggml.so.0", "libggml-base.so.0"],
+ )
+
+ M.slim_pairing_for_artifact(artifact, _host(os_key, arch), "cuda")
+
+ assert calls == []
+
+
+def test_linux_arm64_cpu_bundle_still_requires_manifest_libomp(tmp_path, monkeypatch):
+ # No GPU module, so no exemption: a cpu bundle's ggml really does import libomp.
+ bin_dir = _fake_llama_bin(tmp_path, backend_module = None)
+ monkeypatch.setattr(M, "installed_llama_runtime", lambda: (bin_dir, SLIM_LLAMA_TAG, ""))
+ artifact = _slim_artifact(
+ arch = "arm64",
+ requires_ggml_sonames = ["libggml.so.0", "libggml-base.so.0", "libomp.so.5"],
+ )
+
+ assert M.slim_pairing_for_artifact(artifact, _host("linux", "arm64"), "cpu") is None
+
+
@pytest.mark.parametrize(
"missing_name",
["ggml.dll", "ggml-base.dll", "ggml-hip.dll"],