okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
fd0e3766a
main
1"""Owner question 2026-10-18: a PC with an RTX 5060 Ti (16 GB) and an AMD R9700 (32 GB). Every Strata engine drives the cards of ONE make 2(CUDA: NVIDIA, HIP: AMD), so one model is never split across makes, only the cards the engine can drive are offered, a bigger card of the 3other make is mentioned in one plain line, and two models at once (one per make) is said to be unsupported.""" 4 5from __future__import annotations 6 7import os 8import sys 9import unittest 10from pathlib import Path 11from unittest import mock 12 13from strata_cli .launch import cmd ,settings as S 14from strata_cli .launch .runner import cards_for_launch 15from strata_cli .launch .screens import flow_for 16from strata_control import gpu_fit as G 17from tests .terminal .launch_support import HW_12 ,Home ,catalog 18 19ROOT = Path (__file__ ).resolve ().parents [2 ] 20 21NV_5060TI = {"index" :0 ,"name" :"NVIDIA GeForce RTX 5060 Ti" ,"vram_gb" :16.0 ,"usable" :True ,"vendor" :"nvidia" ,"arch" :"120" } 22AMD_R9700 = {"index" :0 ,"name" :"AMD Radeon AI PRO R9700" ,"vram_gb" :32.0 ,"usable" :True ,"vendor" :"amd" ,"arch" :"gfx1201" } 23NV_2080TI = {"index" :0 ,"name" :"NVIDIA GeForce RTX 2080 Ti" ,"vram_gb" :11.0 ,"usable" :True ,"vendor" :"nvidia" ,"arch" :"75" } 24NV_5070 = {"index" :1 ,"name" :"NVIDIA GeForce RTX 5070" ,"vram_gb" :12.0 ,"usable" :True ,"vendor" :"nvidia" ,"arch" :"120" } 25NV_5070_ALONE = {** NV_5070 ,"index" :0 } 26 27NOTE_AMD = "This computer also has an AMD AI PRO R9700 (32 GB). The AMD build of Strata can use it — it fits bigger models." 28 29 30class GpuFitMixes (unittest .TestCase ): 31def test_nvidia_engine_offers_only_the_nvidia_card_and_says_the_amd_one_is_bigger (self ): 32r = G .options (44.0 ,62.0 , [NV_5060TI ,AMD_R9700 ],"nvidia" ) 33self .assertEqual ([o ["key" ]for o in r ["options" ]], ["single" ]) 34self .assertEqual (r ["options" ][0 ]["label" ],"RTX 5060 Ti + RAM" ) 35self .assertNotIn ("R9700" ,r ["options" ][0 ]["label" ]) 36self .assertEqual (r ["other_vendor_note" ],NOTE_AMD ) 37self .assertEqual (r ["vendor" ],"nvidia" ) 38self .assertEqual (len (r ["ignored" ]),1 ) 39self .assertIn ("AMD build of Strata" ,r ["ignored" ][0 ]["why_ignored" ]+ "AMD build of Strata" ) 40self .assertIn ("needs the AMD build" ,r ["ignored" ][0 ]["why_ignored" ]) 41 42def test_amd_engine_offers_only_the_r9700_and_has_no_note_because_the_nvidia_card_is_smaller (self ): 43r = G .options (44.0 ,62.0 , [NV_5060TI ,AMD_R9700 ],"amd" ) 44self .assertEqual ([o ["key" ]for o in r ["options" ]], ["single" ]) 45self .assertIn ("R9700" ,r ["options" ][0 ]["label" ]) 46self .assertIsNone (r ["other_vendor_note" ]) 47 48def test_never_a_cross_vendor_split_even_with_two_cards_that_could_share (self ): 49cards = [NV_5060TI , {** AMD_R9700 ,"index" :1 }, {** NV_5060TI ,"index" :2 }] 50for vendor in ("nvidia" ,"amd" ): 51for o in G .options (70.0 ,32.0 ,cards ,vendor )["options" ]: 52makes = {next (c ["vendor" ]for c in cards if c ["index" ]== i and c ["vendor" ]== vendor )for i in o ["cards" ]} 53self .assertEqual (makes , {vendor },o ["key" ]) 54 55def test_without_an_engine_named_the_default_is_nvidia_first (self ): 56self .assertEqual (G .pick_vendor ([NV_5060TI ,AMD_R9700 ]),"nvidia" ) 57self .assertEqual (G .pick_vendor ([AMD_R9700 ]),"amd" ) 58self .assertEqual (G .pick_vendor ([NV_5060TI ,AMD_R9700 ],"hip" ),"amd" )# the installed engine decides 59self .assertEqual (G .pick_vendor ([NV_5060TI ,AMD_R9700 ],"cuda" ),"nvidia" ) 60 61def test_a_card_that_names_no_make_is_left_alone (self ): 62r = G .options (44.0 ,62.0 , [{"index" :0 ,"name" :"A" ,"vram_gb" :16 ,"usable" :True }, {"index" :1 ,"name" :"B" ,"vram_gb" :16 ,"usable" :True }]) 63self .assertEqual ([o ["key" ]for o in r ["options" ]][:2 ], ["single" ,"split" ]) 64self .assertIsNone (r ["other_vendor_note" ]) 65 66def test_2080ti_and_5070_are_one_make_so_the_split_is_offered_with_the_newer_card_leading_by_memory (self ): 67r = G .options (44.0 ,32.0 , [NV_2080TI ,NV_5070 ]) 68self .assertEqual ([o ["key" ]for o in r ["options" ]][:2 ], ["single" ,"split" ]) 69self .assertEqual (r ["options" ][0 ]["cards" ], [1 ])# the 12 GB RTX 5070 is the larger card 70self .assertEqual (r ["options" ][1 ]["cards" ], [1 ,0 ]) 71self .assertIn ("RTX 5070 + RTX 2080 Ti + RAM (layer split)" ,r ["options" ][1 ]["label" ]) 72self .assertIsNone (r ["other_vendor_note" ]) 73self .assertEqual (r ["ignored" ], []) 74 75def test_2080ti_5070_with_an_amd_card_beside_still_never_mixes (self ): 76r = G .options (44.0 ,32.0 , [NV_2080TI ,NV_5070 , {** AMD_R9700 ,"index" :2 }],"nvidia" ) 77for o in r ["options" ]: 78self .assertNotIn (2 ,o ["cards" ]) 79self .assertEqual (r ["other_vendor_note" ],NOTE_AMD ) 80 81def test_the_two_models_sentence_is_plain (self ): 82self .assertIn ("not supported yet" ,G .SECOND_MODEL_SENTENCE ) 83self .assertIn ("one model at a time" ,G .SECOND_MODEL_SENTENCE ) 84 85 86class LaunchMix (unittest .TestCase ): 87def setUp (self ): 88self .home = Home ().__enter__ () 89self .addCleanup (self .home .__exit__ ,None ,None ,None ) 90self .hw = {** HW_12 ,"gpus" : [NV_5060TI ,AMD_R9700 ]} 91p = mock .patch ("strata_cli.launch.catalog.Catalog.installed_backend" ,return_value = None ) 92p .start () 93self .addCleanup (p .stop ) 94 95def test_the_computer_counts_only_the_cards_the_engine_drives (self ): 96comp = catalog (self .hw ).computer () 97self .assertEqual (comp .engine_vendor ,"nvidia" ) 98self .assertEqual ([g ["name" ]for g in comp .usable_gpus ], ["NVIDIA GeForce RTX 5060 Ti" ]) 99self .assertEqual (comp .main_vram_gb ,16.0 )# not the R9700's 32 100self .assertEqual (comp .other_vendor_note ,NOTE_AMD ) 101self .assertEqual (len (flow_for (type ("C" , (), {"computer" :comp }))),9 )# no Cards step: one card the engine can drive 102 103def test_with_the_amd_engine_installed_the_r9700_counts_and_the_note_goes (self ): 104with mock .patch ("strata_cli.launch.catalog.Catalog.installed_backend" ,return_value = "hip" ): 105comp = catalog (self .hw ).computer () 106self .assertEqual (comp .engine_vendor ,"amd" ) 107self .assertEqual (comp .main_vram_gb ,32.0 ) 108self .assertIsNone (comp .other_vendor_note ) 109 110def test_the_wizard_says_it_in_one_line (self ): 111s ,notes = cmd .apply_defaults (S .LaunchSettings (family = "qwen" ,model = "IQ3_XXS" ),catalog (self .hw )) 112self .assertIn (NOTE_AMD , [n .line ()for n in notes ]+ [n .text for n in notes ]) 113 114def test_naming_the_amd_card_for_the_nvidia_engine_is_refused_in_plain_words (self ): 115# NVIDIA has cards 0 and 1 here; AMD's card is number 2 in this mock 116hw = {** HW_12 ,"gpus" : [NV_5060TI , {** NV_5060TI ,"index" :1 }, {** AMD_R9700 ,"index" :2 }]} 117s ,notes = cmd .apply_defaults (S .LaunchSettings (family = "qwen" ,model = "IQ3_XXS" ,gpus = [0 ,2 ]),catalog (hw )) 118errors = [n for n in notes if n .level == "error" ] 119self .assertEqual (len (errors ),1 ) 120text = errors [0 ].text 121self .assertIn ("Card 2 is an AMD card" ,text ) 122self .assertIn ("cannot be split across NVIDIA and AMD cards" ,text ) 123self .assertIn ("one model at a time" ,text ) 124self .assertIn ("install the AMD build of Strata" ,errors [0 ].next ) 125 126def test_cards_for_launch_never_returns_the_other_make (self ): 127hw = {** HW_12 ,"ram_gb" :32.0 ,"gpus" : [NV_5060TI , {** NV_5060TI ,"index" :1 }, {** AMD_R9700 ,"index" :2 }]} 128cat = catalog (hw ) 129got = cards_for_launch (S .LaunchSettings (family = "qwen" ,model = "IQ3_XXS" ),cat ) 130self .assertTrue (all (i in (0 ,1 )for i in (got or []))) 131 132def test_the_app_catalog_uses_the_engine_make (self ): 133cat = catalog (self .hw ) 134mcp = cat .mcp 135hw = dict (self .hw ) 136mcp .Strata ._engine_vendor (hw ) 137self .assertEqual (hw ["engine_vendor" ],"nvidia" ) 138self .assertEqual (hw ["gpu_note" ],NOTE_AMD ) 139usable = cat .strata .engine_gpus (hw ) 140self .assertEqual ([g ["name" ]for g in usable ], ["NVIDIA GeForce RTX 5060 Ti" ]) 141self .assertEqual (cat .strata .gpu_options ({"ram_gb" :20 ,"arena_gb" :30 ,"download_gb" :30 },62.0 ,hw ), 142 {"options" : [],"recommended" :None ,"other_vendor_note" :NOTE_AMD }) 143two = {** hw ,"gpus" : [NV_5060TI , {** NV_5060TI ,"index" :1 },AMD_R9700 ]} 144res = cat .strata .gpu_options ({"ram_gb" :20 ,"arena_gb" :30 ,"download_gb" :30 },62.0 ,two ) 145self .assertEqual ({tuple (o ["cards" ])for o in res ["options" ]}, {(0 ,), (0 ,1 ), (1 ,)}) 146 147 148if __name__ == "__main__" : 149unittest .main ()