Repository navigation
Conversation
Signed-off-by: 0z5a <dezhen.lu@student.uni-tuebingen.de>
|
No actionable comments were generated in the recent review. Summary
Change: Feature Merge Risk:
|
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: NVIDIA/cuda-python
- Branch: main
- File: .coderabbit.yaml
- Commit: d4c71ef
- Layers: Repository YAML
- Review profile: CHILL
- Plan: Enterprise
- Run ID:
6dfd55b2-b1d5-41b2-a566-d74988bcde75
Files selected for processing: 3-
samples/cuda_core/graceHopperMemory/README.mdsamples/cuda_core/graceHopperMemory/graceHopperMemory.pysamples/cuda_core/graceHopperMemory/requirements.txt
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
-
| # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
|
||
| # /// script | ||
| # dependencies = ["cuda-python>=13.0.0", "cuda-core>=1.3.0", "numpy>=2.2.5"] |
There was a problem hiding this comment.
| # dependencies = ["cuda-python>=13.0.0", "cuda-core>=1.3.0", "numpy>=2.2.5"] | |
| # dependencies = ["cuda-core>=1.3.0", "numpy>=2.2.5"] |
There was a problem hiding this comment.
Thanks, I dropped cuda-python. Two changes to the suggested line: the rewrite uses CuPy, so cupy-cuda13x>=14.0.0 is now listed, and I use cuda-core[cu13] because plain cuda-core does not install cuda-bindings (import cuda.core failed in a clean venv without it). The header is now:
# dependencies = ["cuda-core[cu13]>=1.3.0", "cupy-cuda13x>=14.0.0", "numpy>=2.2.5"]
requirements.txt matches. Happy to switch back to plain cuda-core>=1.3.0 if you prefer.
There was a problem hiding this comment.
The example seems overly complicated here. What are we trying to achieve?
We can allocate buffers from different MRs, and then wrap them as CuPy arrays via cp.from_dlpack(buf). Then, all the custom kernels can be replaced by standard CuPy ops.
There was a problem hiding this comment.
Agreed. I removed the custom kernels, NVRTC and the bandwidth timing. The goal is to show that on Grace Hopper the GPU can work in place on host memory and the CPU sees the result without a copy. The sample now allocates from PinnedMemoryResource (on the GPU's host NUMA node), ManagedMemoryResource and DeviceMemoryResource, adds a plain NumPy array as pageable memory, wraps each one as a CuPy array, and uses only CuPy ops (*=, sum). The CPU writes the input and checks the result in the same memory.
One snag: cp.from_dlpack() works for the device and managed buffers, but CuPy 14.2 rejects the pinned buffer (kDLCUDAHost: TypeError: Unsupported array type: 3) and NumPy memory (kDLCPU). For those two the sample wraps the pointer with cupy.cuda.UnownedMemory in a small helper. Is there a better way to do this in CuPy?
Verified on GH200.
Wrap buffers from the pinned (host NUMA), managed and device memory resources, plus a pageable NumPy array, as CuPy arrays and use standard CuPy ops instead of custom kernels. Drop the bandwidth timing and the NVML C2C query, and verify every result on the CPU. cp.from_dlpack() does not import pinned or CPU memory, so those two are wrapped with cupy.cuda.UnownedMemory. Update the script dependencies to cuda-core[cu13], CuPy and NumPy, and drop cuda-python. Signed-off-by: 0z5a <dezhen.lu@student.uni-tuebingen.de>
cuda-core 1.2.2 supplies the APIs used by this sample. Lower the minimum version consistently in the script metadata, requirements, and README; verify the clean requirements and sample on GH200. Signed-off-by: 0z5a <dezhen.lu@student.uni-tuebingen.de>
Description
Related to #3219.
This sample demonstrates GPU operations on host-accessible memory on Grace Hopper. It allocates pinned memory on the GPU's host NUMA node and managed memory with
cuda.core, alongside a pageable NumPy array. CuPy doubles and sums the data; the CPU checks the results. A device-memory case demonstrates the corresponding explicit host/device copies.The sample uses CuPy operations rather than custom kernels. CuPy does not import the pinned or pageable buffers through DLPack here, so it wraps their pointers with
cupy.cuda.UnownedMemory. The sample waives when the required host-page-table, managed-memory or NUMA-pool capabilities are unavailable.The minimum
cuda-coreversion is 1.2.2, which is available on PyPI and provides the APIs used by the sample.Validation
On 2026-11-04, tested the sample on a GH200 480GB (compute capability 9.0, driver 595.58.03). The host NUMA node was 0; host-page-table access, concurrent managed access and host NUMA memory-pool support were reported as available.
cuda-core 1.2.2,cuda-bindings 13.4.4,cuda-toolkit 13.4.3, CuPy 14.2.0 and NumPy 2.5.4; the host CUDA toolkit was 13.2.a7058a32e3541634cbc1600ceb5f5c654edb9693:a67cea6066c72ccf8d82f5da9878edfc7eb32a7c43274e3fbc7b5a5285f8e04fandc088005b55f735c586bf4d833634a9395e1d5ea17edee679ae72e3fce64fe79a, respectively. The test ran before the commit was created.The non-ATS waiver path was not rerun. Managed-memory access may migrate pages; the sample makes no bandwidth claim.