DeepSeek card rule shared by the plan, the options and setup: every card that counts, one AMD card on Windows, only cards the engine package has code for, an APU beside a discrete card left out

This commit is contained in:
Niko1221 committed 2026-10-31 02:56:19 +01:00
1 parent 5322f1c2bd
commit f93ec8a924
3 files changed
+62 -15

No files matched your search

+51 -14
View File
@@ -23,6 +23,8 @@ import platform
import sys
from typing import Any
import os
from strata_control import gpu_fit
GB = 1e9
@@ -107,6 +109,46 @@ def variant(model: str | None) -> dict | None:
return next((v for k, v in ISTA_SETS.items() if k.lower() == str(model).lower()), None)
#: The AMD cards the DeepSeek engine package holds code for (packaging/build_hip_linux.sh: strata-dsv41 ships in the rx9070 build, gfx1200 and
#: gfx1201). setup passes the installed package's own list when it has one.
DSV41_HIP_ARCHS = ("gfx1200", "gfx1201")
def _on_windows() -> bool:
return os.name == "nt"
def run_cards(cards: list[dict] | None, vendor: str | None = None, *, windows: bool | None = None,
covered=None, named: bool = False) -> tuple[list[dict], list[dict]]:
"""The cards one DeepSeek run uses when the person named none: (cards, left out with 'why_ignored'), in card order. The ONE rule that
`strata launch --plan`, setup and the app share, so the plan says what the run does.
Every card that counts (gpu_fit.usable_cards: no integrated chip beside a card with memory of its own, no card under 8 GB). AMD:
on Windows one card only (several AMD cards sharing a model is Linux-only, setup.py), and only cards the engine package holds code for
(`covered`, default DSV41_HIP_ARCHS): a PC with an RX 9070 and an RX 7900 uses the RX 9070 and says why the other is left out.
`named`: the person named these cards: they are used as named (setup warns about one the package has no code for)."""
mine = gpu_fit.for_vendor(list(cards or []), vendor)[0] if vendor else list(cards or [])
keep, ignored = gpu_fit.usable_cards(mine)
small = [c for c in keep if float(c.get("vram_gb") or 0) < SMALLEST_CARD_GB]
keep = [c for c in keep if float(c.get("vram_gb") or 0) >= SMALLEST_CARD_GB]
ignored = list(ignored) + [{**c, "why_ignored": f"only {float(c.get('vram_gb') or 0):.0f} GB of graphics memory"} for c in small]
amd = not named and bool(keep) and all(str(c.get("vendor") or vendor or "").lower() == "amd" for c in keep)
if amd:
archs = tuple(covered if covered is not None else DSV41_HIP_ARCHS)
known = [c for c in keep if c.get("arch")]
ok = [c for c in keep if not c.get("arch") or c["arch"] in archs]
if known and ok and len(ok) < len(keep):
ignored += [{**c, "why_ignored": f"the DeepSeek engine has no code for {c['arch']} (it runs on {', '.join(archs)})"}
for c in keep if c not in ok]
keep = ok
if (_on_windows() if windows is None else windows) and len(keep) > 1:
first = min(keep, key=lambda c: (-round(float(c.get("vram_gb") or 0)), c.get("index", 0)))
ignored += [{**c, "why_ignored": "on Windows a model runs on one AMD card"} for c in keep if c is not first]
keep = [first]
keep = sorted(keep, key=lambda c: c.get("index", 0))
return keep, ignored
def uma_card(cards: list[dict] | None) -> dict | None:
"""The integrated Radeon a run uses, when the graphics memory is the PC's RAM (Ryzen AI Max, gfx1151): setup marks it `uma` (and
`integrated`); a discrete card never is. None on every other computer."""
@@ -201,14 +243,12 @@ def _tp_args(n_cards: int, tp: int) -> list[str]:
def _plan_ista(model: str, cards: list[dict] | None, ram_gb: float | None, disk_free_gb: float | None, context: int,
vendor: str | None) -> dict[str, Any]:
vendor: str | None, named: bool = False) -> dict[str, Any]:
"""plan() for an official IST-DAS set (ISTA_SETS): the same keys, the measured speeds in plain words. RAM classes: with RAM for every
expert the CPU lane keeps ("fits"), with 40 GB or more the engine's RAM store keeps the hot experts and reads the rest from the SSD
("tight": measured 4.7 tokens a second on 64 GB, 7.2 on 46 GB), under 40 GB it is untested and slower ("spills"). Never a refusal."""
v = variant(model)
keep, ignored = gpu_fit.usable_cards(gpu_fit.for_vendor(list(cards or []), vendor)[0]) if vendor else gpu_fit.usable_cards(list(cards or []))
keep = [c for c in keep if float(c.get("vram_gb") or 0) >= SMALLEST_CARD_GB]
keep.sort(key=lambda c: c.get("index", 0))
keep, ignored = run_cards(cards, vendor, named=named)
n = len(keep)
expert_gb = v["experts_gb"] / EXPERTS
set_gb = v["set_bytes"] / GB
@@ -353,7 +393,7 @@ def _plan_uma(key: str, model: str, card: dict, ram_gb: float | None, disk_free_
def plan(cards: list[dict] | None, ram_gb: float | None, disk_free_gb: float | None = None, context: int = 8192,
vendor: str | None = None, model: str | None = None) -> dict[str, Any]:
vendor: str | None = None, model: str | None = None, named: bool = False) -> dict[str, Any]:
"""Where the model goes on this computer. `cards`: the graphics cards ({"index", "name", "vram_gb", ...}, as gpu_fit takes them),
`ram_gb` the RAM, `disk_free_gb` the free space where the files go (None: not checked). `model`: an official IST-DAS set
(ISTA_SETS: "IST-DAS-2.00bpw" / "IST-DAS-2.25bpw" / "IST-DAS-1.75bpw") gets its own numbers; None or "UD-Q8_K_XL" is Unsloth's 508 GB set.
@@ -368,13 +408,11 @@ def plan(cards: list[dict] | None, ram_gb: float | None, disk_free_gb: float | N
if mac is not None and variant_key(model) in MAC_SET_PACK:
return _plan_mac(variant_key(model), model, mac, ram_gb, disk_free_gb, context)
mine = gpu_fit.for_vendor(list(cards or []), vendor)[0] if vendor else list(cards or [])
card = uma_card(mine)
card = uma_card(gpu_fit.usable_cards(mine)[0]) # an APU beside a card with memory of its own does not count (setup leaves it out too)
if card is not None:
return _plan_uma(variant_key(model), model, card, ram_gb, disk_free_gb, context)
return _plan_ista(variant_key(model), cards, ram_gb, disk_free_gb, context, vendor)
keep, ignored = gpu_fit.usable_cards(gpu_fit.for_vendor(list(cards or []), vendor)[0]) if vendor else gpu_fit.usable_cards(list(cards or []))
keep = [c for c in keep if float(c.get("vram_gb") or 0) >= SMALLEST_CARD_GB]
keep.sort(key=lambda c: c.get("index", 0)) # the engine takes the layers in card order
return _plan_ista(variant_key(model), cards, ram_gb, disk_free_gb, context, vendor, named)
keep, ignored = run_cards(cards, vendor, named=named) # the engine takes the layers in card order
n = len(keep)
out: dict[str, Any] = {"cards": [], "experts_total": EXPERTS, "experts_in_vram": 0, "vram_experts_gb": 0.0,
"cpu_experts_gb": EXPERTS_GB, "weights_gb": _round1(WEIGHTS_GB), "experts_gb": _round1(EXPERTS_GB),
@@ -490,16 +528,15 @@ def _option(key: str, cards: list[dict], ram_gb: float | None, ctx: int, vendor:
def options(cards: list[dict], ram_gb: float | None, vendor: str | None = None, context: int = 8192, model: str | None = None) -> dict[str, Any]:
"""gpu_fit.options for this model: every card that counts (recommended: the model is bigger than any one card, so each card adds
experts that stay off the CPU), and the largest card alone. Same keys as gpu_fit.options."""
mine, others = gpu_fit.for_vendor(list(cards or []), vendor) if vendor else (list(cards or []), [])
keep, ignored = gpu_fit.usable_cards(mine)
keep = [c for c in keep if float(c.get("vram_gb") or 0) >= SMALLEST_CARD_GB]
keep, ignored = run_cards(cards, vendor) # the same cards `strata launch --plan` and setup use (Windows: one AMD card; the package's own archs)
out: dict[str, Any] = {"options": [], "recommended": None, "ignored": ignored, "cards": len(keep), "vendor": vendor,
"other_vendor_note": gpu_fit.other_vendor_note(list(cards or []), vendor)}
if not keep:
return out
opts = [_option("all", sorted(keep, key=lambda c: c.get("index", 0)), ram_gb, context, vendor, model)]
if len(keep) > 1:
opts.append(_option("single", [keep[0]], ram_gb, context, vendor, model))
largest = min(keep, key=lambda c: (-round(float(c.get("vram_gb") or c.get("unified_gb") or 0)), c.get("index", 0)))
opts.append(_option("single", [largest], ram_gb, context, vendor, model))
opts[0]["recommended"] = True
out["options"], out["recommended"] = opts, "all"
return out
+1 -1
View File
@@ -1371,7 +1371,7 @@ class Strata:
cards = list((hw or {}).get("gpus", []))
if only:
cards = [c for c in cards if int(c.get("index", -1)) in {int(i) for i in only}]
return dsv41_fit.plan(cards, (hw or {}).get("ram_gb"), disk_free, vendor=(hw or {}).get("engine_vendor"), model=model)
return dsv41_fit.plan(cards, (hw or {}).get("ram_gb"), disk_free, vendor=(hw or {}).get("engine_vendor"), model=model, named=bool(only))
def dsv41_words(self, hw, model=None, installed: bool = False) -> str:
"""The catalog's `on_this_pc` text for DeepSeek-V4.1-Flash, with the disk it needs (download and preparation) beside the memory: a set that
+10
View File
@@ -77,6 +77,11 @@ class Entries(unittest.TestCase):
class Fit(unittest.TestCase):
def setUp(self): # the AMD rules below are the Linux ones, whatever box the test runs on
p = mock.patch.object(dsv41_fit, "_on_windows", lambda: False)
p.start()
self.addCleanup(p.stop)
def test_the_numbers_of_the_model(self):
self.assertAlmostEqual(dsv41_fit.WEIGHTS_GB, 305.6, delta=0.1)
self.assertAlmostEqual(dsv41_fit.EXPERTS_GB, 288.8, delta=0.1)
@@ -301,6 +306,11 @@ class Install(unittest.TestCase):
class Catalog(unittest.TestCase):
def setUp(self): # the AMD rules below are the Linux ones, whatever box the test runs on
p = mock.patch.object(dsv41_fit, "_on_windows", lambda: False)
p.start()
self.addCleanup(p.stop)
def test_the_mcp_catalog_lists_the_size(self):
import strata_mcp as M
s = M.Strata(ROOT)