launch --plan: names the model your files are (title, size, picture setting, a copyable line with --model) instead of placeholders, and says what would be downloaded and how big (0 when everything is here, the draft layer and picture reader counted, engine mentioned)

This commit is contained in:
Niko1221 committed 2026-10-20 15:55:39 +02:00
1 parent 226b5f5492
commit fd4f7d445c
4 files changed
+137 -4

No files matched your search

+11 -2
View File
@@ -30,6 +30,9 @@ examples:
"""
PICTURE_WORDS = {"off": "off", "on": "on", "cpu": "on (the reader runs on the processor)", "gpu": "on (the reader runs on the graphics card)"}
def _choice(label: str, options: tuple[str, ...]):
def convert(value: str) -> str:
v = str(value).strip().lower()
@@ -582,8 +585,14 @@ def run_launch(a: argparse.Namespace) -> int:
print(json.dumps({"schema_version": 1, "ok": True, "plan": plan}))
else:
_say(f"Plan for '{s.name}':")
_say(f" model {s.family} {s.model}" if s.model else f" model your files at {s.model_path}")
_say(f" context {S.context_label(s.context)} pictures {s.vision} parallel {s.parallel or 'fit to your card'}")
m = plan.get("model") or {}
size = f", {m['model_gb']:.0f} GB" if m.get("model_gb") else ""
if s.model_path:
_say(f" model {m.get('title') or 'your model files'}{size} (your files in {s.model_path})")
else:
_say(f" model {m.get('title') or f'{s.family} {s.model}'}{size}")
_say(f" context {S.context_label(s.context)} pictures {PICTURE_WORDS.get(s.vision or 'off', s.vision)} parallel {s.parallel or 'fit to your card'}")
_say(f" download {(plan.get('download') or {}).get('text', '')}")
_say(f" tuning {s.tune} access {S.ACCESS_WORDS[s.access]}, port {s.port}"
+ (" API key on" if s.api_key else ""))
for n in notes:
+69 -1
View File
@@ -945,11 +945,79 @@ class Runner:
return tunnel
# ---- all of it
def row(self):
"""The catalog row of the chosen model (None for a model the list does not carry)."""
s = self.s
return next((r for r in self.catalog.rows() if (r.family, r.model) == (s.family, s.model)), None)
def download_plan(self) -> dict:
"""What this launch would download, in numbers and words (nothing is changed): the model's missing files, and for a model that is
not on this computer yet also the draft layer and the picture reader that setup fetches after it. 0 when everything is here."""
from strata_control import engine_component
from strata_control.discovery import MMPROJ_GB, MTP_FETCH_GB
s = self.s
st = self.model_state()
parts = [{"kind": p.kind, "label": p.label, "gb": round(p.gb, 1)} for p in st.parts]
fresh = any(p.kind == "weights" for p in st.parts) and not st.own_files
row = self.row()
helpers = s.family in ("qwen", "swift", "coder", "unsloth")
wants_pictures = s.vision not in (None, "off") and row is not None and bool(row.images)
have = {p["kind"] for p in parts}
if fresh and helpers:
if s.mtp != "off":
parts.append({"kind": "mtp", "label": "the draft layer", "gb": MTP_FETCH_GB})
if wants_pictures:
parts.append({"kind": "mmproj", "label": "the picture reader", "gb": MMPROJ_GB})
elif st.own_files and helpers:
# the person's files come with no draft layer or picture reader: setup fetches them next to the prepared data, unless they are there
try:
data = Path(st.folder) if st.folder 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():
parts.append({"kind": "mtp", "label": "the draft layer", "gb": MTP_FETCH_GB})
if wants_pictures and "mmproj" not in have and not list((data / "models").glob("mmproj*.gguf")):
parts.append({"kind": "mmproj", "label": "the picture reader", "gb": MMPROJ_GB})
except OSError:
pass
gb = round(sum(p["gb"] for p in parts), 1)
engine = True
try:
engine = bool(engine_component.status(Path(self.components_dir) if self.components_dir else None).get("usable"))
except Exception: # noqa: BLE001 - the plan must not fail on this
pass
if gb < 0.05:
text = ("Nothing to download: your model files are used where they are." if st.own_files
else "Nothing to download: the model is already on this computer.")
else:
names = [f"{p['label']} ({p['gb']:.1f} GB)" for p in parts]
what = names[0] if len(names) == 1 else ", ".join(names[:-1]) + " and " + names[-1]
text = f"About {gb:.1f} GB to download: {what}."
if st.on_disk_gb >= 1:
text += f" {st.on_disk_gb:.0f} GB of the model is already in its folder."
if st.own_files:
text += " Your model files are used where they are."
if 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}
def plan(self) -> dict:
s = self.s
self.check_own_files()
warns = [n.line() for n in (*S.check_access(s),)]
row = self.row()
try:
self.resolved_vision()
except Exception: # noqa: BLE001
pass
try:
download = self.download_plan()
except Exception: # noqa: BLE001 - a plan that cannot count the download still shows the rest
download = {"gb": None, "parts": [], "engine_missing": None, "own_files": bool(s.model_path),
"text": "How much would be downloaded could not be worked out here."}
title = row.title if row is not None else (f"{s.family} {s.model}" if s.model else None)
model = {"title": title, "family": s.family, "model": s.model, "model_gb": row.download_gb if row is not None else None,
"own_files": bool(s.model_path), "folder": s.model_path}
return {"profile": self.profile, "settings": s.to_dict(with_key=False), "warnings": warns,
"flags": S.flags_text(s), "steps": list(STAGES)}
"flags": S.flags_text(s), "steps": list(STAGES), "model": model, "download": download}
def run(self, *, start: bool = True) -> Result:
try:
+1 -1
View File
@@ -270,7 +270,7 @@ def flags_text(s: LaunchSettings, *, preset: str | None = None) -> str:
else:
if s.model_path:
parts.append(f'--model-path "{s.model_path}"')
elif s.model:
if s.model: # own files the table recognised say which model they are, so the line stays exact
parts.append(f"--model {s.model.lower()}" + (f" --family {s.family}" if s.family and s.family != "qwen" else ""))
if s.data_dir:
parts.append(f'--data-dir "{s.data_dir}"')
+56
View File
@@ -156,5 +156,61 @@ class LinkedShards(Base):
class PlanWords(Base):
"""Findings 1 and 7: --plan shows the real model, the picture setting, a copyable line, and what would be downloaded."""
def plan_text(self, *args):
code, out, err = run_cli(["launch", "--plan", *args])
self.assertEqual(code, 0, err or out)
return out
def test_own_files_show_the_model_they_are(self):
folder = self.files(self.base / "IQ3_XXS", IQ3XXS, "IQ3_XXS")
out = self.plan_text("--model-path", str(folder))
self.assertIn("Plan for 'IQ3_XXS", out)
self.assertNotIn("model default", out)
self.assertNotIn("None", out)
self.assertIn("Qwen3.8-Flash-Next IQ3_XXS", out)
self.assertIn(f"your files in {folder}", out)
self.assertRegex(out, r"pictures (on|off)")
self.assertIn("--model iq3_xxs", out.split("same as")[1]) # the copyable line names the model too
self.assertIn(f'--model-path "{folder}"', out.split("same as")[1])
def test_a_named_catalog_model_shows_its_size_and_the_download(self):
out = self.plan_text("--model", "q2_0")
self.assertIn("Qwen3.8-Flash-Next Q2_0, 66 GB", out)
self.assertRegex(out, r"download\s+About 7\d\.\d GB to download: the model \(66\.4 GB\), the draft layer \(5\.2 GB\)")
self.assertIn("The engine for your graphics card is downloaded first", out)
def test_nothing_is_downloaded_when_everything_is_here(self):
folder = self.files(self.base / "IQ3_XXS", IQ3XXS, "IQ3_XXS")
data = self.base / "Strata"
(data / "models" / "x").mkdir(parents=True)
(data / "mtp" / "rt").mkdir(parents=True)
(data / "mtp" / "rt" / "experts.bin").write_bytes(b"x")
(data / "models" / "mmproj-Qwen3.8-Flash-Next-BF16.gguf").write_bytes(b"x")
# the files sit under <data>/models/<tag>: the draft layer and the picture reader are found beside them
moved = data / "models" / "iq3_xxs"
folder.rename(moved)
out = self.plan_text("--model-path", str(moved))
self.assertIn("download Nothing to download: your model files are used where they are.", out)
def test_own_files_with_no_draft_layer_say_what_is_fetched(self):
folder = self.files(self.base / "IQ3_XXS", IQ3XXS, "IQ3_XXS")
with mock.patch.object(Runner, "existing_data_dir", return_value=None), mock.patch.object(Catalog, "data_dir", return_value=self.base / "emptydata"):
out = self.plan_text("--model-path", str(folder), "--vision", "off")
self.assertIn("About 5.2 GB to download: the draft layer (5.2 GB). Your model files are used where they are.", out)
def test_json_plan_carries_the_numbers(self):
code, out, err = run_cli(["launch", "--plan", "--output", "json", "--model", "q2_0", "--mtp", "off", "--vision", "off"])
self.assertEqual(code, 0, err)
plan = json.loads(out)["plan"]
self.assertEqual(plan["model"]["title"], "Qwen3.8-Flash-Next Q2_0")
self.assertEqual(plan["model"]["model_gb"], 66.4)
self.assertEqual(plan["download"]["gb"], 66.4)
self.assertEqual([p["kind"] for p in plan["download"]["parts"]], ["weights"])
if __name__ == "__main__":
unittest.main()