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++
Terminal and the shared speed-switch table: Faster long prompts (Qwen KVA) is OFF by default, STRATA_KVA=1 turns it on
Niko1221ae03ef632360
diff --git a/strata_cli/launch/params.py b/strata_cli/launch/params.pyindex 011864078..93da4021d 100644--- a/strata_cli/launch/params.py+++ b/strata_cli/launch/params.py@@ -127,11 +127,11 @@ def env_params() -> list[Param]:def switch_params(applicable: list[Any]) -> list[Param]:- """The rows of the speed switches that apply to this launch (strata_control/speed_switches.py): the environment each one writes when it is off,- shown as "on" until the person types the off value. The same three features as the app's Expert settings."""+ """The rows of the speed switches that apply to this launch (strata_control/speed_switches.py): the environment each one writes outside its default,+ shown as the default ("off" for Faster long prompts, "on" for the others) until the person types the value. The same features as the app's Expert settings."""from strata_control import speed_switches as sw- return [Param(name=name, kind="env", description=sw.env_words(name), help_default="on", full=sw.env_words(name))- for switch in applicable for name, _ in switch.off]+ return [Param(name=name, kind="env", description=sw.env_words(name), help_default=switch.default, full=sw.env_words(name))+ for switch in applicable for name, _ in switch.env]def argv_to_dict(argv: list[Any]) -> dict[str, str]:diff --git a/strata_control/speed_switches.py b/strata_control/speed_switches.pyindex 6b2125592..029022f64 100644--- a/strata_control/speed_switches.py+++ b/strata_control/speed_switches.py@@ -1,12 +1,16 @@-"""The three speed features that are on by default in 0.2.7, and the off switch each one has.+"""The speed features of 0.2.7 that have a switch in the app's Expert settings and in the Terminal's Advanced table.-Each switch, when off, writes exactly the engine environment below into the model's run config ("env"); turning it on again removes those entries,-so a default launch carries none of them and is byte for byte what 0.2.6 started. The names are the engine switch contract-(phaseA-tests/notes-027-plan.md). The app does the same in apps/host/server/native-settings.mjs (SPEED_SWITCHES); tests/terminal/test_speed_switches.py+A switch has a default (``on`` or ``off``). In its other state it writes exactly the engine environment below into the model's run config ("env"); back in+its default it removes those entries, so a default launch carries none of them and is byte for byte what 0.2.6 started. The names are the engine switch+contract (phaseA-tests/notes-027-plan.md). The app does the same in apps/host/server/native-settings.mjs (SPEED_SWITCHES); tests/terminal/test_speed_switches.pyreads that file and fails when the two disagree, so the Terminal and the app cannot drift apart.-The Terminal shows the switches as rows of its Advanced table (strata_cli/launch/params.py), only where they apply: ``strata launch --set STRATA_KVA=0``-turns "Faster long prompts" off, ``--set STRATA_KVA=off`` puts the default back (the same as removing the row).+- "Faster long prompts" (Qwen KVA) is OFF by default (owner decision, 26 October): ``STRATA_KVA=1`` turns it on. A file that holds ``STRATA_KVA=0`` (the+ off switch of an earlier 0.2.7 test build) reads as off, which is what it is now.+- "Faster answers on Radeon RX 9000 / AI PRO R9700" and "DeepSeek speed-ups" are ON by default; turning them off writes their entries.++The Terminal shows the switches as rows of its Advanced table (strata_cli/launch/params.py), only where they apply: ``strata launch --set STRATA_KVA=1``+turns "Faster long prompts" on, ``--set STRATA_KVA=off`` puts the default back (the same as removing the row)."""from __future__ import annotations@@ -20,15 +24,16 @@ from typing import Any, Iterable, Mappingclass Switch:id: strlabel: str # the words the app shows- effect: str # one plain sentence: what it does and what turning it off does- off: tuple[tuple[str, str], ...] # the environment entries written when it is off+ effect: str # one plain sentence: what it does and what the other choice does+ env: tuple[tuple[str, str], ...] # the environment entries written when the switch is NOT in its default stateonly: str # "qwen-gpu" | "qwen-radeon-9000" | "deepseek": where it applies+ default: str = "on" # "on" | "off": what a launch without the entries doesSWITCHES: tuple[Switch, ...] = (Switch("faster_long_prompts", "Faster long prompts",- "Reads long prompts faster by approximating part of the work. Turn off if answers about long documents look wrong.",- (("STRATA_KVA", "0"),), "qwen-gpu"),+ "Reads very long prompts faster by approximating part of the work. Off by default: answers about long documents can miss or mix up details.",+ (("STRATA_KVA", "1"),), "qwen-gpu", default="off"),Switch("faster_radeon_9000", "Faster answers on Radeon RX 9000 / AI PRO R9700","Shares the work between the graphics card and the processor in a way that makes answers faster on these cards. ""Turn off to go back to the previous setting, which is slower.",@@ -81,32 +86,42 @@ def applicable(cfg: Mapping[str, Any] | None, gpus: Iterable[Mapping[str, Any]]return [s for s in SWITCHES if applies(s, cfg, gpus, backend)]-def is_off(env: Mapping[str, Any] | None, switch: Switch | str) -> bool:- """Off only when every entry the switch writes is there with its value; a file with only some of them reads as on and is left alone."""+def is_set(env: Mapping[str, Any] | None, switch: Switch | str) -> bool:+ """Every entry the switch writes is there with its value (the switch is out of its default). A file with only some of them, or other values+ (``STRATA_KVA=0``), is in the default state and is left alone."""+ sw = BY_ID[switch] if isinstance(switch, str) else switch+ return all((env or {}).get(name) == value for name, value in sw.env)+++def is_on(env: Mapping[str, Any] | None, switch: Switch | str) -> bool:+ """Is the feature on for a launch with this environment?"""sw = BY_ID[switch] if isinstance(switch, str) else switch- return all((env or {}).get(name) == value for name, value in sw.off)+ return is_set(env, sw) != (sw.default == "on")def set_switch(env: Mapping[str, Any] | None, switch: Switch | str, on: bool) -> dict[str, Any]:- """The environment with the switch on (its entries removed) or off (its entries written). Nothing else in it changes."""+ """The environment with the feature on or off: the default state removes the switch's entries, the other one writes them. Nothing else changes."""sw = BY_ID[switch] if isinstance(switch, str) else switchout = dict(env or {})- for name, value in sw.off:- if on:- out.pop(name, None)- else:+ write = on != (sw.default == "on")+ for name, value in sw.env:+ if write:out[name] = value+ else:+ out.pop(name, None)return outdef env_names() -> dict[str, Switch]:"""Every environment name a switch writes -> its switch."""- return {name: sw for sw in SWITCHES for name, _ in sw.off}+ return {name: sw for sw in SWITCHES for name, _ in sw.env}def env_words(name: str) -> str:"""The plain sentence of one environment row of the Terminal's Advanced table."""sw = env_names()[name]- value = dict(sw.off)[name]- together = f"; all {len(sw.off)} speed-up rows go together" if len(sw.off) > 1 else ""+ value = dict(sw.env)[name]+ together = f"; all {len(sw.env)} speed-up rows go together" if len(sw.env) > 1 else ""+ if sw.default == "off":+ return f"{sw.label} (off by default; set {value} to turn on{together}). {sw.effect}"return f"{sw.label} (on by default; set {value} to turn off{together}). {sw.effect}"diff --git a/tests/terminal/test_speed_switches.py b/tests/terminal/test_speed_switches.pyindex 0aa78bf3a..01cc2eacb 100644--- a/tests/terminal/test_speed_switches.py+++ b/tests/terminal/test_speed_switches.py@@ -1,8 +1,8 @@-"""The three 0.2.7 speed features are on by default and have an off switch: the contract names, where each applies, and how the Terminal carries them.+"""The 0.2.7 speed features and their switches: the contract names, the defaults (Faster long prompts OFF, the other two ON), where each applies, and how the Terminal carries them.The app (apps/host/server/native-settings.mjs SPEED_SWITCHES) and Control (strata_control/speed_switches.py) say the same thing; the last test reads theapp's table with node and fails when the two differ. `strata launch` shows the environment entries as rows of its Advanced table and writes them into-the run config's "env" (`--set STRATA_KVA=0`); a default launch has none of them.+the run config's "env" (`--set STRATA_KVA=1` turns Faster long prompts on); a default launch has none of them."""from __future__ import annotations@@ -19,12 +19,13 @@ from strata_control import speed_switches as WROOT = Path(__file__).resolve().parents[2]-OFF = {- "faster_long_prompts": {"STRATA_KVA": "0"},+ENV = { # what each switch writes outside its default+ "faster_long_prompts": {"STRATA_KVA": "1"},"faster_radeon_9000": {"STRATA_PCIE_FRAC_DEFAULT": "old"},"deepseek_speedups": {"DS4_FAST_ATTN": "0", "DS4_ATTN_SLAB": "0", "DS4_COPY_PIN": "0", "DS4_COPY_HUGETLB": "0","DS4_STORE_SPARE": "0", "DS4_STORE_PUT": "0"},}+DEFAULT = {"faster_long_prompts": "off", "faster_radeon_9000": "on", "deepseek_speedups": "on"}R9700 = {"name": "AMD Radeon AI PRO R9700", "vendor": "amd", "arch": "gfx1201"}RX7900 = {"name": "AMD Radeon RX 7900 XTX", "vendor": "amd", "arch": "gfx1100"}STRIX = {"name": "AMD Radeon 8060S", "vendor": "amd", "arch": "gfx1151", "uma": True}@@ -38,16 +39,17 @@ def ids(cfg, gpus, backend=None):class Contract(unittest.TestCase):- def test_three_switches_with_the_contract_names(self):- self.assertEqual([s.id for s in W.SWITCHES], list(OFF))+ def test_three_switches_with_the_contract_names_and_their_defaults(self):+ self.assertEqual([s.id for s in W.SWITCHES], list(ENV))for s in W.SWITCHES:- self.assertEqual(dict(s.off), OFF[s.id], s.id)+ self.assertEqual(dict(s.env), ENV[s.id], s.id)+ self.assertEqual(s.default, DEFAULT[s.id], s.id)- def test_an_effect_text_says_what_turning_it_off_does_in_plain_words(self):+ def test_an_effect_text_says_what_the_feature_does_in_plain_words(self):for s in W.SWITCHES:- self.assertRegex(s.effect, r"[Tt]urn off", s.id)+ self.assertRegex(s.effect, r"Off by default" if s.default == "off" else r"[Tt]urn off", s.id)self.assertNotRegex(s.effect, r"STRATA_|DS4_|--|env", s.id)- self.assertEqual(W.SWITCHES[0].effect, "Reads long prompts faster by approximating part of the work. Turn off if answers about long documents look wrong.")+ self.assertEqual(W.SWITCHES[0].effect, "Reads very long prompts faster by approximating part of the work. Off by default: answers about long documents can miss or mix up details.")def test_where_each_switch_applies(self):self.assertEqual(ids(QWEN, [RTX]), ["faster_long_prompts"])@@ -63,16 +65,24 @@ class Contract(unittest.TestCase):self.assertEqual(ids({**DEEPSEEK, "backend": "cuda"}, [RTX]), ["deepseek_speedups"])self.assertEqual(ids({"exe": "C:/x/strata-dsv41.exe"}, [RTX]), ["deepseek_speedups"], "found by the engine's name too")- def test_off_and_on_again_is_the_identical_environment(self):+ def test_outside_the_default_and_back_is_the_identical_environment(self):env = {"PATH": "/bin", "STRATA_PREFILL": "2", "DS4_ASYNC_T": "4"}for s in W.SWITCHES:- off = W.set_switch(env, s, False)- self.assertEqual(off, {**env, **OFF[s.id]})- self.assertTrue(W.is_off(off, s))- back = W.set_switch(off, s, True)+ other = W.set_switch(env, s, s.default != "on") # KVA on, the other two off+ self.assertEqual(other, {**env, **ENV[s.id]})+ self.assertTrue(W.is_set(other, s))+ self.assertEqual(W.is_on(other, s), s.default != "on")+ back = W.set_switch(other, s, s.default == "on")self.assertEqual(json.dumps(back), json.dumps(env), s.id)- self.assertFalse(W.is_off({"DS4_FAST_ATTN": "0"}, "deepseek_speedups"), "only some of the entries reads as on")- self.assertFalse(W.is_off({"STRATA_KVA": "1"}, "faster_long_prompts"))++ def test_kva_is_off_by_default_and_an_earlier_builds_zero_shows_as_off(self):+ self.assertFalse(W.is_on({}, "faster_long_prompts"))+ self.assertTrue(W.is_on({"STRATA_KVA": "1"}, "faster_long_prompts"))+ self.assertFalse(W.is_on({"STRATA_KVA": "0"}, "faster_long_prompts"), "stored by the old off switch: harmless, and Off is what it is now")+ self.assertFalse(W.is_on({"STRATA_KVA": "yes"}, "faster_long_prompts"), "only 1 turns it on")+ self.assertEqual(W.set_switch({"PATH": "/bin", "STRATA_KVA": "0"}, "faster_long_prompts", False), {"PATH": "/bin"}, "choosing Off cleans it up")+ self.assertTrue(W.is_on({}, "deepseek_speedups"))+ self.assertTrue(W.is_on({"DS4_FAST_ATTN": "0"}, "deepseek_speedups"), "only some of the entries reads as the default (on)")class Terminal(unittest.TestCase):@@ -89,8 +99,8 @@ class Terminal(unittest.TestCase):self.assertEqual(env, base["env"], "the environment is exactly the installed one")self.assertEqual(json.dumps(self.config(base), sort_keys=True), json.dumps(self.config(base, {}), sort_keys=True))- def test_each_switch_off_by_set_gives_exactly_its_entries(self):- for sid, entries in OFF.items():+ def test_each_switch_outside_its_default_by_set_gives_exactly_its_entries(self):+ for sid, entries in ENV.items(): # --set STRATA_KVA=1 turns KVA on; the other two are turned off by their entriesbase = DEEPSEEK if sid == "deepseek_speedups" else QWENcfg = self.config(base, S.settings_from_pairs([f"{k}={v}" for k, v in entries.items()]))self.assertEqual(cfg["env"], {**base["env"], **entries}, sid)@@ -99,8 +109,10 @@ class Terminal(unittest.TestCase):def test_off_again_puts_the_default_back(self):cfg = self.config(QWEN, S.settings_from_pairs(["STRATA_KVA=off"]))self.assertEqual(cfg["env"], QWEN["env"])- already = {**QWEN, "env": {**QWEN["env"], "STRATA_KVA": "0"}}- self.assertEqual(self.config(already, S.settings_from_pairs(["STRATA_KVA=off"]))["env"], QWEN["env"])+ turned_on = {**QWEN, "env": {**QWEN["env"], "STRATA_KVA": "1"}}+ self.assertEqual(self.config(turned_on, S.settings_from_pairs(["STRATA_KVA=off"]))["env"], QWEN["env"])+ old = {**QWEN, "env": {**QWEN["env"], "STRATA_KVA": "0"}}+ self.assertEqual(self.config(old, S.settings_from_pairs(["STRATA_KVA=off"]))["env"], QWEN["env"])def test_the_advanced_table_lists_only_the_switches_that_apply(self):def names(cfg, gpus, extra=None):@@ -108,37 +120,42 @@ class Terminal(unittest.TestCase):return [r.name for r in rows if r.name in W.env_names()]self.assertEqual(names(QWEN, [RTX]), ["STRATA_KVA"])self.assertEqual(names({**QWEN, "backend": "hip"}, [R9700]), ["STRATA_KVA", "STRATA_PCIE_FRAC_DEFAULT"])- self.assertEqual(names(DEEPSEEK, [R9700]), list(OFF["deepseek_speedups"]), "the six, in the contract order")+ self.assertEqual(names(DEEPSEEK, [R9700]), list(ENV["deepseek_speedups"]), "the six, in the contract order")self.assertEqual(names({**QWEN, "backend": "sycl"}, [R9700]), [])- def test_a_row_says_on_until_it_is_turned_off_and_explains_itself(self):+ def test_a_row_shows_its_default_until_it_is_changed_and_explains_itself(self):rows = P.build_rows(None, QWEN["args"], None, QWEN["env"], None, {}, P.switch_params(W.applicable(QWEN, [RTX])))row = next(r for r in rows if r.name == "STRATA_KVA")- self.assertEqual((row.name, row.default, row.tuned, row.yours, row.known), ("STRATA_KVA", "on", "on", "", True))+ self.assertEqual((row.name, row.default, row.tuned, row.yours, row.known), ("STRATA_KVA", "off", "off", "", True))self.assertIn("Faster long prompts", row.description)- self.assertIn("set 0 to turn off", row.description)- self.assertIn("Turn off if answers about long documents look wrong", row.description)- off = P.build_rows(None, QWEN["args"], None, QWEN["env"], None, {"STRATA_KVA": "0"}, P.switch_params(W.applicable(QWEN, [RTX])))- self.assertEqual(next(r for r in off if r.name == "STRATA_KVA").yours, "0")+ self.assertIn("off by default; set 1 to turn on", row.description)+ self.assertIn("answers about long documents can miss or mix up details", row.description)+ on = P.build_rows(None, QWEN["args"], None, QWEN["env"], None, {"STRATA_KVA": "1"}, P.switch_params(W.applicable(QWEN, [RTX])))+ self.assertEqual(next(r for r in on if r.name == "STRATA_KVA").yours, "1")+ hip = {**QWEN, "backend": "hip"}+ radeon = next(r for r in P.build_rows(None, hip["args"], None, hip["env"], None, {}, P.switch_params(W.applicable(hip, [R9700]))) if r.name == "STRATA_PCIE_FRAC_DEFAULT")+ self.assertEqual(radeon.default, "on")+ self.assertIn("on by default; set old to turn off", radeon.description)def test_the_six_deepseek_rows_say_they_go_together(self):text = W.env_words("DS4_COPY_PIN")self.assertIn("all 6 speed-up rows go together", text)- self.assertEqual({W.env_names()[n].id for n in OFF["deepseek_speedups"]}, {"deepseek_speedups"})+ self.assertEqual({W.env_names()[n].id for n in ENV["deepseek_speedups"]}, {"deepseek_speedups"})class SameAsTheApp(unittest.TestCase):@unittest.skipUnless(shutil.which("node"), "node is not installed")def test_the_apps_table_has_the_same_names_and_words(self):script = ("import {SPEED_SWITCHES} from './apps/host/server/native-settings.mjs';"- "console.log(JSON.stringify(SPEED_SWITCHES.map(s=>({id:s.id,label:s.label,hint:s.hint,off:s.off}))))")+ "console.log(JSON.stringify(SPEED_SWITCHES.map(s=>({id:s.id,label:s.label,hint:s.hint,default:s.default,env:s.env}))))")out = subprocess.run(["node", "--input-type=module", "-e", script], cwd=ROOT, capture_output=True, text=True, timeout=60, check=True).stdoutapp = json.loads(out)self.assertEqual([a["id"] for a in app], [s.id for s in W.SWITCHES])for a, s in zip(app, W.SWITCHES):self.assertEqual(a["label"], s.label)self.assertEqual(a["hint"], s.effect, s.id)- self.assertEqual(a["off"], dict(s.off), s.id)+ self.assertEqual(a["env"], dict(s.env), s.id)+ self.assertEqual(a["default"], s.default, s.id)if __name__ == "__main__":