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++
launch: one rule for DeepSeek's speed. Nothing is passed to the engine unless the person chose (its --experts auto decides: 5 at 16 GiB of cards or less); the 'default on this PC' words use the same 16 GiB rule summed over the cards the launch uses, and the summary reads the engine's own 'experts per word: N' line back; tests follow
Niko1221c4413c0b544b
diff --git a/docs/DEEPSEEK41.md b/docs/DEEPSEEK41.mdindex a6041d6a5..0854c731c 100644--- a/docs/DEEPSEEK41.md+++ b/docs/DEEPSEEK41.md@@ -90,7 +90,7 @@ Not in this version: several requests at once (`--parallel` is ignored with a wa## Speed: Faster or Full quality-DeepSeek picks 6 experts for every word it writes. **Faster** uses 5 of them (engine flag `--experts 5`): a small quality change, usually not noticeable, and answers come sooner. It is the default on a PC with 16 GB of graphics memory or less. **Full quality** uses all 6 (`--experts 6`).+DeepSeek picks 6 experts for every word it writes. **Faster** uses 5 of them (engine flag `--experts 5`): a small quality change, usually not noticeable, and answers come sooner. It is the default on a PC whose graphics cards total 16 GiB or less: the engine decides that itself (`--experts auto`), and Strata passes `--experts` only when you choose. **Full quality** uses all 6 (`--experts 6`).In `strata launch` the guided screens have a Speed step for DeepSeek; with flags use `--speed faster|full`, or `--full-quality` in scripts. `strata launch --plan` shows which one this PC gets.diff --git a/strata_cli/launch/catalog.py b/strata_cli/launch/catalog.pyindex ef943d2cd..9f8e9359c 100644--- a/strata_cli/launch/catalog.py+++ b/strata_cli/launch/catalog.py@@ -151,11 +151,6 @@ class Computer:"If something fails, start again with --vision off to turn pictures off, and tell us at https://github.com/Niko1221/Strata/issues (say it is a B-series card and attach the engine log).")return None- @property- def total_vram_gb(self) -> float:- """The graphics memory of all the cards that can be used together."""- return sum(float(g.get("vram_gb") or 0) for g in self.usable_gpus)-@propertydef main_vram_gb(self) -> float:return max((float(g.get("vram_gb") or 0) for g in self.usable_gpus), default=0.0)diff --git a/strata_cli/launch/cmd.py b/strata_cli/launch/cmd.pyindex 97834ddcf..99b49a2d8 100644--- a/strata_cli/launch/cmd.py+++ b/strata_cli/launch/cmd.py@@ -839,9 +839,12 @@ def run_launch(a: argparse.Namespace) -> int:from strata_cli.launch import access_say(f" {'API key':<14} {access.mask_key(result.key)} (show it: strata launch --show-key"+ (f" --preset \"{s.name}\")" if (a.preset or a.save_preset) else ")"))- speed_line = runner.speed_line() if hasattr(runner, "speed_line") else ""- if speed_line and not isinstance(speed_line, str):- speed_line = ""+ speed_line = ""+ if hasattr(runner, "speed_line"):+ from strata_cli.launch.runner import experts_from_log+ speed_line = runner.speed_line(experts_from_log(_engine_log_of(result.config) or None))+ if not isinstance(speed_line, str):+ speed_line = ""if speed_line:_say(f" {'Speed':<14} {speed_line.replace('Speed: ', '', 1)}")engine_log = _engine_log_of(result.config)diff --git a/strata_cli/launch/runner.py b/strata_cli/launch/runner.pyindex 11ccfa7c7..0f5e65469 100644--- a/strata_cli/launch/runner.py+++ b/strata_cli/launch/runner.py@@ -398,6 +398,33 @@ def cards_for_launch(s: S.LaunchSettings, catalog, ram_gb: float | None = None,return None+def used_vram_gb(computer, s: "S.LaunchSettings") -> float:+ """Graphics memory (GiB) of the cards this launch uses, summed as the engine sums it: the cards named (--gpu, the Cards step; a role other than+ off), else every card that can be used."""+ cards = list(computer.usable_gpus)+ chosen = None+ if s.gpu_roles:+ chosen = {int(k) for k, v in s.gpu_roles.items() if str(v) != "off"}+ elif s.gpus:+ chosen = {int(g) for g in s.gpus}+ if chosen is not None:+ cards = [c for c in cards if int(c.get("index", 0)) in chosen]+ return sum(float(c.get("vram_gb") or 0) for c in cards)+++EXPERTS_LINE = re.compile(r"experts per word: (\d+)")+++def experts_from_log(path) -> int | None:+ """The engine's own answer, read back from its startup line "experts per word: N" (the last one in the log), None when it is not there."""+ try:+ data = Path(path).read_bytes()[-262144:].decode("utf-8", "replace")+ except (OSError, TypeError, ValueError):+ return None+ found = EXPERTS_LINE.findall(data)+ return int(found[-1]) if found else None++def apply_experts(cfg: dict, experts: int | None) -> None:"""DeepSeek's speed choice as the engine flag: --experts 5 (Faster) or --experts 6 (Full quality), replacing one already in the saved args."""if experts is None or not isinstance(cfg.get("args"), list):@@ -1921,12 +1948,12 @@ class Runner:return outdef resolved_speed(self) -> tuple[str, bool] | None:- """DeepSeek's speed: ("faster" | "full", whether it is the default for this PC); None for any other model. Faster is the default on a PC- with 16 GB of graphics memory or less."""+ """DeepSeek's speed: ("faster" | "full", whether it is the default for this PC); None for any other model. The default is the engine's own+ rule (`--experts auto`: 5 when the cards used total 16 GiB or less); only an explicit choice is written as --experts."""if not self.multi_file():return Nonetry:- default = S.faster_default(self.catalog.computer().total_vram_gb)+ default = S.faster_default(used_vram_gb(self.catalog.computer(), self.s))except Exception: # noqa: BLE001 - when the cards cannot be read, the engine's own default standsdefault = Falseif self.s.speed in S.SPEED_MODES:@@ -1934,15 +1961,20 @@ class Runner:return ("faster" if default else "full"), Truedef experts_flag(self) -> int | None:- """The value of the engine's --experts for this launch (5 or 6), None for a model that has no such choice."""- speed = self.resolved_speed()- return None if speed is None else (5 if speed[0] == "faster" else 6)+ """The engine's --experts for this launch: 5 or 6 only when the person chose; None (nothing is passed, the engine's `--experts auto`+ decides) when they did not, and for a model that has no such choice."""+ if self.resolved_speed() is None or self.s.speed not in S.SPEED_MODES:+ return None+ return 5 if self.s.speed == "faster" else 6- def speed_line(self) -> str:- """The speed line of --plan and of the summary, in plain words, with the quality note when it is Faster."""+ def speed_line(self, engine_experts: int | None = None) -> str:+ """The speed line of --plan and of the summary, in plain words, with the quality note when it is Faster. `engine_experts`: what the+ running engine said at its start ("experts per word: N"); it wins over the rule above, so the words are always the engine's."""speed = self.resolved_speed()if speed is None:return ""+ if engine_experts is not None and not self.s.speed:+ speed = ("faster" if engine_experts < 6 else "full", True)text = "Speed: " + S.speed_words(speed[0], speed[1])return text + (". " + S.FASTER_NOTE if speed[0] == "faster" else "")diff --git a/strata_cli/launch/screens.py b/strata_cli/launch/screens.pyindex c2bfa4134..b1ebdf0fe 100644--- a/strata_cli/launch/screens.py+++ b/strata_cli/launch/screens.py@@ -1033,14 +1033,15 @@ class PicturesScreen(Base):class SpeedScreen(Base):step_id = "speed"help_text = ("DeepSeek picks 6 experts for every word it writes. Faster uses 5 of them: answers come sooner, with a small quality change that is "- "usually not noticeable. Full quality uses all 6. Faster is the default on a PC with 16 GB of graphics memory or less.")+ "usually not noticeable. Full quality uses all 6. Faster is the default on a PC whose graphics cards total 16 GB or less (the engine decides the same way).")def body(self) -> ComposeResult:yield Static(Text("Speed or full quality?", style=f"bold {ACCENT}"), markup=False)yield Menu(id="menu")def default_faster(self) -> bool:- return S.faster_default(self.ctx.computer.total_vram_gb)+ from strata_cli.launch.runner import used_vram_gb+ return S.faster_default(used_vram_gb(self.ctx.computer, self.ctx.settings))def on_mount(self) -> None:s = self.ctx.settings@@ -1531,10 +1532,11 @@ class SaveScreen(Base):def summary_lines(self) -> list[tuple[str, str]]:s = self.ctx.settingsr = next((x for x in self.ctx.rows if (x.family, x.model) == (s.family, s.model)), None)+ from strata_cli.launch.runner import used_vram_gblines = [("Model", (r.title if r else (s.model or "?")) + (" (your files)" if s.model_path else "")),("Context", S.context_label(s.context) + f", memory {s.kv or 'int8'}"),("Pictures", "on" if s.vision != "off" else "off"),- *([("Speed", S.speed_words(s.speed or ("faster" if S.faster_default(self.ctx.computer.total_vram_gb) else "full"),+ *([("Speed", S.speed_words(s.speed or ("faster" if S.faster_default(used_vram_gb(self.ctx.computer, s)) else "full"),s.speed is None))] if s.family == "deepseek41" else []),("Parallel", f"{s.parallel} at a time" if s.parallel else f"fit to your card ({S.fit_parallel(self.ctx.computer.main_vram_gb)})"),("Tuning", ({"quick": "quick (about 5-10 min)", "thorough": "thorough (about 10-15 min)", "skip": "skipped"} if s.family == "deepseek41"diff --git a/strata_cli/launch/settings.py b/strata_cli/launch/settings.pyindex 92b088df8..d653098e7 100644--- a/strata_cli/launch/settings.py+++ b/strata_cli/launch/settings.py@@ -29,13 +29,14 @@ MTP_MODES = ("on", "off")#: strata_control/drafting.py MODES (tests/terminal/test_drafting.py keeps the two the same)DRAFTING_MODES = ("auto", "mtp", "dflash2", "off")SPEED_MODES = ("faster", "full") # DeepSeek: 5 experts per word (Faster) or all 6 (Full quality)-FASTER_VRAM_GB = 16.5 # Faster is the default on a PC with this much graphics memory or less (the owner's 0.2.4.3 decision)+FASTER_VRAM_GIB = 16.0 # the engine's rule (src/dsv41/ds4_experts_rule.hpp): `--experts auto` is 5 when the cards used total 16 GiB or lessFASTER_NOTE = "Faster uses 5 of 6 experts per word: a small quality change, usually not noticeable."def faster_default(total_vram_gb: float | None) -> bool:- """Faster is the default on a PC with 16 GB of graphics memory or less, in all (the cards that can be used together)."""- return bool(total_vram_gb) and float(total_vram_gb) <= FASTER_VRAM_GB+ """Mirrors the engine's `--experts auto`: Faster (5 experts) when the cards the launch uses total 16 GiB (17,179,869,184 bytes) or less.+ The engine decides at its start; this only says the same thing in the screens and in --plan, so the two never disagree."""+ return bool(total_vram_gb) and float(total_vram_gb) <= FASTER_VRAM_GIBdef speed_words(speed: str, default: bool) -> str:diff --git a/tests/terminal/test_launch_speed.py b/tests/terminal/test_launch_speed.pyindex 557f8d6bb..5d902b06f 100644--- a/tests/terminal/test_launch_speed.py+++ b/tests/terminal/test_launch_speed.py@@ -9,7 +9,7 @@ from unittest import mockfrom strata_cli.launch import settings as Sfrom strata_cli.launch.app import LaunchApp-from strata_cli.launch.runner import Runner, apply_experts, derive_config+from strata_cli.launch.runner import Runner, apply_experts, derive_config, experts_from_log, used_vram_gbfrom strata_cli.launch.screens import SpeedScreen, flow_forfrom tests.terminal import test_launch as TLfrom tests.terminal.launch_support import Home, text_of@@ -20,9 +20,9 @@ run_cli = TL.run_cliclass Words(unittest.TestCase):def test_the_default_is_faster_up_to_16_gb_of_graphics_memory(self):- for gb in (8, 12, 15.9, 16, 16.4):+ for gb in (8, 12, 15.9, 16.0): # the engine's rule: 16 GiB or less (17,179,869,184 bytes)self.assertTrue(S.faster_default(gb), gb)- for gb in (20, 24, 48, 0, None):+ for gb in (16.01, 16.4, 20, 24, 48, 0, None):self.assertFalse(S.faster_default(gb), gb)def test_plain_words_and_the_quality_note(self):@@ -57,23 +57,51 @@ class EngineFlag(unittest.TestCase):class Resolve(unittest.TestCase):- def runner(self, vram_gb, **kw):+ def runner(self, *cards, **kw):cat = mock.Mock()cat.strata.multi_family.return_value = True- cat.computer.return_value = mock.Mock(total_vram_gb=vram_gb)+ gpus = [{"index": i, "vram_gb": gb} for i, gb in enumerate(cards)]+ cat.computer.return_value = mock.Mock(usable_gpus=gpus)return Runner(S.LaunchSettings(family="deepseek41", model="IST-DAS-2.00bpw", **kw), catalog=cat, emit=lambda e: None)- def test_a_12_gb_pc_gets_faster_and_a_big_one_full_quality_by_default(self):+ def test_a_12_gb_pc_gets_faster_and_a_big_one_full_quality_in_the_words(self):self.assertEqual(self.runner(12).resolved_speed(), ("faster", True))- self.assertEqual(self.runner(12).experts_flag(), 5)self.assertEqual(self.runner(96).resolved_speed(), ("full", True))- self.assertEqual(self.runner(96).experts_flag(), 6)+ self.assertEqual(self.runner(8, 8).resolved_speed(), ("faster", True)) # summed over the cards, as the engine sums them+ self.assertEqual(self.runner(12, 12).resolved_speed(), ("full", True))- def test_a_choice_wins_over_the_default(self):- self.assertEqual(self.runner(12, speed="full").resolved_speed(), ("full", False))+ def test_nothing_is_passed_to_the_engine_unless_the_person_chose(self):+ for cards in ((12,), (96,), (8, 8)):+ self.assertIsNone(self.runner(*cards).experts_flag(), cards) # the engine's --experts auto decides: one ruleself.assertEqual(self.runner(12, speed="full").experts_flag(), 6)self.assertEqual(self.runner(96, speed="faster").experts_flag(), 5)+ def test_a_choice_wins_over_the_default_in_the_words(self):+ self.assertEqual(self.runner(12, speed="full").resolved_speed(), ("full", False))++ def test_only_the_cards_the_launch_uses_are_summed(self):+ comp = mock.Mock(usable_gpus=[{"index": 0, "vram_gb": 12}, {"index": 1, "vram_gb": 24}])+ self.assertEqual(used_vram_gb(comp, S.LaunchSettings()), 36)+ self.assertEqual(used_vram_gb(comp, S.LaunchSettings(gpus=[0])), 12)+ self.assertEqual(used_vram_gb(comp, S.LaunchSettings(gpu_roles={"0": "main", "1": "off"})), 12)++ def test_the_engines_own_line_wins_in_the_summary(self):+ r = self.runner(12)+ self.assertIn("Faster (default on this PC)", r.speed_line(5))+ self.assertIn("Full quality (default on this PC)", r.speed_line(6)) # the engine said 6 although the rule here said Faster+ self.assertIn("Full quality: all 6 experts per word", self.runner(12, speed="full").speed_line(5)) # a choice stays what was chosen++ def test_the_number_is_read_back_from_the_engine_log(self):+ import tempfile+ from pathlib import Path+ with tempfile.TemporaryDirectory() as d:+ log = Path(d) / "e.log"+ log.write_text("ds4: loading\nds4: experts per word: 6\nlater\nds4: experts per word: 5\n", encoding="utf-8")+ self.assertEqual(experts_from_log(log), 5)+ log.write_text("nothing here\n", encoding="utf-8")+ self.assertIsNone(experts_from_log(log))+ self.assertIsNone(experts_from_log(Path(d) / "missing.log"))+def test_the_line_has_the_note_only_for_faster(self):self.assertIn(S.FASTER_NOTE, self.runner(12).speed_line())self.assertIn("Faster (default on this PC)", self.runner(12).speed_line())@@ -138,6 +166,7 @@ class Screen(unittest.TestCase):def test_the_screen_offers_two_choices_and_remembers_only_a_change(self):ctx = make_ctx()ctx.settings.family, ctx.settings.model = "deepseek41", "IST-DAS-2.00bpw"+ faster_here = S.faster_default(used_vram_gb(ctx.computer, ctx.settings))app = LaunchApp(ctx)async def go():@@ -152,7 +181,7 @@ class Screen(unittest.TestCase):screen = app.screenself.assertIsInstance(screen, SpeedScreen)screen.commit()- self.assertEqual(ctx.settings.speed, None if S.faster_default(ctx.computer.total_vram_gb) else "faster")+ self.assertEqual(ctx.settings.speed, None if faster_here else "faster")await press(pilot, "down")screen.commit()self.assertIn(ctx.settings.speed, (None, "full"))