From cfa7f737cca11b1eec840e8fa3c3dc5db9ca118e Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Fri, 30 Oct 2026 19:18:01 +0100 Subject: [PATCH] Setup: a compiled engine gets code for every usable NVIDIA card in the PC, not only the card setup picked (a TITAN RTX + RTX 3080 build for sm_75 only failed every long prompt with unspecified launch failure) (#4662) --- setup.py | 13 ++++++++++++ tools/test_setup_build_archs.py | 36 +++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 tools/test_setup_build_archs.py diff --git a/setup.py b/setup.py index ad0421ea..b51888bb 100644 --- a/setup.py +++ b/setup.py @@ -5817,6 +5817,18 @@ def prebuilt_vision(meta: dict, gpu: dict, vision: str) -> str: return vision +def local_build_archs(archs, found) -> list: + """#4662: the architectures a compiled engine gets code for: the cards this install uses AND every other card Strata can run on in the PC. + A PC with a TITAN RTX (sm_75) and an RTX 3080 (sm_86) was updated with archs [75] (the pair was not picked as a split by setup), and the + layer-split run on both cards then launched kernels the sm_75 build holds only a trap for: "unspecified launch failure" on every long prompt. + One more architecture is a few more minutes of compile, once; a card Strata cannot use (older than sm_75) is left out.""" + try: + present = {int(g["arch"]) for g in found or [] if gpu_problem(g) is None} + except (KeyError, TypeError, ValueError): + present = set() + return sorted({int(x) for x in archs} | present) + + def build_engine(gpu, vision, yes, llama, toolkit=None) -> Path: """Compile the engine (and, for images, the encoder) for this GPU; the results go to engine/. A compiled engine whose source files changed since (a `git pull`) is compiled again: only the changed files, a few minutes. @@ -5834,6 +5846,7 @@ def build_engine(gpu, vision, yes, llama, toolkit=None) -> Path: local = meta.get("source") == "local" src, vsrc = source_hash(ENGINE_SOURCES), source_hash(VISION_SOURCES) archs = sorted({int(x) for x in gpu.get("archs", [gpu["arch"]])}) # every card the model runs on + archs = local_build_archs(archs, gpus()) # #4662: and every other card in the PC built = set(arch_numbers(meta.get("archs"))) # a card the engine has no code for (a GPU added with --gpus, #128) needs a compile even when the source is the # same; the compile keeps the generations it was built for diff --git a/tools/test_setup_build_archs.py b/tools/test_setup_build_archs.py new file mode 100644 index 00000000..930f0ac4 --- /dev/null +++ b/tools/test_setup_build_archs.py @@ -0,0 +1,36 @@ +"""#4662: a compiled engine gets code for every card Strata can use in the PC, not only the card setup picked. + + python -m unittest tools.test_setup_build_archs +""" +import sys +import unittest +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] +sys.path.insert(0, str(ROOT)) +import setup # noqa: E402 + + +def card(index, arch, vram=16.0): + return {"index": index, "arch": arch, "vram_gb": vram, "name": f"card{index}"} + + +class BuildArchs(unittest.TestCase): + def test_a_mixed_pair_gets_both_architectures(self): + found = [card(0, 75, 24), card(1, 86, 12)] + self.assertEqual(setup.local_build_archs([75], found), [75, 86]) + + def test_one_card_stays_one_architecture(self): + self.assertEqual(setup.local_build_archs([89], [card(0, 89, 24)]), [89]) + + def test_a_card_older_than_sm75_is_left_out(self): + self.assertEqual(setup.local_build_archs([86], [card(0, 86), card(1, 61)]), [86]) + + def test_no_card_answer_keeps_the_given_ones(self): + self.assertEqual(setup.local_build_archs([75, 86], []), [75, 86]) + self.assertEqual(setup.local_build_archs([86], None), [86]) + self.assertEqual(setup.local_build_archs([86], [{"index": 0}]), [86]) + + +if __name__ == "__main__": + unittest.main()