okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
296b59d2f
main
1"""0.1.44.1: setup run again over an installed model keeps its size. 2 30.1.44 made IQ3_S the recommended Qwen size on a PC with 64 GB or more (IQ3_S: about 15% slower decode than IQ3_XXS on an 4RTX 5070, docs/MODELS.md, and about 7 GB more RAM). A first install takes the recommendation; SETUP.bat / --setup on a 5folder that already has a model pre-selects the installed size (and `--yes` takes it), so Enter never moves a working 6install to a slower size. The recommended size stays marked, every size stays a choice. 7 8python -m unittest tools.test_setup_rerun_size 9""" 10from __future__import annotations 11 12import sys 13import unittest 14from pathlib import Path 15 16ROOT = Path (__file__ ).resolve ().parents [1 ] 17sys .path .insert (0 ,str (ROOT )) 18sys .path .insert (0 ,str (ROOT / "tools" )) 19import setup # noqa: E402 20import test_setup_golden as g # noqa: E402 21 22PC64 = (63.7 , [g .card (0 ,"NVIDIA GeForce RTX 5070" ,11.9 ,"120" )]) 23 24 25def earlier (model :str ,family_tag :str = "" )-> tuple : 26tag = f" { family_tag } { model . lower () } " 27return (f"strata- { tag } .json" , {"exe" :"x" ,"args" : ["--pack" ,f"p/ { tag } " ,"--max-context" ,"32768" ],"cwd" :"." , 28"tokenizer" :"t" ,"model_name" :f"qwen3.8-flash-next- { tag } " ,"log" :"l" ,"port" :8080 }) 29 30 31class RerunKeepsSize (unittest .TestCase ): 32def run_setup (self ,argv ,configs ,answers = "" ): 33ram ,found = PC64 34code ,out ,cfg ,asked = g .install (ram ,found ,argv ,answers = answers ,configs = configs ) 35self .assertEqual (code ,0 ,out [- 2000 :]) 36return out ,cfg ,asked 37 38def test_first_install_takes_the_recommendation (self ): 39out ,cfg ,_ = self .run_setup (["--family" ,"qwen" ,"--no-start" ], []) 40self .assertEqual (cfg ["model_name" ],"qwen3.8-flash-next-iq3_s" ) 41self .assertNotIn ("(installed)" ,out ) 42 43def test_enter_over_an_installed_iq3_xxs_keeps_it (self ): 44out ,cfg ,asked = self .run_setup (["--family" ,"qwen" ,"--setup" ,"--no-start" ], [earlier ("IQ3_XXS" )]) 45self .assertEqual (cfg ["model_name" ],"qwen3.8-flash-next-iq3_xxs" ,out [- 1500 :]) 46line_s = next (x for x in out .splitlines ()if " IQ3_S " in x or " IQ3_S\t" in x or "IQ3_S " in x ) 47self .assertIn ("(recommended)" ,line_s )# still marked, still a choice 48line_xxs = next (x for x in out .splitlines ()if "IQ3_XXS" in x and "download" in x ) 49self .assertIn ("(installed)" ,line_xxs ) 50self .assertTrue (any ("Which size?" in a for a in asked )) 51 52def test_yes_over_an_installed_size_keeps_it_too (self ): 53_ ,cfg ,asked = self .run_setup (["--family" ,"qwen" ,"--setup" ,"--no-start" ], [earlier ("Q2_0" )],answers = None ) 54self .assertEqual (cfg ["model_name" ],"qwen3.8-flash-next-q2_0" ) 55self .assertEqual (asked , []) 56 57def test_a_named_size_still_wins (self ): 58_ ,cfg ,_ = self .run_setup (["--family" ,"qwen" ,"--model" ,"IQ3_S" ,"--setup" ,"--no-start" ], [earlier ("IQ3_XXS" )]) 59self .assertEqual (cfg ["model_name" ],"qwen3.8-flash-next-iq3_s" ) 60 61def test_another_family_is_not_touched (self ): 62# a Qwen IQ3_XXS install does not pre-select anything for the Unsloth family 63_ ,cfg ,_ = self .run_setup (["--family" ,"unsloth" ,"--setup" ,"--no-start" ], [earlier ("IQ3_XXS" )]) 64self .assertIn ("unsloth" ,cfg ["model_name" ]) 65 66def test_the_helper_prefers_the_most_recent_config_of_the_family (self ): 67import json 68import tempfile 69with tempfile .TemporaryDirectory ()as tmp : 70t = Path (tmp ) 71paths = [] 72for name ,cfg in (earlier ("IQ3_S" ),earlier ("Q2_0" )): 73p = t / name 74p .write_text (json .dumps (cfg )) 75paths .append (p ) 76names = [m for m in setup .MODELS if "qwen" in setup .MODELS [m ].get ("families" , ("qwen" ,"swift" ))] 77self .assertEqual (setup .installed_size ("qwen" ,names ,paths ),"IQ3_S" )# first = most recently used 78self .assertEqual (setup .installed_size ("qwen" ,names ,paths [1 :]),"Q2_0" ) 79self .assertIsNone (setup .installed_size ("qwen" ,names , [])) 80 81 82class RerunKeepsOwnEnv (unittest .TestCase ): 83"""0.1.44 put STRATA_MMQ_KQ / STRATA_HC_Q8 / STRATA_ROUTE_TAIL_SKIP into SETUP_ENV (the entries setup writes, which a 84setup run again does not carry over): a GSQ-RCO config of the user's own STRATA_ROUTE_TAIL_SKIP=0 was dropped with them. 85Those three are setup's only in an Unsloth config.""" 86 87OLD = {"env" : {"STRATA_ROUTE_TAIL_SKIP" :"0" ,"STRATA_MMQ_KQ" :"1" ,"STRATA_HC_Q8" :"0" ,"STRATA_RESIDENT_PIN" :"0" , 88"MY_VAR" :"1" }} 89 90def test_a_gsq_rco_config_keeps_the_users_values (self ): 91new = {"model_name" :"qwen3.8-flash-next-iq3_xxs" } 92kept = setup .carry_over (dict (self .OLD ),new ) 93self .assertEqual (new ["env" ], {"STRATA_ROUTE_TAIL_SKIP" :"0" ,"STRATA_MMQ_KQ" :"1" ,"STRATA_HC_Q8" :"0" ,"MY_VAR" :"1" }) 94self .assertIn ("env STRATA_ROUTE_TAIL_SKIP" ,kept ) 95self .assertNotIn ("env STRATA_RESIDENT_PIN" ,kept )# the older entries stay setup's own 96 97def test_an_unsloth_config_gets_setups_values_not_the_old_ones (self ): 98new = {"model_name" :"qwen3.8-flash-next-unsloth-ud-q4_k_xl" ,"env" : {"STRATA_HC_Q8" :"1" }} 99setup .carry_over (dict (self .OLD ),new ) 100self .assertEqual (new ["env" ], {"STRATA_HC_Q8" :"1" ,"MY_VAR" :"1" }) 101 102 103if __name__ == "__main__" : 104unittest .main ()