Files
Strata/terminal/tools/test_setup_update_gpu.py
Niko1221 4058aa782b Layout move for 0.2.16: the top level becomes app/, engine/, terminal/, docs/, tools/ and .github/
Made by tools/layout/move_0216.py (the commit before this one) on db8e0be9c, the final code head of 0.2.16:
- 75 git mv (renames, so `git log --follow` and blame keep working; packaging/acceptance_matrix.md shows as delete + add because its links
  changed too) and 3 removals: SETUP.bat, UPDATE.bat and update.sh (setup.py --update pulls the code now);
- 1,425 path edits in 307 files: root-relative paths in CI, Docker, .gitignore and the release scripts; Markdown links; Python and
  Node joins from a root that moved with its folder; explicit edits for code that computes a root or names a moved path; tables of
  repository paths inside tests.

engine/ holds what CMake builds (src, include, cmake, metal, sycl, spark, third_party, the C++ tests and benches). app/ is the desktop
app and its host (was apps/). terminal/ is the Terminal in the layout of the installed one (strata.py, setup.py, strata_cli,
strata_control, serve, bin, data, ref, crates, the Python tools and tests). docs/ has the documentation, docs/lang/ the translated
READMEs, docs/history and docs/bench-results. tools/ has the repository's own checks, packaging, docker, research and nix.
tests/core/test_tqp_ref.py is a pytest file and stays with the Python tests (terminal/tests/core/).
AGENTS.md, README.md, LICENSE, setup.sh and START-HERE.bat stay at the root.

No behaviour change: the same command lines, the same sources. For this head a replay of the script gave the same numbers and the path
scan (tools/layout/checks/path_scan.py) reports no hit; the suites and the builds run on this commit next.
2026-11-17 13:19:21 +01:00

54 lines
2.0 KiB
Python

"""#1485: the card an engine update compiles for is one the installed models use (and CUDA 13 can compile for), not
the card with the most VRAM - a Tesla V100 beside two RTX 4090s made ./update.sh build for sm_70 with CUDA 13.
python -m unittest tools.test_setup_update_gpu -v
"""
import json
import sys
import tempfile
import unittest
from pathlib import Path
from unittest import mock
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
import setup # noqa: E402
V100 = {"index": 1, "name": "Tesla V100-PCIE-32GB", "vram_gb": 32.0, "arch": "70", "driver": "580"}
R4090 = lambda i: {"index": i, "name": "RTX 4090", "vram_gb": 24.0, "arch": "89", "driver": "580"} # noqa: E731
class UpdateEngineGpu(unittest.TestCase):
def pick(self, found, configs, toolkit=13, pinned=None):
tmp = tempfile.TemporaryDirectory()
self.addCleanup(tmp.cleanup)
paths = []
for n, cfg in enumerate(configs):
p = Path(tmp.name) / f"strata-{n}.json"
p.write_text(json.dumps(cfg))
paths.append(p)
with mock.patch.object(setup, "gpus", return_value=found), \
mock.patch.object(setup, "installed_configs", return_value=paths), \
mock.patch.object(setup, "GPU_PICK", pinned):
return setup.update_engine_gpu(toolkit)
def test_the_models_cards_not_the_biggest_one(self):
g = self.pick([R4090(0), V100, R4090(2)], [{"exe": "x", "args": [], "gpu": [0, 2]}])
self.assertEqual(g["arch"], "89")
self.assertEqual(g["count"], 3)
def test_a_card_cuda_13_cannot_compile_for_is_left_out_without_a_config(self):
self.assertEqual(self.pick([R4090(0), V100], [])["index"], 0)
def test_the_cuda_12_engine_may_take_the_volta(self):
self.assertEqual(self.pick([R4090(0), V100], [], toolkit=12)["index"], 1)
def test_only_a_volta_is_still_taken(self):
self.assertEqual(self.pick([V100], [])["index"], 1)
def test_no_nvidia_card(self):
self.assertIsNone(self.pick([], []))
if __name__ == "__main__":
unittest.main()