Skip to content

Commit de17dc8

Browse files
committed
Merge branch 'main' into rparolin/192_issue_fix
2 parents 566842d + 6afdd5c commit de17dc8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+3520
-743
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ cuda/_version.py export-subst
66
# we do not own any headers checked in, don't touch them
77
*.h binary
88
*.hpp binary
9+
# Exception: headers we own (cuda_core C++ implementation)
10+
cuda_core/cuda/core/_cpp/*.h -binary text diff
11+
cuda_core/cuda/core/_cpp/*.hpp -binary text diff
912
# git should not convert line endings in PNG files
1013
*.png binary
1114
*.svg binary

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ __pycache__/
1111
.pytest_cache/
1212
.benchmarks/
1313
*.cpp
14+
!*_impl.cpp
1415
!cuda_bindings/cuda/bindings/_lib/param_packer.cpp
1516
!cuda_bindings/cuda/bindings/_bindings/loader.cpp
1617
cache_driver

ci/tools/merge_cuda_core_wheels.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,21 @@ def merge_wheels(wheels: List[Path], output_dir: Path, show_wheel_contents: bool
150150
"__init__.py",
151151
"_version.py",
152152
"_include",
153+
"_cpp", # Headers for Cython development
153154
"cu12",
154155
"cu13",
155156
)
157+
# _resource_handles is shared (not CUDA-version-specific) and must stay
158+
# at top level. It's imported early in __init__.py before versioned code.
159+
items_to_keep_prefix = ("_resource_handles",)
156160
all_items = os.scandir(base_wheel / base_dir)
157161
removed_count = 0
158162
for f in all_items:
159163
f_abspath = f.path
160164
if f.name in items_to_keep:
161165
continue
166+
if any(f.name.startswith(prefix) for prefix in items_to_keep_prefix):
167+
continue
162168
if f.is_dir():
163169
print(f" Removing directory: {f.name}", file=sys.stderr)
164170
shutil.rmtree(f_abspath)

cuda_bindings/cuda/bindings/_lib/utils.pxd.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ cdef class _HelperCUpointer_attribute:
5050
# Return values
5151
cdef driver.CUcontext _ctx
5252
cdef unsigned int _uint
53+
cdef int _int
5354
cdef driver.CUdeviceptr _devptr
5455
cdef void** _void
5556
cdef driver.CUDA_POINTER_ATTRIBUTE_P2P_TOKENS _token

cuda_bindings/cuda/bindings/_lib/utils.pxi.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,14 @@ cdef class _HelperCUpointer_attribute:
247247
else:
248248
self._cptr = <void*><void_ptr>init_value.getPtr()
249249
elif self._attr in ({{if 'CU_POINTER_ATTRIBUTE_MEMORY_TYPE'}}cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_MEMORY_TYPE,{{endif}}
250-
{{if 'CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL'}}cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL,{{endif}}
251250
{{if 'CU_POINTER_ATTRIBUTE_ALLOWED_HANDLE_TYPES'}}cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_ALLOWED_HANDLE_TYPES,{{endif}}
252251
{{if 'CU_POINTER_ATTRIBUTE_IS_GPU_DIRECT_RDMA_CAPABLE'}}cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_IS_GPU_DIRECT_RDMA_CAPABLE,{{endif}}
253252
{{if 'CU_POINTER_ATTRIBUTE_ACCESS_FLAGS'}}cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_ACCESS_FLAGS,{{endif}}):
254253
self._uint = init_value
255254
self._cptr = <void*>&self._uint
255+
elif self._attr in ({{if 'CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL'}}cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL,{{endif}}):
256+
self._int = init_value
257+
self._cptr = <void*>&self._int
256258
elif self._attr in ({{if 'CU_POINTER_ATTRIBUTE_DEVICE_POINTER'}}cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_DEVICE_POINTER,{{endif}}
257259
{{if 'CU_POINTER_ATTRIBUTE_RANGE_START_ADDR'}}cydriver.CUpointer_attribute_enum.CU_POINTER_ATTRIBUTE_RANGE_START_ADDR,{{endif}}):
258260
if self._is_getter:

cuda_bindings/cuda/bindings/_nvml.pyx

Lines changed: 44 additions & 37 deletions
Large diffs are not rendered by default.

cuda_bindings/docs/source/conf.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@
5353
# This pattern also affects html_static_path and html_extra_path.
5454
exclude_patterns = []
5555

56+
# Include object entries (methods, attributes, etc.) in the table of contents
57+
# This enables the "On This Page" sidebar to show class methods and properties
58+
# Requires Sphinx 5.1+
59+
toc_object_entries = True
60+
toc_object_entries_show_parents = "domain"
61+
5662
# -- Options for HTML output -------------------------------------------------
5763

5864
# The theme to use for HTML and HTML Help pages. See the documentation for
@@ -69,6 +75,10 @@
6975
"version-switcher",
7076
"navbar-nav",
7177
],
78+
# Use custom secondary sidebar that includes autodoc entries
79+
"secondary_sidebar_items": ["page-toc"],
80+
# Show more TOC levels by default
81+
"show_toc_level": 3,
7282
}
7383
if os.environ.get("CI"):
7484
if int(os.environ.get("BUILD_PREVIEW", 0)):
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
.. SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3+
4+
.. module:: cuda.bindings
5+
6+
``cuda-bindings`` 13.1.X Release notes
7+
======================================
8+
9+
Highlights
10+
----------
11+
12+
Experimental
13+
------------
14+
15+
Bugfixes
16+
--------
17+
18+
* Fixed an issue where the ``CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL`` attribute was
19+
retrieved as an unsigned int, rather than a signed int.
20+
(`PR #1336 <https://github.com/NVIDIA/cuda-python/pull/1336>`_)
21+
22+
Known issues
23+
------------
24+
25+
* Updating from older versions (v12.6.2.post1 and below) via ``pip install -U cuda-python`` might not work. Please do a clean re-installation by uninstalling ``pip uninstall -y cuda-python`` followed by installing ``pip install cuda-python``.
26+
* The graphics APIs in ``cuda.bindings.runtime`` are inadvertently disabled in 13.0.2. Users needing these APIs should update to 13.0.3.

cuda_bindings/tests/nvml/test_nvlink.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ def test_nvlink_get_link_count(all_devices):
1111
"""
1212
for device in all_devices:
1313
fields = nvml.FieldValue(1)
14-
fields[0].field_id = nvml.FI.DEV_NVLINK_LINK_COUNT
14+
fields[0].field_id = nvml.FieldId.DEV_NVLINK_LINK_COUNT
1515
value = nvml.device_get_field_values(device, fields)[0]
1616
assert value.nvml_return == nvml.Return.SUCCESS or value.nvml_return == nvml.Return.ERROR_NOT_SUPPORTED, (
1717
f"Unexpected return {value.nvml_return} for link count field query"
1818
)
1919

2020
# Use the alternative argument to device_get_field_values
21-
value = nvml.device_get_field_values(device, [nvml.FI.DEV_NVLINK_LINK_COUNT])[0]
21+
value = nvml.device_get_field_values(device, [nvml.FieldId.DEV_NVLINK_LINK_COUNT])[0]
2222
assert value.nvml_return == nvml.Return.SUCCESS or value.nvml_return == nvml.Return.ERROR_NOT_SUPPORTED, (
2323
f"Unexpected return {value.nvml_return} for link count field query"
2424
)

cuda_bindings/tests/test_cuda.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,22 @@ def test_cuda_pointer_attr():
370370
assert err == cuda.CUresult.CUDA_SUCCESS
371371

372372

373+
@pytest.mark.skipif(
374+
driverVersionLessThan(11030) or not supportsManagedMemory(), reason="When new attributes were introduced"
375+
)
376+
def test_pointer_get_attributes_device_ordinal():
377+
attributes = [
378+
cuda.CUpointer_attribute.CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL,
379+
]
380+
381+
attrs = cuda.cuPointerGetAttributes(len(attributes), attributes, 0)
382+
383+
# device ordinals are always small numbers. A large number would indicate
384+
# an overflow error.
385+
386+
assert abs(attrs[1][0]) < 256
387+
388+
373389
@pytest.mark.skipif(not supportsManagedMemory(), reason="When new attributes were introduced")
374390
def test_cuda_mem_range_attr(device):
375391
size = 0x1000

0 commit comments

Comments
 (0)