okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
b7bcbcde9
main
1"""The Gyro entries of setup's catalog (agentionai/Qwen3.8-Flash-Next-Gyro-GGUF): sizes, pins, the VRAM + RAM memory rule, 2never a default, and the MCP server's recommendation naming them only where nothing else fits. Offline.""" 3import pathlib 4import sys 5import unittest 6 7ROOT = pathlib .Path (__file__ ).resolve ().parent .parent 8sys .path .insert (0 ,str (ROOT )) 9sys .path .insert (0 ,str (ROOT / "tools" )) 10import setup # noqa: E402 11import strata_mcp as M # noqa: E402 12 13 14def hardware (ram ,vram ): 15return {"ram_gb" :ram ,"gpus" : [{"usable" :True ,"vram_gb" :vram ,"vendor" :"nvidia" ,"index" :0 ,"name" :"RTX" }], 16"cpu" : {"avx2" :True }} 17 18 19class GyroCatalog (unittest .TestCase ): 20def test_the_two_sizes_and_their_numbers (self ): 21self .assertEqual (setup .FAMILIES ["gyro" ]["file" ].format (q = "Gyro-S" ),"Qwen3.8-Flash-Next-Gyro-S.gguf" ) 22for model ,name ,download ,memory in (("Gyro-S" ,"Qwen3.8-Flash-Next-Gyro-S-TQ1_0.gguf" ,58.5 ,27.6 ), 23 ("Gyro-M" ,"Qwen3.8-Flash-Next-Gyro-M-TQ2_0.gguf" ,92.0 ,35.0 )): 24d = setup .MODELS [model ] 25self .assertEqual (setup .model_file (setup .FAMILIES ["gyro" ],model ,1 ),name ) 26self .assertEqual ((d ["download_gb" ],d ["ram_gb" ]), (download ,memory )) 27size ,sha = setup .GYRO_FILES [name ] 28self .assertAlmostEqual (size / 1e9 ,download ,delta = 0.05 ) 29self .assertEqual (len (sha ),64 ) 30self .assertEqual (setup .model_shards (setup .FAMILIES ["gyro" ],model ),1 ) 31self .assertIs (d .get ("vision" ),True ) 32self .assertTrue (d ["mem_total" ]) 33self .assertEqual (d ["families" ], ("gyro" ,)) 34 35def test_pinned_revision_and_license (self ): 36repo = "agentionai/Qwen3.8-Flash-Next-Gyro-GGUF" 37self .assertEqual (len (setup .HF_REVISIONS [repo ]),40 ) 38self .assertIn (setup .HF_REVISIONS [repo ],setup .FAMILIES ["gyro" ]["hf" ]) 39self .assertIn ("Qwen Community License 1.0" ,setup .FAMILIES ["gyro" ]["license" ]) 40 41def test_never_the_default_family (self ): 42self .assertEqual (setup .menu_families (False )[0 ],"qwen" ) 43self .assertNotIn ("gyro" ,setup .RECOMMENDED_SIZES ) 44 45def test_memory_is_vram_plus_ram (self ): 46self .assertEqual (setup .mem_have ("Gyro-S" ,16.0 ,12.0 ),28.0 ) 47self .assertEqual (setup .mem_have ("Q2_0" ,16.0 ,12.0 ),16.0 ) 48names = ["Gyro-S" ,"Gyro-M" ] 49self .assertEqual (setup .recommended_size ("gyro" ,names ,24.0 ,12.0 ),"Gyro-M" )# 36 GB 50self .assertEqual (setup .recommended_size ("gyro" ,names ,16.0 ,12.0 ),"Gyro-S" )# 28 GB 51self .assertEqual (setup .recommended_size ("gyro" ,names ,8.0 ,8.0 ),"Gyro-S" )# nothing fits: the first 52 53def test_mcp_table_matches (self ): 54for m in ("Gyro-S" ,"Gyro-M" ): 55for k in ("download_gb" ,"ram_gb" ,"arena_gb" ,"mem_total" ,"vision" ,"engine" ): 56self .assertEqual (setup .MODELS [m ][k ],M .FALLBACK_MODELS [m ][k ], (m ,k )) 57self .assertEqual (setup .FAMILIES ["gyro" ]["tag" ],M .FALLBACK_FAMILIES ["gyro" ]["tag" ]) 58 59def test_mcp_recommends_gyro_only_where_nothing_else_fits (self ): 60s = M .Strata (ROOT ) 61for ram ,vram ,family in ((64.0 ,12.0 ,"qwen" ), (48.0 ,12.0 ,"qwen" ), (32.0 ,12.0 ,"swift" ), (28.0 ,8.0 ,"coder" )): 62self .assertEqual (s .recommend (hardware (ram ,vram ))["family" ],family , (ram ,vram )) 63got = s .recommend (hardware (20.0 ,12.0 ))# 32 GB in total, the Coder's 32 GB of RAM missing 64self .assertEqual ((got ["family" ],got ["model" ]), ("gyro" ,"Gyro-S" )) 65got = s .recommend (hardware (28.0 ,16.0 ))# 44 GB in total, 39 after the 5 GB for the system (#3425): the owner's 40 GB tier, Swift 1.5's IQ2_XS 66self .assertEqual ((got ["family" ],got ["model" ]), ("swift" ,"IQ2_XS" )) 67self .assertIn ("Gyro-M" ,got ["why" ])# named as the other choice (NVIDIA, AMD and Intel Arc) 68intel = hardware (28.0 ,16.0 ) 69intel ["gpus" ]= [{** g ,"vendor" :"intel" }for g in intel ["gpus" ]] 70self .assertIn ("Gyro-M" ,s .recommend (intel )["why" ])# the SYCL engine has the trellis kernels (0.2.2) 71self .assertIsNone (s .recommend (hardware (12.0 ,8.0 ))["family" ]) 72self .assertIsNone (s .recommend (hardware (16.0 ,11.0 ))["family" ])# 27 GB: below Gyro-S's 27.6 + room 73 74def test_mcp_table_verdict_counts_vram (self ): 75s = M .Strata (ROOT ) 76fam = next (f for f in s .model_table (hardware (16.0 ,16.0 ))if f ["family" ]== "gyro" ) 77by = {x ["model" ]:x for x in fam ["sizes" ]} 78self .assertEqual (by ["Gyro-S" ]["on_this_pc" ],"fits" ) 79self .assertEqual (by ["Gyro-M" ]["on_this_pc" ],"may run slower" )# 35 GB of VRAM + RAM together, this PC has 32 80self .assertTrue (by ["Gyro-S" ]["images" ]) 81 82def test_mcp_table_gives_ram_plus_vram_without_the_ngram_table (self ): 83"""The Models page shows what a version needs of RAM + VRAM together, the n-gram table (on the SSD) not counted.""" 84s = M .Strata (ROOT ) 85table = s .model_table (hardware (64.0 ,12.0 )) 86gyro = {x ["model" ]:x for x in next (f for f in table if f ["family" ]== "gyro" )["sizes" ]} 87self .assertEqual (gyro ["Gyro-S" ]["memory_gb" ],27.6 )# stated in total (mem_total), not the 58.5 GB download 88self .assertTrue (gyro ["Gyro-S" ]["mem_total" ]) 89swift = {x ["model" ]:x for x in next (f for f in table if f ["family" ]== "swift" )["sizes" ]} 90self .assertEqual (swift ["IQ2_XS" ]["memory_gb" ],36.5 )# 35.5 GB of experts + ~1 GB dense 91self .assertFalse (swift ["IQ2_XS" ]["mem_total" ]) 92 93 94class GyroEngineVersionTest (unittest .TestCase ): 95"""Gyro's expert files are native_experts.txt v5 (Hadamard-folded). The released 0.1.45 engine reads only up to v4, so the 96minimum is 0.1.45.1, the first engine package built after the v5 reader (APR port, f47b0385f) was merged.""" 97 98def test_gyro_needs_an_engine_that_reads_v5_files (self ): 99self .assertEqual (setup .GYRO_ENGINE , (0 ,1 ,45 ,1 )) 100self .assertGreater (setup .GYRO_ENGINE , (0 ,1 ,45 ))# the released 0.1.45 is not enough 101sizes = [m for m in setup .MODELS .values ()if "gyro" in str (m .get ("file" ,"" )).lower ()] 102self .assertEqual (len (sizes ),2 ) 103self .assertTrue (all (m ["engine" ]== (0 ,1 ,45 ,1 )for m in sizes )) 104 105def test_every_catalog_agrees (self ): 106for m in ("Gyro-S" ,"Gyro-M" ): 107self .assertEqual (setup .MODELS [m ]["engine" ],M .FALLBACK_MODELS [m ]["engine" ],m ) 108 109def test_the_catalog_tells_the_app_the_minimum (self ): 110table = M .Strata (ROOT ).model_table (hardware (64.0 ,12.0 )) 111gyro = {x ["model" ]:x for x in next (f for f in table if f ["family" ]== "gyro" )["sizes" ]} 112self .assertEqual ({k :v ["engine_min" ]for k ,v in gyro .items ()}, {"Gyro-S" :"0.1.45.1" ,"Gyro-M" :"0.1.45.1" }) 113qwen = {x ["model" ]:x for x in next (f for f in table if f ["family" ]== "qwen" )["sizes" ]} 114self .assertIsNone (qwen ["Q2_0" ]["engine_min" ])# a size with no minimum of its own says so 115 116def test_the_pack_reader_is_in_the_source_this_minimum_describes (self ): 117text = (ROOT / "src" / "kernels" / "cpu" / "expert_layout.cpp" ).read_text (encoding = "utf-8" ) 118self .assertIn ("native_experts.txt v5 declares Hadamard-folded experts" ,text ) 119 120 121if __name__ == "__main__" : 122unittest .main ()