diff --git a/setup.py b/setup.py index bbb3380a..fec02400 100644 --- a/setup.py +++ b/setup.py @@ -1738,7 +1738,7 @@ def recommend_remote_expert_opt(cfg: dict, off: bool = False) -> None: plain helper path). The engine uses it only with a helper cache; a layer split runs as before. A recommendation: `off` (setup's --no-remote-expert-opt) or "remote_expert_opt": false in the config keeps it out, and a single-GPU config is not touched.""" - if not isinstance(cfg.get("gpu"), list) or len(cfg["gpu"]) < 2: + if len(gpu_sel(cfg.get("gpu"))) < 2: return args = cfg.setdefault("args", []) if off or cfg.get("remote_expert_opt") is False: @@ -5949,11 +5949,29 @@ def hip_config_cards(sel) -> list[dict]: return cards +def gpu_sel(value) -> list: + """A config's "gpu" as a list of card numbers: 0, [0, 2] or the string form "0,2" (which serve splits + the same way). [] when it names none. Without this, a string "0,1" reached gpu_info() whole and + calibrate died with "there is no GPU 0,1" on a dual-GPU config.""" + if value is None or value == "": + return [] + items = value if isinstance(value, (list, tuple)) else str(value).split(",") + sel = [] + for x in items: + x = str(x).strip() + if x == "": + continue + sel.append(int(x) if x.isdigit() else x) + return sel + + def hardware_key(cfg: dict) -> str: """What a calibration is valid for: this GPU, CPU and RAM, and the model with its context and images setting (the context's KV cache and the image encoder take VRAM from the expert cache). #566: a HIP config's cards are AMD's (hip_config_cards) - nvidia-smi's list named them "?" (or another card with that number) before.""" sel = cfg.get("gpu") + if isinstance(sel, str): + sel = gpu_sel(sel) if cfg.get("backend") == "hip": gl = hip_config_cards(sel) else: diff --git a/tools/test_setup_amd.py b/tools/test_setup_amd.py index 3e1001b8..6a3f121a 100644 --- a/tools/test_setup_amd.py +++ b/tools/test_setup_amd.py @@ -416,6 +416,22 @@ class CalibrationKey(unittest.TestCase): "NVIDIA GeForce RTX 5070 + NVIDIA GeForce RTX 5070|24GB|AMD Ryzen 9 7950X|64GB|" "qwen3.8-flash-next-iq3_xxs|32768|text") + def test_nvidia_string_dual_keys_like_the_list(self): + """A dual config's string "0,1" keys like [0, 1] (calibrate died with "there is no GPU 0,1").""" + def amd(*a, **k): + raise AssertionError("amd_gpus called for an NVIDIA config") + with mock.patch.object(setup, "amd_gpus", amd), \ + mock.patch.object(setup, "gpu_info", lambda i=None: {"name": "NVIDIA GeForce RTX 5070", "vram_gb": 11.94}): + self.assertEqual(setup.hardware_key(self.cfg("0,1", backend="cuda")), + setup.hardware_key(self.cfg([0, 1], backend="cuda"))) + self.assertEqual(setup.gpu_sel("0,1"), [0, 1]) + self.assertEqual(setup.gpu_sel("0"), [0]) + asked = [] + with mock.patch.object(setup, "amd_gpus", amd), \ + mock.patch.object(setup, "gpu_info", lambda i=None: asked.append(i) or {"name": "NVIDIA GeForce RTX 5070", "vram_gb": 11.94}): + setup.hardware_key(self.cfg(1, backend="cuda")) # a single card given as a number still asks for that card + self.assertEqual(asked, [1]) + def test_setup_reuses_a_saved_calibration_on_linux_hip(self): cfg = self.cfg(1) saved = {"settings": {"pcie_frac": 0.0}, "tok_s": 40.1, "date": "2026-10-03"}