|
4 | 4 | import os |
5 | 5 | import platform |
6 | 6 | from pathlib import Path |
| 7 | +from types import SimpleNamespace |
7 | 8 |
|
8 | 9 | import pytest |
9 | 10 | from child_load_nvidia_dynamic_lib_helper import ( |
@@ -123,12 +124,39 @@ def test_known_but_platform_unavailable_libname_raises_dynamic_lib_not_available |
123 | 124 | def _is_expected_load_nvidia_dynamic_lib_failure(libname): |
124 | 125 | if libname == "nvpl_fftw" and platform.machine().lower() != "aarch64": |
125 | 126 | return True |
| 127 | + if libname == "cutensorMg": |
| 128 | + # cuTENSOR 2.8 removed cuTENSORMg in favor of cuTENSORMp. |
| 129 | + return have_distribution(r"^cutensor-cu(?:12|13)$", minimum_version="2.8") |
126 | 130 | dist_name_pattern = IMPORTLIB_METADATA_DISTRIBUTIONS_NAMES.get(libname) |
127 | 131 | if dist_name_pattern is not None: |
128 | 132 | return not have_distribution(dist_name_pattern) |
129 | 133 | return False |
130 | 134 |
|
131 | 135 |
|
| 136 | +@pytest.mark.parametrize( |
| 137 | + ("installed_distributions", "expected"), |
| 138 | + [ |
| 139 | + ([], False), |
| 140 | + ([SimpleNamespace(metadata={"Name": "cutensor-cu13"}, version="2.7.0")], False), |
| 141 | + ([SimpleNamespace(metadata={"Name": "cutensor-cu12"}, version="2.8.0")], True), |
| 142 | + ([SimpleNamespace(metadata={"Name": "cutensor-cu13"}, version="2.9.0")], True), |
| 143 | + ([SimpleNamespace(metadata={"Name": "unrelated-package"}, version="2.8.0")], False), |
| 144 | + ], |
| 145 | +) |
| 146 | +@pytest.mark.agent_authored(model="gpt-5.6-sol") |
| 147 | +def test_cutensor_mg_expected_failure_follows_installed_cutensor_version( |
| 148 | + mocker, |
| 149 | + installed_distributions, |
| 150 | + expected, |
| 151 | +): |
| 152 | + mocker.patch("local_helpers.importlib.metadata.distributions", return_value=installed_distributions) |
| 153 | + have_distribution.cache_clear() |
| 154 | + try: |
| 155 | + assert _is_expected_load_nvidia_dynamic_lib_failure("cutensorMg") is expected |
| 156 | + finally: |
| 157 | + have_distribution.cache_clear() |
| 158 | + |
| 159 | + |
132 | 160 | @pytest.mark.parametrize( |
133 | 161 | "libname", |
134 | 162 | supported_nvidia_libs.SUPPORTED_WINDOWS_DLLS if IS_WINDOWS else supported_nvidia_libs.SUPPORTED_LINUX_SONAMES, |
|
0 commit comments