Skip to content

Commit a01a803

Browse files
committed
pathfinder: add cudla and nvcudla support
Add pathfinder support for loading ``libcudla.so.1`` from the ``nvidia-cudla`` package and probing ``libnvcudla.so`` through the existing canary subprocess path. Use that probe in the cudla load test so hosts without the platform runtime are skipped, while real ``libcudla.so.1`` load failures still surface when ``libnvcudla.so`` is available. Made-with: Cursor
1 parent 1476822 commit a01a803

4 files changed

Lines changed: 32 additions & 4 deletions

File tree

cuda_pathfinder/cuda/pathfinder/_dynamic_libs/descriptor_catalog.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,12 @@ class DescriptorSpec:
324324
site_packages_windows=("nvidia/cu13/bin", "nvidia/cu12/bin"),
325325
dependencies=("nvrtc",),
326326
),
327+
DescriptorSpec(
328+
name="cudla",
329+
packaged_with="other",
330+
linux_sonames=("libcudla.so.1",),
331+
site_packages_linux=("nvidia/cu13/lib",),
332+
),
327333
DescriptorSpec(
328334
name="cudss",
329335
packaged_with="other",
@@ -386,6 +392,11 @@ class DescriptorSpec:
386392
linux_sonames=("libcuda.so.1",),
387393
windows_dlls=("nvcuda.dll",),
388394
),
395+
DescriptorSpec(
396+
name="nvcudla",
397+
packaged_with="driver",
398+
linux_sonames=("libnvcudla.so",),
399+
),
389400
DescriptorSpec(
390401
name="nvml",
391402
packaged_with="driver",

cuda_pathfinder/cuda/pathfinder/_dynamic_libs/load_nvidia_dynamic_lib.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,18 @@ def _raise_canary_probe_child_process_error(
9999

100100

101101
@functools.cache
102-
def _resolve_system_loaded_abs_path_in_subprocess(libname: str) -> str | None:
102+
def _resolve_system_loaded_abs_path_in_subprocess(
103+
libname: str,
104+
*,
105+
timeout: float = _CANARY_PROBE_TIMEOUT_SECONDS,
106+
) -> str | None:
103107
"""Resolve a canary library's absolute path in a fresh Python subprocess."""
104108
try:
105109
result = subprocess.run( # noqa: S603 - trusted argv: current interpreter + internal probe module
106110
build_dynamic_lib_subprocess_command(MODE_CANARY, libname),
107111
capture_output=True,
108112
text=True,
109-
timeout=_CANARY_PROBE_TIMEOUT_SECONDS,
113+
timeout=timeout,
110114
check=False,
111115
cwd=DYNAMIC_LIB_SUBPROCESS_CWD,
112116
)
@@ -127,6 +131,11 @@ def _resolve_system_loaded_abs_path_in_subprocess(libname: str) -> str | None:
127131
return None
128132

129133

134+
def _loadable_via_canary_subprocess(libname: str, *, timeout: float = _CANARY_PROBE_TIMEOUT_SECONDS) -> bool:
135+
"""Return True if the canary subprocess can resolve ``libname`` via system search."""
136+
return _resolve_system_loaded_abs_path_in_subprocess(libname, timeout=timeout) is not None
137+
138+
130139
def _try_ctk_root_canary(ctx: SearchContext) -> str | None:
131140
"""Try CTK-root canary fallback for descriptor-configured libraries."""
132141
for canary_libname in ctx.desc.ctk_root_canary_anchor_libnames:

cuda_pathfinder/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ cu13 = [
3636
"cuda-toolkit[cufile]==13.*; sys_platform != 'win32'",
3737
"cutensor-cu13",
3838
"nvidia-cublasmp-cu13; sys_platform != 'win32'",
39+
"nvidia-cudla; platform_system == 'Linux' and platform_machine == 'aarch64'",
3940
"nvidia-cudss-cu13",
4041
"nvidia-cufftmp-cu13; sys_platform != 'win32'",
4142
"nvidia-cusolvermp-cu13; sys_platform != 'win32'",

cuda_pathfinder/tests/test_load_nvidia_dynamic_lib.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
from cuda.pathfinder import DynamicLibNotAvailableError, DynamicLibUnknownError, load_nvidia_dynamic_lib
1515
from cuda.pathfinder._dynamic_libs import load_nvidia_dynamic_lib as load_nvidia_dynamic_lib_module
1616
from cuda.pathfinder._dynamic_libs import supported_nvidia_libs
17-
from cuda.pathfinder._dynamic_libs.subprocess_protocol import STATUS_NOT_FOUND, parse_dynamic_lib_subprocess_payload
17+
from cuda.pathfinder._dynamic_libs.subprocess_protocol import (
18+
STATUS_NOT_FOUND,
19+
parse_dynamic_lib_subprocess_payload,
20+
)
1821
from cuda.pathfinder._utils.platform_aware import IS_WINDOWS, quote_for_shell
1922

2023
STRICTNESS = os.environ.get("CUDA_PATHFINDER_TEST_LOAD_NVIDIA_DYNAMIC_LIB_STRICTNESS", "see_what_works")
@@ -95,7 +98,7 @@ def test_known_but_platform_unavailable_libname_raises_dynamic_lib_not_available
9598

9699

97100
def _is_expected_load_nvidia_dynamic_lib_failure(libname):
98-
if libname == "nvpl_fftw" and platform.machine().lower() != "aarch64":
101+
if libname in ("cudla", "nvcudla", "nvpl_fftw") and platform.machine().lower() != "aarch64":
99102
return True
100103
dist_name_pattern = IMPORTLIB_METADATA_DISTRIBUTIONS_NAMES.get(libname)
101104
if dist_name_pattern is not None:
@@ -117,6 +120,10 @@ def raise_child_process_failed():
117120
raise RuntimeError(build_child_process_failed_for_libname_message(libname, result))
118121

119122
if result.returncode != 0:
123+
if libname == "cudla" and not load_nvidia_dynamic_lib_module._loadable_via_canary_subprocess(
124+
"nvcudla", timeout=timeout
125+
):
126+
pytest.skip("libnvcudla.so is not loadable via canary subprocess on this host.")
120127
raise_child_process_failed()
121128
assert not result.stderr
122129
payload = parse_dynamic_lib_subprocess_payload(

0 commit comments

Comments
 (0)