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
AMD: Strix defers only to an installable generic tag; gfx1153 health gate classified at inventory refresh (#14022)
Daniel Han983226fa739a
diff --git a/studio/backend/tests/test_krackan2_health_gate.py b/studio/backend/tests/test_krackan2_health_gate.pyindex 636a89cec29..f72ef9b4234 100644--- a/studio/backend/tests/test_krackan2_health_gate.py+++ b/studio/backend/tests/test_krackan2_health_gate.py@@ -9,19 +9,93 @@ from __future__ import annotationsimport pytestimport utils.hardware.hardware as hw+import utils.hardware.nvidia as nvidia+++def _linux_inventory(+ monkeypatch,+ tmp_path,+ *,+ name = None,+ kfd = ("110503",),+ rocm = (),+):+ """One AMD sysfs record through the real inventory refresh, KFD nodes from a fixture."""+ nodes = tmp_path / "nodes"+ for i, version in enumerate(("0", *kfd)):+ node = nodes / str(i)+ node.mkdir(parents = True)+ props = f"simd_count {0 if i == 0 else 16}\nvendor_id {0 if i == 0 else 4098}\n"+ (node / "properties").write_text(props + f"gfx_target_version {version}\n")+ import utils.hardware.amd as amd++ real = amd.amd_kfd_gpu_gfx_targets+ monkeypatch.setattr(amd, "amd_kfd_gpu_gfx_targets", lambda: real(str(nodes)))+ monkeypatch.setattr(hw.platform, "system", lambda: "Linux")+ monkeypatch.setattr(+ nvidia, "get_physical_gpu_inventory", lambda: {"devices": [], "absent": True}+ )+ record = {"vendor": "amd", "index": 0, "name": name, "memory_total_gb": None}+ monkeypatch.setattr(hw, "_linux_drm_sysfs_records", lambda **_: [dict(record)])+ monkeypatch.setattr(hw, "_linux_amd_gfx_candidates", lambda: list(rocm))+ monkeypatch.setattr(hw, "_linux_kfd_reports_an_amd_gpu", lambda: True)+ devices = hw._probe_physical_gpu_inventory()["devices"]+ return [d for d in devices if d.get("vendor") == "amd"]@pytest.mark.parametrize(- "system,name,expected",+ "name,expected",[- ("Linux", "AMD Radeon 820M", False),- ("Linux", "AMD Ryzen AI 5 330 w/ Radeon Graphics", False),- ("Linux", "AMD Radeon 860M", True),- ("Windows", "AMD Radeon 820M", True),+ ("AMD Radeon 820M", False),+ ("AMD Ryzen AI 5 330 w/ Radeon Graphics", False),+ ("AMD Radeon 860M", True),],)-def test_a_linux_krackan_point_2_cannot_establish_a_mismatch(monkeypatch, system, name, expected):+def test_a_named_linux_krackan_point_2_cannot_establish_a_mismatch(+ monkeypatch, tmp_path, name, expected+):+ (device,) = _linux_inventory(monkeypatch, tmp_path, name = name, kfd = ())+ assert hw._amd_device_can_establish_a_mismatch(device) is expected+++def test_windows_krackan_point_2_still_establishes_a_mismatch(monkeypatch):# Windows routing is unchanged: the multi-arch route serves gfx1153 there.- monkeypatch.setattr(hw.platform, "system", lambda: system)+ monkeypatch.setattr(hw.platform, "system", lambda: "Windows")+ monkeypatch.setattr(hw, "_linux_kfd_reports_an_amd_gpu", lambda: True)+ assert hw._amd_device_can_establish_a_mismatch({"name": "AMD Radeon 820M"}) is True+++def test_a_nameless_linux_gfx1153_is_resolved_from_kfd(monkeypatch, tmp_path):+ # sysfs publishes no name and no ROCm tool answers: only KFD can name the gfx1153.+ (device,) = _linux_inventory(monkeypatch, tmp_path)+ assert device["gfx_candidates"] == ["gfx1153"]+ assert hw._amd_device_can_establish_a_mismatch(device) is False++[email protected]("kfd", [("110000",), ("110501",)])+def test_other_kfd_arches_keep_the_no_candidates_answer(monkeypatch, tmp_path, kfd):+ (device,) = _linux_inventory(monkeypatch, tmp_path, kfd = kfd)+ assert "gfx_candidates" not in device+ assert hw._amd_device_can_establish_a_mismatch(device) is True+++def test_gfx1153_beside_a_covered_card_still_establishes_a_mismatch(monkeypatch, tmp_path):+ (device,) = _linux_inventory(monkeypatch, tmp_path, kfd = ("110503", "110000"))+ assert device["gfx_candidates"] == ["gfx1100", "gfx1153"]+ assert hw._amd_device_can_establish_a_mismatch(device) is True+++def test_rocm_tools_answer_first(monkeypatch, tmp_path):+ (device,) = _linux_inventory(monkeypatch, tmp_path, rocm = ("gfx1100",))+ assert device["gfx_candidates"] == ["gfx1100"]+++def test_a_health_poll_does_no_platform_or_name_work(monkeypatch):+ # The Krackan classification lives in the inventory refresh; a poll on a cached+ # candidate-less record must not re-run it.+ calls = []+ monkeypatch.setattr(hw.platform, "system", lambda: calls.append("system") or "Linux")monkeypatch.setattr(hw, "_linux_kfd_reports_an_amd_gpu", lambda: True)- assert hw._amd_device_can_establish_a_mismatch({"name": name}) is expected+ for _ in range(3):+ assert hw._amd_device_can_establish_a_mismatch({"vendor": "amd", "name": None})+ assert calls == []diff --git a/studio/backend/utils/hardware/hardware.py b/studio/backend/utils/hardware/hardware.pyindex 836e2782085..f4866df0334 100644--- a/studio/backend/utils/hardware/hardware.py+++ b/studio/backend/utils/hardware/hardware.py@@ -347,11 +347,17 @@ def _probe_physical_gpu_inventory() -> Dict[str, Any]:if sysfs_devices:if any(device.get("vendor") == "amd" for device in sysfs_devices):# The installers only ship a ROCm wheel for _ROCM_SUPPORTED_GFX, so an older card left on CPU torch on purpose must not read as broken. Attached to every AMD record, not matched one-to-one: setup.sh says the orderings need not agree.- _gfx = _linux_amd_gfx_candidates()- if _gfx:- for device in sysfs_devices:- if device.get("vendor") == "amd":- device["gfx_candidates"] = _gfx+ _gfx = _linux_amd_gfx_candidates() or _linux_kfd_gfx1153_candidates()+ for device in sysfs_devices:+ if device.get("vendor") != "amd":+ continue+ if _gfx:+ device["gfx_candidates"] = _gfx+ elif re.search(+ _LINUX_KRACKAN2_NAME_RE, device.get("name") or "", re.IGNORECASE+ ):+ # Classified here, once per refresh, not on every health poll.+ device["gfx_candidates"] = ["gfx1153"]devices.extend(sysfs_devices)sources.append("sysfs-drm")@@ -366,6 +372,18 @@ def _probe_physical_gpu_inventory() -> Dict[str, Any]:}+def _linux_kfd_gfx1153_candidates() -> list[str]:+ """KFD gfx targets when they include a gfx1153, else []. Without rocminfo or amd-smi this is the only reading that names a Krackan Point 2, which the Linux installers leave on CPU torch on purpose; any other arch keeps the conservative no-candidates answer. Never raises."""+ try:+ from utils.hardware.amd import amd_kfd_gpu_gfx_targets+ targets = amd_kfd_gpu_gfx_targets() or []+ except Exception as e:+ logger.debug("KFD gfx target probe failed: %s", e)+ return []+ found = sorted({gfx for gfx in targets if gfx})+ return found if "gfx1153" in found else []++def _linux_amd_gfx_candidates() -> list[str]:"""gfx targets the ROCm userspace reports for this host, sorted, or []. rocminfo is what studio/setup.sh reads to pick an arch, with amd-smi as its fallback; neither is required to exist, and a host with no ROCm userspace reports nothing, so the caller keeps the card rather than guessing an arch. Bounded and never raises."""for command, pattern in (@@ -1075,11 +1093,6 @@ def _amd_device_can_establish_a_mismatch(device: Dict[str, Any]) -> bool:if gfx]if not candidates:- # A lone Linux gfx1153 is declined by the installers, so its CPU wheel is no fault.- if platform.system() != "Windows" and re.search(- _LINUX_KRACKAN2_NAME_RE, device.get("name") or "", re.IGNORECASE- ):- return False# The DirectX registry publishes AdapterFamily only when the driver wrote one, so a supported Windows card can arrive with no arch. setup.ps1 answers that from the marketing name; the probe below can only speak for Linux._named = _rocm_supported_gfx_from_gpu_name(device.get("name") or "")if _named:diff --git a/studio/install_python_stack.py b/studio/install_python_stack.pyindex 328958cec1c..edc73ebe155 100644--- a/studio/install_python_stack.py+++ b/studio/install_python_stack.py@@ -3645,12 +3645,15 @@ def _runtime_gfx_target(if gfx_deviceselse None)- # Strix defers only where the discrete card's wheel can be installed and will run: a readable- # ROCm version (the versionless path has no generic tag for it) and no HSA override (which- # spoofs every agent, the dGPU included). Otherwise it keeps its own per-arch index, as before.+ # Strix defers only where the discrete card's wheel can be installed and will run: a ROCm+ # version with a generic tag (unreadable or pre-6.0 has none, so nothing would install) and+ # no HSA override (which spoofs every agent, the dGPU included). Otherwise it keeps its own+ # per-arch index, as before.+ _strix_rocm = _detect_rocm_version() if runtime_gfx in _STRIX_APU_GFX else None_strix_first = (runtime_gfx in _STRIX_APU_GFX- and _detect_rocm_version() is not None+ and _strix_rocm is not None+ and _generic_pytorch_rocm_tag(_strix_rocm) is not Noneand _hsa_override_gfx_arch(os.environ.get("HSA_OVERRIDE_GFX_VERSION")) is None)if (runtime_gfx in _SHADOWING_INTEGRATED_GFX or _strix_first) and not _visible_devices_pinned():diff --git a/tests/studio/install/test_linux_amd_strix_dgpu_gfx1153.py b/tests/studio/install/test_linux_amd_strix_dgpu_gfx1153.pyindex ff470a780fd..dca44fe5bb0 100644--- a/tests/studio/install/test_linux_amd_strix_dgpu_gfx1153.py+++ b/tests/studio/install/test_linux_amd_strix_dgpu_gfx1153.py@@ -294,6 +294,14 @@ def test_python_strix_keeps_its_index_when_the_rocm_version_is_unreadable():assert _STRIX_INDEX in calls, calls[email protected]("devices", [("gfx1151", "gfx1100"), ("gfx1151", "gfx942")])+def test_python_strix_keeps_its_index_when_rocm_has_no_generic_tag(devices):+ # ROCm 5.7 maps to no generic tag: deferring would install nothing and leave CPU torch.+ assert stack_mod._generic_pytorch_rocm_tag((5, 7)) is None+ calls = routing._run_install(gfx_devices = devices, rocm_version = (5, 7))+ assert _STRIX_INDEX in calls, calls++@pytest.mark.parametrize("devices", [("gfx1151", "gfx1100"), ("gfx1151", "gfx1201")])def test_python_strix_keeps_its_index_under_an_hsa_override(devices):# The override spoofs every agent, the dGPU included, so dGPU wheels would never load.