From 8c676a7ccdb6d9b3ac729da559c900c18b73ba43 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Sat, 17 Oct 2026 14:10:08 +0200 Subject: [PATCH 1/7] 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 --- strata_control/engine_component.py | 86 ++++++++++++++++++++++++- tests/terminal/test_engine_component.py | 45 +++++++++++++ tools/strata_mcp.py | 30 ++++----- tools/test_strata_mcp.py | 16 +++++ 4 files changed, 157 insertions(+), 20 deletions(-) diff --git a/strata_control/engine_component.py b/strata_control/engine_component.py index 5b784155..55d456cd 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 49396d28..8bdf7387 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 93fb8f9b..10a638ec 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 fbcfff05..57cdef75 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() From 4db866ae00c88d061f8ba8eedfc358a058527106 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Sat, 17 Oct 2026 14:16:02 +0200 Subject: [PATCH 2/7] Engine packages: the folders named in BUILD.json lib_dirs go on the library path with the package folder (the Windows HIP package keeps the ROCm DLLs in rocm/bin), for serve, the binary smoke test and tuning --- serve/server.py | 2 +- strata_control/engine_component.py | 19 +++++++++++++++++++ strata_control/tuning.py | 3 ++- strata_control/updater.py | 2 +- tests/terminal/test_component_start.py | 12 ++++++++++++ 5 files changed, 35 insertions(+), 3 deletions(-) diff --git a/serve/server.py b/serve/server.py index 31dceb85..1b82c102 100644 --- a/serve/server.py +++ b/serve/server.py @@ -7456,7 +7456,7 @@ def with_component_engine(cfg: dict) -> dict: return cfg cfg = dict(cfg) cfg["exe"] = _component_exe(cfg["exe"], cfg) - cfg["lib_dirs"] = [str(Path(cfg["exe"]).parent), *(cfg.get("lib_dirs") or [])] + cfg["lib_dirs"] = [*engine_component.package_lib_dirs(Path(cfg["exe"]).parent), *(cfg.get("lib_dirs") or [])] return cfg diff --git a/strata_control/engine_component.py b/strata_control/engine_component.py index 55d456cd..27f733c9 100644 --- a/strata_control/engine_component.py +++ b/strata_control/engine_component.py @@ -150,6 +150,25 @@ class EngineComponent: "build_id": self.build_id, "variant": self.variant, "signed": bool(self.signature), "file_count": len(self.files), "bytes": sum(item[2] for item in self.files)} +def package_lib_dirs(folder) -> list[str]: + """The folders an engine package needs on the library path (``PATH`` on Windows, ``LD_LIBRARY_PATH`` elsewhere): its own folder, then + the ones its BUILD.json names in ``lib_dirs`` (relative; the Windows HIP package keeps the ROCm DLLs in ``rocm/bin``, which + rocblas.dll's kernel data and ``../.kpack`` are laid out around). Only folders that exist inside the package.""" + folder = Path(folder) + dirs = [str(folder)] + try: + names = json.loads((folder / "BUILD.json").read_text(encoding="utf-8-sig")).get("lib_dirs") or [] + except (OSError, ValueError, AttributeError): + names = [] + for name in names: + if not isinstance(name, str) or not name or Path(name).is_absolute() or ".." in Path(name).parts: + continue + path = folder / name + if path.is_dir() and str(path) not in dirs: + dirs.append(str(path)) + return dirs + + # ----------------------------------------------------------------------------------------------- where def components_dir(environ=None, *, windows: bool | None = None, home: Path | None = None) -> Path: diff --git a/strata_control/tuning.py b/strata_control/tuning.py index c9c8394c..8d366177 100644 --- a/strata_control/tuning.py +++ b/strata_control/tuning.py @@ -197,7 +197,8 @@ def engine_env(engine: Path | str) -> dict[str, str] | None: return None var = "PATH" if os.name == "nt" else "LD_LIBRARY_PATH" env = dict(os.environ) - env[var] = os.pathsep.join([str(folder)] + ([env[var]] if env.get(var) else [])) + from strata_control import engine_component + env[var] = os.pathsep.join(engine_component.package_lib_dirs(folder) + ([env[var]] if env.get(var) else [])) return env diff --git a/strata_control/updater.py b/strata_control/updater.py index e58eed1e..adca61d4 100644 --- a/strata_control/updater.py +++ b/strata_control/updater.py @@ -572,7 +572,7 @@ def binary_smoke(component: ec.EngineComponent, timeout: float = 60) -> dict: report its version. Weaker than a one-token answer, and reported as such.""" var = "PATH" if os.name == "nt" else ("DYLD_LIBRARY_PATH" if sys.platform == "darwin" else "LD_LIBRARY_PATH") env = dict(os.environ) - env[var] = str(component.root) + os.pathsep + env.get(var, "") + env[var] = os.pathsep.join(ec.package_lib_dirs(component.root)) + os.pathsep + env.get(var, "") try: done = subprocess.run([str(component.exe), "--version"], capture_output=True, text=True, timeout=timeout, env=env, cwd=str(component.root), creationflags=getattr(subprocess, "CREATE_NO_WINDOW", 0)) diff --git a/tests/terminal/test_component_start.py b/tests/terminal/test_component_start.py index 42ce5c67..dbab849f 100644 --- a/tests/terminal/test_component_start.py +++ b/tests/terminal/test_component_start.py @@ -202,6 +202,18 @@ class ComponentStart(unittest.TestCase): server.with_component_engine({"exe": "component:strata-engine", "backend": "cuda"}) self.assertEqual(caught.exception.code, 5) + def test_the_build_json_lib_dirs_follow_the_package_folder(self): + """The Windows HIP package keeps the ROCm DLLs in rocm/bin (BUILD.json lib_dirs): strata.exe does not load without them on PATH.""" + from serve import server + folder = install_fake_engine(self.components) + (folder / "rocm" / "bin").mkdir(parents=True) + (folder / "BUILD.json").write_text(json.dumps({"lib_dirs": ["rocm/bin", "../escape", "missing", "/abs"]}), encoding="utf-8") + cfg = server.with_component_engine({"exe": "component:strata-engine", "backend": "cuda", "lib_dirs": ["/other"]}) + self.assertEqual(cfg["lib_dirs"], [str(folder), str(folder / "rocm" / "bin"), "/other"]) + env = server.child_env(cfg) + var = "PATH" if WINDOWS else "LD_LIBRARY_PATH" + self.assertTrue(env[var].startswith(str(folder) + os.pathsep + str(folder / "rocm" / "bin"))) + def test_doctor_names_the_missing_engine(self): from strata_control.doctor import inspect report = inspect(self.config) From 7ecfe4a6a682b17d24a1a92cca2df2c96022a512 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Sat, 17 Oct 2026 14:16:44 +0200 Subject: [PATCH 3/7] A tester build for another AMD card family: one plain line (This build is for AMD RX 9000 cards ... Ask for the RX 7000 build) in the engine status and the start error --- strata_control/engine_component.py | 33 +++++++++++++++++++++---- tests/terminal/test_engine_component.py | 24 ++++++++++++++++++ 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/strata_control/engine_component.py b/strata_control/engine_component.py index 27f733c9..0cf2bc2e 100644 --- a/strata_control/engine_component.py +++ b/strata_control/engine_component.py @@ -72,14 +72,15 @@ class EngineMissing(acquisition.AcquisitionRefused): code = "engine_component_missing" exit_code = 5 - def __init__(self, reason: str, root: Path | None = None, *, problems: list[dict] | None = None): + def __init__(self, reason: str, root: Path | None = None, *, problems: list[dict] | None = None, notice: str | None = None): self.reason = reason self.root = root self.problems = problems or [] + self.plain_notice = notice where = f" in {root}" if root else "" RuntimeError.__init__( self, - f"No engine for this PC was found{where}: {reason}. The app never downloads an engine while it " + (f"{notice} (" if notice else "") + f"No engine for this PC was found{where}: {reason}" + (")" if notice else "") + ". The app never downloads an engine while it " f"starts or serves. Download the engine for your GPU with Update engine in the app's Settings, or with " f"`strata update` (or `strata install`) in the Terminal, or copy an engine package into the component folder.") self.what = "the engine component" @@ -626,6 +627,24 @@ def driver_notice(have: str | None, need: str) -> str: "restart the computer and open Strata again.") +#: The AMD card families a person knows by the box they bought, for the one plain line when a build is for another family. +HIP_FAMILIES = (("RX 9000", ("gfx1200", "gfx1201")), ("RX 7000", ("gfx1100", "gfx1101", "gfx1102")), ("RX 6000", ("gfx1030", "gfx1031")), + ("Ryzen AI Max", ("gfx1151",))) + + +def hip_family(arch: str) -> str: + return next((name for name, archs in HIP_FAMILIES if arch in archs), arch) + + +def arch_notice(built: tuple[str, ...], here: list[str]) -> str: + """The plain sentence for an AMD engine that has code for other cards than this computer's (a tester build for another card).""" + built_for = sorted({hip_family(a) for a in built}) + have = sorted({hip_family(a) for a in here}) + make = lambda names: " and ".join(names) # noqa: E731 + return (f"This build of Strata is for AMD {make(built_for)} cards. This computer has an AMD {make(have)} card ({', '.join(sorted(set(here)))}). " + f"Ask for the {make(have)} build.") + + def resolve(root: Path | None = None, *, backend: str | None = None, target: str | None = None, full: bool = False, runtime: str | None = None) -> EngineComponent: """The engine to start on this machine, or `EngineMissing` / `EngineIntegrityError`. Never downloads, never creates @@ -643,7 +662,7 @@ def resolve(root: Path | None = None, *, backend: str | None = None, target: str # no GPU tool answered: only a CPU engine can be started wanted = "cpu" usable, reasons, broken = [], [], [] - compatible, driver_blocked = 0, [] + compatible, driver_blocked, arch_blocked = 0, [], [] archs_here = cuda_archs_present() if wanted == "cuda" else [] driver_here = nvidia_driver_version() if wanted == "cuda" else None hip_here = hip_archs_present() if wanted == "hip" else [] @@ -671,6 +690,7 @@ def resolve(root: Path | None = None, *, backend: str | None = None, target: str if item.hip_archs and hip_here and not set(item.hip_archs) & set(hip_here): reasons.append(f"{label} has code for {', '.join(item.hip_archs)}, this PC's GPU is " f"{', '.join(hip_here)}") + arch_blocked.append(item) continue need = item.min_driver.get("nvidia") if need and driver_here and _version_key(driver_here) < _version_key(need): @@ -689,7 +709,10 @@ def resolve(root: Path | None = None, *, backend: str | None = None, target: str everything = reasons + [p["folder"] + ": " + p["problem"] for p in problems] if broken and len(broken) == len(reasons): # every package that fits this PC failed its integrity check raise EngineIntegrityError("; ".join(broken), base, problems=problems) - missing = EngineMissing("; ".join(everything) or "nothing matched", base, problems=problems) + plain = None + if arch_blocked and len(arch_blocked) == compatible and not broken: # every engine that fits this PC is built for other cards + plain = arch_notice(tuple(sorted({a for item in arch_blocked for a in item.hip_archs})), hip_here) + missing = EngineMissing("; ".join(everything) or "nothing matched", base, problems=problems, notice=plain) if driver_blocked and len(driver_blocked) == compatible and not broken: # the only thing in the way is the NVIDIA driver: one plain line that names the version to install missing.driver_notice = driver_notice(driver_here, min(driver_blocked, key=_version_key)) @@ -743,5 +766,5 @@ def status(root: Path | None = None, *, backend: str | None = None, full: bool = report["engine"] = chosen.to_dict() report["usable"] = True except EngineMissing as exc: - report["notice"] = getattr(exc, "driver_notice", None) or str(exc) + report["notice"] = getattr(exc, "driver_notice", None) or getattr(exc, "plain_notice", None) or str(exc) return report diff --git a/tests/terminal/test_engine_component.py b/tests/terminal/test_engine_component.py index 8bdf7387..7b801aab 100644 --- a/tests/terminal/test_engine_component.py +++ b/tests/terminal/test_engine_component.py @@ -293,6 +293,30 @@ class WindowsAmd(unittest.TestCase): self.assertIn(device, ec.WIN_AMD_IGPU_IDS) +class WrongCardFamily(unittest.TestCase): + """A tester build is for one AMD card family; on another family the person gets one plain line, not a technical list.""" + + def setUp(self): + self.dir = tempfile.TemporaryDirectory() + self.root = Path(self.dir.name) + self.addCleanup(self.dir.cleanup) + self.folder = make_package(self.root, backend="hip", archs=("gfx1200", "gfx1201")) + + def test_an_rx7000_card_with_the_rx9000_build_is_told_to_ask_for_the_other_build(self): + with mock.patch.object(ec, "hip_archs_present", return_value=["gfx1100"]): + with self.assertRaises(ec.EngineMissing) as caught: + ec.resolve(self.root, backend="hip", runtime="1") + note = ec.status(self.root, backend="hip")["notice"] + self.assertTrue(str(caught.exception).startswith("This build of Strata is for AMD RX 9000 cards."), str(caught.exception)) + self.assertIn("Ask for the RX 7000 build.", note) + self.assertIn("(gfx1100)", note) + self.assertNotIn("component", note) + + def test_the_matching_family_is_not_blocked(self): + with mock.patch.object(ec, "hip_archs_present", return_value=["gfx1201"]): + self.assertEqual(ec.resolve(self.root, backend="hip", runtime="1").backend, "hip") + + class NeverAcquires(unittest.TestCase): """The lookup, the status report and the CLI work with the network and process creation unavailable.""" From 67bd2a1609c12cc0dc07e080b3172ba44c546c6c Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Sat, 17 Oct 2026 18:21:43 +0200 Subject: [PATCH 4/7] hip_archs_present: an explicit kfd folder is always read (the Windows adapter lookup only replaces the default Linux one) --- strata_control/engine_component.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/strata_control/engine_component.py b/strata_control/engine_component.py index 0cf2bc2e..b8c55442 100644 --- a/strata_control/engine_component.py +++ b/strata_control/engine_component.py @@ -536,12 +536,14 @@ def cuda_archs_present(environ=None) -> list[str]: return found -def hip_archs_present(kfd_root: str = "/sys/class/kfd/kfd/topology/nodes") -> list[str]: +def hip_archs_present(kfd_root: str | None = None) -> list[str]: """``gfxNNNN`` for each AMD GPU the Linux kernel driver lists (``gfx_target_version`` is MMmmss: gfx1201 = 120001, 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"]}) + if kfd_root is None: + if os.name == "nt": + return sorted({c["arch"] for c in windows_amd_cards() if c["arch"]}) + kfd_root = "/sys/class/kfd/kfd/topology/nodes" found = [] try: nodes = sorted(Path(kfd_root).iterdir()) From 6aa502d938baf67b35a15177f4b0cc50a28efec5 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Sat, 17 Oct 2026 18:25:27 +0200 Subject: [PATCH 5/7] strata update: a feed whose only HIP engine is for another AMD card family says so in one plain line (This build of Strata is for AMD RX 7000 cards ... Ask for the RX 9000 build) --- strata_cli/update_cmd.py | 2 +- strata_control/updater.py | 6 ++++++ tests/terminal/test_updater.py | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/strata_cli/update_cmd.py b/strata_cli/update_cmd.py index 4e89a433..953b4dd9 100644 --- a/strata_cli/update_cmd.py +++ b/strata_cli/update_cmd.py @@ -136,7 +136,7 @@ def _print_check(report: dict) -> None: offered = (eng["offered"] or {}).get("version") text = {"available": f"update available: {installed} -> {offered} ({_mib(eng['download_bytes'])})", "install": f"no engine installed yet; {offered} is the one for this PC ({_mib(eng['download_bytes'])})", - "current": f"{installed} is up to date", "none-for-this-pc": "the feed has no engine for this PC", + "current": f"{installed} is up to date", "none-for-this-pc": eng.get("note") or "the feed has no engine for this PC", "not-in-feed": "the feed lists no engines"}.get(eng["status"], eng.get("note") or eng["status"]) print(f" Engine {text}") for reason in eng.get("reasons") or []: diff --git a/strata_control/updater.py b/strata_control/updater.py index adca61d4..b83cc869 100644 --- a/strata_control/updater.py +++ b/strata_control/updater.py @@ -435,6 +435,12 @@ def _choose_engine(feed: feedmod.Feed, ctx: Context, state: State) -> tuple[dict if offered is None: if not feed.engine: report["status"] = "not-in-feed" + else: + hip = [p for p in feed.engine if p.backend == "hip" and p.platform == ctx.hardware.get("platform")] + if hip and ctx.hardware.get("backend") == "hip" and ctx.hardware.get("gfx") and not any( + feedmod.engine_fit_reasons(p, ctx.hardware) == [] for p in hip): + # a build for another AMD card family: one plain line instead of the list of reasons + report["note"] = ec.arch_notice(tuple(sorted({a for p in hip for a in p.archs if a.startswith("gfx")})), ctx.hardware["gfx"]) return report, None report["download_bytes"] = offered.size if installed is None: diff --git a/tests/terminal/test_updater.py b/tests/terminal/test_updater.py index 8d19d383..67d93eda 100644 --- a/tests/terminal/test_updater.py +++ b/tests/terminal/test_updater.py @@ -686,5 +686,22 @@ class Cli(UpdaterCase): self.assertEqual(self.archive_requests(), []) +class AnotherCardFamilyNote(unittest.TestCase): + """A feed whose only HIP engine is built for another AMD card family says so in one plain line.""" + + def test_the_note_names_both_families_and_the_build_to_ask_for(self): + import tempfile + from types import SimpleNamespace + pkg = SimpleNamespace(label="0.1.45.1 linux-x86_64-hip-rx7900", platform="linux-x86_64", backend="hip", min_runtime=None, + archs=("gfx1100", "gfx1101", "gfx1102"), min_driver={}) + hardware = {"platform": "linux-x86_64", "backend": "hip", "runtime": None, "gfx": ["gfx1201"], "cuda_archs": [], "nvidia_driver": None} + with tempfile.TemporaryDirectory() as d: + ctx = SimpleNamespace(components=Path(d), hardware=hardware) + report, offered = updater._choose_engine(SimpleNamespace(engine=[pkg]), ctx, SimpleNamespace(section=lambda name: {})) + self.assertIsNone(offered) + self.assertEqual(report["status"], "none-for-this-pc") + self.assertEqual(report["note"], "This build of Strata is for AMD RX 7000 cards. This computer has an AMD RX 9000 card (gfx1201). Ask for the RX 9000 build.") + + if __name__ == "__main__": unittest.main() From cbb249d3dd96fc6b2ba8ec5653a2a64807b41f87 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Sat, 17 Oct 2026 18:54:32 +0200 Subject: [PATCH 6/7] Windows HIP package: ship msvcp140_atomic_wait.dll (strata.exe imports it) and the other VC++ runtime DLLs next to the exes as well as in rocm/bin --- tools/hip/package_windows.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/hip/package_windows.py b/tools/hip/package_windows.py index a2104e81..4db84d7f 100644 --- a/tools/hip/package_windows.py +++ b/tools/hip/package_windows.py @@ -35,7 +35,8 @@ ROOT = Path(__file__).resolve().parents[2] ASSET = "strata-windows-x64-hip.zip" PROGRAMS = ("strata.exe", "strata-device.exe") DYNAMIC = ("amd_comgr.dll",) # LoadLibrary'd by amdhip64_7.dll: not in any import table -CRT = ("msvcp140.dll", "msvcp140_1.dll", "msvcp140_2.dll", "vcruntime140.dll", "vcruntime140_1.dll") +CRT = ("msvcp140.dll", "msvcp140_1.dll", "msvcp140_2.dll", "vcruntime140.dll", "vcruntime140_1.dll", + "msvcp140_atomic_wait.dll", "msvcp140_codecvt_ids.dll", "vcruntime140_threads.dll", "concrt140.dll") # strata.exe imports msvcp140_atomic_wait.dll (VS 2022 std::atomic wait) KPACKS = ("blas_lib",) # rocblas.dll's own device code; rocSOLVER's (27 MB per arch) is never launched by Strata LICENSES = ("rocblas", "rocsolver", "hipblas", "hipblas-common", "hipblaslt", "amd_comgr", "rocm-core") NOTICE = """Strata's Windows HIP engine ships these AMD ROCm components unmodified, from AMD's TheRock Python wheels @@ -105,6 +106,7 @@ def main() -> int: sys.exit("VCToolsRedistDir is not set: run this from a Visual Studio x64 developer prompt (vcvars64.bat)") for d in sorted(crt): shutil.copy2(cdir / d, stage / "rocm" / "bin" / d) + shutil.copy2(cdir / d, stage / d) # and beside the exes: the folder Windows searches first, with no PATH needed # #468 #461: the HIP runtime (and the compiler it loads by name) next to the exes as well - Windows searches the # exe's folder before System32, where an AMD driver may install its own amdhip64_7.dll (found before PATH's # rocm/bin); rocBLAS/hipBLASLt stay in rocm/bin, which they resolve their kernel libraries and ../.kpack from From b2761df6264873322e3ce57db7a4299be554758b Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Sat, 17 Oct 2026 19:53:48 +0200 Subject: [PATCH 7/7] stage-harness.mjs: the missing-imports message had raw line breaks inside a string (SyntaxError, no Harness could be staged on any OS) --- apps/desktop/scripts/stage-harness.mjs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/desktop/scripts/stage-harness.mjs b/apps/desktop/scripts/stage-harness.mjs index 74d9b960..747d64cc 100644 --- a/apps/desktop/scripts/stage-harness.mjs +++ b/apps/desktop/scripts/stage-harness.mjs @@ -164,9 +164,7 @@ if (keepIgnore) writeFileSync(join(out, '.gitignore'), keepIgnore); // --- proof 1: nothing the Harness imports by name was pruned ------------------------------------------------------------ // (2026-10-17: the other-OS rule once removed @deepseek-ai/dsh-win32-process, which every platform imports; Linux/Mac agent chats died.) const lost = missingHarnessImports(out); -if (lost.length) { console.error('staged Harness is missing imported packages: -' + lost.map(l => ` ${l.from} -> ${l.missing}`).join(' -')); process.exit(1); } +if (lost.length) { console.error('staged Harness is missing imported packages:' + String.fromCharCode(10) + lost.map(l => ` ${l.from} -> ${l.missing}`).join(String.fromCharCode(10))); process.exit(1); } console.log('import check: every @deepseek-ai package the Harness imports is staged'); // --- proof 2: the staged copy answers --version and boots the web profile once ----------------------------------------