Skip to content

coverage: add cuda.core tests for graph, IPC, launcher, program, and DLPack - #2728

Open
rluo8 wants to merge 6 commits into
NVIDIA:mainfrom
rluo8:test/expand-cuda-core-coverage
Open

coverage: add cuda.core tests for graph, IPC, launcher, program, and DLPack#2728
rluo8 wants to merge 6 commits into
NVIDIA:mainfrom
rluo8:test/expand-cuda-core-coverage

Conversation

@rluo8

@rluo8 rluo8 commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Description

Adds focused unit tests across cuda.core, targeting input-validation branches, error paths, and object-lifecycle behavior that were previously uncovered. All tests are real-path: host-only tests exercise pure helpers / argument validation directly, and GPU-required tests use the existing fixtures and skips. No production changes.

Measured effect on cuda/core/ line coverage: about +1.65%, +208 lines. Largest gains in _program.pyx, graph/_subclasses.pyx, _memory/_ipc.pyx, _memoryview.pyx, _kernel_arg_handler.pyx, and graph/_graph_builder.pyx.
Note that the coverage numbers are for cuda/core/ only, combined across local systems with Linux, Windows, H800, B10, and B100.

File Tests
graph/test_graph_builder.py join type check; __cuda_stream__ after close; capture guards (end_building / debug_dot_print / callback / create_condition / embed / if_then); factory-only GraphBuilder/Graph; close() ends an active capture
graph/test_graph_definition.py HOST AllocNode reconstructs memory_type from the driver via a pred walk (CUDA_ERROR_NOT_SUPPORTED skip)
graph/test_graph_definition_lifetime.py pred-chain _create_from_driver for memcpy / event record / event wait / free
graph/test_graph_node_update.py memset/memcpy owner + no-op + 2D geometry updates; factory-only ExecutableGraphNode; executable-node repr; clustered/cooperative update reject; ctypes host-callback repr
memory_ipc/test_errors.py factory-only IPC types; raw-fd from_allocation_handle; ForkingPickler fd dup; registry dedup of repeated imports (Linux)
test_launcher.py numpy scalar-subclass prepare_numpy_arg fallback (kernel readback); CUgraphConditionalHandle packed as uint64
test_memory.py Buffer() forbidden; context-manager close; abstract MemoryResource stubs; copy_to() without a memory resource
test_optional_dependency_imports.py NVVM import rejects cuda-bindings < 12.9 and caches the failure
test_program.py nested define_macro error; each NVVM-unsupported option; NVRTC as_bytes sequence flags; debug temp-write fallback; use_libdevice resolves __nv_sin
test_utils.py CAI-only proxy .view(); view(dtype=) itemsize mismatch
test_utils_dlpack.py CPU array-interface export; Buffer re-view owner reuse; CUDA stream=None; versioned readonly; malformed dtype; C-exchange API NULL/scalar/device-accessible cases

@github-actions github-actions Bot added the cuda.core Everything related to the cuda.core module label Aug 28, 2026
@rluo8
rluo8 requested review from Andy-Jost and mdboom August 28, 2026 09:23
@rluo8
rluo8 force-pushed the test/expand-cuda-core-coverage branch from 1dab946 to 21f1913 Compare August 28, 2026 09:27
@rluo8 rluo8 self-assigned this Aug 28, 2026
@github-actions

Copy link
Copy Markdown

@mdboom

mdboom commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Looks mostly fine to me, but I think @Andy-Jost may want to review the graph stuff.

@Andy-Jost Andy-Jost added P1 Medium priority - Should do test Improvements or additions to tests labels Sep 3, 2026
@Andy-Jost Andy-Jost added this to the cuda.core 1.3.0 milestone Sep 3, 2026
src = np.arange(6, dtype=np.int32)
view = StridedMemoryView.from_array_interface(src)
assert view.is_device_accessible is False
assert view.device_id == init_cuda.device_id

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This asserts the current-device value, but the StridedMemoryView docstring says device_id "is -1 for CPU tensors", and the DLPack import path already returns -1 for kDLCPU. _smv_from_array_interface is the outlier: it sets buf.device_id = handle_return(driver.cuCtxGetDevice()).

Recommend fixing the source in this PR with a one-liner (buf.device_id = -1 in _smv_from_array_interface) and changing this assertion to assert view.device_id == -1. That way the new test pins the documented behavior rather than the inconsistency.

@pytest.mark.agent_authored(model="gpt-5.6-sol")
def test_nvvm_options_reject_each_unsupported_flag(kwargs):
"""Every NVVM-unsupported option is rejected, named, and reported alone."""
# This table mirrors _prepare_nvvm_options_impl's rejection list one-for-one.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

use_bundled_headers landed in _prepare_nvvm_options_impl's rejection list yesterday (#2753), so the table is one short of one-for-one. Recommend adding {"use_bundled_headers": True} to the parametrize list (after include_path, matching the source order) so the comment stays true.

@Andy-Jost Andy-Jost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good overall. I just found two issues that need to be corrected.

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 P1 Medium priority - Should do test Improvements or additions to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants