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
9 changes: 5 additions & 4 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` derives the name sets and filename tables that
the package itself reads from the catalog.
- `supported_nvidia_libs.py` derives the library-name sets 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 All @@ -38,8 +38,9 @@ Windows.
## Editing guidance

- **Edit authored descriptors, not derived tables**: when adding/changing a
library, update `descriptor_catalog.py` first; keep derived exports in sync
through existing conversion logic and tests.
library, update `descriptor_catalog.py`. The name sets in
`supported_nvidia_libs.py` are computed from it, so there are no derived
tables to edit by hand.
- **Respect cache semantics**: `load_nvidia_dynamic_lib` is cached. Never add
behavior that closes returned handles or assumes repeated fresh loads.
- **Keep error contracts intact**:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
"nsight-compute": (_NSIGHT_COMPUTE_BIN,),
}

SUPPORTED_BINARIES_ALL = SUPPORTED_BINARIES = tuple(SITE_PACKAGES_BINDIRS.keys())
SUPPORTED_BINARIES = tuple(SITE_PACKAGES_BINDIRS.keys())
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ def _load_nvidia_dynamic_lib_for_test(libname: str) -> str:
# code under test rather than the parent test module.
from cuda.pathfinder import load_nvidia_dynamic_lib
from cuda.pathfinder._dynamic_libs.load_nvidia_dynamic_lib import _load_lib_no_cache
from cuda.pathfinder._dynamic_libs.supported_nvidia_libs import (
SUPPORTED_LINUX_SONAMES,
SUPPORTED_WINDOWS_DLLS,
)
from cuda.pathfinder._utils.platform_aware import IS_WINDOWS

loaded_dl_fresh = load_nvidia_dynamic_lib(libname)
Expand All @@ -75,8 +71,9 @@ def _load_nvidia_dynamic_lib_for_test(libname: str) -> str:
raise RuntimeError("loaded_dl_from_cache is not loaded_dl_fresh")

loaded_dl_no_cache = _load_lib_no_cache(libname)
supported_libs = SUPPORTED_WINDOWS_DLLS if IS_WINDOWS else SUPPORTED_LINUX_SONAMES
if not loaded_dl_no_cache.was_already_loaded_from_elsewhere and libname in supported_libs:
desc = LIB_DESCRIPTORS[libname]
has_filenames = desc.windows_dlls if IS_WINDOWS else desc.linux_sonames
if not loaded_dl_no_cache.was_already_loaded_from_elsewhere and has_filenames:
raise RuntimeError("not loaded_dl_no_cache.was_already_loaded_from_elsewhere")
abs_path_no_cache = loaded_dl_no_cache.abs_path
if not isinstance(abs_path_no_cache, str):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

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

The canonical data entry point is :mod:`descriptor_catalog`. This module holds
only the projections that the package itself reads.
Expand All @@ -13,13 +13,6 @@
from cuda.pathfinder._utils.platform_aware import IS_WINDOWS, IS_WINDOWS_ARM64, IS_WINDOWS_X64

_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")


def _legacy_least_preferred_first(names: tuple[str, ...]) -> tuple[str, ...]:
"""Preserve the historical ordering of legacy filename projections."""
return tuple(reversed(names))


SUPPORTED_LIBNAMES_COMMON = tuple(desc.name for desc in _CTK_DESCRIPTORS if desc.linux_sonames and desc.windows_dlls)
Expand Down Expand Up @@ -49,28 +42,6 @@ def _legacy_least_preferred_first(names: tuple[str, ...]) -> tuple[str, ...]:
assert IS_WINDOWS_ARM64
SUPPORTED_LIBNAMES = SUPPORTED_LIBNAMES_WINDOWS_ARM64

SUPPORTED_LINUX_SONAMES_CTK = {
desc.name: _legacy_least_preferred_first(desc.linux_sonames) for desc in _CTK_DESCRIPTORS if desc.linux_sonames
}
SUPPORTED_LINUX_SONAMES_OTHER = {
desc.name: _legacy_least_preferred_first(desc.linux_sonames) for desc in _OTHER_DESCRIPTORS if desc.linux_sonames
}
SUPPORTED_LINUX_SONAMES_DRIVER = {
desc.name: _legacy_least_preferred_first(desc.linux_sonames) for desc in _DRIVER_DESCRIPTORS if desc.linux_sonames
}
SUPPORTED_LINUX_SONAMES = SUPPORTED_LINUX_SONAMES_CTK | SUPPORTED_LINUX_SONAMES_OTHER | SUPPORTED_LINUX_SONAMES_DRIVER

SUPPORTED_WINDOWS_DLLS_CTK = {
desc.name: _legacy_least_preferred_first(desc.windows_dlls) for desc in _CTK_DESCRIPTORS if desc.windows_dlls
}
SUPPORTED_WINDOWS_DLLS_OTHER = {
desc.name: _legacy_least_preferred_first(desc.windows_dlls) for desc in _OTHER_DESCRIPTORS if desc.windows_dlls
}
SUPPORTED_WINDOWS_DLLS_DRIVER = {
desc.name: _legacy_least_preferred_first(desc.windows_dlls) for desc in _DRIVER_DESCRIPTORS if desc.windows_dlls
}
SUPPORTED_WINDOWS_DLLS = SUPPORTED_WINDOWS_DLLS_CTK | SUPPORTED_WINDOWS_DLLS_OTHER | SUPPORTED_WINDOWS_DLLS_DRIVER


def is_suppressed_dll_file(path_basename: str) -> bool:
if path_basename.startswith("nvrtc"):
Expand Down
6 changes: 0 additions & 6 deletions cuda_pathfinder/tests/test_find_nvidia_binaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
_CUDA13_BIN,
SITE_PACKAGES_BINDIRS,
SUPPORTED_BINARIES,
SUPPORTED_BINARIES_ALL,
)
from cuda.pathfinder._utils.env_vars import get_cuda_path_or_home

Expand All @@ -35,11 +34,6 @@ def test_find_binary_utilities(info_summary_append, utility_name):
assert bin_path is None or os.path.isfile(bin_path)


def test_supported_binaries_consistency():
assert set(SUPPORTED_BINARIES).issubset(SUPPORTED_BINARIES_ALL)
assert set(SITE_PACKAGES_BINDIRS).issubset(SUPPORTED_BINARIES_ALL)


@pytest.mark.agent_authored(model="claude-opus-5")
def test_cuda13_wheel_layout_is_declared_and_preferred():
"""Every supported utility shipped in nvidia/cu13/bin must declare that layout first.
Expand Down
34 changes: 0 additions & 34 deletions cuda_pathfinder/tests/test_lib_descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,9 @@
SUPPORTED_LIBNAMES_LINUX,
SUPPORTED_LIBNAMES_WINDOWS_ARM64,
SUPPORTED_LIBNAMES_WINDOWS_X64,
SUPPORTED_LINUX_SONAMES,
SUPPORTED_WINDOWS_DLLS,
)
from cuda.pathfinder._utils.platform_aware import IS_WINDOWS, IS_WINDOWS_ARM64, IS_WINDOWS_X64

# ---------------------------------------------------------------------------
# Registry completeness
# ---------------------------------------------------------------------------


def test_registry_covers_all_linux_sonames():
assert set(SUPPORTED_LINUX_SONAMES) <= set(LIB_DESCRIPTORS)


def test_registry_covers_all_windows_dlls():
assert set(SUPPORTED_WINDOWS_DLLS) <= set(LIB_DESCRIPTORS)


def test_registry_has_no_extra_entries():
expected = set(SUPPORTED_LINUX_SONAMES) | set(SUPPORTED_WINDOWS_DLLS)
assert set(LIB_DESCRIPTORS) == expected


# ---------------------------------------------------------------------------
# Per-field consistency with source dicts
# ---------------------------------------------------------------------------


@pytest.mark.parametrize("name", sorted(LIB_DESCRIPTORS))
def test_linux_sonames_match(name):
assert tuple(reversed(LIB_DESCRIPTORS[name].linux_sonames)) == SUPPORTED_LINUX_SONAMES.get(name, ())


@pytest.mark.parametrize("name", sorted(LIB_DESCRIPTORS))
def test_windows_dlls_match(name):
assert tuple(reversed(LIB_DESCRIPTORS[name].windows_dlls)) == SUPPORTED_WINDOWS_DLLS.get(name, ())


@pytest.mark.agent_authored(model="gpt-5")
def test_supported_libnames_selects_current_platform_and_arch():
Expand Down
27 changes: 12 additions & 15 deletions cuda_pathfinder/tests/test_load_nvidia_dynamic_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ def test_loader_uses_all_available_libnames():
assert supported_nvidia_libs.ALL_AVAILABLE_LIBNAMES == load_nvidia_dynamic_lib_module.ALL_AVAILABLE_LIBNAMES


def test_supported_libnames_linux_sonames_consistency():
assert tuple(sorted(supported_nvidia_libs.SUPPORTED_LIBNAMES_LINUX)) == tuple(
sorted(supported_nvidia_libs.SUPPORTED_LINUX_SONAMES_CTK.keys())
)


_CTK_DESCRIPTORS = tuple(
desc for desc in load_nvidia_dynamic_lib_module.LIB_DESCRIPTORS.values() if desc.packaged_with == "ctk"
)
# Every library that has file names for the platform the tests run on, in catalog order.
_LIBNAMES_WITH_FILENAMES_HERE = tuple(
libname
for libname, desc in load_nvidia_dynamic_lib_module.LIB_DESCRIPTORS.items()
if (desc.windows_dlls if IS_WINDOWS else desc.linux_sonames)
)


@pytest.mark.agent_authored(model="claude-fable-5-2")
Expand Down Expand Up @@ -69,12 +69,12 @@ def test_supported_libnames_windows_site_packages_libdirs_ctk_consistency(target
assert site_packages_libnames <= set(supported_libnames)


@pytest.mark.parametrize("dict_name", ["SUPPORTED_LINUX_SONAMES", "SUPPORTED_WINDOWS_DLLS"])
def test_libname_dict_values_are_unique(dict_name):
libname_dict = getattr(supported_nvidia_libs, dict_name)
@pytest.mark.parametrize("filenames_field", ["linux_sonames", "windows_dlls"])
@pytest.mark.agent_authored(model="claude-fable-5-2")
def test_library_filenames_belong_to_one_libname(filenames_field):
libname_for_value = {}
for libname, values in libname_dict.items():
for value in values:
for libname, desc in load_nvidia_dynamic_lib_module.LIB_DESCRIPTORS.items():
for value in getattr(desc, filenames_field):
prev_libname = libname_for_value.get(value)
if prev_libname is not None:
raise RuntimeError(f"Multiple libnames for {value!r}: {prev_libname}, {libname}")
Expand Down Expand Up @@ -149,10 +149,7 @@ def test_cutensor_mg_expected_failure_follows_installed_cutensor_version(

# For libname=nvcudla:
# This test is not currently run in any CI job
@pytest.mark.parametrize(
"libname",
supported_nvidia_libs.SUPPORTED_WINDOWS_DLLS if IS_WINDOWS else supported_nvidia_libs.SUPPORTED_LINUX_SONAMES,
)
@pytest.mark.parametrize("libname", _LIBNAMES_WITH_FILENAMES_HERE)
def test_load_nvidia_dynamic_lib(info_summary_append, libname):
# Use a fresh Python subprocess for each load to isolate global dynamic
# loader state and keep the tests aligned with the canary probe model.
Expand Down
Loading