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: reach the published source asset when a mix build's commit 404s (#6314)
Daniel Han23a3d972bf75
diff --git a/studio/install_llama_prebuilt.py b/studio/install_llama_prebuilt.pyindex 111a0485e90..4edab0b8ab2 100644--- a/studio/install_llama_prebuilt.py+++ b/studio/install_llama_prebuilt.py@@ -5948,6 +5948,34 @@ def preferred_source_archive()+def exact_source_asset_url(+ approved_checksums: ApprovedReleaseChecksums,+ source_repo: str,+ source_archive: ApprovedArtifactHash | None,+ exact_source: bool,+ release_tag: str,+) -> str | None:+ """Release-asset URL for a mix build's merged source tree, or None.++ A mix build's merge commit is never pushed, so its codeload/archive URLs+ 404; the only durable copy of the merged tree is the+ ``llama.cpp-source-commit-<sha>.tar.gz`` asset published alongside the+ prebuilt. Resolve its host and tag defensively so a manifest that omits the+ top-level ``repo``/``release_tag`` still reaches the asset: prefer the+ artifact's own repo, then the manifest repo, then the source repo; and prefer+ the manifest release tag, then the tag we actually installed the prebuilt+ from (its sibling on the same release). Without this the empty fields drop the+ only working URL and hydration falls through to the 404-ing commit archive.+ """+ if not exact_source or source_archive is None:+ return None+ return release_asset_download_url(+ source_archive.repo or approved_checksums.repo or source_repo,+ approved_checksums.release_tag or release_tag,+ source_archive.asset_name,+ )++def selected_source_archive_metadata(checksums: ApprovedReleaseChecksums, llama_tag: str) -> tuple[str, str | None]:@@ -6389,12 +6417,8 @@ def validate_prebuilt_choice()# For an exact (mix) source the merge commit lives only in the release asset,# not in any repo, so fetch the asset directly; codeload stays the fallback.- asset_url = (- release_asset_download_url(- approved_checksums.repo, approved_checksums.release_tag, source_archive.asset_name- )- if exact_source and source_archive is not None- else None+ asset_url = exact_source_asset_url(+ approved_checksums, source_repo, source_archive, exact_source, release_tag)if exact_source:log(f"hydrating exact llama.cpp source for {source_repo}@{source_ref} into {install_dir}")diff --git a/tests/studio/install/test_selection_logic.py b/tests/studio/install/test_selection_logic.pyindex 64715a63275..771b19c0432 100644--- a/tests/studio/install/test_selection_logic.py+++ b/tests/studio/install/test_selection_logic.py@@ -4084,3 +4084,126 @@ class TestCudaDriverToolkitMismatchMessage:output = self._run_bash(script)assert "NONE" in outputassert "FOUND" not in output+++class TestExactSourceAssetUrl:+ """exact_source_asset_url resolves the published source-commit release asset+ for mix builds even when the manifest omits the top-level repo/release_tag.++ A mix build's merge commit is never pushed, so its codeload/archive URLs+ 404; the ``llama.cpp-source-commit-<sha>.tar.gz`` asset is the only durable+ copy. If the asset URL resolves empty, hydration falls through to the 404-ing+ commit archive and the whole prebuilt install fails to a source build.+ """++ COMMIT = "c4fca6de" + "a" * 32 # 40-char sha+ INSTALL_TAG = "b9616-mix-17e50db"++ def _artifact(self, *, repo):+ name = exact_source_archive_logical_name(self.COMMIT)+ return ApprovedArtifactHash(+ asset_name = name,+ sha256 = "c" * 64,+ repo = repo,+ kind = "exact-source",+ )++ def _checksums(self, *, repo, release_tag):+ return ApprovedReleaseChecksums(+ repo = repo,+ release_tag = release_tag,+ upstream_tag = "b9616",+ source_repo = "unslothai/llama.cpp",+ source_commit = self.COMMIT,+ artifacts = {},+ )++ def _expected(self, repo, tag):+ return (+ f"https://github.com/{repo}/releases/download/"+ f"{tag}/{exact_source_archive_logical_name(self.COMMIT)}"+ )++ def test_uses_manifest_repo_and_tag_when_present(self):+ checksums = self._checksums(repo = "unslothai/llama.cpp", release_tag = self.INSTALL_TAG)+ url = INSTALL_LLAMA_PREBUILT.exact_source_asset_url(+ checksums, "unslothai/llama.cpp", self._artifact(repo = None), True, "ignored-tag"+ )+ assert url == self._expected("unslothai/llama.cpp", self.INSTALL_TAG)++ def test_falls_back_to_install_tag_when_manifest_tag_missing(self):+ # Regression: an empty manifest release_tag must not drop the asset URL.+ # Before the fix this returned None and hydration 404'd on the merge commit.+ checksums = self._checksums(repo = "unslothai/llama.cpp", release_tag = "")+ url = INSTALL_LLAMA_PREBUILT.exact_source_asset_url(+ checksums, "unslothai/llama.cpp", self._artifact(repo = None), True, self.INSTALL_TAG+ )+ assert url == self._expected("unslothai/llama.cpp", self.INSTALL_TAG)++ def test_falls_back_to_source_repo_when_manifest_repo_missing(self):+ checksums = self._checksums(repo = "", release_tag = self.INSTALL_TAG)+ url = INSTALL_LLAMA_PREBUILT.exact_source_asset_url(+ checksums, "unslothai/llama.cpp", self._artifact(repo = None), True, self.INSTALL_TAG+ )+ assert url == self._expected("unslothai/llama.cpp", self.INSTALL_TAG)++ def test_prefers_artifact_repo_over_manifest_repo(self):+ checksums = self._checksums(repo = "unslothai/checksums-only", release_tag = self.INSTALL_TAG)+ url = INSTALL_LLAMA_PREBUILT.exact_source_asset_url(+ checksums,+ "unslothai/llama.cpp",+ self._artifact(repo = "unslothai/llama.cpp"),+ True,+ self.INSTALL_TAG,+ )+ assert url == self._expected("unslothai/llama.cpp", self.INSTALL_TAG)++ def test_returns_none_for_non_exact_source(self):+ checksums = self._checksums(repo = "unslothai/llama.cpp", release_tag = self.INSTALL_TAG)+ assert (+ INSTALL_LLAMA_PREBUILT.exact_source_asset_url(+ checksums, UPSTREAM_REPO, None, False, self.INSTALL_TAG+ )+ is None+ )++ def test_returns_none_without_source_archive(self):+ checksums = self._checksums(repo = "unslothai/llama.cpp", release_tag = self.INSTALL_TAG)+ assert (+ INSTALL_LLAMA_PREBUILT.exact_source_asset_url(+ checksums, "unslothai/llama.cpp", None, True, self.INSTALL_TAG+ )+ is None+ )++ def test_resolves_through_real_parser_chain(self):+ # The cases above hand-build ApprovedReleaseChecksums; this exercises the+ # production path they bypass: parse_approved_release_checksums ->+ # preferred_source_archive -> exact_source_asset_url, so a regression in the+ # parser/selection wiring can't pass while only the helper unit tests stay green.+ payload = {+ "schema_version": 1,+ "component": "llama.cpp",+ "release_tag": self.INSTALL_TAG,+ "upstream_tag": "b9616",+ "source_repo": "unslothai/llama.cpp",+ "source_commit": self.COMMIT,+ "artifacts": {+ exact_source_archive_logical_name(self.COMMIT): {+ "sha256": "c" * 64,+ "kind": "exact-source",+ },+ },+ }+ checksums = INSTALL_LLAMA_PREBUILT.parse_approved_release_checksums(+ "unslothai/llama.cpp", self.INSTALL_TAG, payload+ )+ source_repo, _source_ref, source_archive, exact_source = (+ INSTALL_LLAMA_PREBUILT.preferred_source_archive(checksums, "b9616")+ )+ assert exact_source is True+ assert source_archive is not None+ url = INSTALL_LLAMA_PREBUILT.exact_source_asset_url(+ checksums, source_repo, source_archive, exact_source, self.INSTALL_TAG+ )+ assert url == self._expected("unslothai/llama.cpp", self.INSTALL_TAG)