From dbf8e2cde669df58340cfab78cd0121fa8d82626 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Wed, 25 Mar 2026 13:47:54 +0000 Subject: [PATCH 1/2] fix(studio): source-build fallback prefers Unsloth's tested tag over upstream latest When the prebuilt install fails and falls back to source build, --resolve-llama-tag now queries the Unsloth release repo (unslothai/llama.cpp) first to get the latest tested/approved tag (e.g. b8508), instead of going straight to ggml-org/llama.cpp which may return a newer untested tag (e.g. b8514). This ensures the source-build fallback compiles the same version that the prebuilt path would have installed, rather than a potentially incompatible bleeding-edge release. Resolution order for "latest": 1. Unsloth release repo (tested/approved) 2. ggml-org upstream (bleeding-edge) 3. Raw requested tag string (last resort) Changes: - resolve_requested_llama_tag() accepts optional published_repo param with docstring explaining the resolution order - CLI --resolve-llama-tag passes --published-repo through - setup.sh and setup.ps1 pass --published-repo to --resolve-llama-tag with inline comments explaining the preference --- studio/install_llama_prebuilt.py | 38 +++++++++++++++++++++++++++++++- studio/setup.ps1 | 5 ++++- studio/setup.sh | 5 ++++- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/studio/install_llama_prebuilt.py b/studio/install_llama_prebuilt.py index a9d0b72352..129e878acb 100755 --- a/studio/install_llama_prebuilt.py +++ b/studio/install_llama_prebuilt.py @@ -1285,9 +1285,39 @@ def pinned_published_release_bundle( def resolve_requested_llama_tag( requested_tag: str | None, + published_repo: str = "", ) -> str: + """Resolve a llama.cpp tag for source-build fallback. + + Resolution order: + 1. Concrete tag (e.g. "b8508") -- returned as-is. + 2. "latest" with published_repo -- query the Unsloth release repo + (e.g. unslothai/llama.cpp) for its latest release tag. This is the + tested/approved version that matches the prebuilt binaries. + 3. "latest" without published_repo or if (2) fails -- query the upstream + ggml-org/llama.cpp repo. This may return a newer, untested tag. + + The Unsloth repo is preferred because its releases are pinned to specific + upstream tags that have been validated with Unsloth Studio. Using the + upstream bleeding-edge tag risks API/ABI incompatibilities. + """ if requested_tag and requested_tag != "latest": return requested_tag + # Prefer the Unsloth release repo tag (tested/approved) over bleeding-edge + # upstream. For example, unslothai/llama.cpp may publish b8508 while + # ggml-org/llama.cpp latest is b8514. The source-build fallback should + # compile the same version the prebuilt path would have installed. + if published_repo: + try: + payload = fetch_json( + f"https://api.github.com/repos/{published_repo}/releases/latest" + ) + tag = payload.get("tag_name") + if isinstance(tag, str) and tag: + return tag + except Exception: + pass + # Fall back to upstream ggml-org latest release tag return latest_upstream_release_tag() @@ -3360,7 +3390,13 @@ def parse_args() -> argparse.Namespace: def main() -> int: args = parse_args() if args.resolve_llama_tag is not None: - print(resolve_requested_llama_tag(args.resolve_llama_tag)) + # Pass published_repo so the resolver prefers the Unsloth release tag + # (tested/approved) over the upstream ggml-org bleeding-edge tag. + print( + resolve_requested_llama_tag( + args.resolve_llama_tag, args.published_repo + ) + ) return EXIT_SUCCESS if args.resolve_install_tag is not None: diff --git a/studio/setup.ps1 b/studio/setup.ps1 index d8465fd039..4cd19fdb03 100644 --- a/studio/setup.ps1 +++ b/studio/setup.ps1 @@ -1314,7 +1314,10 @@ if ($resolveExit -ne 0 -or [string]::IsNullOrWhiteSpace($ResolvedLlamaTag)) { if ($resolveOutput) { $resolveOutput | ForEach-Object { Write-Host $_ } } - $fallbackOutput = & python "$PSScriptRoot\install_llama_prebuilt.py" --resolve-llama-tag $RequestedLlamaTag 2>$null + # Resolve the llama.cpp tag for source-build fallback. Pass --published-repo + # so the resolver prefers Unsloth's tested tag (e.g. b8508) over the upstream + # bleeding-edge tag (e.g. b8514) from ggml-org/llama.cpp. + $fallbackOutput = & python "$PSScriptRoot\install_llama_prebuilt.py" --resolve-llama-tag $RequestedLlamaTag --published-repo $HelperReleaseRepo 2>$null $fallbackExit = $LASTEXITCODE $ResolvedLlamaTag = if ($fallbackExit -eq 0 -and $fallbackOutput) { ($fallbackOutput | Select-Object -Last 1).ToString().Trim() diff --git a/studio/setup.sh b/studio/setup.sh index 90631f6131..580045b956 100755 --- a/studio/setup.sh +++ b/studio/setup.sh @@ -412,7 +412,10 @@ if [ -z "$_RESOLVED_LLAMA_TAG" ]; then echo "⚠️ Failed to resolve an installable prebuilt llama.cpp tag via $_HELPER_RELEASE_REPO" cat "$_RESOLVE_LLAMA_LOG" >&2 || true set +e - _RESOLVED_LLAMA_TAG="$(python "$SCRIPT_DIR/install_llama_prebuilt.py" --resolve-llama-tag "$_REQUESTED_LLAMA_TAG" 2>/dev/null)" + # Resolve the llama.cpp tag for source-build fallback. Pass --published-repo + # so the resolver prefers Unsloth's tested tag (e.g. b8508) over the upstream + # bleeding-edge tag (e.g. b8514) from ggml-org/llama.cpp. + _RESOLVED_LLAMA_TAG="$(python "$SCRIPT_DIR/install_llama_prebuilt.py" --resolve-llama-tag "$_REQUESTED_LLAMA_TAG" --published-repo "$_HELPER_RELEASE_REPO" 2>/dev/null)" _RESOLVE_UPSTREAM_STATUS=$? set -e if [ "$_RESOLVE_UPSTREAM_STATUS" -ne 0 ] || [ -z "$_RESOLVED_LLAMA_TAG" ]; then From ae24b002933308ed5eeae5ce9d0c708447664eda Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 25 Mar 2026 14:08:37 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- studio/install_llama_prebuilt.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/studio/install_llama_prebuilt.py b/studio/install_llama_prebuilt.py index 129e878acb..516dc4b6a4 100755 --- a/studio/install_llama_prebuilt.py +++ b/studio/install_llama_prebuilt.py @@ -3392,11 +3392,7 @@ def main() -> int: if args.resolve_llama_tag is not None: # Pass published_repo so the resolver prefers the Unsloth release tag # (tested/approved) over the upstream ggml-org bleeding-edge tag. - print( - resolve_requested_llama_tag( - args.resolve_llama_tag, args.published_repo - ) - ) + print(resolve_requested_llama_tag(args.resolve_llama_tag, args.published_repo)) return EXIT_SUCCESS if args.resolve_install_tag is not None: