diff --git a/tests/terminal/test_dsv41_fit_mac.py b/tests/terminal/test_dsv41_fit_mac.py index 3f2e0cfb..7545673a 100644 --- a/tests/terminal/test_dsv41_fit_mac.py +++ b/tests/terminal/test_dsv41_fit_mac.py @@ -68,5 +68,46 @@ class MacPlan(unittest.TestCase): self.assertGreater(p["disk_need_gb"], F.MAC_ENGRAM_GB) +class MacInThePlan(unittest.TestCase): + """plan() answers for an Apple Silicon Mac in the shape the catalog, `strata launch` and the app read (0.2.7.1).""" + + def card(self, ram): + return [{"index": 0, "name": "Apple M5 Max", "vendor": "apple", "vram_gb": 0.0, "unified_gb": float(ram), "usable": True}] + + def test_the_m5_max_streams_and_says_what_was_measured(self): + p = F.plan(self.card(128), 128, 900.0, 8192, model="IST-DAS-2.00bpw") + self.assertTrue(p["mac"]) + self.assertEqual(p["mac_verdict"], "streams") + self.assertAlmostEqual(p["vram_experts_gb"], 71.5, delta=0.5) + self.assertAlmostEqual(p["streamed_gb"], p["experts_gb"] - p["vram_experts_gb"], delta=0.2) + self.assertEqual(p["tp"], 1) + self.assertEqual(p["args"], []) + self.assertIn("M5 Max", p["words"]) + self.assertTrue(p["disk_ok"]) + for key in ("cards", "experts_total", "experts_in_vram", "cpu_experts_gb", "ram_needed_gb", "spill_gb", "engram_gb", "download_gb", "measured"): + self.assertIn(key, p) # the keys the catalog and the Terminal read + + def test_a_small_mac_gets_a_plain_warning_not_a_refusal(self): + p = F.plan(self.card(32), 32, 900.0, 8192, model="IST-DAS-2.25bpw") + self.assertEqual(p["mac_verdict"], "small") + self.assertEqual(p["verdict"], "spills") + self.assertTrue(any("much slower" in w for w in p["warnings"])) + self.assertFalse(any("refuse" in w.lower() for w in p["warnings"])) + + def test_the_file_cache_floor_grows_with_the_memory(self): + self.assertAlmostEqual(F.mac_expert_cap_gb(128), 71.4, delta=0.3) # the measured M5 Max + self.assertGreater(F.mac_expert_cap_gb(64), 20.0) # a 64 GB Mac is not told it keeps nothing + self.assertLess(F.mac_expert_cap_gb(64), F.mac_expert_cap_gb(96)) + + def test_a_pc_is_unchanged(self): + pc = [{"index": 0, "name": "RTX 5070", "vram_gb": 12.0, "vendor": "nvidia"}] + p = F.plan(pc, 64, 900.0, 8192, model="IST-DAS-2.00bpw") + self.assertNotIn("mac", p) + + def test_the_175_set_is_not_a_mac_set(self): + p = F.plan(self.card(128), 128, 900.0, 8192, model="IST-DAS-1.75bpw") + self.assertNotIn("mac", p) # never run on a Mac: falls through to the PC rules (no usable card) + + if __name__ == "__main__": unittest.main() diff --git a/tools/strata_mcp.py b/tools/strata_mcp.py index 7fa021f9..6affbe08 100644 --- a/tools/strata_mcp.py +++ b/tools/strata_mcp.py @@ -2261,6 +2261,14 @@ class Tools: if rec.get("model") is None and model is not None and s.mac() and hw.get("ram_gb", 0) < s.mac().MIN_STREAM_RAM_GB: raise ToolError(f"{model} does not fit this Mac: {rec['why']}") gpu = gpus = kv = low_ram = None + if md.get("multi_file"): # DeepSeek on a Mac (0.2.7.1): the sets that were run there, 8K like everywhere, text only + from strata_control import dsv41_fit + if model not in dsv41_fit.MAC_SET_PACK: + raise ToolError(f"{model} is not offered on a Mac: DeepSeek runs there as " + " or ".join(dsv41_fit.MAC_SET_PACK)) + if vision in ("yes", "gpu", "cpu"): + raise ToolError("images are not available with DeepSeek on a Mac yet: use vision=no") + vision = "no" + context = context or getattr(s.setup_module(), "DSV41_CONTEXT", 8192) context = context or (s.mac().recommend_context(hw.get("ram_gb") or 0) if s.mac() else 32768) if context is None and md.get("multi_file"): context = getattr(s.setup_module(), "DSV41_CONTEXT", 8192) # the context the engine was checked at diff --git a/tools/test_strata_mcp.py b/tools/test_strata_mcp.py index 93650e35..87aa30e1 100644 --- a/tools/test_strata_mcp.py +++ b/tools/test_strata_mcp.py @@ -816,6 +816,22 @@ class MacCatalog(unittest.TestCase): s2.hardware = lambda fresh=False: hw2 M.Tools(s2).install_plan(None, None, None, None, None, None, None, None, None, None, None) + def test_the_install_plan_for_deepseek_on_a_mac_is_text_only_at_8k(self): + s, hw = self.hw(128) + s.hardware = lambda fresh=False: hw + s.disk_free = lambda p: 1000.0 + with tempfile.TemporaryDirectory() as own: + plan, args = M.Tools(s).install_plan("deepseek41", "IST-DAS-2.00bpw", None, None, None, None, None, None, None, None, None, None) + self.assertEqual(args[:9], ["--yes", "--no-start", "--family", "deepseek41", "--model", "IST-DAS-2.00bpw", "--context", "8192", "--vision"]) + self.assertEqual(args[args.index("--vision") + 1], "no", "the Metal engine has not run DeepSeek's picture tower") + for flag in ("--kv", "--gpu", "--gpus", "--low-ram", "--backend"): + self.assertNotIn(flag, args) + self.assertTrue(plan["ram"].startswith("runs on this Mac's memory")) + with self.assertRaises(M.ToolError): # UD-Q8_K_XL (508 GB) and the 1.75 set were never run on a Mac + M.Tools(s).install_plan("deepseek41", "UD-Q8_K_XL", None, None, None, None, None, None, None, None, None, None) + with self.assertRaises(M.ToolError): + M.Tools(s).install_plan("deepseek41", "IST-DAS-2.25bpw", None, "yes", None, None, None, None, None, None, None, None) + def test_a_pc_is_unchanged(self): s = M.Strata(HERE.parent) r = s.recommend({"ram_gb": 96, "gpus": [{"index": 0, "name": "x", "vram_gb": 24.0, "usable": True, "vendor": "nvidia"}],