Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

Own model files: a --model-path that is not there or holds no model is said in plain words before the engine or setup start (no 'missing /Qwen...gguf', no promise of a download), also in --plan and the screens

Niko12219dc1c963772a
diff --git a/strata_cli/launch/cmd.py b/strata_cli/launch/cmd.py
index 7abd7b791..365107923 100644
--- a/strata_cli/launch/cmd.py
+++ b/strata_cli/launch/cmd.py
@@ -559,6 +559,11 @@ def run_launch(a: argparse.Namespace) -> int:
return _tui(app.run_tui, None, catalog=catalog, feed=a.feed, open_page=bool(a.open))
if catalog is None:
return fail("This Terminal does not carry the model list. Install it again with the one-line installer.", 5)
+ runner = Runner(s, catalog=catalog, emit=_printer(machine), feed=a.feed, assume_yes=bool(a.yes or machine), confirm=_ask_yes)
+ try:
+ runner.check_own_files() # the person's own files: a wrong path is said now, and the files name the model
+ except LaunchError as e:
+ return fail(f"{e.text}" + (f" {e.next}" if e.next else ""), e.code)
s, notes = apply_defaults(s, catalog)
errors = [n for n in notes if n.level == "error"]
if errors:
@@ -569,8 +574,7 @@ def run_launch(a: argparse.Namespace) -> int:
if not s.name:
s.name = f"{s.model or 'model'} {S.context_label(s.context)}"
move_data = _move_data_choice(a, s, catalog, machine)
- runner = Runner(s, catalog=catalog, emit=_printer(machine), feed=a.feed, assume_yes=bool(a.yes or machine), confirm=_ask_yes,
- move_data=move_data)
+ runner.s, runner.move_data = s, move_data
if a.plan:
plan = runner.plan()
plan["warnings"] = [n.line() for n in notes]
diff --git a/strata_cli/launch/runner.py b/strata_cli/launch/runner.py
index 709675b84..9cc81c487 100644
--- a/strata_cli/launch/runner.py
+++ b/strata_cli/launch/runner.py
@@ -331,6 +331,7 @@ class Runner:
self.notices: list[str] = []
self.tune_result: dict | None = None
self.config_path: Path | None = None
+ self._own_checked = False
# ---- small helpers
def emit(self, stage: str, text: str, pct: float | None = None, level: str = "info", **data: Any) -> None:
@@ -625,8 +626,7 @@ class Runner:
def ensure_model(self) -> Path:
s, cat = self.s, self.catalog
- if s.model_path:
- self.resolve_own_files()
+ self.check_own_files()
self.resolved_vision()
if not (s.family and s.model):
raise LaunchError("No model was chosen.", "Choose a model, or use --model NAME (strata launch --help lists them).", 2)
@@ -641,7 +641,8 @@ class Runner:
adopted = self.adopt_prepared_files("no Mac model installer in this Terminal")
if adopted is not None:
return adopted
- self.emit("model", f"Getting {title} ready (a download may be large; it continues where it stopped if interrupted)…", 0)
+ self.emit("model", f"Preparing {title} from your model files…" if s.model_path else
+ f"Getting {title} ready (a download may be large; it continues where it stopped if interrupted)…", 0)
argv = [self.python, str(cat.src / "setup.py"), *self.setup_args()]
env = self._env()
env.update(STRATA_CONTROL_INSTALL="1", STRATA_INSTALL_DIR=str(cat.root), PYTHONNOUSERSITE="1")
@@ -695,7 +696,8 @@ class Runner:
if adopted is not None:
return adopted
raise LaunchError("The model could not be installed." + (f" {err}." if err else ""),
- hint or "Run it again: finished steps are skipped and a download continues where it stopped.", 6)
+ hint or ("Run it again: finished steps are skipped." if s.model_path else
+ "Run it again: finished steps are skipped and a download continues where it stopped."), 6)
path, _desc = self.installed_state()
if path is None:
raise LaunchError("Setup finished but no run config was written for this model.",
@@ -737,12 +739,22 @@ class Runner:
self.emit("model", f"Used your prepared model files and wrote the run settings ({path.name}); this card is not one the built-in downloader sets up.", 100, level="warn")
return path
+ def check_own_files(self) -> None:
+ """The person's own model files, looked at once: a path that is not there or holds no model is said in plain words first, and the
+ files are matched to the catalog model (resolve_own_files). Nothing else is done with a path that was already checked."""
+ if self.s.model_path and not self._own_checked:
+ self.resolve_own_files()
+ self._own_checked = True
+
def resolve_own_files(self) -> None:
""""Use model files I already have": the fingerprint table says which catalog model the files are, and which folder holds them (the
person may have named the folder above it). When the person also named the model (--model), the files are never refused here: setup
takes the files of that model out of the folder by name, as it always did (0.1.45), and says what is wrong when it cannot."""
from strata_control import models
s = self.s
+ problem = models.own_path_problem(s.model_path)
+ if problem: # before the engine or setup are touched, with the path as typed
+ raise LaunchError(problem[0], problem[1], 2)
given = bool(s.family and s.model)
try:
plan = models.plan_import(models.absolute(s.model_path))
@@ -760,7 +772,7 @@ class Runner:
sel = plan.get("candidate_selection") or {}
fam, model = sel.get("family"), sel.get("model")
if not (fam and model) or plan.get("issues"):
- issues = "; ".join(plain_issue(str(x)) for x in (plan.get("issues") or [])[:3]) or "they are not a model Strata knows"
+ issues = models.problem_words(plan.get("issues") or []) or "they are not a model Strata knows"
more = " " + next((m for m in plan.get("messages") or [] if "holds" in m), "")
raise LaunchError(f"These files cannot be used as they are ({issues}).{more.rstrip()}",
"Choose the matching model in the list, or check that every shard is in the folder.", 5)
@@ -941,6 +953,7 @@ class Runner:
def run(self, *, start: bool = True) -> Result:
try:
+ self.check_own_files() # a wrong --model-path is said before the engine is downloaded
self.ensure_engine()
self.check_cancel()
base = self.ensure_model()
diff --git a/strata_cli/launch/screens.py b/strata_cli/launch/screens.py
index f2ec0db7c..537309373 100644
--- a/strata_cli/launch/screens.py
+++ b/strata_cli/launch/screens.py
@@ -492,8 +492,11 @@ class ModelScreen(Base):
self.check_own(path)
def check_own(self, path: str) -> None:
- from strata_cli.launch.runner import plain_issue
from strata_control import models
+ problem = models.own_path_problem(path)
+ if problem:
+ self.say(f"{problem[0]} {problem[1]}", True)
+ return
try:
plan = models.plan_import(models.absolute(path))
except Exception as e: # noqa: BLE001
@@ -510,7 +513,7 @@ class ModelScreen(Base):
self.menu().select((sel["family"], sel["model"]))
self.paint()
else:
- why = "; ".join(plain_issue(str(x)) for x in (plan.get("issues") or [])[:3]) or "they are not a model Strata knows"
+ why = models.problem_words(plan.get("issues") or []) or "they are not a model Strata knows"
holds = next((m for m in plan.get("messages") or [] if "holds" in m), "")
self.say(f"These files cannot be used as they are ({why}). " + (holds + " " if holds else "") +
"Check that every shard is in the folder, or pick a model from the list.", True)
diff --git a/strata_control/models.py b/strata_control/models.py
index 74914ed28..a42d85393 100644
--- a/strata_control/models.py
+++ b/strata_control/models.py
@@ -339,6 +339,34 @@ def plain_issue(code: str) -> str:
return f"{name}: {words}" if name else words
+def problem_words(issues: list, limit: int = 3) -> str:
+ """The problems of a file set as ONE sentence part, each said once: the same reason for several files names the files together
+ ("a.gguf and b.gguf: the file is cut short"), a reason that was already given is not given again, and a long list is cut with a count.
+ A folder that holds several models does not also say "not a size Strata knows"."""
+ codes = [str(x) for x in issues or []]
+ if "multiple_model_groups" in codes:
+ codes = [x for x in codes if x != "unrecognized_or_unsupported_model_variant"]
+ by_reason: dict[str, list[str]] = {}
+ for code in codes:
+ words = plain_issue(code)
+ name, sep, reason = words.partition(": ")
+ if sep and name.lower().endswith(".gguf"):
+ by_reason.setdefault(reason, []).append(name)
+ else:
+ by_reason.setdefault(words, [])
+ parts = []
+ for reason, names in by_reason.items():
+ if not names:
+ parts.append(reason)
+ elif len(names) <= 2:
+ parts.append(f"{' and '.join(names)}: {reason}")
+ else:
+ parts.append(f"{names[0]}, {names[1]} and {len(names) - 2} more files: {reason}")
+ if len(parts) > limit:
+ parts = parts[:limit] + [f"and {len(parts) - limit} more problem" + ("s" if len(parts) - limit > 1 else "")]
+ return "; ".join(parts)
+
+
UNSUPPORTED_MODEL_TYPE = ("This model type isn't supported by the Strata engine. "
"Add it as a Custom model API (llama-server) instead.")
# The picture readers Strata ships a pinned copy of (setup downloads and checks one of these next to the model).
@@ -496,6 +524,30 @@ def import_target(picked: str, plan: dict) -> str:
return plan.get("model_dir") or picked
+def own_path_problem(picked: str) -> tuple[str, str] | None:
+ """(what is wrong, what to do) when the path a person gave for their own model files is not there or holds no model file, in plain
+ words; None when there is something to look at. Said before anything is installed or downloaded, with the path the person typed."""
+ path = Path(absolute(picked))
+ kind = "file" if path.name.lower().endswith(".gguf") else "folder"
+ try:
+ if not path.exists():
+ if path.is_symlink():
+ return (f"This {kind} is a shortcut to something that is not there any more: {path}.",
+ "Point it at the real folder, or at the .gguf file itself. Nothing was downloaded or changed.")
+ return (f"This {kind} does not exist: {path}.",
+ "Check the spelling, and that the drive or folder is connected (in Docker or a virtual machine it has to be shared with it). "
+ "Nothing was downloaded or changed.")
+ if path.is_dir():
+ has_files = any(entry.name.lower().endswith(".gguf") for entry in os.scandir(path))
+ if not has_files and not _folders_with_models(path):
+ return (f"There are no .gguf model files in {path}, nor in the folders inside it.",
+ "Point it at the folder that holds the model's .gguf files (names like ...-00001-of-00002.gguf), or at one of the files. "
+ "Nothing was downloaded or changed.")
+ except OSError:
+ return None
+ return None
+
+
def plan_import(raw_path: str) -> dict:
"""Inspect a local candidate without copying, parsing tensors or adopting it.
diff --git a/tests/terminal/test_launch.py b/tests/terminal/test_launch.py
index a6255e8d8..18fd91bd8 100644
--- a/tests/terminal/test_launch.py
+++ b/tests/terminal/test_launch.py
@@ -795,10 +795,16 @@ class FlagsCommand(unittest.TestCase):
self.assertEqual(p["settings"]["api_key"], "set")
def test_model_path_is_used_instead_of_a_catalog_model(self):
- p = self.plan("--model-path", "/data/models/IQ3_XXS")
- s = p["settings"]
- self.assertEqual(s["model_path"], str(Path("/data/models/IQ3_XXS")))
- self.assertIsNone(s["model"])
+ import tempfile
+ from tests.terminal.test_own_files import IQ3XXS, gguf_bytes
+ with tempfile.TemporaryDirectory() as tmp:
+ folder = Path(tmp) / "IQ3_XXS"
+ folder.mkdir()
+ for n in IQ3XXS:
+ (folder / n).write_bytes(gguf_bytes(["IQ3_XXS"]))
+ s = self.plan("--model-path", str(folder))["settings"]
+ self.assertEqual(s["model_path"], str(folder))
+ self.assertEqual((s["family"], s["model"]), ("qwen", "IQ3_XXS")) # the files say which model they are
def test_no_choices_and_no_terminal_does_not_start_anything(self):
with mock.patch.dict(os.environ, {"CI": "1"}), mock.patch.object(Runner, "run", side_effect=AssertionError("must not run")):
diff --git a/tests/terminal/test_launch_tui.py b/tests/terminal/test_launch_tui.py
index 003fb3055..e9b0a6f53 100644
--- a/tests/terminal/test_launch_tui.py
+++ b/tests/terminal/test_launch_tui.py
@@ -259,7 +259,7 @@ class ModelStep(Base):
async def case(app, pilot, ctx):
await press(pilot, "enter", "o")
self.assertIn("Type or paste the folder", text_of(app))
- with mock.patch("strata_control.models.plan_import", return_value=plan) as pi:
+ with mock.patch("strata_control.models.plan_import", return_value=plan) as pi, mock.patch("strata_control.models.own_path_problem", return_value=None):
await typed(pilot, "/data/models/IQ3_XXS")
await press(pilot, "enter")
self.assertEqual(ctx.settings.model_path, os.path.abspath("/data/models/IQ3_XXS"))
@@ -274,7 +274,7 @@ class ModelStep(Base):
async def case(app, pilot, ctx):
await press(pilot, "enter", "o")
- with mock.patch("strata_control.models.plan_import", return_value=plan):
+ with mock.patch("strata_control.models.plan_import", return_value=plan), mock.patch("strata_control.models.own_path_problem", return_value=None):
await typed(pilot, "/x")
await press(pilot, "enter")
t = flat(app)
@@ -283,6 +283,17 @@ class ModelStep(Base):
self.assertIsNone(ctx.settings.model_path)
self.run_app(case)
+ def test_own_files_folder_that_is_not_there_is_named(self):
+ async def case(app, pilot, ctx):
+ await press(pilot, "enter", "o")
+ await typed(pilot, "/no/such/folder")
+ await press(pilot, "enter")
+ t = flat(app)
+ self.assertIn("does not exist", t)
+ self.assertIn("Nothing was downloaded", t)
+ self.assertIsNone(ctx.settings.model_path)
+ self.run_app(case)
+
def test_own_files_path_from_the_start_screen(self):
async def case(app, pilot, ctx):
await press(pilot, "down", "enter")