Skip to content

Fix CUDA pointer and coredump attribute types - #2929

Merged
leofang merged 4 commits into
NVIDIA:13.4.xfrom
kkraus14:codex/issue-2928-pointer-device-ordinal
Sep 22, 2026
Merged

leofang merged 4 commits into
NVIDIA:13.4.xfrom
kkraus14:codex/issue-2928-pointer-device-ordinal

Conversation

@kkraus14

@kkraus14 kkraus14 commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

Fixes #2928.

Correct the internal result storage and Python conversion for CUDA pointer and coredump attributes:

  • return CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL from signed integer storage so negative CUDA device sentinels are preserved
  • store CU_POINTER_ATTRIBUTE_ALLOWED_HANDLE_TYPES in its 64-bit unsigned slot instead of truncating it to 32 bits
  • use a void * result slot for CU_POINTER_ATTRIBUTE_HOST_POINTER
  • use a one-byte C++ bool and its actual size for boolean coredump attributes

The helper declarations are private implementation details, so these corrections do not change the public API or extension ABI. Regression tests exercise negative device ordinals, full-width allowed-handle results, and one-byte coredump writes; the existing pointer and coredump integration tests cover the affected API paths.

Testing:

  • pixi run -q -m cuda_bindings/pixi.toml -e cu13 pytest -q cuda_bindings/tests/test_cuda.py::test_pointer_get_attributes_device_ordinal cuda_bindings/tests/test_cuda.py::test_pointer_allowed_handle_types_preserves_64_bits cuda_bindings/tests/test_cuda.py::test_cuda_pointer_attr cuda_bindings/tests/test_cuda.py::test_coredump_bool_uses_single_byte_storage cuda_bindings/tests/test_cuda.py::test_cuda_coredump_attr (5 passed)
  • git diff --check

@kkraus14 kkraus14 added bug Something isn't working cuda.bindings Everything related to the cuda.bindings module labels Sep 22, 2026
@kkraus14 kkraus14 self-assigned this Sep 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

@kkraus14 kkraus14 changed the title Fix CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL results Fix CUDA pointer and coredump attribute types Sep 22, 2026
Comment thread cuda_bindings/cuda/bindings/_lib/utils.pxd
cdef int _int
cdef driver.CUdeviceptr _devptr
cdef void** _void
cdef void* _void

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Odd name for the type. Should we call it _hostptr?

@leofang leofang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! It is a bit annoying that the C API returns boolean, but sometimes it's unsigned int...

From my bot:

The correct rule for "bool" attrs in this file turns out to be per-API, not blanket:

  • cuCoredumpGetAttribute — driver writes 1 byte → cpp_bool (or uint8_t) is right.
  • cuPointerGetAttribute — driver writes 4 bytes → bint (or uint32_t) is right.

Two follow-ups worth noting:

  • Handle CU_COREDUMP_GENERATION_FLAGS (4 bytes, int bitmask) in _HelperCUcoredumpSettings. Currently raises TypeError.
  • CU_POINTER_ATTRIBUTE_IS_HW_DECOMPRESS_CAPABLE (CTK 12.6+, enum value 21) is a bool-typed pointer attribute the driver already returns, but the helper doesn't handle it — it would raise TypeError: Unsupported attribute. Same completeness-gap category as CU_COREDUMP_GENERATION_FLAGS.

Comment thread cuda_bindings/cuda/bindings/_lib/utils.pxd
@leofang

leofang commented Sep 22, 2026

Copy link
Copy Markdown
Member

Once this PR is merged, I'll backport it to the 13.4.x branch and cut a patch from there.

@leofang
leofang changed the base branch from main to 13.4.x September 22, 2026 15:35
@leofang

leofang commented Sep 22, 2026

Copy link
Copy Markdown
Member

Once this PR is merged, I'll backport it to the 13.4.x branch and cut a patch from there.

I've changed the base branch to 13.4.x, following the new practice established by Mike: We merge critical fixes to the maintenance branch (ex: #2900), and then forward-port it to the main branch (ex: #2913, though it should have been linear- instead of squash- merged).

@leofang

leofang commented Sep 22, 2026

Copy link
Copy Markdown
Member

/ok to test

@copy-pr-bot

copy-pr-bot Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

/ok to test

@leofang, there was an error processing your request: E1

See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/1/

@leofang
leofang marked this pull request as draft September 22, 2026 15:37
@leofang
leofang force-pushed the codex/issue-2928-pointer-device-ordinal branch from 47701ba to 4c3a604 Compare September 22, 2026 15:49
@copy-pr-bot

copy-pr-bot Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@leofang

leofang commented Sep 22, 2026

Copy link
Copy Markdown
Member

/ok to test 4c3a604

@leofang
leofang marked this pull request as ready for review September 22, 2026 15:50
@leofang
leofang enabled auto-merge (squash) September 22, 2026 16:22
@leofang
leofang disabled auto-merge September 22, 2026 16:51
@leofang
leofang enabled auto-merge (squash) September 22, 2026 16:53
@leofang
leofang merged commit 2dcb3f1 into NVIDIA:13.4.x Sep 22, 2026
158 of 160 checks passed
@leofang

leofang commented Sep 22, 2026

Copy link
Copy Markdown
Member

Note: This is also a follow-up of #1451, which fixed half of the type-mismatching bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cuda.bindings Everything related to the cuda.bindings module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL from cuPointerGetAttribute always returns 0

3 participants