Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

Windows AMD: the engine is picked from the display adapters when no GPU tool answers (an AMD card, not an integrated Radeon), the app lists AMD cards on Windows and no longer refuses the hip backend there

Niko12218c676a7ccdb6
diff --git a/strata_control/engine_component.py b/strata_control/engine_component.py
index 5b784155a..55d456cda 100644
--- a/strata_control/engine_component.py
+++ b/strata_control/engine_component.py
@@ -400,9 +400,9 @@ def detect_backend(environ=None) -> tuple[str | None, str]:
if backend == "sycl" and "level_zero" not in done.stdout.lower() and "gpu" not in done.stdout.lower():
continue
return backend, command[0]
- found = _drm_vendor_backend()
+ found = _drm_vendor_backend() if os.name != "nt" else _windows_vendor_backend()
if found:
- return found, "sysfs pci vendor"
+ return found, "sysfs pci vendor" if os.name != "nt" else "display adapters"
return None, "no GPU tool answered"
@@ -429,6 +429,83 @@ def _drm_vendor_backend() -> str | None:
return None
+#: Windows AMD cards by PCI device id (VEN_1002), the same table as setup.py's _WIN_AMD_DID (tests/terminal/test_engine_component.py
+#: keeps the two equal): the architecture Strata runs the card as. Integrated Radeons are not in it (the one APU that is supported,
+#: Strix Halo, 0x1586, is in WIN_AMD_UMA_IDS), so an integrated Radeon beside a card never counts as "the GPU".
+WIN_AMD_DEVICE_ARCH = {0x744C: "gfx1100", 0x7448: "gfx1100", 0x745E: "gfx1100", 0x747E: "gfx1101", 0x7480: "gfx1102",
+ 0x7590: "gfx1200", 0x7550: "gfx1201", 0x7551: "gfx1201",
+ 0x73BF: "gfx1030", 0x73AF: "gfx1030", 0x73A5: "gfx1030", 0x73DF: "gfx1031"}
+WIN_AMD_UMA_IDS = {0x1586: "gfx1151"} # Strix Halo: unified memory, supported
+WIN_AMD_IGPU_IDS = {0x150E, 0x1114, 0x1902, 0x15BF, 0x15C8, 0x164F, 0x1900, 0x1901, 0x1681, 0x1638, 0x1636, 0x15D8, 0x15E7}
+_WIN_DISPLAY_CLASS = r"SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}"
+
+
+def windows_display_adapters() -> list[dict]:
+ """The display adapters Windows has a driver for (the display-class registry key, readable without admin and without running
+ anything): {"vendor": "10de"|"1002"|"8086"|..., "device": int, "name", "vram_gb"}. Empty off Windows or when it cannot be read."""
+ found: list[dict] = []
+ try:
+ import winreg
+ cls = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, _WIN_DISPLAY_CLASS)
+ except (ImportError, OSError):
+ return found
+ index = 0
+ while True:
+ try:
+ sub = winreg.EnumKey(cls, index)
+ except OSError:
+ break
+ index += 1
+ if not sub.isdigit():
+ continue
+ try:
+ key = winreg.OpenKey(cls, sub)
+ except OSError:
+ continue
+ values = {}
+ for name in ("DriverDesc", "MatchingDeviceId", "HardwareInformation.qwMemorySize"):
+ try:
+ values[name] = winreg.QueryValueEx(key, name)[0]
+ except OSError:
+ pass
+ match = re.search(r"VEN_([0-9A-F]{4})&DEV_([0-9A-F]{4})", str(values.get("MatchingDeviceId") or ""), re.I)
+ if not match:
+ continue
+ memory = values.get("HardwareInformation.qwMemorySize")
+ if isinstance(memory, bytes):
+ memory = int.from_bytes(memory[:8], "little")
+ found.append({"vendor": match.group(1).lower(), "device": int(match.group(2), 16),
+ "name": str(values.get("DriverDesc") or ""),
+ "vram_gb": (int(memory) / 2 ** 30) if isinstance(memory, int) and memory > 0 else 0.0})
+ return found
+
+
+def windows_amd_cards(adapters: list[dict] | None = None) -> list[dict]:
+ """The AMD graphics cards (not an integrated Radeon) among the Windows display adapters, each with the architecture Strata
+ runs it as ("" when the id is not in the table but the adapter has 3 GB or more of its own memory, so it is no APU)."""
+ cards = []
+ for adapter in (windows_display_adapters() if adapters is None else adapters):
+ if adapter.get("vendor") != "1002":
+ continue
+ device = adapter.get("device")
+ arch = WIN_AMD_DEVICE_ARCH.get(device) or WIN_AMD_UMA_IDS.get(device) or ""
+ if not arch and (device in WIN_AMD_IGPU_IDS or float(adapter.get("vram_gb") or 0) < 3.0):
+ continue # an integrated Radeon (512 MB of carve-out)
+ cards.append({"arch": arch, "name": adapter.get("name", ""), "device": device})
+ return cards
+
+
+def _windows_vendor_backend(adapters: list[dict] | None = None) -> str | None:
+ """Windows without nvidia-smi / hipInfo on PATH: the display adapters decide, NVIDIA first, then an AMD card (an AMD
+ integrated GPU alone is not one), as on Linux. Read-only registry, nothing is run."""
+ adapters = windows_display_adapters() if adapters is None else adapters
+ if any(a.get("vendor") == "10de" for a in adapters):
+ return "cuda"
+ if windows_amd_cards(adapters):
+ return "hip"
+ return None
+
+
def cuda_archs_present(environ=None) -> list[str]:
"""``sm_XX`` for each NVIDIA card nvidia-smi reports; empty when it cannot say."""
found = []
@@ -441,7 +518,10 @@ def cuda_archs_present(environ=None) -> list[str]:
def hip_archs_present(kfd_root: str = "/sys/class/kfd/kfd/topology/nodes") -> list[str]:
"""``gfxNNNN`` for each AMD GPU the Linux kernel driver lists (``gfx_target_version`` is MMmmss: gfx1201 = 120001,
- gfx1103 = 110003, gfx90a = 90010); empty when it cannot say (Windows, no amdgpu/kfd, no permission)."""
+ gfx1103 = 110003, gfx90a = 90010); Windows: from the display adapters' PCI ids (integrated Radeons left out); empty when
+ it cannot say (no amdgpu/kfd, no permission, an id not in the table)."""
+ if os.name == "nt":
+ return sorted({c["arch"] for c in windows_amd_cards() if c["arch"]})
found = []
try:
nodes = sorted(Path(kfd_root).iterdir())
diff --git a/tests/terminal/test_engine_component.py b/tests/terminal/test_engine_component.py
index 49396d289..8bdf7387d 100644
--- a/tests/terminal/test_engine_component.py
+++ b/tests/terminal/test_engine_component.py
@@ -248,6 +248,51 @@ class Where(unittest.TestCase):
self.assertEqual(calls, ["nvidia-smi"])
+class WindowsAmd(unittest.TestCase):
+ """Windows PCs with an AMD card and no HIP SDK / nvidia-smi: the display adapters decide the engine."""
+
+ OWNER_PC = [{"vendor": "10de", "device": 0x2F04, "name": "NVIDIA GeForce RTX 5070", "vram_gb": 12.0},
+ {"vendor": "1002", "device": 0x164E, "name": "AMD Radeon(TM) Graphics", "vram_gb": 0.5}]
+ TESTER_A = [{"vendor": "1002", "device": 0x7550, "name": "AMD Radeon RX 9070 XT", "vram_gb": 16.0}]
+ RYZEN_IGPU_AND_CARD = [{"vendor": "1002", "device": 0x164E, "name": "AMD Radeon(TM) Graphics", "vram_gb": 0.5},
+ {"vendor": "1002", "device": 0x744C, "name": "AMD Radeon RX 7900 XTX", "vram_gb": 24.0}]
+ IGPU_ONLY = [{"vendor": "1002", "device": 0x15BF, "name": "AMD Radeon 780M Graphics", "vram_gb": 0.5}]
+
+ def test_nvidia_wins_and_an_integrated_radeon_is_not_a_card(self):
+ self.assertEqual(ec._windows_vendor_backend(self.OWNER_PC), "cuda")
+ self.assertEqual(ec.windows_amd_cards(self.OWNER_PC), [])
+
+ def test_an_amd_card_is_hip(self):
+ self.assertEqual(ec._windows_vendor_backend(self.TESTER_A), "hip")
+ self.assertEqual([c["arch"] for c in ec.windows_amd_cards(self.TESTER_A)], ["gfx1201"])
+
+ def test_a_card_beside_an_integrated_radeon_counts_only_the_card(self):
+ self.assertEqual(ec._windows_vendor_backend(self.RYZEN_IGPU_AND_CARD), "hip")
+ self.assertEqual([c["arch"] for c in ec.windows_amd_cards(self.RYZEN_IGPU_AND_CARD)], ["gfx1100"])
+
+ def test_an_integrated_radeon_alone_is_no_gpu_for_the_engine(self):
+ self.assertIsNone(ec._windows_vendor_backend(self.IGPU_ONLY))
+ self.assertIsNone(ec._windows_vendor_backend([]))
+
+ def test_an_unknown_id_with_its_own_memory_is_a_card_without_an_arch(self):
+ cards = ec.windows_amd_cards([{"vendor": "1002", "device": 0x9999, "name": "AMD Radeon RX Future", "vram_gb": 20.0}])
+ self.assertEqual(cards, [{"arch": "", "name": "AMD Radeon RX Future", "device": 0x9999}])
+
+ def test_detect_backend_on_windows_uses_the_adapters_when_no_tool_answers(self):
+ with mock.patch.object(ec.shutil, "which", lambda name: None), mock.patch.object(ec.os, "name", "nt"), mock.patch.object(ec, "host_platform", return_value="windows-x86_64"), mock.patch.object(ec, "windows_display_adapters", return_value=self.TESTER_A):
+ self.assertEqual(ec.detect_backend({}), ("hip", "display adapters"))
+
+ def test_the_arch_table_is_the_one_setup_uses(self):
+ sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
+ import setup as strata_setup
+ self.assertEqual({k: v for k, v in strata_setup._WIN_AMD_DID.items() if k not in strata_setup.AMD_IGPU_PCI},
+ ec.WIN_AMD_DEVICE_ARCH)
+ self.assertEqual({k: v for k, v in strata_setup.AMD_IGPU_PCI.items() if v == strata_setup.STRIX_HALO_ARCH}, ec.WIN_AMD_UMA_IDS)
+ for device in strata_setup.AMD_IGPU_PCI:
+ if device not in ec.WIN_AMD_UMA_IDS:
+ self.assertIn(device, ec.WIN_AMD_IGPU_IDS)
+
+
class NeverAcquires(unittest.TestCase):
"""The lookup, the status report and the CLI work with the network and process creation unavailable."""
diff --git a/tools/strata_mcp.py b/tools/strata_mcp.py
index 93fb8f9b8..10a638ece 100644
--- a/tools/strata_mcp.py
+++ b/tools/strata_mcp.py
@@ -747,18 +747,17 @@ class Strata:
g["problem"] = None
g["usable"] = g["problem"] is None
amd = []
- if not WIN:
- try:
- amd = S.amd_gpus() if S else []
- for g in amd:
- g["vendor"] = "amd"
- g["vram_gb"] = round(g["vram_gb"], 1)
- g["problem"] = S.amd_problem(g)
- g["usable"] = g["problem"] is None
- except Exception: # noqa: BLE001
- amd = []
- if not amd and shutil.which("rocm-smi"):
- amd = rocm_smi_gpus()
+ try: # Linux: the kernel's KFD topology; Windows: the display adapters' PCI ids + registry (setup.amd_gpus_win)
+ amd = S.amd_gpus() if S else []
+ for g in amd:
+ g["vendor"] = "amd"
+ g["vram_gb"] = round(g["vram_gb"], 1)
+ g["problem"] = S.amd_problem(g)
+ g["usable"] = g["problem"] is None
+ except Exception: # noqa: BLE001
+ amd = []
+ if not WIN and not amd and shutil.which("rocm-smi"):
+ amd = rocm_smi_gpus()
if any(g.get("usable") for g in nv):
for g in amd: # a Ryzen's integrated graphics beside an NVIDIA card: the engine runs on the NVIDIA card
if g.get("uma") and g.get("usable"):
@@ -868,7 +867,7 @@ class Strata:
ram = hw.get("ram_gb") or 0
if not usable:
why = ("no NVIDIA RTX 20-series-or-newer GPU found (nvidia-smi did not list one)"
- + ("; AMD cards run on Linux only" if WIN and any(
+ + ("; the AMD graphics in this PC is not a card Strata supports (an RX 7000 or 9000 series card, or a Ryzen AI Max, is needed)" if WIN and any(
"amd" in str(a.get("name", "")).lower() or "radeon" in str(a.get("name", "")).lower()
for a in hw.get("display_adapters", [])) else ""))
return {"family": None, "model": None, "why": why}
@@ -911,7 +910,7 @@ class Strata:
notes.append("this CPU has no AVX2: EXPERIMENTAL and slow - setup compiles the engine on this PC for the "
"older CPU (10-20 minutes), and the CPU's share of the experts runs a few times slower")
if backend == "hip":
- notes.append("AMD (experimental, Linux): the engine is compiled during setup; no images")
+ notes.append("AMD (experimental): no GPU picture reader yet")
cmd = (("START-HERE.bat --setup" if WIN else "./setup.sh --setup") +
f" --yes --family {fam} --model {model} --context {ctx}" + (" --backend hip" if backend == "hip" else ""))
return {"family": fam, "model": model, "title": families[fam]["title"] + " " + model, "context": ctx,
@@ -1518,9 +1517,6 @@ class Tools:
models, families, contexts, _src = s.tables()
if gpu is not None and gpus is not None:
raise ToolError("give gpu (one card) or gpus (several), not both")
- if backend == "hip" and WIN:
- raise ToolError("the AMD (hip) backend runs on Linux only; on Windows Strata needs an NVIDIA RTX 20 "
- "series or newer card")
if sys.version_info < (3, 10) or (WIN and sys.maxsize <= 2**32):
raise ToolError("this Python is too old or 32-bit: Strata's setup needs 64-bit Python 3.10+; run "
+ ("START-HERE.bat" if WIN else "./setup.sh") + " once instead (it installs Python)")
diff --git a/tools/test_strata_mcp.py b/tools/test_strata_mcp.py
index fbcfff056..57cdef754 100644
--- a/tools/test_strata_mcp.py
+++ b/tools/test_strata_mcp.py
@@ -321,6 +321,9 @@ class Validation(FakeRoot):
self.assertFalse(err, res)
with mock.patch.object(M, "WIN", True):
self.assertRejected("strata_install", {"backend": "hip", "vision": "cpu"}, "Linux")
+ res, err = self.call("strata_install", {"backend": "hip", "vision": "no"}) # the Windows AMD engine is no longer refused outright
+ self.assertFalse(err, res)
+ self.assertIn("--backend hip", res["plan"]["setup_command"])
def test_data_dir_paths(self):
self.assertRejected("strata_install", {"data_dir": "models"}, "absolute")
@@ -710,6 +713,19 @@ class MixedGraphics(unittest.TestCase):
with mock.patch.object(M.sys, "platform", "linux"), mock.patch.object(M, "WIN", False), mock.patch.object(S, "gpus", lambda: []), mock.patch.object(S, "amd_gpus", lambda: [dict(g) for g in igpu]), mock.patch.object(S, "amd_problem", lambda g: None):
self.assertTrue(s._hardware()["gpus"][0]["usable"])
+ def test_windows_lists_an_amd_card_and_not_the_integrated_radeon(self):
+ s = M.Strata(HERE.parent)
+ S = s.setup_module()
+ cards = [{"index": 0, "name": "AMD Radeon RX 9070 XT", "vram_gb": 15.9, "arch": "gfx1201", "driver": "32.0.1"},
+ {"index": 1, "name": "AMD Radeon(TM) Graphics", "vram_gb": 0.5, "arch": "unknown (PCI 164E)", "driver": "32.0.1"}]
+ with mock.patch.object(M, "WIN", True), mock.patch.object(S, "gpus", lambda: []), mock.patch.object(S, "amd_gpus", lambda: [dict(g) for g in cards]), mock.patch.object(M, "windows_video_controllers", lambda: [{"name": "AMD Radeon RX 9070 XT", "driver": "32"}]), mock.patch.object(S, "ram_gb", lambda: 64.0), mock.patch.object(S, "page_file_gb", lambda: 10.0):
+ hw = s._hardware()
+ by = {g["name"]: g for g in hw["gpus"]}
+ self.assertTrue(by["AMD Radeon RX 9070 XT"]["usable"])
+ self.assertFalse(by["AMD Radeon(TM) Graphics"]["usable"])
+ rec = s.recommend({**hw, "ram_gb": 64.0})
+ self.assertEqual((rec["backend"], rec["gpu"]["name"]), ("hip", "AMD Radeon RX 9070 XT"))
+
if __name__ == "__main__":
unittest.main()