Skip to content

Commit efd6a2f

Browse files
committed
Merge remote-tracking branch 'origin/main' into cythonize-linker
Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # cuda_core/cuda/core/_cpp/resource_handles.cpp # cuda_core/cuda/core/_cpp/resource_handles.hpp # cuda_core/cuda/core/_program.pxd # cuda_core/cuda/core/_resource_handles.pxd # cuda_core/cuda/core/_resource_handles.pyx # cuda_core/cuda/core/_utils/cuda_utils.pxd # cuda_core/cuda/core/_utils/cuda_utils.pyx # cuda_core/docs/source/release/0.6.x-notes.rst
2 parents 82377ed + 0921933 commit efd6a2f

12 files changed

Lines changed: 100 additions & 13 deletions

File tree

‎cuda_bindings/MANIFEST.in‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
33

4-
recursive-include cuda/ *.pyx *.pxd *.pxi
4+
recursive-include cuda/ *.pyx *.pxd *.pxi *.pyx.in *.pxd.in *.pxi.in *.h
55
# at least with setuptools 75.0.0 this folder was added erroneously
66
# to the payload, causing file copying to the build environment failed
77
exclude cuda/bindings cuda?bindings

‎cuda_bindings/cuda/bindings/_internal/utils.pyx‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
#
33
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
44

@@ -8,6 +8,28 @@ from libcpp.utility cimport move
88
from cython.operator cimport dereference as deref
99

1010

11+
cdef extern from *:
12+
"""
13+
#if defined(__clang__)
14+
#define _COMPILER_VERSION ("Clang " __clang_version__)
15+
#elif defined(__GNUC__) || defined(__GNUG__)
16+
#define _COMPILER_VERSION ("GCC " __VERSION__)
17+
#elif defined(_MSC_VER)
18+
#define _COMPILER_VERSION ("MSVC " Py_STRINGIFY(_MSC_VER))
19+
#else
20+
#define _COMPILER_VERSION ("Unknown Compiler")
21+
#endif
22+
"""
23+
cdef char *_COMPILER_VERSION
24+
25+
26+
cpdef str get_c_compiler():
27+
"""
28+
Returns a string describing the C compiler used to build cuda.bindings
29+
"""
30+
return _COMPILER_VERSION.decode()
31+
32+
1133
cdef bint is_nested_sequence(data):
1234
if not cpython.PySequence_Check(data):
1335
return False

‎cuda_bindings/docs/source/release/13.1.2-notes.rst‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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: LicenseRef-NVIDIA-SOFTWARE-LICENSE
33
44
.. module:: cuda.bindings
@@ -22,6 +22,13 @@ Bugfixes
2222
(`PR #1336 <https://github.com/NVIDIA/cuda-python/pull/1336>`_)
2323
* Fixed ABI incompatibility bugs in cuFILE bindings introduced in v13.1.0.
2424

25+
Miscellaneous
26+
-------------
27+
28+
* Wheel and installed package sizes significantly reduced (e.g., on a typical Linux x86_64
29+
build, wheel from ~16.6 MB to ~5.7 MB and installed from ~152 MB to ~23 MB) by excluding
30+
Cython source files, generated C++ files, and template files from distribution packages.
31+
2532
Known issues
2633
------------
2734

‎cuda_bindings/pyproject.toml‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,13 @@ Documentation = "https://nvidia.github.io/cuda-python/"
5656
[tool.setuptools.packages.find]
5757
include = ["cuda*"]
5858

59-
[tool.setuptools.exclude-package-data]
60-
"*" = ["*.cpp"]
59+
[tool.setuptools]
60+
include-package-data = false
61+
62+
[tool.setuptools.package-data]
63+
"*" = ["*.pxd", "*.pxi"]
64+
"cuda.bindings._bindings" = ["*.h"]
65+
"cuda.bindings._lib" = ["*.h"]
6166

6267
[tool.setuptools.dynamic]
6368
readme = { file = ["DESCRIPTION.rst"], content-type = "text/x-rst" }

‎cuda_bindings/tests/nvml/test_device.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def test_get_nv_link_supported_bw_modes(all_devices):
7171
for device in all_devices:
7272
with unsupported_before(device, None):
7373
modes = nvml.device_get_nvlink_supported_bw_modes(device)
74-
assert isinstance(modes, nvml.NvLinkSupportedBWModes)
74+
assert isinstance(modes, nvml.NvLinkSupportedBWModes_v1)
7575
# #define NVML_NVLINK_TOTAL_SUPPORTED_BW_MODES 23
7676
assert len(modes.bw_modes) <= 23
7777
assert not hasattr(modes, "total_bw_modes")

‎cuda_bindings/tests/test_utils.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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: LicenseRef-NVIDIA-SOFTWARE-LICENSE
33

44
import importlib
@@ -9,6 +9,7 @@
99

1010
import pytest
1111
from cuda.bindings import driver, runtime
12+
from cuda.bindings._internal.utils import get_c_compiler
1213
from cuda.bindings.utils import get_cuda_native_handle, get_minimal_required_cuda_ver_from_ptx_ver, get_ptx_ver
1314

1415
have_cufile = importlib.util.find_spec("cuda.bindings.cufile") is not None
@@ -110,3 +111,9 @@ def test_cyclical_imports(module):
110111
subprocess.check_call( # noqa: S603
111112
[sys.executable, Path(__file__).parent / "utils" / "check_cyclical_import.py", f"cuda.bindings.{module}"],
112113
)
114+
115+
116+
def test_get_c_compiler():
117+
c_compiler = get_c_compiler()
118+
prefix = ("GCC", "Clang", "MSVC", "Unknown")
119+
assert sum(c_compiler.startswith(p) for p in prefix) == 1

‎cuda_core/MANIFEST.in‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44

55
recursive-include cuda/core *.pyx *.pxd *.pxi
66
recursive-include cuda/core/_cpp *.cpp *.hpp
7+
recursive-include cuda/core/_include *.h *.hpp

‎cuda_core/docs/source/release/0.6.x-notes.rst‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ Breaking Changes
1717
----------------
1818

1919
- Building ``cuda.core`` from source now requires ``cuda-bindings`` >= 12.9.0, due to Cython-level
20-
dependencies on the NVVM bindings (``cynvvm``). Pre-built wheels are unaffected. The previous
21-
minimum was 12.8.0.
20+
dependencies on the NVVM and nvJitLink bindings (``cynvvm``, ``cynvjitlink``). Pre-built wheels
21+
are unaffected. The previous minimum was 12.8.0.
2222

2323

2424
New features
@@ -36,4 +36,11 @@ None.
3636
Fixes and enhancements
3737
----------------------
3838

39-
None.
39+
- Reduced Python overhead in :class:`Program` and :class:`Linker` by moving compilation and
40+
linking operations to the C level and releasing the GIL during backend calls. This benefits
41+
workloads that create many programs or linkers, and enables concurrent compilation in
42+
multithreaded applications.
43+
- Wheel and installed package sizes significantly reduced (e.g., on a typical Linux x86_64
44+
build, wheel from ~4.6 MB to ~1.6 MB and installed from ~26 MB to ~4.4 MB) by excluding
45+
Cython source files, generated C++ files, and other build artifacts from distribution
46+
packages.

‎cuda_core/pyproject.toml‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,13 @@ issues = "https://github.com/NVIDIA/cuda-python/issues/"
7272
[tool.setuptools.packages.find]
7373
include = ["cuda.core*"]
7474

75+
[tool.setuptools]
76+
include-package-data = false
77+
7578
[tool.setuptools.package-data]
76-
"cuda.core._include" = ["*.h", "*.hpp", "*.cuh"]
77-
"cuda.core._cpp" = ["*.cpp", "*.hpp"]
79+
"*" = ["*.pxd"]
80+
"cuda.core._include" = ["*.h", "*.hpp"]
81+
"cuda.core._cpp" = ["*.hpp"]
7882

7983
[tool.setuptools.dynamic]
8084
readme = { file = ["DESCRIPTION.rst"], content-type = "text/x-rst" }

‎cuda_pathfinder/cuda/pathfinder/_utils/find_sub_dirs.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,9 @@ def find_sub_dirs_sys_path(sub_dirs: Sequence[str]) -> list[str]:
5050

5151

5252
def find_sub_dirs_all_sitepackages(sub_dirs: Sequence[str]) -> list[str]:
53-
return find_sub_dirs((site.getusersitepackages(), *site.getsitepackages()), sub_dirs)
53+
parent_dirs = list(site.getsitepackages())
54+
if site.ENABLE_USER_SITE:
55+
user_site = site.getusersitepackages()
56+
if user_site:
57+
parent_dirs.insert(0, user_site)
58+
return find_sub_dirs(parent_dirs, sub_dirs)

0 commit comments

Comments
 (0)