From 7cbc6cae640a615ab41acb4fdb7d4ee59dfd00ab Mon Sep 17 00:00:00 2001 From: Rob Parolin Date: Wed, 25 Nov 2026 14:37:27 -0700 Subject: [PATCH 1/4] refactor(pathfinder): move data that only tests read out of the package A trace of every module-level name in the package found data that no shipped behavior reads: - `SUPPORTED_BINARIES_ALL`, an alias of `SUPPORTED_BINARIES` that one test used. - The eight `SUPPORTED_LINUX_SONAMES*` and `SUPPORTED_WINDOWS_DLLS*` tables, with the two descriptor groups and the reversing helper that built them. Their only readers were tests and the test-mode loader in `dynamic_lib_subprocess.py`. The test-mode loader now asks the descriptor whether the library has file names on this platform. That is the question the table lookup answered. Tests: - The real-load test builds its list of library names from the catalog, in the same order as before. - The "one file name belongs to one library" test reads the catalog. - Tests that only compared a removed table with the catalog are removed. No behavior change. 1290 passed, 6 skipped. The test-mode loader gives the same result as `main` for all 50 libraries, in both of its outcomes, on Linux and on simulated Windows x64 and arm64. After this change the trace finds no data in the package that only tests read. Risk: these are private names, as in the earlier table removals. Co-Authored-By: Claude Fable 5.2 Signed-off-by: Rob Parolin --- cuda_pathfinder/AGENTS.md | 4 +-- .../_binaries/supported_nvidia_binaries.py | 2 +- .../_dynamic_libs/dynamic_lib_subprocess.py | 9 ++--- .../_dynamic_libs/supported_nvidia_libs.py | 31 +---------------- .../tests/test_find_nvidia_binaries.py | 4 +-- cuda_pathfinder/tests/test_lib_descriptor.py | 34 ------------------- .../tests/test_load_nvidia_dynamic_lib.py | 27 +++++++-------- 7 files changed, 20 insertions(+), 91 deletions(-) diff --git a/cuda_pathfinder/AGENTS.md b/cuda_pathfinder/AGENTS.md index 923f20cf88bd..e05e0e1fb4ff 100644 --- a/cuda_pathfinder/AGENTS.md +++ b/cuda_pathfinder/AGENTS.md @@ -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). diff --git a/cuda_pathfinder/cuda/pathfinder/_binaries/supported_nvidia_binaries.py b/cuda_pathfinder/cuda/pathfinder/_binaries/supported_nvidia_binaries.py index 9839c03de3e8..c2f818da6c07 100644 --- a/cuda_pathfinder/cuda/pathfinder/_binaries/supported_nvidia_binaries.py +++ b/cuda_pathfinder/cuda/pathfinder/_binaries/supported_nvidia_binaries.py @@ -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()) diff --git a/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/dynamic_lib_subprocess.py b/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/dynamic_lib_subprocess.py index ba5d05242f2f..12ade6167d34 100644 --- a/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/dynamic_lib_subprocess.py +++ b/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/dynamic_lib_subprocess.py @@ -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) @@ -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): diff --git a/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/supported_nvidia_libs.py b/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/supported_nvidia_libs.py index 850002b87686..fbc677c0abf6 100644 --- a/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/supported_nvidia_libs.py +++ b/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/supported_nvidia_libs.py @@ -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. @@ -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) @@ -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"): diff --git a/cuda_pathfinder/tests/test_find_nvidia_binaries.py b/cuda_pathfinder/tests/test_find_nvidia_binaries.py index 19ecb9c77736..99314fda6b49 100644 --- a/cuda_pathfinder/tests/test_find_nvidia_binaries.py +++ b/cuda_pathfinder/tests/test_find_nvidia_binaries.py @@ -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 @@ -36,8 +35,7 @@ def test_find_binary_utilities(info_summary_append, utility_name): def test_supported_binaries_consistency(): - assert set(SUPPORTED_BINARIES).issubset(SUPPORTED_BINARIES_ALL) - assert set(SITE_PACKAGES_BINDIRS).issubset(SUPPORTED_BINARIES_ALL) + assert set(SITE_PACKAGES_BINDIRS).issubset(SUPPORTED_BINARIES) @pytest.mark.agent_authored(model="claude-opus-5") diff --git a/cuda_pathfinder/tests/test_lib_descriptor.py b/cuda_pathfinder/tests/test_lib_descriptor.py index fc63822f6635..9de86dfabb60 100644 --- a/cuda_pathfinder/tests/test_lib_descriptor.py +++ b/cuda_pathfinder/tests/test_lib_descriptor.py @@ -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(): diff --git a/cuda_pathfinder/tests/test_load_nvidia_dynamic_lib.py b/cuda_pathfinder/tests/test_load_nvidia_dynamic_lib.py index 1ba77154c24f..00af73b80d08 100644 --- a/cuda_pathfinder/tests/test_load_nvidia_dynamic_lib.py +++ b/cuda_pathfinder/tests/test_load_nvidia_dynamic_lib.py @@ -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") @@ -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}") @@ -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. From 1528755eca243a0f7ad53f3cfa80788ab3f7137e Mon Sep 17 00:00:00 2001 From: Rob Parolin Date: Wed, 25 Nov 2026 15:52:43 -0700 Subject: [PATCH 2/4] test(pathfinder): remove a binaries test that could not fail `SUPPORTED_BINARIES` is built from the keys of `SITE_PACKAGES_BINDIRS`, so asserting that those keys are a subset of it is always true. Co-Authored-By: Claude Fable 5.2 Signed-off-by: Rob Parolin --- cuda_pathfinder/tests/test_find_nvidia_binaries.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cuda_pathfinder/tests/test_find_nvidia_binaries.py b/cuda_pathfinder/tests/test_find_nvidia_binaries.py index 99314fda6b49..00d43b928443 100644 --- a/cuda_pathfinder/tests/test_find_nvidia_binaries.py +++ b/cuda_pathfinder/tests/test_find_nvidia_binaries.py @@ -34,10 +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(SITE_PACKAGES_BINDIRS).issubset(SUPPORTED_BINARIES) - - @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. From 5c05e64f6633e3efc3abcac104df846ad45bf00a Mon Sep 17 00:00:00 2001 From: Rob Parolin Date: Thu, 26 Nov 2026 10:30:46 -0700 Subject: [PATCH 3/4] docs(pathfinder): drop the stale "keep derived exports in sync" advice AGENTS.md told agents to keep derived exports in sync "through existing conversion logic and tests". After the last three changes there are no hand-kept derived tables left: `supported_nvidia_libs.py` computes its name sets from the catalog. The advice now says that. Co-Authored-By: Claude Fable 5.2 Signed-off-by: Rob Parolin --- cuda_pathfinder/AGENTS.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cuda_pathfinder/AGENTS.md b/cuda_pathfinder/AGENTS.md index e05e0e1fb4ff..271e5797f82c 100644 --- a/cuda_pathfinder/AGENTS.md +++ b/cuda_pathfinder/AGENTS.md @@ -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**: From 9c11ae56ddbde954a3a0721d68fe0417373ff1f5 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Thu, 26 Nov 2026 11:17:27 -0800 Subject: [PATCH 4/4] ci: require manual copy-pr-bot approval Signed-off-by: Ralf W. Grosse-Kunstleve