You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add cuda-python agent skill for users and evals - #3452
Added a CUDA Python guide with installation guidance, API recommendations, and examples for compiling and launching kernels.
The guide covers kernel arguments, header discovery, interoperability with CuPy, PyTorch, and Numba, CUDA graph capture, and migration from older CUDA Python and PyCUDA APIs.
Added practical examples illustrating CUDA workflows, performance measurement, debugging, memory handling, streams, and API usage.
Adds a CUDA Python skill guide, 16 evaluation cases, and runnable examples. The guide covers installation, CUDA Core workflows, interoperability, graph capture, header discovery, and migration. The examples demonstrate CUDA kernel workflows and legacy API usage.
Changes: CUDA Python skill and evaluations
Layer / File(s)
Summary
Guide and skill scope skills/cuda-python/SKILL.md, toolshed/check_spdx.py
The guide describes installation, cuda.core workflows, framework interoperability, graph capture, header discovery, and migration. The SPDX directory map includes skills.
Evaluation suite skills/cuda-python/evals/evals.json
The suite defines 16 evaluation cases with expected skill classifications, output criteria, and assertions. It covers CUDA Python workflows and migrations, plus negative cases for CuPy-only and PyTorch-install prompts.
Core and runtime examples skills/cuda-python/evals/files/cuda-python-fix-hardcoded-paths/code/half_roundtrip.py, skills/cuda-python/evals/files/cuda-python-fix-ignored-errors/code/hot_cells.py, skills/cuda-python/evals/files/cuda-python-fix-scalar-args/code/normalize.py, skills/cuda-python/evals/files/cuda-python-fix-stream-order/code/denoise.py, skills/cuda-python/evals/files/cuda-python-perf-launch-loop/code/diffuse.py, skills/cuda-python/evals/files/cuda-python-review-calibrate/code/calibrate.py
The examples compile and launch CUDA kernels for numerical processing, counting, normalization, stream interoperability, diffusion, and calibration. They report results and synchronize work as described in each example.
API migration examples skills/cuda-python/evals/files/cuda-python-port-core-experimental/code/pipeline.py, skills/cuda-python/evals/files/cuda-python-port-legacy-bindings/code/saxpy_legacy.py, skills/cuda-python/evals/files/cuda-python-port-pycuda/code/threshold_pycuda.py
The examples demonstrate CUDA Core experimental LTO linking, CUDA 11.8 low-level bindings, and PyCUDA kernel workflows.
Change: Other
Merge Risk: Moderate · up to 3f28b
The guide's main example can fail or race when users copy it. It writes to a pinned buffer that may be read-only under NumPy 2.x, and it does so before synchronizing the stream. A few other guide and evaluation examples also have open gaps. Fix the main example before merging, since it is the first code readers will run.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
Additional comments: 1
skills/cuda-python/SKILL.md-86-86: 1
86-86: Major · Stability & Availability · Quick win
Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
important: Wait for the host allocation before writing.
PinnedMemoryResource.allocate is stream-ordered, but this CPU write does not wait for the allocation to complete. This can access the allocation too early. Synchronize before host access, or use a synchronous pinned allocation. (raw.githubusercontent.com)
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Major · Functional Correctness · Quick win
important: Make layer_scale accessible to the kernel.
CUDA 12.4 treats this namespace-scope constexpr array as a host object. half_error indexes it with the runtime value layer, so compilation fails even after the header paths are fixed. Move the array into the kernel or use device constant storage. Keep the <cuda/std/array> dependency if the evaluation must test CCCL header lookup. (docs.nvidia.com)
The reason will be displayed to describe this comment to others. Learn more.
Major · Functional Correctness · Quick win
important: Support devices without host memory pools.
After fixing the import, this allocation can fail on devices without host memory pool support. Use LegacyPinnedMemoryResource for this example, or check the capability and provide a fallback. (raw.githubusercontent.com)
The reason will be displayed to describe this comment to others. Learn more.
Major · Functional Correctness · Quick win
important: Validate the array’s device.
On a multi-GPU system, an array on GPU 1 can pass this check while the kernel runs on GPU 0. is_device_accessible does not establish that GPU 0 can access the allocation. Check view.device_id against the launch device, or verify peer access before launch. (nvidia.github.io)
The reason will be displayed to describe this comment to others. Learn more.
Major · Functional Correctness · Quick win
important: Handle missing header directories.
If either lookup returns None, ProgramOptions converts it to --include-path=None. Compilation then cannot find the missing headers. Check each result and tell users which header package to install before constructing the options. (nvidia.github.io)
Write eval starter script output with sys.stdout.write, use snake_case
names in the legacy bindings starter, and register the skills directory
in the SPDX check. Use PinnedMemoryResource in the skill example.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
⚠️ Outside diff range comments (1)
Major · important: Require a NumPy version that provides a writable DLPack view. · SKILL.md:85
skills/cuda-python/SKILL.md:85 Major · Functional Correctness · Quick win
important: Require a NumPy version that provides a writable DLPack view.
With NumPy 2.0, np.from_dlpack() returns a read-only view, so the assignment at Line 86 raises ValueError. The installation instructions do not require a newer NumPy version. Require a compatible version or use a writable host-memory representation. (numpy.org)
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Major · Stability & Availability · Quick win
important: Synchronize the host allocation before writing to it.
PinnedMemoryResource.allocate() is asynchronous. The host write at Line 86 can access the allocation before it completes, which has undefined behavior. Synchronize the stream before accessing h_x, or use LegacyPinnedMemoryResource. (raw.githubusercontent.com)
We should continue making our docs better for humans and agents. The skill mentions to see the docs in case of doubts, so thats ultimately the big source of truth but the evals do show some improvements (5-10%) with these directions. We should get a more detailed report about this from the nv-skills report.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cuda.bindingsEverything related to the cuda.bindings modulecuda.coreEverything related to the cuda.core modulecuda.pathfinderEverything related to the cuda.pathfinder moduledocumentationImprovements or additions to documentationP1Medium priority - Should do
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add skills/cuda-python/SKILL.md covering cuda.core, cuda.bindings and cuda.pathfinder, with 20 eval cases and their starter files.
Description
closes
Checklist