okami.mom/strata

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

Niko1221Merge tag 'v0.2.9' into f-041-maya-b8ea5361bf

main
2.3 KiB53 linesraw
1"""A card that works alone but cannot share a model (under 7.5 GB) beside a bigger NVIDIA card: setup says it is not used (a line, no question, no
2change to which cards run).  Fake cards through setup.main (tools/test_setup_golden.py's harness)."""
3from __future__ import annotations
4
5import sys
6import unittest
7from pathlib import Path
8
9sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
10sys.path.insert(0, str(Path(__file__).resolve().parent))
11from test_setup_golden import install, argv_for       # noqa: E402
12
13
14def card(i, name, gb, arch="86"):
15    return {"index": i, "name": name, "vram_gb": gb, "arch": arch, "driver": "580.97"}
16
17
18BIG = card(0, "NVIDIA GeForce RTX 4090", 24.0, "89")
19SMALL = card(1, "NVIDIA GeForce RTX 2060", 5.9, "75")
20
21
22class SmallCardSaid(unittest.TestCase):
23    def run_it(self, found, extra=()):
24        code, out, cfg, asked = install(256.0, found, argv_for("qwen", "IQ3_S") + ["--yes", *extra])
25        self.assertEqual(code, 0, out)
26        return out, cfg, asked
27
28    def test_the_small_card_is_named_with_the_reason(self):
29        out, cfg, asked = self.run_it([BIG, SMALL])
30        self.assertIn("GPU 1 (NVIDIA GeForce RTX 2060, 6 GB) is not used", out)
31        self.assertIn("needs 8 GB or more", out)
32        self.assertIn("runs on GPU 0 alone", out)
33        self.assertEqual(asked, [])                                   # printed only
34        self.assertEqual((cfg["gpu"], cfg["gpus_asked"]), (0, True))   # the cards used are what they were
35
36    def test_the_small_card_listed_first(self):
37        out, cfg, _ = self.run_it([card(0, "NVIDIA GeForce RTX 2060", 5.9, "75"), card(1, "NVIDIA GeForce RTX 4090", 24.0, "89")])
38        self.assertIn("GPU 0 (NVIDIA GeForce RTX 2060, 6 GB) is not used", out)
39        self.assertEqual(cfg["gpu"], 1)
40
41    def test_nothing_is_said_where_nothing_is_left_out(self):
42        for found in ([BIG], [BIG, card(1, "NVIDIA GeForce RTX 3060", 12.0)], [BIG, card(1, "NVIDIA GeForce RTX 3070", 8.0)]):
43            out, _cfg, _ = self.run_it(found)
44            self.assertNotIn("is not used", out, found)
45
46    def test_naming_a_card_says_nothing_extra(self):
47        out, cfg, _ = self.run_it([BIG, SMALL], ["--gpu", "0"])
48        self.assertNotIn("is not used", out)
49        self.assertEqual(cfg["gpu"], 0)
50
51
52if __name__ == "__main__":
53    unittest.main()