Skip to content

Commit 7c04302

Browse files
committed
pathfinder: rely on nvcudla runtime probe in tests
Remove the machine-architecture gating for cudla and nvcudla so they remain part of the normal Linux descriptor tables. Let the nvcudla canary probe decide whether cudla and nvcudla tests should run, which keeps strict test runs green on hosts without the platform runtime while still exercising real load behavior where libnvcudla.so is available. Made-with: Cursor
1 parent 42bebe3 commit 7c04302

7 files changed

Lines changed: 32 additions & 101 deletions

File tree

cuda_pathfinder/cuda/pathfinder/_dynamic_libs/descriptor_catalog.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
from dataclasses import dataclass
99
from typing import Literal
1010

11-
from cuda.pathfinder._utils.platform_aware import PLATFORM_MACHINE
12-
1311
PackagedWith = Literal["ctk", "other", "driver"]
1412

1513

@@ -19,7 +17,6 @@ class DescriptorSpec:
1917
packaged_with: PackagedWith
2018
linux_sonames: tuple[str, ...] = ()
2119
windows_dlls: tuple[str, ...] = ()
22-
platform_machines: tuple[str, ...] = ()
2320
site_packages_linux: tuple[str, ...] = ()
2421
site_packages_windows: tuple[str, ...] = ()
2522
dependencies: tuple[str, ...] = ()
@@ -30,10 +27,6 @@ class DescriptorSpec:
3027
requires_rtld_deepbind: bool = False
3128

3229

33-
def is_supported_on_current_machine(desc: DescriptorSpec) -> bool:
34-
return not desc.platform_machines or PLATFORM_MACHINE in desc.platform_machines
35-
36-
3730
DESCRIPTOR_CATALOG: tuple[DescriptorSpec, ...] = (
3831
# -----------------------------------------------------------------------
3932
# CTK (CUDA Toolkit) libraries
@@ -335,7 +328,6 @@ def is_supported_on_current_machine(desc: DescriptorSpec) -> bool:
335328
name="cudla",
336329
packaged_with="other",
337330
linux_sonames=("libcudla.so.1",),
338-
platform_machines=("aarch64",),
339331
site_packages_linux=("nvidia/cu13/lib",),
340332
),
341333
DescriptorSpec(
@@ -404,7 +396,6 @@ def is_supported_on_current_machine(desc: DescriptorSpec) -> bool:
404396
name="nvcudla",
405397
packaged_with="driver",
406398
linux_sonames=("libnvcudla.so",),
407-
platform_machines=("aarch64",),
408399
),
409400
DescriptorSpec(
410401
name="nvml",

cuda_pathfinder/cuda/pathfinder/_dynamic_libs/load_nvidia_dynamic_lib.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import sys
1010
from typing import TYPE_CHECKING
1111

12-
from cuda.pathfinder._dynamic_libs.descriptor_catalog import is_supported_on_current_machine
1312
from cuda.pathfinder._dynamic_libs.lib_descriptor import LIB_DESCRIPTORS
1413
from cuda.pathfinder._dynamic_libs.load_dl_common import (
1514
DynamicLibNotAvailableError,
@@ -44,19 +43,15 @@
4443
# (CTK, third-party, driver).
4544
_ALL_KNOWN_LIBNAMES: frozenset[str] = frozenset(LIB_DESCRIPTORS)
4645
_ALL_SUPPORTED_LIBNAMES: frozenset[str] = frozenset(
47-
name
48-
for name, desc in LIB_DESCRIPTORS.items()
49-
if is_supported_on_current_machine(desc) and (desc.windows_dlls if IS_WINDOWS else desc.linux_sonames)
46+
name for name, desc in LIB_DESCRIPTORS.items() if (desc.windows_dlls if IS_WINDOWS else desc.linux_sonames)
5047
)
5148
_PLATFORM_NAME = "Windows" if IS_WINDOWS else "Linux"
5249
_CANARY_PROBE_TIMEOUT_SECONDS = 10.0
5350

5451
# Driver libraries: shipped with the NVIDIA display driver, always on the
5552
# system linker path. These skip all CTK search steps (site-packages,
5653
# conda, CUDA_PATH, canary) and go straight to system search.
57-
_DRIVER_ONLY_LIBNAMES = frozenset(
58-
name for name, desc in LIB_DESCRIPTORS.items() if desc.packaged_with == "driver" and name in _ALL_SUPPORTED_LIBNAMES
59-
)
54+
_DRIVER_ONLY_LIBNAMES = frozenset(name for name, desc in LIB_DESCRIPTORS.items() if desc.packaged_with == "driver")
6055

6156

6257
def _load_driver_lib_no_cache(desc: LibDescriptor) -> LoadedDL:

cuda_pathfinder/cuda/pathfinder/_dynamic_libs/supported_nvidia_libs.py

Lines changed: 16 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,20 @@
1010

1111
from __future__ import annotations
1212

13-
from cuda.pathfinder._dynamic_libs.descriptor_catalog import DESCRIPTOR_CATALOG, is_supported_on_current_machine
14-
from cuda.pathfinder._dynamic_libs.lib_descriptor import LibDescriptor
13+
from cuda.pathfinder._dynamic_libs.descriptor_catalog import DESCRIPTOR_CATALOG
1514
from cuda.pathfinder._utils.platform_aware import IS_WINDOWS
1615

1716
_CTK_DESCRIPTORS = tuple(desc for desc in DESCRIPTOR_CATALOG if desc.packaged_with == "ctk")
1817
_OTHER_DESCRIPTORS = tuple(desc for desc in DESCRIPTOR_CATALOG if desc.packaged_with == "other")
1918
_DRIVER_DESCRIPTORS = tuple(desc for desc in DESCRIPTOR_CATALOG if desc.packaged_with == "driver")
2019
_NON_CTK_DESCRIPTORS = _OTHER_DESCRIPTORS + _DRIVER_DESCRIPTORS
2120

22-
23-
def _has_supported_linux_sonames(desc: LibDescriptor) -> bool:
24-
return bool(desc.linux_sonames) and is_supported_on_current_machine(desc)
25-
26-
27-
def _has_supported_windows_dlls(desc: LibDescriptor) -> bool:
28-
return bool(desc.windows_dlls) and is_supported_on_current_machine(desc)
29-
30-
31-
SUPPORTED_LIBNAMES_COMMON = tuple(
32-
desc.name for desc in _CTK_DESCRIPTORS if _has_supported_linux_sonames(desc) and _has_supported_windows_dlls(desc)
33-
)
21+
SUPPORTED_LIBNAMES_COMMON = tuple(desc.name for desc in _CTK_DESCRIPTORS if desc.linux_sonames and desc.windows_dlls)
3422
SUPPORTED_LIBNAMES_LINUX_ONLY = tuple(
35-
desc.name
36-
for desc in _CTK_DESCRIPTORS
37-
if _has_supported_linux_sonames(desc) and not _has_supported_windows_dlls(desc)
23+
desc.name for desc in _CTK_DESCRIPTORS if desc.linux_sonames and not desc.windows_dlls
3824
)
3925
SUPPORTED_LIBNAMES_WINDOWS_ONLY = tuple(
40-
desc.name
41-
for desc in _CTK_DESCRIPTORS
42-
if _has_supported_windows_dlls(desc) and not _has_supported_linux_sonames(desc)
26+
desc.name for desc in _CTK_DESCRIPTORS if desc.windows_dlls and not desc.linux_sonames
4327
)
4428

4529
SUPPORTED_LIBNAMES_LINUX = SUPPORTED_LIBNAMES_COMMON + SUPPORTED_LIBNAMES_LINUX_ONLY
@@ -50,57 +34,37 @@ def _has_supported_windows_dlls(desc: LibDescriptor) -> bool:
5034
DIRECT_DEPENDENCIES_CTK = {desc.name: desc.dependencies for desc in _CTK_DESCRIPTORS if desc.dependencies}
5135
DIRECT_DEPENDENCIES = {desc.name: desc.dependencies for desc in DESCRIPTOR_CATALOG if desc.dependencies}
5236

53-
SUPPORTED_LINUX_SONAMES_CTK = {
54-
desc.name: desc.linux_sonames for desc in _CTK_DESCRIPTORS if _has_supported_linux_sonames(desc)
55-
}
56-
SUPPORTED_LINUX_SONAMES_OTHER = {
57-
desc.name: desc.linux_sonames for desc in _OTHER_DESCRIPTORS if _has_supported_linux_sonames(desc)
58-
}
59-
SUPPORTED_LINUX_SONAMES_DRIVER = {
60-
desc.name: desc.linux_sonames for desc in _DRIVER_DESCRIPTORS if _has_supported_linux_sonames(desc)
61-
}
37+
SUPPORTED_LINUX_SONAMES_CTK = {desc.name: desc.linux_sonames for desc in _CTK_DESCRIPTORS if desc.linux_sonames}
38+
SUPPORTED_LINUX_SONAMES_OTHER = {desc.name: desc.linux_sonames for desc in _OTHER_DESCRIPTORS if desc.linux_sonames}
39+
SUPPORTED_LINUX_SONAMES_DRIVER = {desc.name: desc.linux_sonames for desc in _DRIVER_DESCRIPTORS if desc.linux_sonames}
6240
SUPPORTED_LINUX_SONAMES = SUPPORTED_LINUX_SONAMES_CTK | SUPPORTED_LINUX_SONAMES_OTHER | SUPPORTED_LINUX_SONAMES_DRIVER
6341

64-
SUPPORTED_WINDOWS_DLLS_CTK = {
65-
desc.name: desc.windows_dlls for desc in _CTK_DESCRIPTORS if _has_supported_windows_dlls(desc)
66-
}
67-
SUPPORTED_WINDOWS_DLLS_OTHER = {
68-
desc.name: desc.windows_dlls for desc in _OTHER_DESCRIPTORS if _has_supported_windows_dlls(desc)
69-
}
70-
SUPPORTED_WINDOWS_DLLS_DRIVER = {
71-
desc.name: desc.windows_dlls for desc in _DRIVER_DESCRIPTORS if _has_supported_windows_dlls(desc)
72-
}
42+
SUPPORTED_WINDOWS_DLLS_CTK = {desc.name: desc.windows_dlls for desc in _CTK_DESCRIPTORS if desc.windows_dlls}
43+
SUPPORTED_WINDOWS_DLLS_OTHER = {desc.name: desc.windows_dlls for desc in _OTHER_DESCRIPTORS if desc.windows_dlls}
44+
SUPPORTED_WINDOWS_DLLS_DRIVER = {desc.name: desc.windows_dlls for desc in _DRIVER_DESCRIPTORS if desc.windows_dlls}
7345
SUPPORTED_WINDOWS_DLLS = SUPPORTED_WINDOWS_DLLS_CTK | SUPPORTED_WINDOWS_DLLS_OTHER | SUPPORTED_WINDOWS_DLLS_DRIVER
7446

7547
LIBNAMES_REQUIRING_OS_ADD_DLL_DIRECTORY = tuple(
76-
desc.name for desc in DESCRIPTOR_CATALOG if desc.requires_add_dll_directory and _has_supported_windows_dlls(desc)
48+
desc.name for desc in DESCRIPTOR_CATALOG if desc.requires_add_dll_directory and desc.windows_dlls
7749
)
7850
LIBNAMES_REQUIRING_RTLD_DEEPBIND = tuple(
79-
desc.name for desc in DESCRIPTOR_CATALOG if desc.requires_rtld_deepbind and _has_supported_linux_sonames(desc)
51+
desc.name for desc in DESCRIPTOR_CATALOG if desc.requires_rtld_deepbind and desc.linux_sonames
8052
)
8153

8254
# Based on output of toolshed/make_site_packages_libdirs_linux.py
8355
SITE_PACKAGES_LIBDIRS_LINUX_CTK = {
84-
desc.name: desc.site_packages_linux
85-
for desc in _CTK_DESCRIPTORS
86-
if desc.site_packages_linux and _has_supported_linux_sonames(desc)
56+
desc.name: desc.site_packages_linux for desc in _CTK_DESCRIPTORS if desc.site_packages_linux
8757
}
8858
SITE_PACKAGES_LIBDIRS_LINUX_OTHER = {
89-
desc.name: desc.site_packages_linux
90-
for desc in _NON_CTK_DESCRIPTORS
91-
if desc.site_packages_linux and _has_supported_linux_sonames(desc)
59+
desc.name: desc.site_packages_linux for desc in _NON_CTK_DESCRIPTORS if desc.site_packages_linux
9260
}
9361
SITE_PACKAGES_LIBDIRS_LINUX = SITE_PACKAGES_LIBDIRS_LINUX_CTK | SITE_PACKAGES_LIBDIRS_LINUX_OTHER
9462

9563
SITE_PACKAGES_LIBDIRS_WINDOWS_CTK = {
96-
desc.name: desc.site_packages_windows
97-
for desc in _CTK_DESCRIPTORS
98-
if desc.site_packages_windows and _has_supported_windows_dlls(desc)
64+
desc.name: desc.site_packages_windows for desc in _CTK_DESCRIPTORS if desc.site_packages_windows
9965
}
10066
SITE_PACKAGES_LIBDIRS_WINDOWS_OTHER = {
101-
desc.name: desc.site_packages_windows
102-
for desc in _NON_CTK_DESCRIPTORS
103-
if desc.site_packages_windows and _has_supported_windows_dlls(desc)
67+
desc.name: desc.site_packages_windows for desc in _NON_CTK_DESCRIPTORS if desc.site_packages_windows
10468
}
10569
SITE_PACKAGES_LIBDIRS_WINDOWS = SITE_PACKAGES_LIBDIRS_WINDOWS_CTK | SITE_PACKAGES_LIBDIRS_WINDOWS_OTHER
10670

cuda_pathfinder/cuda/pathfinder/_utils/platform_aware.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
import platform
54
import sys
65

76
IS_WINDOWS = sys.platform == "win32"
8-
PLATFORM_MACHINE = platform.machine().lower()
97

108

119
def quote_for_shell(s: str) -> str:

cuda_pathfinder/tests/test_driver_lib_loading.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
_load_lib_no_cache,
2626
)
2727
from cuda.pathfinder._dynamic_libs.subprocess_protocol import STATUS_NOT_FOUND, parse_dynamic_lib_subprocess_payload
28-
from cuda.pathfinder._utils.platform_aware import IS_WINDOWS, PLATFORM_MACHINE, quote_for_shell
28+
from cuda.pathfinder._utils.platform_aware import IS_WINDOWS, quote_for_shell
2929

3030
STRICTNESS = os.environ.get("CUDA_PATHFINDER_TEST_LOAD_NVIDIA_DYNAMIC_LIB_STRICTNESS", "see_what_works")
3131
assert STRICTNESS in ("see_what_works", "all_must_work")
@@ -42,7 +42,7 @@ def _make_loaded_dl(path, found_via):
4242

4343

4444
def _skip_if_missing_nvcudla_runtime(libname: str, *, timeout: float) -> None:
45-
if libname != "nvcudla" or PLATFORM_MACHINE != "aarch64":
45+
if libname != "nvcudla":
4646
return
4747
if load_nvidia_dynamic_lib_module._loadable_via_canary_subprocess("nvcudla", timeout=timeout):
4848
return

cuda_pathfinder/tests/test_lib_descriptor.py

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
"""Tests verifying that the LibDescriptor registry faithfully represents
5-
the current-platform data tables in supported_nvidia_libs.py."""
5+
the existing data tables in supported_nvidia_libs.py."""
66

77
import pytest
88

9-
from cuda.pathfinder._dynamic_libs.descriptor_catalog import is_supported_on_current_machine
109
from cuda.pathfinder._dynamic_libs.lib_descriptor import LIB_DESCRIPTORS
1110
from cuda.pathfinder._dynamic_libs.supported_nvidia_libs import (
1211
DIRECT_DEPENDENCIES,
@@ -34,8 +33,7 @@ def test_registry_covers_all_windows_dlls():
3433

3534
def test_registry_has_no_extra_entries():
3635
expected = set(SUPPORTED_LINUX_SONAMES) | set(SUPPORTED_WINDOWS_DLLS)
37-
extra = set(LIB_DESCRIPTORS) - expected
38-
assert all(not is_supported_on_current_machine(LIB_DESCRIPTORS[name]) for name in extra)
36+
assert set(LIB_DESCRIPTORS) == expected
3937

4038

4139
# ---------------------------------------------------------------------------
@@ -45,30 +43,22 @@ def test_registry_has_no_extra_entries():
4543

4644
@pytest.mark.parametrize("name", sorted(LIB_DESCRIPTORS))
4745
def test_linux_sonames_match(name):
48-
desc = LIB_DESCRIPTORS[name]
49-
expected = desc.linux_sonames if is_supported_on_current_machine(desc) else ()
50-
assert expected == SUPPORTED_LINUX_SONAMES.get(name, ())
46+
assert LIB_DESCRIPTORS[name].linux_sonames == SUPPORTED_LINUX_SONAMES.get(name, ())
5147

5248

5349
@pytest.mark.parametrize("name", sorted(LIB_DESCRIPTORS))
5450
def test_windows_dlls_match(name):
55-
desc = LIB_DESCRIPTORS[name]
56-
expected = desc.windows_dlls if is_supported_on_current_machine(desc) else ()
57-
assert expected == SUPPORTED_WINDOWS_DLLS.get(name, ())
51+
assert LIB_DESCRIPTORS[name].windows_dlls == SUPPORTED_WINDOWS_DLLS.get(name, ())
5852

5953

6054
@pytest.mark.parametrize("name", sorted(LIB_DESCRIPTORS))
6155
def test_site_packages_linux_match(name):
62-
desc = LIB_DESCRIPTORS[name]
63-
expected = desc.site_packages_linux if is_supported_on_current_machine(desc) else ()
64-
assert expected == SITE_PACKAGES_LIBDIRS_LINUX.get(name, ())
56+
assert LIB_DESCRIPTORS[name].site_packages_linux == SITE_PACKAGES_LIBDIRS_LINUX.get(name, ())
6557

6658

6759
@pytest.mark.parametrize("name", sorted(LIB_DESCRIPTORS))
6860
def test_site_packages_windows_match(name):
69-
desc = LIB_DESCRIPTORS[name]
70-
expected = desc.site_packages_windows if is_supported_on_current_machine(desc) else ()
71-
assert expected == SITE_PACKAGES_LIBDIRS_WINDOWS.get(name, ())
61+
assert LIB_DESCRIPTORS[name].site_packages_windows == SITE_PACKAGES_LIBDIRS_WINDOWS.get(name, ())
7262

7363

7464
@pytest.mark.parametrize("name", sorted(LIB_DESCRIPTORS))
@@ -78,16 +68,12 @@ def test_dependencies_match(name):
7868

7969
@pytest.mark.parametrize("name", sorted(LIB_DESCRIPTORS))
8070
def test_requires_add_dll_directory_match(name):
81-
desc = LIB_DESCRIPTORS[name]
82-
expected = desc.requires_add_dll_directory if is_supported_on_current_machine(desc) else False
83-
assert expected == (name in LIBNAMES_REQUIRING_OS_ADD_DLL_DIRECTORY)
71+
assert LIB_DESCRIPTORS[name].requires_add_dll_directory == (name in LIBNAMES_REQUIRING_OS_ADD_DLL_DIRECTORY)
8472

8573

8674
@pytest.mark.parametrize("name", sorted(LIB_DESCRIPTORS))
8775
def test_requires_rtld_deepbind_match(name):
88-
desc = LIB_DESCRIPTORS[name]
89-
expected = desc.requires_rtld_deepbind if is_supported_on_current_machine(desc) else False
90-
assert expected == (name in LIBNAMES_REQUIRING_RTLD_DEEPBIND)
76+
assert LIB_DESCRIPTORS[name].requires_rtld_deepbind == (name in LIBNAMES_REQUIRING_RTLD_DEEPBIND)
9177

9278

9379
# ---------------------------------------------------------------------------

cuda_pathfinder/tests/test_load_nvidia_dynamic_lib.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
STATUS_NOT_FOUND,
1919
parse_dynamic_lib_subprocess_payload,
2020
)
21-
from cuda.pathfinder._utils.platform_aware import IS_WINDOWS, PLATFORM_MACHINE, quote_for_shell
21+
from cuda.pathfinder._utils.platform_aware import IS_WINDOWS, quote_for_shell
2222

2323
STRICTNESS = os.environ.get("CUDA_PATHFINDER_TEST_LOAD_NVIDIA_DYNAMIC_LIB_STRICTNESS", "see_what_works")
2424
assert STRICTNESS in ("see_what_works", "all_must_work")
@@ -98,7 +98,7 @@ def test_known_but_platform_unavailable_libname_raises_dynamic_lib_not_available
9898

9999

100100
def _is_expected_load_nvidia_dynamic_lib_failure(libname):
101-
if libname in ("cudla", "nvcudla", "nvpl_fftw") and platform.machine().lower() != "aarch64":
101+
if libname == "nvpl_fftw" and platform.machine().lower() != "aarch64":
102102
return True
103103
dist_name_pattern = IMPORTLIB_METADATA_DISTRIBUTIONS_NAMES.get(libname)
104104
if dist_name_pattern is not None:
@@ -107,7 +107,7 @@ def _is_expected_load_nvidia_dynamic_lib_failure(libname):
107107

108108

109109
def _skip_if_missing_nvcudla_runtime(libname: str, *, timeout: float) -> None:
110-
if libname != "nvcudla" or PLATFORM_MACHINE != "aarch64":
110+
if libname not in ("cudla", "nvcudla"):
111111
return
112112
if load_nvidia_dynamic_lib_module._loadable_via_canary_subprocess("nvcudla", timeout=timeout):
113113
return
@@ -128,10 +128,7 @@ def raise_child_process_failed():
128128
raise RuntimeError(build_child_process_failed_for_libname_message(libname, result))
129129

130130
if result.returncode != 0:
131-
if libname == "cudla" and not load_nvidia_dynamic_lib_module._loadable_via_canary_subprocess(
132-
"nvcudla", timeout=timeout
133-
):
134-
pytest.skip("libnvcudla.so is not loadable via canary subprocess on this host.")
131+
_skip_if_missing_nvcudla_runtime(libname, timeout=timeout)
135132
raise_child_process_failed()
136133
assert not result.stderr
137134
payload = parse_dynamic_lib_subprocess_payload(

0 commit comments

Comments
 (0)