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
Unsloth Studio installer (AMD/Windows): install PyTorch for RX 5000 to 9000 cards from AMD's multi-arch index (#11846)
Leo Borcherdingf00582ab2981
diff --git a/install.ps1 b/install.ps1index 048760c41e2..96c1d8a58f3 100644--- a/install.ps1+++ b/install.ps1@@ -9993,8 +9993,15 @@ main()"gfx1030" = "gfx103X-all""gfx90a" = "gfx90a"; "gfx908" = "gfx908" # MI200/MI100}- # RDNA 1: AMD multi-arch index (unslothai#11614). Keep in sync with _ROCM_MULTIARCH_* in studio/install_python_stack.py.- $multiArchGfx = @("gfx1010", "gfx1011", "gfx1012")+ # RDNA arches route to AMD's multi-arch index, one pinned tag (unslothai#11815, #11614, #11814).+ # gfx1033 (miscomputes) and CDNA stay on the family map. In sync with _WINDOWS_MULTIARCH_GFX in studio/install_python_stack.py.+ $multiArchGfx = @(+ "gfx1010", "gfx1011", "gfx1012", # RDNA 1+ "gfx1030", "gfx1031", "gfx1032", "gfx1034", "gfx1035", "gfx1036", # RDNA 2, gfx1033 stays per-family+ "gfx1100", "gfx1101", "gfx1102", "gfx1103", # RDNA 3+ "gfx1150", "gfx1151", "gfx1152", "gfx1153", # RDNA 3.5+ "gfx1200", "gfx1201" # RDNA 4+ )$MultiArchIndexBase = if ($env:UNSLOTH_ROCM_WINDOWS_MULTIARCH_MIRROR) { $env:UNSLOTH_ROCM_WINDOWS_MULTIARCH_MIRROR.TrimEnd('/') } else { "https://repo.amd.com/rocm/whl-multi-arch" }$MultiArchTag = "rocm7.14.1"$MultiArchTorchVersion = "2.11.0"@@ -10647,13 +10654,15 @@ main()"gfx1103" = "torchaudio>=2.11.0,<2.12.0"}$archFamily = if ($ROCmGfxArch -and $archFamilyMap.ContainsKey($ROCmGfxArch)) { $archFamilyMap[$ROCmGfxArch] } else { $null }- $ROCmMultiArch = [bool]($ROCmGfxArch -and $multiArchGfx -contains $ROCmGfxArch)+ # A family-layout mirror (and no multi-arch mirror) keeps the family route for arches that have one.+ $_familyMirrorPinned = [bool]($env:UNSLOTH_ROCM_WINDOWS_MIRROR) -and -not [bool]($env:UNSLOTH_ROCM_WINDOWS_MULTIARCH_MIRROR)+ $ROCmMultiArch = [bool]($ROCmGfxArch -and $multiArchGfx -contains $ROCmGfxArch -and -not ($archFamily -and $_familyMirrorPinned))if ($ROCmMultiArch) {$ROCmIndexUrl = "$MultiArchIndexBase/"$ROCmTorchFloor = "torch[device-$ROCmGfxArch]==$MultiArchTorchVersion+$MultiArchTag"- $PinnedRocmVisionSpec = "torchvision==$MultiArchTorchvisionVersion+$MultiArchTag"+ $PinnedRocmVisionSpec = "torchvision[device-$ROCmGfxArch]==$MultiArchTorchvisionVersion+$MultiArchTag"$PinnedRocmAudioSpec = "torchaudio==$MultiArchTorchaudioVersion+$MultiArchTag"- substep "$ROCmGfxArch is RDNA 1 -- AMD multi-arch index, pinned to $MultiArchTorchVersion+$MultiArchTag (torch, torchvision, torchaudio)" "Cyan"+ substep "$ROCmGfxArch -- AMD multi-arch index, pinned to $MultiArchTorchVersion+$MultiArchTag (torch, torchvision, torchaudio)" "Cyan"} elseif ($archFamily) {$ROCmIndexUrl = "$amdIndexBase/$archFamily/"$ROCmTorchFloor = if ($ROCmGfxArch -and $torchFloorMap.ContainsKey($ROCmGfxArch)) { $torchFloorMap[$ROCmGfxArch] } else { $null }diff --git a/studio/backend/utils/hardware/hardware.py b/studio/backend/utils/hardware/hardware.pyindex e6d0f066462..377afebc308 100644--- a/studio/backend/utils/hardware/hardware.py+++ b/studio/backend/utils/hardware/hardware.py@@ -1019,8 +1019,8 @@ _GPU_NAME_GFX_TABLE: "list[tuple[str, str]]" = []-# RDNA 1 gets ROCm wheels on Windows only (multi-arch index, #11755).-_ROCM_SUPPORTED_GFX_WINDOWS_ONLY = frozenset({"gfx1010", "gfx1011", "gfx1012"})+# Only the Windows multi-arch route ships these (#11755, #11815); Linux installers decline them.+_ROCM_SUPPORTED_GFX_WINDOWS_ONLY = frozenset({"gfx1010", "gfx1011", "gfx1012", "gfx1153"})def _rocm_supported_gfx_here() -> "frozenset[str]":diff --git a/studio/install_python_stack.py b/studio/install_python_stack.pyindex 2bbfe4c642a..fa837a39e83 100644--- a/studio/install_python_stack.py+++ b/studio/install_python_stack.py@@ -306,8 +306,9 @@ _WINDOWS_ROCM_TORCH_PKG_SPECS: dict[str, tuple[str, str, str]] = {"gfx1102": _ROCM_TORCH_PKG_SPECS["rocm7.2"],"gfx1103": _ROCM_TORCH_PKG_SPECS["rocm7.2"],}-# RDNA 1 has no repo.amd.com/rocm/whl family; the multi-arch index picks the card by the-# torch[device-gfxNNNN] extra. Exact pin: its next tag (2.12.0) sits on the Windows ceiling. #11614+# Windows RDNA arches install from AMD's multi-arch index (#11815, #11614): one URL, card picked by the+# torch[device-gfxNNNN] extra, pinned to the newest tag inside <2.12.0 so nothing is kept (#11814).+# The family map stays for family-layout mirrors and the stale / mismatch classifiers. Linux unchanged._ROCM_WINDOWS_MULTIARCH_INDEX_BASE = (os.environ.get("UNSLOTH_ROCM_WINDOWS_MULTIARCH_MIRROR")or "https://repo.amd.com/rocm/whl-multi-arch"@@ -316,8 +317,31 @@ _ROCM_MULTIARCH_TAG = "rocm7.14.1"_ROCM_MULTIARCH_TORCH_VERSION = "2.11.0"_ROCM_MULTIARCH_TORCHVISION_VERSION = "0.26.0"_ROCM_MULTIARCH_TORCHAUDIO_VERSION = "2.11.0"-# Only gfx1010 measured; gfx1011/gfx1012 ride along since the Triton and zoo fixes key on gfx101x.-_WINDOWS_MULTIARCH_GFX: "frozenset[str]" = frozenset({"gfx1010", "gfx1011", "gfx1012"})+# gfx1033 excluded: in _ROCM_MISCOMPUTING_GFX, keeps its family route. CDNA stays on the family map.+_WINDOWS_MULTIARCH_GFX: "frozenset[str]" = frozenset(+ {+ "gfx1010",+ "gfx1011",+ "gfx1012", # RDNA 1+ "gfx1030",+ "gfx1031",+ "gfx1032",+ "gfx1034",+ "gfx1035",+ "gfx1036", # RDNA 2+ "gfx1100",+ "gfx1101",+ "gfx1102",+ "gfx1103", # RDNA 3+ "gfx1150",+ "gfx1151",+ "gfx1152",+ "gfx1153", # RDNA 3.5+ "gfx1200",+ "gfx1201", # RDNA 4+ }+)+_ROCM_WINDOWS_FAMILY_INDEX_DEFAULT = "https://repo.amd.com/rocm/whl"def _bare_gfx(gfx_arch: "str | None") -> str:@@ -329,33 +353,79 @@ def _is_windows_multiarch_gfx(gfx_arch: "str | None") -> bool:return _bare_gfx(gfx_arch) in _WINDOWS_MULTIARCH_GFX+def _windows_family_mirror_pinned() -> bool:+ """A host that mirrors the per-family layout and not the multi-arch one keeps the family+ route for arches that have a family; a multi-arch mirror, or no mirror, routes there."""+ if os.environ.get("UNSLOTH_ROCM_WINDOWS_MULTIARCH_MIRROR"):+ return False+ if os.environ.get("UNSLOTH_ROCM_WINDOWS_MIRROR"):+ return True+ return _ROCM_WINDOWS_INDEX_BASE.rstrip("/") != _ROCM_WINDOWS_FAMILY_INDEX_DEFAULT+++def _windows_routes_multiarch(gfx_arch: "str | None") -> bool:+ """Whether the Windows install of `gfx_arch` goes to the multi-arch index: it has a+ device pack there, and no family-only mirror claims an arch that has a family."""+ if not _is_windows_multiarch_gfx(gfx_arch):+ return False+ if _bare_gfx(gfx_arch) in _GFX_TO_AMD_INDEX_ARCH and _windows_family_mirror_pinned():+ return False+ return True++def _multiarch_device_pack_installed(gfx_arch: "str | None") -> bool:- """Whether the venv carries AMD's amd-torch-device-<gfx> kernel pack for this card."""+ """Whether the venv carries AMD's torch and torchvision kernel packs for this card."""try:from importlib import metadata- metadata.distribution(f"amd-torch-device-{_bare_gfx(gfx_arch)}")- return True+ names = {+ (d.metadata["Name"] or "").strip().lower().replace("_", "-")+ for d in metadata.distributions()+ }except Exception:return False+ gfx = _bare_gfx(gfx_arch)+ return {f"amd-torch-device-{gfx}", f"amd-torchvision-device-{gfx}"} <= namesdef _windows_multiarch_torch_pkg_specs(gfx_arch: str) -> tuple[str, str, str]:gfx = _bare_gfx(gfx_arch)return (f"torch[device-{gfx}]=={_ROCM_MULTIARCH_TORCH_VERSION}+{_ROCM_MULTIARCH_TAG}",- f"torchvision=={_ROCM_MULTIARCH_TORCHVISION_VERSION}+{_ROCM_MULTIARCH_TAG}",+ f"torchvision[device-{gfx}]=={_ROCM_MULTIARCH_TORCHVISION_VERSION}+{_ROCM_MULTIARCH_TAG}",f"torchaudio=={_ROCM_MULTIARCH_TORCHAUDIO_VERSION}+{_ROCM_MULTIARCH_TAG}",)-def _windows_rocm_torch_pkg_specs(gfx_arch: "str | None") -> tuple[str, str, str]:- if _is_windows_multiarch_gfx(gfx_arch):+def _index_is_multiarch(index_url: "str | None") -> bool:+ """The multi-arch index, by identity with the configured base or by its leaf. An explicit+ UNSLOTH_TORCH_INDEX_URL pin never gets here: unknown-family pins install verbatim."""+ if not index_url:+ return False++ def _path(u: str) -> str:+ return re.split(r"[?#]", u, maxsplit = 1)[0].rstrip("/")++ _p = _path(index_url)+ return _p == _path(_ROCM_WINDOWS_MULTIARCH_INDEX_BASE) or _p.endswith("/whl-multi-arch")+++def _windows_rocm_torch_pkg_specs_for(+ index_url: "str | None", gfx_arch: "str | None"+) -> tuple[str, str, str]:+ """The trio for the index that was actually chosen: the pinned multi-arch trio on that+ index, the per-arch ABI pin where one exists, bare names otherwise. Derived from the URL+ so the specs can never name a build the index does not serve."""+ if _index_is_multiarch(index_url):return _windows_multiarch_torch_pkg_specs(gfx_arch)return _WINDOWS_ROCM_TORCH_PKG_SPECS.get(_bare_gfx(gfx_arch), ("torch", "torchvision", "torchaudio"))+def _windows_rocm_torch_pkg_specs(gfx_arch: "str | None") -> tuple[str, str, str]:+ return _windows_rocm_torch_pkg_specs_for(_windows_rocm_index_url(gfx_arch), gfx_arch)++# Bound companion versions for ABI compatibility while retaining older per-arch mirror builds._ROCM_ARCH_INDEX_TORCH_PKG_SPEC: tuple[str, str, str] = ("torch>=2.4,<2.12.0",@@ -2059,7 +2129,7 @@ _WIN_GPU_NAME_ARCH_TABLE: "list[tuple[str, str]]" = [r"RX 6550|RX 6500|RX 6450|RX 6400|RX 6300|PRO W6400|PRO W6500|PRO W6300","gfx1034",), # Navi 24- # RDNA 1, multi-arch index. Names from LLVM + libdrm amdgpu.ids.+ # RDNA 1 (Navi 10 / 14), routed via _WINDOWS_MULTIARCH_GFX; names from LLVM AMDGPU + amdgpu.ids.(r"Radeon Pro V520|Radeon Pro 5600M", "gfx1011"),(r"RX 5700|RX 5600|Radeon Pro 5600 XT|Radeon Pro 5700|Radeon Pro W5700", "gfx1010"),(r"RX 5500|RX 5300|Radeon Pro W5500|Radeon Pro W5300", "gfx1012"),@@ -2364,9 +2434,17 @@ def _rocm_miscomputing_host() -> bool:def _windows_rocm_index_url(gfx_arch: str | None) -> str | None:- """Return the AMD pip index URL for the given GPU arch, or None if unsupported."""- if _is_windows_multiarch_gfx(gfx_arch):- return _ROCM_WINDOWS_MULTIARCH_INDEX_BASE+ """Return the AMD pip index URL for the given GPU arch, or None if unsupported.++ Every RDNA arch resolves to AMD's multi-arch index (one URL for every device on it; the+ device is selected by the `torch[device-gfxNNNN]` extra, not by the path), unless a+ family-only mirror is pinned and the arch has a family; CDNA and gfx1033 go to their+ repo.amd.com family."""+ if _windows_routes_multiarch(gfx_arch):+ # Slash on the path, not after a ?token= query (as _index_url_join splits).+ _base = _ROCM_WINDOWS_MULTIARCH_INDEX_BASE+ _cut = min([_base.index(_c) for _c in "?#" if _c in _base] or [len(_base)])+ return f"{_base[:_cut].rstrip('/')}/{_base[_cut:]}"arch_family = _GFX_TO_AMD_INDEX_ARCH.get(_bare_gfx(gfx_arch))if arch_family is None:return None@@ -5772,7 +5850,7 @@ def _ensure_rocm_torch() -> None:if (_torch_already_rocmand _win_rocm_pin is None- and _is_windows_multiarch_gfx(gfx_arch)+ and _windows_routes_multiarch(gfx_arch)and not _multiarch_device_pack_installed(gfx_arch)):_safe_print(@@ -5780,7 +5858,12 @@ def _ensure_rocm_torch() -> None:"AMD's multi-arch index")_torch_already_rocm = False- if _torch_already_rocm and _win_rocm_pin is None:+ # A multi-arch route is judged by its packs alone: a migrated venv keeps the orphaned family runtime.+ if (+ _torch_already_rocm+ and _win_rocm_pin is None+ and not _windows_routes_multiarch(gfx_arch)+ ):_want = (_GFX_TO_AMD_INDEX_ARCH.get(gfx_arch or "") or "").lower()_have = _installed_rocm_wheel_family()if _want and _have and _have != _want:@@ -5798,14 +5881,16 @@ def _ensure_rocm_torch() -> None:f" {gfx_arch or 'pinned ROCm index'} (Windows) -- installing torch from "f"{_strip_index_url_credentials(index_url)}")- _torch_pkg, _vision_pkg, _audio_pkg = _windows_rocm_torch_pkg_specs(gfx_arch)+ _torch_pkg, _vision_pkg, _audio_pkg = _windows_rocm_torch_pkg_specs_for(+ index_url, gfx_arch+ )_rocm_trio = [_torch_pkg, _vision_pkg, _audio_pkg]if _is_win_arm64_interpreter():_rocm_trio = [_torch_pkg, _vision_pkg]- if _is_windows_multiarch_gfx(gfx_arch):- # Not _bare_gfx(): a local of that name below shadows it (UnboundLocalError).+ if _index_is_multiarch(index_url):+ # Not _bare_gfx(): a later local of that name shadows it (UnboundLocalError)._safe_print(- f" {(gfx_arch or '').split(':')[0].lower()} is RDNA 1: AMD's multi-arch index, pinned to "+ f" {(gfx_arch or '').split(':')[0].lower()}: AMD's multi-arch index, pinned to "f"{_ROCM_MULTIARCH_TORCH_VERSION}+{_ROCM_MULTIARCH_TAG} (torch, torchvision, torchaudio)")# Nonfatal: a transient AMD-index failure must not abort the install.diff --git a/studio/setup.ps1 b/studio/setup.ps1index 7c5dda269b3..fb6af63460d 100644--- a/studio/setup.ps1+++ b/studio/setup.ps1@@ -4188,8 +4188,15 @@ $archFamilyMap = @{"gfx1030" = "gfx103X-all""gfx90a" = "gfx90a"; "gfx908" = "gfx908" # MI200/MI100}-# RDNA 1: AMD multi-arch index (unslothai#11614). Keep in sync with _ROCM_MULTIARCH_* in studio/install_python_stack.py.-$multiArchGfx = @("gfx1010", "gfx1011", "gfx1012")+# RDNA arches route to AMD's multi-arch index, one pinned tag (unslothai#11815, #11614, #11814).+# gfx1033 (miscomputes) and CDNA stay on the family map. In sync with _WINDOWS_MULTIARCH_GFX in studio/install_python_stack.py.+$multiArchGfx = @(+ "gfx1010", "gfx1011", "gfx1012", # RDNA 1+ "gfx1030", "gfx1031", "gfx1032", "gfx1034", "gfx1035", "gfx1036", # RDNA 2, gfx1033 stays per-family+ "gfx1100", "gfx1101", "gfx1102", "gfx1103", # RDNA 3+ "gfx1150", "gfx1151", "gfx1152", "gfx1153", # RDNA 3.5+ "gfx1200", "gfx1201" # RDNA 4+)$MultiArchIndexBase = if ($env:UNSLOTH_ROCM_WINDOWS_MULTIARCH_MIRROR) { $env:UNSLOTH_ROCM_WINDOWS_MULTIARCH_MIRROR.TrimEnd('/') } else { "https://repo.amd.com/rocm/whl-multi-arch" }$MultiArchTag = "rocm7.14.1"$MultiArchTorchVersion = "2.11.0"@@ -4715,7 +4722,7 @@ if (-not $HasNvidiaSmi) {# usable Arc card. test_rocm_arch_table_parity.py keeps it in sync with $archFamilyMap below.$_rocmWheelArches = @("gfx1201", "gfx1200", # RDNA 4- "gfx1151", "gfx1150", "gfx1152", # RDNA 3.5 (Strix Halo/Point, Krackan Point)+ "gfx1151", "gfx1150", "gfx1152", "gfx1153", # RDNA 3.5 (Strix Halo/Point, Krackan Point)"gfx1103", "gfx1102", "gfx1101", "gfx1100", # RDNA 3"gfx1036", "gfx1035", "gfx1034", "gfx1033", "gfx1032", "gfx1031", "gfx1030", # RDNA 2 (RX 6000)"gfx1012", "gfx1011", "gfx1010", # RDNA 1 (RX 5000): AMD's multi-arch index (unslothai#11755)@@ -8466,18 +8473,20 @@ if (-not $TorchIndexPinned -and ($HasROCm -or $ROCmGfxArch) -and $CuTag -eq "cpu$ROCmTorchSpec = if ($ROCmGfxArch -and $torchFloorMap.ContainsKey($ROCmGfxArch)) { $torchFloorMap[$ROCmGfxArch] } else { "torch" }$ROCmVisionSpec = if ($ROCmGfxArch -and $torchvisionFloorMap.ContainsKey($ROCmGfxArch)) { $torchvisionFloorMap[$ROCmGfxArch] } else { "torchvision" }$ROCmAudioSpec = if ($ROCmGfxArch -and $torchaudioFloorMap.ContainsKey($ROCmGfxArch)) { $torchaudioFloorMap[$ROCmGfxArch] } else { "torchaudio" }- $script:ROCmMultiArch = [bool]($ROCmGfxArch -and $multiArchGfx -contains $ROCmGfxArch)+ # A family-layout mirror (and no multi-arch mirror) keeps the family route for arches that have one.+ $_familyMirrorPinned = [bool]($env:UNSLOTH_ROCM_WINDOWS_MIRROR) -and -not [bool]($env:UNSLOTH_ROCM_WINDOWS_MULTIARCH_MIRROR)+ $script:ROCmMultiArch = [bool]($ROCmGfxArch -and $multiArchGfx -contains $ROCmGfxArch -and -not ($archFamily -and $_familyMirrorPinned))if ($script:ROCmMultiArch) {$ROCmIndexUrl = "$MultiArchIndexBase/"$ROCmTorchSpec = "torch[device-$ROCmGfxArch]==$MultiArchTorchVersion+$MultiArchTag"- $ROCmVisionSpec = "torchvision==$MultiArchTorchvisionVersion+$MultiArchTag"+ $ROCmVisionSpec = "torchvision[device-$ROCmGfxArch]==$MultiArchTorchvisionVersion+$MultiArchTag"$ROCmAudioSpec = "torchaudio==$MultiArchTorchaudioVersion+$MultiArchTag"- substep "$ROCmGfxArch is RDNA 1 -- AMD multi-arch index, pinned to $MultiArchTorchVersion+$MultiArchTag (torch, torchvision, torchaudio)" "Cyan"+ substep "$ROCmGfxArch -- AMD multi-arch index, pinned to $MultiArchTorchVersion+$MultiArchTag (torch, torchvision, torchaudio)" "Cyan"} elseif ($archFamily) {$ROCmIndexUrl = "$amdIndexBase/$archFamily/"} elseif ($ROCmGfxArch) {substep "[WARN] AMD GPU ($ROCmGfxArch) not in supported arch list -- falling back to CPU-only PyTorch" "Yellow"- substep " Supported: gfx1200/1201 (RDNA 4), gfx1150/1151/1152 (RDNA 3.5), gfx1100-1103 (RDNA 3), gfx1030-1036 (RDNA 2), gfx1010-1012 (RDNA 1, AMD multi-arch index), gfx90a, gfx908" "Yellow"+ substep " Supported: gfx1200/1201 (RDNA 4), gfx1150/1151/1152 (RDNA 3.5), gfx1100-1103 (RDNA 3), gfx1030-1036 (RDNA 2), gfx1010-1012 (RDNA 1), gfx90a, gfx908 (RDNA parts: AMD multi-arch index)" "Yellow"} else {substep "[WARN] AMD GPU detected (HIP SDK present) but GPU arch could not be read -- falling back to CPU-only PyTorch" "Yellow"substep " Arch detection requires hipinfo to report gcnArchName. Re-install the HIP SDK if this is unexpected." "Yellow"diff --git a/tests/studio/install/test_cuda_repair.py b/tests/studio/install/test_cuda_repair.pyindex 661e8515531..e37734593f0 100644--- a/tests/studio/install/test_cuda_repair.py+++ b/tests/studio/install/test_cuda_repair.py@@ -2331,7 +2331,7 @@ class TestTheDelegatedRocmRepairKeepsTheArm64Exception:def test_the_windows_rocm_install_drops_torchaudio_on_arm64(self):source = inspect.getsource(stack_mod._ensure_rocm_torch)- block = source[source.index("_windows_rocm_torch_pkg_specs(") :][:1200]+ block = source[source.index("_windows_rocm_torch_pkg_specs_for(") :][:1200]# The interpreter's arch, not the machine's: an emulated x64 venv installs win_amd64.assert ("_is_win_arm64_interpreter()" in block@@ -2343,7 +2343,7 @@ class TestTheDelegatedRocmRepairKeepsTheArm64Exception:def test_x64_windows_still_asks_for_all_three(self):source = inspect.getsource(stack_mod._ensure_rocm_torch)- block = source[source.index("_windows_rocm_torch_pkg_specs(") :][:1200]+ block = source[source.index("_windows_rocm_torch_pkg_specs_for(") :][:1200]assert "_rocm_trio = [_torch_pkg, _vision_pkg, _audio_pkg]" in blockdiff --git a/tests/studio/install/test_rdna1_multiarch_windows_route_11614.py b/tests/studio/install/test_rdna1_multiarch_windows_route_11614.pyindex 7a49a1df628..e4608f38f05 100644--- a/tests/studio/install/test_rdna1_multiarch_windows_route_11614.py+++ b/tests/studio/install/test_rdna1_multiarch_windows_route_11614.py@@ -47,34 +47,46 @@ class TestPackageSpecs:assert (torch_spec == f"torch[device-{bare}]=={stack_mod._ROCM_MULTIARCH_TORCH_VERSION}+{tag}")- assert vision_spec == f"torchvision=={stack_mod._ROCM_MULTIARCH_TORCHVISION_VERSION}+{tag}"+ assert (+ vision_spec+ == f"torchvision[device-{bare}]=={stack_mod._ROCM_MULTIARCH_TORCHVISION_VERSION}+{tag}"+ )assert audio_spec == f"torchaudio=={stack_mod._ROCM_MULTIARCH_TORCHAUDIO_VERSION}+{tag}"def test_the_pin_is_a_release_tag_not_a_nightly(self):- """A nightly tag (rocmX.Y.ZaYYYYMMDD) moves under users; the stable index is dated- by release only."""+ """A nightly tag (rocmX.Y.ZaYYYYMMDD) moves under users."""assert re.fullmatch(r"rocm\d+\.\d+\.\d+", stack_mod._ROCM_MULTIARCH_TAG)def test_the_pin_sits_inside_the_windows_torch_window(self):- """install.ps1 applies torch<2.12.0 everywhere else on Windows; the multi-arch index- also serves 2.12.0, so the pin must stay the newest release under that ceiling."""+ """install.ps1 applies torch<2.12.0 everywhere else on Windows."""major, minor, _ = (int(x) for x in stack_mod._ROCM_MULTIARCH_TORCH_VERSION.split("."))assert (major, minor) < (2, 12)assert (stack_mod._ROCM_MULTIARCH_TORCHAUDIO_VERSION == stack_mod._ROCM_MULTIARCH_TORCH_VERSION)- def test_other_arches_keep_their_specs(self):+ def test_other_arches_keep_their_specs(self, monkeypatch):+ """Since #11815 every RDNA arch takes the multi-arch pin by default."""+ monkeypatch.delenv("UNSLOTH_ROCM_WINDOWS_MIRROR", raising = False)+ monkeypatch.delenv("UNSLOTH_ROCM_WINDOWS_MULTIARCH_MIRROR", raising = False)+ monkeypatch.setattr(stack_mod, "_ROCM_WINDOWS_INDEX_BASE", "https://repo.amd.com/rocm/whl")+ assert stack_mod._windows_rocm_torch_pkg_specs(+ "gfx1201"+ ) == stack_mod._windows_multiarch_torch_pkg_specs("gfx1201")+ assert stack_mod._windows_rocm_torch_pkg_specs(+ "gfx1034"+ ) == stack_mod._windows_multiarch_torch_pkg_specs("gfx1034")+ monkeypatch.setenv("UNSLOTH_ROCM_WINDOWS_MIRROR", "https://mirror.example/whl")assert (stack_mod._windows_rocm_torch_pkg_specs("gfx1201")== stack_mod._WINDOWS_ROCM_TORCH_PKG_SPECS["gfx1201"])- assert stack_mod._windows_rocm_torch_pkg_specs("gfx1034") == (- stack_mod._WINDOWS_ROCM_TORCH_PKG_SPECS.get(- "gfx1034", ("torch", "torchvision", "torchaudio")- )+ assert (+ stack_mod._windows_rocm_torch_pkg_specs("gfx1034")+ == stack_mod._WINDOWS_ROCM_TORCH_PKG_SPECS["gfx1034"])- assert stack_mod._windows_rocm_torch_pkg_specs("gfx9999") == (+ monkeypatch.delenv("UNSLOTH_ROCM_WINDOWS_MIRROR", raising = False)+ assert stack_mod._windows_rocm_torch_pkg_specs("gfx908") == ("torch","torchvision","torchaudio",@@ -91,7 +103,8 @@ class TestIndexResolution:def test_rdna1_resolves_to_the_multiarch_index(self, arch, monkeypatch):monkeypatch.delenv("UNSLOTH_ROCM_WINDOWS_MULTIARCH_MIRROR", raising = False)assert (- stack_mod._windows_rocm_index_url(arch) == stack_mod._ROCM_WINDOWS_MULTIARCH_INDEX_BASE+ stack_mod._windows_rocm_index_url(arch)+ == stack_mod._ROCM_WINDOWS_MULTIARCH_INDEX_BASE + "/")def test_the_default_base_is_amds_stable_multiarch_index(self):@@ -100,12 +113,24 @@ class TestIndexResolution:== "https://repo.amd.com/rocm/whl-multi-arch")- def test_rdna2_still_resolves_to_its_family(self, monkeypatch):+ def test_rdna2_resolves_to_its_family_only_under_a_family_mirror(self, monkeypatch):+ """#11815 moved RDNA 2 onto the multi-arch index."""monkeypatch.delenv("UNSLOTH_ROCM_WINDOWS_MIRROR", raising = False)+ monkeypatch.delenv("UNSLOTH_ROCM_WINDOWS_MULTIARCH_MIRROR", raising = False)monkeypatch.setattr(stack_mod, "_ROCM_WINDOWS_INDEX_BASE", "https://repo.amd.com/rocm/whl")assert (stack_mod._windows_rocm_index_url("gfx1034")- == "https://repo.amd.com/rocm/whl/gfx103X-all/"+ == stack_mod._ROCM_WINDOWS_MULTIARCH_INDEX_BASE + "/"+ )+ monkeypatch.setenv("UNSLOTH_ROCM_WINDOWS_MIRROR", "https://mirror.example/whl")+ monkeypatch.setattr(stack_mod, "_ROCM_WINDOWS_INDEX_BASE", "https://mirror.example/whl")+ assert (+ stack_mod._windows_rocm_index_url("gfx1034")+ == "https://mirror.example/whl/gfx103X-all/"+ )+ assert (+ stack_mod._windows_rocm_index_url("gfx1010")+ == stack_mod._ROCM_WINDOWS_MULTIARCH_INDEX_BASE + "/")def test_polaris_still_resolves_to_nothing(self):@@ -282,18 +307,22 @@ class TestTheWindowsRepairSiteRunsForRdna1:if installs:assert "torch[device-gfx1010]" in " ".join(str(a) for a in pip_try.call_args.args)- def test_the_device_pack_check_reads_the_distribution(self, monkeypatch):+ def test_the_device_pack_check_needs_torch_and_torchvision_packs(self, monkeypatch):from importlib import metadata- def absent(name):- raise metadata.PackageNotFoundError(name)+ def dists(*names):+ return lambda: [type("D", (), {"metadata": {"Name": n}})() for n in names]- monkeypatch.setattr(metadata, "distribution", absent)+ monkeypatch.setattr(metadata, "distributions", dists("torch"))assert stack_mod._multiarch_device_pack_installed("GFX1010:xnack-") is False- seen = []- monkeypatch.setattr(metadata, "distribution", lambda name: seen.append(name) or object())+ monkeypatch.setattr(metadata, "distributions", dists("amd_torch_device_gfx1010"))+ assert stack_mod._multiarch_device_pack_installed("GFX1010:xnack-") is False+ monkeypatch.setattr(+ metadata,+ "distributions",+ dists("amd-torch-device-gfx1010", "amd-torchvision-device-gfx1010"),+ )assert stack_mod._multiarch_device_pack_installed("GFX1010:xnack-") is True- assert seen == ["amd-torch-device-gfx1010"]class TestRdna1CountsAsCoveredEverywhereItIsRouted:diff --git a/tests/studio/install/test_rocm_support.py b/tests/studio/install/test_rocm_support.pyindex e240a24151a..323bdfff0c9 100644--- a/tests/studio/install/test_rocm_support.py+++ b/tests/studio/install/test_rocm_support.py@@ -998,7 +998,11 @@ class TestEnsureRocmTorch:assert "rocm7.1" in str(mock_pip.call_args_list[0])@staticmethod- def _windows_repair(installed_family, gfx = "gfx1200"):+ def _windows_repair(+ installed_family,+ gfx = "gfx1200",+ dists = (),+ ):"""Run the Windows ROCm repair with an already-ROCm torch on disk. Returns thepip_install_try mock so callers can assert on the reinstall."""probe = MagicMock(returncode = 0, stdout = _MARK + "2.10.0+rocm7.1|7.1|\n")@@ -1021,6 +1025,7 @@ class TestEnsureRocmTorch:patch.object(stack_mod, "_install_bnb_windows_rocm", return_value = True),patch.object(stack_mod, "pip_install_try", pip_try),patch("subprocess.run", return_value = probe),+ patch("importlib.metadata.distributions", return_value = list(dists)),):_ensure_rocm_torch()return pip_try@@ -1031,16 +1036,32 @@ class TestEnsureRocmTorch:# a ROCm build and stopped. setup.ps1 force-reinstalls, so this is `studio update`.pip_try = self._windows_repair("gfx103x-all")assert pip_try.call_count == 1- assert "gfx120X-all" in str(pip_try.call_args)+ assert "torch[device-gfx1200]" in str(pip_try.call_args)+ assert "whl-multi-arch" in str(pip_try.call_args)def test_matching_wheel_family_is_left_alone(self):# Negative control: the right family must not be re-downloaded on every update.- assert self._windows_repair("gfx120x-all").call_count == 0+ assert self._windows_repair("gfx103x-all", gfx = "gfx1033").call_count == 0def test_unknown_wheel_family_is_left_alone(self):# Older wheels predate the split runtime, so the family is unreadable and# guessing would force a multi-GB reinstall on every update.- assert self._windows_repair(None).call_count == 0+ assert self._windows_repair(None, gfx = "gfx1033").call_count == 0++ def test_swapped_card_on_a_multiarch_install_gets_its_device_pack(self):+ dists = self._dists("amd-torch-device-gfx1151", "amd_torchvision_device_gfx1151")+ pip_try = self._windows_repair(None, gfx = "gfx1200", dists = dists)+ assert pip_try.call_count == 1+ assert "torch[device-gfx1200]" in str(pip_try.call_args)+ assert "torchvision[device-gfx1200]" in str(pip_try.call_args)++ def test_multiarch_install_with_this_cards_packs_is_left_alone(self):+ dists = self._dists("amd-torch-device-gfx1200", "amd-torchvision-device-gfx1200")+ assert self._windows_repair(None, gfx = "gfx1200", dists = dists).call_count == 0++ def test_multiarch_install_without_the_torchvision_pack_is_repaired(self):+ dists = self._dists("amd-torch-device-gfx1200")+ assert self._windows_repair(None, gfx = "gfx1200", dists = dists).call_count == 1@staticmethoddef _dists(*names):@@ -1087,14 +1108,20 @@ class TestEnsureRocmTorch:assert stack_mod._installed_rocm_wheel_family() is Nonedef test_switched_host_does_not_reinstall_on_every_update(self):- # End to end: after the gfx103X -> gfx120X switch the orphan is still installed- # and the next `studio update` must do nothing.- reqs = ['rocm-sdk-libraries-gfx120X-all==7.13.0; extra == "libraries"']- dists = self._dists("rocm_sdk_libraries_gfx103X-all", "rocm_sdk_libraries_gfx120X-all")- with patch("importlib.metadata.requires", return_value = reqs):- with patch("importlib.metadata.distributions", return_value = dists):- family = stack_mod._installed_rocm_wheel_family()- assert self._windows_repair(family).call_count == 0+ # A venv migrated to the multi-arch packs keeps its orphaned family runtimes; the next+ # `studio update` must do nothing rather than chase the stale family.+ dists = self._dists(+ "rocm_sdk_libraries_gfx103X-all",+ "rocm_sdk_libraries_gfx120X-all",+ "amd-torch-device-gfx1200",+ "amd-torchvision-device-gfx1200",+ )+ assert self._windows_repair("gfx103x-all", dists = dists).call_count == 0++ def test_a_per_family_install_on_a_multiarch_arch_migrates_once(self):+ pip_try = self._windows_repair("gfx120x-all")+ assert pip_try.call_count == 1+ assert "torchvision[device-gfx1200]" in str(pip_try.call_args)def test_torch_already_has_hip_skips(self):"""If torch already has HIP, should skip ROCm reinstall."""@@ -4475,30 +4502,36 @@ class TestIsRdnaExpansion:class TestWindowsRocmIndexUrl:"""Verify GPU arch → AMD pip index URL mapping."""- def test_gfx1200_maps_to_gfx120x_all(self):- url = stack_mod._windows_rocm_index_url("gfx1200")- assert url is not None- assert "gfx120X-all" in url-- def test_gfx1201_maps_to_gfx120x_all(self):- url = stack_mod._windows_rocm_index_url("gfx1201")- assert url is not None- assert "gfx120X-all" in url+ @pytest.fixture(autouse = True)+ def _no_mirror(self, monkeypatch):+ monkeypatch.delenv("UNSLOTH_ROCM_WINDOWS_MIRROR", raising = False)+ monkeypatch.delenv("UNSLOTH_ROCM_WINDOWS_MULTIARCH_MIRROR", raising = False)+ monkeypatch.setattr(stack_mod, "_ROCM_WINDOWS_INDEX_BASE", "https://repo.amd.com/rocm/whl")- def test_gfx1151_maps_to_gfx1151(self):- url = stack_mod._windows_rocm_index_url("gfx1151")- assert url is not None- assert "gfx1151" in url+ @pytest.mark.parametrize("gfx", ["gfx1200", "gfx1201", "gfx1151", "gfx1150", "gfx1100"])+ def test_rdna_maps_to_the_multiarch_index(self, gfx):+ url = stack_mod._windows_rocm_index_url(gfx)+ assert url == "https://repo.amd.com/rocm/whl-multi-arch/"- def test_gfx1150_maps_to_gfx1150(self):- url = stack_mod._windows_rocm_index_url("gfx1150")- assert url is not None- assert "gfx1150" in url+ @pytest.mark.parametrize(+ "gfx,leaf",+ [+ ("gfx1200", "gfx120X-all"),+ ("gfx1201", "gfx120X-all"),+ ("gfx1151", "gfx1151"),+ ("gfx1150", "gfx1150"),+ ("gfx1100", "gfx110X-all"),+ ],+ )+ def test_family_mirror_keeps_the_family_leaf(self, gfx, leaf, monkeypatch):+ monkeypatch.setenv("UNSLOTH_ROCM_WINDOWS_MIRROR", "https://mirror.example/whl")+ monkeypatch.setattr(stack_mod, "_ROCM_WINDOWS_INDEX_BASE", "https://mirror.example/whl")+ assert stack_mod._windows_rocm_index_url(gfx) == f"https://mirror.example/whl/{leaf}/"- def test_gfx1100_maps_to_gfx110x_all(self):- url = stack_mod._windows_rocm_index_url("gfx1100")- assert url is not None- assert "gfx110X-all" in url+ def test_cdna_keeps_its_family(self):+ assert (+ stack_mod._windows_rocm_index_url("gfx90a") == "https://repo.amd.com/rocm/whl/gfx90a/"+ )def test_unknown_arch_returns_none(self):assert stack_mod._windows_rocm_index_url("gfx9999") is Nonediff --git a/tests/studio/install/test_selection_logic.py b/tests/studio/install/test_selection_logic.pyindex 93a9dde81cb..30e09461044 100644--- a/tests/studio/install/test_selection_logic.py+++ b/tests/studio/install/test_selection_logic.py@@ -3785,7 +3785,7 @@ class TestPublishedRocmBundleCoverage:# Read the table from source; importing the installer pulls a heavy dependency chain this suite does not need.stack = (PACKAGE_ROOT / "studio" / "install_python_stack.py").read_text(encoding = "utf-8")- body = re.search(r"_GFX_TO_AMD_INDEX_ARCH.*?=\s*\{(.*?)\n\}", stack, re.S)+ body = re.search(r"^_GFX_TO_AMD_INDEX_ARCH[^=\n]*=\s*\{(.*?)\n\}", stack, re.S | re.M)assert body, "_GFX_TO_AMD_INDEX_ARCH not found in install_python_stack.py"routed = set(re.findall(r'"(gfx[0-9a-z]+)":', body.group(1)))assert routed, "parsed no arches out of _GFX_TO_AMD_INDEX_ARCH"diff --git a/tests/studio/install/test_unsupported_arch_routing_guards_8529.py b/tests/studio/install/test_unsupported_arch_routing_guards_8529.pyindex dc0b28e26f3..e240e15a3c9 100644--- a/tests/studio/install/test_unsupported_arch_routing_guards_8529.py+++ b/tests/studio/install/test_unsupported_arch_routing_guards_8529.py@@ -143,7 +143,14 @@ class TestPythonIndexResolversAreAskedDirectly:with patch.object(stack_mod, "IS_WINDOWS", is_windows):url = stack_mod._amd_arch_index_url(arch)assert url is not None, f"{arch} lost its wheel index"- assert url.endswith(f"/{family}/"), f"{arch} routed to {url!r}, expected the {family} index"+ if is_windows and arch in stack_mod._WINDOWS_MULTIARCH_GFX:+ assert url.endswith(+ "/whl-multi-arch/"+ ), f"{arch} routed to {url!r}, expected the multi-arch index"+ else:+ assert url.endswith(+ f"/{family}/"+ ), f"{arch} routed to {url!r}, expected the {family} index"@pytest.mark.parametrize("arch", _UNSUPPORTED_ARCHES)def test_no_unsupported_arch_is_a_key_of_the_family_map(self, arch):@@ -193,7 +200,7 @@ class TestRdna1RoutesOnWindowsOnly:stack_mod, "_ROCM_WINDOWS_MULTIARCH_INDEX_BASE", "https://mirror.example/whl-multi-arch")assert (- stack_mod._windows_rocm_index_url("gfx1010") == "https://mirror.example/whl-multi-arch"+ stack_mod._windows_rocm_index_url("gfx1010") == "https://mirror.example/whl-multi-arch/")diff --git a/tests/studio/install/test_windows_multiarch_all_11815.py b/tests/studio/install/test_windows_multiarch_all_11815.pynew file mode 100644index 00000000000..fee64e0e2ec--- /dev/null+++ b/tests/studio/install/test_windows_multiarch_all_11815.py@@ -0,0 +1,219 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0+"""unslothai/unsloth#11815: every Windows RDNA arch installs from the multi-arch index."""++import ast+import importlib.util+import re+import sys+from pathlib import Path++import pytest++PACKAGE_ROOT = Path(__file__).resolve().parents[3]+_STACK_PY = PACKAGE_ROOT / "studio" / "install_python_stack.py"+_INSTALL_PS1 = PACKAGE_ROOT / "install.ps1"+_SETUP_PS1 = PACKAGE_ROOT / "studio" / "setup.ps1"+_HARDWARE_PY = PACKAGE_ROOT / "studio" / "backend" / "utils" / "hardware" / "hardware.py"+++def _load_stack_module():+ spec = importlib.util.spec_from_file_location(+ "studio_install_python_stack_multiarch_all", _STACK_PY+ )+ assert spec is not None and spec.loader is not None+ mod = importlib.util.module_from_spec(spec)+ sys.modules[spec.name] = mod+ spec.loader.exec_module(mod)+ return mod+++stack_mod = _load_stack_module()++_EXPECTED = {+ "gfx1010",+ "gfx1011",+ "gfx1012",+ "gfx1030",+ "gfx1031",+ "gfx1032",+ "gfx1034",+ "gfx1035",+ "gfx1036",+ "gfx1100",+ "gfx1101",+ "gfx1102",+ "gfx1103",+ "gfx1150",+ "gfx1151",+ "gfx1152",+ "gfx1153",+ "gfx1200",+ "gfx1201",+}+_MULTIARCH = "https://repo.amd.com/rocm/whl-multi-arch/"+++def stock(monkeypatch):+ monkeypatch.delenv("UNSLOTH_ROCM_WINDOWS_MIRROR", raising = False)+ monkeypatch.delenv("UNSLOTH_ROCM_WINDOWS_MULTIARCH_MIRROR", raising = False)+ monkeypatch.setattr(stack_mod, "_ROCM_WINDOWS_INDEX_BASE", "https://repo.amd.com/rocm/whl")+ monkeypatch.setattr(+ stack_mod, "_ROCM_WINDOWS_MULTIARCH_INDEX_BASE", "https://repo.amd.com/rocm/whl-multi-arch"+ )+ return monkeypatch+++class TestTheArchSet:+ def test_is_exactly_rdna_one_to_four_minus_van_gogh(self):+ assert set(stack_mod._WINDOWS_MULTIARCH_GFX) == _EXPECTED++ def test_van_gogh_and_cdna_are_out(self):+ for gfx in ("gfx1033", "gfx908", "gfx90a"):+ assert gfx not in stack_mod._WINDOWS_MULTIARCH_GFX+ assert "gfx1033" in stack_mod._ROCM_MISCOMPUTING_GFX+++class TestDefaultRoute:+ @pytest.mark.parametrize("gfx", sorted(_EXPECTED))+ def test_resolves_to_the_multiarch_index_with_the_pinned_trio(self, gfx, stock):+ assert stack_mod._windows_rocm_index_url(gfx) == _MULTIARCH+ assert stack_mod._windows_rocm_index_url(gfx.upper() + ":xnack-") == _MULTIARCH+ tag = stack_mod._ROCM_MULTIARCH_TAG+ assert stack_mod._windows_rocm_torch_pkg_specs(gfx) == (+ f"torch[device-{gfx}]=={stack_mod._ROCM_MULTIARCH_TORCH_VERSION}+{tag}",+ f"torchvision[device-{gfx}]=={stack_mod._ROCM_MULTIARCH_TORCHVISION_VERSION}+{tag}",+ f"torchaudio=={stack_mod._ROCM_MULTIARCH_TORCHAUDIO_VERSION}+{tag}",+ )++ def test_van_gogh_and_cdna_keep_their_family(self, stock):+ assert (+ stack_mod._windows_rocm_index_url("gfx1033")+ == "https://repo.amd.com/rocm/whl/gfx103X-all/"+ )+ assert (+ stack_mod._windows_rocm_index_url("gfx90a") == "https://repo.amd.com/rocm/whl/gfx90a/"+ )+ assert (+ stack_mod._windows_rocm_torch_pkg_specs("gfx1033")+ == stack_mod._WINDOWS_ROCM_TORCH_PKG_SPECS["gfx1033"]+ )++ def test_unknown_stays_none(self, stock):+ assert stack_mod._windows_rocm_index_url("gfx9999") is None+ assert stack_mod._windows_rocm_index_url(None) is None+++class TestMirrors:+ def test_a_family_mirror_keeps_the_family_route_where_one_exists(self, stock):+ stock.setenv("UNSLOTH_ROCM_WINDOWS_MIRROR", "https://mirror.example/whl")+ stock.setattr(stack_mod, "_ROCM_WINDOWS_INDEX_BASE", "https://mirror.example/whl")+ assert (+ stack_mod._windows_rocm_index_url("gfx1034")+ == "https://mirror.example/whl/gfx103X-all/"+ )+ assert (+ stack_mod._windows_rocm_torch_pkg_specs("gfx1034")+ == stack_mod._WINDOWS_ROCM_TORCH_PKG_SPECS["gfx1034"]+ )+ assert (+ stack_mod._windows_rocm_index_url("gfx1201")+ == "https://mirror.example/whl/gfx120X-all/"+ )+ assert (+ stack_mod._windows_rocm_torch_pkg_specs("gfx1201")+ == stack_mod._WINDOWS_ROCM_TORCH_PKG_SPECS["gfx1201"]+ )+ assert stack_mod._windows_rocm_index_url("gfx1010") == _MULTIARCH+ assert stack_mod._windows_rocm_index_url("gfx1153") == _MULTIARCH++ def test_a_multiarch_mirror_wins_over_a_family_mirror(self, stock):+ stock.setenv("UNSLOTH_ROCM_WINDOWS_MIRROR", "https://mirror.example/whl")+ stock.setattr(stack_mod, "_ROCM_WINDOWS_INDEX_BASE", "https://mirror.example/whl")+ stock.setenv(+ "UNSLOTH_ROCM_WINDOWS_MULTIARCH_MIRROR", "https://mirror.example/whl-multi-arch"+ )+ stock.setattr(+ stack_mod, "_ROCM_WINDOWS_MULTIARCH_INDEX_BASE", "https://mirror.example/whl-multi-arch"+ )+ assert (+ stack_mod._windows_rocm_index_url("gfx1034") == "https://mirror.example/whl-multi-arch/"+ )++ def test_a_patched_family_base_counts_as_a_family_mirror(self, stock):+ """Tests and callers that set _ROCM_WINDOWS_INDEX_BASE directly expect the family route."""+ stock.setattr(stack_mod, "_ROCM_WINDOWS_INDEX_BASE", "https://mirror.example/whl/")+ assert stack_mod._windows_rocm_index_url("gfx1151") == "https://mirror.example/whl/gfx1151/"++ def test_a_query_token_mirror_keeps_its_token(self, stock):+ stock.setattr(+ stack_mod,+ "_ROCM_WINDOWS_MULTIARCH_INDEX_BASE",+ "https://m.example/whl-multi-arch?token=abc",+ )+ assert (+ stack_mod._windows_rocm_index_url("gfx1151")+ == "https://m.example/whl-multi-arch/?token=abc"+ )+ assert stack_mod._windows_rocm_torch_pkg_specs("gfx1151")[0].startswith(+ "torch[device-gfx1151]=="+ )+++class TestPowerShellAgrees:+ @staticmethod+ def _list(path):+ src = path.read_text(encoding = "utf-8")+ block = src[src.index("$multiArchGfx = @(") :]+ block = block[: block.index(")") + 1]+ return set(re.findall(r'"(gfx[0-9a-z]+)"', block))++ @pytest.mark.parametrize("path", [_INSTALL_PS1, _SETUP_PS1], ids = lambda p: p.name)+ def test_same_arch_set(self, path):+ assert self._list(path) == _EXPECTED, f"{path.name}: {sorted(self._list(path) ^ _EXPECTED)}"++ @pytest.mark.parametrize("path", [_INSTALL_PS1, _SETUP_PS1], ids = lambda p: p.name)+ def test_family_mirror_rule_is_mirrored(self, path):+ src = path.read_text(encoding = "utf-8")+ assert (+ "$_familyMirrorPinned = [bool]($env:UNSLOTH_ROCM_WINDOWS_MIRROR) -and -not [bool]($env:UNSLOTH_ROCM_WINDOWS_MULTIARCH_MIRROR)"+ in src+ )+ assert "-and -not ($archFamily -and $_familyMirrorPinned)" in src+ assert "is RDNA 1 --" not in src++ @pytest.mark.parametrize("path", [_INSTALL_PS1, _SETUP_PS1], ids = lambda p: p.name)+ def test_torchvision_carries_the_device_extra(self, path):+ # Bare torchvision on this index has no GPU kernels: nms raised hipErrorInvalidDeviceFunction on gfx1151.+ src = path.read_text(encoding = "utf-8")+ assert (+ '"torchvision[device-$ROCmGfxArch]==$MultiArchTorchvisionVersion+$MultiArchTag"' in src+ )+ assert '"torchvision==$MultiArchTorchvisionVersion+$MultiArchTag"' not in src++ def test_setup_counts_every_multiarch_arch_as_having_wheels(self):+ src = _SETUP_PS1.read_text(encoding = "utf-8")+ block = src[src.index("$_rocmWheelArches = @(") :]+ block = block[: block.index("\n)") + 2]+ listed = set(re.findall(r'"(gfx[0-9a-z]+)"', block))+ missing = (_EXPECTED - {"gfx1010", "gfx1011", "gfx1012"}) - listed+ assert not missing, f"setup.ps1 $_rocmWheelArches lacks {sorted(missing)}"+++def _frozenset_literal(path, name):+ for node in ast.parse(path.read_text(encoding = "utf-8")).body:+ if isinstance(node, (ast.Assign, ast.AnnAssign)):+ targets = node.targets if isinstance(node, ast.Assign) else [node.target]+ if any(isinstance(t, ast.Name) and t.id == name for t in targets):+ return {e.value for e in node.value.args[0].elts}+ raise AssertionError(f"{name} not found in {path.name}")+++def test_backend_counts_every_routed_arch_as_supported_on_windows():+ # A routed arch the backend calls unsupported suppresses its CPU-torch mismatch repair.+ supported = _frozenset_literal(_HARDWARE_PY, "_ROCM_SUPPORTED_GFX") | _frozenset_literal(+ _HARDWARE_PY, "_ROCM_SUPPORTED_GFX_WINDOWS_ONLY"+ )+ missing = set(stack_mod._WINDOWS_MULTIARCH_GFX) - supported+ assert not missing, f"hardware.py does not count {sorted(missing)} as supported on Windows"