Skip to content

Add pickle/cloudpickle regression tests for cuda.core objects#1810

Merged
Andy-Jost merged 1 commit intoNVIDIA:mainfrom
Andy-Jost:add-pickle-regression-tests
Mar 23, 2026
Merged

Add pickle/cloudpickle regression tests for cuda.core objects#1810
Andy-Jost merged 1 commit intoNVIDIA:mainfrom
Andy-Jost:add-pickle-regression-tests

Conversation

@Andy-Jost
Copy link
Contributor

Summary

Adds parametrized pickle/cloudpickle roundtrip tests to test_object_protocols.py for Device, ObjectCode, IPCBufferDescriptor, and IPCEventDescriptor. These tests guard against the Cython @classmethod identity issue fixed in #1660 where cloudpickle fails with PicklingError: Can't pickle ... it's not the same object as ....

Changes

  • cuda_core/tests/test_object_protocols.py:
    • Added PICKLE_TYPES and PICKLE_MODULES parametrization lists
    • Added IPC sample fixtures (sample_ipc_buffer_descriptor, sample_ipc_event_descriptor) with proper skip guards via ipc_device
    • Added test_pickle_roundtrip covering both pickle and cloudpickle with importorskip for optional cloudpickle dependency

Test Coverage

  • Verified all 8 test variants pass on current main
  • Verified that reverting the @staticmethod fix (back to @classmethod) causes exactly 3 cloudpickle failures, confirming the tests catch the original bug

Closes #1671

Made with Cursor

Adds parametrized roundtrip tests covering both pickle and cloudpickle
for Device, ObjectCode, IPCBufferDescriptor, and IPCEventDescriptor.
These tests guard against the Cython @classmethod identity issue fixed
in NVIDIA#1660 (cloudpickle fails when __reduce__ references a @classmethod).

Closes NVIDIA#1671

Made-with: Cursor
@Andy-Jost Andy-Jost added this to the cuda.core v0.7.0 milestone Mar 23, 2026
@Andy-Jost Andy-Jost added bug Something isn't working P0 High priority - Must do! cuda.core Everything related to the cuda.core module labels Mar 23, 2026
@Andy-Jost Andy-Jost self-assigned this Mar 23, 2026
@Andy-Jost Andy-Jost requested review from leofang, mdboom, rparolin and rwgk and removed request for leofang, mdboom and rwgk March 23, 2026 20:17
@github-actions

This comment has been minimized.

# Fixtures - IPC samples (for pickle tests)
# =============================================================================

POOL_SIZE = 2097152
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice-to-have: a comment to explain why this value was chosen.

"sample_ipc_event_descriptor",
]

PICKLE_MODULES = ["pickle", "cloudpickle"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

git grep cloudpickle doesn't have any hits. Could we add cloudpickle to dependency-groups.test in cuda_core/pyproject.toml?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will follow up in #1811

@Andy-Jost Andy-Jost merged commit 653939e into NVIDIA:main Mar 23, 2026
92 checks passed
@Andy-Jost Andy-Jost deleted the add-pickle-regression-tests branch March 23, 2026 22:51
@github-actions
Copy link

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

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

Labels

bug Something isn't working cuda.core Everything related to the cuda.core module P0 High priority - Must do!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: numba-cuda errors related to ObjectCode pickling

2 participants