Download size counts the draft layer and the picture reader; --plan no longer calls an installed engine missing; --drafting off writes no --mtp (TUI stress #6, B03, B10/E04)
#6 (A07/B03): a model that is not installed now counts the draft layer (5.2 GB) and the picture reader (0.9 GB) in the one place (modelstate.assess), so the Folder step, the confirm and --plan agree (Gyro-S 58.5 + 5.2 + 0.9 = 64.6 GB). Gyro joins the families that get the helpers. --mtp off and --drafting off drop the draft layer from the count and from what setup is told. setup.py's disk check counts the draft layer it is about to fetch. B03: --plan keeps "engine_missing" for no engine at all; an installed engine that fails the check says so in plain words and adds engine_usable. B10/E04: with --drafting off (or an installed config that says off) the written run config carries "mtp": false and no --mtp / --spec-min-p arguments.
This commit is contained in:
1 parent
c924d3c9d7
commit
eb818c50ed
6 files changed
+155
-15
No files matched your search
@@ -8610,7 +8610,8 @@ def main() -> int:
|
||||
prep_gb = MODELS[model].get("prepare_gb", 0.0) if ready and MODELS[model].get("prepare") and \
|
||||
not prepared_done(model, models_dir) else 0.0
|
||||
margin = 2 if mtp_have else 8 # working room: a guess, not bytes that will be written
|
||||
real = to_fetch + prep_gb + \
|
||||
mtp_fetch = 5.2 if (not mtp_have and not ready and a.mtp != "off") else 0.0 # the draft layer's tensors step 6 fetches (strata_control.discovery.MTP_FETCH_GB)
|
||||
real = to_fetch + prep_gb + mtp_fetch + \
|
||||
(40 if q2_avx and not pack_bin else 0) + (1 if vision != "none" else 0) + \
|
||||
(MODELS[model]["arena_gb"] + 1 if low_ram and not q2_avx and not pack_bin else 0)
|
||||
need = real + margin
|
||||
|
||||
@@ -108,7 +108,7 @@ class Ctx:
|
||||
from strata_cli.launch import modelstate
|
||||
s = self.settings
|
||||
return modelstate.assess(self.catalog, s.family, s.model, vision=s.vision, model_path=s.model_path,
|
||||
data_dir=data_dir if data_dir is not None else s.data_dir, rows=self.rows)
|
||||
data_dir=data_dir if data_dir is not None else s.data_dir, rows=self.rows, mtp=s.mtp, drafting=s.drafting)
|
||||
|
||||
def default_folder(self) -> Path:
|
||||
"""The folder the Folder step starts with: where the chosen model already is (installed, or the person's own files with their
|
||||
|
||||
@@ -76,6 +76,18 @@ class ModelState:
|
||||
"an interrupted download continues where it stopped.")
|
||||
|
||||
|
||||
#: The families whose setup also fetches the draft layer and the picture reader after the model (setup.py steps 5 and 6). NVFP4 packs bring
|
||||
#: theirs inside the download, Qwen3.6 has its own engine path.
|
||||
HELPER_FAMILIES = ("qwen", "swift", "coder", "unsloth", "gyro")
|
||||
|
||||
|
||||
def mtp_choice(mtp: str | None, drafting: str | None = None) -> str | None:
|
||||
"""The draft-layer choice setup is given: off when the person said --mtp off or --drafting off (nothing then uses the layer), else as chosen."""
|
||||
if str(drafting or "").strip().lower() == "off":
|
||||
return "off"
|
||||
return mtp
|
||||
|
||||
|
||||
def mmproj_name(catalog, family: str | None) -> str:
|
||||
try:
|
||||
_m, families, _c, _s = catalog.tables()
|
||||
@@ -92,10 +104,11 @@ def mmproj_name(catalog, family: str | None) -> str:
|
||||
|
||||
def assess(catalog, family: str | None, model: str | None, *, vision: str = "off", model_path: str | None = None,
|
||||
data_dir: str | Path | None = None, config: Path | None = None, desc: dict | None = None, rows: list | None = None,
|
||||
mtp: str | None = None) -> ModelState:
|
||||
mtp: str | None = None, drafting: str | None = None) -> ModelState:
|
||||
"""The state of `family model` for these choices. `config` / `desc` are the installed run config and its description (looked up when
|
||||
not given)."""
|
||||
st = ModelState()
|
||||
mtp = mtp_choice(mtp, drafting)
|
||||
row = next((r for r in (rows if rows is not None else catalog.rows()) if r.family == family and r.model == model), None) if (family and model) else None
|
||||
st.total_gb = float(row.download_gb) if row else 0.0
|
||||
wants_pictures = vision != "off" and (row is None or row.images)
|
||||
@@ -151,9 +164,25 @@ def assess(catalog, family: str | None, model: str | None, *, vision: str = "off
|
||||
pass
|
||||
st.on_disk_gb = got / 1e9
|
||||
st.parts.append(Part("weights", "the model", max(st.total_gb - st.on_disk_gb, 0.0)))
|
||||
if family in HELPER_FAMILIES:
|
||||
# setup fetches the draft layer and the picture reader after the model, so the question and the disk check count them too
|
||||
if mtp != "off" and not (base / "mtp" / "rt" / "experts.bin").is_file():
|
||||
st.parts.append(Part("mtp", "the draft layer", MTP_FETCH_GB))
|
||||
if wants_pictures and not _has_reader(base):
|
||||
st.parts.append(Part("mmproj", "the picture reader", MMPROJ_GB))
|
||||
return st
|
||||
|
||||
|
||||
def _has_reader(base: Path) -> bool:
|
||||
for folder in (base / "models", base / "Models"):
|
||||
try:
|
||||
if any(folder.glob("mmproj*.gguf")):
|
||||
return True
|
||||
except OSError:
|
||||
pass
|
||||
return False
|
||||
|
||||
|
||||
def _first_gguf(path: Path) -> Path | None:
|
||||
try:
|
||||
if path.is_file():
|
||||
|
||||
+21
-11
@@ -27,6 +27,7 @@ from pathlib import Path
|
||||
from typing import Any, Callable
|
||||
|
||||
from strata_cli.launch import access as acc
|
||||
from strata_cli.launch import modelstate
|
||||
from strata_cli.launch import settings as S
|
||||
from strata_cli.launch.catalog import Catalog, CatalogUnavailable
|
||||
|
||||
@@ -365,8 +366,10 @@ def derive_config(base: dict, s: S.LaunchSettings, *, bool_flags: frozenset[str]
|
||||
if log:
|
||||
cfg["log"] = log
|
||||
apply_cards(cfg, gpus)
|
||||
if s.mtp == "off": # no draft layer for this launch (serve/server.py applies "mtp": false at every start)
|
||||
from strata_control import draft_layer
|
||||
from strata_control import drafting as _drafting
|
||||
drafting_off = _drafting.normalize(s.drafting if s.drafting is not None else cfg.get("drafting")) == "off"
|
||||
if s.mtp == "off" or drafting_off: # no draft layer for this launch (serve/server.py applies "mtp": false at every start)
|
||||
from strata_control import draft_layer # --drafting off: the written file carries no --mtp either (it was left in before)
|
||||
cfg["mtp"] = False
|
||||
draft_layer.apply(cfg)
|
||||
elif s.mtp == "on":
|
||||
@@ -699,8 +702,9 @@ class Runner:
|
||||
args += ["--kv", s.kv]
|
||||
if fam in ("qwen", "coder"):
|
||||
args += ["--experimental-speed-projection", "off"]
|
||||
if s.mtp in ("on", "off") and fam in ("qwen", "swift", "coder", "unsloth"):
|
||||
args += ["--mtp", s.mtp] # round 8, N3: "--mtp off" never reached setup, which then fetched the 5.2 GB draft layer
|
||||
mtp_word = modelstate.mtp_choice(s.mtp, s.drafting)
|
||||
if mtp_word in ("on", "off") and fam in modelstate.HELPER_FAMILIES:
|
||||
args += ["--mtp", mtp_word] # round 8, N3: "--mtp off" never reached setup, which then fetched the 5.2 GB draft layer
|
||||
data = s.data_dir or self.existing_data_dir()
|
||||
if data:
|
||||
args += ["--data-dir", str(data)]
|
||||
@@ -793,7 +797,7 @@ class Runner:
|
||||
if s.family and s.model and not s.model_path:
|
||||
path, desc = self.installed_state()
|
||||
return modelstate.assess(self.catalog, s.family, s.model, vision=s.vision, model_path=s.model_path, data_dir=s.data_dir,
|
||||
config=path, desc=desc, mtp=s.mtp)
|
||||
config=path, desc=desc, mtp=s.mtp, drafting=s.drafting)
|
||||
|
||||
def download_gb(self) -> float:
|
||||
"""How much would be downloaded for this launch right now: 0 when everything is on disk (the model is installed with these choices
|
||||
@@ -1294,7 +1298,7 @@ class Runner:
|
||||
st = self.model_state()
|
||||
parts = [{"kind": p.kind, "label": p.label, "gb": round(p.gb, 1)} for p in st.parts if p.gb >= 0.05] # a part already on disk is not a download
|
||||
row = self.row()
|
||||
helpers = s.family in ("qwen", "swift", "coder", "unsloth")
|
||||
helpers = s.family in modelstate.HELPER_FAMILIES
|
||||
wants_pictures = s.vision not in (None, "off") and row is not None and bool(row.images)
|
||||
if helpers and (st.own_files or not st.installed):
|
||||
# a model that is not set up yet (or the person's own files) comes without the draft layer and the picture reader: setup fetches them
|
||||
@@ -1302,7 +1306,7 @@ class Runner:
|
||||
have = {p["kind"] for p in parts}
|
||||
try:
|
||||
data = Path(st.folder) if st.folder else (Path(s.data_dir) if s.data_dir else (self.existing_data_dir() or self.catalog.data_dir()))
|
||||
if s.mtp != "off" and "mtp" not in have and not (data / "mtp" / "rt" / "experts.bin").is_file():
|
||||
if modelstate.mtp_choice(s.mtp, s.drafting) != "off" and "mtp" not in have and not (data / "mtp" / "rt" / "experts.bin").is_file():
|
||||
parts.append({"kind": "mtp", "label": "the draft layer", "gb": MTP_FETCH_GB})
|
||||
places = [data / "models", data / "Models"]
|
||||
if s.model_path: # setup uses a reader that sits with the person's own files (setup.py --gguf-dir)
|
||||
@@ -1328,9 +1332,11 @@ class Runner:
|
||||
# said "nothing to download" and setup then asked for 129 GB): count what setup will fetch
|
||||
parts = [p for p in parts if p["kind"] != "weights"] + [{"kind": "weights", "label": "the ready-made pack", "gb": gap["gb"]}]
|
||||
gb = round(sum(p["gb"] for p in parts), 1)
|
||||
engine = True
|
||||
engine, here = True, []
|
||||
try:
|
||||
engine = bool(engine_component.status(Path(self.components_dir) if self.components_dir else None).get("usable"))
|
||||
report = engine_component.status(Path(self.components_dir) if self.components_dir else None)
|
||||
engine = bool(report.get("usable"))
|
||||
here = [str(i.get("version")) for i in report.get("installed") or [] if i.get("version")]
|
||||
except Exception: # noqa: BLE001 - the plan must not fail on this
|
||||
pass
|
||||
if gb < 0.05:
|
||||
@@ -1354,9 +1360,13 @@ class Runner:
|
||||
text += " To skip the draft layer (a little slower, less memory), add --mtp off."
|
||||
if any(p["kind"] == "dflash2" for p in parts):
|
||||
text += " To skip the DFlash2 drafter, add --drafting mtp."
|
||||
if not engine:
|
||||
if not engine and here:
|
||||
# B03: an engine IS installed, but this plan cannot use it (its signature cannot be checked here, or it is for another card): not "missing"
|
||||
text += (f" An engine ({', '.join(here[:3])}) is installed, but it did not pass Strata's check on this computer, so Strata looks for a working one "
|
||||
"first. `strata components engine` says why.")
|
||||
elif not engine:
|
||||
text += " The engine for your graphics card is downloaded first (from the update source; its size is shown when it starts)."
|
||||
return {"gb": gb, "parts": parts, "engine_missing": not engine, "own_files": st.own_files, "text": text}
|
||||
return {"gb": gb, "parts": parts, "engine_missing": not engine and not here, "engine_usable": engine, "own_files": st.own_files, "text": text}
|
||||
|
||||
def ready_pack_gap(self) -> dict | None:
|
||||
"""For a ready-made pack family (NVFP4): what setup would still fetch into its models folder for these choices, {gb, folder, free_gb}, or None."""
|
||||
|
||||
@@ -315,7 +315,7 @@ class FolderStep(Base):
|
||||
await press(pilot, "enter", "enter")
|
||||
t = text_of(app)
|
||||
self.assertIn("Where should the model files be stored?", t)
|
||||
self.assertIn("Not downloaded yet: about 84 GB", t)
|
||||
self.assertIn("Not downloaded yet: about 90 GB", t)
|
||||
self.assertIn("Free space in that folder's drive", t)
|
||||
f = app.screen.query_one("#folderpath")
|
||||
f.value = ""
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
"""0.2.3 RC stress test: #6 (A07/B03) the download size counts the draft layer and the picture reader, B03 `--plan` does not call an installed
|
||||
engine missing, B10/E04 `--drafting off` leaves `--mtp <path>` out of the written config."""
|
||||
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
from strata_cli.launch import modelstate, settings as S
|
||||
from strata_cli.launch.runner import Runner, derive_config
|
||||
from strata_control import engine_component
|
||||
from tests.terminal.launch_support import HW_12, Home, catalog
|
||||
|
||||
|
||||
class DownloadSize(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.home = Home().__enter__()
|
||||
self.addCleanup(self.home.__exit__, None, None, None)
|
||||
|
||||
def runner(self, **kw):
|
||||
values = dict(family="gyro", model="Gyro-S", context=32768, vision="cpu")
|
||||
values.update(kw)
|
||||
return Runner(S.LaunchSettings(**values), catalog=catalog(HW_12))
|
||||
|
||||
def test_gyro_s_counts_the_model_the_draft_layer_and_the_picture_reader(self):
|
||||
runner = self.runner()
|
||||
state = runner.model_state()
|
||||
self.assertEqual([p.kind for p in state.parts], ["weights", "mtp", "mmproj"])
|
||||
self.assertAlmostEqual(state.remaining_gb, 58.5 + 5.2 + 0.9, places=1)
|
||||
title, text = runner.download_question()
|
||||
self.assertEqual(title, "Download about 65 GB?")
|
||||
plan = runner.download_plan()
|
||||
self.assertEqual([p["kind"] for p in plan["parts"]], ["weights", "mtp", "mmproj"])
|
||||
self.assertAlmostEqual(plan["gb"], 64.6, places=1)
|
||||
self.assertIn("the draft layer (5.2 GB)", plan["text"])
|
||||
|
||||
def test_what_the_person_turns_off_is_not_counted(self):
|
||||
self.assertEqual([p.kind for p in self.runner(vision="off").model_state().parts], ["weights", "mtp"])
|
||||
self.assertEqual([p.kind for p in self.runner(mtp="off").model_state().parts], ["weights", "mmproj"])
|
||||
self.assertEqual([p.kind for p in self.runner(drafting="off").model_state().parts], ["weights", "mmproj"])
|
||||
self.assertAlmostEqual(self.runner(vision="off", mtp="off").model_state().remaining_gb, 58.5, places=1)
|
||||
|
||||
def test_the_other_families_that_get_helpers_count_the_same(self):
|
||||
for family, model in (("qwen", "Q2_0"), ("swift", "IQ2_XS"), ("coder", "IQ3_XXS")):
|
||||
kinds = [p.kind for p in self.runner(family=family, model=model).model_state().parts]
|
||||
self.assertEqual(kinds, ["weights", "mtp", "mmproj"], family)
|
||||
|
||||
def test_setup_is_told_the_draft_layer_is_off_for_drafting_off(self):
|
||||
args = self.runner(drafting="off").setup_args()
|
||||
self.assertEqual(args[args.index("--mtp") + 1], "off")
|
||||
self.assertTrue(modelstate.HELPER_FAMILIES.count("gyro"))
|
||||
|
||||
|
||||
class PlanEngine(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.home = Home().__enter__()
|
||||
self.addCleanup(self.home.__exit__, None, None, None)
|
||||
|
||||
def plan(self, report):
|
||||
runner = Runner(S.LaunchSettings(family="gyro", model="Gyro-S", context=32768, vision="off"), catalog=catalog(HW_12))
|
||||
with mock.patch.object(engine_component, "status", return_value=report):
|
||||
return runner.download_plan()
|
||||
|
||||
def test_an_engine_that_is_installed_but_unusable_is_not_called_missing(self):
|
||||
out = self.plan({"usable": False, "installed": [{"version": "0.1.48"}], "notice": "x"})
|
||||
self.assertIs(out["engine_missing"], False)
|
||||
self.assertIs(out["engine_usable"], False)
|
||||
self.assertIn("An engine (0.1.48) is installed", out["text"])
|
||||
self.assertNotIn("downloaded first", out["text"])
|
||||
|
||||
def test_no_engine_at_all_is_missing_and_a_usable_one_is_neither(self):
|
||||
out = self.plan({"usable": False, "installed": []})
|
||||
self.assertIs(out["engine_missing"], True)
|
||||
self.assertIn("downloaded first", out["text"])
|
||||
ok = self.plan({"usable": True, "installed": [{"version": "0.1.48"}]})
|
||||
self.assertEqual((ok["engine_missing"], ok["engine_usable"]), (False, True))
|
||||
|
||||
|
||||
class DraftingOffConfig(unittest.TestCase):
|
||||
BASE = {"exe": "component:strata-engine", "port": 8080, "model_name": "m", "env": {},
|
||||
"args": ["--native", "x.gguf", "--spec", "4", "--spec-min-p", "0.5", "--mtp", "/m/rt"]}
|
||||
|
||||
def test_drafting_off_writes_no_mtp_path(self):
|
||||
cfg = derive_config(self.BASE, S.LaunchSettings(drafting="off"), bool_flags=frozenset())
|
||||
self.assertIs(cfg["mtp"], False)
|
||||
self.assertEqual(cfg["drafting"], "off")
|
||||
for flag in ("--mtp", "--spec-min-p"):
|
||||
self.assertNotIn(flag, cfg["args"])
|
||||
self.assertIn("--mtp", self.BASE["args"])
|
||||
|
||||
def test_auto_and_mtp_keep_the_draft_layer(self):
|
||||
for mode in ("auto", "mtp", None):
|
||||
cfg = derive_config(self.BASE, S.LaunchSettings(drafting=mode), bool_flags=frozenset())
|
||||
self.assertIn("--mtp", cfg["args"], mode)
|
||||
|
||||
def test_an_installed_config_that_already_says_off_stays_off(self):
|
||||
cfg = derive_config({**self.BASE, "drafting": "off"}, S.LaunchSettings(), bool_flags=frozenset())
|
||||
self.assertNotIn("--mtp", cfg["args"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user