From ae03ef632360e7a5441edb6b0efd5d7e129d01d8 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Mon, 26 Oct 2026 16:34:01 +0100 Subject: [PATCH 1/3] Terminal and the shared speed-switch table: Faster long prompts (Qwen KVA) is OFF by default, STRATA_KVA=1 turns it on Owner decision (26 October, conditional on the last KVA variant results): KVA ships off. strata_control/speed_switches.py now gives every switch a default and the environment it writes outside that default: KVA is default off and writes STRATA_KVA=1; the Radeon RX 9000 and DeepSeek switches stay on by default and write their off entries as before. A launch in the default carries no entry. 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; choosing Off cleans it up. The Advanced table row says "off by default; set 1 to turn on" with the new sentence (`--set STRATA_KVA=1`; `off` or Del puts the default back). tests/terminal/test_speed_switches.py covers the defaults, KVA on/off/old-zero, the rows and the comparison with the app's table. --- strata_cli/launch/params.py | 8 +-- strata_control/speed_switches.py | 57 ++++++++++++------- tests/terminal/test_speed_switches.py | 79 ++++++++++++++++----------- 3 files changed, 88 insertions(+), 56 deletions(-) diff --git a/strata_cli/launch/params.py b/strata_cli/launch/params.py index 01186407..93da4021 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.py index 6b212559..029022f6 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.py reads 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, Mapping class Switch: id: str label: 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 state only: str # "qwen-gpu" | "qwen-radeon-9000" | "deepseek": where it applies + default: str = "on" # "on" | "off": what a launch without the entries does SWITCHES: 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.off) + 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 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 switch out = 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 out def 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.py index 0aa78bf3..01cc2eac 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 the app'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 W ROOT = 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 entries base = DEEPSEEK if sid == "deepseek_speedups" else QWEN cfg = 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).stdout app = 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__": From 9760cbca4b711449e615f5c06df8b51c38d37bd5 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Mon, 26 Oct 2026 16:34:01 +0100 Subject: [PATCH 2/3] App: "Faster long prompts" (KVA) is Off by default in the model's Expert settings; On writes STRATA_KVA=1, Off removes it The Speed row now follows the shared table's default: Faster long prompts reads "Off (recommended)" / "On" and its new sentence is "Reads very long prompts faster by approximating part of the work. Off by default: answers about long documents can miss or mix up details." (replaces fx73; "Off (recommended)" is fx79; translated in zh, ja, de, es, ru, pt, ko). The other two rows are unchanged ("On (recommended)" / "Off"). A STRATA_KVA=0 stored by an earlier 0.2.7 test build shows as Off. Still shown only where KVA applies (Qwen on CUDA or HIP). tests/speed-switches.test.mjs updated: the default launch has no KVA entry, On writes STRATA_KVA=1, Off removes it, the old 0 shows as Off, and the other two switches are tested as before. --- apps/host/server/native-settings.mjs | 31 +++--- apps/host/src/components/NativeSettings.tsx | 14 +-- apps/host/src/locales/fix-de.json | 5 +- apps/host/src/locales/fix-en.json | 5 +- apps/host/src/locales/fix-es.json | 5 +- apps/host/src/locales/fix-ja.json | 5 +- apps/host/src/locales/fix-ko.json | 5 +- apps/host/src/locales/fix-pt.json | 5 +- apps/host/src/locales/fix-ru.json | 5 +- apps/host/src/locales/fix-zh.json | 5 +- apps/host/tests/speed-switches.test.mjs | 106 ++++++++++++-------- 11 files changed, 111 insertions(+), 80 deletions(-) diff --git a/apps/host/server/native-settings.mjs b/apps/host/server/native-settings.mjs index 37730c78..fb671659 100644 --- a/apps/host/server/native-settings.mjs +++ b/apps/host/server/native-settings.mjs @@ -29,21 +29,22 @@ export const NATIVE_FIELDS=[ /** Engine environment names the app shows and edits: STRATA_* and the DeepSeek engine's DS4_*. Any other name in a model's file is kept untouched and not shown. */ export const ENV_FLAG=/^(?:STRATA|DS4)_[A-Z0-9_]+$/; /** - * The three speed features that are on by default in 0.2.7 and have an off switch in Expert settings. Each switch, when off, writes exactly the - * environment entries below into the model's settings file ("env"); turning it on again removes them, so a default launch carries none of them. - * The names are the engine switch contract (phaseA-tests/notes-027-plan.md); strata_control/speed_switches.py says the same for the Terminal - * (tests/terminal/test_speed_switches.py compares the two). + * The speed features of 0.2.7 that have a switch in Expert settings. A switch has a default ('on' or 'off'); outside it, it writes exactly the + * environment entries `env` into the model's settings file ("env"); back in its default it removes them, so a default launch carries none of them. + * "Faster long prompts" (Qwen KVA) is OFF by default (owner decision, 26 October): STRATA_KVA=1 turns it on, and an earlier test build's STRATA_KVA=0 reads as off. + * The other two are on by default. The names are the engine switch contract (phaseA-tests/notes-027-plan.md); strata_control/speed_switches.py says the + * same for the Terminal (tests/terminal/test_speed_switches.py compares the two). */ export const SPEED_SWITCHES=[ {id:'faster_long_prompts',label:'Faster long prompts',group:'Speed', - hint:'Reads long prompts faster by approximating part of the work. Turn off if answers about long documents look wrong.', - off:{STRATA_KVA:'0'}}, + hint:'Reads very long prompts faster by approximating part of the work. Off by default: answers about long documents can miss or mix up details.', + default:'off',env:{STRATA_KVA:'1'}}, {id:'faster_radeon_9000',label:'Faster answers on Radeon RX 9000 / AI PRO R9700',group:'Speed', hint:'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.', - off:{STRATA_PCIE_FRAC_DEFAULT:'old'}}, + default:'on',env:{STRATA_PCIE_FRAC_DEFAULT:'old'}}, {id:'deepseek_speedups',label:'DeepSeek speed-ups',group:'Speed', hint:'Reads long prompts faster and loads the parts of the model it needs faster. Turn off if DeepSeek stops working or its answers look wrong; it then runs as in version 0.2.6.', - off:{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:'on',env:{DS4_FAST_ATTN:'0',DS4_ATTN_SLAB:'0',DS4_COPY_PIN:'0',DS4_COPY_HUGETLB:'0',DS4_STORE_SPARE:'0',DS4_STORE_PUT:'0'}}, ]; const GFX12=/^gfx120[01]$/i, RADEON_9000=/\b(?:RX\s*9\d{3}|AI\s*PRO\s*R97\d{2}|R97\d{2})\b/i; /** Which switches make sense for this model on this PC: only those are shown. `backend` is the engine's (cuda, hip, sycl, metal, cpu). */ @@ -54,15 +55,17 @@ export function speedSwitchApplies(id,{deepseek=false,backend=null,gpus=[]}={}){ if(id==='faster_radeon_9000')return backend==='hip'&&(gpus??[]).some(g=>(!g.vendor||g.vendor==='amd')&&(GFX12.test(String(g.arch??''))||(!g.arch&&RADEON_9000.test(String(g.name??''))))); return false; } -/** A switch is off when every entry it writes is in the environment with its value; anything less (a hand-edited file) reads as on and is left alone. */ -export function speedSwitchIsOff(env,id){const sw=SPEED_SWITCHES.find(s=>s.id===id);return !!sw&&Object.entries(sw.off).every(([name,value])=>env?.[name]===value);} -/** The environment with the switch turned off (its entries written) or on (its entries removed). Nothing else in it changes. */ +/** The switch is outside its default when every entry it writes is in the environment with its value; anything less or other (a hand-edited file, STRATA_KVA=0) is the default state and is left alone. */ +export function speedSwitchIsSet(env,id){const sw=SPEED_SWITCHES.find(s=>s.id===id);return !!sw&&Object.entries(sw.env).every(([name,value])=>env?.[name]===value);} +/** Is the feature on for a launch with this environment? */ +export function speedSwitchIsOn(env,id){const sw=SPEED_SWITCHES.find(s=>s.id===id);return !!sw&&speedSwitchIsSet(env,id)!==(sw.default==='on');} +/** The environment with the feature on or off: its default removes the switch's entries, the other state writes them. Nothing else in it changes. */ export function setSpeedSwitch(env,id,on){ const sw=SPEED_SWITCHES.find(s=>s.id===id);if(!sw)throw new Error(`Unknown speed switch: ${id}`); - const next={...(env??{})};for(const [name,value] of Object.entries(sw.off)){if(on)delete next[name];else next[name]=value;}return next; + const write=on!==(sw.default==='on'),next={...(env??{})};for(const [name,value] of Object.entries(sw.env)){if(write)next[name]=value;else delete next[name];}return next; } -/** What the settings answer carries: each switch that applies, with its words, the entries it writes when off, and whether it is on. */ -export function speedSwitchRows(env,context){return SPEED_SWITCHES.filter(s=>speedSwitchApplies(s.id,context)).map(s=>({...s,on:!speedSwitchIsOff(env,s.id)}));} +/** What the settings answer carries: each switch that applies, with its words, its default, the entries it writes outside the default, and whether the feature is on. */ +export function speedSwitchRows(env,context){return SPEED_SWITCHES.filter(s=>speedSwitchApplies(s.id,context)).map(s=>({...s,on:speedSwitchIsOn(env,s.id)}));} /** Settings the app itself applies when it starts a model (they are not read from the engine's source, so the engine's text never says it supports them). */ export const APP_OWNED_FIELDS=['mtp','batchMtp','drafting','ds_experts']; /** The engine arguments without the draft layer: --mtp , --spec-min-p

(its confidence threshold) and --batch-mtp. --spec stays: prompt lookup still uses its windows. Same rule as strata_control/draft_layer.py. */ diff --git a/apps/host/src/components/NativeSettings.tsx b/apps/host/src/components/NativeSettings.tsx index 561c8f66..062874f1 100644 --- a/apps/host/src/components/NativeSettings.tsx +++ b/apps/host/src/components/NativeSettings.tsx @@ -9,14 +9,16 @@ import { Btn, ErrorNotice, Select } from './ui'; import { speedOptions } from '../lib/deepseek-speed'; import type { RunCard } from '../lib/native-fit'; import { NativeMcpEditor } from './NativeMcpEditor'; -/** One of the three speed features that are on by default: what it is called, what turning it off does, and the engine environment it writes when off (server/native-settings.mjs). */ +/** One of the speed features: what it is called, what it does, whether it is on by default, and the engine environment it writes outside its default (server/native-settings.mjs). */ interface SpeedSwitch { id: string; label: string; hint: string; - off: Record; + default: 'on' | 'off'; + env: Record; } -const switchIsOff = (sw: SpeedSwitch, env: Record | undefined) => Object.entries(sw.off).every(([name, value]) => env?.[name] === value); +const switchIsSet = (sw: SpeedSwitch, env: Record | undefined) => Object.entries(sw.env).every(([name, value]) => env?.[name] === value); +const switchIsOn = (sw: SpeedSwitch, env: Record | undefined) => switchIsSet(sw, env) !== (sw.default === 'on'); export function NativeSettings({ model }: { model: string; }) { @@ -58,8 +60,8 @@ export function NativeSettings({ model }: { return () => { active = false; }; }, [model,revision]); const change = (id: string, value: any) => { const next = { ...values, [id]: value }; setValues(next); setText(JSON.stringify(next, null, 2)); setNotice(''); }; - /** On removes the switch's environment entries, off writes them: the model's file then carries nothing for a default launch. */ - const changeSwitch = (sw: SpeedSwitch, on: boolean) => { const env = { ...(values.env ?? {}) }; for (const [name, value] of Object.entries(sw.off)) { if (on) delete env[name]; else env[name] = value; } change('env', env); }; + /** The default removes the switch's environment entries, the other state writes them: the model's file then carries nothing for a default launch. */ + const changeSwitch = (sw: SpeedSwitch, on: boolean) => { const env = { ...(values.env ?? {}) }; const write = on !== (sw.default === 'on'); for (const [name, value] of Object.entries(sw.env)) { if (write) env[name] = value; else delete env[name]; } change('env', env); }; async function save() { setPending(true); setError(''); @@ -112,7 +114,7 @@ export function NativeSettings({ model }: { const rows = (native?.fields ?? []).filter(f => (!f.forModel || (model.toLowerCase().includes(f.forModel) && (f.id !== 'ds_experts' || dsExperts))) && `${tr(f.label)} ${f.id} ${tr(f.group)}`.toLowerCase().includes(query.toLowerCase())); const switchRows = switches.filter(sw => `${tr(sw.label)} ${sw.id} ${tr('Speed')}`.toLowerCase().includes(query.toLowerCase())); return

{tr("Native engine settings")}{tr(tuned?.changed?.length ?

{tr("Your tuning '{0}' sets", [tuned.preset?.name ?? ''])}

    {tuned.changed.map(c => { const d = describeChange(c); return
  • {d.name}{d.now || tr('off')}{d.was !== null ? {tr("was {0}", [d.was])} : null}
  • ; })}
: null)}

{tr(!original ? 'Reading saved settings… ' : '')}{tr("Settings for this model. Blank values use Strata\u2019s defaults.")}

{tr(['fields', 'json', 'tools'].map(t => ))}
- {tr(tab === 'fields' ? <> setQuery(e.target.value)}/>{tr(['Responses', 'GPU & memory', 'Serving', 'Image reading', 'Tools', 'Recovery'].map(group => rows.some(f => f.group === group) ?

{tr(group)}

{tr(rows.filter(f => f.group === group).map(f => ))}
: null))}{tr(switchRows.length ?

{tr("Speed")}

{tr(switchRows.map(sw =>