Skip to content

test(cuda.core): expand API validation and lifecycle coverage - #3535

Open
rluo8 wants to merge 3 commits into
NVIDIA:mainfrom
rluo8:test/core-coverage-20261120
Open

rluo8 wants to merge 3 commits into
NVIDIA:mainfrom
rluo8:test/core-coverage-20261120

Conversation

@rluo8

@rluo8 rluo8 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Description

Expand cuda.core test coverage for API validation, failure recovery, interoperability, and resource lifecycles.

Changes

  • Graphs and launches: test invalid adjacency batches without partial edge updates, adjacency self-subtraction, launch-priority validation, and preservation of captured kernel priority with GPU readback.
  • Memory and IPC: cover null VMM deallocation, empty-buffer IPC with explicit deallocation streams, resource representations, peer-access set operations, imported event flags, and buffer deserialization without a current context.
  • Streams and callbacks: verify that streams remain usable after rejecting invalid events and that empty ctypes callback payloads still invoke the callback.
  • Array interoperability: cover class-based exporters, PyTorch CPU/CUDA factory entry points, strided storage sharing, exporter ownership, producer-to-consumer ordering, and unsupported dtype handling.
  • Compatibility and recovery: strengthen CUDA 12 SM-resource option rejection and tensor-map rank validation; cover retrying a missing object-code file, import diagnostics, and cache accounting when files are replaced or disappear.

Validation

The PR contains 24 new test functions and strengthens 7 existing functions, totaling 50 parameterized test items.

Configuration Passed Skipped
Linux / CUDA 13 47 3
Windows / CUDA 13 41 9
Windows / CUDA 12.9 38 12

Signed-off-by: Rui Luo <ruluo@nvidia.com>
@github-actions github-actions Bot added the cuda.core Everything related to the cuda.core module label Nov 23, 2026
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Tests
    • Expanded coverage for CUDA graph adjacency updates, IPC event and memory sharing, and virtual memory behavior.
    • Added checks for stream recording, launch priorities, host callbacks, and recovery from import and resource-handling errors.
    • Improved validation coverage for tensor-view interoperability, program-cache edge cases, peer access, green-context options, and tensor-map rank errors.

The pull request adds regression tests across graph operations, CUDA IPC, memory and launch APIs, package imports, program-cache races, and tensor interoperability. It also adds child-process communication helpers used by IPC tests.

Changes: Graph and Execution

Layer / File(s) Summary
Graph adjacency updates
cuda_core/tests/graph/test_graph_definition_mutation.py
Tests cover invalid batch updates for predecessor and successor proxies, valid updates after rejection, and self-subtraction while preserving unrelated edges and nodes.
Launch priority validation and graph capture
cuda_core/tests/test_launcher.py
Tests cover out-of-range priorities, missing current context, and priority preservation on a captured kernel node that executes successfully.
Host callbacks and stream recording
cuda_core/tests/test_host_launch.py, cuda_core/tests/test_stream.py
Tests cover an empty callback payload and confirm that a valid event can be recorded after stream.record() rejects an invalid argument.

IPC Resource Exchange

Layer / File(s) Summary
Child-process transport and event IPC
cuda_core/tests/helpers/child_processes.py, cuda_core/tests/memory_ipc/test_event_ipc.py
Timed receive and exporter helpers support tests that import IPC event descriptors, check event properties and synchronization, and verify closure signaling.
Serialized buffer exchange
cuda_core/tests/memory_ipc/test_serialize.py
The test exchanges an IPC memory resource and pickled buffer, then checks context creation, shared contents, context restoration, and the child-process update handshake.
Empty VMM buffer round trip
cuda_core/tests/memory_ipc/test_vmm_ipc.py
The test covers default and created streams, cleanup through ExitStack, and imported-alias close behavior during stream capture.

Memory and SM Resources

Layer / File(s) Summary
SM resource split validation
cuda_core/tests/test_green_context.py
Tests check that unsupported structured split options fail without changing the SM count, then check a discovery split.
VMM and peer-access behavior
cuda_core/tests/test_memory.py, cuda_core/tests/test_memory_peer_access.py
Tests cover null-pointer deallocation, VMM device reporting, peer removal by Device, and peer-access intersection and subtraction operations.

Package Loading and Program Cache

Layer / File(s) Summary
Package import error paths
cuda_core/tests/test_bindings_floor.py
Subprocess tests distinguish incomplete package layouts and missing direct bindings from missing nested dependencies.
Cubin load retry
cuda_core/tests/test_module.py
The test checks that lazy loading succeeds after the missing cubin file is restored.
Program-cache errors and race handling
cuda_core/tests/test_program_cache.py
Tests cover non-retryable filesystem errors, concurrent replacement and deletion during eviction, and file removal during startup size accounting.

Tensor Maps and Interoperability

Layer / File(s) Summary
Tensor-map rank validation
cuda_core/tests/test_tensor_map.py
Tests cover lower- and upper-corner rank mismatches and im2col-wide rank validation.
Exporter-backed array views
cuda_core/tests/test_utils.py, cuda_core/tests/test_utils_torch.py
Tests cover exporter identity, tensor metadata, owner retention, shared storage, and mutations through NumPy, Array Interface, and DLPack paths.
PyTorch stream ordering and dtype handling
cuda_core/tests/test_utils_torch.py
Tests check producer-to-consumer stream dependencies and unsupported float8 and complex-half dtype errors.

Suggested reviewers: cpcloud, andy-jost

Change: Other

Merge Risk: Minimal · up to 624c6

This change adds regression tests and test helpers without altering production behavior. The earlier concern about message-text coupling in the stream test has been fixed, so no merge-blocking risk remains.

Security architecture risk: Minimal · up to 624c6

The PR expands regression coverage for existing CUDA Core behavior without changing production interfaces, access controls, or resource ownership.

Finishing Touches

Fix failing CI checks

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 27a7571 and 624c6be.

Files selected for processing: 3

  • cuda_core/tests/test_bindings_floor.py
  • cuda_core/tests/test_program_cache.py
  • cuda_core/tests/test_stream.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.

@rluo8 rluo8 self-assigned this Nov 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Nitpick comments: 4

cuda_core/tests/test_stream.py: 1

71-71: Trivial · Maintainability & Code Quality · Quick win

suggestion: Remove the diagnostic-text constraint.

The match argument makes this test fail if the diagnostic changes while TypeError and stream recovery remain correct. Use pytest.raises(TypeError) and retain the recovery assertions.

As per coding guidelines, “Avoid asserting on ... error message substrings that are not part of the contract.”

Source: Coding guidelines

cuda_core/tests/test_bindings_floor.py: 1

496-496: Trivial · Maintainability & Code Quality · Quick win

suggestion: Remove the exact import-probe assertions.

Line 496 fixes the metadata lookup order. Line 541 fixes the import attempt count. Both assertions can reject a refactor that preserves the required import errors. Keep the existing exception, cause, dependency-name and diagnostic assertions instead.

As per coding guidelines, “Avoid asserting on internal call counts, private helper invocation order.”

Also applies to: 541-541

Source: Coding guidelines

cuda_core/tests/test_program_cache.py: 2

1755-1755: Trivial · Maintainability & Code Quality · Quick win

suggestion: Make the first snapshot entry disappear.

os.scandir does not guarantee entry order. If a appears last, replacing continue with break in the snapshot's FileNotFoundError handler would still leave the tracker at 200 bytes and pass this test. Control the scan order so the test always checks that eviction counts the entries after the disappearance. (docs.python.org)


3085-3086: Trivial · Maintainability & Code Quality · Quick win

suggestion: Count a surviving temp file after the disappearing file.

With one temp file, _sum_tmp_sizes can stop at FileNotFoundError instead of continuing and still return the expected zero temp bytes. Yield a second temp file after inflight and include its bytes in the expected totals. The committed survivor cannot detect this regression because startup accounts for it before scanning temp files. (raw.githubusercontent.com)

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between edf1b31 and 27a7571.

Files selected for processing: 17

  • cuda_core/tests/graph/test_graph_definition_mutation.py
  • cuda_core/tests/helpers/child_processes.py
  • cuda_core/tests/memory_ipc/test_event_ipc.py
  • cuda_core/tests/memory_ipc/test_serialize.py
  • cuda_core/tests/memory_ipc/test_vmm_ipc.py
  • cuda_core/tests/test_bindings_floor.py
  • cuda_core/tests/test_green_context.py
  • cuda_core/tests/test_host_launch.py
  • cuda_core/tests/test_launcher.py
  • cuda_core/tests/test_memory.py
  • cuda_core/tests/test_memory_peer_access.py
  • cuda_core/tests/test_module.py
  • cuda_core/tests/test_program_cache.py
  • cuda_core/tests/test_stream.py
  • cuda_core/tests/test_tensor_map.py
  • cuda_core/tests/test_utils.py
  • cuda_core/tests/test_utils_torch.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.

Comment thread cuda_core/tests/test_program_cache.py Resolved
Comment thread cuda_core/tests/test_program_cache.py Resolved
Signed-off-by: Rui Luo <ruluo@nvidia.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda.core Everything related to the cuda.core module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant