setup: the sm_120 compiler warning covers CUDA 13.2.0 and 13.2.1 only; 13.2.2 (nvcc build 86) is accepted (#968); tests for it and for the per-family ROCm pins

This commit is contained in:
Niko1221 committed 2026-10-07 03:57:38 +02:00
1 parent 10f27e6e74
commit 1341e01a94
3 files changed
+189 -13

No files matched your search

+3 -3
View File
@@ -92,10 +92,10 @@ RTX 4080 SUPER). Try another driver (a Studio one, or an older one) and a lower
`--spec 4`, `--spec 0` avoids the verify window while you wait for a driver fix.
**An RTX 50 card (a source build with CUDA 13.2) answers with nonsense, or reads prompts wrongly (#892, #968).**
CUDA 13.2's compiler (nvcc 13.2.51) miscompiles some of the engine's kernels for sm_120: on our RTX 5070 the IQ2_S and IQ3_S
CUDA 13.2.0 and 13.2.1's compiler (nvcc 13.2.51) miscompile some of the engine's kernels for sm_120: on our RTX 5070 the IQ2_S and IQ3_S
products are wrong (relative error 0.5 to 1.0 in the tests) with 13.2 and right with 13.0. The ready-made engine is built
with 13.0. If you compile it yourself, use CUDA 13.0 or 13.1 (it can sit next to 13.2: `STRATA_NVCC=<path to its nvcc>`);
setup warns when it finds 13.2 for such a card, and takes an older 13.x when one is installed.
with 13.0. If you compile it yourself, use CUDA 13.0, 13.1 or 13.2.2 (13.2.2, nvcc build 13.2.86, fixes it; an older one can sit next to a newer: `STRATA_NVCC=<path to its nvcc>`);
setup warns when it finds 13.2.0 or 13.2.1 for such a card, and takes an older 13.x when one is installed.
**Pictures are refused, or slow.**
"this server was started without the vision encoder": the model was set up for text only - run setup again with
+20 -10
View File
@@ -2710,26 +2710,36 @@ def pip_cuda_libs(toolkit=13) -> None:
pip_install(CUDA_WHEELS, "NVIDIA CUDA libraries (cuBLAS, CUDA runtime; ~0.4 GB)")
CUDA_SM120_SUSPECT = (13, 2) # #892 #968: nvcc 13.2.51 for sm_120 made garbage answers (IQ1_S / IQ2_S / IQ3_S) and prompts
CUDA_SM120_SUSPECT = (13, 2) # #892 #968: nvcc 13.2.0 / 13.2.1 (build 13.2.51) for sm_120 made garbage answers (IQ1_S / IQ2_S / IQ3_S) and prompts
# (K-quant MMQ) that the same source compiled with 13.0.88 answers correctly (llama.cpp hit it too)
CUDA_SM120_FIXED_BUILD = 86 # CUDA 13.2.2 (nvcc build 13.2.86) fixes it (ggml-org/llama.cpp#28581, confirmed on a 5090 in #968)
def nvcc_build(nvcc):
"""The build number of an nvcc ("Build cuda_13.2.r13.2/compiler...", "V13.2.86" -> 86); None when it cannot be read."""
m = re.search(r"\bV\d+\.\d+\.(\d+)", out([nvcc, "--version"]) if nvcc else "")
return int(m.group(1)) if m else None
def sm120_nvcc(nvcc, cuda_v, archs):
"""#892 / #968: CUDA 13.2's nvcc for an RTX 50 card (sm_120). Returns (nvcc, cuda_v): an older 13.x toolkit when one is
installed and the user did not name a compiler (STRATA_NVCC), else the one found, with a warning that says what to
do. Recommends, never forces: a user who picked 13.2 keeps it."""
"""#892 / #968: CUDA 13.2.0 / 13.2.1's nvcc for an RTX 50 card (sm_120). Returns (nvcc, cuda_v): an older 13.x toolkit
when one is installed and the user did not name a compiler (STRATA_NVCC), else the one found, with a warning that says
what to do. CUDA 13.2.2 (build 86 or newer) is fine. Recommends, never forces: a user who picked 13.2 keeps it."""
if not nvcc or cuda_v != CUDA_SM120_SUSPECT or max(archs) < 120:
return nvcc, cuda_v
build = nvcc_build(nvcc)
if build is not None and build >= CUDA_SM120_FIXED_BUILD:
return nvcc, cuda_v
if not os.environ.get("STRATA_NVCC"):
alt, alt_v = find_nvcc(below=CUDA_SM120_SUSPECT)
if alt and alt_v and alt_v >= (13, 0):
ok(f"CUDA {alt_v[0]}.{alt_v[1]} is used for the RTX 50 card (sm_120): CUDA 13.2's compiler made wrong answers "
"there (#892, #968); STRATA_NVCC=<nvcc> picks another")
ok(f"CUDA {alt_v[0]}.{alt_v[1]} is used for the RTX 50 card (sm_120): CUDA 13.2.0 / 13.2.1's compiler made wrong "
"answers there (#892, #968); STRATA_NVCC=<nvcc> picks another")
return alt, alt_v
warn("CUDA 13.2's compiler (nvcc) made garbage prompts and answers for RTX 50 cards (sm_120) in two reports "
"(#892, #968): the same source compiled with CUDA 13.0 or 13.1 is right. If the engine answers with "
"nonsense, install CUDA 13.0 next to it (https://developer.nvidia.com/cuda-toolkit-archive) and set "
"STRATA_NVCC to its nvcc; the ready-made engine is built with 13.0")
warn("CUDA 13.2.0 and 13.2.1's compiler (nvcc) made garbage prompts and answers for RTX 50 cards (sm_120) in two "
"reports (#892, #968): the same source compiled with CUDA 13.0, 13.1 or 13.2.2 is right. If the engine answers "
"with nonsense, update to CUDA 13.2.2 or install CUDA 13.0 next to it (https://developer.nvidia.com/cuda-toolkit-archive) "
"and set STRATA_NVCC to its nvcc; the ready-made engine is built with 13.0")
return nvcc, cuda_v
+166
View File
@@ -0,0 +1,166 @@
"""Tests for the per-family ROCm wheel choice of setup.py (#1103, #1267), against the version lists that AMD's TheRock
indexes really offered on 2026-10-07 (tools/test_setup_rocm_indexes.json), and for the sm_120 compiler warning that
now covers CUDA 13.2.0 / 13.2.1 only (#968). No network, no GPU.
python -m unittest tools.test_setup_rocm_pins
"""
from __future__ import annotations
import json
import sys
import unittest
from pathlib import Path
from unittest import mock
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT))
import setup # noqa: E402
LISTINGS = json.loads((ROOT / "tools" / "test_setup_rocm_indexes.json").read_text(encoding="utf-8"))["indexes"]
def page(family):
"""The index page's html as pip sees it, from the saved version list."""
return "<html><body>" + "".join(f'<a href="../rocm-{v}.tar.gz">rocm-{v}.tar.gz</a><br/>' for v in LISTINGS[family]) + "</body></html>"
class RocmPick(unittest.TestCase):
def setUp(self):
p = mock.patch.object(setup, "ROCM_VERSION_OVERRIDE", None)
p.start()
self.addCleanup(p.stop)
def want(self, arch):
index = setup.ROCM_INDEXES[arch]
return setup.rocm_wanted(index, page(setup.rocm_family(index)))
def test_every_family_gets_a_version_its_index_has(self):
for arch in setup.ROCM_INDEXES:
with self.subTest(arch=arch):
version, note = self.want(arch)
self.assertIn(version, LISTINGS[setup.rocm_family(setup.ROCM_INDEXES[arch])])
self.assertIsNone(note, note) # the shipped pins all exist: no warning
def test_gfx103X_has_no_7_10_but_gets_the_7_13_pin(self): # #1103
self.assertFalse([v for v in LISTINGS["gfx103X-all"] if v.startswith("7.10")])
self.assertEqual(self.want("gfx1030"), ("7.13.0a20260515", None))
self.assertEqual(self.want("gfx1031"), ("7.13.0a20260515", None))
def test_gfx120X_and_gfx110X_keep_the_tested_version(self):
for arch in ("gfx1201", "gfx1200", "gfx1100", "gfx1101", "gfx1102"):
self.assertEqual(self.want(arch), ("7.10.0a20251120", None))
def test_gfx1151_is_off_the_7_10_wheel(self): # #1267
version, note = self.want("gfx1151")
self.assertEqual((version, note), ("7.14.0a20260608", None))
self.assertGreaterEqual(setup.rocm_vkey(version)[:2], (7, 11))
def test_pinned_version_gone_falls_back_to_the_same_line_with_a_warning(self):
old = setup.ROCM_FAMILY_PINS["gfx103X-all"]
with mock.patch.dict(setup.ROCM_FAMILY_PINS, {"gfx103X-all": "7.13.0a20260301"}):
version, note = setup.rocm_wanted(setup.ROCM_INDEXES["gfx1030"], page("gfx103X-all"))
self.assertEqual(version, "7.13.0a20260515") # the newest of 7.13, not of 7.14
self.assertIn("7.13.0a20260301", note)
self.assertIn("same line", note)
self.assertEqual(old, "7.13.0a20260515")
def test_whole_line_gone_falls_back_to_the_same_major(self):
# gfx103X-all has no 7.10 line at all: the default 7.10.0a20251120 would land on the newest 7.x there
with mock.patch.dict(setup.ROCM_FAMILY_PINS, {"gfx103X-all": "7.10.0a20251120"}):
version, note = setup.rocm_wanted(setup.ROCM_INDEXES["gfx1030"], page("gfx103X-all"))
self.assertEqual(version, "7.14.0a20260612")
self.assertIn("same major", note)
def test_other_major_is_not_taken(self):
version, note = setup.rocm_pick(["6.5.0rc20250610"], "7.10.0a20251120")
self.assertEqual(version, "7.10.0a20251120")
self.assertIn("nothing of its major", note)
def test_unreadable_index_keeps_the_preferred_version(self):
self.assertEqual(setup.rocm_pick([], "7.10.0a20251120"), ("7.10.0a20251120", None))
with mock.patch.object(setup.urllib.request, "urlopen", side_effect=OSError("offline")):
self.assertEqual(setup.rocm_wanted(setup.ROCM_INDEXES["gfx1030"]), ("7.13.0a20260515", None))
def test_the_index_page_is_read_from_the_rocm_folder(self):
seen = []
class Resp:
def __enter__(self): return self
def __exit__(self, *a): return False
def read(self): return page("gfx103X-all").encode()
def fake(req, timeout=0):
seen.append(req.full_url)
return Resp()
with mock.patch.object(setup.urllib.request, "urlopen", fake):
self.assertEqual(setup.rocm_wanted(setup.ROCM_INDEXES["gfx1030"])[0], "7.13.0a20260515")
self.assertEqual(seen, ["https://rocm.nightlies.amd.com/v2/gfx103X-all/rocm/"])
def test_the_override_is_exact_and_not_looked_up(self):
with mock.patch.object(setup, "ROCM_VERSION_OVERRIDE", "7.12.0a20260311"), \
mock.patch.object(setup.urllib.request, "urlopen", side_effect=AssertionError("no lookup")):
self.assertEqual(setup.rocm_wanted(setup.ROCM_INDEXES["gfx1030"]), ("7.12.0a20260311", None))
with mock.patch.object(setup, "ROCM_VERSION_OVERRIDE", "7.10.0a20251120"): # forced, but still warned about
version, note = setup.rocm_wanted(setup.ROCM_INDEXES["gfx1151"])
self.assertEqual(version, "7.10.0a20251120")
self.assertIn("segfault", note)
def test_gfx1151_on_the_7_10_wheel_warns(self): # #1267 with an override or a fallback
version, note = None, None
with mock.patch.dict(setup.ROCM_FAMILY_PINS, {"gfx1151": "7.10.0a20251120"}):
version, note = setup.rocm_wanted(setup.ROCM_INDEXES["gfx1151"], page("gfx1151"))
self.assertEqual(version, "7.10.0a20251120")
self.assertIn("segfault", note)
def test_version_order(self):
v = setup.rocm_index_versions(page("gfx1151"))
self.assertEqual(v, sorted(v, key=setup.rocm_vkey))
self.assertEqual(v[-1], "7.14.0a20260612")
self.assertLess(setup.rocm_vkey("7.9.0rc20251008"), setup.rocm_vkey("7.10.0a20251009")) # 7.9 before 7.10
class Sm120Compiler(unittest.TestCase):
"""#968: only CUDA 13.2.0 / 13.2.1 (nvcc build 51) are warned about; 13.2.2 (build 86) is accepted."""
def run_sm120(self, build, archs=(120,), cuda_v=(13, 2), env=None):
with mock.patch.object(setup, "nvcc_build", return_value=build), \
mock.patch.object(setup, "find_nvcc", return_value=(None, None)), \
mock.patch.object(setup, "warn") as warn, mock.patch.object(setup, "ok"), \
mock.patch.dict(setup.os.environ, env or {}):
got = setup.sm120_nvcc("nvcc", cuda_v, list(archs))
return got, warn
def test_13_2_0_and_13_2_1_warn(self):
for build in (51, 78, None): # None: a build that cannot be read stays suspect
got, warn = self.run_sm120(build)
self.assertEqual(got, ("nvcc", (13, 2)))
warn.assert_called_once()
self.assertIn("13.2.0", warn.call_args[0][0])
def test_13_2_2_is_accepted_silently(self):
for build in (86, 90):
got, warn = self.run_sm120(build)
self.assertEqual(got, ("nvcc", (13, 2)))
warn.assert_not_called()
def test_13_2_2_keeps_the_newest_toolkit_not_an_older_one(self):
with mock.patch.object(setup, "nvcc_build", return_value=86), \
mock.patch.object(setup, "find_nvcc", side_effect=AssertionError("must not look for an older one")):
self.assertEqual(setup.sm120_nvcc("nvcc", (13, 2), [120]), ("nvcc", (13, 2)))
def test_not_sm120_or_not_13_2_is_untouched(self):
for archs, v in (((86,), (13, 2)), ((120,), (13, 0)), ((120,), (13, 3))):
got, warn = self.run_sm120(51, archs, v)
self.assertEqual(got, ("nvcc", v))
warn.assert_not_called()
def test_build_number_is_read_from_nvcc_output(self):
text = "nvcc: NVIDIA (R) Cuda compiler driver\nCuda compilation tools, release 13.2, V13.2.86\nBuild cuda_13.2.r13.2/compiler.123_0\n"
with mock.patch.object(setup, "out", return_value=text):
self.assertEqual(setup.nvcc_build("nvcc"), 86)
with mock.patch.object(setup, "out", return_value=""):
self.assertIsNone(setup.nvcc_build("nvcc"))
if __name__ == "__main__":
unittest.main()