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.

whisper.cpp: skip the macOS release walk when llama.cpp is ahead of every release (#14302)

Daniel Han87b8c45a6aee
diff --git a/studio/install_whisper_prebuilt.py b/studio/install_whisper_prebuilt.py
index 4ff605de311..f282722bb29 100644
--- a/studio/install_whisper_prebuilt.py
+++ b/studio/install_whisper_prebuilt.py
@@ -120,6 +120,13 @@ class ReleaseCompatibilityError(PrebuiltFallback):
"""A valid slim release cannot pair with this host's installed runtime."""
+class LlamaPairingGapError(ReleaseCompatibilityError):
+ """The release's slim bundles pair with no llama.cpp build tree the host has installed."""
+
+
+_PAIRING_GAP_PREFIX = "slim bundle requires llama.cpp "
+
+
def log(message: str) -> None:
print(f"[whisper-prebuilt] {message}", file = sys.stdout if _LOG_TO_STDOUT else sys.stderr)
@@ -630,10 +637,40 @@ def select_artifact_with_cpu_fallback(
except PrebuiltFallback as exc:
reason = _slim_release_incompatibility(manifest, host)
if reason is not None:
- raise ReleaseCompatibilityError(reason) from exc
+ gap = reason.startswith(_PAIRING_GAP_PREFIX)
+ raise (LlamaPairingGapError if gap else ReleaseCompatibilityError)(reason) from exc
raise
+_LLAMA_BUILD = re.compile(r"^b(\d+)(?:-|$)")
+
+
+def _llama_build(tag: Any) -> int | None:
+ match = _LLAMA_BUILD.match(tag) if isinstance(tag, str) else None
+ return int(match.group(1)) if match else None
+
+
+def _installed_llama_is_ahead(manifest: dict[str, Any], host: HostInfo) -> bool:
+ """Whether every slim bundle this host can run needs an older llama.cpp build than the installed one."""
+ os_token, arch_token = host_platform_tokens(host)
+ required = [
+ _llama_build(artifact.get("requires_llama_tag"))
+ for artifact in manifest.get("artifacts", [])
+ if artifact.get("os") == os_token
+ and artifact.get("arch") == arch_token
+ and artifact.get("backend") == "slim"
+ and artifact.get("install_kind") == "slim"
+ and (not host.is_macos or _macos_min_os_ok(host, artifact.get("min_os")))
+ ]
+ runtime = installed_llama_runtime()
+ installed = _llama_build(runtime[1]) if runtime is not None else None
+ return (
+ bool(required)
+ and installed is not None
+ and all(build is not None and build < installed for build in required)
+ )
+
+
def _slim_release_incompatibility(manifest: dict[str, Any], host: HostInfo) -> str | None:
"""Explain a valid platform slim release that this runtime cannot pair.
@@ -690,9 +727,7 @@ def _slim_release_incompatibility(manifest: dict[str, Any], host: HostInfo) -> s
for tag, tree in required_pairs
):
required_tag = sorted(required_tags)[0]
- return (
- f"slim bundle requires llama.cpp {required_tag}; installed llama.cpp is {installed_tag}"
- )
+ return f"{_PAIRING_GAP_PREFIX}{required_tag}; installed llama.cpp is {installed_tag}"
return None
@@ -1711,6 +1746,21 @@ def _release_plan_for_host(
assert first_error is not None
raise first_error
+ if (
+ not requested_specific_tag
+ and isinstance(first_error, LlamaPairingGapError)
+ # Our releases track llama.cpp builds in order; a custom repo's need not, on either side.
+ and published_repo == DEFAULT_PUBLISHED_REPO
+ and installed_llama_tree_repo() == llama.DEFAULT_PUBLISHED_REPO
+ and first_bundle is not None
+ and _installed_llama_is_ahead(first_bundle.manifest, host)
+ ):
+ # llama.cpp is published before its paired whisper.cpp release. Until that lands, the newest
+ # release pairs with an older llama.cpp and older ones with older still, so a walk finds
+ # nothing and costs a release listing plus two fetches per release on every update.
+ assert first_error is not None
+ raise first_error
+
# An API limit or network failure is "could not answer", which the keep path handles.
try:
compatible_tags = _published_release_tags(published_repo)
diff --git a/tests/studio/install/test_install_whisper_prebuilt_logic.py b/tests/studio/install/test_install_whisper_prebuilt_logic.py
index 3e7773b689b..c5e7f69a38c 100644
--- a/tests/studio/install/test_install_whisper_prebuilt_logic.py
+++ b/tests/studio/install/test_install_whisper_prebuilt_logic.py
@@ -2956,3 +2956,124 @@ def test_a_custom_repository_asset_name_is_judged_by_the_recorded_platform(tmp_p
install_dir, asset = f"whisper-v1.9.1-{os_token}-{arch_token}-cpu.tar.gz", os = None, arch = None
)
assert _whisper_check(install_dir, host) is True
+
+
+def _paired_macos_release(requires_llama_tag: str) -> M.ReleaseBundle:
+ asset = "whisper-macos-arm64-slim.tar.gz"
+ return _release_for_selection(
+ "v1.9.5-unsloth.9",
+ "v1.9.5",
+ _slim_artifact(
+ os = "macos",
+ arch = "arm64",
+ asset = asset,
+ requires_llama_tag = requires_llama_tag,
+ requires_ggml_sonames = ["libggml.0.dylib", "libggml-base.0.dylib"],
+ ),
+ )
+
+
+def _macos_pairing_gap(
+ monkeypatch,
+ installed_llama_tag: str,
+ llama_repo: str | None = "unslothai/llama.cpp",
+) -> list[str]:
+ """The newest whisper.cpp release pairs with b10069; llama.cpp is installed at another build."""
+ newest = _paired_macos_release(SLIM_LLAMA_TAG)
+ monkeypatch.setattr(
+ M,
+ "installed_llama_runtime",
+ lambda install_dir = None: (Path("/nowhere"), installed_llama_tag, ""),
+ )
+ monkeypatch.setattr(M, "installed_llama_ggml_tree", lambda *a, **k: None)
+ monkeypatch.setattr(M, "installed_llama_tree_repo", lambda *a, **k: llama_repo)
+ monkeypatch.setattr(M, "published_llama_ggml_tree", lambda *a, **k: None)
+ monkeypatch.setattr(
+ M, "fetch_release_for_install", lambda repo, *, published_release_tag = None: (newest, {})
+ )
+ listed: list[str] = []
+
+ def listing(repo):
+ listed.append(repo)
+ return [newest.release_tag]
+
+ monkeypatch.setattr(M, "_published_release_tags", listing)
+ return listed
+
+
+def _plan_on_macos(published_repo: str = "unslothai/whisper.cpp"):
+ return M._release_plan_for_host(
+ _host("macos", "arm64", macos_version = (15, 7)),
+ published_repo = published_repo,
+ published_release_tag = None,
+ whisper_tag = "latest",
+ requested_backend = "metal",
+ )
+
+
+def test_macos_does_not_walk_back_when_llama_is_ahead_of_every_whisper_release(monkeypatch):
+ """llama.cpp b10080 is out and its paired whisper.cpp release is not yet: no older release can
+ pair with a newer llama.cpp, so listing and fetching all of them (two requests each, on every
+ update) found nothing. Seen in CI as ~50 GitHub requests in a no-op macOS update."""
+ listed = _macos_pairing_gap(monkeypatch, "b10080-mix-0000000")
+ with pytest.raises(M.LlamaPairingGapError, match = SLIM_LLAMA_TAG):
+ _plan_on_macos()
+ assert listed == []
+
+
+def test_macos_still_walks_back_when_llama_is_behind_the_newest_whisper_release(monkeypatch):
+ # An older whisper.cpp release may pair with the older llama.cpp still installed.
+ listed = _macos_pairing_gap(monkeypatch, "b10060-mix-0000000")
+ with pytest.raises(ReleaseCompatibilityError, match = SLIM_LLAMA_TAG):
+ _plan_on_macos()
+ assert listed == ["unslothai/whisper.cpp"]
+
+
+ "tag, build",
+ [
+ ("b11734-mix-c208e5f", 11734),
+ ("b11734", 11734),
+ ("b11734x", None),
+ ("v1.9.5", None),
+ (None, None),
+ ],
+)
+def test_llama_build_numbers(tag, build):
+ assert M._llama_build(tag) == build
+
+
+def test_an_unparsable_llama_tag_keeps_the_walk(monkeypatch):
+ listed = _macos_pairing_gap(monkeypatch, "custom-build")
+ with pytest.raises(ReleaseCompatibilityError):
+ _plan_on_macos()
+ assert listed == ["unslothai/whisper.cpp"]
+
+
+def test_macos_still_walks_back_when_the_tags_pair_but_selection_failed_otherwise(monkeypatch):
+ # b10079 shares b10069's ggml, so the pairing holds and the miss is about the runtime's files
+ # (none at /nowhere); an older release may need fewer of them, so the build numbers alone
+ # must not stop the walk.
+ listed = _macos_pairing_gap(monkeypatch, NEWER_LLAMA_TAG)
+ with pytest.raises(PrebuiltFallback) as raised:
+ _plan_on_macos()
+ assert not isinstance(raised.value, M.LlamaPairingGapError)
+ assert listed == ["unslothai/whisper.cpp"]
+
+
+def test_a_custom_release_repo_keeps_the_walk_when_llama_is_ahead(monkeypatch):
+ # Only our releases are published in llama.cpp build order; another repo may hold an older
+ # release that pairs with a newer llama.cpp.
+ listed = _macos_pairing_gap(monkeypatch, "b10080-mix-0000000")
+ with pytest.raises(M.LlamaPairingGapError):
+ _plan_on_macos("someone/whisper.cpp")
+ assert listed == ["someone/whisper.cpp"]
+
+
[email protected]("llama_repo", ["someone/llama.cpp", None])
+def test_a_llama_runtime_from_another_repo_keeps_the_walk(monkeypatch, llama_repo):
+ # Its build numbers say nothing about the ggml trees our whisper.cpp releases were built on.
+ listed = _macos_pairing_gap(monkeypatch, "b10080-mix-0000000", llama_repo)
+ with pytest.raises(M.LlamaPairingGapError):
+ _plan_on_macos()
+ assert listed == ["unslothai/whisper.cpp"]