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
fix(studio): bundle hf-xet for Desktop large Hub downloads (#10849)
Sourav Rajvic052e1f9e0f5
diff --git a/pyproject.toml b/pyproject.tomlindex ae8f3b9c4f1..3c3dcf06136 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -157,6 +157,7 @@ studio = ["pyjwt==2.13.0","huggingface-hub>=1.23.0,<2.0 ; python_version >= '3.10'","huggingface-hub==0.36.2 ; python_version < '3.10'",+ "hf-xet>=1.5.2,<2.0 ; python_version >= '3.10' and (platform_machine == 'x86_64' or platform_machine == 'amd64' or platform_machine == 'AMD64' or platform_machine == 'arm64' or platform_machine == 'aarch64' or platform_machine == 'ARM64')","urllib3>=2.3.0","jinja2>=3.1.0","structlog>=24.1.0",diff --git a/studio/backend/requirements/no-torch-runtime.txt b/studio/backend/requirements/no-torch-runtime.txtindex b303b5fb37a..5b1716b6a33 100644--- a/studio/backend/requirements/no-torch-runtime.txt+++ b/studio/backend/requirements/no-torch-runtime.txt@@ -48,6 +48,11 @@ accelerate>=0.34.1peft>=0.18.0,!=0.11.0huggingface_hub>=1.23.0,<2.0; python_version >= "3.10"huggingface_hub==0.36.2; python_version < "3.10"+# --no-deps here, so the hub never pulls it transitively, and without it huggingface_hub refuses any+# single blob over 50GB (file_download.py, MAX_HTTP_DOWNLOAD_SIZE). Arch gate is huggingface-hub's+# own Requires-Dist plus ARM64, which does have a win_arm64 wheel; an off-list machine would build+# the maturin sdist, the same reason hf_transfer below is marked. 1.5.2 is what the hub 1.32 asks.+hf-xet>=1.5.2,<2.0; python_version >= "3.10" and (platform_machine == "x86_64" or platform_machine == "amd64" or platform_machine == "AMD64" or platform_machine == "arm64" or platform_machine == "aarch64" or platform_machine == "ARM64")# No win_arm64 wheel and this file installs --no-deps, so pip would need cargo plus MSVC.hf_transfer==0.1.9; sys_platform != "win32" or platform_machine != "ARM64"# diffusers: see diffusers-pin.txt, installed by its own step (this file isdiff --git a/studio/backend/requirements/single-env/constraints.txt b/studio/backend/requirements/single-env/constraints.txtindex 34dc56992d4..f0d2cbd2358 100644--- a/studio/backend/requirements/single-env/constraints.txt+++ b/studio/backend/requirements/single-env/constraints.txt@@ -10,6 +10,7 @@ tokenizers>=0.22.0,<=0.23.0trl==0.23.1huggingface-hub>=1.23.0,<2.0; python_version >= "3.10"huggingface-hub==0.36.2; python_version < "3.10"+hf-xet>=1.5.2,<2.0; python_version >= "3.10" and (platform_machine == "x86_64" or platform_machine == "amd64" or platform_machine == "AMD64" or platform_machine == "arm64" or platform_machine == "aarch64" or platform_machine == "ARM64")# Unsloth stackdatasets==4.3.0diff --git a/studio/backend/requirements/studio.txt b/studio/backend/requirements/studio.txtindex dd53d60e643..6a1c8f2af62 100644--- a/studio/backend/requirements/studio.txt+++ b/studio/backend/requirements/studio.txt@@ -22,6 +22,8 @@ pyjwt==2.13.0# gradio>=4.0.0 # 148 MB - Unsloth uses React + FastAPI, not Gradiohuggingface-hub>=1.23.0,<2.0; python_version >= "3.10"huggingface-hub==0.36.2; python_version < "3.10"+# Matches no-torch-runtime.txt, the file that actually needs it; see there for the arch gate.+hf-xet>=1.5.2,<2.0; python_version >= "3.10" and (platform_machine == "x86_64" or platform_machine == "amd64" or platform_machine == "AMD64" or platform_machine == "arm64" or platform_machine == "aarch64" or platform_machine == "ARM64")# truststore is vendored at backend/vendor/, deliberately not a dependency.# Transitive via requests, pinned here for one reason: the GGUF header range-read# preflight bounds itself by half-closing the socket, and HTTPResponse.shutdown isdiff --git a/tests/studio/install/test_no_torch_runtime_hf_xet.py b/tests/studio/install/test_no_torch_runtime_hf_xet.pynew file mode 100644index 00000000000..494901d1435--- /dev/null+++ b/tests/studio/install/test_no_torch_runtime_hf_xet.py@@ -0,0 +1,135 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++"""GGUF-only installs apply no-torch-runtime.txt with --no-deps, so Hub extras must be declared."""++from __future__ import annotations++import pathlib++import pytest+from packaging.requirements import Requirement++REPO_ROOT = pathlib.Path(__file__).resolve().parents[3]+NO_TORCH_RUNTIME = REPO_ROOT / "studio" / "backend" / "requirements" / "no-torch-runtime.txt"+STUDIO_TXT = REPO_ROOT / "studio" / "backend" / "requirements" / "studio.txt"+CONSTRAINTS = REPO_ROOT / "studio" / "backend" / "requirements" / "single-env" / "constraints.txt"+PYPROJECT = REPO_ROOT / "pyproject.toml"++# Machines hf-xet ships a wheel for, as of 1.6.0; off-list resolves the maturin sdist instead.+WHEELED_MACHINES = ("x86_64", "amd64", "AMD64", "arm64", "aarch64", "ARM64")+UNWHEELED_MACHINES = ("ppc64le", "s390x", "i686", "armv7l", "riscv64")++# huggingface-hub 1.32's own floor, which --no-deps leaves nothing else to enforce.+HUB_HF_XET_FLOOR = "1.5.2"++ALL_FILES = (NO_TORCH_RUNTIME, STUDIO_TXT, CONSTRAINTS)+++def _requirement_names(path: pathlib.Path) -> set[str]:+ names = set()+ for line in path.read_text(encoding = "utf-8").splitlines():+ text = line.split("#", 1)[0].strip()+ if not text or text.startswith("-"):+ continue+ names.add(Requirement(text).name.lower().replace("_", "-"))+ return names+++def _hf_xet_requirements(path: pathlib.Path) -> list[Requirement]:+ out = []+ if path.suffix == ".toml":+ for line in path.read_text(encoding = "utf-8").splitlines():+ text = line.strip().rstrip(",")+ if text.startswith('"hf-xet') or text.startswith("'hf-xet"):+ out.append(Requirement(text.strip("\"'")))+ return out+ for line in path.read_text(encoding = "utf-8").splitlines():+ text = line.split("#", 1)[0].strip()+ if not text or text.startswith("-"):+ continue+ req = Requirement(text)+ if req.name.lower().replace("_", "-") == "hf-xet":+ out.append(req)+ return out+++def _env(python_version: str, machine: str) -> dict[str, str]:+ """Full environment: an absent platform_machine makes the arch assertions read as the runner."""+ return {+ "python_version": python_version,+ "python_full_version": python_version + ".0",+ "platform_machine": machine,+ "platform_system": "Linux",+ "sys_platform": "linux",+ "os_name": "posix",+ "platform_release": "",+ "platform_version": "",+ "implementation_name": "cpython",+ "implementation_version": python_version + ".0",+ "platform_python_implementation": "CPython",+ "extra": "",+ }+++def test_no_torch_runtime_declares_hf_xet_for_hub_large_downloads():+ names = _requirement_names(NO_TORCH_RUNTIME)+ assert "hf-xet" in names, (+ "no-torch-runtime.txt is installed --no-deps; without an explicit hf-xet pin, "+ "Desktop GGUF-only envs fall back to HTTP and huggingface_hub raises on large blobs."+ )++[email protected]("path", ALL_FILES + (PYPROJECT,), ids = lambda p: p.name)+def test_every_hf_xet_pin_is_declared_once_and_marked(path: pathlib.Path):+ pins = _hf_xet_requirements(path)+ assert len(pins) == 1, f"expected one hf-xet line in {path.name}, got {pins!r}"+ assert pins[0].marker is not None, f"{path.name} hf-xet must be environment-marked"++[email protected]("path", ALL_FILES + (PYPROJECT,), ids = lambda p: p.name)+def test_hf_xet_pins_are_python_310_plus_only(path: pathlib.Path):+ """Python < 3.10 stays on huggingface-hub 0.36.2, the same split the hub pins above use.++ Not a wheel question: hf-xet ships cp38-abi3 wheels and declares Requires-Python >= 3.8, so 3.9+ could install it. No Desktop or Studio path selects 3.9 (install.sh defaults 3.13/3.12,+ install.ps1 ranks 3.13/3.12/3.11), so the pre-Xet branch is left exactly as it was.+ """+ marker = _hf_xet_requirements(path)[0].marker+ assert marker.evaluate(_env("3.9", "x86_64")) is False+ assert marker.evaluate(_env("3.10", "x86_64")) is True+ assert marker.evaluate(_env("3.13", "x86_64")) is True++[email protected]("path", ALL_FILES + (PYPROJECT,), ids = lambda p: p.name)+def test_hf_xet_pins_only_ask_for_machines_with_wheels(path: pathlib.Path):+ """A machine with no hf-xet wheel must not be asked for it: the fallback is a maturin build."""+ marker = _hf_xet_requirements(path)[0].marker+ for machine in WHEELED_MACHINES:+ assert marker.evaluate(_env("3.12", machine)) is True, machine+ for machine in UNWHEELED_MACHINES:+ assert marker.evaluate(_env("3.12", machine)) is False, (+ f"{path.name} would resolve hf-xet on {machine}, which has no wheel; under --no-deps "+ "that is a Rust source build on the user's machine."+ )++[email protected]("path", ALL_FILES + (PYPROJECT,), ids = lambda p: p.name)+def test_hf_xet_floor_is_not_below_the_hub_requirement(path: pathlib.Path):+ specifier = _hf_xet_requirements(path)[0].specifier+ assert (+ HUB_HF_XET_FLOOR in specifier+ ), f"{path.name} pins hf-xet {specifier}, excluding the floor itself"+ below = ("1.5.1", "1.5.0", "1.1.3")+ allowed = [v for v in below if v in specifier]+ assert not allowed, (+ f"{path.name} pins hf-xet {specifier}, which still allows {allowed}, below the "+ f"{HUB_HF_XET_FLOOR} floor huggingface-hub declares; --no-deps means nothing else enforces it."+ )+ assert "2.0" not in specifier, f"{path.name} must keep the <2.0 ceiling"+++def test_the_four_declarations_agree():+ pins = {p.name: str(_hf_xet_requirements(p)[0]) for p in ALL_FILES + (PYPROJECT,)}+ canonical = {str(Requirement(v)) for v in pins.values()}+ assert len(canonical) == 1, f"hf-xet pins disagree across files: {pins}"