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 prebuilt flash-attn, causal-conv1d and mamba-ssm wheels on Windows and ARM (#13262)

Daniel Han14ad75e8579e
diff --git a/studio/backend/core/training/worker.py b/studio/backend/core/training/worker.py
index 02fffb92f62..e08dc0d57b6 100644
--- a/studio/backend/core/training/worker.py
+++ b/studio/backend/core/training/worker.py
@@ -84,6 +84,7 @@ from utils.wheel_utils import (
direct_wheel_url,
flash_attn_wheel_url,
install_wheel,
+ is_windows_wheel_env,
probe_torch_wheel_env,
url_exists,
)
@@ -1345,7 +1346,9 @@ def _attempt_package_install(
# Set when a wheel installed but would not import; see the uninstall before the fallback.
wheel_rejected = False
- env = probe_torch_wheel_env(timeout = 30)
+ env = probe_torch_wheel_env(timeout = 30, include_windows = True)
+ # Windows is wheel-only: a PyPI fallback there is a source build needing MSVC + the CUDA toolkit.
+ wheel_only = sys.platform == "win32" or is_windows_wheel_env(env)
if wheel_url_builder is not None:
wheel_url = wheel_url_builder(env)
else:
@@ -1381,18 +1384,24 @@ def _attempt_package_install(
return True
if outcome == "rejected":
logger.warning(
- "%s wheel installed but is not importable; falling back to PyPI",
+ "%s wheel installed but is not importable; %s",
display_name,
+ "removing it" if wheel_only else "falling back to PyPI",
)
wheel_rejected = True
elif wheel_available is None:
_send_status(
event_queue,
- f"Could not check the {display_name} prebuilt wheel; installing from PyPI.",
+ f"Could not check the {display_name} prebuilt wheel; "
+ + ("skipping it." if wheel_only else "installing from PyPI."),
)
else:
logger.info("No published %s wheel found: %s", display_name, wheel_url)
+ if wheel_only:
+ logger.info("%s: no usable prebuilt wheel for Windows; skipping", display_name)
+ return False
+
is_hip = env and env.get("hip_version")
if is_hip and not shutil.which("hipcc"):
logger.error(
@@ -1484,20 +1493,11 @@ def _attempt_package_install(
f"{snippet}",
)
else:
- if sys.platform == "win32":
- # No prebuilt wheel and no source toolchain on Windows -- expected for packages like causal-conv1d.
- # Log at info so users aren't alarmed by what looks like an error.
- logger.info(
- "%s is not available on Windows (no prebuilt wheel); skipping",
- display_name,
- )
- logger.debug("Install output:\n%s", result.stdout)
- else:
- logger.error(
- "Failed to install %s from PyPI:\n%s",
- display_name,
- result.stdout,
- )
+ logger.error(
+ "Failed to install %s from PyPI:\n%s",
+ display_name,
+ result.stdout,
+ )
return False
# rc=0 is not proof again here: pip/uv exit 0 on "Requirement already satisfied" without installing anything.
@@ -1536,9 +1536,6 @@ def _ensure_causal_conv1d_fast_path(
required = _model_wants_causal_conv1d(model_name)
if not required:
return
- if sys.platform == "win32":
- logger.info("causal-conv1d: no prebuilt wheel for Windows; skipping")
- return
_install_package_wheel_first(event_queue = event_queue, **_pinned_kernel_kwargs(CAUSAL_CONV1D))
@@ -1561,6 +1558,11 @@ def _ensure_mamba_ssm(event_queue: Any, model_name: str) -> None:
if not any(sub in model_name.lower() for sub in _SSM_MODEL_SUBSTRINGS):
return
+ if sys.platform == "win32" and importlib.util.find_spec("triton") is None:
+ # mamba_ssm imports triton at load and the wheel goes in --no-deps.
+ _send_status(event_queue, "mamba-ssm needs Triton on Windows (triton-windows); skipping it")
+ return
+
logger.info("SSM model detected; setting up mamba-ssm after causal-conv1d")
_install_package_wheel_first(event_queue = event_queue, **_pinned_kernel_kwargs(MAMBA_SSM))
@@ -1977,9 +1979,6 @@ def _install_fast_path_hooks(
return wrapper
def _causal_conv1d_install(eq: Any) -> bool:
- if sys.platform == "win32":
- logger.info("causal-conv1d: no prebuilt wheel for Windows; skipping")
- return False
ok = _install_package_wheel_first(event_queue = eq, **_pinned_kernel_kwargs(CAUSAL_CONV1D))
return bool(ok)
@@ -2010,7 +2009,7 @@ def _should_try_runtime_flash_attn_install(max_seq_length: int) -> bool:
return False
if max_seq_length < _FLASH_ATTN_RUNTIME_MIN_SEQ_LEN:
return False
- return sys.platform.startswith("linux")
+ return sys.platform.startswith("linux") or sys.platform == "win32"
def _ensure_flash_attn_for_long_context(event_queue: Any, max_seq_length: int) -> None:
diff --git a/studio/backend/tests/test_kernel_install.py b/studio/backend/tests/test_kernel_install.py
index 5d75d947c7c..d8a55409c38 100644
--- a/studio/backend/tests/test_kernel_install.py
+++ b/studio/backend/tests/test_kernel_install.py
@@ -674,3 +674,36 @@ def test_source_build_run_kwargs(monkeypatch):
def test_uninstall_command(use_uv, system, expected):
cmd = kernel_install.uninstall_command("k", use_uv = use_uv, uv_needs_system = system)
assert cmd == [sys.executable if part == "PY" else part for part in expected]
+
+
+_WIN = {
+ "platform_tag": "win_amd64",
+ "torch_mm": "2.13",
+ "torch_version": "2.13.0+cu130",
+ "cuda_major": "13",
+ "cuda_version": "13.0",
+ "cxx11abi": "TRUE",
+ "python_tag": "cp313",
+ "abi_tag": "cp313",
+ "hip_version": "",
+}
+
+
+def test_windows_mamba_ssm_waits_for_triton(uv, monkeypatch, capsys):
+ """mamba_ssm imports triton at load; on Windows that is triton-windows, absent from its METADATA."""
+ uv(False)
+ monkeypatch.setattr(kernel_install.sys, "platform", "win32")
+ run = _Runner([], triton = None)
+ assert kernel_install.install_kernel("mamba_ssm", _WIN, run = run, exists = lambda url: True) == 0
+ assert run.installer_calls == []
+ assert "needs Triton on Windows" in capsys.readouterr().out
+
+
+def test_windows_mamba_ssm_installs_with_triton(uv, monkeypatch):
+ uv(False)
+ monkeypatch.setattr(kernel_install.sys, "platform", "win32")
+ run = _Runner([False, True], triton = "3.7.1")
+ assert kernel_install.install_kernel("mamba_ssm", _WIN, run = run, exists = lambda url: True) == 0
+ assert run.installer_calls[0][-1].endswith(
+ "mamba_ssm-2.3.2.post1+cu13torch2.13cxx11abiTRUE-cp313-cp313-win_amd64.whl"
+ )
diff --git a/studio/backend/tests/test_mlx_training_worker_config.py b/studio/backend/tests/test_mlx_training_worker_config.py
index bb6214d3f57..127b9c49bd7 100644
--- a/studio/backend/tests/test_mlx_training_worker_config.py
+++ b/studio/backend/tests/test_mlx_training_worker_config.py
@@ -81,6 +81,7 @@ def _load_worker_module():
"direct_wheel_url",
"flash_attn_wheel_url",
"install_wheel",
+ "is_windows_wheel_env",
"probe_torch_wheel_env",
"url_exists",
):
diff --git a/studio/backend/tests/test_ssm_runtime.py b/studio/backend/tests/test_ssm_runtime.py
index 8d09c7ef418..7aecaee13df 100644
--- a/studio/backend/tests/test_ssm_runtime.py
+++ b/studio/backend/tests/test_ssm_runtime.py
@@ -144,14 +144,11 @@ def test_ssm_model_installs_causal_then_mamba(monkeypatch):
return True
monkeypatch.setattr(ssm_runtime, "_install_kernel", fake_install)
+ monkeypatch.setattr(ssm_runtime.sys, "platform", "linux")
ssm_runtime.ensure_ssm_runtime("unsloth/NVIDIA-Nemotron-3-Nano-4B")
- expected = ["mamba_ssm"] if sys.platform == "win32" else ["causal_conv1d", "mamba_ssm"]
- assert order == expected
+ assert order == ["causal_conv1d", "mamba_ssm"]
- sys.platform == "win32", reason = "causal-conv1d is skipped on Windows (no prebuilt wheel)"
-)
def test_causal_only_model_skips_mamba(monkeypatch):
order = []
monkeypatch.setattr(
@@ -242,7 +239,9 @@ def test_install_kernel_uses_prebuilt_wheel(monkeypatch):
# not importable before install, importable after the wheel lands
states = iter([False, True])
monkeypatch.setattr(ssm_runtime, "_is_importable", lambda name: next(states))
- monkeypatch.setattr(ssm_runtime, "probe_torch_wheel_env", lambda timeout = 30: {"x": "y"})
+ monkeypatch.setattr(
+ ssm_runtime, "probe_torch_wheel_env", lambda timeout = 30, include_windows = False: {"x": "y"}
+ )
seen = {}
monkeypatch.setattr(
ssm_runtime,
@@ -281,7 +280,9 @@ def test_install_kernel_heartbeats_during_prebuilt_wheel(monkeypatch):
monkeypatch.setattr(ssm_runtime, "_HEARTBEAT_SECONDS", 0.05)
monkeypatch.setattr(ssm_runtime, "_is_importable", lambda name: False)
- monkeypatch.setattr(ssm_runtime, "probe_torch_wheel_env", lambda timeout = 30: {})
+ monkeypatch.setattr(
+ ssm_runtime, "probe_torch_wheel_env", lambda timeout = 30, include_windows = False: {}
+ )
monkeypatch.setattr(
ssm_runtime,
"direct_wheel_url",
@@ -336,7 +337,9 @@ def test_install_kernel_heartbeats_through_the_import_check(monkeypatch):
import time
monkeypatch.setattr(ssm_runtime, "_HEARTBEAT_SECONDS", 0.05)
- monkeypatch.setattr(ssm_runtime, "probe_torch_wheel_env", lambda timeout = 30: {})
+ monkeypatch.setattr(
+ ssm_runtime, "probe_torch_wheel_env", lambda timeout = 30, include_windows = False: {}
+ )
monkeypatch.setattr(
ssm_runtime,
"direct_wheel_url",
@@ -404,7 +407,9 @@ def test_install_kernel_falls_back_to_source(monkeypatch):
# no wheel -> source build -> importable after install
states = iter([False, True]) # before install, after install
monkeypatch.setattr(ssm_runtime, "_is_importable", lambda name: next(states))
- monkeypatch.setattr(ssm_runtime, "probe_torch_wheel_env", lambda timeout = 30: {})
+ monkeypatch.setattr(
+ ssm_runtime, "probe_torch_wheel_env", lambda timeout = 30, include_windows = False: {}
+ )
monkeypatch.setattr(ssm_runtime, "direct_wheel_url", lambda **k: None)
pip_cmds = []
ok = ssm_runtime._install_kernel(
@@ -451,9 +456,7 @@ def test_is_importable_treats_broken_kernel_as_not_importable(monkeypatch, exc):
assert ssm_runtime._is_importable("causal_conv1d") is False
-def test_causal_conv1d_skipped_on_windows(monkeypatch):
- # No prebuilt Windows wheel: a causal-conv1d-only model must NOT enter the source build
- # (which can hang a chat load for minutes); it falls back to torch.
+def test_causal_conv1d_attempted_on_windows(monkeypatch):
monkeypatch.setattr(ssm_runtime.sys, "platform", "win32")
installed = []
monkeypatch.setattr(
@@ -462,12 +465,16 @@ def test_causal_conv1d_skipped_on_windows(monkeypatch):
lambda *, import_name, **_: installed.append(import_name) or True,
)
ssm_runtime.ensure_ssm_runtime("Qwen/Qwen3-Next-80B-A3B")
- assert installed == [] # never attempted to build causal-conv1d
+ assert installed == ["causal_conv1d"]
-def test_ssm_model_on_windows_still_installs_mamba(monkeypatch):
- # A true SSM hybrid still needs mamba-ssm on Windows; only causal-conv1d is skipped.
+def test_ssm_model_on_windows_installs_causal_then_mamba_with_triton(monkeypatch):
monkeypatch.setattr(ssm_runtime.sys, "platform", "win32")
+ monkeypatch.setattr(
+ ssm_runtime.importlib.util,
+ "find_spec",
+ lambda name, *a: object() if name == "triton" else None,
+ )
installed = []
monkeypatch.setattr(
ssm_runtime,
@@ -475,7 +482,93 @@ def test_ssm_model_on_windows_still_installs_mamba(monkeypatch):
lambda *, import_name, **_: installed.append(import_name) or True,
)
ssm_runtime.ensure_ssm_runtime("unsloth/NVIDIA-Nemotron-3-Nano-4B")
- assert installed == ["mamba_ssm"] # causal-conv1d skipped, mamba-ssm still attempted
+ assert installed == ["causal_conv1d", "mamba_ssm"]
+
+
+def test_ssm_model_on_windows_without_triton_fails_clearly(monkeypatch):
+ monkeypatch.setattr(ssm_runtime.sys, "platform", "win32")
+ monkeypatch.setattr(ssm_runtime.importlib.util, "find_spec", lambda name, *a: None)
+ installed = []
+ monkeypatch.setattr(
+ ssm_runtime,
+ "_install_kernel",
+ lambda *, import_name, **_: installed.append(import_name) or True,
+ )
+ with pytest.raises(RuntimeError, match = "triton-windows"):
+ ssm_runtime.ensure_ssm_runtime("unsloth/NVIDIA-Nemotron-3-Nano-4B")
+ assert "mamba_ssm" not in installed
+
+
+def _windows_install_kernel(
+ monkeypatch,
+ *,
+ wheel_url,
+ exists,
+ outcome_rc = 0,
+ importable_after = True,
+):
+ """Drive _install_kernel as Windows; returns (result, commands run, wheel installs)."""
+ monkeypatch.setattr(ssm_runtime.sys, "platform", "win32")
+ # shutil.which consults sys.platform, and a Linux host cannot answer as Windows.
+ monkeypatch.setattr(ssm_runtime.shutil, "which", lambda *a, **k: None)
+ states = iter([False, importable_after])
+ monkeypatch.setattr(ssm_runtime, "_is_importable", lambda name: next(states))
+ probe_kwargs = {}
+ monkeypatch.setattr(
+ ssm_runtime,
+ "probe_torch_wheel_env",
+ lambda **k: probe_kwargs.update(k) or {"platform_tag": "win_amd64"},
+ )
+ monkeypatch.setattr(ssm_runtime, "direct_wheel_url", lambda **k: wheel_url)
+ monkeypatch.setattr(ssm_runtime, "url_exists", lambda u: exists)
+ installs = []
+ monkeypatch.setattr(
+ ssm_runtime,
+ "install_wheel",
+ lambda url, **k: installs.append(url) or [("uv", _Result(returncode = outcome_rc))],
+ )
+ ran = []
+ ok = ssm_runtime._install_kernel(
+ import_name = "causal_conv1d",
+ display_name = "causal-conv1d",
+ pypi_name = "causal-conv1d",
+ package_version = "1.6.1",
+ release_tag = "v1.6.1.post4",
+ release_base_url = "https://github.com/Dao-AILab/causal-conv1d/releases/download",
+ status_cb = None,
+ run = lambda cmd, **k: ran.append(cmd) or _Result(),
+ )
+ assert probe_kwargs.get("include_windows") is True
+ return ok, ran, installs
+
+
+def test_windows_installs_the_published_wheel(monkeypatch):
+ ok, ran, installs = _windows_install_kernel(
+ monkeypatch, wheel_url = "https://example/causal_conv1d-win_amd64.whl", exists = True
+ )
+ assert ok is True
+ assert installs == ["https://example/causal_conv1d-win_amd64.whl"]
+ assert ran == []
+
+
+ ("wheel_url", "exists"), [(None, False), ("https://x/w.whl", False), ("https://x/w.whl", None)]
+)
+def test_windows_never_source_builds_without_a_wheel(monkeypatch, wheel_url, exists):
+ ok, ran, installs = _windows_install_kernel(monkeypatch, wheel_url = wheel_url, exists = exists)
+ assert ok is False
+ assert installs == []
+ assert ran == [] # no pip / uv source build
+
+
+def test_windows_rejected_wheel_is_removed_not_source_built(monkeypatch):
+ ok, ran, installs = _windows_install_kernel(
+ monkeypatch, wheel_url = "https://x/w.whl", exists = True, importable_after = False
+ )
+ assert ok is False
+ assert len(installs) == 1
+ assert len(ran) == 1 and "uninstall" in ran[0]
+ assert not any("--no-build-isolation" in cmd for cmd in ran)
def test_wheel_installed_but_not_importable_falls_back_to_source(monkeypatch):
@@ -483,7 +576,9 @@ def test_wheel_installed_but_not_importable_falls_back_to_source(monkeypatch):
# after source build: importable.
states = iter([False, False, True])
monkeypatch.setattr(ssm_runtime, "_is_importable", lambda name: next(states))
- monkeypatch.setattr(ssm_runtime, "probe_torch_wheel_env", lambda timeout = 30: {})
+ monkeypatch.setattr(
+ ssm_runtime, "probe_torch_wheel_env", lambda timeout = 30, include_windows = False: {}
+ )
monkeypatch.setattr(ssm_runtime, "direct_wheel_url", lambda **k: "https://x/w.whl")
monkeypatch.setattr(ssm_runtime, "url_exists", lambda u: True)
monkeypatch.setattr(
@@ -508,7 +603,9 @@ def test_hip_source_build_requires_hipcc(monkeypatch):
# ROCm env (hip_version set) with no wheel and no hipcc must fail clearly, not build.
monkeypatch.setattr(ssm_runtime, "_is_importable", lambda name: False)
monkeypatch.setattr(
- ssm_runtime, "probe_torch_wheel_env", lambda timeout = 30: {"hip_version": "6.2"}
+ ssm_runtime,
+ "probe_torch_wheel_env",
+ lambda timeout = 30, include_windows = False: {"hip_version": "6.2"},
)
monkeypatch.setattr(ssm_runtime, "direct_wheel_url", lambda **k: None)
monkeypatch.setattr(ssm_runtime.shutil, "which", lambda name: None) # no uv, no hipcc
@@ -532,7 +629,9 @@ def test_source_build_reinstalls_to_replace_broken_wheel(monkeypatch):
# the source build must reinstall so it replaces it instead of no-opping.
states = iter([False, True])
monkeypatch.setattr(ssm_runtime, "_is_importable", lambda name: next(states))
- monkeypatch.setattr(ssm_runtime, "probe_torch_wheel_env", lambda timeout = 30: {})
+ monkeypatch.setattr(
+ ssm_runtime, "probe_torch_wheel_env", lambda timeout = 30, include_windows = False: {}
+ )
monkeypatch.setattr(ssm_runtime, "direct_wheel_url", lambda **k: None)
cmds = []
ssm_runtime._install_kernel(
@@ -553,7 +652,9 @@ def test_hip_uv_source_build_uses_no_cache(monkeypatch):
states = iter([False, True])
monkeypatch.setattr(ssm_runtime, "_is_importable", lambda name: next(states))
monkeypatch.setattr(
- ssm_runtime, "probe_torch_wheel_env", lambda timeout = 30: {"hip_version": "6.2"}
+ ssm_runtime,
+ "probe_torch_wheel_env",
+ lambda timeout = 30, include_windows = False: {"hip_version": "6.2"},
)
monkeypatch.setattr(ssm_runtime, "direct_wheel_url", lambda **k: None)
monkeypatch.setattr(ssm_runtime.shutil, "which", lambda name: "/usr/bin/" + name) # uv + hipcc
diff --git a/studio/backend/tests/test_training_worker_flash_attn.py b/studio/backend/tests/test_training_worker_flash_attn.py
index 9f34dbe32bf..87012b042e8 100644
--- a/studio/backend/tests/test_training_worker_flash_attn.py
+++ b/studio/backend/tests/test_training_worker_flash_attn.py
@@ -18,18 +18,17 @@ import pytest
from core.training import worker
-# The runtime install is Linux-only, so elsewhere these return before any status.
+# The runtime flash-attn install runs on Linux and Windows only, and Windows never takes the PyPI
+# fallback these exercise, so they are pinned to a Linux host.
linux_only = pytest.mark.skipif(
not sys.platform.startswith("linux"),
- reason = "the runtime flash-attn install is gated to Linux",
+ reason = "exercises the Linux runtime flash-attn install and its PyPI fallback",
)
-# causal-conv1d is NOT Linux-gated: the installer bails out on `sys.platform == "win32"`
-# alone (no prebuilt wheel for Windows) and runs everywhere else, macOS included.
-# linux_only here would skip cases that legitimately pass off Linux.
+# Windows installs kernels wheel-only (no PyPI source build), which these do not model.
not_on_windows = pytest.mark.skipif(
sys.platform == "win32",
- reason = "mirrors the sys.platform == 'win32' bail-out in _ensure_causal_conv1d_fast_path",
+ reason = "models the PyPI fallback that Windows never takes",
)
@@ -212,7 +211,7 @@ class TestNoExitLeavesAnUnusableInstall:
monkeypatch.setattr(
worker,
"probe_torch_wheel_env",
- lambda timeout = 30: {
+ lambda timeout = 30, include_windows = False: {
"python_tag": "cp313",
"torch_mm": "2.10",
"cuda_major": "",
@@ -287,7 +286,15 @@ class TestNoExitLeavesAnUnusableInstall:
def test_should_try_runtime_flash_attn_install_threshold_and_skip(monkeypatch):
monkeypatch.delenv(worker._FLASH_ATTN_SKIP_ENV, raising = False)
assert worker._should_try_runtime_flash_attn_install(32767) is False
- assert worker._should_try_runtime_flash_attn_install(32768) is sys.platform.startswith("linux")
+ assert worker._should_try_runtime_flash_attn_install(32768) is (
+ sys.platform.startswith("linux") or sys.platform == "win32"
+ )
+ monkeypatch.setattr(worker.sys, "platform", "win32")
+ monkeypatch.delenv(worker._FLASH_ATTN_SKIP_ENV, raising = False)
+ assert worker._should_try_runtime_flash_attn_install(32768) is True
+ monkeypatch.setattr(worker.sys, "platform", "darwin")
+ assert worker._should_try_runtime_flash_attn_install(32768) is False
+ monkeypatch.undo()
monkeypatch.setenv(worker._FLASH_ATTN_SKIP_ENV, "1")
assert worker._should_try_runtime_flash_attn_install(32768) is False
@@ -476,7 +483,7 @@ def test_runtime_flash_attn_falls_back_to_pypi(monkeypatch):
monkeypatch.setattr(
worker,
"probe_torch_wheel_env",
- lambda timeout = 30: {
+ lambda timeout = 30, include_windows = False: {
"python_tag": "cp313",
"torch_mm": "2.10",
"cuda_major": "13",
@@ -976,7 +983,9 @@ def test_no_install_path_pips_flash_linear_attention_or_tilelang(monkeypatch, uv
monkeypatch.setattr(worker._sp, "run", fake_run)
monkeypatch.setattr(worker, "_is_importable", lambda name: False)
monkeypatch.setattr(worker, "_is_importable_isolated", lambda name: True)
- monkeypatch.setattr(worker, "probe_torch_wheel_env", lambda timeout = 30: {})
+ monkeypatch.setattr(
+ worker, "probe_torch_wheel_env", lambda timeout = 30, include_windows = False: {}
+ )
monkeypatch.setattr(worker, "url_exists", lambda url: False)
monkeypatch.setattr(worker, "install_wheel", mock.Mock())
monkeypatch.setattr(worker, "flash_attn_wheel_url", lambda env: None)
@@ -1321,7 +1330,7 @@ def _make_hip_install_env(monkeypatch, *, gcc_dir: str | None):
monkeypatch.setattr(
worker,
"probe_torch_wheel_env",
- lambda timeout = 30: {
+ lambda timeout = 30, include_windows = False: {
"hip_version": "7.13.26176",
"python_tag": "cp312",
"torch_mm": "2.11",
@@ -1438,7 +1447,7 @@ def test_install_does_not_inject_env_on_cuda(monkeypatch):
monkeypatch.setattr(
worker,
"probe_torch_wheel_env",
- lambda timeout = 30: {
+ lambda timeout = 30, include_windows = False: {
"python_tag": "cp312",
"torch_mm": "2.11",
"cuda_major": "12",
@@ -1477,3 +1486,108 @@ def test_install_does_not_inject_env_on_cuda(monkeypatch):
# env is always passed (to force UTF-8), but never the HIP flag.
assert "HIPCC_COMPILE_FLAGS_APPEND" not in captured
+
+
+def _as_windows(monkeypatch):
+ monkeypatch.setattr(worker.sys, "platform", "win32")
+ # shutil.which consults sys.platform, and a Linux host cannot answer as Windows.
+ monkeypatch.setattr(worker.shutil, "which", lambda *a, **k: None)
+
+
+def test_windows_causal_conv1d_fast_path_installs(monkeypatch):
+ _as_windows(monkeypatch)
+ install_mock = mock.Mock(return_value = True)
+ monkeypatch.setattr(worker, "_install_package_wheel_first", install_mock)
+ worker._ensure_causal_conv1d_fast_path(event_queue = [], model_name = "unsloth/Qwen3.6-4B")
+ install_mock.assert_called_once()
+
+
+def test_windows_mamba_ssm_needs_triton(monkeypatch):
+ _as_windows(monkeypatch)
+ statuses: list[str] = []
+ monkeypatch.setattr(worker, "_send_status", lambda queue, message: statuses.append(message))
+ install_mock = mock.Mock(return_value = True)
+ monkeypatch.setattr(worker, "_install_package_wheel_first", install_mock)
+ monkeypatch.setattr(worker.importlib.util, "find_spec", lambda name, *a: None)
+ worker._ensure_mamba_ssm(event_queue = [], model_name = "tiiuae/Falcon-H1-0.5B-Instruct")
+ install_mock.assert_not_called()
+ assert any("triton-windows" in message for message in statuses)
+
+ monkeypatch.setattr(
+ worker.importlib.util,
+ "find_spec",
+ lambda name, *a: object() if name == "triton" else None,
+ )
+ worker._ensure_mamba_ssm(event_queue = [], model_name = "tiiuae/Falcon-H1-0.5B-Instruct")
+ install_mock.assert_called_once()
+
+
+def _windows_attempt(monkeypatch, *, wheel_url, exists, importable_after_install):
+ _as_windows(monkeypatch)
+ probe_kwargs: dict[str, Any] = {}
+ monkeypatch.setattr(
+ worker,
+ "probe_torch_wheel_env",
+ lambda **k: probe_kwargs.update(k) or {"platform_tag": "win_amd64", "cuda_major": "13"},
+ )
+ monkeypatch.setattr(worker, "url_exists", lambda url: exists)
+ state = {"installed": False}
+
+ def _install(*_a, **_k):
+ state["installed"] = True
+ return [("pip", subprocess.CompletedProcess(["pip"], 0, ""))]
+
+ monkeypatch.setattr(worker, "install_wheel", _install)
+ monkeypatch.setattr(
+ worker,
+ "_is_importable_isolated",
+ lambda name: state["installed"] and importable_after_install,
+ )
+ monkeypatch.setattr(worker, "_send_status", lambda queue, message: None)
+ runs: list[list[str]] = []
+ monkeypatch.setattr(
+ worker._sp,
+ "run",
+ lambda cmd, **k: runs.append(list(cmd)) or subprocess.CompletedProcess(cmd, 0, ""),
+ )
+ ok = worker._attempt_package_install(
+ event_queue = [],
+ import_name = "flash_attn",
+ display_name = "flash-attn",
+ pypi_name = "flash-attn",
+ wheel_url_builder = lambda env: wheel_url,
+ pypi_spec = "flash-attn",
+ )
+ assert probe_kwargs.get("include_windows") is True
+ return ok, runs, state["installed"]
+
+
+def test_windows_installs_a_published_wheel(monkeypatch):
+ ok, runs, installed = _windows_attempt(
+ monkeypatch,
+ wheel_url = "https://x/fa-win_amd64.whl",
+ exists = True,
+ importable_after_install = True,
+ )
+ assert ok is True and installed is True
+ assert runs == []
+
+
+ ("wheel_url", "exists"),
+ [(None, False), ("https://x/fa.whl", False), ("https://x/fa.whl", None)],
+)
+def test_windows_never_falls_back_to_pypi(monkeypatch, wheel_url, exists):
+ ok, runs, installed = _windows_attempt(
+ monkeypatch, wheel_url = wheel_url, exists = exists, importable_after_install = True
+ )
+ assert ok is False and installed is False
+ assert runs == [] # no pip / uv install from PyPI
+
+
+def test_windows_rejected_wheel_does_not_fall_back_to_pypi(monkeypatch):
+ ok, runs, installed = _windows_attempt(
+ monkeypatch, wheel_url = "https://x/fa.whl", exists = True, importable_after_install = False
+ )
+ assert ok is False and installed is True
+ assert runs == []
diff --git a/studio/backend/tests/test_wheel_utils_linux_aarch64_kernels.py b/studio/backend/tests/test_wheel_utils_linux_aarch64_kernels.py
new file mode 100644
index 00000000000..ebb1f46205f
--- /dev/null
+++ b/studio/backend/tests/test_wheel_utils_linux_aarch64_kernels.py
@@ -0,0 +1,70 @@
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+"""linux_aarch64 kernel wheel resolution: upstream's aarch64 wheels stop at torch 2.10, so torch
+2.13 / 2.14 cp313 resolve to our builds on prebuilt-wheels-cu13, and every other cell resolves
+exactly as it did before."""
+
+import sys
+from pathlib import Path
+
+import pytest
+
+_BACKEND = Path(__file__).resolve().parent.parent
+if str(_BACKEND) not in sys.path:
+ sys.path.insert(0, str(_BACKEND))
+
+from utils import kernel_install, wheel_utils # noqa: E402
+
+OURS = "https://github.com/unslothai/unsloth/releases/download/prebuilt-wheels-cu13/"
+
+
+def env(**overrides):
+ base = {
+ "platform_tag": "linux_aarch64",
+ "torch_mm": "2.13",
+ "cuda_major": "13",
+ "cxx11abi": "TRUE",
+ "python_tag": "cp313",
+ "abi_tag": "cp313",
+ "torch_version": "2.13.0+cu130",
+ "cuda_version": "13.0",
+ "hip_version": "",
+ }
+ base.update(overrides)
+ return base
+
+
[email protected]("torch_mm", ["2.13", "2.14"])
+def test_all_three_resolve_to_our_builds(torch_mm):
+ e = env(torch_mm = torch_mm, torch_version = f"{torch_mm}.0+cu130")
+ tail = f"+cu13torch{torch_mm}cxx11abiTRUE-cp313-cp313-linux_aarch64.whl"
+ assert wheel_utils.flash_attn_wheel_url(e) == f"{OURS}flash_attn-2.8.4{tail}"
+ assert kernel_install.CAUSAL_CONV1D.wheel_url(e) == f"{OURS}causal_conv1d-1.7.0{tail}"
+ assert kernel_install.MAMBA_SSM.wheel_url(e) == f"{OURS}mamba_ssm-2.3.2.post1{tail}"
+
+
+ "overrides",
+ [
+ {"python_tag": "cp312", "abi_tag": "cp312"},
+ {"python_tag": "cp314", "abi_tag": "cp314t"},
+ {"cuda_major": "12", "cuda_version": "12.8"},
+ {"cxx11abi": "FALSE"},
+ {"torch_mm": "2.10"},
+ {"torch_mm": "2.11"},
+ ],
+)
+def test_cells_we_do_not_build_never_name_our_release(overrides):
+ e = env(**overrides)
+ for url in (
+ wheel_utils.flash_attn_wheel_url(e),
+ kernel_install.CAUSAL_CONV1D.wheel_url(e),
+ kernel_install.MAMBA_SSM.wheel_url(e),
+ ):
+ assert url is None or not url.startswith(OURS), url
+
+
+def test_torch_2_10_still_resolves_upstream():
+ e = env(torch_mm = "2.10", torch_version = "2.10.0+cu130")
+ assert "Dao-AILab/causal-conv1d" in kernel_install.CAUSAL_CONV1D.wheel_url(e)
diff --git a/studio/backend/tests/test_wheel_utils_windows_kernels.py b/studio/backend/tests/test_wheel_utils_windows_kernels.py
new file mode 100644
index 00000000000..4458874aeed
--- /dev/null
+++ b/studio/backend/tests/test_wheel_utils_windows_kernels.py
@@ -0,0 +1,278 @@
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+"""Windows kernel wheel resolution: our win_amd64 builds on prebuilt-wheels-cu13, NVIDIA's win_arm64
+flash-attn, nothing upstream, and Linux URLs exactly as before."""
+
+import itertools
+import subprocess
+import sys
+from pathlib import Path
+
+import pytest
+
+_BACKEND = Path(__file__).resolve().parent.parent
+if str(_BACKEND) not in sys.path:
+ sys.path.insert(0, str(_BACKEND))
+
+from utils import kernel_install, wheel_utils # noqa: E402
+
+OURS = "https://github.com/unslothai/unsloth/releases/download/prebuilt-wheels-cu13/"
+NVIDIA = "https://github.com/NVIDIA/pytorch-windows-ci/releases/download/Flash-Attention-for-WoA/"
+
+
+def env(**overrides):
+ base = {
+ "platform_tag": "win_amd64",
+ "torch_mm": "2.13",
+ "cuda_major": "13",
+ # What the Windows cu130 torch 2.13 / 2.14 wheels report (measured on windows-2022).
+ "cxx11abi": "TRUE",
+ "python_tag": "cp313",
+ "abi_tag": "cp313",
+ "torch_version": "2.13.0+cu130",
+ "cuda_version": "13.0",
+ "hip_version": "",
+ }
+ base.update(overrides)
+ return base
+
+
[email protected]("torch_mm", ["2.13", "2.14"])
+def test_win_amd64_resolves_every_kernel_to_our_release(torch_mm):
+ e = env(torch_mm = torch_mm)
+ suffix = f"+cu13torch{torch_mm}cxx11abiTRUE-cp313-cp313-win_amd64.whl"
+ assert wheel_utils.flash_attn_wheel_url(e) == f"{OURS}flash_attn-2.8.4{suffix}"
+ assert kernel_install.CAUSAL_CONV1D.wheel_url(e) == f"{OURS}causal_conv1d-1.7.0{suffix}"
+ assert kernel_install.MAMBA_SSM.wheel_url(e) == f"{OURS}mamba_ssm-2.3.2.post1{suffix}"
+
+
+ "overrides",
+ [
+ {"python_tag": "cp312", "abi_tag": "cp312"}, # only cp313 is published for Windows
+ {"abi_tag": "cp313t"}, # a free-threaded build cannot load the GIL wheel
+ {"cxx11abi": "FALSE"}, # not what the Windows cu130 torch reports
+ {"torch_mm": "2.11"}, # Windows default today; no wheel, and no upstream fallback
+ {"torch_mm": "2.10"},
+ {"cuda_major": "12"},
+ {"cuda_major": ""},
+ ],
+)
+def test_win_amd64_outside_the_published_cells_resolves_to_nothing(overrides):
+ e = env(**overrides)
+ assert wheel_utils.flash_attn_wheel_url(e) is None
+ assert kernel_install.CAUSAL_CONV1D.wheel_url(e) is None
+ assert kernel_install.MAMBA_SSM.wheel_url(e) is None
+
+
+def test_no_windows_url_ever_names_an_upstream_release():
+ for torch_mm, cuda, py, abi in itertools.product(
+ ["2.4", "2.8", "2.9", "2.10", "2.11", "2.12", "2.13", "2.14"],
+ ["12", "13"],
+ ["cp311", "cp312", "cp313", "cp314"],
+ ["TRUE", "FALSE"],
+ ):
+ for platform_tag in ("win_amd64", "win_arm64"):
+ e = env(
+ platform_tag = platform_tag,
+ torch_mm = torch_mm,
+ cuda_major = cuda,
+ python_tag = py,
+ abi_tag = py,
+ cxx11abi = abi,
+ )
+ for url in (
+ wheel_utils.flash_attn_wheel_url(e),
+ kernel_install.CAUSAL_CONV1D.wheel_url(e),
+ kernel_install.MAMBA_SSM.wheel_url(e),
+ ):
+ assert url is None or url.startswith((OURS, NVIDIA)), url
+ assert url is None or "Dao-AILab" not in url and "state-spaces" not in url
+
+
+ ("python_tag", "abi_tag"),
+ [
+ ("cp311", "cp311"),
+ ("cp312", "cp312"),
+ ("cp313", "cp313"),
+ ("cp314", "cp314"),
+ ("cp314", "cp314t"),
+ ],
+)
+def test_win_arm64_flash_attn_is_nvidias_wheel_with_its_sha256(python_tag, abi_tag):
+ e = env(
+ platform_tag = "win_arm64",
+ torch_mm = "2.14",
+ python_tag = python_tag,
+ abi_tag = abi_tag,
+ torch_version = "2.14.0+cu134",
+ cuda_version = "13.4",
+ )
+ url = wheel_utils.flash_attn_wheel_url(e)
+ digest = wheel_utils.NVIDIA_WOA_FLASH_ATTN_SHA256[abi_tag]
+ assert url == (
+ f"{NVIDIA}flash_attn-2.8.4+cu13torch2.14-{python_tag}-{abi_tag}-win_arm64.whl#sha256={digest}"
+ )
+ assert len(digest) == 64 and int(digest, 16) >= 0
+ assert "#" not in wheel_utils.redact_url_credentials(url)
+
+
+ "overrides",
+ [
+ {"torch_mm": "2.13"},
+ {"torch_mm": "2.15"},
+ {"cuda_major": "12", "cuda_version": "12.8"},
+ {"cuda_version": "13.0"},
+ {"python_tag": "cp310", "abi_tag": "cp310"},
+ ],
+)
+def test_win_arm64_flash_attn_only_for_the_published_pair(overrides):
+ e = woa_env()
+ e.update(overrides)
+ assert wheel_utils.flash_attn_wheel_url(e) is None
+
+
+def woa_env(**overrides):
+ """What NVIDIA's torch 2.14.0+cu134 reports on Windows on ARM."""
+ return env(
+ **{
+ "platform_tag": "win_arm64",
+ "torch_mm": "2.14",
+ "torch_version": "2.14.0+cu134",
+ "cuda_version": "13.4",
+ **overrides,
+ }
+ )
+
+
[email protected]("python_tag", ["cp311", "cp312", "cp313"])
+def test_win_arm64_causal_conv1d_and_mamba_are_ours(python_tag):
+ e = woa_env(python_tag = python_tag, abi_tag = python_tag)
+ assert kernel_install.CAUSAL_CONV1D.wheel_url(e) == (
+ f"{OURS}causal_conv1d-1.7.0+cu13torch2.14cxx11abiTRUE-{python_tag}-{python_tag}-win_arm64.whl"
+ )
+ assert kernel_install.MAMBA_SSM.wheel_url(e) == (
+ f"{OURS}mamba_ssm-2.3.2.post1+cu13torch2.14cxx11abiTRUE-{python_tag}-{python_tag}-win_arm64.whl"
+ )
+ # flash-attn stays NVIDIA's even though the platform is in our table.
+ assert wheel_utils.flash_attn_wheel_url(e).startswith(NVIDIA)
+
+
+ "overrides",
+ [
+ {"torch_mm": "2.13", "torch_version": "2.13.0+cu134"},
+ {"cuda_version": "13.0"},
+ {"cuda_version": "", "cuda_major": ""},
+ {"python_tag": "cp314", "abi_tag": "cp314"},
+ {"python_tag": "cp314", "abi_tag": "cp314t"},
+ ],
+)
+def test_win_arm64_kernels_only_for_the_cells_we_build(overrides):
+ e = woa_env(**overrides)
+ assert kernel_install.CAUSAL_CONV1D.wheel_url(e) is None
+ assert kernel_install.MAMBA_SSM.wheel_url(e) is None
+
+
+def test_an_env_without_abi_tag_is_read_as_a_gil_build():
+ e = woa_env()
+ del e["abi_tag"]
+ assert wheel_utils.flash_attn_wheel_url(e).endswith(
+ "-cp313-cp313-win_arm64.whl#sha256=" + wheel_utils.NVIDIA_WOA_FLASH_ATTN_SHA256["cp313"]
+ )
+ e = env()
+ del e["abi_tag"]
+ assert wheel_utils.flash_attn_wheel_url(e) is not None
+
+
+ ("torch_mm", "python_tag", "expected"),
+ [
+ (
+ "2.13",
+ "cp313",
+ f"{OURS}flash_attn-2.8.4+cu13torch2.13cxx11abiTRUE-cp313-cp313-linux_x86_64.whl",
+ ),
+ (
+ "2.14",
+ "cp312",
+ f"{OURS}flash_attn-2.8.4+cu13torch2.14cxx11abiTRUE-cp312-cp312-linux_x86_64.whl",
+ ),
+ (
+ "2.11",
+ "cp313",
+ "https://github.com/Dao-AILab/flash-attention/releases/download/v2.8.1/"
+ "flash_attn-2.8.1+cu13torch2.10cxx11abiTRUE-cp313-cp313-linux_x86_64.whl",
+ ),
+ ],
+)
+def test_linux_flash_attn_urls_unchanged(torch_mm, python_tag, expected):
+ e = env(
+ platform_tag = "linux_x86_64",
+ cxx11abi = "TRUE",
+ torch_mm = torch_mm,
+ python_tag = python_tag,
+ abi_tag = python_tag,
+ )
+ assert wheel_utils.flash_attn_wheel_url(e) == expected
+
+
+def test_linux_free_threaded_keeps_resolving_as_before():
+ # Linux has never looked at abi_tag; adding it must not change a Linux answer.
+ e = env(platform_tag = "linux_x86_64", cxx11abi = "TRUE", abi_tag = "cp313t")
+ assert wheel_utils.flash_attn_wheel_url(e) == (
+ f"{OURS}flash_attn-2.8.4+cu13torch2.13cxx11abiTRUE-cp313-cp313-linux_x86_64.whl"
+ )
+
+
+def test_windows_probe_is_opt_in_for_both_windows_tags(monkeypatch):
+ calls = []
+ monkeypatch.setattr(
+ wheel_utils.subprocess,
+ "run",
+ lambda *a, **k: calls.append(a) or subprocess.CompletedProcess(a, 1, ""),
+ )
+ for tag in ("win_amd64", "win_arm64"):
+ monkeypatch.setattr(wheel_utils, "wheel_platform_tag", lambda tag = tag: tag)
+ assert wheel_utils.probe_torch_wheel_env(timeout = 5) is None
+ assert calls == [] # never even spawned the probe without the opt-in
+ wheel_utils.probe_torch_wheel_env(timeout = 5, include_windows = True)
+ assert len(calls) == 1
+
+
+def test_probe_reports_abi_tag():
+ probe = subprocess.run(
+ [
+ sys.executable,
+ "-c",
+ "import sys, sysconfig; print(f'cp{sys.version_info.major}{sys.version_info.minor}' + "
+ "('t' if sysconfig.get_config_var('Py_GIL_DISABLED') else ''))",
+ ],
+ capture_output = True,
+ text = True,
+ check = True,
+ )
+ tag = probe.stdout.strip()
+ assert tag.startswith(f"cp{sys.version_info.major}{sys.version_info.minor}")
+ source = Path(wheel_utils.__file__).read_text(encoding = "utf-8")
+ assert (
+ "'abi_tag': f'cp{sys.version_info.major}{sys.version_info.minor}' + ('t' if sysconfig.get_config_var('Py_GIL_DISABLED') else '')"
+ in source
+ )
+
+
+def test_cli_resolves_windows_kernels():
+ e = env()
+ assert kernel_install.resolve_wheel_url("flash_attn", e).endswith("-cp313-cp313-win_amd64.whl")
+ assert kernel_install.resolve_wheel_url("causal_conv1d", e).endswith(
+ "-cp313-cp313-win_amd64.whl"
+ )
+ assert kernel_install.resolve_wheel_url("mamba_ssm", e).endswith("-cp313-cp313-win_amd64.whl")
+ assert kernel_install.resolve_wheel_url("flash_attn", env(torch_mm = "2.11")) is None
+ assert (
+ kernel_install.resolve_wheel_url("flash_attn", env(platform_tag = "macosx_14_0_arm64"))
+ is None
+ )
diff --git a/studio/backend/tests/test_wheel_utils_xformers.py b/studio/backend/tests/test_wheel_utils_xformers.py
index 89ee084f152..8c60ae7b5ad 100644
--- a/studio/backend/tests/test_wheel_utils_xformers.py
+++ b/studio/backend/tests/test_wheel_utils_xformers.py
@@ -45,11 +45,17 @@ class TestWheelPlatformTag:
monkeypatch.setattr(wheel_utils.platform, "machine", lambda: "AMD64")
assert wheel_utils.wheel_platform_tag() == "win_amd64"
- def test_windows_on_arm_has_no_wheel(self, monkeypatch):
- """No CUDA and no win_arm64 asset on any index -- must stay None."""
+ def test_windows_on_arm_is_named_but_has_no_xformers_wheel(self, monkeypatch):
+ """NVIDIA publishes win_arm64 CUDA torch and flash-attn, so the tag is named; xFormers still has no win_arm64 asset."""
monkeypatch.setattr(wheel_utils.sys, "platform", "win32")
monkeypatch.setattr(wheel_utils.platform, "machine", lambda: "ARM64")
- assert wheel_utils.wheel_platform_tag() is None
+ assert wheel_utils.wheel_platform_tag() == "win_arm64"
+ env = {
+ "platform_tag": "win_arm64",
+ "torch_version": "2.14.0+cu134",
+ "cuda_version": "13.4",
+ }
+ assert wheel_utils.xformers_wheel_url(env) is None
@pytest.mark.parametrize(
("machine", "expected"),
diff --git a/studio/backend/utils/kernel_install.py b/studio/backend/utils/kernel_install.py
index 0d397941cc5..130f8a7ab2a 100644
--- a/studio/backend/utils/kernel_install.py
+++ b/studio/backend/utils/kernel_install.py
@@ -209,8 +209,7 @@ def resolve_wheel_url(name: str, env: dict[str, str] | None) -> str | None:
return None
if name == "xformers":
return xformers_wheel_url(env)
- # flash-attn, causal-conv1d and mamba-ssm publish Linux wheels only.
- if not str(env.get("platform_tag") or "").startswith("linux"):
+ if not str(env.get("platform_tag") or "").startswith(("linux", "win_")):
return None
if name == "flash_attn":
return flash_attn_wheel_url(env)
@@ -350,6 +349,13 @@ def install_kernel(
if url is None or exists(url) is False:
print(f"Unsloth: no prebuilt {name} for {torch_desc}; using the torch fallback.")
return 0
+ # mamba_ssm imports triton at load; on Windows that is triton-windows, which its metadata cannot name.
+ if name == "mamba_ssm" and sys.platform == "win32" and not _loads("import triton", run):
+ print(
+ "Unsloth: skipping mamba_ssm, which needs Triton on Windows; "
+ "install triton-windows first (Studio setup does), then re-run."
+ )
+ return 0
# UNSLOTH_PYTORCH_MIRROR may carry credentials, and notebook output gets shared.
shown = redact_url_credentials(url)
if dry_run:
diff --git a/studio/backend/utils/ssm_runtime.py b/studio/backend/utils/ssm_runtime.py
index c60f1e618b0..db6d2e65b87 100644
--- a/studio/backend/utils/ssm_runtime.py
+++ b/studio/backend/utils/ssm_runtime.py
@@ -8,6 +8,7 @@ the inference-path counterpart of the training worker's install.
from __future__ import annotations
import importlib
+import importlib.util
import os
import shutil
import subprocess
@@ -26,10 +27,12 @@ from utils.kernel_install import (
install_prebuilt,
source_build_command,
source_build_run_kwargs,
+ uninstall_command,
)
from utils.wheel_utils import (
direct_wheel_url,
install_wheel,
+ is_windows_wheel_env,
probe_torch_wheel_env,
url_exists,
)
@@ -263,7 +266,7 @@ def _install_kernel(
status_cb: StatusCb,
run: Callable[..., Any],
) -> bool:
- """Install one kernel wheel-first, then a HIP-aware PyPI source build. Returns True iff importable afterwards; idempotent (no-op when already installed)."""
+ """Install one kernel wheel-first, then a HIP-aware PyPI source build (never on Windows). Returns True iff importable afterwards; idempotent (no-op when already installed)."""
if _is_importable(import_name):
logger.info("%s already installed", display_name)
return True
@@ -274,7 +277,8 @@ def _install_kernel(
logger.info("Skipping %s installation while offline", display_name)
return False
- env = probe_torch_wheel_env(timeout = 30)
+ env = probe_torch_wheel_env(timeout = 30, include_windows = True)
+ wheel_only = sys.platform == "win32" or is_windows_wheel_env(env)
wheel_url = direct_wheel_url(
filename_prefix = import_name,
package_version = package_version,
@@ -308,10 +312,31 @@ def _install_kernel(
logger.info("Installed prebuilt %s wheel", display_name)
return True
if outcome == "rejected":
+ if wheel_only:
+ removed = (
+ run(
+ uninstall_command(pypi_name, use_uv = bool(shutil.which("uv"))),
+ stdout = subprocess.DEVNULL,
+ stderr = subprocess.DEVNULL,
+ ).returncode
+ == 0
+ )
+ logger.warning(
+ "%s wheel installed but not importable; %s",
+ display_name,
+ "removed it" if removed else f"uninstall {pypi_name} manually",
+ )
+ return False
logger.warning(
"%s wheel installed but not importable; building from source",
display_name,
)
+ elif wheel_only:
+ logger.info(
+ "No prebuilt %s wheel for this Windows environment (%s); using the torch fallback",
+ display_name,
+ wheel_url,
+ )
elif wheel_available is None:
_emit(
status_cb,
@@ -324,6 +349,9 @@ def _install_kernel(
wheel_url,
)
+ if wheel_only:
+ return False
+
# Source build (slow). ROCm has no prebuilt wheel and needs hipcc + a gcc-install-dir shim.
spec = f"{pypi_name}=={package_version}"
is_hip = bool((env or {}).get("hip_version"))
@@ -372,18 +400,17 @@ def ensure_ssm_runtime(
if not (wants_causal_conv1d or is_ssm):
return
- # No prebuilt Windows wheel: skip causal-conv1d on win32 (mirrors training) rather than dropping a chat load into a multi-minute source build for an optional fast path.
- if wants_causal_conv1d and sys.platform == "win32":
- logger.info(
- "Skipping causal-conv1d on Windows (no prebuilt wheel); using the torch fallback"
- )
- wants_causal_conv1d = False
-
# causal-conv1d first: SSM modeling files lazy-import it, and mamba-ssm's fast path uses it.
if wants_causal_conv1d and not _install_kernel(
**_pinned_kwargs(CAUSAL_CONV1D), status_cb = status_cb, run = run
):
logger.warning("causal-conv1d unavailable; continuing on the model's torch fallback")
+ if is_ssm and sys.platform == "win32" and importlib.util.find_spec("triton") is None:
+ # mamba_ssm imports triton at load and the wheel goes in --no-deps.
+ raise RuntimeError(
+ "mamba-ssm, required by this Mamba model, needs Triton on Windows "
+ "(the triton-windows package); install it and reload the model."
+ )
if is_ssm and not _install_kernel(**_pinned_kwargs(MAMBA_SSM), status_cb = status_cb, run = run):
raise RuntimeError("Could not install mamba-ssm, required by this Mamba model.")
diff --git a/studio/backend/utils/wheel_utils.py b/studio/backend/utils/wheel_utils.py
index 327461789c8..3adf4a96699 100644
--- a/studio/backend/utils/wheel_utils.py
+++ b/studio/backend/utils/wheel_utils.py
@@ -34,7 +34,7 @@ MAMBA_SSM_RELEASE_BASE_URL = "https://github.com/state-spaces/mamba/releases/dow
# No arch gate, deliberately: has_blackwell_gpu() skipped flash-attn before sm_100+ wheels existed (#5420) and became the bug once they did (#6961), denying B200 hosts a working wheel. An arch gate encodes a snapshot of what upstream ships and goes stale silently both ways; the post-install import check catches a wheel that will not load whatever the cause.
def wheel_platform_tag() -> str | None:
- """pip platform tag for this host, or None where nothing we resolve is published. Windows is included because download.pytorch.org publishes CUDA-matched ``win_amd64`` xFormers wheels (see ``xformers_wheel_url``). It is NOT included for flash-attn / causal-conv1d / mamba-ssm, whose upstreams publish Linux assets only; ``probe_torch_wheel_env`` keeps that gate, not this function."""
+ """pip platform tag for this host, or None where nothing we resolve is published. Windows is included because download.pytorch.org publishes CUDA-matched ``win_amd64`` xFormers wheels (see ``xformers_wheel_url``), and flash-attn / causal-conv1d / mamba-ssm resolve only to the Windows wheels listed in this module; ``probe_torch_wheel_env`` keeps the per-caller opt-in, not this function."""
machine = platform.machine().lower()
if sys.platform.startswith("linux"):
if machine in {"x86_64", "amd64"}:
@@ -44,7 +44,8 @@ def wheel_platform_tag() -> str | None:
elif sys.platform == "win32":
if machine in {"x86_64", "amd64"}:
return "win_amd64"
- # Windows on ARM: no CUDA, and no win_arm64 wheel on any index.
+ if machine in {"arm64", "aarch64"}:
+ return "win_arm64"
# No prebuilt wheels published for macOS
return None
@@ -52,11 +53,11 @@ def wheel_platform_tag() -> str | None:
def probe_torch_wheel_env(
*, timeout: int | None = None, include_windows: bool = False
) -> dict[str, str] | None:
- """Describe the resident torch build for wheel-URL resolution, or None. Windows is opt-in via ``include_windows``: every existing caller resolves a flash-attn / causal-conv1d / mamba-ssm asset, and those projects publish no win_amd64 wheels at all, so returning an env there would only build 404s."""
+ """Describe the resident torch build for wheel-URL resolution, or None. Windows is opt-in via ``include_windows``, for callers whose every Windows URL names a published asset."""
platform_tag = wheel_platform_tag()
if platform_tag is None:
return None
- if platform_tag == "win_amd64" and not include_windows:
+ if platform_tag.startswith("win_") and not include_windows:
return None
try:
@@ -65,12 +66,14 @@ def probe_torch_wheel_env(
sys.executable,
"-c",
(
- "import json, sys, re, torch; "
+ "import json, sys, sysconfig, re, torch; "
"parts = torch.__version__.split('+', 1)[0].split('.')[:2]; "
"minor = re.sub(r'[^0-9].*', '', parts[1]) if len(parts) > 1 else '0'; "
"torch_mm = parts[0] + '.' + minor; "
"print(json.dumps({"
"'python_tag': f'cp{sys.version_info.major}{sys.version_info.minor}', "
+ # Differs from python_tag only on a free-threaded build (cp314t).
+ "'abi_tag': f'cp{sys.version_info.major}{sys.version_info.minor}' + ('t' if sysconfig.get_config_var('Py_GIL_DISABLED') else ''), "
"'torch_mm': torch_mm, "
# xFormers publishes one wheel per exact torch PATCH and per CUDA MINOR, so 'torch_mm' / 'cuda_major' cannot pick between them. Full release + full CUDA version: cu126 and cu128 are different builds of the same version string.
"'torch_version': str(torch.__version__), "
@@ -128,11 +131,72 @@ _UNSLOTH_PREBUILT_VERSIONS = {
"mamba_ssm": "2.3.2.post1",
}
+# platform_tag -> (cxx11abi field, published interpreters or None for any). The Windows cu130 torch also reports cxx11abi True; Windows publishes cp313 GIL builds only, and so does linux_aarch64 (upstream's aarch64 wheels stop at torch 2.10).
+_UNSLOTH_PREBUILT_PLATFORMS: dict[str, tuple[str, frozenset[str] | None]] = {
+ "linux_x86_64": ("TRUE", None),
+ "win_amd64": ("TRUE", frozenset({"cp313"})),
+ "linux_aarch64": ("TRUE", frozenset({"cp313"})),
+ "win_arm64": ("TRUE", frozenset({"cp311", "cp312", "cp313"})),
+}
+
+# Windows on ARM has one CUDA torch, NVIDIA's 2.14.0+cu134 (CUDA 13.4, the first with a Windows ARM64 nvcc), and NVIDIA publishes flash-attn for it, so only these two are ours there.
+_UNSLOTH_WIN_ARM64_PREFIXES = frozenset({"causal_conv1d", "mamba_ssm"})
+_WIN_ARM64_TORCH_MM = "2.14"
+_WIN_ARM64_MIN_CUDA = (13, 4)
+
+
+def _cuda_at_least(env: dict[str, str], floor: tuple[int, int]) -> bool:
+ try:
+ major, minor = (int(part) for part in str(env.get("cuda_version") or "").split(".")[:2])
+ except ValueError:
+ return False
+ return (major, minor) >= floor
+
+
+# NVIDIA's flash-attn for Windows on ARM, built for the torch 2.14.0+cu134 the WoA installer takes. Not ours to sign: each file is pinned by GitHub's asset sha256 via a #sha256= fragment, which uv and pip both enforce.
+NVIDIA_WOA_FLASH_ATTN_RELEASE_URL = (
+ "https://github.com/NVIDIA/pytorch-windows-ci/releases/download/Flash-Attention-for-WoA"
+)
+NVIDIA_WOA_FLASH_ATTN_VERSION = "2.8.4"
+NVIDIA_WOA_FLASH_ATTN_TORCH_MM = "2.14"
+NVIDIA_WOA_FLASH_ATTN_SHA256 = {
+ "cp311": "1995cf916142eeadf8474ec992b2215d3b0319dfbf0b2b57b627f1c3d2f907e4",
+ "cp312": "4be12d62df9e5adafc1be7451b9b3b2ea335d43ebd1b8288e642097144236de2",
+ "cp313": "54d1c98df04b133d227d5414a9d6d9d668e4b049246b96ecfd811b8272a9d926",
+ "cp314": "b016989f1d30a01edc9fff9ba5643170174c27cc12968fdaa33ca1c055eb17aa",
+ "cp314t": "c5269dc146c61a35e95df34aea81f35b85d7449d912325e4af00640f63cfcd5a",
+}
+
+
+def is_windows_wheel_env(env: dict[str, str] | None) -> bool:
+ """True for a Windows env, where a kernel comes from a listed wheel or not at all."""
+ return bool(env) and str(env.get("platform_tag") or "").startswith("win_")
+
+
+def nvidia_woa_flash_attn_wheel_url(env: dict[str, str] | None) -> str | None:
+ """NVIDIA's win_arm64 flash-attn for this env, with its pinned #sha256= fragment, else None."""
+ if env is None or env.get("platform_tag") != "win_arm64":
+ return None
+ if env.get("torch_mm") != NVIDIA_WOA_FLASH_ATTN_TORCH_MM or not _cuda_at_least(
+ env, _WIN_ARM64_MIN_CUDA
+ ):
+ return None
+ python_tag = env.get("python_tag") or ""
+ abi_tag = env.get("abi_tag") or python_tag
+ digest = NVIDIA_WOA_FLASH_ATTN_SHA256.get(abi_tag)
+ if not python_tag or digest is None or not abi_tag.startswith(python_tag):
+ return None
+ filename = (
+ f"flash_attn-{NVIDIA_WOA_FLASH_ATTN_VERSION}+cu13torch{NVIDIA_WOA_FLASH_ATTN_TORCH_MM}"
+ f"-{python_tag}-{abi_tag}-win_arm64.whl"
+ )
+ return f"{NVIDIA_WOA_FLASH_ATTN_RELEASE_URL}/{filename}#sha256={digest}"
+
def unsloth_prebuilt_wheel_url(*, filename_prefix: str, env: dict[str, str] | None) -> str | None:
"""Our own prebuilt wheel for this environment, or None to leave resolution unchanged.
- Every gate here is narrower than it strictly has to be, because the cost of the two answers is not symmetric: returning None costs a source build the user was already facing, and returning a URL for a combination we did not publish costs a 404 and the same source build with a misleading log line in front of it. So it answers only for the exact cells the workflow builds, and the torch minor, CUDA major, ABI, interpreter and platform must all match. Linux x86_64 only: nothing else is built, and Windows, macOS and linux_aarch64 keep whatever behaviour they have today.
+ Every gate here is narrower than it strictly has to be, because the cost of the two answers is not symmetric: returning None costs a source build the user was already facing, and returning a URL for a combination we did not publish costs a 404 and the same source build with a misleading log line in front of it. So it answers only for the exact cells the workflow builds, and the torch minor, CUDA major, ABI, interpreter and platform must all match (see _UNSLOTH_PREBUILT_PLATFORMS); macOS keeps whatever behaviour it has today.
"""
if env is None:
return None
@@ -141,14 +205,27 @@ def unsloth_prebuilt_wheel_url(*, filename_prefix: str, env: dict[str, str] | No
# cu13 only. The workflow builds against the CUDA 13 toolkit and nothing else.
if env.get("cuda_major") != "13":
return None
- if env.get("platform_tag") != "linux_x86_64":
+ platform_spec = _UNSLOTH_PREBUILT_PLATFORMS.get(str(env.get("platform_tag") or ""))
+ if platform_spec is None:
return None
- # Every torch pip wheel from 2.7 on is built with _GLIBCXX_USE_CXX11_ABI=1, so there is no abiFALSE variant to publish. A torch built otherwise -- a source build, an NGC image -- is not something these wheels can serve.
- if env.get("cxx11abi") != "TRUE":
+ cxx11abi, published_pythons = platform_spec
+ if env.get("platform_tag") == "win_arm64" and (
+ filename_prefix not in _UNSLOTH_WIN_ARM64_PREFIXES
+ or env.get("torch_mm") != _WIN_ARM64_TORCH_MM
+ or not _cuda_at_least(env, _WIN_ARM64_MIN_CUDA)
+ ):
+ return None
+ # Every Linux torch pip wheel from 2.7 on is built with _GLIBCXX_USE_CXX11_ABI=1, so there is no abiFALSE variant to publish. A torch built otherwise -- a source build, an NGC image -- is not something these wheels can serve.
+ if env.get("cxx11abi") != cxx11abi:
return None
python_tag = env.get("python_tag")
if not python_tag:
return None
+ if published_pythons is not None:
+ if python_tag not in published_pythons:
+ return None
+ if (env.get("abi_tag") or python_tag) != python_tag:
+ return None
package_version = _UNSLOTH_PREBUILT_VERSIONS.get(filename_prefix)
if package_version is None:
return None
@@ -177,6 +254,9 @@ def direct_wheel_url(
ours = unsloth_prebuilt_wheel_url(filename_prefix = filename_prefix, env = env)
if ours is not None:
return ours
+ # No upstream release has a Windows asset.
+ if is_windows_wheel_env(env):
+ return None
filename = (
f"{filename_prefix}-{package_version}"
@@ -373,6 +453,8 @@ def flash_attn_wheel_url(env: dict[str, str] | None) -> str | None:
ours = unsloth_prebuilt_wheel_url(filename_prefix = "flash_attn", env = env)
if ours is not None:
return ours
+ if is_windows_wheel_env(env):
+ return nvidia_woa_flash_attn_wheel_url(env)
package_version = flash_attn_package_version(prebuilt_wheel_torch_mm(env["torch_mm"]))
if package_version is None:
return None
diff --git a/studio/install_python_stack.py b/studio/install_python_stack.py
index 92eed171c02..b19559339b2 100644
--- a/studio/install_python_stack.py
+++ b/studio/install_python_stack.py
@@ -8386,12 +8386,16 @@ def _ensure_flash_attn() -> None:
return
if NO_TORCH:
return
- if IS_WINDOWS or IS_MACOS:
+ if IS_MACOS:
return
if _flash_attn_importable():
return
- env = probe_torch_wheel_env()
+ # Bounded like the import probe: a wedged Windows driver must not hang setup.
+ env = probe_torch_wheel_env(
+ timeout = _FLASH_ATTN_IMPORT_PROBE_TIMEOUT if IS_WINDOWS else None,
+ include_windows = True,
+ )
# a failed flash-attn probe proves staleness only when torch still imports.
stale = env is not None and _installed_distribution_version("flash-attn") is not None
wheel_url = _build_flash_attn_wheel_url(env) if env else None
@@ -8435,7 +8439,10 @@ def _ensure_flash_attn() -> None:
return
if wheel_url is None:
- _step("warning", "No compatible flash-attn prebuilt wheel found", _cyan)
+ if IS_WINDOWS:
+ _note("no flash-attn prebuilt wheel for this torch build; skipped")
+ else:
+ _step("warning", "No compatible flash-attn prebuilt wheel found", _cyan)
elif wheel_available is None:
_step(
"warning",
@@ -12141,8 +12148,9 @@ def install_python_stack() -> int:
base_total -= 1 # triton step is skipped on macOS
if not IS_MACOS and not NO_TORCH:
base_total += 1 # ROCm torch check (step 2b), non-macOS
+ base_total += 1 # flash-attn, Linux and Windows
if not IS_WINDOWS:
- base_total += 2 # flash-attn + torch final repair (step 13), Linux
+ base_total += 1 # torch final repair (step 13), Linux
else:
base_total += 1 # torch flavor invariant (step 13w), Windows
if IS_MAC_ARM and not NO_TORCH:
@@ -12545,7 +12553,7 @@ def install_python_stack() -> int:
if not IS_WINDOWS and not IS_MACOS:
_triton_kernels_step()
- if not IS_WINDOWS and not IS_MACOS and not NO_TORCH:
+ if not IS_MACOS and not NO_TORCH:
_progress("flash-attn")
_ensure_flash_attn()
@@ -12742,8 +12750,13 @@ def install_python_stack() -> int:
if IS_WINDOWS and not NO_TORCH:
_progress(_torch_step_label("flavor"))
torch_flavor_tag = _expected_torch_flavor_tag()
+ _torch_before_flavor = str(_probe_installed_torch_version() or "")
if not _ensure_expected_torch_flavor(torch_flavor_tag):
return 1
+ _torch_after_flavor = str(_probe_installed_torch_version() or "")
+ if _torch_after_flavor and _torch_after_flavor != _torch_before_flavor:
+ # flash-attn was chosen for the torch the invariant just replaced, as in step 13.
+ _ensure_flash_attn()
# A direct run has no setup.ps1 postlude to swap triton back. After the invariant,
# because the swap keys off the installed +xpu label.
_ensure_xpu_triton()
diff --git a/tests/python/test_flash_attn_install_python_stack.py b/tests/python/test_flash_attn_install_python_stack.py
index 386cad40479..78393d53686 100644
--- a/tests/python/test_flash_attn_install_python_stack.py
+++ b/tests/python/test_flash_attn_install_python_stack.py
@@ -699,26 +699,74 @@ class TestEnsureFlashAttn:
mock_probe.assert_not_called()
mock_install_wheel.assert_not_called()
- def test_windows_skips_install_without_probing(self):
- # flash-attn is Linux-only: on Windows the installer returns before probing the torch env or resolving a
- # wheel (no Windows wheels are published upstream).
+ def test_windows_probes_with_windows_opt_in_and_installs_the_wheel(self):
+ url = "https://example.invalid/flash_attn-2.8.4+cu13torch2.13cxx11abiTRUE-cp313-cp313-win_amd64.whl"
with (
mock.patch.object(ips, "NO_TORCH", False),
mock.patch.object(ips, "IS_WINDOWS", True),
mock.patch.object(ips, "IS_MACOS", False),
- mock.patch.object(ips, "probe_torch_wheel_env") as mock_probe,
+ mock.patch.object(ips, "USE_UV", True),
+ mock.patch.object(ips, "UV_NEEDS_SYSTEM", False),
+ mock.patch.object(
+ ips, "probe_torch_wheel_env", return_value = {"platform_tag": "win_amd64"}
+ ) as mock_probe,
+ mock.patch.object(ips, "_build_flash_attn_wheel_url", return_value = url),
+ mock.patch.object(ips, "url_exists", return_value = True),
+ mock.patch.object(
+ ips,
+ "install_wheel",
+ return_value = [("uv", subprocess.CompletedProcess(["uv"], 0, ""))],
+ ) as mock_install_wheel,
+ mock.patch.object(ips, "_flash_attn_importable", side_effect = [False, True]),
+ ):
+ ips._ensure_flash_attn()
+
+ mock_probe.assert_called_once_with(
+ timeout = ips._FLASH_ATTN_IMPORT_PROBE_TIMEOUT, include_windows = True
+ )
+ assert mock_install_wheel.call_args.args[0] == url
+
+ def test_windows_without_a_wheel_notes_it_quietly(self):
+ notes: list[str] = []
+ steps: list[tuple[str, str]] = []
+ with (
+ mock.patch.object(ips, "NO_TORCH", False),
+ mock.patch.object(ips, "IS_WINDOWS", True),
+ mock.patch.object(ips, "IS_MACOS", False),
+ mock.patch.object(
+ ips, "probe_torch_wheel_env", return_value = {"platform_tag": "win_amd64"}
+ ),
+ mock.patch.object(ips, "_build_flash_attn_wheel_url", return_value = None),
mock.patch.object(ips, "install_wheel") as mock_install_wheel,
- mock.patch("subprocess.run", return_value = self._import_check()),
+ mock.patch.object(ips, "_flash_attn_importable", return_value = False),
+ mock.patch.object(ips, "_note", side_effect = lambda message, *a: notes.append(message)),
+ mock.patch.object(
+ ips, "_step", side_effect = lambda kind, message, *a: steps.append((kind, message))
+ ),
):
ips._ensure_flash_attn()
- mock_probe.assert_not_called()
mock_install_wheel.assert_not_called()
+ assert steps == []
+ assert any("flash-attn" in note for note in notes)
class TestInstallPythonStackFlashAttnIntegration:
- def _run_install(self, *, no_torch: bool, is_macos: bool, is_windows: bool) -> int:
+ def _run_install(
+ self,
+ *,
+ no_torch: bool,
+ is_macos: bool,
+ is_windows: bool,
+ flavor_moves_torch: bool = False,
+ ) -> int:
flash_attn_calls = 0
+ torch_version = ["2.13.0+cpu"]
+
+ def fix_flavor(tag):
+ if flavor_moves_torch:
+ torch_version[0] = "2.13.0+cu130"
+ return True
def fake_run(cmd, **kw):
return subprocess.CompletedProcess(cmd, 0, b"", b"")
@@ -743,6 +791,10 @@ class TestInstallPythonStackFlashAttnIntegration:
mock.patch("pathlib.Path.is_dir", return_value = True),
mock.patch("pathlib.Path.is_file", return_value = True),
mock.patch.dict(os.environ, {"SKIP_STUDIO_BASE": "1"}, clear = False),
+ mock.patch.object(ips, "_ensure_expected_torch_flavor", side_effect = fix_flavor),
+ mock.patch.object(
+ ips, "_probe_installed_torch_version", side_effect = lambda: torch_version[0]
+ ),
):
ips.install_python_stack()
@@ -757,8 +809,8 @@ class TestInstallPythonStackFlashAttnIntegration:
def test_macos_install_skips_flash_attn_step(self):
assert self._run_install(no_torch = False, is_macos = True, is_windows = False) == 0
- def test_windows_install_skips_flash_attn_step(self):
- assert self._run_install(no_torch = False, is_macos = False, is_windows = True) == 0
+ def test_windows_install_calls_flash_attn_step(self):
+ assert self._run_install(no_torch = False, is_macos = False, is_windows = True) == 1
def test_flash_attn_is_rechecked_after_the_linux_torch_repair(self):
"""step 13 can move torch from 2.12+cu130 to 2.9+cu126 under cu13torch2.10 (#13244)."""
@@ -770,3 +822,11 @@ class TestInstallPythonStackFlashAttnIntegration:
)[1]
moved = moved.split("_evict_xformers_built_for_another_torch(", 1)[0]
assert "_ensure_flash_attn()" in moved
+
+ def test_flash_attn_is_rechecked_when_the_windows_flavor_invariant_moves_torch(self):
+ assert (
+ self._run_install(
+ no_torch = False, is_macos = False, is_windows = True, flavor_moves_torch = True
+ )
+ == 2
+ )
diff --git a/tests/python/test_prebuilt_cuda_wheels.py b/tests/python/test_prebuilt_cuda_wheels.py
index 3575c7efb4b..45487252e50 100644
--- a/tests/python/test_prebuilt_cuda_wheels.py
+++ b/tests/python/test_prebuilt_cuda_wheels.py
@@ -157,8 +157,10 @@ class TestOverrideScope:
is None
)
- @pytest.mark.parametrize("platform_tag", ["linux_aarch64", "win_amd64", "macosx_11_0_arm64"])
- def test_only_linux_x86_64(self, platform_tag):
+ # win_amd64, win_arm64 and linux_aarch64 are published too, for fewer cells; the windows and arm
+ # resolver tests own them.
+ @pytest.mark.parametrize("platform_tag", ["macosx_11_0_arm64", "linux_armv7l"])
+ def test_no_wheel_for_an_unbuilt_platform(self, platform_tag):
assert (
wheel_utils.unsloth_prebuilt_wheel_url(
filename_prefix = "mamba_ssm", env = env(platform_tag = platform_tag)
@@ -249,8 +251,8 @@ class TestBackwardsCompatible:
== f"{OUR_BASE}causal_conv1d-1.7.0+cu13torch2.13cxx11abiTRUE-cp313-cp313-linux_x86_64.whl"
)
- def test_a_windows_env_still_reaches_upstream_for_a_non_our_package(self):
- """The override must not become a Windows gate for anything else that uses this path."""
+ def test_a_windows_env_never_reaches_an_upstream_name(self):
+ """No upstream release publishes a Windows asset, so a name built for one could only 404."""
url = wheel_utils.direct_wheel_url(
filename_prefix = "something_else",
package_version = "1.0",
@@ -258,10 +260,7 @@ class TestBackwardsCompatible:
release_base_url = "https://example.invalid/download",
env = env(torch_mm = "2.13", platform_tag = "win_amd64"),
)
- assert url == (
- "https://example.invalid/download/v1.0/"
- "something_else-1.0+cu13torch2.13cxx11abiTRUE-cp313-cp313-win_amd64.whl"
- )
+ assert url is None
def test_no_cuda_still_resolves_to_nothing(self):
assert (
diff --git a/tests/studio/install/test_dependency_pass_skips.py b/tests/studio/install/test_dependency_pass_skips.py
index 24ca5b10a49..a8c91425402 100644
--- a/tests/studio/install/test_dependency_pass_skips.py
+++ b/tests/studio/install/test_dependency_pass_skips.py
@@ -2231,7 +2231,7 @@ def test_installing_a_flash_attn_wheel_counts_as_an_install_action(monkeypatch)
monkeypatch.setattr(stack, "IS_MACOS", False)
monkeypatch.setattr(stack, "_flash_attn_install_disabled", lambda: False)
monkeypatch.setattr(stack, "_flash_attn_importable", lambda: False)
- monkeypatch.setattr(stack, "probe_torch_wheel_env", lambda: {"torch": "2.8.0"})
+ monkeypatch.setattr(stack, "probe_torch_wheel_env", lambda **_k: {"torch": "2.8.0"})
monkeypatch.setattr(stack, "_build_flash_attn_wheel_url", lambda env: "https://x.invalid/w")
monkeypatch.setattr(stack, "url_exists", lambda url, **k: True)
monkeypatch.setattr(
diff --git a/tests/studio/install/test_windows_torch_flavor_invariant.py b/tests/studio/install/test_windows_torch_flavor_invariant.py
index 2a94bcfac14..a9e6a51e707 100644
--- a/tests/studio/install/test_windows_torch_flavor_invariant.py
+++ b/tests/studio/install/test_windows_torch_flavor_invariant.py
@@ -329,7 +329,7 @@ class TestStepTotals:
# 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. Both also
# carry the diffusers main slot (11c), which is spent on every path including opting out.
- assert _base_total(IS_WINDOWS = True) == 17
+ assert _base_total(IS_WINDOWS = True) == 18
assert _base_total(IS_WINDOWS = True, NO_TORCH = True) == 16
@pytest.mark.parametrize(