hip-<package> is accepted wherever the backend is named (#4013)

STRATA_ENGINE_BACKEND=hip-rdna2 worked for strata update (updater.detect_hardware), but strata update --backend hip-rdna2 offered no package and
strata launch stopped with "STRATA_ENGINE_BACKEND='hip-rdna2' is not one of cpu, cuda, hip, metal, sycl". engine_component.split_backend reads
hip-<variant> as the hip family and its package; detect_backend (the start path), detect_hardware and update --backend all use it. Any other name is
checked as before. Tests in tests/terminal/test_gfx_selection.py.
This commit is contained in:
Niko1221 committed 2026-10-26 19:03:30 +01:00
1 parent a3b7d9de3f
commit 557aad0265
4 files changed
+57 -6

No files matched your search

+3 -1
View File
@@ -186,7 +186,9 @@ def run(a) -> int:
try:
hardware = updater.detect_hardware()
if a.backend:
hardware["backend"] = a.backend
hardware["backend"], variant = ec.split_backend(a.backend) # --backend hip-rdna2 = the hip family, the rdna2 package (#4013)
if variant:
hardware["variant_wanted"] = variant
hardware["backend_source"] = "requested" # the person's own decision: the make guard lets it through
lines: list = []
cancel = threading.Event()
+10 -1
View File
@@ -436,11 +436,20 @@ def runtime_version() -> str | None:
# ----------------------------------------------------------------------------------------------- the GPU
def split_backend(value) -> tuple[str, str]:
"""(backend, variant) for a name the person typed: "hip-rdna2" is the hip family and its rdna2 package (the way the feed labels an AMD
package, #4013), "hip" is the family alone, any other name is returned as it is with no variant."""
name = str(value or "").strip().lower()
if name not in BACKEND_MATRIX and name.startswith("hip-") and len(name) > 4:
return "hip", name[4:]
return name, ""
def detect_backend(environ=None) -> tuple[str | None, str]:
"""(backend, how) for this machine: the engine family its GPU needs. Bounded, read-only probes of tools that are
already installed; ``STRATA_ENGINE_BACKEND`` overrides (the tests and the support desk use it)."""
environ = os.environ if environ is None else environ
forced = environ.get(ENV_BACKEND, "").strip().lower()
forced = split_backend(environ.get(ENV_BACKEND, ""))[0] # "hip-rdna2" starts the hip family (the package choice reads the variant)
if forced:
if forced not in BACKEND_MATRIX:
raise ComponentProblem(f"{ENV_BACKEND}={forced!r} is not one of {', '.join(sorted(BACKEND_MATRIX))}")
+3 -4
View File
@@ -258,11 +258,10 @@ def detect_hardware(environ=None) -> dict:
selection treats as "cannot tell", never as a refusal."""
environ = os.environ if environ is None else environ
prefer = ""
forced = str(environ.get(ec.ENV_BACKEND, "")).strip().lower()
if forced.startswith("hip-") and forced not in ec.BACKEND_MATRIX:
family, prefer = ec.split_backend(environ.get(ec.ENV_BACKEND, ""))
if prefer:
# "hip-rx9070" is how the feed labels a package; accept it as "the hip family, this variant"
prefer = forced[4:]
environ = {**environ, ec.ENV_BACKEND: "hip"}
environ = {**environ, ec.ENV_BACKEND: family}
backend, how = ec.detect_backend(environ)
hw = {"platform": host_platform(), "backend": backend, "backend_source": how, "runtime": ec.runtime_version(),
"nvidia_driver": None, "cuda_archs": [], "gfx": [], "gpu_names": [], "variant_wanted": prefer,
+41
View File
@@ -91,5 +91,46 @@ class Detection(unittest.TestCase):
self.assertEqual((got["backend"], got["variant_wanted"]), ("hip", "rx9070"))
class FeedStyleBackendName(unittest.TestCase):
"""#4013: `hip-<package>` named the AMD package for `strata update` through STRATA_ENGINE_BACKEND only. As `--backend` it offered nothing,
and `strata launch` stopped with "STRATA_ENGINE_BACKEND='hip-rdna2' is not one of cpu, cuda, hip, metal, sycl"."""
def test_split_backend(self):
self.assertEqual(ec.split_backend("hip-rdna2"), ("hip", "rdna2"))
self.assertEqual(ec.split_backend(" HIP-RX9070 "), ("hip", "rx9070"))
self.assertEqual(ec.split_backend("hip"), ("hip", ""))
self.assertEqual(ec.split_backend("cuda"), ("cuda", ""))
self.assertEqual(ec.split_backend("hip-"), ("hip-", ""))
self.assertEqual(ec.split_backend("cuda-13"), ("cuda-13", "")) # only the AMD family has package names
self.assertEqual(ec.split_backend(None), ("", ""))
def test_the_engine_start_takes_the_package_name_as_the_hip_family(self):
self.assertEqual(ec.detect_backend({ec.ENV_BACKEND: "hip-rdna2"}), ("hip", "environment"))
with self.assertRaisesRegex(ec.ComponentProblem, "is not one of"):
ec.detect_backend({ec.ENV_BACKEND: "cuda-13"})
def test_update_backend_option_takes_it_too(self):
import argparse
from strata_cli import update_cmd
seen = {}
class Stop(Exception):
pass
def context(**kw):
seen.update(kw["hardware"])
raise Stop
args = argparse.Namespace(components_dir="C:/nowhere", backend="hip-rdna2", output="json", model_config=None, wait=0, force=False,
app_version=None, check=True, feed=None, no_control=True, yes=True, components_command=None)
base = {"platform": WIN, "backend": "hip", "backend_source": "display adapters", "variant_wanted": ""}
with mock.patch.object(updater, "detect_hardware", return_value=dict(base)), mock.patch.object(updater, "Context", context):
try:
update_cmd.run(args)
except Stop:
pass
self.assertEqual((seen.get("backend"), seen.get("variant_wanted"), seen.get("backend_source")), ("hip", "rdna2", "requested"))
if __name__ == "__main__":
unittest.main()