setup.py: DeepSeek on a Mac goes through install_dsv41 (Control mode); launch passes --feed/--dsv41-package on a Mac; model-list tests
This commit is contained in:
1 parent
2e7af09a86
commit
fa370e46d1
3 files changed
+69
-8
No files matched your search
@@ -744,6 +744,7 @@ DSV41_SHARED = {
|
||||
DSV41_ALL_FILES = {**DSV41_FILES, **DSV41_ISTA_FILES, **DSV41_LEGACY_FILES}
|
||||
DSV41_PROFILES = ROOT / "data" / "dsv41" # the shipped hot-expert profiles (profile-2.00.bin, profile-2.25.bin, + .sha256)
|
||||
DSV41_CONTEXT = 8192 # the context the engine was checked at (4096 and 8192; 64K is not tried yet)
|
||||
DSV41_MAC_VISION = False # an Apple Silicon Mac: the Metal engine has not run DeepSeek's picture tower (0.2.7.1), so pictures stay off there
|
||||
MULTI_FILE_FAMILIES = {
|
||||
"deepseek41": {"title": "DeepSeek-V4.1-Flash", "by": "DeepSeek; the 2-bit GGUFs by IST-DAS, UD-Q8_K_XL by Unsloth", "arch": "deepseek41",
|
||||
"about": "a big model that runs on a PC with a 12 GB card and 64 GB of RAM (the two official 2-bit versions: 257 or "
|
||||
@@ -8213,6 +8214,7 @@ def install_dsv41(a, family, gpu, hip, amd, cuda_tk, multi, port, ram, adopted,
|
||||
pinned shards (or your own, --gguf-dir), the engine's pack folder, the tokenizer and chat template from the GGUF, the config. The
|
||||
engine places the experts itself (as many as the cards hold in graphics memory, the rest computed on the CPU from the files)."""
|
||||
from strata_control import dsv41_fit
|
||||
mac = sys.platform == "darwin" # an Apple Silicon Mac (0.2.7.1): the Metal build of the DeepSeek engine, one pool of memory
|
||||
fam = MULTI_FILE_FAMILIES[family]
|
||||
say()
|
||||
say(f" {fam['title']} - {fam['by']}: {fam['about']}")
|
||||
@@ -8250,7 +8252,9 @@ def install_dsv41(a, family, gpu, hip, amd, cuda_tk, multi, port, ram, adopted,
|
||||
shared_dir = dsv41_shared_dir(a, fam)
|
||||
# Pictures are on by default (owner rule): the engine reads them with its own vision tower, which the pack carries when the tower's weights
|
||||
# (mmproj-BF16.gguf, a shared file) were there when it was made. --vision no leaves the file out and the pack text-only.
|
||||
ds_vision = "off" if a.vision in ("no", "off") else "on"
|
||||
ds_vision = "off" if a.vision in ("no", "off") or (mac and not DSV41_MAC_VISION) else "on"
|
||||
if mac and not DSV41_MAC_VISION and a.vision not in ("no", "off"):
|
||||
warn("pictures are off for DeepSeek on a Mac: its picture reader has not been run on the Metal engine yet, so it reads text only")
|
||||
shared_names = list(md.get("shared", [])) + ([DSV41_MMPROJ] if ds_vision == "on" else [])
|
||||
shared = [dsv41_find_shared(a, n, folder, shared_dir) for n in shared_names]
|
||||
mmproj_file = shared[len(md.get("shared", []))] if ds_vision == "on" else None
|
||||
@@ -8283,7 +8287,14 @@ def install_dsv41(a, family, gpu, hip, amd, cuda_tk, multi, port, ram, adopted,
|
||||
if "free disk space" in w:
|
||||
continue # the disk is a hard limit, said below
|
||||
warn(w)
|
||||
if plan["verdict"] == "spills":
|
||||
if plan["verdict"] == "spills" and mac:
|
||||
confirm_risk(f"this Mac's memory holds about {plan['vram_experts_gb']:.0f} GB of {model}'s {plan['experts_gb']:.0f} GB of experts and the "
|
||||
f"other {plan['streamed_gb']:.0f} GB are read from the SSD for every word: much slower than on a Mac with 128 GB (a Mac this "
|
||||
"small was not measured)", bool(a.model), a.yes,
|
||||
f"{model} is slow on a Mac with {ram:.0f} GB", f"a Mac with 64 GB or more suits it; --model {model} --yes "
|
||||
"installs it anyway", " Install it anyway?")
|
||||
warn(f"installing {model} with {ram:.0f} GB of memory, as you chose")
|
||||
elif plan["verdict"] == "spills":
|
||||
confirm_risk(f"{model} runs best with about {plan['ram_needed_gb']:.0f} GB of RAM beside this PC's graphics memory and this PC has "
|
||||
f"{ram:.0f} GB: most of its experts are read from the SSD while it answers (slow)", bool(a.model), a.yes,
|
||||
f"{model} needs about {plan['ram_needed_gb']:.0f} GB of RAM", f"more RAM or cards fix it; --model {model} --yes "
|
||||
@@ -8331,8 +8342,9 @@ def install_dsv41(a, family, gpu, hip, amd, cuda_tk, multi, port, ram, adopted,
|
||||
say(" Details for developers: build it with cmake -DSTRATA_BUILD_DSV41=ON -DCMAKE_CUDA_ARCHITECTURES=<your card: 86 RTX 30, 89 RTX 40, 120 RTX 50> "
|
||||
"and point STRATA_DSV41_EXE at it (docs/DEEPSEEK41.md, \"Building the engine for your card\").")
|
||||
fail("DeepSeek's engine is not available for this computer yet",
|
||||
"Supported graphics cards: NVIDIA RTX 30, 40 and 50 series, the Radeon AI PRO R9700, and a Ryzen AI Max (Strix Halo) on "
|
||||
"Windows with the AMD DeepSeek engine package. " + dsv41_manual_steps(eng)
|
||||
("It runs on an Apple Silicon Mac with the Metal DeepSeek engine package from the Strata update feed. " if mac else
|
||||
"Supported graphics cards: NVIDIA RTX 30, 40 and 50 series, the Radeon AI PRO R9700, and a Ryzen AI Max (Strix Halo) on "
|
||||
"Windows with the AMD DeepSeek engine package. ") + dsv41_manual_steps(eng)
|
||||
+ " Or update Strata later (a newer version may add your card), pick another model, or build the engine for your card yourself "
|
||||
"(docs/DEEPSEEK41.md, \"Building the engine for your card\"). Nothing has been downloaded.")
|
||||
ok(f"engine: {exe}")
|
||||
@@ -8429,6 +8441,8 @@ def install_dsv41(a, family, gpu, hip, amd, cuda_tk, multi, port, ram, adopted,
|
||||
cfg["cuda"] = 12
|
||||
if hip:
|
||||
cfg["backend"] = "hip"
|
||||
if mac:
|
||||
cfg["backend"] = "metal"
|
||||
idx = [c["index"] for c in cards]
|
||||
if len(idx) > 1 or a.gpu is not None or a.gpus:
|
||||
cfg["gpu"] = idx if len(idx) > 1 else idx[0]
|
||||
@@ -8708,6 +8722,30 @@ def mac_control_setup(a) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
def mac_dsv41_setup(a) -> int:
|
||||
"""DeepSeek-V4.1-Flash on an Apple Silicon Mac (the app and `strata launch`, Control mode; 0.2.7.1): the model files and the DeepSeek
|
||||
engine package (macOS arm64, Metal) from the signed feed. The steps are install_dsv41's; this only checks the Mac and hands over its
|
||||
one pool of unified memory as the "card" the fit plan reads (strata_control/dsv41_fit.py, mac_plan)."""
|
||||
from strata_control import mac_fit as MF
|
||||
step(1, "checking your Mac")
|
||||
info = MF.mac_info()
|
||||
ram = float(info["ram_gb"] or ram_gb())
|
||||
ok(f"{info['chip']}, {ram:.0f} GB unified memory, macOS {info['macos'] or '?'}")
|
||||
problems = MF.mac_problems(info, need_compiler=False) # the app compiles nothing: no Command Line Tools needed
|
||||
for p in problems:
|
||||
warn(p)
|
||||
data, _elsewhere = data_folder_for(a)
|
||||
if not a.models_dir:
|
||||
a.models_dir = str(data / "models")
|
||||
ok(f"free disk: {free_gb(data if data.exists() else home()):.0f} GB at {data}")
|
||||
if a.check:
|
||||
return 1 if problems else 0
|
||||
if problems:
|
||||
fail(problems[0])
|
||||
gpu = {"index": 0, "name": info["chip"], "vendor": "apple", "vram_gb": 0.0, "unified_gb": ram, "usable": True}
|
||||
return install_dsv41(a, a.family, gpu, False, False, 0, False, a.port or 8080, ram, None, [gpu])
|
||||
|
||||
|
||||
def main() -> int:
|
||||
try: # files made by a run as administrator still belong to the user
|
||||
from strata_control import private_files as _pf
|
||||
@@ -8862,6 +8900,8 @@ def main() -> int:
|
||||
if a.inspect: # headers only: nothing is installed
|
||||
sys.exit(subprocess.run([sys.executable, str(ROOT / "tools" / "strata_inspect.py"), *a.inspect[:2]]).returncode)
|
||||
if sys.platform == "darwin" and CONTROL: # the app on a Mac: model files only; the Metal engine is a component
|
||||
if a.family in MULTI_FILE_FAMILIES: # DeepSeek-V4.1-Flash: its own engine package, the generic DeepSeek install
|
||||
return mac_dsv41_setup(a)
|
||||
return mac_control_setup(a)
|
||||
if a.backend == "sycl": # Intel Arc: the SYCL port's own setup (sycl/setup_intel.py)
|
||||
return sycl_setup(sys.argv[1:])
|
||||
|
||||
@@ -915,7 +915,7 @@ class Runner:
|
||||
if sys.platform == "darwin":
|
||||
# a Mac's setup (Control mode, strata_control/mac_fit.py) takes fewer options (no --kv, --gpu, speed projection)
|
||||
keep = {"--yes", "--no-start", "--family", "--model", "--context", "--vision", "--data-dir", "--gguf-dir", "--move-data",
|
||||
"--set-default-data-dir"}
|
||||
"--set-default-data-dir", "--feed", "--dsv41-package"} # (the last two: the DeepSeek engine package, 0.2.7.1)
|
||||
flags = ("--yes", "--no-start", "--move-data", "--set-default-data-dir")
|
||||
out, i = [], 0
|
||||
while i < len(args):
|
||||
|
||||
@@ -759,7 +759,8 @@ class MacCatalog(unittest.TestCase):
|
||||
def test_the_model_list_is_the_macs_sizes_with_unified_memory_verdicts(self):
|
||||
s, hw = self.hw(32)
|
||||
fams = s.model_table(hw)
|
||||
self.assertEqual([f["family"] for f in fams], ["qwen", "gyro"], "no Unsloth, Swift or NVFP4 on a Mac in the app; Gyro after the regular sizes")
|
||||
self.assertEqual([f["family"] for f in fams], ["qwen", "gyro", "deepseek41"],
|
||||
"no Unsloth, Swift or NVFP4 on a Mac in the app; Gyro after the regular sizes, DeepSeek (0.2.7.1) last")
|
||||
by = {x["model"]: x for x in fams[0]["sizes"]}
|
||||
self.assertEqual(list(by), ["Q2_0", "IQ3_XXS", "IQ3_S"])
|
||||
gy = {x["model"]: x for x in fams[1]["sizes"]}
|
||||
@@ -772,9 +773,29 @@ class MacCatalog(unittest.TestCase):
|
||||
self.assertTrue(by["IQ3_S"]["on_this_pc"].startswith("slow here"))
|
||||
self.assertTrue(all(x["images"] for x in by.values()), "the Mac engine carries the Metal picture reader: pictures are on")
|
||||
s, hw = self.hw(128)
|
||||
self.assertEqual({x["on_this_pc"] for f in s.model_table(hw) for x in f["sizes"]}, {"fits"})
|
||||
self.assertEqual({x["on_this_pc"] for f in s.model_table(hw) if f["family"] != "deepseek41" for x in f["sizes"]}, {"fits"})
|
||||
s, hw = self.hw(8)
|
||||
self.assertEqual({x["on_this_pc"] for f in s.model_table(hw) for x in f["sizes"]}, {"does not fit"})
|
||||
self.assertEqual({x["on_this_pc"] for f in s.model_table(hw) if f["family"] != "deepseek41" for x in f["sizes"]}, {"does not fit"})
|
||||
self.assertTrue(all(x["on_this_pc"].startswith("does not fit") for f in s.model_table(hw) if f["family"] == "deepseek41" for x in f["sizes"]))
|
||||
|
||||
def test_deepseek_on_a_mac_offers_the_two_sets_that_were_run_with_the_mac_words(self):
|
||||
s, hw = self.hw(128)
|
||||
ds = next(f for f in s.model_table(hw) if f["family"] == "deepseek41")
|
||||
by = {x["model"]: x for x in ds["sizes"]}
|
||||
self.assertEqual(list(by), ["IST-DAS-2.00bpw", "IST-DAS-2.25bpw"], "the 1.75 bpw set was never run on a Mac")
|
||||
for x in by.values():
|
||||
self.assertTrue(x["multi_file"] and not x["images"])
|
||||
self.assertTrue(x["on_this_pc"].startswith("runs on this Mac's memory"), x["on_this_pc"])
|
||||
self.assertIn("read from the SSD", x["on_this_pc"])
|
||||
self.assertGreater(x["disk_gb"], x["download_gb"])
|
||||
s, hw = self.hw(32)
|
||||
ds = next(f for f in s.model_table(hw) if f["family"] == "deepseek41")
|
||||
for x in ds["sizes"]: # a small Mac: said plainly, never refused
|
||||
self.assertTrue(x["on_this_pc"].startswith("slow here"), x["on_this_pc"])
|
||||
self.assertIn("can still be installed", x["on_this_pc"])
|
||||
from strata_cli.launch import catalog as C
|
||||
self.assertEqual(C.verdict(by["IST-DAS-2.00bpw"]["on_this_pc"])[0], C.FITS)
|
||||
self.assertEqual(C.verdict(ds["sizes"][0]["on_this_pc"])[0], C.TIGHT)
|
||||
|
||||
def test_the_install_plan_on_a_mac_has_no_card_kv_or_ram_options(self):
|
||||
s, hw = self.hw(32)
|
||||
|
||||
Reference in new issue
Block a user