Skip to content

Commit c80c137

Browse files
committed
pathfinder: gate cudla support by machine architecture
Mark cudla and nvcudla as aarch64-only descriptors and derive the supported library tables from the current machine as well as the current OS. This keeps those libraries known to pathfinder while reporting them as unavailable on linux-64, and updates the descriptor-registry tests to match the new current-platform filtering model. Made-with: Cursor
1 parent a01a803 commit c80c137

5 files changed

Lines changed: 93 additions & 27 deletions

File tree

cuda_pathfinder/cuda/pathfinder/_dynamic_libs/descriptor_catalog.py

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

11+
from cuda.pathfinder._utils.platform_aware import PLATFORM_MACHINE
12+
1113
PackagedWith = Literal["ctk", "other", "driver"]
1214

1315

@@ -17,6 +19,7 @@ class DescriptorSpec:
1719
packaged_with: PackagedWith
1820
linux_sonames: tuple[str, ...] = ()
1921
windows_dlls: tuple[str, ...] = ()
22+
platform_machines: tuple[str, ...] = ()
2023
site_packages_linux: tuple[str, ...] = ()
2124
site_packages_windows: tuple[str, ...] = ()
2225
dependencies: tuple[str, ...] = ()
@@ -27,6 +30,10 @@ class DescriptorSpec:
2730
requires_rtld_deepbind: bool = False
2831

2932

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+
3037
DESCRIPTOR_CATALOG: tuple[DescriptorSpec, ...] = (
3138
# -----------------------------------------------------------------------
3239
# CTK (CUDA Toolkit) libraries
@@ -328,6 +335,7 @@ class DescriptorSpec:
328335
name="cudla",
329336
packaged_with="other",
330337
linux_sonames=("libcudla.so.1",),
338+
platform_machines=("aarch64",),
331339
site_packages_linux=("nvidia/cu13/lib",),
332340
),
333341
DescriptorSpec(
@@ -396,6 +404,7 @@ class DescriptorSpec:
396404
name="nvcudla",
397405
packaged_with="driver",
398406
linux_sonames=("libnvcudla.so",),
407+
platform_machines=("aarch64",),
399408
),
400409
DescriptorSpec(
401410
name="nvml",

cuda_pathfinder/cuda/pathfinder/_dynamic_libs/load_nvidia_dynamic_lib.py

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

12+
from cuda.pathfinder._dynamic_libs.descriptor_catalog import is_supported_on_current_machine
1213
from cuda.pathfinder._dynamic_libs.lib_descriptor import LIB_DESCRIPTORS
1314
from cuda.pathfinder._dynamic_libs.load_dl_common import (
1415
DynamicLibNotAvailableError,
@@ -43,15 +44,19 @@
4344
# (CTK, third-party, driver).
4445
_ALL_KNOWN_LIBNAMES: frozenset[str] = frozenset(LIB_DESCRIPTORS)
4546
_ALL_SUPPORTED_LIBNAMES: frozenset[str] = frozenset(
46-
name for name, desc in LIB_DESCRIPTORS.items() if (desc.windows_dlls if IS_WINDOWS else desc.linux_sonames)
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)
4750
)
4851
_PLATFORM_NAME = "Windows" if IS_WINDOWS else "Linux"
4952
_CANARY_PROBE_TIMEOUT_SECONDS = 10.0
5053

5154
# Driver libraries: shipped with the NVIDIA display driver, always on the
5255
# system linker path. These skip all CTK search steps (site-packages,
5356
# conda, CUDA_PATH, canary) and go straight to system search.
54-
_DRIVER_ONLY_LIBNAMES = frozenset(name for name, desc in LIB_DESCRIPTORS.items() if desc.packaged_with == "driver")
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+
)
5560

5661

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

cuda_pathfinder/cuda/pathfinder/_dynamic_libs/supported_nvidia_libs.py

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

1111
from __future__ import annotations
1212

13-
from cuda.pathfinder._dynamic_libs.descriptor_catalog import DESCRIPTOR_CATALOG
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
1415
from cuda.pathfinder._utils.platform_aware import IS_WINDOWS
1516

1617
_CTK_DESCRIPTORS = tuple(desc for desc in DESCRIPTOR_CATALOG if desc.packaged_with == "ctk")
1718
_OTHER_DESCRIPTORS = tuple(desc for desc in DESCRIPTOR_CATALOG if desc.packaged_with == "other")
1819
_DRIVER_DESCRIPTORS = tuple(desc for desc in DESCRIPTOR_CATALOG if desc.packaged_with == "driver")
1920
_NON_CTK_DESCRIPTORS = _OTHER_DESCRIPTORS + _DRIVER_DESCRIPTORS
2021

21-
SUPPORTED_LIBNAMES_COMMON = tuple(desc.name for desc in _CTK_DESCRIPTORS if desc.linux_sonames and desc.windows_dlls)
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+
)
2234
SUPPORTED_LIBNAMES_LINUX_ONLY = tuple(
23-
desc.name for desc in _CTK_DESCRIPTORS if desc.linux_sonames and not desc.windows_dlls
35+
desc.name
36+
for desc in _CTK_DESCRIPTORS
37+
if _has_supported_linux_sonames(desc) and not _has_supported_windows_dlls(desc)
2438
)
2539
SUPPORTED_LIBNAMES_WINDOWS_ONLY = tuple(
26-
desc.name for desc in _CTK_DESCRIPTORS if desc.windows_dlls and not desc.linux_sonames
40+
desc.name
41+
for desc in _CTK_DESCRIPTORS
42+
if _has_supported_windows_dlls(desc) and not _has_supported_linux_sonames(desc)
2743
)
2844

2945
SUPPORTED_LIBNAMES_LINUX = SUPPORTED_LIBNAMES_COMMON + SUPPORTED_LIBNAMES_LINUX_ONLY
@@ -34,37 +50,57 @@
3450
DIRECT_DEPENDENCIES_CTK = {desc.name: desc.dependencies for desc in _CTK_DESCRIPTORS if desc.dependencies}
3551
DIRECT_DEPENDENCIES = {desc.name: desc.dependencies for desc in DESCRIPTOR_CATALOG if desc.dependencies}
3652

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}
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+
}
4062
SUPPORTED_LINUX_SONAMES = SUPPORTED_LINUX_SONAMES_CTK | SUPPORTED_LINUX_SONAMES_OTHER | SUPPORTED_LINUX_SONAMES_DRIVER
4163

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}
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+
}
4573
SUPPORTED_WINDOWS_DLLS = SUPPORTED_WINDOWS_DLLS_CTK | SUPPORTED_WINDOWS_DLLS_OTHER | SUPPORTED_WINDOWS_DLLS_DRIVER
4674

4775
LIBNAMES_REQUIRING_OS_ADD_DLL_DIRECTORY = tuple(
48-
desc.name for desc in DESCRIPTOR_CATALOG if desc.requires_add_dll_directory and desc.windows_dlls
76+
desc.name for desc in DESCRIPTOR_CATALOG if desc.requires_add_dll_directory and _has_supported_windows_dlls(desc)
4977
)
5078
LIBNAMES_REQUIRING_RTLD_DEEPBIND = tuple(
51-
desc.name for desc in DESCRIPTOR_CATALOG if desc.requires_rtld_deepbind and desc.linux_sonames
79+
desc.name for desc in DESCRIPTOR_CATALOG if desc.requires_rtld_deepbind and _has_supported_linux_sonames(desc)
5280
)
5381

5482
# Based on output of toolshed/make_site_packages_libdirs_linux.py
5583
SITE_PACKAGES_LIBDIRS_LINUX_CTK = {
56-
desc.name: desc.site_packages_linux for desc in _CTK_DESCRIPTORS if desc.site_packages_linux
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)
5787
}
5888
SITE_PACKAGES_LIBDIRS_LINUX_OTHER = {
59-
desc.name: desc.site_packages_linux for desc in _NON_CTK_DESCRIPTORS if desc.site_packages_linux
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)
6092
}
6193
SITE_PACKAGES_LIBDIRS_LINUX = SITE_PACKAGES_LIBDIRS_LINUX_CTK | SITE_PACKAGES_LIBDIRS_LINUX_OTHER
6294

6395
SITE_PACKAGES_LIBDIRS_WINDOWS_CTK = {
64-
desc.name: desc.site_packages_windows for desc in _CTK_DESCRIPTORS if desc.site_packages_windows
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)
6599
}
66100
SITE_PACKAGES_LIBDIRS_WINDOWS_OTHER = {
67-
desc.name: desc.site_packages_windows for desc in _NON_CTK_DESCRIPTORS if desc.site_packages_windows
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)
68104
}
69105
SITE_PACKAGES_LIBDIRS_WINDOWS = SITE_PACKAGES_LIBDIRS_WINDOWS_CTK | SITE_PACKAGES_LIBDIRS_WINDOWS_OTHER
70106

cuda_pathfinder/cuda/pathfinder/_utils/platform_aware.py

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

4+
import platform
45
import sys
56

67
IS_WINDOWS = sys.platform == "win32"
8+
PLATFORM_MACHINE = platform.machine().lower()
79

810

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

cuda_pathfinder/tests/test_lib_descriptor.py

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

44
"""Tests verifying that the LibDescriptor registry faithfully represents
5-
the existing data tables in supported_nvidia_libs.py."""
5+
the current-platform 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
910
from cuda.pathfinder._dynamic_libs.lib_descriptor import LIB_DESCRIPTORS
1011
from cuda.pathfinder._dynamic_libs.supported_nvidia_libs import (
1112
DIRECT_DEPENDENCIES,
@@ -33,7 +34,8 @@ def test_registry_covers_all_windows_dlls():
3334

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

3840

3941
# ---------------------------------------------------------------------------
@@ -43,22 +45,30 @@ def test_registry_has_no_extra_entries():
4345

4446
@pytest.mark.parametrize("name", sorted(LIB_DESCRIPTORS))
4547
def test_linux_sonames_match(name):
46-
assert LIB_DESCRIPTORS[name].linux_sonames == SUPPORTED_LINUX_SONAMES.get(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, ())
4751

4852

4953
@pytest.mark.parametrize("name", sorted(LIB_DESCRIPTORS))
5054
def test_windows_dlls_match(name):
51-
assert LIB_DESCRIPTORS[name].windows_dlls == SUPPORTED_WINDOWS_DLLS.get(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, ())
5258

5359

5460
@pytest.mark.parametrize("name", sorted(LIB_DESCRIPTORS))
5561
def test_site_packages_linux_match(name):
56-
assert LIB_DESCRIPTORS[name].site_packages_linux == SITE_PACKAGES_LIBDIRS_LINUX.get(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, ())
5765

5866

5967
@pytest.mark.parametrize("name", sorted(LIB_DESCRIPTORS))
6068
def test_site_packages_windows_match(name):
61-
assert LIB_DESCRIPTORS[name].site_packages_windows == SITE_PACKAGES_LIBDIRS_WINDOWS.get(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, ())
6272

6373

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

6979
@pytest.mark.parametrize("name", sorted(LIB_DESCRIPTORS))
7080
def test_requires_add_dll_directory_match(name):
71-
assert LIB_DESCRIPTORS[name].requires_add_dll_directory == (name in LIBNAMES_REQUIRING_OS_ADD_DLL_DIRECTORY)
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)
7284

7385

7486
@pytest.mark.parametrize("name", sorted(LIB_DESCRIPTORS))
7587
def test_requires_rtld_deepbind_match(name):
76-
assert LIB_DESCRIPTORS[name].requires_rtld_deepbind == (name in LIBNAMES_REQUIRING_RTLD_DEEPBIND)
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)
7791

7892

7993
# ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)