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++

bench: tools/strata_bench.py (BENCH.bat, bench.sh) names an AMD card on ROCm 7+ too (#3630)

l33tm4st3rc471588f3ec2
diff --git a/tests/terminal/test_bench_community_amd.py b/tests/terminal/test_bench_community_amd.py
new file mode 100644
index 000000000..2aa53068a
--- /dev/null
+++ b/tests/terminal/test_bench_community_amd.py
@@ -0,0 +1,90 @@
+"""`bench.sh` (tools/strata_bench.py) has its own GPU probe, so the ROCm 7+ fix in strata_cli/bench_facts.py did not
+reach it: with no `rocm-smi` on the box it wrote the server's vendor stub as the card ("AMD Radeon",
+`...-community-unknown-...`) and `GPU driver: not read`. The strings below are the real answers of `amd-smi static
+--asic --json`, `static --driver --json` and `list --json` on one AI PRO R9700 (gfx1201) plus a Ryzen iGPU, with ROCm
+10.1, trimmed to the fields the probe reads."""
+from __future__ import annotations
+
+import json
+import os
+import sys
+import tempfile
+import unittest
+from pathlib import Path
+from unittest import mock
+
+from tools import strata_bench as sb
+
+ASIC = {"gpu_data": [{"gpu": 0, "asic": {"market_name": "AMD Radeon AI PRO R9700", "target_graphics_version": "gfx1201"}},
+ {"gpu": 1, "asic": {"market_name": "AMD Radeon Graphics", "target_graphics_version": "gfx1036"}}]}
+DRIVER = {"gpu_data": [{"gpu": 0, "driver": {"name": "amdgpu", "version": "N/A",
+ "os_kernel_version": "7.3.0-rc6-2-cachyos-rc"}},
+ {"gpu": 1, "driver": {"name": "amdgpu", "version": "6.16.4"}}]}
+LIST = [{"gpu": 0, "bdf": "0000:03:00.0", "node_id": 1}, {"gpu": 1, "bdf": "0000:7c:00.0", "node_id": 2}]
+BDF_TO_TOTAL = {"0000:03:00.0": "34208743424", "0000:7c:00.0": "805306368"}
+
+
+def run_cmd(cmd: list[str], timeout: float = 15) -> str:
+ """ROCm 10.1 answers, with `rocm-smi` missing entirely."""
+ if cmd[:1] == ["rocm-smi"] or cmd[:1] == ["nvidia-smi"]:
+ return ""
+ if cmd[:3] == ["amd-smi", "list", "--json"]:
+ return json.dumps(LIST)
+ if cmd[:2] == ["amd-smi", "static"]:
+ return json.dumps(DRIVER if "--driver" in cmd else ASIC)
+ return ""
+
+
[email protected](os.name == "nt", "the probe is the non-Windows branch")
+class AmdSmiProbe(unittest.TestCase):
+ def setUp(self):
+ self.tmp = tempfile.TemporaryDirectory()
+ self.addCleanup(self.tmp.cleanup)
+ # /sys/class/drm/cardN/device is a symlink whose target ends in the PCI address; the fake tree repeats the
+ # shape, and the probe matches that address against `amd-smi list`
+ root = Path(self.tmp.name)
+ drm = root / "drm"
+ for card, bdf in (("card1", "0000:03:00.0"), ("card2", "0000:7c:00.0")):
+ real = root / "devices" / bdf
+ real.mkdir(parents=True)
+ (real / "mem_info_vram_total").write_text(BDF_TO_TOTAL[bdf], encoding="utf-8")
+ drm.mkdir(parents=True, exist_ok=True)
+ (drm / card).mkdir(exist_ok=True)
+ os.symlink(real, drm / card / "device")
+ self.drm = str(drm)
+ real_path = Path
+
+ class DrmPath(real_path):
+ def __new__(cls, *a, **kw):
+ return real_path(self.drm) if a == ("/sys/class/drm",) else real_path(*a, **kw)
+
+ self.drm_patch = mock.patch.object(sb, "Path", DrmPath)
+ self.drm_patch.start()
+ self.addCleanup(self.drm_patch.stop)
+ self.cmd_patch = mock.patch.object(sb, "run_cmd", run_cmd)
+ self.cmd_patch.start()
+ self.addCleanup(self.cmd_patch.stop)
+
+ def test_the_probe_names_both_cards(self):
+ info = sb.gpu_info_local()
+ self.assertEqual([g["name"] for g in info["gpus"]], ["AMD Radeon AI PRO R9700", "AMD Radeon Graphics"])
+ self.assertEqual([g["vram_mib"] for g in info["gpus"]], [34208743424 >> 20, 805306368 >> 20])
+ self.assertEqual([g["driver"] for g in info["gpus"]], [None, "6.16.4"])
+ self.assertEqual(info.get("rocm_driver"), "6.16.4")
+
+ def test_the_folder_names_the_card_it_used(self):
+ # the suite reports the card the engine runs on: the words gpu_slug drops are the vendor ones only
+ self.assertEqual(sb.gpu_slug({"gpu": ["AMD Radeon AI PRO R9700"]}), "ai-pro-r9700")
+
+ def test_the_vendor_stub_does_not_replace_the_card(self):
+ metrics = {"hardware_static": {"gpu_name": "AMD Radeon", "cpu_name": "AMD Ryzen 9 9950X3D",
+ "cores": 16, "threads": 32}, "engine": {}}
+ with mock.patch.object(sb, "try_json", lambda base, path, key="", timeout=20: metrics if path == "/metrics" else {}):
+ m = sb.collect_machine("http://127.0.0.1:1", "", None)
+ self.assertEqual(m["gpu"], ["AMD Radeon AI PRO R9700"])
+ self.assertEqual(m["gpu_vram_mib"], 34208743424 >> 20)
+ self.assertEqual(m["gpu_driver"], None)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tools/strata_bench.py b/tools/strata_bench.py
index be0e39cfe..36d919e7b 100644
--- a/tools/strata_bench.py
+++ b/tools/strata_bench.py
@@ -502,6 +502,39 @@ def gpu_info_local() -> dict:
m2 = re.search(r"Driver version:\s*(\S+)", v)
if m2:
info["rocm_driver"] = m2.group(1)
+ if not info["gpus"] and os.name != "nt":
+ # ROCm 7 and newer ship `amd-smi` and no `rocm-smi`, so a Radeon wrote the server's vendor stub ("AMD
+ # Radeon", `...-community-unknown-...`) and `GPU driver: not read`. `static --asic` gives the marketing
+ # name, `static --driver` the kernel driver's version, the PCI address only comes from `amd-smi list` and
+ # the VRAM size is the amdgpu driver's sysfs file for that address (same probe as strata_cli/bench_facts.py).
+ def amd_json(args):
+ try:
+ return json.loads(run_cmd(["amd-smi", "static"] + args + ["--json"]).strip() or "{}").get("gpu_data") or []
+ except ValueError: # noqa: BLE001 - a report without the card's name is a report
+ return []
+ try:
+ bdf = {e.get("gpu"): (e.get("bdf") or "") for e in json.loads(run_cmd(["amd-smi", "list", "--json"]).strip() or "[]")}
+ except ValueError:
+ bdf = {}
+ drv = {e.get("gpu"): ((e.get("driver") or {}).get("version") or "") for e in amd_json(["--driver"])}
+ cards = []
+ for e in amd_json(["--asic"]):
+ name = ((e.get("asic") or {}).get("market_name") or "").strip()
+ if not name:
+ continue
+ d = drv.get(e.get("gpu"), "")
+ d = d if d.upper() not in ("", "N/A") else None
+ if d:
+ info["rocm_driver"] = info.get("rocm_driver") or d
+ vram = None
+ for dev in Path("/sys/class/drm").glob("card[0-9]*/device"):
+ try:
+ if bdf.get(e.get("gpu")) and os.path.basename(os.path.realpath(dev)).lower() == bdf[e["gpu"]].lower():
+ vram = int((dev / "mem_info_vram_total").read_text(encoding="utf-8").strip()) >> 20
+ except (OSError, ValueError):
+ pass
+ cards.append({"name": name, "vram_mib": vram, "driver": d})
+ info["gpus"] = cards
if not info["gpus"] and os.name == "nt":
# #1587: Windows with only an AMD card has neither nvidia-smi nor rocm-smi; the display class in the registry
# names the card, its VRAM and its driver (the run was labelled "CPU only" before)
@@ -624,6 +657,10 @@ def collect_machine(base: str, key: str, cfg: dict | None, gpu_arg: str | None =
# engine runs on another vendor's card (an Intel Arc beside a GeForce): the server's names are the right ones, and
# so is its VRAM total - the PC's NVIDIA cards were not used.
served = [n for n in (static.get("gpu_name") or "").split(" + ") if n and n != "?"]
+ # the engine's own stub when the driver names no card is the vendor alone ("AMD Radeon"), not a card name:
+ # taking it as one would throw away the real name amd-smi read (same guard as strata_cli/bench_facts.py)
+ served = [n for n in served if not re.fullmatch(r"(?i)\s*(nvidia|amd|intel|advanced micro devices)"
+ r"([ -](geforce|radeon|graphics|arc))?\s*", n)]
if served and not all(n in {g["name"] for g in local["gpus"]} for n in served):
gpu_names, used = served, []
local = {**local, "cuda": None} # the PC's CUDA belongs to cards the engine did not use