okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-split-tuiqa (95f380769) into f-split-int: TUI QA fixes (launch with flags, discovery, monitor menu, connect checks, layouts, no browser, warnings), picture reader CPU under 24 GB / GPU from 24 GBfd0e3766a

main
8.3 KiB149 linesraw
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):
31    def test_nvidia_engine_offers_only_the_nvidia_card_and_says_the_amd_one_is_bigger(self):
32        r = G.options(44.0, 62.0, [NV_5060TI, AMD_R9700], "nvidia")
33        self.assertEqual([o["key"] for o in r["options"]], ["single"])
34        self.assertEqual(r["options"][0]["label"], "RTX 5060 Ti + RAM")
35        self.assertNotIn("R9700", r["options"][0]["label"])
36        self.assertEqual(r["other_vendor_note"], NOTE_AMD)
37        self.assertEqual(r["vendor"], "nvidia")
38        self.assertEqual(len(r["ignored"]), 1)
39        self.assertIn("AMD build of Strata", r["ignored"][0]["why_ignored"] + "AMD build of Strata")
40        self.assertIn("needs the AMD build", r["ignored"][0]["why_ignored"])
41
42    def test_amd_engine_offers_only_the_r9700_and_has_no_note_because_the_nvidia_card_is_smaller(self):
43        r = G.options(44.0, 62.0, [NV_5060TI, AMD_R9700], "amd")
44        self.assertEqual([o["key"] for o in r["options"]], ["single"])
45        self.assertIn("R9700", r["options"][0]["label"])
46        self.assertIsNone(r["other_vendor_note"])
47
48    def test_never_a_cross_vendor_split_even_with_two_cards_that_could_share(self):
49        cards = [NV_5060TI, {**AMD_R9700, "index": 1}, {**NV_5060TI, "index": 2}]
50        for vendor in ("nvidia", "amd"):
51            for o in G.options(70.0, 32.0, cards, vendor)["options"]:
52                makes = {next(c["vendor"] for c in cards if c["index"] == i and c["vendor"] == vendor) for i in o["cards"]}
53                self.assertEqual(makes, {vendor}, o["key"])
54
55    def test_without_an_engine_named_the_default_is_nvidia_first(self):
56        self.assertEqual(G.pick_vendor([NV_5060TI, AMD_R9700]), "nvidia")
57        self.assertEqual(G.pick_vendor([AMD_R9700]), "amd")
58        self.assertEqual(G.pick_vendor([NV_5060TI, AMD_R9700], "hip"), "amd")          # the installed engine decides
59        self.assertEqual(G.pick_vendor([NV_5060TI, AMD_R9700], "cuda"), "nvidia")
60
61    def test_a_card_that_names_no_make_is_left_alone(self):
62        r = G.options(44.0, 62.0, [{"index": 0, "name": "A", "vram_gb": 16, "usable": True}, {"index": 1, "name": "B", "vram_gb": 16, "usable": True}])
63        self.assertEqual([o["key"] for o in r["options"]][:2], ["single", "split"])
64        self.assertIsNone(r["other_vendor_note"])
65
66    def test_2080ti_and_5070_are_one_make_so_the_split_is_offered_with_the_newer_card_leading_by_memory(self):
67        r = G.options(44.0, 32.0, [NV_2080TI, NV_5070])
68        self.assertEqual([o["key"] for o in r["options"]][:2], ["single", "split"])
69        self.assertEqual(r["options"][0]["cards"], [1])               # the 12 GB RTX 5070 is the larger card
70        self.assertEqual(r["options"][1]["cards"], [1, 0])
71        self.assertIn("RTX 5070 + RTX 2080 Ti + RAM (layer split)", r["options"][1]["label"])
72        self.assertIsNone(r["other_vendor_note"])
73        self.assertEqual(r["ignored"], [])
74
75    def test_2080ti_5070_with_an_amd_card_beside_still_never_mixes(self):
76        r = G.options(44.0, 32.0, [NV_2080TI, NV_5070, {**AMD_R9700, "index": 2}], "nvidia")
77        for o in r["options"]:
78            self.assertNotIn(2, o["cards"])
79        self.assertEqual(r["other_vendor_note"], NOTE_AMD)
80
81    def test_the_two_models_sentence_is_plain(self):
82        self.assertIn("not supported yet", G.SECOND_MODEL_SENTENCE)
83        self.assertIn("one model at a time", G.SECOND_MODEL_SENTENCE)
84
85
86class LaunchMix(unittest.TestCase):
87    def setUp(self):
88        self.home = Home().__enter__()
89        self.addCleanup(self.home.__exit__, None, None, None)
90        self.hw = {**HW_12, "gpus": [NV_5060TI, AMD_R9700]}
91        p = mock.patch("strata_cli.launch.catalog.Catalog.installed_backend", return_value=None)
92        p.start()
93        self.addCleanup(p.stop)
94
95    def test_the_computer_counts_only_the_cards_the_engine_drives(self):
96        comp = catalog(self.hw).computer()
97        self.assertEqual(comp.engine_vendor, "nvidia")
98        self.assertEqual([g["name"] for g in comp.usable_gpus], ["NVIDIA GeForce RTX 5060 Ti"])
99        self.assertEqual(comp.main_vram_gb, 16.0)                      # not the R9700's 32
100        self.assertEqual(comp.other_vendor_note, NOTE_AMD)
101        self.assertEqual(len(flow_for(type("C", (), {"computer": comp}))), 9)       # no Cards step: one card the engine can drive
102
103    def test_with_the_amd_engine_installed_the_r9700_counts_and_the_note_goes(self):
104        with mock.patch("strata_cli.launch.catalog.Catalog.installed_backend", return_value="hip"):
105            comp = catalog(self.hw).computer()
106        self.assertEqual(comp.engine_vendor, "amd")
107        self.assertEqual(comp.main_vram_gb, 32.0)
108        self.assertIsNone(comp.other_vendor_note)
109
110    def test_the_wizard_says_it_in_one_line(self):
111        s, notes = cmd.apply_defaults(S.LaunchSettings(family="qwen", model="IQ3_XXS"), catalog(self.hw))
112        self.assertIn(NOTE_AMD, [n.line() for n in notes] + [n.text for n in notes])
113
114    def 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
116        hw = {**HW_12, "gpus": [NV_5060TI, {**NV_5060TI, "index": 1}, {**AMD_R9700, "index": 2}]}
117        s, notes = cmd.apply_defaults(S.LaunchSettings(family="qwen", model="IQ3_XXS", gpus=[0, 2]), catalog(hw))
118        errors = [n for n in notes if n.level == "error"]
119        self.assertEqual(len(errors), 1)
120        text = errors[0].text
121        self.assertIn("Card 2 is an AMD card", text)
122        self.assertIn("cannot be split across NVIDIA and AMD cards", text)
123        self.assertIn("one model at a time", text)
124        self.assertIn("install the AMD build of Strata", errors[0].next)
125
126    def test_cards_for_launch_never_returns_the_other_make(self):
127        hw = {**HW_12, "ram_gb": 32.0, "gpus": [NV_5060TI, {**NV_5060TI, "index": 1}, {**AMD_R9700, "index": 2}]}
128        cat = catalog(hw)
129        got = cards_for_launch(S.LaunchSettings(family="qwen", model="IQ3_XXS"), cat)
130        self.assertTrue(all(i in (0, 1) for i in (got or [])))
131
132    def test_the_app_catalog_uses_the_engine_make(self):
133        cat = catalog(self.hw)
134        mcp = cat.mcp
135        hw = dict(self.hw)
136        mcp.Strata._engine_vendor(hw)
137        self.assertEqual(hw["engine_vendor"], "nvidia")
138        self.assertEqual(hw["gpu_note"], NOTE_AMD)
139        usable = cat.strata.engine_gpus(hw)
140        self.assertEqual([g["name"] for g in usable], ["NVIDIA GeForce RTX 5060 Ti"])
141        self.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})
143        two = {**hw, "gpus": [NV_5060TI, {**NV_5060TI, "index": 1}, AMD_R9700]}
144        res = cat.strata.gpu_options({"ram_gb": 20, "arena_gb": 30, "download_gb": 30}, 62.0, two)
145        self.assertEqual({tuple(o["cards"]) for o in res["options"]}, {(0,), (0, 1), (1,)})
146
147
148if __name__ == "__main__":
149    unittest.main()