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: cap accelerate below 1.15 on Windows, where 1.15 breaks all ROCm training (#10819)
Leo Borcherding910847e4009f
diff --git a/studio/backend/requirements/single-env/constraints.txt b/studio/backend/requirements/single-env/constraints.txtindex f3b4a7dff6b..68c9980643b 100644--- a/studio/backend/requirements/single-env/constraints.txt+++ b/studio/backend/requirements/single-env/constraints.txt@@ -27,6 +27,13 @@ websockets>=15.0.1# later with-deps steps can't re-resolve it up.anyio<4.14.0+# accelerate 1.15.0 calls model_has_dtensor() unconditionally in prepare_model, reaching+# torch._C._distributed_c10d, which AMD's Windows ROCm wheels do not ship, so every run dies+# at trainer start (huggingface/accelerate#4249). A marker cannot say "ROCm", so this caps+# Windows generally; CUDA there loses only 1.15's DTensor placement fix. Lift once upstream+# guards the call. install_python_stack.py repairs an install that is already past the cap.+accelerate<1.15.0; sys_platform == "win32"+pandas==2.3.3# av (PyAV) 16+ builds its macOS arm64 wheels against macosx_14_0, so on macOS 13 nonediff --git a/studio/backend/tests/test_torchao_select.py b/studio/backend/tests/test_torchao_select.pyindex c03dcf45e57..c42613a11a0 100644--- a/studio/backend/tests/test_torchao_select.py+++ b/studio/backend/tests/test_torchao_select.py@@ -368,6 +368,7 @@ def test_skips_torchao_on_windows_rocm(monkeypatch.setattr(mod, "_repair_damaged_core_payload", lambda *a, **k: True)monkeypatch.setattr(mod, "_bootstrap_uv", lambda: False)monkeypatch.setattr(mod, "_repair_bad_anyio", lambda: None)+ monkeypatch.setattr(mod, "_repair_bad_accelerate", lambda: None)monkeypatch.setattr(mod, "_ensure_rocm_torch", lambda: None)monkeypatch.setattr(mod, "_ensure_cuda_torch", lambda: None)# A Windows ROCm box has no usable NVIDIA GPU. Claiming one here described adiff --git a/studio/install_python_stack.py b/studio/install_python_stack.pyindex 98a6a6232ff..559c9fbe410 100644--- a/studio/install_python_stack.py+++ b/studio/install_python_stack.py@@ -950,10 +950,10 @@ def _installed_torch_is_windows_rocm() -> bool:_ANYIO_BAD_FLOOR = (4, 14)-def _installed_anyio_version() -> tuple[int, int] | None:+def _installed_version(package: str) -> tuple[int, int] | None:try:from importlib.metadata import version as _pkg_version- raw = _pkg_version("anyio")+ raw = _pkg_version(package)except Exception:return Noneparts = raw.split(".")@@ -966,7 +966,7 @@ def _installed_anyio_version() -> tuple[int, int] | None:def _repair_bad_anyio() -> None:- installed = _installed_anyio_version()+ installed = _installed_version("anyio")if installed is None or installed < _ANYIO_BAD_FLOOR:return_note(f"anyio {installed[0]}.{installed[1]} found -- reinstalling anyio<4.14...")@@ -979,6 +979,34 @@ def _repair_bad_anyio() -> None:)+# The constraints cap cannot reach a fresh install: install.ps1 resolves accelerate with no -c,+# then hands off with SKIP_STUDIO_BASE=1, and no later step re-resolves it (#10819).+_ACCELERATE_BAD_FLOOR = (1, 15)+++def _repair_bad_accelerate() -> None:+ if not IS_WINDOWS:+ return+ installed = _installed_version("accelerate")+ if installed is None or installed < _ACCELERATE_BAD_FLOOR:+ return+ _note(f"accelerate {installed[0]}.{installed[1]} found -- reinstalling accelerate<1.15...")+ # --no-deps: accelerate requires torch>=2.0.0, and a with-deps reinstall replaces the ROCm+ # wheel. _try, not pip_install: that exits, and this fires on nearly every Windows install.+ if not pip_install_try(+ "Repairing accelerate version",+ "--no-cache-dir",+ "--no-deps",+ "accelerate<1.15.0",+ constrain = False,+ ):+ _note(+ "could not install accelerate<1.15 -- training on a Windows AMD GPU will fail "+ "at trainer start until it is downgraded (huggingface/accelerate#4249)",+ _red,+ )++# AMD Windows ROCm wheels (repo.amd.com/rocm/whl/{arch_family}/).# Override with UNSLOTH_ROCM_WINDOWS_MIRROR for air-gapped/mirror installs.# Kept verbatim: _index_url_join trims the path head, and only the path head. Trimming the@@ -8952,9 +8980,11 @@ def install_python_stack() -> int:# reinstall path too, not just the two calls below# Clean-machine CI overlays only unsloth, not the full local source pair.ci_source_overlay = os.environ.get("UNSLOTH_CI_SOURCE_OVERLAY", "")- # Three lettered steps beside the numbered ones: anyio repair (8b), diffusers pin (11b),- # torchcodec (13b).+ # Four lettered steps beside the numbered ones: anyio repair (8b), accelerate repair+ # (8c, Windows only), diffusers pin (11b), torchcodec (13b).base_total = 13 if IS_WINDOWS else 14+ if IS_WINDOWS:+ base_total += 1 # 8c, gated exactly as the step isif IS_MACOS:base_total -= 1 # triton step is skipped on macOSif not IS_MACOS and not NO_TORCH:@@ -9358,6 +9388,11 @@ def install_python_stack() -> int:_progress("anyio check")_repair_bad_anyio()+ # 8c. Outside skip_base on purpose: install.ps1 sets it and is the path that lands 1.15.+ if IS_WINDOWS:+ _progress("accelerate check")+ _repair_bad_accelerate()+# 9. Data-designer dependencies_dd_deps_ran = not _skip_step(SINGLE_ENV / "data-designer-deps.txt", "data designer deps", no_deps = Falsediff --git a/tests/studio/install/test_rocm_support.py b/tests/studio/install/test_rocm_support.pyindex 9b48abc90e0..41c8563e54c 100644--- a/tests/studio/install/test_rocm_support.py+++ b/tests/studio/install/test_rocm_support.py@@ -5031,6 +5031,7 @@ class TestWindowsRocmTorchaoGuard:with patch.object(stack_mod, "IS_WINDOWS", False):assert stack_mod._installed_torch_is_windows_rocm() is False+ @patch.object(stack_mod, "_repair_bad_accelerate")@patch.object(stack_mod, "_repair_bad_anyio")@patch.object(stack_mod, "_ensure_rocm_torch")@patch.object(stack_mod, "_ensure_cuda_torch")@@ -5038,7 +5039,15 @@ class TestWindowsRocmTorchaoGuard:@patch.object(stack_mod, "run")@patch.object(stack_mod, "pip_install")def test_install_python_stack_skips_torchao_when_windows_rocm_torch_is_installed(- self, mock_pip, mock_run, mock_has_nvidia, mock_cuda, mock_rocm, mock_anyio, tmp_path+ self,+ mock_pip,+ mock_run,+ mock_has_nvidia,+ mock_cuda,+ mock_rocm,+ mock_anyio,+ mock_accelerate,+ tmp_path,):unstructured_plugin = tmp_path / "unstructured"github_plugin = tmp_path / "github"@@ -5103,6 +5112,7 @@ class TestProgressStepCountMatchesTotal:patch.object(stack_mod, "_installed_torch_is_windows_rocm", return_value = False),patch.object(stack_mod, "_has_usable_nvidia_gpu", return_value = True),patch.object(stack_mod, "_repair_bad_anyio"),+ patch.object(stack_mod, "_repair_bad_accelerate"),patch.object(stack_mod, "_ensure_cuda_torch"),patch.object(stack_mod, "_ensure_rocm_torch"),patch.object(stack_mod, "_ensure_cpu_torch"),@@ -5164,6 +5174,95 @@ class TestProgressStepCountMatchesTotal:assert step == total, f"progress {step} != total {total}"+class TestAccelerateRepair:+ """accelerate 1.15 reaches torch._C._distributed_c10d, absent from AMD's Windows ROCm+ wheels (#4249). The constraints cap misses a fresh install, which sets SKIP_STUDIO_BASE=1."""++ def _repair(+ self,+ installed,+ *,+ is_windows = True,+ succeeds = True,+ ):+ with (+ patch.object(stack_mod, "IS_WINDOWS", is_windows),+ patch.object(stack_mod, "_installed_version", return_value = installed),+ patch.object(stack_mod, "pip_install_try", return_value = succeeds) as mock_pip,+ ):+ stack_mod._repair_bad_accelerate()+ return mock_pip++ def test_a_failed_repair_does_not_abort_the_install(self):+ """pip_install exits, and this fires on nearly every fresh Windows install, so one+ unreachable index would fail an install that used to finish."""+ mock_pip = self._repair((1, 15), succeeds = False)+ assert mock_pip.call_count == 1++ def test_the_repair_is_never_the_fatal_variant(self):+ """At source level: swapping the call back changes nothing the mock above sees."""+ src = (PACKAGE_ROOT / "studio" / "install_python_stack.py").read_text(encoding = "utf-8")+ body = src.split("def _repair_bad_accelerate()")[1].split("\ndef ")[0]+ assert "pip_install_try(" in body+ assert "\n pip_install(" not in body++ @pytest.mark.parametrize("installed", [(1, 15), (1, 16), (2, 0)])+ def test_repairs_a_capped_out_accelerate_on_windows(self, installed):+ mock_pip = self._repair(installed)+ args = [str(a) for a in mock_pip.call_args.args]+ assert "accelerate<1.15.0" in args++ @pytest.mark.parametrize("installed", [None, (1, 14), (1, 9), (0, 34)])+ def test_leaves_a_good_or_missing_accelerate_alone(self, installed):+ """(1, 9) guards a string compare, where "1.9" sorts above "1.15"."""+ assert self._repair(installed).call_count == 0++ @pytest.mark.parametrize("is_windows", [False, True])+ def test_only_windows_is_touched(self, is_windows):+ """WSL reports sys.platform "linux", and every non-Windows build ships c10d."""+ assert self._repair((1, 15), is_windows = is_windows).call_count == int(is_windows)++ def test_repair_is_no_deps(self):+ """accelerate requires torch>=2.0.0: with deps, the reinstall replaces the ROCm wheel."""+ args = [str(a) for a in self._repair((1, 15)).call_args.args]+ assert "--no-deps" in args+ assert "--force-reinstall" not in args++ def test_repair_survives_flag_translation_to_uv(self):+ """pip_install prefers uv, so --no-deps must reach uv too, not just pip."""+ args = ("--no-cache-dir", "--no-deps", "accelerate<1.15.0")+ assert "--no-deps" in stack_mod._translate_pip_args_for_uv(args)+ assert "--no-deps" in stack_mod._build_pip_cmd(args)++ @pytest.mark.parametrize(+ "raw, expected",+ [+ ("1.15.0", (1, 15)),+ ("1.15", (1, 15)),+ ("1.15.0.dev0", (1, 15)),+ ("1.14.0", (1, 14)),+ ("1.9.0", (1, 9)),+ ("unknown", None),+ ],+ )+ def test_version_parsing(self, raw, expected):+ with patch.object(stack_mod, "_installed_version", wraps = stack_mod._installed_version):+ with patch("importlib.metadata.version", return_value = raw):+ assert stack_mod._installed_version("accelerate") == expected++ def test_constraints_file_caps_accelerate_on_win32_only(self):+ """The repair and the constraint must agree, or install and update disagree."""+ text = (+ PACKAGE_ROOT / "studio" / "backend" / "requirements" / "single-env" / "constraints.txt"+ ).read_text(encoding = "utf-8")+ line = next(+ ln+ for ln in text.splitlines()+ if ln.strip().startswith("accelerate") and not ln.strip().startswith("#")+ )+ assert line.strip() == 'accelerate<1.15.0; sys_platform == "win32"'++# TEST: worker.py -- Windows ROCm patches (source-level checks)diff --git a/tests/studio/install/test_windows_torch_flavor_invariant.py b/tests/studio/install/test_windows_torch_flavor_invariant.pyindex f1b1e8d3374..e04d176b15a 100644--- a/tests/studio/install/test_windows_torch_flavor_invariant.py+++ b/tests/studio/install/test_windows_torch_flavor_invariant.py@@ -328,9 +328,10 @@ def _base_total(**flags) -> int:class TestStepTotals:def test_windows_totals_include_torchcodec(self):- assert _base_total(IS_WINDOWS = True) == 15- # 14, not 13: an update installs the no-torch runtime deps on their own slot.- assert _base_total(IS_WINDOWS = True, NO_TORCH = True) == 14+ # Both carry the Windows-only accelerate repair (8c), which ignores NO_TORCH; the+ # no-torch case also gets the runtime-deps slot an update announces separately.+ assert _base_total(IS_WINDOWS = True) == 16+ assert _base_total(IS_WINDOWS = True, NO_TORCH = True) == 15@pytest.mark.parametrize("flags,total",