Skip to content

Add get_cuda_native_handle #773

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 23, 2025
Merged

Add get_cuda_native_handle #773

merged 4 commits into from
Jul 23, 2025

Conversation

leofang
Copy link
Member

@leofang leofang commented Jul 22, 2025

Description

closes #564

The performance is comparable to the existing int() approach (O(10) ns):

In [1]: from cuda.bindings import driver

In [3]: s = driver.CUstream(1234)

In [4]: int(s)
Out[4]: 1234

In [6]: from cuda.bindings.utils import get_cuda_native_handle

In [7]: get_cuda_native_handle(s)
Out[7]: 1234

In [8]: %timeit int(s)
44.7 ns ± 1.34 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)

In [9]: %timeit get_cuda_native_handle(s)
95.1 ns ± 1.06 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)

Checklist

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@leofang leofang added this to the cuda-python 12-next, 11-next milestone Jul 22, 2025
@leofang leofang self-assigned this Jul 22, 2025
@leofang leofang added P1 Medium priority - Should do feature New feature or request cuda.bindings Everything related to the cuda.bindings module labels Jul 22, 2025
@github-project-automation github-project-automation bot moved this to Todo in CCCL Jul 22, 2025
Copy link
Contributor

copy-pr-bot bot commented Jul 22, 2025

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
Copy link
Member Author

leofang commented Jul 22, 2025

(added a short benchmark to the PR description)

@leofang
Copy link
Member Author

leofang commented Jul 22, 2025

/ok to test 8970dca

@leofang
Copy link
Member Author

leofang commented Jul 22, 2025

/ok to test 4ca551c

@@ -287,6 +288,7 @@ def prep_extensions(sources, libraries):

# new path for the bindings from cybind
def rename_architecture_specific_files():
path = os.path.join("cuda", "bindings", "_internal")
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: this is a bug fix exposed by the new line 224. Previously, the path variable happened to be right (leaking from the loop variable at line 227), but it's not longer correct after we append one more item to path_list.

This comment has been minimized.

@leofang leofang requested a review from shwina July 23, 2025 01:39
@leofang
Copy link
Member Author

leofang commented Jul 23, 2025

Decision to make: Should we raise DeprecationWarning in __int__()? It can be very noisy but it's the only effective way for us to inform users about the deprecation.

rwgk
rwgk previously approved these changes Jul 23, 2025
Copy link
Collaborator

@rwgk rwgk left a comment

Choose a reason for hiding this comment

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

Decision to make: Should we raise DeprecationWarning in __int__()? It can be very noisy but it's the only effective way for us to inform users about the deprecation.

Do we want to give users a grace period, in case they need to support two cuda-bindings versions for a while?

Concretely:

In the next release, deprecate only in the documentation.

Only with the next minor release bump: actually raise DeprecationWarning.

@github-project-automation github-project-automation bot moved this from Todo to In Review in CCCL Jul 23, 2025
@leofang
Copy link
Member Author

leofang commented Jul 23, 2025

/ok to test 53055e5

@leofang leofang merged commit 8cc1b68 into NVIDIA:main Jul 23, 2025
53 checks passed
@rwgk
Copy link
Collaborator

rwgk commented Jul 23, 2025

Decision to make: Should we raise DeprecationWarning in __int__()? It can be very noisy but it's the only effective way for us to inform users about the deprecation.

Do we want to give users a grace period, in case they need to support two cuda-bindings versions for a while?

Concretely:

In the next release, deprecate only in the documentation.

Only with the next minor release bump: actually raise DeprecationWarning.

@leofang WDYT about introducing a "Phased deprecations" section somewhere, so we don't forget in the future.

E.g. for this case:

__int__() method for type A, B, C were informally deprecated in cuda-bindings release vX.Y.Z. DeprecationWarning will be raised starting with release vX.Y+1.0.

Copy link

Doc Preview CI
Preview removed because the pull request was closed or merged.

@leofang leofang deleted the utils_get_handle branch July 23, 2025 17:05
@leofang
Copy link
Member Author

leofang commented Jul 23, 2025

Yup that's great idea, tracked in #775.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cuda.bindings Everything related to the cuda.bindings module feature New feature or request P1 Medium priority - Should do
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[FEA]: Expose get_cuda_native_handle to Python
2 participants