okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
40bf5f5c4
main
1"""The draft layer switch: "mtp": false in a run config starts the engine without --mtp (serve/server.py engine_args), however the 2arguments got there, and strata_control/draft_layer.py is the one rule setup, the launcher and the server share. 3 4python -m unittest serve.test_draft_layer 5""" 6import contextlib 7import io 8import unittest 9 10from serve import runconfig 11from serve .server import engine_args 12from strata_control import draft_layer 13 14ARGS = ["--pack" ,"/p" ,"--spec" ,"4" ,"--spec-min-p" ,"0.5" ,"--mtp" ,"/m/rt" ,"--max-context" ,"32768" ,"--batch-mtp" ,"--kv" ,"int8" ] 15 16 17class DraftLayer (unittest .TestCase ): 18def test_strip_keeps_everything_but_the_draft_layer (self ): 19out ,removed = draft_layer .strip (ARGS ) 20self .assertEqual (out , ["--pack" ,"/p" ,"--spec" ,"4" ,"--max-context" ,"32768" ,"--kv" ,"int8" ]) 21self .assertEqual (removed , ["--spec-min-p" ,"--mtp" ,"--batch-mtp" ]) 22self .assertEqual (draft_layer .strip (["--mtp" ,"2" ,"--spec" ,"2" ])[0 ], ["--spec" ,"2" ])# Qwen3.6: a draft count 23 24def test_only_an_explicit_false_turns_it_off (self ): 25for cfg in ({}, {"mtp" :True }, {"mtp" :None }, {"mtp" :0 }, {"mtp" :"off" },None ): 26self .assertFalse (draft_layer .is_off (cfg ),cfg ) 27self .assertTrue (draft_layer .is_off ({"mtp" :False })) 28 29def test_the_server_applies_it_at_every_start (self ): 30on = engine_args ({"args" :list (ARGS )}) 31self .assertIn ("--mtp" ,on ) 32out = io .StringIO () 33with contextlib .redirect_stdout (out ): 34off = engine_args ({"args" :list (ARGS ),"mtp" :False }) 35for flag in ("--mtp" ,"--spec-min-p" ,"--batch-mtp" ): 36self .assertNotIn (flag ,off ) 37self .assertEqual (off [off .index ("--spec" )+ 1 ],"4" ) 38self .assertIn ("without the draft layer" ,out .getvalue ()) 39 40def test_the_web_settings_page_lists_it (self ): 41cfg = {"args" : []} 42self .assertTrue (any (k ["key" ]== "mtp" for k in runconfig .view (cfg ,"strata-x.json" )["keys" ])) 43new ,changed = runconfig .apply (cfg , {"mtp" :False }) 44self .assertIs (new ["mtp" ],False ) 45self .assertEqual (changed , ["mtp" ]) 46with self .assertRaises (ValueError ): 47runconfig .apply (cfg , {"mtp" :"off" }) 48 49 50if __name__ == "__main__" : 51unittest .main ()