From 987ebd442fe2e02fc5ccd01a573a5723f3fde3fd Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Sat, 31 Oct 2026 02:57:34 +0100 Subject: [PATCH] Launch: list the Arc Pro B65 (0xe222) and the other discrete Battlemage/Alchemist ids, so two cards are both named for a launch that names none --- strata_cli/launch/catalog.py | 11 ++-- sycl/setup_intel.py | 2 +- tests/terminal/test_intel_cards_029.py | 80 ++++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 5 deletions(-) create mode 100644 tests/terminal/test_intel_cards_029.py diff --git a/strata_cli/launch/catalog.py b/strata_cli/launch/catalog.py index cc0977e6..e9a36e82 100644 --- a/strata_cli/launch/catalog.py +++ b/strata_cli/launch/catalog.py @@ -193,11 +193,14 @@ def install_root(explicit: str | os.PathLike | None = None, src: str | os.PathLi return discovery.find_install(here=installer_folder(src))[0] -# Intel Arc cards by PCI id: (name, memory in GB). The kernel does not tell an ordinary user how much memory the card has, so the common -# cards are listed; an id that is not here is shown as "Intel Arc" with no size and is treated as a small card. (A770: the 8 GB model shares -# the id of the 16 GB one, so the smaller figure is used.) +# Intel Arc cards by PCI id: (name, memory in GB). The kernel does not tell an ordinary user how much memory the card has, so the discrete +# cards are listed (the same ids as sycl/setup_intel.py; tests/terminal/test_intel_cards_029.py keeps the two in step). An id that is not +# here is NOT counted: it is skipped, because an Intel chip built into the processor shares this vendor id and must never be named as a card. +# (A770: the 8 GB model shares the id of the 16 GB one, so the smaller figure is used.) INTEL_ARC = {"0x56a1": ("Arc A750", 8.0), "0x56a2": ("Arc A580", 8.0), "0x56a0": ("Arc A770", 8.0), "0x56a5": ("Arc A380", 6.0), - "0x56a6": ("Arc A310", 4.0), "0xe20b": ("Arc B580", 12.0), "0xe20c": ("Arc B570", 10.0), "0xe223": ("Arc Pro B70", 32.0)} + "0x56a6": ("Arc A310", 4.0), "0x5690": ("Arc A770M", 16.0), "0xe20b": ("Arc B580", 12.0), "0xe20c": ("Arc B570", 10.0), + "0xe223": ("Arc Pro B70", 32.0), "0xe222": ("Arc Pro B65", 32.0), "0xe221": ("Arc Pro B60", 24.0), "0xe211": ("Arc Pro B60", 24.0), + "0xe212": ("Arc B50", 16.0)} def intel_arc_cards(root: str = "/sys/class/drm") -> list[dict]: diff --git a/sycl/setup_intel.py b/sycl/setup_intel.py index 2a0bf012..e89f0a20 100644 --- a/sycl/setup_intel.py +++ b/sycl/setup_intel.py @@ -44,7 +44,7 @@ MOUNT = Path(os.environ.get("STRATA_SYCL_ROOT") or ROOT.parent) # what strata- # Battlemage / Alchemist PCI device ids -> (name, VRAM GB). lspci's database lags new cards (an Arc Pro B70 reads # "Intel Corporation Device [8086:e223]"), so the sysfs id is the reliable signal and the name table is ours. -INTEL_ARC = {"e223": ("Arc Pro B70", 32.0), "e221": ("Arc Pro B60", 24.0), "e211": ("Arc Pro B60", 24.0), +INTEL_ARC = {"e223": ("Arc Pro B70", 32.0), "e222": ("Arc Pro B65", 32.0), "e221": ("Arc Pro B60", 24.0), "e211": ("Arc Pro B60", 24.0), "e20b": ("Arc B580", 12.0), "e20c": ("Arc B570", 10.0), "e212": ("Arc B50", 16.0), "56a0": ("Arc A770", 16.0), "56a1": ("Arc A750", 8.0), "56a2": ("Arc A580", 8.0), diff --git a/tests/terminal/test_intel_cards_029.py b/tests/terminal/test_intel_cards_029.py new file mode 100644 index 00000000..ad0e548e --- /dev/null +++ b/tests/terminal/test_intel_cards_029.py @@ -0,0 +1,80 @@ +"""Two Intel Arc Pro B65 cards (device id 0xe222): the Terminal must see both and name both for a launch that names none (fake sysfs, no hardware).""" +from __future__ import annotations + +import sys +import tempfile +import unittest +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[2] +sys.path.insert(0, str(ROOT)) + +from strata_cli.launch import catalog as C, runner as R, settings as S # noqa: E402 + + +def fake_drm(root: Path, ids: list[str]) -> None: + for i, did in enumerate(ids): + dev = root / f"card{i}" / "device" + dev.mkdir(parents=True) + (dev / "vendor").write_text("0x8086\n") + (dev / "device").write_text(did + "\n") + + +class IntelCards(unittest.TestCase): + def cards(self, ids): + with tempfile.TemporaryDirectory() as d: + fake_drm(Path(d), ids) + return C.intel_arc_cards(d) + + def test_two_b65_are_two_cards_of_32_gb(self): + cards = self.cards(["0xe222", "0xe222"]) + self.assertEqual([(c["index"], c["vram_gb"]) for c in cards], [(0, 32.0), (1, 32.0)]) + self.assertTrue(all("B65" in c["name"] for c in cards)) + + def test_the_other_battlemage_ids_are_listed(self): + for did in ("0xe221", "0xe211", "0xe212", "0xe20b", "0xe223"): + self.assertEqual(len(self.cards([did])), 1, did) + + def test_an_integrated_intel_gpu_is_never_a_card(self): + for did in ("0x46a6", "0x7d55", "0xa7a0", "0x9a49", "0x4680", "0x64a0"): + self.assertEqual(self.cards([did]), [], did) + self.assertEqual(len(self.cards(["0x7d55", "0xe222"])), 1) # an iGPU beside a B65: one card + + def test_both_tables_list_the_same_discrete_ids(self): + import ast + src = (ROOT / "sycl" / "setup_intel.py").read_text(encoding="utf-8") + node = next(n for n in ast.parse(src).body if isinstance(n, ast.Assign) and getattr(n.targets[0], "id", "") == "INTEL_ARC") + theirs = {"0x" + k: v[0].replace("Arc ", "") for k, v in ast.literal_eval(node.value).items()} + ours = {k: v[0].replace("Arc ", "") for k, v in C.INTEL_ARC.items()} + self.assertEqual(set(theirs), set(ours)) + self.assertEqual({k: v.replace(" ", "") for k, v in theirs.items()}, {k: v.replace(" ", "") for k, v in ours.items()}) + + def test_mixed_sizes_get_roles_like_any_other_pair(self): + cards = self.cards(["0xe222", "0xe20b"]) # 32 GB + 12 GB + hw = {"ram_gb": 128.0, "os": "Linux", "cpu": {"avx2": True}, "gpus": cards} + cat = C.Catalog(root=Path(tempfile.mkdtemp()), hardware=hw) + cat.installed_backend = lambda: "sycl" + got = R.cards_for_launch(S.LaunchSettings(family="qwen", model="IQ3_S"), cat, base={}) + self.assertEqual(sorted(got), [0, 1]) + + def test_one_card_names_nothing(self): + hw = {"ram_gb": 128.0, "os": "Linux", "cpu": {"avx2": True}, "gpus": self.cards(["0xe222"])} + cat = C.Catalog(root=Path(tempfile.mkdtemp()), hardware=hw) + cat.installed_backend = lambda: "sycl" + self.assertIsNone(R.cards_for_launch(S.LaunchSettings(family="qwen", model="IQ3_S"), cat, base={})) + + def test_a_launch_that_names_no_card_gets_both_b65(self): + hw = {"ram_gb": 128.0, "os": "Linux", "cpu": {"avx2": True}, "gpus": self.cards(["0xe222", "0xe222"])} + cat = C.Catalog(root=Path(tempfile.mkdtemp()), hardware=hw) + cat.installed_backend = lambda: "sycl" + s = S.LaunchSettings(family="qwen", model="IQ3_S") + got = R.cards_for_launch(s, cat, base={}) + self.assertEqual(sorted(got), [0, 1]) + cfg = {} + R.apply_cards(cfg, got) + self.assertEqual(sorted(cfg["gpu"]), [0, 1]) + self.assertEqual(cfg["layer_split"], "auto") + + +if __name__ == "__main__": + unittest.main()