Feature Request
Promote the internal cuLibrary*-backed loading path into a public
first-class Library class in cuda.core, symmetric to ObjectCode and
Kernel.
Current State
The low-level cuda.bindings layer already exposes cudaLibrary_t and
CUlibraryOption_enum. Internal cuda.core code references library
handles (e.g. LibraryHandle _h_library in _module.pxd, LIBRARY in
cuda.core.typing.CodeType, and ObjectCode.from_library(...)). However,
there is no public cuda.core.Library class — users who want to load a
CUDA library (a collection of kernels, constants, and global variables,
loaded via cuLibraryLoadData / cuLibraryLoadFromFile) have to go
through ObjectCode.from_library which returns an ObjectCode, not a
richer library-aware object.
Motivation
CUDA 12.0+ introduced cuLibrary* as the modern replacement for
cuModule*, supporting:
- Per-library global variables with
cuLibraryGetGlobal /
cuLibraryGetManaged / cuLibraryGetUnifiedFunction.
- Per-kernel and per-library options (
CU_LIBRARY_BINARY_IS_PRESERVED,
host universal function fallback, etc.).
- Cleaner separation between "compiled artifact" (ObjectCode) and
"loaded runtime handle" (Library) than the legacy module path.
A public Library class would let users access globals, query kernel
tables, and manage library lifetime explicitly — parity with what
cuModule* users get today via ObjectCode + Kernel, but for the
modern driver API.
Proposed Scope
- A
cuda.core.Library class wrapping CUlibrary with:
Library.load(data_or_path, options=...) factory
.get_kernel(name) -> Kernel
.get_global(name) -> (device_ptr, size)
.get_managed(name), .get_unified_function(name)
- Context-manager lifecycle
- A
LibraryOptions dataclass mirroring CU_LIBRARY_* enum values.
- Integration with the existing
ObjectCode.from_library path — likely
ObjectCode can expose a .to_library(options=...) shortcut.
- API reference entries and at least one example.
Related
- Driver APIs:
cuLibraryLoadData, cuLibraryLoadFromFile, cuLibraryUnload,
cuLibraryGetKernel, cuLibraryGetGlobal, cuLibraryGetManaged,
cuLibraryGetUnifiedFunction, cuLibraryGetModule.
- Existing internal references:
cuda_core/cuda/core/_module.pxd
(LibraryHandle), cuda_core/cuda/core/typing.py (CodeType.LIBRARY),
ObjectCode.from_library in _module.pyx.
- Part of cuda.core feature audit gap list (Nov 2025).
Feature Request
Promote the internal
cuLibrary*-backed loading path into a publicfirst-class
Libraryclass incuda.core, symmetric toObjectCodeandKernel.Current State
The low-level
cuda.bindingslayer already exposescudaLibrary_tandCUlibraryOption_enum. Internalcuda.corecode references libraryhandles (e.g.
LibraryHandle _h_libraryin_module.pxd,LIBRARYincuda.core.typing.CodeType, andObjectCode.from_library(...)). However,there is no public
cuda.core.Libraryclass — users who want to load aCUDA library (a collection of kernels, constants, and global variables,
loaded via
cuLibraryLoadData/cuLibraryLoadFromFile) have to gothrough
ObjectCode.from_librarywhich returns anObjectCode, not aricher library-aware object.
Motivation
CUDA 12.0+ introduced
cuLibrary*as the modern replacement forcuModule*, supporting:cuLibraryGetGlobal/cuLibraryGetManaged/cuLibraryGetUnifiedFunction.CU_LIBRARY_BINARY_IS_PRESERVED,host universal function fallback, etc.).
"loaded runtime handle" (Library) than the legacy module path.
A public
Libraryclass would let users access globals, query kerneltables, and manage library lifetime explicitly — parity with what
cuModule*users get today viaObjectCode+Kernel, but for themodern driver API.
Proposed Scope
cuda.core.Libraryclass wrappingCUlibrarywith:Library.load(data_or_path, options=...)factory.get_kernel(name) -> Kernel.get_global(name) -> (device_ptr, size).get_managed(name),.get_unified_function(name)LibraryOptionsdataclass mirroringCU_LIBRARY_*enum values.ObjectCode.from_librarypath — likelyObjectCodecan expose a.to_library(options=...)shortcut.Related
cuLibraryLoadData,cuLibraryLoadFromFile,cuLibraryUnload,cuLibraryGetKernel,cuLibraryGetGlobal,cuLibraryGetManaged,cuLibraryGetUnifiedFunction,cuLibraryGetModule.cuda_core/cuda/core/_module.pxd(
LibraryHandle),cuda_core/cuda/core/typing.py(CodeType.LIBRARY),ObjectCode.from_libraryin_module.pyx.