Skip to content

Conversation

mdboom
Copy link
Contributor

@mdboom mdboom commented Aug 27, 2025

This now textually includes cuda.bindings._lib.cyruntime.cyruntime in cuda.bindings._bindings.cyruntime to remove the cycle.

Since this is only /adding/ symbols to cuda.bindings._bindings.cyruntime, I believe it isn't breaking ABI compatibility (but I admittedly am only now getting used to "Cython ABI compatibility"). The old cuda.bindings._lib.cyruntime.cyruntime and cuda.bindings._lib.cyruntime.utils are just removed, but since those were private, I think we ok for ABI there, too.

I also discovered a bug in the test for cycles that was finding erroneous cycles when ImportErrors were raised and caught.

Description

closes

Checklist

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

@copy-pr-bot
Copy link
Contributor

copy-pr-bot bot commented Aug 27, 2025

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@mdboom
Copy link
Contributor Author

mdboom commented Aug 27, 2025

/ok to test

@github-actions

This comment has been minimized.

@leofang leofang added enhancement Any code-related improvements P0 High priority - Must do! cuda.bindings Everything related to the cuda.bindings module labels Aug 27, 2025
@leofang leofang added this to the cuda-python 13-next, 12-next milestone Aug 27, 2025
Copy link
Member

@leofang leofang left a comment

Choose a reason for hiding this comment

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

LGTM overall! Left a few questions. Is this still WIP (since it's in the draft state)?

@mdboom mdboom marked this pull request as ready for review August 27, 2025 20:24
@copy-pr-bot
Copy link
Contributor

copy-pr-bot bot commented Aug 27, 2025

Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@mdboom
Copy link
Contributor Author

mdboom commented Aug 27, 2025

LGTM overall! Left a few questions. Is this still WIP (since it's in the draft state)?

No, it's ready for review. I didn't notice I created a draft...

@mdboom
Copy link
Contributor Author

mdboom commented Aug 27, 2025

/ok to test

@kkraus14
Copy link
Collaborator

The old cuda.bindings._lib.cyruntime.cyruntime and cuda.bindings._lib.cyruntime.utils are just removed, but since those were private, I think we ok for ABI there, too.

I poked around the generated .cpp code from the Cython to get a better sense as to what's happening when using cimport and the potential ABI issues.

It looks like when you cimport something it adds a declaration, i.e. for cuda.bindings._lib.cyruntime.utils.getDriverEglFrame the generated .cpp code from something that cimports it contains the following:

  • A declaration statement that looks like:
static cudaError_t (*__pyx_f_4cuda_8bindings_4_lib_9cyruntime_5utils_getDriverEglFrame)(__pyx_t_4cuda_8bindings_8cydriver_CUeglFrame *, __pyx_t_4cuda_8bindings_9cyruntime_cudaEglFrame); /*proto*/
  • Within a static int __Pyx_modinit_function_import_code function, a call that looks like:
if (__Pyx_ImportFunction_3_0_12(__pyx_t_1, "getDriverEglFrame", (void (**)(void))&__pyx_f_4cuda_8bindings_4_lib_9cyruntime_5utils_getDriverEglFrame, "cudaError_t (__pyx_t_4cuda_8bindings_8cydriver_CUeglFrame *, __pyx_t_4cuda_8bindings_9cyruntime_cudaEglFrame)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)

So there's zero linkage happening and everything is declared as static. The symbol resolution is happening via the __Pyx_ImportFunction_3_0_12 function and unless the cimport is redeclared in a .pxd file, it doesn't yield a corresponding __Pyx_ExportFunction call for it.

I think this effectively means we can treat Cython the same way we treat Python where we only need to worry about API compatibility, except for externed vs non-externed declarations in .pxd files in public modules where we have shown in the past that it causes ABI breakage.

@mdboom
Copy link
Contributor Author

mdboom commented Aug 27, 2025

/ok to test

kkraus14
kkraus14 previously approved these changes Aug 27, 2025
@mdboom
Copy link
Contributor Author

mdboom commented Aug 27, 2025

/ok to test

@mdboom
Copy link
Contributor Author

mdboom commented Aug 28, 2025

/ok to test

@mdboom
Copy link
Contributor Author

mdboom commented Aug 28, 2025

/ok to test

@mdboom mdboom requested a review from leofang August 28, 2025 14:15
leofang
leofang previously approved these changes Aug 28, 2025
@leofang leofang merged commit dd0ceef into NVIDIA:main Aug 28, 2025
1 check passed
@leofang
Copy link
Member

leofang commented Aug 28, 2025

Thanks a lot @mdboom!

@github-actions
Copy link

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

mdboom added a commit to mdboom/cuda-python that referenced this pull request Aug 28, 2025
mdboom added a commit to mdboom/cuda-python that referenced this pull request Aug 28, 2025
kkraus14 pushed a commit that referenced this pull request Aug 28, 2025
@cpcloud cpcloud mentioned this pull request Oct 8, 2025
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 enhancement Any code-related improvements P0 High priority - Must do!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants