This file describes cuda_core, the high-level Pythonic CUDA subpackage in the
cuda-python monorepo.
- Role: provide higher-level CUDA abstractions (
Device,Stream,Program,Linker, memory resources, graphs) on top ofcuda.bindings. - API intent: keep interfaces Pythonic while preserving explicit CUDA behavior and error visibility.
- Compatibility: changes should remain compatible with supported
cuda.bindingsmajor versions (12.x and 13.x).
- Main package:
cuda/core/contains most Cython modules (*.pyx,*.pxd) implementing runtime behaviors and public objects. - Subsystems:
- memory/resource stack:
cuda/core/_memory/ - system-level APIs:
cuda/core/system/ - compile/link path:
_program.pyx,_linker.pyx,_module.pyx - execution path:
_launcher.pyx,_launch_config.pyx,_stream.pyx
- memory/resource stack:
- C++ helpers: module-specific C++ implementations live under
cuda/core/_cpp/. - Build backend:
build_hooks.pyhandles Cython extension setup and build dependency wiring.
build_hooks.pydetermines CUDA major version fromCUDA_CORE_BUILD_MAJORor CUDA headers (CUDA_HOME/CUDA_PATH) and uses it for build decisions.- Source builds require CUDA headers available through
CUDA_HOMEorCUDA_PATH. cuda_coreexpectscuda.bindingsto be present and version-compatible.
- Primary tests:
pytest tests/ - Examples: validate affected examples in
examples/when changing user workflows or public APIs. - Orchestrated run: from repo root,
scripts/run_tests.sh core.
- Runtime env vars commonly relevant:
CUDA_PYTHON_CUDA_PER_THREAD_DEFAULT_STREAMCUDA_PYTHON_DISABLE_MAJOR_VERSION_WARNING
- Build env vars commonly relevant:
CUDA_HOME/CUDA_PATHCUDA_CORE_BUILD_MAJORCUDA_PYTHON_PARALLEL_LEVELCUDA_PYTHON_COVERAGE
- Keep user-facing behaviors coherent with docs and examples, especially around stream semantics, memory ownership, and compile/link flows.
- Reuse existing shared utilities in
cuda/core/_utils/before adding new helpers. - When changing Cython signatures or cimports, verify related
.pxdand call-site consistency. - Prefer explicit error propagation over silent fallback paths.
- If you change public behavior, update tests and docs under
docs/source/.