Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cuda_bindings/tests/test_cufile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1520,6 +1520,7 @@ def stats(driver):
cufileVersionLessThan(1150), reason="cuFile parameter APIs require cuFile library version 13.0 or later"
)
@pytest.mark.usefixtures("stats")
@pytest.mark.thread_unsafe(reason="cuFile stats level is process-global")
def test_set_stats_level():
"""Test cuFile statistics level configuration."""
# Test setting different statistics levels
Expand Down
8 changes: 6 additions & 2 deletions cuda_pathfinder/tests/local_helpers.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

import functools
import importlib.metadata
import re

from packaging.version import Version


@functools.cache
def have_distribution(name_pattern: str) -> bool:
def have_distribution(name_pattern: str, *, minimum_version: str | None = None) -> bool:
re_name_pattern = re.compile(name_pattern)
parsed_minimum_version = Version(minimum_version) if minimum_version is not None else None
return any(
re_name_pattern.match(dist.metadata["Name"])
and (parsed_minimum_version is None or Version(dist.version) >= parsed_minimum_version)
for dist in importlib.metadata.distributions()
if "Name" in dist.metadata
)
28 changes: 28 additions & 0 deletions cuda_pathfinder/tests/test_load_nvidia_dynamic_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import platform
from pathlib import Path
from types import SimpleNamespace

import pytest
from child_load_nvidia_dynamic_lib_helper import (
Expand Down Expand Up @@ -123,12 +124,39 @@ def test_known_but_platform_unavailable_libname_raises_dynamic_lib_not_available
def _is_expected_load_nvidia_dynamic_lib_failure(libname):
if libname == "nvpl_fftw" and platform.machine().lower() != "aarch64":
return True
if libname == "cutensorMg":
# cuTENSOR 2.8 removed cuTENSORMg in favor of cuTENSORMp.
return have_distribution(r"^cutensor-cu(?:12|13)$", minimum_version="2.8")
dist_name_pattern = IMPORTLIB_METADATA_DISTRIBUTIONS_NAMES.get(libname)
if dist_name_pattern is not None:
return not have_distribution(dist_name_pattern)
return False


@pytest.mark.parametrize(
("installed_distributions", "expected"),
[
([], False),
([SimpleNamespace(metadata={"Name": "cutensor-cu13"}, version="2.7.0")], False),
([SimpleNamespace(metadata={"Name": "cutensor-cu12"}, version="2.8.0")], True),
([SimpleNamespace(metadata={"Name": "cutensor-cu13"}, version="2.9.0")], True),
([SimpleNamespace(metadata={"Name": "unrelated-package"}, version="2.8.0")], False),
],
)
@pytest.mark.agent_authored(model="gpt-5.6-sol")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test feels a bit redundant, but maybe some small value for have_distribution getting this logic wrong.

(It might make sense to check on successful load that _is_expected_load_nvidia_dynamic_lib_failure isn't True. But I think the function isn't strict it just says if a failure is acceptable).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This came from #2809, which I had to include here for the CI to pass, but it was merged before this PR. The net change in this PR is only the one-line addition of the marker (git show 51ec66b after this PR was merged).

I agree the test is more defensive than what a human would write, but it's not wrong, and trimming back the defensiveness takes time, so I often/usually leave it as-is; it's clearly marked as agent-generated.

def test_cutensor_mg_expected_failure_follows_installed_cutensor_version(
mocker,
installed_distributions,
expected,
):
mocker.patch("local_helpers.importlib.metadata.distributions", return_value=installed_distributions)
have_distribution.cache_clear()
try:
assert _is_expected_load_nvidia_dynamic_lib_failure("cutensorMg") is expected
finally:
have_distribution.cache_clear()


@pytest.mark.parametrize(
"libname",
supported_nvidia_libs.SUPPORTED_WINDOWS_DLLS if IS_WINDOWS else supported_nvidia_libs.SUPPORTED_LINUX_SONAMES,
Expand Down
Loading