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
Resolve compatible Unsloth and Zoo pairs for all no-torch installs (#16157)
Daniel Han95aae40bb42d
diff --git a/install.ps1 b/install.ps1index f991e7ebc1f..00c35b7447c 100644--- a/install.ps1+++ b/install.ps1@@ -9898,10 +9898,117 @@ main()$_unslothZooInstallSpec = "unsloth-zoo>=2026.10.11"# Twin of install.sh's _relax_unsloth_floors_to_index (#14031).+ function Resolve-NoTorchPair {+ param([string]$ReleaseSpec, [string]$ZooSpec)+ $pairCode = @'+def _no_torch_pair(unsloth_spec, zoo_spec, use_uv=True, uv_executable="uv", install_env=None):+ """Resolve the pair from wheel metadata without resolving training dependencies."""+ import re+ import subprocess+ import sys+ import tempfile+ from importlib.metadata import distributions++ cache = {}++ def metadata(name, requirements):+ key = (name, tuple(requirements))+ if key in cache:+ return cache[key]+ with tempfile.TemporaryDirectory(prefix="unsloth-pair-") as target:+ cmd = (+ [uv_executable, "pip", "install", "--python", sys.executable, "--resolution", "highest"]+ if use_uv+ else [sys.executable, "-m", "pip", "install", "--upgrade"]+ )+ cmd += ["--no-deps", "--quiet", "--target", target, *requirements]+ try:+ result = subprocess.run(+ cmd,+ env=install_env,+ stdout=subprocess.DEVNULL,+ stderr=subprocess.DEVNULL,+ timeout=120,+ **(+ {"creationflags": subprocess.CREATE_NO_WINDOW}+ if sys.platform == "win32"+ else {}+ ),+ )+ dist = (+ next(+ d+ for d in distributions(path=[target])+ if re.sub(r"[-_.]+", "-", d.metadata["Name"]).lower() == name+ )+ if result.returncode == 0+ else None+ )+ value = (dist.version, dist.requires or []) if dist else None+ except (OSError, subprocess.SubprocessError, StopIteration, ValueError):+ value = None+ cache[key] = value+ return value++ if metadata("unsloth-zoo", [zoo_spec]) is None:+ zoo_spec = "unsloth-zoo"+ request, cap, seen = unsloth_spec, [], set()+ while True:+ unsloth = metadata("unsloth", [request, *cap])+ if unsloth is None:+ if request != "unsloth":+ request = "unsloth"+ continue+ return None+ version, requires = unsloth+ if version in seen or not re.fullmatch(r"[0-9][0-9A-Za-z.+!-]*", version):+ return None+ seen.add(version)+ zoo_requires = [r for r in requires if re.match(r"(?i)^unsloth[-_.]zoo\b", r)]+ zoo = metadata("unsloth-zoo", [zoo_spec, *zoo_requires])+ if zoo is not None:+ return version, zoo[0], int(request != unsloth_spec)+ cap = [f"unsloth<{version}"]++import sys+pair = _no_torch_pair(sys.argv[1], sys.argv[2], uv_executable=sys.argv[3])+if pair is None:+ raise SystemExit(1)+print(*pair)+'@+ $pairScript = [System.IO.Path]::GetTempFileName()+ try {+ [System.IO.File]::WriteAllText($pairScript, $pairCode, (New-Object System.Text.UTF8Encoding($false)))+ & $VenvPython -I $pairScript $ReleaseSpec $ZooSpec $script:UvExe+ } finally {+ Remove-Item -LiteralPath $pairScript -ErrorAction SilentlyContinue+ }+ }+function Resolve-UnslothFloorsForIndex {- param([string]$ReleaseSpec, [string]$ZooSpec, [string]$DesktopVersion, [string]$Marker)+ param([string]$ReleaseSpec, [string]$ZooSpec, [string]$DesktopVersion, [string]$Marker, [bool]$NoTorch = $false)$result = @{ Release = $ReleaseSpec; Zoo = $ZooSpec; Available = $null }Remove-Item -LiteralPath $Marker -Force -ErrorAction SilentlyContinue+ if ($NoTorch) {+ $pair = Resolve-NoTorchPair $ReleaseSpec $ZooSpec+ if ($LASTEXITCODE -ne 0 -or -not $pair) {+ throw "Could not resolve a compatible unsloth / unsloth-zoo pair for no-torch mode"+ }+ $parts = ([string]$pair).Split(' ')+ $result.Release = "unsloth==$($parts[0])"+ $result.Zoo = "unsloth-zoo==$($parts[1])"+ if ($parts[2] -eq "1") {+ $result.Available = $parts[0]+ if ($DesktopVersion) {+ substep "[WARN] your package index cannot meet $ReleaseSpec; installing unsloth $($parts[0]) + unsloth-zoo $($parts[1])" "Yellow"+ try {+ $json = @{ requested = $DesktopVersion; available = $parts[0] } | ConvertTo-Json -Compress+ [System.IO.File]::WriteAllText($Marker, $json + "`n", (New-Object System.Text.UTF8Encoding($false)))+ } catch { }+ }+ }+ return $result+ }$prevEap = $ErrorActionPreference$ErrorActionPreference = "Continue"try {@@ -9939,7 +10046,7 @@ main()return $result}$_floors = Resolve-UnslothFloorsForIndex -ReleaseSpec $_unslothReleaseInstallSpec -ZooSpec $_unslothZooInstallSpec `- -DesktopVersion $_desktopMinVer -Marker (Join-Path $VenvDir "unsloth_feed_ceiling.json")+ -DesktopVersion $_desktopMinVer -Marker (Join-Path $VenvDir "unsloth_feed_ceiling.json") -NoTorch ($SkipTorch -and $PackageName -eq "unsloth")$_unslothReleaseInstallSpec = $_floors.Release$_unslothZooInstallSpec = $_floors.Zooif ($_floors.Available -and $_unslothDesktopInstallSpec) { $_unslothDesktopInstallSpec = $_unslothReleaseInstallSpec }diff --git a/install.sh b/install.shindex 1f2fc6807f7..36adf01cd62 100755--- a/install.sh+++ b/install.sh@@ -7597,8 +7597,105 @@ _rfi_newest() {sed -n "s/^$1==\([0-9][0-9A-Za-z.+!-]*\).*/\1/p" "$_rfi_out"rm -f "$_rfi_out"}+_rfi_no_torch_pair() {+ "$_VENV_PY" -I - "$1" "$2" <<'UNSLOTH_PAIR_PY'+def _no_torch_pair(unsloth_spec, zoo_spec, use_uv=True, uv_executable="uv", install_env=None):+ """Resolve the pair from wheel metadata without resolving training dependencies."""+ import re+ import subprocess+ import sys+ import tempfile+ from importlib.metadata import distributions++ cache = {}++ def metadata(name, requirements):+ key = (name, tuple(requirements))+ if key in cache:+ return cache[key]+ with tempfile.TemporaryDirectory(prefix="unsloth-pair-") as target:+ cmd = (+ [uv_executable, "pip", "install", "--python", sys.executable, "--resolution", "highest"]+ if use_uv+ else [sys.executable, "-m", "pip", "install", "--upgrade"]+ )+ cmd += ["--no-deps", "--quiet", "--target", target, *requirements]+ try:+ result = subprocess.run(+ cmd,+ env=install_env,+ stdout=subprocess.DEVNULL,+ stderr=subprocess.DEVNULL,+ timeout=120,+ **(+ {"creationflags": subprocess.CREATE_NO_WINDOW}+ if sys.platform == "win32"+ else {}+ ),+ )+ dist = (+ next(+ d+ for d in distributions(path=[target])+ if re.sub(r"[-_.]+", "-", d.metadata["Name"]).lower() == name+ )+ if result.returncode == 0+ else None+ )+ value = (dist.version, dist.requires or []) if dist else None+ except (OSError, subprocess.SubprocessError, StopIteration, ValueError):+ value = None+ cache[key] = value+ return value++ if metadata("unsloth-zoo", [zoo_spec]) is None:+ zoo_spec = "unsloth-zoo"+ request, cap, seen = unsloth_spec, [], set()+ while True:+ unsloth = metadata("unsloth", [request, *cap])+ if unsloth is None:+ if request != "unsloth":+ request = "unsloth"+ continue+ return None+ version, requires = unsloth+ if version in seen or not re.fullmatch(r"[0-9][0-9A-Za-z.+!-]*", version):+ return None+ seen.add(version)+ zoo_requires = [r for r in requires if re.match(r"(?i)^unsloth[-_.]zoo\b", r)]+ zoo = metadata("unsloth-zoo", [zoo_spec, *zoo_requires])+ if zoo is not None:+ return version, zoo[0], int(request != unsloth_spec)+ cap = [f"unsloth<{version}"]++import sys+pair = _no_torch_pair(*sys.argv[1:])+if pair is None:+ raise SystemExit(1)+print(*pair)+UNSLOTH_PAIR_PY+}+_relax_unsloth_floors_to_index() {rm -f "$_UNSLOTH_FEED_CEILING_MARKER"+ if [ "${SKIP_TORCH:-false}" = true ] && [ "${PACKAGE_NAME:-unsloth}" = unsloth ]; then+ _rfi_pair=$(_rfi_no_torch_pair "$_unsloth_release_install_spec" "$_unsloth_zoo_install_spec") || {+ substep "[ERROR] Could not resolve a compatible unsloth / unsloth-zoo pair for no-torch mode." "$C_WARN"+ return 1+ }+ set -- $_rfi_pair+ _unsloth_release_install_spec="unsloth==$1"+ _unsloth_zoo_install_spec="unsloth-zoo==$2"+ if [ -n "$_unsloth_desktop_install_spec" ]; then+ _unsloth_desktop_install_spec=$_unsloth_release_install_spec+ if [ "$3" = 1 ]; then+ substep "[WARN] your package index cannot meet unsloth>=$UNSLOTH_DESKTOP_BACKEND_VERSION; installing unsloth $1 + unsloth-zoo $2" "$C_WARN"+ printf '{"requested": "%s", "available": "%s"}\n' "$UNSLOTH_DESKTOP_BACKEND_VERSION" "$1" \+ > "$_UNSLOTH_FEED_CEILING_MARKER" 2>/dev/null || true+ fi+ fi+ return 0+ fiprintf '%s\n%s\n' "$_unsloth_release_install_spec" "$_unsloth_zoo_install_spec" | _rfi_newest unsloth > /dev/null && return 0# The newest zoo, then the newest unsloth not above it (an unsloth never needs a newer zoo), pinned as a pair._rfi_zoo=$(printf 'unsloth-zoo\n' | _rfi_newest unsloth-zoo) || return 0diff --git a/studio/install_python_stack.py b/studio/install_python_stack.pyindex fd566ceb586..e49886fa2ee 100644--- a/studio/install_python_stack.py+++ b/studio/install_python_stack.py@@ -9935,23 +9935,129 @@ def _mirror_retry(args: "tuple[str, ...]", output: bytes, rerun) -> "bool | NoneFEED_CEILING_MARKER = "unsloth_feed_ceiling.json"-def _desktop_unsloth_spec(package_name: str) -> "tuple[str, str]":- """Desktop's backend floor, lowered to a lagging index's newest release (#14031).+def _no_torch_pair(+ unsloth_spec,+ zoo_spec,+ use_uv = True,+ uv_executable = "uv",+ install_env = None,+):+ """Resolve the pair from wheel metadata without resolving training dependencies."""+ import re+ import subprocess+ import sys+ import tempfile+ from importlib.metadata import distributions++ cache = {}++ def metadata(name, requirements):+ key = (name, tuple(requirements))+ if key in cache:+ return cache[key]+ with tempfile.TemporaryDirectory(prefix = "unsloth-pair-") as target:+ cmd = (+ [+ uv_executable,+ "pip",+ "install",+ "--python",+ sys.executable,+ "--resolution",+ "highest",+ ]+ if use_uv+ else [sys.executable, "-m", "pip", "install", "--upgrade"]+ )+ cmd += ["--no-deps", "--quiet", "--target", target, *requirements]+ try:+ result = subprocess.run(+ cmd,+ env = install_env,+ stdout = subprocess.DEVNULL,+ stderr = subprocess.DEVNULL,+ timeout = 120,+ **(+ {"creationflags": subprocess.CREATE_NO_WINDOW}+ if sys.platform == "win32"+ else {}+ ),+ )+ dist = (+ next(+ d+ for d in distributions(path = [target])+ if re.sub(r"[-_.]+", "-", d.metadata["Name"]).lower() == name+ )+ if result.returncode == 0+ else None+ )+ value = (dist.version, dist.requires or []) if dist else None+ except (OSError, subprocess.SubprocessError, StopIteration, ValueError):+ value = None+ cache[key] = value+ return value++ if metadata("unsloth-zoo", [zoo_spec]) is None:+ zoo_spec = "unsloth-zoo"+ request, cap, seen = unsloth_spec, [], set()+ while True:+ unsloth = metadata("unsloth", [request, *cap])+ if unsloth is None:+ if request != "unsloth":+ request = "unsloth"+ continue+ return None+ version, requires = unsloth+ if version in seen or not re.fullmatch(r"[0-9][0-9A-Za-z.+!-]*", version):+ return None+ seen.add(version)+ zoo_requires = [r for r in requires if re.match(r"(?i)^unsloth[-_.]zoo\b", r)]+ zoo = metadata("unsloth-zoo", [zoo_spec, *zoo_requires])+ if zoo is not None:+ return version, zoo[0], int(request != unsloth_spec)+ cap = [f"unsloth<{version}"]- Returns the (unsloth, unsloth-zoo) requirements to install. A lowered unsloth comes with- the zoo it was resolved against, since the no-torch path installs --no-deps and so never- reads unsloth's zoo floor. Twin of install.sh's _relax_unsloth_floors_to_index.- """++def _desktop_unsloth_spec(package_name: str) -> "tuple[str, str]":+ """Backend requirements permitted by the Desktop floor and package index (#14031)."""zoo_spec = "unsloth-zoo"desktop_min_ver = os.environ.get("UNSLOTH_DESKTOP_BACKEND_VERSION", "").strip()- if not (desktop_min_ver and package_name == "unsloth"):+ if package_name != "unsloth" or (not desktop_min_ver and not NO_TORCH):return package_name, zoo_spec- spec = f"unsloth>={desktop_min_ver}"+ spec = f"unsloth>={desktop_min_ver}" if desktop_min_ver else package_namemarker = Path(sys.prefix) / FEED_CEILING_MARKERtry:marker.unlink()except OSError:pass+ if NO_TORCH:+ pair = _no_torch_pair(+ spec,+ zoo_spec,+ use_uv = USE_UV,+ install_env = _install_env_for_cmd(+ ["uv", "pip", "install"] if USE_UV else [sys.executable, "-m", "pip", "install"]+ ),+ )+ if pair is None:+ raise RuntimeError(+ "Could not resolve a compatible unsloth / unsloth-zoo pair for no-torch mode"+ )+ available, zoo, lowered = pair+ if lowered and desktop_min_ver:+ _note(+ f"[WARN] your package index cannot meet {spec}; installing unsloth {available} + unsloth-zoo {zoo}",+ _warn,+ )+ try:+ marker.write_text(+ json.dumps({"requested": desktop_min_ver, "available": available}) + "\n",+ encoding = "utf-8",+ )+ except OSError:+ pass+ return f"unsloth=={available}", f"unsloth-zoo=={zoo}"if not USE_UV:return spec, zoo_spec@@ -9989,8 +10095,6 @@ def _desktop_unsloth_spec(package_name: str) -> "tuple[str, str]":found = resolve(spec, zoo_spec, deps = True) or {}if found.get("unsloth"):- # The zoo it resolved against as a floor: the no-torch install is --no-deps, so a bare- # unsloth-zoo under UV_RESOLUTION=lowest could pick one below unsloth's own zoo floor.return spec, (f"unsloth-zoo>={found['unsloth-zoo']}" if found.get("unsloth-zoo") else zoo_spec)diff --git a/tests/python/test_desktop_unsloth_spec_no_deps_pair.py b/tests/python/test_desktop_unsloth_spec_no_deps_pair.pynew file mode 100644index 00000000000..f8820a78f4e--- /dev/null+++ b/tests/python/test_desktop_unsloth_spec_no_deps_pair.py@@ -0,0 +1,277 @@+# SPDX-License-Identifier: AGPL-3.0-or-later+# Copyright 2023-present Daniel Han-Chen, Michael Han-Chen & the Unsloth team. All rights reserved.++from __future__ import annotations++import ast+import json+import os+import re+import shlex+import shutil+import subprocess+import sys+import zipfile+from pathlib import Path++import pytest++STUDIO_DIR = Path(__file__).resolve().parents[2] / "studio"+sys.path.insert(0, str(STUDIO_DIR))++import install_python_stack as ips # noqa: E402++pytestmark = pytest.mark.skipif(shutil.which("uv") is None, reason = "needs uv")+++def _wheel(+ index: Path,+ name: str,+ version: str,+ requires = (),+) -> None:+ dist = f"{name.replace('-', '_')}-{version}.dist-info"+ meta = f"Metadata-Version: 2.1\nName: {name}\nVersion: {version}\n"+ meta += "".join(f"Requires-Dist: {r}\n" for r in requires)+ path = index / f"{name.replace('-', '_')}-{version}-py3-none-any.whl"+ with zipfile.ZipFile(path, "w") as z:+ z.writestr(dist + "/METADATA", meta)+ z.writestr(+ dist + "/WHEEL", "Wheel-Version: 1.0\nRoot-Is-Purelib: true\nTag: py3-none-any\n"+ )+ z.writestr(dist + "/RECORD", "")+++def lagging_index(tmp_path, monkeypatch):+ index = tmp_path / "index"+ index.mkdir()+ _wheel(index, "unsloth", "2026.10.6", ["unsloth-zoo>=2026.10.6"])+ _wheel(index, "unsloth", "2026.10.7", ["unsloth-zoo>=2026.10.7"])+ _wheel(index, "unsloth-zoo", "2026.10.6")+ for key in ("UV_NO_DEPS", "UV_CONSTRAINT", "UV_OVERRIDE", "UV_RESOLUTION", "UV_EXCLUDE_NEWER"):+ monkeypatch.delenv(key, raising = False)+ config = tmp_path / "uv.toml"+ config.write_text(+ "[pip]\nno-index = true\nfind-links = [" + json.dumps(str(index)) + "]\n", encoding = "utf-8"+ )+ monkeypatch.delenv("UV_NO_CONFIG", raising = False)+ monkeypatch.setenv("UV_CONFIG_FILE", str(config))+ monkeypatch.setenv("PIP_NO_INDEX", "1")+ monkeypatch.setenv("PIP_FIND_LINKS", str(index))+ monkeypatch.setenv("TMPDIR", str(tmp_path))+ monkeypatch.setenv("UV_CACHE_DIR", str(tmp_path / "uv-cache"))+ monkeypatch.setenv("UNSLOTH_DESKTOP_BACKEND_VERSION", "2026.10.6")+ monkeypatch.setattr(ips, "USE_UV", True)++ monkeypatch.setattr(ips.sys, "prefix", str(tmp_path))+ return index+++def _no_deps_selection(specs, index) -> dict:+ out = subprocess.run(+ [+ "uv",+ "pip",+ "compile",+ "--no-index",+ "--find-links",+ str(index),+ "--no-deps",+ "--resolution",+ "highest",+ "--no-header",+ "--no-annotate",+ "-",+ ],+ input = "\n".join(specs) + "\n",+ capture_output = True,+ text = True,+ check = True,+ ).stdout+ return dict(re.findall(r"^(unsloth(?:-zoo)?)==(\S+)", out, re.MULTILINE))+++def test_no_torch_install_gets_the_resolved_unsloth_not_a_lower_bound(lagging_index, monkeypatch):+ monkeypatch.setattr(ips, "NO_TORCH", True)+ specs = ips._desktop_unsloth_spec("unsloth")+ assert _no_deps_selection(specs, lagging_index) == {+ "unsloth": "2026.10.6",+ "unsloth-zoo": "2026.10.6",+ }+++def test_with_deps_install_keeps_the_floor(lagging_index, monkeypatch):+ monkeypatch.setattr(ips, "NO_TORCH", False)+ assert ips._desktop_unsloth_spec("unsloth") == ("unsloth>=2026.10.6", "unsloth-zoo>=2026.10.6")++[email protected](params = ["python", "sh", "powershell"])+def installer_pair(request, tmp_path, monkeypatch):+ monkeypatch.setattr(ips, "NO_TORCH", True)++ def resolve(*, selected_uv = False):+ if request.param == "python":+ return ips._desktop_unsloth_spec("unsloth")+ floor = os.environ.get("UNSLOTH_DESKTOP_BACKEND_VERSION", "")+ release = f"unsloth>={floor or '2026.10.6'}"+ marker = tmp_path / ips.FEED_CEILING_MARKER+ if request.param == "sh":+ shell = shutil.which("sh")+ if not shell:+ pytest.skip("POSIX shell unavailable")+ source = (STUDIO_DIR.parent / "install.sh").read_text(encoding = "utf-8")+ functions = "\n".join(+ m.group(0)+ for name in ("_rfi_newest", "_rfi_no_torch_pair", "_relax_unsloth_floors_to_index")+ if (m := re.search(rf"(?ms)^{name}\(\) \{{.*?^\}}", source))+ )+ values = {+ "VENV_DIR": tmp_path.as_posix(),+ "_VENV_PY": Path(sys.executable).as_posix(),+ "SKIP_TORCH": "true",+ "PACKAGE_NAME": "unsloth",+ "C_WARN": "",+ "_unsloth_release_install_spec": release,+ "_unsloth_desktop_install_spec": f"unsloth>={floor}" if floor else "",+ "_unsloth_zoo_install_spec": "unsloth-zoo>=2026.10.6",+ "_UNSLOTH_FEED_CEILING_MARKER": marker.as_posix(),+ }+ script = tmp_path / "pair.sh"+ script.write_text(+ "set -e\n"+ + functions+ + "\n"+ + "\n".join(f"{k}={shlex.quote(v)}" for k, v in values.items())+ + '\nsubstep() { printf "%s\\n" "$1" >&2; }\n_relax_unsloth_floors_to_index\n'+ + 'printf "%s\\n" "$_unsloth_release_install_spec" "$_unsloth_zoo_install_spec"\n',+ encoding = "utf-8",+ )+ argv = [shell, str(script)]+ else:+ shell = shutil.which("powershell") or shutil.which("pwsh")+ if not shell:+ pytest.skip("PowerShell unavailable")+ source = (STUDIO_DIR.parent / "install.ps1").read_text(encoding = "utf-8")+ functions = "\n".join(+ m.group(0)+ for name in ("Resolve-NoTorchPair", "Resolve-UnslothFloorsForIndex")+ if (m := re.search(rf"(?ms)^ function {name} \{{.*?^ \}}", source))+ )+ quote = lambda value: "'" + str(value).replace("'", "''") + "'"+ script = tmp_path / "pair.ps1"+ script.write_text(+ '$ErrorActionPreference = "Stop"\n'+ + functions+ + f"\n$VenvDir = {quote(tmp_path)}\n$VenvPython = {quote(sys.executable)}\n$script:UvExe = {quote(shutil.which('uv') if selected_uv else 'uv')}\n"+ + "function substep { param($Message, $Color); [Console]::Error.WriteLine($Message) }\n"+ + f"$r = Resolve-UnslothFloorsForIndex -ReleaseSpec {quote(release)} -ZooSpec 'unsloth-zoo>=2026.10.6' -DesktopVersion {quote(floor)} -Marker {quote(marker)}"+ + (" -NoTorch $true" if "[bool]$NoTorch" in functions else "")+ + "\nWrite-Output $r.Release\nWrite-Output $r.Zoo\n",+ encoding = "utf-8-sig",+ )+ argv = [shell, "-NoProfile", "-File", str(script)]+ env = dict(os.environ, PATH = str(tmp_path / "empty-path")) if selected_uv else None+ result = subprocess.run(argv, capture_output = True, text = True, timeout = 180, env = env)+ if result.returncode:+ raise RuntimeError(result.stderr)+ return tuple(result.stdout.strip().splitlines()[-2:])++ return resolve++[email protected]("desktop", [True, False])+def test_every_no_torch_entrypoint_installs_a_compatible_pair(+ lagging_index, installer_pair, monkeypatch, desktop+):+ if not desktop:+ monkeypatch.delenv("UNSLOTH_DESKTOP_BACKEND_VERSION")+ assert _no_deps_selection(installer_pair(), lagging_index) == {+ "unsloth": "2026.10.6",+ "unsloth-zoo": "2026.10.6",+ }+++def test_no_torch_does_not_backtrack_for_missing_torch(lagging_index, installer_pair):+ _wheel(lagging_index, "unsloth", "2026.10.7", ["unsloth-zoo>=2026.10.6", "torch>=999"])+ assert _no_deps_selection(installer_pair(), lagging_index) == {+ "unsloth": "2026.10.7",+ "unsloth-zoo": "2026.10.6",+ }+++def test_feed_ceiling_is_cleared_when_the_pair_becomes_available(+ lagging_index, installer_pair, monkeypatch, tmp_path+):+ monkeypatch.setenv("UNSLOTH_DESKTOP_BACKEND_VERSION", "2026.10.7")+ assert _no_deps_selection(installer_pair(), lagging_index)["unsloth"] == "2026.10.6"+ marker = tmp_path / ips.FEED_CEILING_MARKER+ assert json.loads(marker.read_text(encoding = "utf-8")) == {+ "requested": "2026.10.7",+ "available": "2026.10.6",+ }+ _wheel(lagging_index, "unsloth-zoo", "2026.10.7")+ assert _no_deps_selection(installer_pair(), lagging_index) == {+ "unsloth": "2026.10.7",+ "unsloth-zoo": "2026.10.7",+ }+ assert not marker.exists()+++def test_an_index_with_no_compatible_pair_is_refused(lagging_index, installer_pair):+ _wheel(lagging_index, "unsloth", "2026.10.6", ["unsloth-zoo>=9999"])+ _wheel(lagging_index, "unsloth", "2026.10.7", ["unsloth-zoo>=9999"])+ with pytest.raises(RuntimeError):+ installer_pair()+++def test_pip_fallback_resolves_the_same_pair(lagging_index, monkeypatch):+ monkeypatch.setattr(ips, "NO_TORCH", True)+ monkeypatch.setattr(ips, "USE_UV", False)+ monkeypatch.setenv("PIP_CONFIG_FILE", os.devnull)+ assert _no_deps_selection(ips._desktop_unsloth_spec("unsloth"), lagging_index) == {+ "unsloth": "2026.10.6",+ "unsloth-zoo": "2026.10.6",+ }++[email protected]("policy", ["env", "config"])+def test_pip_metadata_uses_the_install_hash_policy(lagging_index, monkeypatch, tmp_path, policy):+ monkeypatch.setattr(ips, "NO_TORCH", True)+ monkeypatch.setattr(ips, "USE_UV", False)+ if policy == "env":+ monkeypatch.setenv("PIP_REQUIRE_HASHES", "1")+ else:+ config = tmp_path / "pip.conf"+ config.write_text("[install]\nrequire-hashes = true\n", encoding = "utf-8")+ monkeypatch.delenv("PIP_REQUIRE_HASHES", raising = False)+ monkeypatch.setenv("PIP_CONFIG_FILE", str(config))+ assert ips._desktop_unsloth_spec("unsloth") == ("unsloth==2026.10.6", "unsloth-zoo==2026.10.6")+++def test_powershell_metadata_uses_the_selected_uv(lagging_index, installer_pair, request):+ if request.node.callspec.params["installer_pair"] != "powershell":+ pytest.skip("PowerShell executable selection")+ assert installer_pair(selected_uv = True) == ("unsloth==2026.10.6", "unsloth-zoo==2026.10.6")+++def test_bootstrap_pair_resolvers_match_the_python_installer():+ source = (STUDIO_DIR / "install_python_stack.py").read_text(encoding = "utf-8")+ reference = next(+ n+ for n in ast.parse(source).body+ if isinstance(n, ast.FunctionDef) and n.name == "_no_torch_pair"+ )+ shell = (STUDIO_DIR.parent / "install.sh").read_text(encoding = "utf-8")+ powershell = (STUDIO_DIR.parent / "install.ps1").read_text(encoding = "utf-8")+ snippets = [+ shell.split("<<'UNSLOTH_PAIR_PY'\n", 1)[1].split("\nUNSLOTH_PAIR_PY", 1)[0],+ powershell.split("$pairCode = @'\n", 1)[1].split("\n'@", 1)[0],+ ]+ for snippet in snippets:+ actual = next(+ n+ for n in ast.parse(snippet).body+ if isinstance(n, ast.FunctionDef) and n.name == "_no_torch_pair"+ )+ assert ast.dump(actual) == ast.dump(reference)diff --git a/tests/python/test_install_python_stack.py b/tests/python/test_install_python_stack.pyindex e25064f78a3..6697ab402a6 100644--- a/tests/python/test_install_python_stack.py+++ b/tests/python/test_install_python_stack.py@@ -2939,11 +2939,13 @@ class TestDesktopBackendVersionConstraint:zoo = None,floors = None,full = False,+ no_torch = False,):with (mock.patch.dict(os.environ, env, clear = True),mock.patch.object(ips.sys, "prefix", str(tmp_path)),mock.patch.object(ips, "USE_UV", True),+ mock.patch.object(ips, "NO_TORCH", no_torch),mock.patch.object(ips,"_uv_config_index_policy",