Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct test_segmented_reduce.py::test_segmented_reduce #4197

Closed
oleksandr-pavlyk opened this issue Mar 19, 2025 · 0 comments · Fixed by #4198
Closed

Correct test_segmented_reduce.py::test_segmented_reduce #4197

oleksandr-pavlyk opened this issue Mar 19, 2025 · 0 comments · Fixed by #4198

Comments

@oleksandr-pavlyk
Copy link
Contributor

The test is meant to create partition of input array into random-size segments, call segmented_reduce and verify against sequential calls to sum over segments.

The test does not correctly form offsets associated with such partition. It samples random sizes from multinomial distribution, but fails to scan over these sizes, hence producing a sequence which is not guaranteed to be non-decreasing.

The test should be modified to perform meaningful acceptance testing.

@github-project-automation github-project-automation bot moved this to Todo in CCCL Mar 19, 2025
oleksandr-pavlyk added a commit to oleksandr-pavlyk/cccl that referenced this issue Mar 19, 2025
… offsets

To resolve NVIDIAgh-4197, use `cupy.cumsum` to accumulate over random partition
sizes to form correct offsets sequence.

Add assertions to verify that `offsets` is a non-decreasing sequence, and
that its last element equals the size of the input array.

Perform the test for several plausible offset data types.
@cccl-authenticator-app cccl-authenticator-app bot moved this from Todo to In Review in CCCL Mar 19, 2025
@github-project-automation github-project-automation bot moved this from In Review to Done in CCCL Mar 24, 2025
caugonnet pushed a commit to caugonnet/cccl that referenced this issue Mar 25, 2025
* Fix logic in test_segmented_reduce, also test over different types of offsets

To resolve NVIDIAgh-4197, use `cupy.cumsum` to accumulate over random partition
sizes to form correct offsets sequence.

Add assertions to verify that `offsets` is a non-decreasing sequence, and
that its last element equals the size of the input array.

Perform the test for several plausible offset data types.

* Changes per PR review comments

1. Use `cupy.random` to draw random sample on GPU, rather than on CPU
   followed by a transfer
2. Use `cp.empty` to allocate output, rather than `cp.zeros`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant