okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
ffb3d9b31
main
1"""A feed model whose entry says `drafter: none` starts with no drafter at every start, and the Terminal plans none for it (lane APP-LIN 0.2.14 item 8; Q4-P8 G14).""" 2from pathlib import Path 3from types import SimpleNamespace 4 5from strata_cli .launch import runner as R 6from strata_control import drafting 7 8 9def _cfg (** kw ): 10return {"model_name" :"qwen4exp-q4_k_m" ,"args" : ["--native" ,"/m/a.gguf" ,"--mtp" ,"/d/mtp/rt" ,"--spec-min-p" ,"0.5" ,"--max-context" ,"32768" ],** kw } 11 12 13def test_a_feed_model_with_no_draft_layer_starts_with_no_drafter (): 14from serve .server import engine_args 15for extra in ({"mtp" :False ,"drafting" :"off" }, {"mtp" :False }, {"drafting" :"off" }): 16d = drafting .apply (_cfg (** extra ),backend = "cuda" ,archs = ["sm_86" ]) 17assert d .drafter == "off" ,extra 18started = engine_args (_cfg (** extra ),announce = False )# what the server starts: no draft layer, whichever key said so 19assert "--mtp" not in started and "--spec-min-p" not in started ,extra 20assert started [started .index ("--max-context" )+ 1 ]== "32768" 21 22 23def test_other_models_keep_their_decision (): 24cfg = _cfg ()# a model DFlash2 is not for, draft layer on: as before 25assert drafting .apply (cfg ,backend = "cuda" ,archs = ["sm_86" ]).drafter == "mtp" 26assert "--mtp" in cfg ["args" ] 27cfg = _cfg (drafting = "dflash2" ) 28d = drafting .apply (cfg ,backend = "cuda" ,archs = ["sm_86" ]) 29assert (d .drafter ,d .note )== ("mtp" ,drafting .NOT_SUPPORTED ) 30 31 32def test_the_terminal_plans_no_drafter_for_it (): 33fake = SimpleNamespace (s = SimpleNamespace (drafting = None ,family = "qwen4exp" ),split_expected = lambda :False , 34feed_without_draft_layer = lambda family = None :family == "qwen4exp" ) 35assert R .Runner .resolved_drafting (fake ,"qwen4exp" )== "off" 36fake .s .drafting = "mtp" 37assert R .Runner .resolved_drafting (fake ,"qwen4exp" )== "off" ,"the head the MTP would load is Flash-Next's, not this model's" 38 39 40def test_setup_writes_drafting_off_for_it (): 41src = (Path (drafting .__file__ ).parent / "setup_config.py" ).read_text (encoding = "utf-8" ) 42assert 'if getattr(a, "feed_no_drafter", False):' in src and 'cfg["drafting"] = "off"' in src 43setup = (Path (drafting .__file__ ).parent .parent / "setup.py" ).read_text (encoding = "utf-8" ) 44at = setup .index ('fam.get("drafter") == "none" and a.mtp is None' ) 45assert "a.feed_no_drafter = True" in setup [at :at + 600 ]