Skip to content
Open
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
4 changes: 2 additions & 2 deletions cuda_pathfinder/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Windows.
defines canonical metadata for known libraries.
- **Registry layers**:
- `lib_descriptor.py` builds the name-keyed runtime registry from the catalog.
- `supported_nvidia_libs.py` keeps legacy exported tables derived from the
catalog for compatibility.
- `supported_nvidia_libs.py` derives the name sets and filename tables that
the package itself reads from the catalog.
- **Search pipeline**:
- `search_steps.py` implements composable find steps (`site-packages`,
`CONDA_PREFIX`, `CUDA_HOME`/`CUDA_PATH`, canary-assisted CTK root flow).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

"""Legacy table exports derived from the authored descriptor catalog.
"""Library-name sets and filename tables derived from the authored descriptor catalog.

The canonical data entry point is :mod:`descriptor_catalog`. This module keeps
historical constant names for backward compatibility by deriving them from the
catalog.

The unsuffixed ``SUPPORTED_LIBNAMES_WINDOWS`` and
``SITE_PACKAGES_LIBDIRS_WINDOWS*`` constants retain their historical x64
meaning for compatibility, but are not recommended for new code. Use the
explicit ``*_X64`` or ``*_ARM64`` projection instead. Never combine the two
architecture projections.
The canonical data entry point is :mod:`descriptor_catalog`. This module holds
only the projections that the package itself reads.
"""

from __future__ import annotations
Expand All @@ -22,7 +15,6 @@
_CTK_DESCRIPTORS = tuple(desc for desc in DESCRIPTOR_CATALOG if desc.packaged_with == "ctk")
_OTHER_DESCRIPTORS = tuple(desc for desc in DESCRIPTOR_CATALOG if desc.packaged_with == "other")
_DRIVER_DESCRIPTORS = tuple(desc for desc in DESCRIPTOR_CATALOG if desc.packaged_with == "driver")
_NON_CTK_DESCRIPTORS = _OTHER_DESCRIPTORS + _DRIVER_DESCRIPTORS


def _legacy_least_preferred_first(names: tuple[str, ...]) -> tuple[str, ...]:
Expand All @@ -34,9 +26,6 @@ def _legacy_least_preferred_first(names: tuple[str, ...]) -> tuple[str, ...]:
SUPPORTED_LIBNAMES_LINUX_ONLY = tuple(
desc.name for desc in _CTK_DESCRIPTORS if desc.linux_sonames and not desc.windows_dlls
)
SUPPORTED_LIBNAMES_WINDOWS_ONLY = tuple(
desc.name for desc in _CTK_DESCRIPTORS if desc.windows_dlls and not desc.linux_sonames
)

if not IS_WINDOWS:
ALL_AVAILABLE_LIBNAMES = frozenset(desc.name for desc in DESCRIPTOR_CATALOG if desc.linux_sonames)
Expand All @@ -52,9 +41,6 @@ def _legacy_least_preferred_first(names: tuple[str, ...]) -> tuple[str, ...]:
SUPPORTED_LIBNAMES_WINDOWS_ARM64 = tuple(
desc.name for desc in _CTK_DESCRIPTORS if "arm64" in desc.supported_windows_arch
)

@coderabbitai coderabbitai Bot Nov 26, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Major · Data Integrity & Integration · Quick win

important: Keep the documented Windows aliases or revise the 1.6.1 promise.

The 1.6.1 release notes state that the unsuffixed SUPPORTED_LIBNAMES_WINDOWS* and SITE_PACKAGES_LIBDIRS_WINDOWS* names "remain x64 aliases for backward compatibility." This change removes those names. An import of any of them from cuda.pathfinder._dynamic_libs.supported_nvidia_libs now fails with ImportError.

The impact is limited to code that imports this private module directly. No code in this repository imports the removed unsuffixed names, and the public cuda.pathfinder API is unchanged. The suffixed SUPPORTED_LIBNAMES_WINDOWS_X64 and SUPPORTED_LIBNAMES_WINDOWS_ARM64 names remain.

Before merging, choose one of the following:

  • Keep the unsuffixed names, so they resolve to their x64 values.
  • Withdraw the compatibility promise in the 1.6.1 release notes, and document the removal in the next version's notes.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Taking the second option: this withdraws the 1.6.1 promise.

The removal is intended. The names live in a private module and nothing in this repository reads them. The PR description now says this up front and lists the four aliases removed.

The release-note line is drafted in the description. It goes into the notes file once the next version has one.

# Backward-compatible alias preserves the historical x64 meaning.
SUPPORTED_LIBNAMES_WINDOWS = SUPPORTED_LIBNAMES_WINDOWS_X64
SUPPORTED_LIBNAMES_ALL = SUPPORTED_LIBNAMES_COMMON + SUPPORTED_LIBNAMES_LINUX_ONLY + SUPPORTED_LIBNAMES_WINDOWS_ONLY
if not IS_WINDOWS:
SUPPORTED_LIBNAMES = SUPPORTED_LIBNAMES_LINUX
elif IS_WINDOWS_X64:
Expand All @@ -63,9 +49,6 @@ def _legacy_least_preferred_first(names: tuple[str, ...]) -> tuple[str, ...]:
assert IS_WINDOWS_ARM64
SUPPORTED_LIBNAMES = SUPPORTED_LIBNAMES_WINDOWS_ARM64

DIRECT_DEPENDENCIES_CTK = {desc.name: desc.dependencies for desc in _CTK_DESCRIPTORS if desc.dependencies}
DIRECT_DEPENDENCIES = {desc.name: desc.dependencies for desc in DESCRIPTOR_CATALOG if desc.dependencies}

SUPPORTED_LINUX_SONAMES_CTK = {
desc.name: _legacy_least_preferred_first(desc.linux_sonames) for desc in _CTK_DESCRIPTORS if desc.linux_sonames
}
Expand All @@ -88,45 +71,6 @@ def _legacy_least_preferred_first(names: tuple[str, ...]) -> tuple[str, ...]:
}
SUPPORTED_WINDOWS_DLLS = SUPPORTED_WINDOWS_DLLS_CTK | SUPPORTED_WINDOWS_DLLS_OTHER | SUPPORTED_WINDOWS_DLLS_DRIVER

LIBNAMES_REQUIRING_OS_ADD_DLL_DIRECTORY = tuple(
desc.name for desc in DESCRIPTOR_CATALOG if desc.requires_add_dll_directory and desc.windows_dlls
)
LIBNAMES_REQUIRING_RTLD_DEEPBIND = tuple(
desc.name for desc in DESCRIPTOR_CATALOG if desc.requires_rtld_deepbind and desc.linux_sonames
)

SITE_PACKAGES_LIBDIRS_LINUX_CTK = {
desc.name: desc.site_packages_linux for desc in _CTK_DESCRIPTORS if desc.site_packages_linux
}
SITE_PACKAGES_LIBDIRS_LINUX_OTHER = {
desc.name: desc.site_packages_linux for desc in _NON_CTK_DESCRIPTORS if desc.site_packages_linux
}
SITE_PACKAGES_LIBDIRS_LINUX = SITE_PACKAGES_LIBDIRS_LINUX_CTK | SITE_PACKAGES_LIBDIRS_LINUX_OTHER

# Architecture-specific Windows projections. Keep these separate: combining
# them would make the table unsafe to consume for either process ABI.
SITE_PACKAGES_LIBDIRS_WINDOWS_CTK_X64 = {
desc.name: desc.site_packages_windows.x64 for desc in _CTK_DESCRIPTORS if desc.site_packages_windows.x64
}
SITE_PACKAGES_LIBDIRS_WINDOWS_CTK_ARM64 = {
desc.name: desc.site_packages_windows.arm64 for desc in _CTK_DESCRIPTORS if desc.site_packages_windows.arm64
}
SITE_PACKAGES_LIBDIRS_WINDOWS_OTHER_X64 = {
desc.name: desc.site_packages_windows.x64 for desc in _NON_CTK_DESCRIPTORS if desc.site_packages_windows.x64
}
SITE_PACKAGES_LIBDIRS_WINDOWS_OTHER_ARM64 = {
desc.name: desc.site_packages_windows.arm64 for desc in _NON_CTK_DESCRIPTORS if desc.site_packages_windows.arm64
}
SITE_PACKAGES_LIBDIRS_WINDOWS_X64 = SITE_PACKAGES_LIBDIRS_WINDOWS_CTK_X64 | SITE_PACKAGES_LIBDIRS_WINDOWS_OTHER_X64
SITE_PACKAGES_LIBDIRS_WINDOWS_ARM64 = (
SITE_PACKAGES_LIBDIRS_WINDOWS_CTK_ARM64 | SITE_PACKAGES_LIBDIRS_WINDOWS_OTHER_ARM64
)

# Backward-compatible aliases preserve the historical x64 meaning.
SITE_PACKAGES_LIBDIRS_WINDOWS_CTK = SITE_PACKAGES_LIBDIRS_WINDOWS_CTK_X64
SITE_PACKAGES_LIBDIRS_WINDOWS_OTHER = SITE_PACKAGES_LIBDIRS_WINDOWS_OTHER_X64
SITE_PACKAGES_LIBDIRS_WINDOWS = SITE_PACKAGES_LIBDIRS_WINDOWS_X64


def is_suppressed_dll_file(path_basename: str) -> bool:
if path_basename.startswith("nvrtc"):
Expand Down
7 changes: 7 additions & 0 deletions cuda_pathfinder/tests/test_descriptor_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ def test_has_at_least_one_soname_or_dll(spec: DescriptorSpec):
assert spec.linux_sonames or spec.windows_dlls, f"{spec.name} has no sonames or DLLs"


@pytest.mark.parametrize("spec", DESCRIPTOR_CATALOG, ids=lambda s: s.name)
@pytest.mark.agent_authored(model="claude-fable-5-2")
def test_platform_load_flags_require_that_platform_filenames(spec: DescriptorSpec):
assert not spec.requires_add_dll_directory or spec.windows_dlls
assert not spec.requires_rtld_deepbind or spec.linux_sonames


@pytest.mark.parametrize("spec", DESCRIPTOR_CATALOG, ids=lambda s: s.name)
def test_dependencies_reference_existing_entries(spec: DescriptorSpec):
for dep in spec.dependencies:
Expand Down
59 changes: 1 addition & 58 deletions cuda_pathfinder/tests/test_lib_descriptor.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

"""Tests for the canonical library descriptors and their legacy projections."""
"""Tests for the canonical library descriptors and the tables derived from them."""

import pytest

from cuda.pathfinder._dynamic_libs.lib_descriptor import LIB_DESCRIPTORS
from cuda.pathfinder._dynamic_libs.supported_nvidia_libs import (
DIRECT_DEPENDENCIES,
LIBNAMES_REQUIRING_OS_ADD_DLL_DIRECTORY,
LIBNAMES_REQUIRING_RTLD_DEEPBIND,
SITE_PACKAGES_LIBDIRS_LINUX,
SITE_PACKAGES_LIBDIRS_WINDOWS,
SITE_PACKAGES_LIBDIRS_WINDOWS_ARM64,
SITE_PACKAGES_LIBDIRS_WINDOWS_CTK,
SITE_PACKAGES_LIBDIRS_WINDOWS_CTK_X64,
SITE_PACKAGES_LIBDIRS_WINDOWS_OTHER,
SITE_PACKAGES_LIBDIRS_WINDOWS_OTHER_X64,
SITE_PACKAGES_LIBDIRS_WINDOWS_X64,
SUPPORTED_LIBNAMES,
SUPPORTED_LIBNAMES_LINUX,
SUPPORTED_LIBNAMES_WINDOWS,
SUPPORTED_LIBNAMES_WINDOWS_ARM64,
SUPPORTED_LIBNAMES_WINDOWS_X64,
SUPPORTED_LINUX_SONAMES,
Expand Down Expand Up @@ -61,36 +49,6 @@ def test_windows_dlls_match(name):
assert tuple(reversed(LIB_DESCRIPTORS[name].windows_dlls)) == SUPPORTED_WINDOWS_DLLS.get(name, ())


@pytest.mark.parametrize("name", sorted(LIB_DESCRIPTORS))
def test_site_packages_linux_match(name):
assert LIB_DESCRIPTORS[name].site_packages_linux == SITE_PACKAGES_LIBDIRS_LINUX.get(name, ())


@pytest.mark.parametrize(
("target_arch", "site_packages_libdirs"),
[
("x64", SITE_PACKAGES_LIBDIRS_WINDOWS_X64),
("arm64", SITE_PACKAGES_LIBDIRS_WINDOWS_ARM64),
],
)
@pytest.mark.parametrize("name", sorted(LIB_DESCRIPTORS))
@pytest.mark.agent_authored(model="gpt-5")
def test_site_packages_windows_match(name, target_arch, site_packages_libdirs):
assert LIB_DESCRIPTORS[name].site_packages_windows.for_arch(target_arch) == site_packages_libdirs.get(name, ())


@pytest.mark.agent_authored(model="gpt-5")
def test_legacy_site_packages_windows_tables_are_x64_aliases():
assert SITE_PACKAGES_LIBDIRS_WINDOWS_CTK is SITE_PACKAGES_LIBDIRS_WINDOWS_CTK_X64
assert SITE_PACKAGES_LIBDIRS_WINDOWS_OTHER is SITE_PACKAGES_LIBDIRS_WINDOWS_OTHER_X64
assert SITE_PACKAGES_LIBDIRS_WINDOWS is SITE_PACKAGES_LIBDIRS_WINDOWS_X64


@pytest.mark.agent_authored(model="gpt-5")
def test_legacy_supported_libnames_windows_is_x64_alias():
assert SUPPORTED_LIBNAMES_WINDOWS is SUPPORTED_LIBNAMES_WINDOWS_X64


@pytest.mark.agent_authored(model="gpt-5")
def test_supported_libnames_selects_current_platform_and_arch():
if not IS_WINDOWS:
Expand All @@ -111,21 +69,6 @@ def test_arch_specific_ctk_libname_projections():
assert "nvjpeg" in SUPPORTED_LIBNAMES_WINDOWS_ARM64


@pytest.mark.parametrize("name", sorted(LIB_DESCRIPTORS))
def test_dependencies_match(name):
assert LIB_DESCRIPTORS[name].dependencies == DIRECT_DEPENDENCIES.get(name, ())


@pytest.mark.parametrize("name", sorted(LIB_DESCRIPTORS))
def test_requires_add_dll_directory_match(name):
assert LIB_DESCRIPTORS[name].requires_add_dll_directory == (name in LIBNAMES_REQUIRING_OS_ADD_DLL_DIRECTORY)


@pytest.mark.parametrize("name", sorted(LIB_DESCRIPTORS))
def test_requires_rtld_deepbind_match(name):
assert LIB_DESCRIPTORS[name].requires_rtld_deepbind == (name in LIBNAMES_REQUIRING_RTLD_DEEPBIND)


# ---------------------------------------------------------------------------
# Strategy classification
# ---------------------------------------------------------------------------
Expand Down
40 changes: 15 additions & 25 deletions cuda_pathfinder/tests/test_load_nvidia_dynamic_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,37 +38,34 @@ def test_supported_libnames_linux_sonames_consistency():
)


_CTK_DESCRIPTORS = tuple(
desc for desc in load_nvidia_dynamic_lib_module.LIB_DESCRIPTORS.values() if desc.packaged_with == "ctk"
)


@pytest.mark.agent_authored(model="claude-fable-5-2")
def test_supported_libnames_linux_site_packages_libdirs_ctk_consistency():
assert tuple(sorted(supported_nvidia_libs.SUPPORTED_LIBNAMES_LINUX)) == tuple(
sorted(supported_nvidia_libs.SITE_PACKAGES_LIBDIRS_LINUX_CTK.keys())
sorted(desc.name for desc in _CTK_DESCRIPTORS if desc.site_packages_linux)
)


@pytest.mark.parametrize(
("site_packages_libdirs", "supported_libnames"),
("target_arch", "supported_libnames"),
[
pytest.param(
supported_nvidia_libs.SITE_PACKAGES_LIBDIRS_WINDOWS_CTK_X64,
supported_nvidia_libs.SUPPORTED_LIBNAMES_WINDOWS_X64,
id="x64",
),
pytest.param(
supported_nvidia_libs.SITE_PACKAGES_LIBDIRS_WINDOWS_CTK_ARM64,
supported_nvidia_libs.SUPPORTED_LIBNAMES_WINDOWS_ARM64,
id="arm64",
),
pytest.param("x64", supported_nvidia_libs.SUPPORTED_LIBNAMES_WINDOWS_X64, id="x64"),
pytest.param("arm64", supported_nvidia_libs.SUPPORTED_LIBNAMES_WINDOWS_ARM64, id="arm64"),
],
)
@pytest.mark.human_reviewed
def test_supported_libnames_windows_site_packages_libdirs_ctk_consistency(
site_packages_libdirs,
supported_libnames,
):
@pytest.mark.agent_authored(model="claude-fable-5-2")
def test_supported_libnames_windows_site_packages_libdirs_ctk_consistency(target_arch, supported_libnames):
# Not every Windows CTK library ships in a pip wheel (e.g. cudla is loaded
# from the local CUDA Toolkit only), so a library may legitimately omit
# site_packages_windows. Only assert that every site-packages entry maps to
# a supported Windows libname, not the other way around.
site_packages_libnames = set(site_packages_libdirs)
site_packages_libnames = {
desc.name for desc in _CTK_DESCRIPTORS if desc.site_packages_windows.for_arch(target_arch)
}
assert site_packages_libnames <= set(supported_libnames)


Expand All @@ -84,13 +81,6 @@ def test_libname_dict_values_are_unique(dict_name):
libname_for_value[value] = libname


def test_supported_libnames_windows_libnames_requiring_os_add_dll_directory_consistency():
assert not (
set(supported_nvidia_libs.LIBNAMES_REQUIRING_OS_ADD_DLL_DIRECTORY)
- set(supported_nvidia_libs.SUPPORTED_WINDOWS_DLLS)
)


def test_runtime_error_on_non_64bit_python(mocker):
# Ensure this test is not affected by any prior cached calls.
load_nvidia_dynamic_lib.cache_clear()
Expand Down
Loading