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: a Windows AMD host without usable ROCm takes Vulkan, not CPU (#10908)

Daniel Han8760d44374e5
diff --git a/studio/backend/tests/test_install_resolve_prebuilt.py b/studio/backend/tests/test_install_resolve_prebuilt.py
index c17f4188bd1..cc1f7f415e5 100644
--- a/studio/backend/tests/test_install_resolve_prebuilt.py
+++ b/studio/backend/tests/test_install_resolve_prebuilt.py
@@ -1161,6 +1161,7 @@ def _detect_windows_host(
monkeypatch,
winreg_fake,
powershell_stdout = "",
+ env = None,
):
"""Drive the real detect_host() as a GPU-less Windows host with a fake
registry, recording every run_capture invocation. Pins the wiring the
@@ -1176,6 +1177,9 @@ def _detect_windows_host(
"ROCM_PATH",
):
monkeypatch.delenv(_env, raising = False)
+ # After the wipe, or the wipe would undo the very mask a caller set.
+ for _name, _value in (env or {}).items():
+ monkeypatch.setenv(_name, _value)
monkeypatch.setattr(
ilp.shutil,
"which",
@@ -1206,6 +1210,39 @@ def test_detect_host_registry_intel_skips_cim_probe(monkeypatch):
assert "powershell" not in captured
+def test_detect_host_registry_amd_skips_cim_probe(monkeypatch):
+ # A single-vendor AMD box has no Intel match, so an `and` gate is what earns this skip.
+ winreg = _FakeWinreg(
+ _FakeRegKey(
+ subkeys = {
+ "0000": _FakeRegKey(values = {"MatchingDeviceId": r"PCI\VEN_1002&DEV_1586"}),
+ }
+ )
+ )
+ host, captured = _detect_windows_host(monkeypatch, winreg)
+ assert host.has_amd_gpu_without_rocm is True
+ assert host.has_intel_gpu is False
+ assert "powershell" not in captured
+
+
+ "mask_var", ["HIP_VISIBLE_DEVICES", "ROCR_VISIBLE_DEVICES", "CUDA_VISIBLE_DEVICES"]
+)
+def test_detect_host_windows_amd_honours_every_hip_mask(monkeypatch, mask_var):
+ # Windows probes the AMD arch with hipinfo, a HIP application, so all three vars hide
+ # devices from it. Vulkan honours none of them (it selects via GGML_VK_VISIBLE_DEVICES),
+ # so routing a masked host there would hand llama.cpp the GPU the caller hid.
+ winreg = _FakeWinreg(
+ _FakeRegKey(
+ subkeys = {
+ "0000": _FakeRegKey(values = {"MatchingDeviceId": r"PCI\VEN_1002&DEV_1586"}),
+ }
+ )
+ )
+ host, _captured = _detect_windows_host(monkeypatch, winreg, env = {mask_var: ""})
+ assert host.has_amd_gpu_without_rocm is False
+
+
def test_detect_host_cim_fallback_fires_on_registry_miss(monkeypatch):
winreg = _FakeWinreg(
_FakeRegKey(
diff --git a/studio/install_llama_prebuilt.py b/studio/install_llama_prebuilt.py
index 02af02a8e03..940ef58beb9 100644
--- a/studio/install_llama_prebuilt.py
+++ b/studio/install_llama_prebuilt.py
@@ -377,8 +377,7 @@ class HostInfo:
has_usable_nvidia: bool
has_rocm: bool = False
has_intel_gpu: bool = False
- # AMD GPU present but ROCm unusable. Linux only, probed only when there is no usable
- # NVIDIA and no ROCm, so the ROCm branches still own every host where ROCm works.
+ # AMD present, ROCm unusable. Probed only when neither NVIDIA nor ROCm is usable.
has_amd_gpu_without_rocm: bool = False
rocm_gfx_target: str | None = None
rocm_gfx_targets: list[str] = field(default_factory = list)
@@ -1056,11 +1055,14 @@ def direct_upstream_release_plan(
install_kind = "windows-hip",
)
)
- # Intel (or other non-NVIDIA/non-AMD) GPU: use the Vulkan prebuilt. Gate
- # on no PHYSICAL NVIDIA (not just no usable one): a host that hid NVIDIA
- # via CUDA_VISIBLE_DEVICES must not reach Vulkan, which ignores that mask
- # and could enumerate the reserved card. Falls through to CPU below.
- elif host.has_intel_gpu and not host.has_physical_nvidia:
+ # Intel or AMD-without-usable-ROCm: use the Vulkan prebuilt, matching the published
+ # branch and the Linux x86_64 one here. Reached when the caller pins a non-default
+ # --published-repo, so leaving it Intel-only sent a Windows AMD host to the CPU
+ # attempt even when the release carries win-vulkan. Gate on no PHYSICAL NVIDIA (not
+ # just no usable one): a host that hid NVIDIA via CUDA_VISIBLE_DEVICES must not reach
+ # Vulkan, which ignores that mask and could enumerate the reserved card. Falls
+ # through to CPU below.
+ elif (host.has_intel_gpu or host.has_amd_gpu_without_rocm) and not host.has_physical_nvidia:
vulkan_asset = f"llama-{release_tag}-bin-win-vulkan-x64.zip"
vulkan_url = assets.get(vulkan_asset)
if vulkan_url:
@@ -2496,6 +2498,27 @@ def windows_intel_gpu_in_registry() -> bool:
answers in microseconds. Matches the PCI vendor id in MatchingDeviceId
(ven_8086) or an Intel DriverDesc.
"""
+ return _windows_display_adapter_in_registry(
+ (("MatchingDeviceId", "ven_8086"), ("DriverDesc", "intel"))
+ )
+
+
+def windows_amd_gpu_in_registry() -> bool:
+ """Whether the Windows registry lists an AMD display adapter.
+
+ Same probe and same caveats as windows_intel_gpu_in_registry, against PCI
+ vendor id 0x1002. Two DriverDesc needles because AMD ships adapters named
+ "AMD Radeon(TM) 8060S Graphics" and others named only "Radeon (TM) ...".
+ Only consulted with no usable NVIDIA and no usable ROCm, so a host reaching
+ it is one the ROCm branch has already declined.
+ """
+ return _windows_display_adapter_in_registry(
+ (("MatchingDeviceId", "ven_1002"), ("DriverDesc", "amd"), ("DriverDesc", "radeon"))
+ )
+
+
+def _windows_display_adapter_in_registry(needles: tuple[tuple[str, str], ...]) -> bool:
+ """Whether any display-adapter class key matches one of (value_name, needle)."""
try:
import winreg
except ImportError:
@@ -2509,10 +2532,7 @@ def windows_intel_gpu_in_registry() -> bool:
# "Properties" is ACL-restricted and not an adapter.
continue
with winreg.OpenKey(class_key, name) as adapter_key:
- for value_name, needle in (
- ("MatchingDeviceId", "ven_8086"),
- ("DriverDesc", "intel"),
- ):
+ for value_name, needle in needles:
try:
value, _ = winreg.QueryValueEx(adapter_key, value_name)
except OSError:
@@ -2760,7 +2780,15 @@ def detect_host(*, probe_rocm_with_nvidia: bool = False) -> HostInfo:
# GPU-isolation docs), so counting those would cost Vulkan to any host merely exporting
# CUDA_VISIBLE_DEVICES. Windows reads all three: its probe is hipinfo, a HIP
# application. Intel is unaffected by HIP masks.
- _amd_hidden_by_mask = os.environ.get("ROCR_VISIBLE_DEVICES") is not None
+ # Windows really does read all three, via _hip_visible_device_mask_set: the arch
+ # probe there is hipinfo, so HIP_VISIBLE_DEVICES and its CUDA_VISIBLE_DEVICES alias
+ # hide devices from it exactly as ROCR does, and Vulkan would then pick up a GPU the
+ # caller had hidden. On Linux the probe is a sysfs walk that no HIP mask touches.
+ _amd_hidden_by_mask = (
+ _hip_visible_device_mask_set()
+ if is_windows
+ else os.environ.get("ROCR_VISIBLE_DEVICES") is not None
+ )
if is_linux:
# No early break: a laptop can pair an Intel iGPU with an AMD dGPU.
for _vendor_file in glob.glob("/sys/class/drm/card*/device/vendor"):
@@ -2775,10 +2803,13 @@ def detect_host(*, probe_rocm_with_nvidia: bool = False) -> HostInfo:
has_amd_gpu_without_rocm = True
elif is_windows:
# Registry first (in-process; see windows_intel_gpu_in_registry).
- # The CIM query stays as the fallback when the registry shows no
- # Intel adapter.
+ # CIM stays the fallback for a registry that names neither adapter.
has_intel_gpu = windows_intel_gpu_in_registry()
- if not has_intel_gpu:
+ if not _amd_hidden_by_mask:
+ has_amd_gpu_without_rocm = windows_amd_gpu_in_registry()
+ # `and`, not `or`: either flag alone settles the Vulkan gate, and `or` made every
+ # single-vendor host pay the CIM probe's 15s timeout after the registry answered.
+ if not has_intel_gpu and not has_amd_gpu_without_rocm:
_ps = shutil.which("powershell") or shutil.which("pwsh")
if _ps:
try:
@@ -2792,8 +2823,12 @@ def detect_host(*, probe_rocm_with_nvidia: bool = False) -> HostInfo:
],
timeout = 15,
)
- if _result.returncode == 0 and "intel" in _result.stdout.lower():
- has_intel_gpu = True
+ if _result.returncode == 0:
+ _names = _result.stdout.lower()
+ if "intel" in _names:
+ has_intel_gpu = True
+ if not _amd_hidden_by_mask and ("amd" in _names or "radeon" in _names):
+ has_amd_gpu_without_rocm = True
except Exception:
pass
@@ -3636,14 +3671,17 @@ def resolve_upstream_asset_choice(host: HostInfo, llama_tag: str) -> AssetChoice
)
log("AMD ROCm detected on Windows but no HIP prebuilt found -- falling back to CPU")
- # Intel (or other non-NVIDIA/non-AMD) GPU on Windows: use Vulkan. No
- # physical NVIDIA so a CUDA-hidden card isn't reached through Vulkan.
- if host.has_intel_gpu and not host.has_physical_nvidia and not host.has_rocm:
+ # Mirrors the Linux branch: without the AMD half a Strix Halo box with no ROCm
+ # tooling took windows-cpu, where the same silicon takes Vulkan on Linux.
+ if (
+ (host.has_intel_gpu or host.has_amd_gpu_without_rocm)
+ and not host.has_physical_nvidia
+ and not host.has_rocm
+ ):
+ vendor = "Intel GPU" if host.has_intel_gpu else "AMD GPU without usable ROCm"
vulkan_name = f"llama-{llama_tag}-bin-win-vulkan-x64.zip"
if vulkan_name in upstream_assets:
- log(
- f"Intel GPU detected on Windows -- using upstream Vulkan prebuilt {vulkan_name}"
- )
+ log(f"{vendor} detected on Windows -- using upstream Vulkan prebuilt {vulkan_name}")
return AssetChoice(
repo = UPSTREAM_REPO,
tag = llama_tag,
@@ -3652,7 +3690,7 @@ def resolve_upstream_asset_choice(host: HostInfo, llama_tag: str) -> AssetChoice
source_label = "upstream",
install_kind = "windows-vulkan",
)
- log("Intel GPU detected on Windows but no Vulkan prebuilt found -- falling back to CPU")
+ log(f"{vendor} detected on Windows but no Vulkan prebuilt found -- falling back to CPU")
upstream_name = f"llama-{llama_tag}-bin-win-cpu-x64.zip"
if upstream_name not in upstream_assets:
@@ -3735,7 +3773,12 @@ def resolve_release_asset_choice(
published_choice: AssetChoice | None = None
if host.is_windows and host.is_x86_64:
- if host.has_intel_gpu and not host.has_physical_nvidia and not host.has_rocm:
+ # Intel OR AMD-without-usable-ROCm, mirroring the Linux branch.
+ if (
+ (host.has_intel_gpu or host.has_amd_gpu_without_rocm)
+ and not host.has_physical_nvidia
+ and not host.has_rocm
+ ):
choices = [
choice
for choice in (
diff --git a/tests/studio/install/test_selection_logic.py b/tests/studio/install/test_selection_logic.py
index 099ef2f19ee..011a29765bf 100644
--- a/tests/studio/install/test_selection_logic.py
+++ b/tests/studio/install/test_selection_logic.py
@@ -2455,6 +2455,72 @@ class TestWindowsCudaAttemptCoversBlackwell:
# ===========================================================================
+class TestDirectUpstreamWindowsAmdTakesVulkan:
+ """The direct/upstream planner is reached when the caller pins --published-repo, so the
+ Windows Vulkan gate there has to match the published one. Left Intel-only, a Windows AMD
+ host with no usable ROCm took the CPU attempt even with win-vulkan in the release."""
+
+ TAG = "b9365"
+
+ def _release(self):
+ names = [
+ f"llama-{self.TAG}-bin-win-vulkan-x64.zip",
+ f"llama-{self.TAG}-bin-win-cpu-x64.zip",
+ ]
+ return {
+ "tag_name": self.TAG,
+ "assets": [
+ {"name": n, "browser_download_url": f"https://example.com/{n}"} for n in names
+ ],
+ }
+
+ def _host(self, **overrides):
+ defaults = dict(
+ system = "Windows",
+ machine = "AMD64",
+ has_physical_nvidia = False,
+ has_usable_nvidia = False,
+ nvidia_smi = None,
+ driver_cuda_version = None,
+ compute_caps = [],
+ )
+ defaults.update(overrides)
+ return make_host(**defaults)
+
+ def test_an_amd_host_without_rocm_gets_vulkan_first(self):
+ plan = direct_upstream_release_plan(
+ self._release(), self._host(has_amd_gpu_without_rocm = True), UPSTREAM_REPO, "latest"
+ )
+ kinds = [a.install_kind for a in plan.attempts]
+ assert kinds[0] == "windows-vulkan"
+ # The CPU attempt stays as the tail, exactly as it does for an Intel host.
+ assert "windows-cpu" in kinds
+
+ def test_an_intel_host_is_unchanged(self):
+ plan = direct_upstream_release_plan(
+ self._release(), self._host(has_intel_gpu = True), UPSTREAM_REPO, "latest"
+ )
+ assert [a.install_kind for a in plan.attempts][0] == "windows-vulkan"
+
+ def test_a_windows_host_with_no_gpu_still_takes_cpu(self):
+ plan = direct_upstream_release_plan(self._release(), self._host(), UPSTREAM_REPO, "latest")
+ assert [a.install_kind for a in plan.attempts] == ["windows-cpu"]
+
+ def test_a_masked_nvidia_host_is_not_routed_to_vulkan(self):
+ # Vulkan ignores CUDA_VISIBLE_DEVICES, so it could enumerate the reserved card.
+ plan = direct_upstream_release_plan(
+ self._release(),
+ self._host(
+ has_amd_gpu_without_rocm = True,
+ has_physical_nvidia = True,
+ visible_cuda_devices = "",
+ ),
+ UPSTREAM_REPO,
+ "latest",
+ )
+ assert all(a.install_kind != "windows-vulkan" for a in plan.attempts)
+
+
# N.1c. direct_upstream_release_plan -- Blackwell windows-cuda fallback ordering
# ===========================================================================
@@ -2892,6 +2958,93 @@ class TestResolveReleaseAssetChoicePin:
assert "b9360" not in [a.tag for a in result]
+class TestWindowsAmdWithoutRocmTakesVulkan:
+ """An AMD Windows host with no usable ROCm must take the Vulkan bundle, not windows-cpu.
+
+ The Windows gate checked has_intel_gpu alone while the Linux one checked
+ `has_intel_gpu or has_amd_gpu_without_rocm`, so the same silicon took Vulkan on Linux
+ and CPU on Windows. Measured on a gfx1151 (Radeon 8060S) box where amd-smi.exe failed
+ to load its library and HIP_PATH / ROCM_PATH were both unset: every ref resolved
+ app-<tag>-windows-x64-cpu.zip, with a windows-vulkan bundle sitting in the same
+ release."""
+
+ TAG = "b10909"
+
+ def _release(self):
+ return make_release(
+ [
+ make_cpu_artifact(
+ f"app-{self.TAG}-windows-x64-vulkan.zip", install_kind = "windows-vulkan"
+ ),
+ make_cpu_artifact(
+ f"app-{self.TAG}-windows-x64-cpu.zip", install_kind = "windows-cpu"
+ ),
+ ],
+ upstream_tag = self.TAG,
+ )
+
+ def _checksums(self):
+ return make_checksums(
+ [
+ f"app-{self.TAG}-windows-x64-vulkan.zip",
+ f"app-{self.TAG}-windows-x64-cpu.zip",
+ ]
+ )
+
+ def _host(self, **overrides):
+ defaults = dict(
+ system = "Windows",
+ machine = "AMD64",
+ nvidia_smi = None,
+ driver_cuda_version = None,
+ compute_caps = [],
+ has_physical_nvidia = False,
+ has_usable_nvidia = False,
+ has_rocm = False,
+ has_intel_gpu = False,
+ has_amd_gpu_without_rocm = True,
+ )
+ defaults.update(overrides)
+ return make_host(**defaults)
+
+ def test_vulkan_is_preferred_over_the_cpu_bundle(self):
+ result = resolve_release_asset_choice(
+ self._host(), self.TAG, self._release(), self._checksums()
+ )
+ assert result[0].install_kind == "windows-vulkan"
+ # The CPU bundle stays as the tail, exactly as it does for an Intel host.
+ assert [c.install_kind for c in result] == ["windows-vulkan", "windows-cpu"]
+
+ def test_an_intel_host_is_unchanged(self):
+ result = resolve_release_asset_choice(
+ self._host(has_intel_gpu = True, has_amd_gpu_without_rocm = False),
+ self.TAG,
+ self._release(),
+ self._checksums(),
+ )
+ assert result[0].install_kind == "windows-vulkan"
+
+ def test_a_host_with_usable_rocm_is_not_diverted_to_vulkan(self, monkeypatch):
+ # The windows-rocm branch must keep owning a ROCm host; this release carries no
+ # windows-rocm bundle, so it walks past the published pair rather than taking Vulkan.
+ # Stubbed because resolve_asset_choice reaches the upstream fetch before it can raise,
+ # and offline that is four GitHub retries and a URLError instead of the assertion.
+ monkeypatch.setattr(INSTALL_LLAMA_PREBUILT, "github_release_assets", lambda repo, tag: {})
+ with pytest.raises(PrebuiltFallback):
+ resolve_release_asset_choice(
+ self._host(has_rocm = True), self.TAG, self._release(), self._checksums()
+ )
+
+ def test_a_plain_cpu_windows_host_still_takes_the_cpu_bundle(self):
+ result = resolve_release_asset_choice(
+ self._host(has_amd_gpu_without_rocm = False),
+ self.TAG,
+ self._release(),
+ self._checksums(),
+ )
+ assert result[0].install_kind == "windows-cpu"
+
+
class TestPublishedWindowsCudaAppBundleSmSelection:
"""app-named windows-cuda bundles carry no minor, so the driver-minor gate is skipped; selection must filter by SM coverage instead of handing every host the lowest-rank "older" bundle."""