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
coverage: expand tests coverage for API validation and resource lifecycles - #3222
Add test functions covering cuda.core API validation, resource lifetimes, and recovery after rejected operations. This PR contains test changes only.
Changes
Devices, memory, and streams: cover invalid device ordinals, thread-local context initialization, memory-resource assignment, buffer subclasses as kernel arguments, and borrowed-stream ownership.
Graphs: cover cyclic graphs, unsupported host callbacks for device launch, mixed-context nodes, and unused conditional handles. Verify that repaired graphs can be instantiated and executed after a rejected operation.
Compilation and modules: cover invalid object-code payloads, cleanup after externally removing a debug source file, and compilation with automatic PCH enabled while checking creation status and kernel results.
Tensor maps and textures: cover pointer alignment, hardware/context restrictions, dtype encoding with padded-row strides and exporter lifetimes, 1D/3D mipmap round trips, surface/texture lifecycles, and border-color sampling on the GPU.
Validation
Ran the tests on Linux/H800 and Windows/A100 using CUDA 13.4 wheels. All applicable PR test cases passed; unsupported hardware and platform combinations were skipped.
Revalidated the two tensor-map API tests on Linux/H800 and B10 (RTX PRO 4500 Blackwell): 15 parameterized cases passed on each. They skip on Windows/A100, which lacks TMA.
Validated the PCH test locally on Windows/Ada with NVRTC 12.9.86 and 13.4 runtimes, reusing CUDA 13.4 cuda-python wheels; normal and changed-diagnostic runs passed, with skip and incorrect-output probes behaving as expected.
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.
Expanded coverage for CUDA graph validation and recovery, device selection, context handling, and external stream interoperability.
Added checks for memory-resource assignment, kernel launches with managed and virtual memory, and allocation failures.
Added coverage for program cleanup and precompiled-header reuse, module errors, tensor-map alignment and ownership, and texture and surface operations.
Added checks for green-context resource validation and DLPack exports of extended-precision data types.
This PR adds CUDA core regression tests for graph validation, device and stream behavior, memory allocation, program and module lifecycle, tensor maps, texture and surface objects, and versioned DLPack export.
Tests rejection of cyclic graphs, host callbacks in device-launch graphs, nodes from different contexts, and unassociated graph conditions. Cycle and mixed-context tests also verify that repaired graphs can launch.
Context and Stream Handling
Layer / File(s)
Summary
Device initialization and memory resources cuda_core/tests/test_device.py
Tests invalid device ordinals, per-thread initialization, and memory-resource assignment and use.
Tests versioned DLPack export errors for unsupported extended-precision item sizes and checks exported view metadata.
Possibly related issues
NVIDIA/cuda-python#2910: The PR tests rejection of invalid addr_align values and verifies that another resource remains usable. It does not change the validation logic described by the issue.
Priority: Low
Change: Other
Merge Risk: Low · previous review 21643
Some supported CUDA or NVRTC versions may fail these tests solely because diagnostic wording changes; replace exact message checks with contractual signals before merging.
Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
suggestion: Assert exception types without matching message text.
These tests depend on error-message substrings. A wording change would fail the tests even if the API behavior remains correct. Remove match= unless the message is part of a documented contract. As per coding guidelines, “Avoid asserting on ... error message substrings that are not part of the contract.” (raw.githubusercontent.com)
A wording-only change to either exception will fail these tests. Keep the exception-type and context checks, but remove both match= arguments. The public create_context documentation does not specify error-message text. (nvidia.github.io)
As per coding guidelines: “Avoid asserting on ... error message substrings that are not part of the contract.”
suggestion: Replace pytest.importorskip("ml_dtypes") with a direct import. The test-cu12 and test-cu13 groups include ml-dtypes, so skipping here hides a broken test environment.
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
Exercise validation failures, resource ownership, and recovery paths using real CUDA resources. Verify tensor-map dtype encoding and exporter lifetime without requiring runtime kernel compilation.
Signed-off-by: Rui Luo <ruluo@nvidia.com>
suggestion: Do not assert on repr(descriptor) substrings. The test checks ", rank=2," and f"dtype={data_type.name},". The repr format is not part of the TensorMapDescriptor contract. A formatting change in _repr_info or __repr__ breaks the test while the descriptor stays correct. Assert on a public property of the descriptor if one exposes rank and data type. Otherwise keep only the isinstance and device assertions.
As per coding guidelines: "Avoid asserting on internal call counts, private helper invocation order, or error message substrings that are not part of the contract."
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
suggestion: Drop the match= message substrings from both pytest.raises calls. Assert only the exception type.
Line 875 matches "requires an active CUDA context" and "was created in a different CUDA context". Line 911 matches "Compute capability 9\.0 or higher is required". The contract defines the exception types (RuntimeError, CUDAError) and the ownership state after the call. It does not define the message text. A reword of these messages would break the tests without any behavior change. The ownership assertions on lines 879-880 already show that the rejected call had no effect.
As per coding guidelines: "Avoid asserting on internal call counts, private helper invocation order, or error message substrings that are not part of the contract."
Reviewing files that changed from the base of the PR and between d47ef9f and 2a570f2.
Files selected for processing: 4
cuda_core/tests/test_device.py
cuda_core/tests/test_launcher.py
cuda_core/tests/test_program.py
cuda_core/tests/test_tensor_map.py
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
Reviewing files that changed from the base of the PR and between 2a570f2 and 216430a.
Files selected for processing: 1
cuda_core/tests/test_program.py
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.
Thanks, this is useful coverage: 26 tests, no library change, each with one marker, no memory pools, and the new tests pass or skip for a stated reason on the H100, V100, L4, T4 x2, RTX 4090 WDDM, and WSL rows. Most of them check real behavior on the device or in the driver (the borrowed stream that outlives close(), kernel-argument marshalling for buffer subclasses, a descriptor keeping its source alive across replace_address, border-color sampling, the foreign-context surface rejection), so they would catch a regression. Approving.
One small point you may want to take: test_nvrtc_automatic_pch_preserves_compiled_kernel skips when NVRTC reports NOT_ATTEMPTED, so if cuda.core ever stopped passing --pch the test would skip rather than fail. An assert "--pch" in flags for ProgramOptions(pch=True) in the as_bytes option test would catch that without a GPU.
The metadata check is red only for the missing milestone.
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.coreEverything related to the cuda.core module
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.
Description
Add test functions covering cuda.core API validation, resource lifetimes, and recovery after rejected operations. This PR contains test changes only.
Changes
Validation