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: install the released Diffusers 0.42.1 instead of the pinned main commit (#15761)
Daniel Han3cced21e9d95
diff --git a/studio/backend/core/inference/diffusion_cond_blocks.py b/studio/backend/core/inference/diffusion_cond_blocks.pyindex 78c7cc327cc..437088645cb 100644--- a/studio/backend/core/inference/diffusion_cond_blocks.py+++ b/studio/backend/core/inference/diffusion_cond_blocks.py@@ -16,7 +16,7 @@ from typing import Any, OptionalCOND_BLOCKS_ENV = "UNSLOTH_DIFFUSION_COND_BLOCKS"COND_KWARG = "unsloth_cond"-# sha256[:16] of inspect.getsource(Flux3Transformer2DModel.forward) the replacement mirrors (diffusers 0.41.0.dev0).+# sha256[:16] of inspect.getsource(Flux3Transformer2DModel.forward) the replacement mirrors (d42ebf9c and 0.42.1)._FLUX3_FORWARD_SHA = frozenset({"f2f7c836416cfd58"})_PATCHED: dict[type, Any] = {}diff --git a/studio/backend/core/inference/diffusion_families.py b/studio/backend/core/inference/diffusion_families.pyindex 766c755d9a7..3d4b0b25556 100644--- a/studio/backend/core/inference/diffusion_families.py+++ b/studio/backend/core/inference/diffusion_families.py@@ -2286,6 +2286,7 @@ def family_prequant_filename(# diffusers 0.37.0 requires Python >= 3.10_DIFFUSERS_DROPPED_PY39 = "0.37.0"+_DIFFUSERS_DROPPED_PY310 = "0.42.0"_MAX_PIPELINE_MANIFEST_BYTES = 1 << 20# First diffusers release exporting each class; every probed class must be listed, since an unlisted one reads as available.@@ -2310,9 +2311,8 @@ _PIPELINE_MIN_DIFFUSERS: dict[str, str] = {"QwenImage21Pipeline": "0.41.0",# 0.39.0 drops Edge's use_native_flow_schedule; 0.40.0 resolves a group-offloaded transformer's device as the CPU."Cosmos3OmniPipeline": "0.41.0",- # FLUX.3 Image Klein (huggingface/diffusers#15046) is in no release yet, so the first one that can carry it is- # 0.42.0. Main and the PR branch both report 0.41.0.dev0, which reads as the 0.41.0 release that lacks it, so the- # listing probes the module file instead (``_PIPELINE_PROBE_FILES``).+ # FLUX.3 (huggingface/diffusers#15046), Python >= 3.11; the retired d42ebf9c build reads as 0.41.0, see+ # ``_PIPELINE_PROBE_FILES``."Flux3ModularPipeline": "0.42.0","Flux3DistilledModularPipeline": "0.42.0","Krea2Pipeline": "0.39.0",@@ -2597,18 +2597,14 @@ def _twin_only_component(component: Path) -> bool:return any(is_fp16_twin(n) for n in names) and not any(is_default_weight(n) for n in names)-# Minimums that name a release which does not EXIST yet. ``pip install -U 'diffusers>=0.41.0'`` has-# no candidate today, so quoting it as the remedy sends someone to a command that cannot succeed.-# Studio installs the pinned main build for exactly these classes (studio/backend/requirements/-# diffusers-main.txt), so the remedy is to put that back, not to chase a release. Delete an entry-# here the moment its version ships, which is the same moment diffusers-pin.txt moves to it.-_UNRELEASED_MIN_DIFFUSERS: frozenset = frozenset({"0.42.0"})+# Minimums no release carries yet, served by the pinned main build (diffusers-main.txt): ``pip install -U``+# cannot succeed, so the remedy is that build. Empty while diffusers-pin.txt's release covers every family.+_UNRELEASED_MIN_DIFFUSERS: frozenset = frozenset()# The pinned main build's requires-python (the installer's DIFFUSERS_MAIN_MIN_PYTHON)._DIFFUSERS_MAIN_MIN_PYTHON = (3, 11)-# Classes whose presence a version number cannot answer: an unreleased model on a diffusers main build that reports-# the same x.y.0.dev0 as the release without it. The listing checks the file that defines the class, relative to the-# installed diffusers package, which needs no import. Delete an entry once its release is the pin.+# Classes a main build carries under a version that reads as an older release, so the listing checks the defining+# file instead. FLUX.3's stay while the retired d42ebf9c build (0.41.0.dev0) can still be resident until an update._PIPELINE_PROBE_FILES: dict[str, str] = {"Flux3ModularPipeline": "modular_pipelines/flux3/modular_pipeline.py","Flux3DistilledModularPipeline": "modular_pipelines/flux3/modular_pipeline.py",@@ -2748,6 +2744,20 @@ def _too_old_message(pipeline_class: str, family_name: str, installed: str) -> s"means the install had no working git (check with: git --version) or could not reach "f"github.com. {remedy}")+ if _version_tuple(minimum) >= _version_tuple(_DIFFUSERS_DROPPED_PY310):+ if sys.version_info[:2] < (3, 11):+ # diffusers-pin.txt gives < 3.11 an older release, so updating cannot help.+ return (+ f"'{family_name}' needs diffusers >= {minimum} ({pipeline_class}); this "+ f"environment has diffusers {installed}. That release needs Python 3.11 or newer "+ f"and this is Python {sys.version_info[0]}.{sys.version_info[1]}, so updating "+ "Unsloth cannot install it here. Reinstall Unsloth on Python 3.11+."+ )+ return (+ f"'{family_name}' needs diffusers >= {minimum} ({pipeline_class}); this environment "+ f"has diffusers {installed}. {DIFFUSERS_UPDATE_REMEDY} On a plain pip install: "+ f"pip install -U 'diffusers>={minimum}' (that release needs Python >= 3.11)."+ )remedy = (f"{DIFFUSERS_UPDATE_REMEDY} On a plain pip install: pip install -U 'diffusers>={minimum}'.")diff --git a/studio/backend/core/inference/diffusion_flux3.py b/studio/backend/core/inference/diffusion_flux3.pyindex a25723aaa6f..a54a8ddb772 100644--- a/studio/backend/core/inference/diffusion_flux3.py+++ b/studio/backend/core/inference/diffusion_flux3.py@@ -175,9 +175,8 @@ class _Flux3Interrupted(Exception):# Each reference is scaled to this area before the VAE, aspect kept, Lanczos: ComfyUI's-# ``ReferenceMultiLatent`` with the templates' ``["resize", 1]`` (1.0 megapixels), and the BFL-# reference's multi-reference rule (each <= 1 MiP). Diffusers alone only downsizes above 16 MiP, so-# a phone photo would otherwise be encoded at full size. The 16-px grid crop stays with the blocks.+# ``ReferenceMultiLatent`` ``["resize", 1]`` and BFL's multi-reference rule. Diffusers alone keeps a+# single reference up to 4 MiP (16 MiP before 0.42.0); the 16-px grid fit stays with the blocks.REFERENCE_AREA = 1024 * 1024diff --git a/studio/backend/requirements/diffusers-main.txt b/studio/backend/requirements/diffusers-main.txtindex 896852bf09d..303244f33b1 100644--- a/studio/backend/requirements/diffusers-main.txt+++ b/studio/backend/requirements/diffusers-main.txt@@ -1,12 +1,10 @@-# INSTALLED BY DEFAULT, on top of diffusers-pin.txt. Set UNSLOTH_DIFFUSERS_MAIN=0 to opt out.-# Today that is FLUX.3 Image Klein: Diffusers support merged as huggingface/diffusers#15046 on 2026-10-15 and is-# in no release yet. The commit below is main as of 2026-10-16 (d42ebf9c, the FLUX.3 prompt upsampler block,-# huggingface/diffusers#15058), which carries that merge; past it only FLUX.3 files changed. Studio drops the-# upsampler step from the blocks (diffusion_flux3.flux3_blocks). Comment the line out again (and empty-# _UNRELEASED_MIN_DIFFUSERS) once a release carries it.+# DISABLED (line commented out) while diffusers-pin.txt's release carries every family. To re-enable,+# uncomment with the new commit + archive-sha256 and add the minimum to _UNRELEASED_MIN_DIFFUSERS+# (diffusion_families.py); when active it installs by default, UNSLOTH_DIFFUSERS_MAIN=0 opts out.+# Last used for FLUX.3 Image Klein (huggingface/diffusers#15046, #15058) until 0.42.0 shipped.## A pinned commit of Diffusers main, for models whose support has merged upstream but has not-# reached a release yet. The last one was Qwen-Image-2.1: it merged on 2026-09-18, four weeks after+# reached a release yet. Qwen-Image-2.1 was the first: it merged on 2026-09-18, four weeks after# 0.40.0 was cut, and until 0.41.0 shipped (2026-10-06) nothing on PyPI could run it. Without this# file the only way to run such a model is to break the release pin by hand.#@@ -41,5 +39,6 @@# curl -sL https://github.com/huggingface/diffusers/archive/<commit>.zip | sha256sum# archive-sha256: c46925a12c1b64340272dbd4c5d72a4298ecd4c96cad2c9d549b85a99ffb491f#-# Retiring a pin: bump diffusers-pin.txt to the release and comment the line out (done for 0.41.0).-diffusers @ git+https://github.com/huggingface/diffusers.git@d42ebf9c6e0b46103b74283f5324357a67acaa04+# Retiring a pin: bump diffusers-pin.txt to the release and comment the line out (done for 0.41.0+# and 0.42.1).+# diffusers @ git+https://github.com/huggingface/diffusers.git@d42ebf9c6e0b46103b74283f5324357a67acaa04diff --git a/studio/backend/requirements/diffusers-pin.txt b/studio/backend/requirements/diffusers-pin.txtindex 6cb2ce97fd4..a60eae9c4f6 100644--- a/studio/backend/requirements/diffusers-pin.txt+++ b/studio/backend/requirements/diffusers-pin.txt@@ -2,15 +2,15 @@# no other requirements file may name diffusers, and a test in# tests/studio/install/test_diffusers_pin.py enforces that.#-# 0.41.0 is the first release with Qwen-Image-2.1 (0.40.0: MiniMax-H3 / Music 3). Exact pin, so-# installs are reproducible without a source build from GitHub.+# 0.42.1: FLUX.3 Image Klein (0.42.0) plus the fix stopping a model repo naming a module for+# from_pretrained to import. Exact pin: reproducible, no source build.## Why it is installed from its own file, in its own step: base.txt is applied near the# start of the dependency pass. This step runs late, after every other requirements file,# so nothing can re-resolve diffusers back to a release behind it.#-# python < 3.10 has no candidate: diffusers dropped 3.9 in 0.38, so pinning 0.41.0-# outright would leave the resolver nothing at all on a 3.9 host. Those hosts get the-# newest release they can take and the H3 guard refuses the model with a clear message.-diffusers==0.41.0 ; python_version >= "3.10"+# One line per Python floor (0.42.0 needs 3.11, 0.38 dropped 3.9): an unmarked pin leaves older+# hosts nothing to resolve. The family version gate refuses what their release lacks.+diffusers==0.42.1 ; python_version >= "3.11"+diffusers==0.41.0 ; python_version == "3.10"diffusers==0.36.0 ; python_version < "3.10"diff --git a/studio/backend/requirements/single-env/overrides-darwin-arm64.txt b/studio/backend/requirements/single-env/overrides-darwin-arm64.txtindex 3dcd701134f..a61de35e506 100644--- a/studio/backend/requirements/single-env/overrides-darwin-arm64.txt+++ b/studio/backend/requirements/single-env/overrides-darwin-arm64.txt@@ -43,6 +43,6 @@ anyio<4.14.0# On python >= 3.10 the premise is gone: constraints.txt, studio.txt,# no-torch-runtime.txt and the pyproject studio extra take hub 1.x, so a flat# <1.0 here is unsatisfiable (macOS-arm only; uv falls back to pip). 1.32.0 is-# the floor the Diffusers release in diffusers-pin.txt (0.41.0) declares.+# the floor the Diffusers releases in diffusers-pin.txt (0.42.1, 0.41.0) declare.huggingface_hub>=1.32.0,<2.0; python_version >= "3.10"huggingface_hub>=0.34.0,<1.0; python_version < "3.10"diff --git a/studio/backend/tests/test_diffusers_repair.py b/studio/backend/tests/test_diffusers_repair.pyindex f84533592fe..0a619da2327 100644--- a/studio/backend/tests/test_diffusers_repair.py+++ b/studio/backend/tests/test_diffusers_repair.py@@ -454,12 +454,13 @@ def _release_mode(monkeypatch, installed):_installed_diffusers(monkeypatch, None) # an index install, whatever the host has-def test_the_shipped_main_pin_is_active():- # FLUX.3 Klein needs the pinned build (huggingface/diffusers#15046 merged but is unreleased).- assert _REAL_MAIN_PIN_ACTIVE() is True+def test_the_shipped_main_pin_is_inactive():+ # 0.42.1 carries FLUX.3 Klein (huggingface/diffusers#15046), so no main build is pinned.+ assert _REAL_MAIN_PIN_ACTIVE() is False[email protected]("installed", ["0.41.0", "0.41.0.post1"])[email protected](sys.version_info < (3, 11), reason = "diffusers-pin.txt names 0.42.1 from 3.11")[email protected]("installed", ["0.42.1", "0.42.1.post1"])def test_a_current_release_starts_nothing(monkeypatch, installed):_release_mode(monkeypatch, installed)monkeypatch.setattr(dr, "_run_installer", lambda *a, **k: pytest.fail("started a repair"))@@ -467,6 +468,28 @@ def test_a_current_release_starts_nothing(monkeypatch, installed):assert dr.repair_diffusers_before_imports(lines.append) is False and lines == [][email protected](sys.version_info < (3, 11), reason = "diffusers-pin.txt names 0.42.1 from 3.11")+def test_the_release_behind_is_0_41_on_python_311(monkeypatch):+ _release_mode(monkeypatch, "0.41.0")+ assert dr._release_behind() is True+++def test_the_retired_main_build_is_left_for_the_update(monkeypatch):+ """The d42ebf9c git build reports 0.41.0.dev0; startup repair touches index installs only, and the build still+ has FLUX.3, so it stays until an update's dependency pass replaces it with the release."""+ _release_mode(monkeypatch, "0.41.0.dev0")+ _installed_diffusers(+ monkeypatch,+ {+ "url": "https://github.com/huggingface/diffusers.git",+ "vcs_info": {"vcs": "git", "commit_id": "d42ebf9c6e0b46103b74283f5324357a67acaa04"},+ },+ )+ monkeypatch.setattr(dr, "_run_installer", lambda *a, **k: pytest.fail("started a repair"))+ lines = []+ assert dr.repair_diffusers_before_imports(lines.append) is False and lines == []++@pytest.mark.parametrize("env", [{}, {"UNSLOTH_DIFFUSERS_MAIN": "0"}])def test_a_release_behind_the_pin_is_prefetched_then_repaired(monkeypatch, env):_release_mode(monkeypatch, "0.40.0")diff --git a/studio/backend/tests/test_diffusion_flux3.py b/studio/backend/tests/test_diffusion_flux3.pyindex 87cd5d49886..db09adbe0de 100644--- a/studio/backend/tests/test_diffusion_flux3.py+++ b/studio/backend/tests/test_diffusion_flux3.py@@ -139,14 +139,18 @@ def test_bf16_component_table():assert vae_gb <= 0.5-# ── unreleased diffusers gate ────────────────────────────────────────────────-def test_minimum_is_the_unreleased_next_release():+# ── diffusers version gate ───────────────────────────────────────────────────+def test_minimum_is_the_released_0_42(monkeypatch):+ """0.42.0 shipped FLUX.3 Klein, so a 0.41.0 install on Python 3.11+ is told to update, not sent to a git build."""+ monkeypatch.setattr(families.sys, "version_info", (3, 12, 1, "final", 0))for cls in ("Flux3ModularPipeline", "Flux3DistilledModularPipeline"):minimum, _ = pipeline_class_requirement(cls)assert minimum == "0.42.0"- assert minimum in families._UNRELEASED_MIN_DIFFUSERS+ assert minimum not in families._UNRELEASED_MIN_DIFFUSERSmessage = families._too_old_message("Flux3DistilledModularPipeline", "flux.3-klein", "0.41.0")- assert "has not been released yet" in message+ assert "has not been released yet" not in message and "git" not in message, message+ assert "Settings, Check for updates" in message+ assert "pip install -U 'diffusers>=0.42.0'" in message and "Python >= 3.11" in messagedef _fake_diffusers(monkeypatch, root, version):@@ -612,16 +616,18 @@ def test_contiguous_guard_feeds_mx_linears_a_contiguous_activation():assert not getattr(model[1], "_unsloth_contig_hook", False)-def test_python_310_gets_a_reason_it_can_act_on(monkeypatch):- # Diffusers main (and so the pinned FLUX.3 build) needs Python 3.11; the installer skips it below that, so the- # refusal must not send a 3.10 user to reinstall or fetch an archive that cannot install.- monkeypatch.setattr(families.sys, "version_info", (3, 10, 14, "final", 0))[email protected]("old_python", [(3, 10, 14, "final", 0), (3, 9, 18, "final", 0)])+def test_python_below_311_gets_a_reason_it_can_act_on(monkeypatch, old_python):+ # diffusers 0.42.0 needs Python 3.11 and diffusers-pin.txt keeps 0.41.0 on 3.10 (0.36.0 on 3.9), so the+ # refusal must not send that user to an update or a pip upgrade that cannot install.+ monkeypatch.setattr(families.sys, "version_info", old_python)message = families._too_old_message("Flux3DistilledModularPipeline", "flux.3-klein", "0.41.0")- assert "Python 3.11" in message and "3.10" in message- assert "archive" not in message- monkeypatch.setattr(families.sys, "version_info", (3, 12, 1, "final", 0))+ assert "Python 3.11" in message and f"Python 3.{old_python[1]}" in message, message+ assert "pip install" not in message and "Check for updates" not in message, message+ assert "archive" not in message and "has not been released yet" not in message+ monkeypatch.setattr(families.sys, "version_info", (3, 11, 0, "final", 0))message = families._too_old_message("Flux3DistilledModularPipeline", "flux.3-klein", "0.41.0")- assert "Python 3.11" not in message and "has not been released yet" in message+ assert "this is Python" not in message and "Check for updates" in message# ── hosted artifacts ─────────────────────────────────────────────────────────diff --git a/studio/install_python_stack.py b/studio/install_python_stack.pyindex 514c64b8e9a..21d6d7879b9 100644--- a/studio/install_python_stack.py+++ b/studio/install_python_stack.py@@ -11373,7 +11373,7 @@ def _diffusers_release_target() -> "str | None":def _diffusers_release_behind() -> bool:"""Resident diffusers older than diffusers-pin.txt's ``==``; a git / zip / checkout build is judged on- release numbers (the main build's 0.41.0.dev0 is current), an index prerelease is not."""+ its release number (0.41.0.dev0 reads as 0.41.0), an index prerelease is not."""target = _diffusers_release_target()installed = _installed_distribution_version("diffusers")if target is None or installed is None:@@ -12442,8 +12442,7 @@ def install_python_stack() -> int:)# 11b. The pinned Diffusers release, after every other requirements file and on every path.- # Stands down once 11c's build is resident (main reports 0.41.0.dev0, never ==0.40.0), else every- # update would install the release then main again.+ # Stands down while 11c's main build is pinned and resident, else every update reinstalls both.if not _skip_step(REQ_ROOT / "diffusers-pin.txt","diffusers pin",diff --git a/tests/studio/install/test_diffusers_pin.py b/tests/studio/install/test_diffusers_pin.pyindex 35ef3a05ca5..8bad90711af 100644--- a/tests/studio/install/test_diffusers_pin.py+++ b/tests/studio/install/test_diffusers_pin.py@@ -10,6 +10,7 @@ import ioimport pathlibimport reimport subprocess+import sysimport tokenizeimport pytest@@ -86,15 +87,36 @@ def _code_only(source: str) -> str:def test_the_pin_file_exists_and_names_the_first_supported_release():assert PIN_FILE.is_file(), f"{PIN_FILE} is missing"lines = _requirements(PIN_FILE)- modern = [line for line in lines if 'python_version >= "3.10"' in line]- assert modern == ['diffusers==0.41.0 ; python_version >= "3.10"'], modern- legacy = [line for line in lines if 'python_version < "3.10"' in line]- assert legacy == ['diffusers==0.36.0 ; python_version < "3.10"'], legacy- assert "://" not in modern[0], "the released dependency must not require a source build"- assert 'python_version >= "3.10"' in modern[0], (- "diffusers dropped Python 3.9 in 0.38, so the release needs a >= 3.10 marker or "- "the resolver has no candidate at all on a 3.9 host"- )+ assert lines == [+ 'diffusers==0.42.1 ; python_version >= "3.11"',+ 'diffusers==0.41.0 ; python_version == "3.10"',+ 'diffusers==0.36.0 ; python_version < "3.10"',+ ], lines+ assert not any("://" in line for line in lines), "a release must not require a source build"+++ "python, release",+ [+ ("3.14", "0.42.1"),+ ("3.13", "0.42.1"),+ ("3.11", "0.42.1"),+ # 0.42.0 declares requires-python >= 3.11 and 0.38 dropped 3.9, so each floor keeps a release.+ ("3.10", "0.41.0"),+ ("3.9", "0.36.0"),+ ],+)+def test_every_supported_python_gets_exactly_one_installable_release(python, release):+ from packaging.requirements import Requirement++ environment = {"python_version": python, "python_full_version": f"{python}.0"}+ picked = [+ str(spec.version)+ for spec in (Requirement(line) for line in _requirements(PIN_FILE))+ if spec.marker is None or spec.marker.evaluate(environment)+ for spec in spec.specifier+ ]+ assert picked == [release], pickeddef test_only_the_pin_file_names_diffusers():@@ -140,25 +162,27 @@ def test_the_main_build_pins_a_commit_and_runs_after_the_release():assert source.index(call) > source.rindex('req = REQ_ROOT / "diffusers-pin.txt"')-def test_the_shipped_main_build_is_active_with_a_digest():- """FLUX.3 Klein (huggingface/diffusers#15046, merged 2026-10-15) is in no release, so the pinned build ships active."""- lines = _requirements(MAIN_FILE)- assert len(lines) == 1 and re.fullmatch(- r"diffusers @ git\+https://\S+@[0-9a-f]{40}", lines[0]- ), lines+def test_the_shipped_main_build_is_commented_out_but_keeps_its_commit():+ """0.42.1 carries FLUX.3 Klein: nothing installs from git, and re-enabling is one uncomment away."""+ assert _requirements(MAIN_FILE) == []text = MAIN_FILE.read_text(encoding = "utf-8")+ assert re.search(r"^# diffusers @ git\+https://\S+@[0-9a-f]{40}$", text, re.M), textassert len(re.findall(r"^# archive-sha256: [0-9a-f]{64}$", text, re.M)) == 1module = _probe_module("install_python_stack_probe_shipped", shipped = True)- assert module._diffusers_main_active() is True+ assert module._diffusers_main_active() is False+ assert module._diffusers_main_supersedes_release() is False-def test_the_flux3_pin_is_main_with_the_merged_flux3_support():- """huggingface/diffusers#15046 merged on 2026-10-15 (7ecb1e1b4); the pin is main at d42ebf9c (2026-10-16, the- prompt upsampler block #15058), which carries it, with that commit's archive digest, not the PR branch head."""+def test_the_retired_flux3_pin_keeps_its_commit_and_digest():+ """d42ebf9c (main on 2026-10-16, after huggingface/diffusers#15046 and #15058) is an ancestor of v0.42.1, so the+ release replaces it; the line and its archive digest stay for the next unreleased model to re-pin."""text = MAIN_FILE.read_text(encoding = "utf-8")- (line,) = _requirements(MAIN_FILE)- assert line.endswith("@d42ebf9c6e0b46103b74283f5324357a67acaa04"), line- assert "ec288418a5efa32e9fd49eb7b193babce920a106" not in line+ assert re.search(+ r"^# diffusers @ git\+https://github\.com/huggingface/diffusers\.git"+ r"@d42ebf9c6e0b46103b74283f5324357a67acaa04$",+ text,+ re.M,+ ), textassert re.search(r"^# archive-sha256: c46925a12c1b64340272dbd4c5d72a4298ecd4c96cad2c9d549b85a99ffb491f$",text,@@ -923,7 +947,7 @@ def test_the_startup_prefetch_fills_the_cache_and_never_the_environment(monkeypadef _release_module(monkeypatch,name,- installed = "0.41.0",+ installed = "0.42.1",):module = _probe_module(name, active = False)monkeypatch.delenv("UNSLOTH_DIFFUSERS_MAIN", raising = False)@@ -938,7 +962,7 @@ def _release_module(def test_a_missing_release_still_forces_the_pass(monkeypatch):- module = _release_module(monkeypatch, "install_python_stack_release_damaged", "0.41.0")+ module = _release_module(monkeypatch, "install_python_stack_release_damaged", "0.42.1")assert module._diffusers_main_needs_dependency_pass() is False# Same-version damage would not converge: 11b's version check skips it.monkeypatch.setattr(module, "_payload_recorded_intact", lambda dist: False)@@ -959,32 +983,64 @@ def test_the_shipped_main_step_skips_without_installing(monkeypatch):assert steps == {"diffusers-main.txt": "skipped"}+_NEEDS_311 = pytest.mark.skipif(+ sys.version_info < (3, 11), reason = "diffusers-pin.txt names 0.42.1 from Python 3.11"+)+++@_NEEDS_311@pytest.mark.parametrize("installed, forced",[- ("0.41.0", False),- ("0.41.0.dev0", True),- ("0.41.0rc1", True),- ("0.42.0", False),+ ("0.42.1", False),+ ("0.42.1.post1", False),+ ("0.42.1rc1", True),+ ("0.42.0", True),+ ("0.41.0", True),+ ("0.43.0", False),("0.40.0", True),],)def test_the_fast_path_is_forced_only_by_a_release_behind_the_pin(monkeypatch, installed, forced):module = _release_module(monkeypatch, "install_python_stack_release_fast", installed)monkeypatch.setattr(module, "_has_working_git", lambda: pytest.fail("probed git"))- assert module._diffusers_release_target() == "0.41.0"+ assert module._diffusers_release_target() == "0.42.1"assert module._diffusers_main_needs_dependency_pass() is forced+@_NEEDS_311def test_a_git_or_zip_build_of_the_release_keeps_the_fast_path(monkeypatch):- module = _release_module(monkeypatch, "install_python_stack_release_built", "0.41.0.dev0")+ module = _release_module(monkeypatch, "install_python_stack_release_built", "0.43.0.dev0")for direct in ({"vcs_info": {"vcs": "git"}}, {"archive_info": {}}):monkeypatch.setattr(module, "_recorded_direct_url", lambda dist, d = direct: dict(d, url = "x"))assert module._diffusers_main_needs_dependency_pass() is False+_RETIRED_MAIN = {+ "url": "https://github.com/huggingface/diffusers.git",+ "vcs_info": {+ "vcs": "git",+ "commit_id": "d42ebf9c6e0b46103b74283f5324357a67acaa04",+ "requested_revision": "d42ebf9c6e0b46103b74283f5324357a67acaa04",+ },+}+++@_NEEDS_311[email protected]("built", [_RETIRED_MAIN, {"url": "https://x/d.zip", "archive_info": {}}])+def test_the_retired_main_build_is_replaced_by_the_release_on_update(monkeypatch, built):+ """The d42ebf9c build (git, or the zip route) reports 0.41.0.dev0: behind 0.42.1, so an update runs the pass+ and the release step installs the pin instead of standing down for a main build nothing asks for."""+ module = _release_module(monkeypatch, "install_python_stack_release_retired", "0.41.0.dev0")+ monkeypatch.setattr(module, "_recorded_direct_url", lambda dist: dict(built))+ monkeypatch.setattr(module, "_has_working_git", lambda: pytest.fail("probed git"))+ assert module._diffusers_release_behind() is True+ assert module._diffusers_main_needs_dependency_pass() is True+ assert module._diffusers_main_supersedes_release() is False++def test_the_release_prefetch_fetches_the_pin_into_scratch_only_when_behind(monkeypatch):- module = _release_module(monkeypatch, "install_python_stack_release_prefetch", "0.41.0")+ module = _release_module(monkeypatch, "install_python_stack_release_prefetch", "0.42.1")monkeypatch.setattr(module.subprocess, "run", lambda *a, **k: pytest.fail("spawned"))monkeypatch.setattr(module, "_bootstrap_uv", lambda: pytest.fail("bootstrapped uv"))assert module._prefetch_diffusers_main() == 1@@ -1051,7 +1107,7 @@ def _release_repair():installs.append(req)if install_ok:- state["version"] = "0.41.0"+ state["version"] = module._diffusers_release_target()return install_okmonkeypatch.setattr(module, "pip_install_try", fake_install)@@ -1067,7 +1123,7 @@ def test_the_startup_repair_installs_the_release_behind_the_pin(monkeypatch):def test_the_startup_repair_leaves_a_current_release_alone(monkeypatch):- for installed in ("0.41.0", "0.41.0.post1"):+ for installed in ("0.42.1", "0.42.1.post1"):module, installs, _ = _release_repair(monkeypatch, "rel_repair_noop", installed)assert module._repair_diffusers_main() == 1 and installs == []