Skip to content

Add ObjectCode.get_module() for legacy driver API integration#2339

Merged
isVoid merged 2 commits into
NVIDIA:mainfrom
lijinf2:fix_489
Jul 23, 2026
Merged

Add ObjectCode.get_module() for legacy driver API integration#2339
isVoid merged 2 commits into
NVIDIA:mainfrom
lijinf2:fix_489

Conversation

@lijinf2

@lijinf2 lijinf2 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Description

closes #489

Add ObjectCode.get_module() to expose the CUmodule for the current context via cuLibraryGetModule, so code using legacy driver APIs can interoperate with cuda.core's context-independent CUlibrary loading.

Checklist

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

@copy-pr-bot

copy-pr-bot Bot commented Jul 10, 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.

@github-actions github-actions Bot added the cuda.core Everything related to the cuda.core module label Jul 10, 2026
@lijinf2 lijinf2 self-assigned this Jul 10, 2026
@lijinf2 lijinf2 added this to the cuda.core next milestone Jul 10, 2026
@lijinf2 lijinf2 added the P1 Medium priority - Should do label Jul 10, 2026
@lijinf2

lijinf2 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 600176e

@github-actions

This comment has been minimized.

cdef cydriver.CUmodule mod
with nogil:
HANDLE_RETURN(cydriver.cuLibraryGetModule(&mod, as_cu(self._h_library)))
return driver.CUmodule(<intptr_t>mod)

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.

Q: Shouldn't we use as_py() to do the return value conversion?

Q: How do we teach the difference between .get_module() and .handle?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry for not getting back sooner. I shifted focus to issue #2179, for which I need to set up cuda bindings development environment for the first time.

It looks as_py() does not provide support for CUmodule type yet. I am not sure if we should add the support there per CUmodule is deemed as legacy API. But let me know if you find the support favorable. Happy to add that.

For .handle vs .get_module(): I'll clarify in the docstring.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@leofang
leofang requested a review from isVoid July 14, 2026 18:58
@leofang leofang added the feature New feature or request label Jul 14, 2026
Document that .handle returns the native context-independent CUlibrary
for cuda.core/newer APIs, while get_module() is a legacy-interop bridge
returning a context-dependent CUmodule via cuLibraryGetModule.
@lijinf2

lijinf2 commented Jul 18, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test b56e37e

@isVoid isVoid left a comment

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.

I think we can create a new as_py function in _resource_handle.hpp that accpets cumodule type. But this can be set as a follow up issue.

@isVoid
isVoid merged commit c918891 into NVIDIA:main Jul 23, 2026
199 of 201 checks passed
@github-actions

This comment has been minimized.

1 similar comment
@github-actions

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

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

Labels

cuda.core Everything related to the cuda.core module feature New feature or request P1 Medium priority - Should do

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exposing cuLibraryGetModule in cuda.core

3 participants