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: install the pinned Diffusers commit from a zip when there is no git (#11565)

Daniel Hanf39470176f16
diff --git a/studio/backend/core/inference/diffusion_families.py b/studio/backend/core/inference/diffusion_families.py
index 8999bae3fe9..250830b3241 100644
--- a/studio/backend/core/inference/diffusion_families.py
+++ b/studio/backend/core/inference/diffusion_families.py
@@ -1286,6 +1286,53 @@ def pipeline_class_requirement(pipeline_class: str) -> tuple[Optional[str], bool
_UNRELEASED_MIN_DIFFUSERS = frozenset({"0.41.0"})
+_DIFFUSERS_MAIN_PIN = Path(__file__).resolve().parents[2] / "requirements" / "diffusers-main.txt"
+_DIFFUSERS_MAIN_COMMIT_RE = re.compile(
+ r"github\.com/(?P<repo>[^/\s]+/[^/@\s]+?)(?:\.git)?@(?P<commit>[0-9a-fA-F]{40})\b"
+)
+
+
+def _diffusers_main_archive_remedy() -> str:
+ """A remedy line a reader can actually run, naming the commit this build wants.
+
+ The old text said "re-run the installer, or pip install -r diffusers-main.txt". Both resolve
+ the same ``git+https`` requirement, so both fail for the one cause that produces this refusal
+ most often, a host with no working git, and the reader is sent round the loop that put them
+ here. The installer now falls back to the zip for that case, so re-running is once again real
+ advice, and the zip is quoted beside it because it is the fix that needs no git and no
+ installer run at all.
+
+ Read out of the pin file rather than hardcoded, so the commit in the message cannot drift from
+ the commit that is installed. An unreadable or unrecognised pin file degrades to advice that is
+ still true, just less specific, because a refusal that says nothing is worse than one that
+ cannot name the SHA.
+ """
+ generic = (
+ "Re-run the Unsloth installer (leaving UNSLOTH_DIFFUSERS_MAIN unset), which installs it "
+ "from a zip archive when git is missing."
+ )
+ try:
+ text = _DIFFUSERS_MAIN_PIN.read_text(encoding = "utf-8-sig")
+ except (OSError, ValueError):
+ return generic
+ for line in text.splitlines():
+ stripped = line.split("#", 1)[0].strip()
+ if not stripped:
+ continue
+ found = _DIFFUSERS_MAIN_COMMIT_RE.search(stripped)
+ if found is None:
+ continue
+ url = (
+ f"https://github.com/{found.group('repo')}/archive/"
+ f"{found.group('commit').lower()}.zip"
+ )
+ return (
+ f"{generic} To install it by hand with no git at all: "
+ f'pip install "diffusers @ {url}"'
+ )
+ return generic
+
+
def _too_old_message(pipeline_class: str, family_name: str, installed: str) -> str:
"""The refusal text: what is missing, what is installed, and a remedy this interpreter can
actually carry out."""
@@ -1296,12 +1343,13 @@ def _too_old_message(pipeline_class: str, family_name: str, installed: str) -> s
f"diffusers {installed}. Upgrade with: pip install -U diffusers."
)
if minimum in _UNRELEASED_MIN_DIFFUSERS:
+ remedy = _diffusers_main_archive_remedy()
return (
f"'{family_name}' needs diffusers >= {minimum} ({pipeline_class}), which has not been "
f"released yet; this environment has diffusers {installed}. Unsloth installs a pinned "
- "build of diffusers main for this, so re-run the Unsloth installer (and leave "
- "UNSLOTH_DIFFUSERS_MAIN unset), or install it directly with: pip install -r "
- "studio/backend/requirements/diffusers-main.txt"
+ "build of diffusers main for this and that build is not here, which almost always "
+ "means the install had no working git (run: git --version) or could not reach "
+ f"github.com. {remedy}"
)
remedy = f"Upgrade with: pip install -U 'diffusers>={minimum}'."
if needs_py310:
diff --git a/studio/backend/requirements/diffusers-main.txt b/studio/backend/requirements/diffusers-main.txt
index b947e58ab7e..773355a4655 100644
--- a/studio/backend/requirements/diffusers-main.txt
+++ b/studio/backend/requirements/diffusers-main.txt
@@ -24,6 +24,13 @@
# This exact commit is the tree the Qwen-Image-2.1 FP8 and INT8 artifacts were built and measured
# against, so what a user gets is what was tested, not "whatever main was that day".
#
+# Why the URL still says git+ when most hosts have no git. It is the requirement, not the transport:
+# a host with no working git installs the same commit from
+# https://github.com/huggingface/diffusers/archive/<commit>.zip, which needs nothing but https, and
+# _github_archive_url derives that URL from this line so there is still one commit written down in
+# one place. That fallback is why the commit below must stay a full 40-character SHA: an archive
+# records no ref, so only a SHA in the URL makes the resident build identifiable afterwards.
+#
# Retiring this file: once 0.41.0 ships, bump diffusers-pin.txt to it and delete this. The family
# entry already records 0.41.0 as QwenImage21Pipeline's minimum, so nothing else has to move.
diffusers @ git+https://github.com/huggingface/diffusers.git@80c7ed262aeffbeb43ef13ae04baeb9b84515a69
diff --git a/studio/backend/tests/test_diffusion_more_families.py b/studio/backend/tests/test_diffusion_more_families.py
index a0ba70fd8bd..4e1f94f8ac0 100644
--- a/studio/backend/tests/test_diffusion_more_families.py
+++ b/studio/backend/tests/test_diffusion_more_families.py
@@ -734,7 +734,16 @@ def test_the_pinned_prebuilt_is_one_that_can_load_qwen_image_21():
def test_a_minimum_that_has_not_shipped_does_not_prescribe_an_impossible_upgrade():
"""``pip install -U 'diffusers>=0.41.0'`` has no candidate while 0.41.0 is unreleased, so the
- refusal has to name the pinned main build Studio actually installs for this class."""
+ refusal has to name the pinned main build Studio actually installs for this class.
+
+ And it has to name a remedy that WORKS for the cause that produces this refusal. Measured on a
+ host whose git exits non-zero: the install keeps diffusers 0.40.0, and the old text sent the
+ reader to `pip install -r diffusers-main.txt`, which resolves the same git+https requirement
+ and fails identically. The quoted zip URL needs no git, so it is the one line here that has to
+ stay true, hence the check that it names the commit the pin file actually carries."""
+ import pathlib
+ import re as _re
+
from core.inference.diffusion_families import (
_PIPELINE_MIN_DIFFUSERS,
_UNRELEASED_MIN_DIFFUSERS,
@@ -743,8 +752,20 @@ def test_a_minimum_that_has_not_shipped_does_not_prescribe_an_impossible_upgrade
message = _too_old_message("QwenImage21Pipeline", "qwen-image-2.1", "0.40.0")
assert "pip install -U 'diffusers>=0.41.0'" not in message
- assert "diffusers-main.txt" in message
assert "has not been released yet" in message
+ assert "git --version" in message, "the likely cause has to be checkable by the reader"
+
+ pin = (
+ pathlib.Path(__file__).resolve().parents[1]
+ / "requirements"
+ / "diffusers-main.txt"
+ )
+ commit = _re.search(r"@([0-9a-fA-F]{40})\b", pin.read_text(encoding = "utf-8"))
+ assert commit is not None, "the main pin must carry a full commit for the zip route to exist"
+ assert (
+ f"https://github.com/huggingface/diffusers/archive/{commit.group(1).lower()}.zip"
+ in message
+ ), message
# A released minimum keeps the ordinary remedy.
released = _too_old_message("Krea2Pipeline", "krea-2", "0.38.0")
diff --git a/studio/install_python_stack.py b/studio/install_python_stack.py
index 3cef5061d78..e165ac5597e 100644
--- a/studio/install_python_stack.py
+++ b/studio/install_python_stack.py
@@ -10396,6 +10396,47 @@ def _direct_reference_in_requirements(req: Path) -> "tuple[str, str, str] | None
_COMMIT_REVISION_RE = re.compile(r"[0-9a-fA-F]{7,40}")
+# The hosts whose /archive/<commit>.zip is the same tree git would have cloned.
+_GITHUB_ARCHIVE_HOSTS = ("github.com", "www.github.com")
+
+
+def _github_archive_url(url: str, revision: str, subdirectory: str = "") -> "str | None":
+ """The zip GitHub serves for *revision* of *url*, or None when there is no such URL.
+
+ This is the route a host with no working git takes. pip fetches a zip over plain https and
+ needs no git binary anywhere, which is the entire point: git is absent from the desktop bundle,
+ and on macOS `git` is frequently a bare xcrun shim that exits non-zero, so the git requirement
+ is skipped on hosts whose owners have no idea they are missing anything.
+
+ Deliberately narrow, because an archive is weaker evidence than a clone:
+
+ * a FULL 40-character commit only. An archive carries no history and records no ref, so a
+ branch or tag would become "whatever that name pointed at when it was fetched" with nothing
+ left on disk to tell two fetches apart. A commit has no such ambiguity, and the SHA is in the
+ URL, so the recorded url IS the provenance.
+ * github.com over http(s) only. Every other forge spells its archive differently, and guessing
+ wrong installs nothing rather than something wrong, but there is no reason to guess.
+ * no subdirectory. ``#subdirectory=`` is part of the package identity and this URL cannot
+ carry it, so a requirement that uses one keeps the git route and skips as before.
+ """
+ if subdirectory:
+ return None
+ if len(revision) != 40 or not _COMMIT_REVISION_RE.fullmatch(revision):
+ return None
+ scheme, separator, remainder = url.partition("://")
+ if not separator or scheme.lower() not in ("http", "https"):
+ return None
+ netloc, _, path = remainder.partition("/")
+ if netloc.lower() not in _GITHUB_ARCHIVE_HOSTS:
+ return None
+ path = path.strip("/")
+ if path.endswith(".git"):
+ path = path[: -len(".git")]
+ owner, slash, repo = path.partition("/")
+ if not (owner and slash and repo) or "/" in repo:
+ return None
+ return f"https://github.com/{owner}/{repo}/archive/{revision.lower()}.zip"
+
def _direct_reference_is_installed(req: Path, dist_name: str) -> bool:
"""Whether the resident *dist_name* came from the ref *req* names.
@@ -10413,7 +10454,19 @@ def _direct_reference_is_installed(req: Path, dist_name: str) -> bool:
return False
vcs = payload.get("vcs_info")
if not isinstance(vcs, dict):
- return False
+ # The no-git route installed the same commit from a zip, which pip records as archive_info
+ # with no ref at all, so the URL is the only evidence there is. For a full commit that is
+ # exactly as strong as the vcs record, because the SHA is IN the URL. Reading it matters as
+ # much as writing it: without this the archive build is never recognised as resident, so
+ # _diffusers_main_supersedes_release reads the main build as absent, the RELEASE pin
+ # reinstalls over it on the very next pass, and a git-less host silently loses the build it
+ # was just given. Measured, not theorised: the zip went in, the next update put 0.40.0 back.
+ archive = _github_archive_url(url, revision, subdirectory)
+ return (
+ archive is not None
+ and isinstance(payload.get("archive_info"), dict)
+ and str(payload.get("url") or "") == archive
+ )
if not (
str(payload.get("url") or "").rstrip("/") == url.rstrip("/")
and str(vcs.get("requested_revision") or "") == revision
@@ -10577,14 +10630,24 @@ def _diffusers_main_step() -> None:
if not req.is_file():
_progress("diffusers main (skipped, no pin file)")
return
+ # The zip route, taken ONLY when git cannot do the job. Not the default: a clone records the
+ # ref in direct_url.json and an archive records only a URL, and the git URL is what the pin
+ # file is written in. But "no git" is the common case, not the exotic one (the desktop bundle
+ # ships no git, and a macOS `git` that is an unconfigured xcrun shim exits non-zero), and
+ # skipping there costs the newest model family on a host that could have fetched the same tree
+ # over plain https. None when the pin is not a full GitHub commit, which keeps the old skip.
+ archive = None
if not _has_working_git():
- _progress("diffusers main (skipped, no git)")
- _note(
- "No working git, so this install keeps the pinned Diffusers release instead of the "
- "pinned main build. Everything else works; models that need an unreleased Diffusers "
- "will refuse with a message naming the version they want.",
- )
- return
+ wanted = _direct_reference_in_requirements(req)
+ archive = _github_archive_url(*wanted) if wanted is not None else None
+ if archive is None:
+ _progress("diffusers main (skipped, no git)")
+ _note(
+ "No working git, so this install keeps the pinned Diffusers release instead of "
+ "the pinned main build. Everything else works; models that need an unreleased "
+ "Diffusers will refuse with a message naming the version they want.",
+ )
+ return
# The escape hatch reaches this skip too. UNSLOTH_STUDIO_FULL_DEPS is the documented way to
# repair an install whose evidence looks fine and whose payload is not, and _diffusers_main_resident
# is exactly such evidence: _payload_recorded_intact compares recorded sizes, so a same-size
@@ -10593,7 +10656,7 @@ def _diffusers_main_step() -> None:
_progress("diffusers main (satisfied, skipped)")
_record_step("diffusers-main.txt", "skipped")
return
- _progress("diffusers main")
+ _progress("diffusers main (no git, from archive)" if archive else "diffusers main")
_record_step("diffusers-main.txt", "ran")
# pip_install_try, NOT pip_install, and this is the whole reason the step is safe to run by
# default. pip_install exits the installer on failure, which would make a reachable github.com
@@ -10601,12 +10664,21 @@ def _diffusers_main_step() -> None:
# over https, a transient upstream outage would each turn a working install into no install at
# all. Diffusers is mandatory, so the failure has to be survivable, and it is exactly survivable
# because the release pin ran first and is still resident. Degrading costs one model.
- if not pip_install_try(
- "Installing the pinned Diffusers main build",
- "--no-cache-dir",
- req = req,
- constrain = False,
- ):
+ if archive is not None:
+ installed = pip_install_try(
+ "Installing the pinned Diffusers main build (zip archive, no git)",
+ "--no-cache-dir",
+ f"diffusers @ {archive}",
+ constrain = False,
+ )
+ else:
+ installed = pip_install_try(
+ "Installing the pinned Diffusers main build",
+ "--no-cache-dir",
+ req = req,
+ constrain = False,
+ )
+ if not installed:
_record_step("diffusers-main.txt", "skipped")
_note(
"Could not install the pinned Diffusers main build, so this install keeps the pinned "
diff --git a/tests/studio/install/test_diffusers_pin.py b/tests/studio/install/test_diffusers_pin.py
index 434f26e84e6..3aac6a5a26e 100644
--- a/tests/studio/install/test_diffusers_pin.py
+++ b/tests/studio/install/test_diffusers_pin.py
@@ -186,13 +186,60 @@ def test_the_main_build_is_on_by_default_and_opts_out_on_zero(monkeypatch):
assert len(progressed) == 1, progressed
-def test_the_main_build_keeps_the_release_when_there_is_no_git(monkeypatch):
- """Diffusers is mandatory, unlike triton_kernels, so a host with no working git must be left
- with the release the previous step installed rather than nothing at all."""
+def test_the_main_build_falls_back_to_the_zip_when_there_is_no_git(monkeypatch):
+ """No git is the COMMON case, so it must still get the pinned commit.
+
+ Measured on a host whose ``git`` exits non-zero, which is what the desktop bundle looks like on
+ macOS: installing 0.1.811 and then updating to 0.1.812 both left diffusers at 0.40.0, and
+ Qwen-Image-2.1 refused to load on an install that had done nothing wrong. Nothing about that
+ needed git: the same commit is a zip over plain https. The git clone stays the default because
+ it records a ref, and this is the fallback.
+ """
module = _probe_module("install_python_stack_probe2")
monkeypatch.delenv("UNSLOTH_DIFFUSERS_MAIN", raising = False)
monkeypatch.setattr(module, "_has_working_git", lambda: False)
+ monkeypatch.setattr(module, "_direct_reference_is_installed", lambda *a, **k: False)
+ monkeypatch.setattr(module, "_progress", lambda *a, **k: None)
+ monkeypatch.setattr(module, "_note", lambda *a, **k: None)
+ monkeypatch.setattr(module, "_record_step", lambda *a, **k: None)
+ calls = []
+
+ def _capture(label, *args, **kwargs):
+ calls.append((args, kwargs))
+ return True
+
+ monkeypatch.setattr(module, "pip_install_try", _capture)
+ module._diffusers_main_step()
+
+ assert len(calls) == 1, calls
+ args, kwargs = calls[0]
+ assert kwargs.get("req") is None, "the git requirement file must not be handed to pip here"
+ spec = [arg for arg in args if arg.startswith("diffusers @ ")]
+ assert len(spec) == 1, args
+ revision = _requirements(MAIN_FILE)[0].rpartition("@")[2].strip().lower()
+ assert spec[0] == (
+ "diffusers @ https://github.com/huggingface/diffusers/archive/"
+ f"{revision}.zip"
+ ), spec
+
+
+def test_the_main_build_keeps_the_release_when_there_is_no_git_and_no_zip(monkeypatch):
+ """Diffusers is mandatory, unlike triton_kernels, so a host that can reach neither route must
+ be left with the release the previous step installed rather than nothing at all.
+
+ Reached by a pin file the zip route cannot serve: a non-GitHub remote, or a branch ref, which
+ an archive cannot pin because it records no ref of its own.
+ """
+ module = _probe_module("install_python_stack_probe2b")
+
+ monkeypatch.delenv("UNSLOTH_DIFFUSERS_MAIN", raising = False)
+ monkeypatch.setattr(module, "_has_working_git", lambda: False)
+ monkeypatch.setattr(
+ module,
+ "_direct_reference_in_requirements",
+ lambda req: ("https://gitlab.example/huggingface/diffusers", "a" * 40, ""),
+ )
monkeypatch.setattr(
module, "pip_install_try", lambda *a, **k: pytest.fail("a git requirement without git")
)
@@ -204,6 +251,61 @@ def test_the_main_build_keeps_the_release_when_there_is_no_git(monkeypatch):
assert notes and "no working git" in notes[0].lower()
+def test_an_archive_install_reads_back_as_resident(monkeypatch):
+ """The half that makes the zip route survive.
+
+ Without it the fallback works exactly once: pip records ``archive_info`` and no ref, the
+ residency check only understood ``vcs_info``, so the main build read as absent,
+ ``_diffusers_main_supersedes_release`` said the release pin had not been superseded, and the
+ NEXT pass reinstalled diffusers 0.40.0 straight over it. Measured, not theorised.
+ """
+ module = _probe_module("install_python_stack_probe2c")
+
+ revision = _requirements(MAIN_FILE)[0].rpartition("@")[2].strip().lower()
+ archive = f"https://github.com/huggingface/diffusers/archive/{revision}.zip"
+ monkeypatch.setattr(module, "_payload_recorded_intact", lambda *a, **k: True)
+
+ monkeypatch.setattr(
+ module,
+ "_recorded_direct_url",
+ lambda dist: {"url": archive, "archive_info": {"hash": "sha256=abc"}},
+ )
+ assert module._direct_reference_is_installed(MAIN_FILE, "diffusers") is True
+
+ # A zip of a DIFFERENT commit is not this one, which is the whole reason the SHA has to be in
+ # the URL: an archive records no ref, so the URL is the only provenance there is.
+ other = f"https://github.com/huggingface/diffusers/archive/{'b' * 40}.zip"
+ monkeypatch.setattr(
+ module,
+ "_recorded_direct_url",
+ lambda dist: {"url": other, "archive_info": {"hash": "sha256=abc"}},
+ )
+ assert module._direct_reference_is_installed(MAIN_FILE, "diffusers") is False
+
+
+def test_the_zip_route_refuses_anything_it_cannot_pin():
+ """The derivation is narrow on purpose: a wrong URL installs the wrong tree silently."""
+ module = _probe_module("install_python_stack_probe2d")
+ commit = "0" * 40
+
+ assert module._github_archive_url("https://github.com/a/b.git", commit) == (
+ f"https://github.com/a/b/archive/{commit}.zip"
+ )
+ assert module._github_archive_url("https://www.github.com/a/b/", commit) == (
+ f"https://github.com/a/b/archive/{commit}.zip"
+ )
+ # A short SHA, a branch and a tag all fail: an archive carries no history, so only a full
+ # commit in the URL can identify the tree afterwards.
+ assert module._github_archive_url("https://github.com/a/b", commit[:12]) is None
+ assert module._github_archive_url("https://github.com/a/b", "main") is None
+ assert module._github_archive_url("https://github.com/a/b", "v1.2.3") is None
+ # Other forges spell archives differently, and ssh carries no https route at all.
+ assert module._github_archive_url("https://gitlab.com/a/b", commit) is None
+ assert module._github_archive_url("ssh://[email protected]/a/b", commit) is None
+ # A subdirectory is part of the package identity and this URL cannot carry it.
+ assert module._github_archive_url("https://github.com/a/b", commit, "sub") is None
+
+
def test_a_failed_main_build_degrades_instead_of_failing_the_install(monkeypatch):
"""The one that makes default-on safe.