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: the standard report names an AMD card and its ROCm runtime when only amd-smi exists (#3519)

l33tm4st3r2ac3482144e9
diff --git a/docs/BENCHMARK_PROTOCOL.md b/docs/BENCHMARK_PROTOCOL.md
index 29e9e9ebf..949f9d8f7 100644
--- a/docs/BENCHMARK_PROTOCOL.md
+++ b/docs/BENCHMARK_PROTOCOL.md
@@ -329,7 +329,12 @@ An install with neither has no commit, and the run is `nonconforming`. `engine_v
from `/props` (`build_info`), or `/v1/status` when `/props` has none. `build_kind` is `source` when the
folder has a `.git`, otherwise `release`. The runner cannot read build options from a server; pass `--build-options`
for a source build. The drivers and the CUDA version come from `nvidia-smi` (or `rocm-smi`, or the Windows display
-driver key), read on the machine that runs the engine.
+driver key), read on the machine that runs the engine. ROCm 7 and newer ship `amd-smi` and no `rocm-smi`: the card's
+name is that tool's `static --asic` market name, its memory is the amdgpu sysfs file of the PCI address `amd-smi list`
+reports, and the `rocm` runtime entry is the version file inside the ROCm install (`amd-smi -h` prints the same
+version). Where the kernel builds amdgpu in there is no driver version to read, and `gpu-driver` stays null with a
+reason. When the server can only name a vendor, because the amdgpu `product_name` is empty on some cards, the card the
+local probe named is kept instead.
Except for typed objects, arrays, numbers and booleans identified above, identity and descriptive fields are
strings (or null with a reason where unavailable). Empty configuration objects mean no relevant options;
diff --git a/strata_cli/bench_facts.py b/strata_cli/bench_facts.py
index 309223bf7..026b5c49f 100644
--- a/strata_cli/bench_facts.py
+++ b/strata_cli/bench_facts.py
@@ -1,12 +1,13 @@
"""What a standard benchmark report says about the machine, the build, the model and the settings (docs/BENCHMARK_PROTOCOL.md).
-Every probe is best effort and local: it reads the inference host's own tools (nvidia-smi, rocm-smi, PowerShell, /proc, sysctl) and the
+Every probe is best effort and local: it reads the inference host's own tools (nvidia-smi, rocm-smi, amd-smi, PowerShell, /proc, sysctl) and the
server's answers. A fact that cannot be read becomes `None` with a reason in `Why`, never a guess. Nothing here changes the machine.
"""
from __future__ import annotations
import getpass
+import glob
import hashlib
import json
import os
@@ -193,6 +194,37 @@ def other_gpus() -> tuple[list[dict], str | None]:
driver = next((c.get("driver") for c in found if c.get("driver")), None)
except Exception: # noqa: BLE001 - a report without the card's name is still a report
pass
+ elif os.name != "nt" and sys.platform != "darwin": # (a Mac has no AMD card to ask for; its chip is read below)
+ # ROCm 7 and newer ship amd-smi and no rocm-smi (verified on ROCm 10.1). Different grammar: `static --asic`
+ # gives the marketing name, `static --driver` the kernel driver's version, and the PCI address only comes
+ # from `amd-smi list`; the VRAM size is the amdgpu driver's sysfs file for that address.
+ def amd_json(args):
+ try:
+ return json.loads(run_cmd(["amd-smi", "static"] + args + ["--json"]).strip() or "{}").get("gpu_data") or []
+ except (ValueError, OSError):
+ 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, OSError):
+ bdf = {}
+ drv = {e.get("gpu"): ((e.get("driver") or {}).get("version") or "") for e in amd_json(["--driver"])}
+ for i, e in enumerate(amd_json(["--asic"])):
+ name = ((e.get("asic") or {}).get("market_name") or "").strip()
+ if not name:
+ continue
+ d = drv.get(e.get("gpu"), "")
+ driver = driver or (d if d.upper() not in ("", "N/A") else None)
+ vram = None
+ for dev in glob.glob("/sys/class/drm/card[0-9]*/device"):
+ try:
+ if bdf.get(e.get("gpu")) and os.path.basename(os.path.realpath(dev)).lower() == bdf[e["gpu"]].lower():
+ with open(os.path.join(dev, "mem_info_vram_total"), encoding="utf-8") as f:
+ total = f.read().strip()
+ vram = int(total) if total.isdigit() else None
+ except OSError:
+ pass
+ cards.append({"device_index": i, "name": name, "memory_bytes": vram, "memory_kind": "dedicated",
+ "power_limit_w": None})
elif sys.platform == "darwin":
chip = cpu_name()
if chip:
@@ -201,6 +233,25 @@ def other_gpus() -> tuple[list[dict], str | None]:
return cards, driver
+def rocm_version() -> str | None:
+ """ROCm's own version, which `rocm-smi --showdriverversion` used to report with the driver. ROCm 10 has no
+ `rocm-smi` and no `/opt/rocm/.info/`: its version file sits under `<install>/core/.info/version`, and
+ `amd-smi -h` prints the same version."""
+ for base in [os.environ.get("ROCM_PATH", ""), "/opt/rocm"]:
+ if not base:
+ continue
+ for sub in (".info/version", "core/.info/version"):
+ try:
+ with open(os.path.join(base, sub), encoding="utf-8") as f:
+ found = f.read().strip()
+ if found:
+ return found
+ except OSError:
+ pass
+ match = re.search(r"ROCm version:\s*([\d.]+)", run_cmd(["amd-smi", "-h"]))
+ return match.group(1) if match else None
+
+
def lsblk_disk(data: dict) -> list[dict] | None:
"""The first physical disk in `lsblk -J -s` output. `-s` lists the parents of a device as nested children: an LVM volume
is lvm -> partition -> disk, two levels down, so the walk goes all the way down."""
@@ -277,7 +328,12 @@ def hardware(why: Why, *, selected: list[int], served_gpu: str | None, model_dir
named = [c for c in cards if c["name"] == served_gpu]
cards = named[:1] or cards[:1]
served = [n for n in (served_gpu or "").split(" + ") if n and n != "?"]
- if served and cards and not all(n in {c["name"] for c in cards} for n in served):
+ # the amdgpu driver's product_name is empty on some cards (gfx1201 among them), so the server falls back to a bare
+ # "AMD Radeon": that names the vendor, not the card, and the local probe's marketing name is the one to keep
+ stub = re.compile(r"(?i)^(amd radeon|advanced micro devices(,? inc\.?)?|nvidia( corporation)?|intel"
+ r"( corporation)?)( graphics)?$")
+ if served and cards and not all(stub.match(n) for n in served) \
+ and not all(n in {c["name"] for c in cards} for n in served):
# the server reads cards the local tools do not list (another vendor's, or a different numbering)
cards = [{"device_index": i, "name": n, "memory_bytes": None, "memory_kind": "dedicated", "power_limit_w": None}
for i, n in enumerate(served)]
@@ -308,7 +364,10 @@ def hardware(why: Why, *, selected: list[int], served_gpu: str | None, model_dir
if not declared_background:
why.add(pointer("hardware", "background_workloads"),
"the runner does not inspect other programs; none were declared with --background")
- return block, {"driver": driver, "cuda": cuda}
+ # an AMD card on Linux runs on ROCm, which the report names as the runtime; on ROCm 7 and newer that version no
+ # longer comes from rocm-smi, but from the install itself
+ rocm = rocm_version() if (sys.platform.startswith("linux") and cards and not cuda) else None
+ return block, {"driver": driver, "cuda": cuda, "rocm": rocm}
# ------------------------------------------------------------------------------------------------------------ software
@@ -364,6 +423,8 @@ def software(why: Why, machine: dict, *, engine_version: str | None, build_optio
runtime.append({"name": "cuda-driver-supports", "version": machine["cuda"]})
elif machine.get("cuda"):
runtime.append({"name": "cuda", "version": machine["cuda"]})
+ if machine.get("rocm") and not any(r.get("name") == "rocm" for r in runtime):
+ runtime.append({"name": "rocm", "version": machine["rocm"]})
if sys.platform == "darwin":
runtime.append({"name": "metal", "version": platform.mac_ver()[0] or platform.release()})
drivers = [{"name": "gpu-driver", "version": machine["driver"]}] if machine.get("driver") else []
diff --git a/tests/terminal/test_bench_facts_amd.py b/tests/terminal/test_bench_facts_amd.py
new file mode 100644
index 000000000..353f432fe
--- /dev/null
+++ b/tests/terminal/test_bench_facts_amd.py
@@ -0,0 +1,157 @@
+"""ROCm 7 and newer ship `amd-smi` and no `rocm-smi`, and the amdgpu driver's `product_name` is empty on gfx1201, so a
+report from a Radeon wrote the vendor as the card ("AMD Radeon", `...-standard-unknown-...`) and `runtime: not
+measured`. The strings below are the real output of `amd-smi static --asic --json`, `static --driver --json`,
+`list --json` and `-h` on one AI PRO R9700 (gfx1201) with ROCm 10.1, trimmed to the fields the probe reads."""
+from __future__ import annotations
+
+import json
+import os
+import tempfile
+import unittest
+from unittest import mock
+
+from strata_cli import bench_facts as bf
+
+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"}}]}
+LIST = [{"gpu": 0, "bdf": "0000:03:00.0", "node_id": 1}, {"gpu": 1, "bdf": "0000:7c:00.0", "node_id": 2}]
+HELP = "AMD System Management Interface | Version: 27.1.0+7da43026 | ROCm version: 10.1.0 |"
+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"]:
+ 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)
+ if cmd == ["amd-smi", "-h"]:
+ return HELP
+ 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's last component is the PCI address; the probe matches
+ # that address against `amd-smi list`, so the fake tree repeats the shape instead of the path
+ devices = []
+ for card, bdf in (("card1", "0000:03:00.0"), ("card2", "0000:7c:00.0")):
+ pci = os.path.join(self.tmp.name, "pci", bdf)
+ os.makedirs(pci)
+ with open(os.path.join(pci, "mem_info_vram_total"), "w", encoding="utf-8") as f:
+ f.write(BDF_TO_TOTAL[bdf] + "\n")
+ link = os.path.join(self.tmp.name, "drm", card, "device")
+ os.makedirs(os.path.dirname(link))
+ os.symlink(pci, link)
+ devices.append(link)
+ self.globs = mock.patch.object(bf.glob, "glob", lambda pattern: devices)
+ self.globs.start()
+ self.addCleanup(self.globs.stop)
+ self.cmds = mock.patch.object(bf, "run_cmd", run_cmd)
+ self.cmds.start()
+ self.addCleanup(self.cmds.stop)
+
+ def test_names_both_cards_with_their_vram(self):
+ cards, driver = bf.other_gpus()
+ self.assertEqual([c["name"] for c in cards], ["AMD Radeon AI PRO R9700", "AMD Radeon Graphics"])
+ self.assertEqual([c["memory_bytes"] for c in cards], [34208743424, 805306368])
+ self.assertEqual([c["device_index"] for c in cards], [0, 1])
+
+ def test_a_stub_driver_version_stays_unmeasured(self):
+ # `amd-smi static --driver` says N/A when amdgpu is built into the kernel: that is not a version, so the report
+ # must keep saying it did not measure one instead of writing "N/A"
+ _, driver = bf.other_gpus()
+ self.assertIsNone(driver)
+
+ def test_an_asic_without_a_market_name_is_skipped(self):
+ blank = {"gpu_data": [{"gpu": 0, "asic": {"market_name": ""}},
+ {"gpu": 1, "asic": {"market_name": "AMD Radeon AI PRO R9700"}}]}
+ with mock.patch.object(bf, "run_cmd", lambda cmd, timeout=15: json.dumps(blank) if "static" in cmd else ""):
+ cards, _ = bf.other_gpus()
+ self.assertEqual([c["name"] for c in cards], ["AMD Radeon AI PRO R9700"])
+
+ def test_rocm_version_comes_from_the_install(self):
+ base = os.path.join(self.tmp.name, "rocm")
+ os.makedirs(os.path.join(base, "core", ".info"))
+ with open(os.path.join(base, "core", ".info", "version"), "w", encoding="utf-8") as f:
+ f.write("10.1.0\n")
+ with mock.patch.object(bf.os, "environ", {"ROCM_PATH": base}):
+ self.assertEqual(bf.rocm_version(), "10.1.0")
+
+ def test_rocm_version_falls_back_to_the_help_text(self):
+ real_open = open
+
+ def refuse(path, *args, **kwargs):
+ if "/opt/rocm" in str(path):
+ raise OSError("no ROCm install here")
+ return real_open(path, *args, **kwargs)
+
+ env = {k: v for k, v in os.environ.items() if k != "ROCM_PATH"}
+ with mock.patch.object(bf.os, "environ", env), mock.patch("builtins.open", side_effect=refuse):
+ self.assertEqual(bf.rocm_version(), "10.1.0")
+
+
[email protected](os.name == "nt", "the probe is the non-Windows branch")
+class ServedName(unittest.TestCase):
+ """The server's `gpu` string is the driver's product_name, empty on gfx1201, so it degrades to the vendor. That
+ must not overwrite the card the local probe named, while a card only the server can see still wins."""
+
+ def cards(self):
+ return [{"device_index": 0, "name": "AMD Radeon AI PRO R9700", "memory_bytes": 34208743424,
+ "memory_kind": "dedicated", "power_limit_w": None}]
+
+ def hardware(self, served_gpu):
+ with mock.patch.object(bf, "nvidia_gpus", lambda: ([], None, None)), \
+ mock.patch.object(bf, "other_gpus", lambda: (self.cards(), None)):
+ block, machine = bf.hardware(bf.Why(), selected=[], served_gpu=served_gpu, model_dir=None,
+ declared_background=[])
+ return block, machine
+
+ def test_a_vendor_only_name_does_not_replace_the_card(self):
+ block, machine = self.hardware("AMD Radeon")
+ self.assertEqual([c["name"] for c in block["gpus"]], ["AMD Radeon AI PRO R9700"])
+ self.assertEqual(block["gpus"][0]["memory_bytes"], 34208743424)
+
+ def test_a_card_only_the_server_lists_still_wins(self):
+ block, _ = self.hardware("AMD Radeon RX 7900 XTX")
+ self.assertEqual([c["name"] for c in block["gpus"]], ["AMD Radeon RX 7900 XTX"])
+ self.assertIsNone(block["gpus"][0]["memory_bytes"])
+
+ def test_the_rocm_runtime_reaches_the_report(self):
+ why = bf.Why()
+ with mock.patch.object(bf, "nvidia_gpus", lambda: ([], None, None)), \
+ mock.patch.object(bf, "other_gpus", lambda: (self.cards(), None)), \
+ mock.patch.object(bf, "rocm_version", lambda: "10.1.0"):
+ _, machine = bf.hardware(why, selected=[], served_gpu="AMD Radeon", model_dir=None,
+ declared_background=[])
+ software = bf.software(why, dict(machine), engine_version="0.1.46.2", build_options=None)
+ self.assertEqual(machine["rocm"], "10.1.0")
+ self.assertIn({"name": "rocm", "version": "10.1.0"}, software["runtime"])
+
+
+class MacStillReadsItsChip(unittest.TestCase):
+ """The amd-smi branch is for Linux; a Mac (os.name is posix there too) still takes its card from the chip name."""
+
+ def test_a_mac_is_not_sent_down_the_amd_smi_branch(self):
+ calls = []
+
+ def run(cmd, timeout=15):
+ calls.append(cmd[0])
+ return ""
+
+ with mock.patch.object(bf.os, "name", "posix"), mock.patch.object(bf.sys, "platform", "darwin"), mock.patch.object(bf, "run_cmd", run), mock.patch.object(bf, "cpu_name", lambda: "Apple M5 Max"), mock.patch.object(bf, "ram_bytes", lambda: 137438953472):
+ cards, driver = bf.other_gpus()
+ self.assertEqual([c["name"] for c in cards], ["Apple M5 Max"])
+ self.assertEqual(cards[0]["memory_kind"], "shared")
+ self.assertNotIn("amd-smi", calls)
+
+
+if __name__ == "__main__":
+ unittest.main()