Skip to content

coverage: add cuda.core tests for system device, checkpoint, memory, stream, green context, and tensor map - #2404

Merged
mdboom merged 6 commits into
NVIDIA:mainfrom
rluo8:test/expand-cuda-core-coverage
Jul 29, 2026
Merged

coverage: add cuda.core tests for system device, checkpoint, memory, stream, green context, and tensor map#2404
mdboom merged 6 commits into
NVIDIA:mainfrom
rluo8:test/expand-cuda-core-coverage

Conversation

@rluo8

@rluo8rluo8 commented Jul 22, 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 : 84.34% → ~85.6%, with system/_device.pyx crossing 85%. Largest gains in checkpoint.py, _stream.pyx, _memory/_memory_pool.pyx, _tensor_map.pyx, andsystem/_device.pyx.
Note that the coverage numbers are for cuda/core/ only, combined across the local systems Linux (A10), Windows (A10), and Linux (H200).

FileTests
graph/test_graph_definition.pyhost-callback node reconstruction via _create_from_driver through an embedded child graph
system/test_system_device.pytemperature / constructor-selector / affinity·topology·P2P argument validation (rejected before any NVML call)
test_checkpoint.pyTestCheckpointHelpers (host-only _check_timeout_ms / _make_restore_args / _as_cuuuid marshalling + validation) and TestCheckpointDriverDispatch (_call_driver result-code / missing-symbol translation via a dependency-injected boundary fake)
test_green_context.pyclosed-context handle/is_green/resources degradation, empty/wrong-type count split rejection, primary-context stream SM-resource path
test_launcher.pytest_launch_scalar_argument_subclass_fallback expanded to all ctypes scalar widths/signs + numpy, with kernel read-back asserting correct C-type marshalling (guards e.g. uint64 → uint32_t truncation)
test_memory.pymempool DeviceMemoryResource handle ownership, idempotent close, deallocate-frees-pointer (verified via used_mem_current drop, not just handle == 0), IPC-unsupported raise, _MemPoolAttributes non-instantiable
test_stream.py__cuda_stream__ protocol validation (malformed value / wrong length / bad version / deprecated attribute form), borrow-from-existing-Stream, from_handle flag/priority query, per-thread vs legacy default-stream env selection
test_tensor_map.pyTMA descriptor arg rejection branches — box_dim/enum via the public TensorMapDescriptorOptions(...) constructor, dtype and box_dim-required via the host-only marshalling helpers

…stream, green context, and tensor map
Signed-off-by: Rui Luo <ruluo@nvidia.com>
@rluo8rluo8 self-assigned this Jul 22, 2026
@github-actionsgithub-actionsBot added the cuda.core Everything related to the cuda.core module label Jul 22, 2026
@rluo8
rluo8 requested review from leofang and mdboomJuly 22, 2026 08:09
@github-actions

This comment has been minimized.

@mdboom

Copy link
Copy Markdown
Contributor

The system tests look good to me. This should probably get reviewed by specialists in other areas of the code as well.

@rluo8

Copy link
Copy Markdown
ContributorAuthor

Thanks @mdboom! @leofang could you please help suggest the right experts to review the other areas (checkpoint, memory, stream, green context, and tensor map)?

@Andy-Jost

Andy-Jost commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

I was able to review everything except the tensor map changes. Looks good to me.

Update: given how straightforward the tensor map change appear, I'm comfortable approving.

@Andy-JostAndy-Jost added this to the cuda.core next milestone Jul 23, 2026

@Andy-JostAndy-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.

LGTM!

@Andy-JostAndy-Jost added the P1 Medium priority - Should do label Jul 23, 2026
@mdboom
mdboom enabled auto-merge (squash) July 24, 2026 15:42
@mdboom
mdboom merged commit 55a2c88 into NVIDIA:mainJul 29, 2026
103 checks passed
@github-actions

Copy link
Copy Markdown
Doc Preview CI
Preview removed because the pull request was closed or merged.

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

Labels

cuda.coreEverything related to the cuda.core moduleP1Medium priority - Should do

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@rluo8@mdboom@Andy-Jost