-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add SUM_OVERFLOW in sort groupby #22832
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
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
ab0cb1a
Support SUM_WITH_OVERFLOW in sort-based groupby
PointKernel 63e67a9
Merge remote-tracking branch 'upstream/main' into enable-sum-with-ove…
PointKernel e287993
Centralize SUM_WITH_OVERFLOW supported-types check
PointKernel 5570dd5
Key SUM_WITH_OVERFLOW group reduction off group_labels
PointKernel 015e0ad
Merge remote-tracking branch 'upstream/main' into enable-sum-with-ove…
PointKernel b7ae891
Merge branch 'main' into enable-sum-with-overflow-sort-groupby
PointKernel 81b2953
Remove CUDF_EXPORT from sum_with_overflow detail header
PointKernel e68c31f
Merge remote-tracking branch 'upstream/main' into enable-sum-with-ove…
PointKernel 8703b32
Merge commit 'b7ae891256e9d4c65701b9d91e5145dd0dadc475' into enable-s…
PointKernel 67a367f
Remove CUDF_EXPORT from sum_with_overflow detail header
PointKernel 1637773
Merge remote-tracking branch 'upstream/main' into enable-sum-with-ove…
PointKernel 4ee482f
Replace sort-groupby SUM_WITH_OVERFLOW throws test with positive tests
PointKernel 0398d4e
Merge remote-tracking branch 'upstream/enable-sum-with-overflow-sort-…
PointKernel 02f817e
Merge branch 'main' into enable-sum-with-overflow-sort-groupby
vyasr c0e101b
Fix copyright headers to pass style checks
vyasr b2ca465
Merge branch 'main' into enable-sum-with-overflow-sort-groupby
vyasr 53ae9b4
Force sort path in sort groupby SUM_WITH_OVERFLOW tests via a sort-on…
PointKernel ca9dca9
Convert is_sum_with_overflow_supported into a concept
PointKernel de1cd8a
Merge remote-tracking branch 'upstream/main' into enable-sum-with-ove…
PointKernel 1ffa685
Add SUM_OVERFLOW and use sum_overflow naming for new code
PointKernel 37d8ffd
Merge remote-tracking branch 'upstream/main' into enable-sum-with-ove…
PointKernel 10344e8
Merge remote-tracking branch 'upstream/enable-sum-with-overflow-sort-…
PointKernel f5ea347
Keep null_aware naming and use make_counting_transform_iterator
PointKernel bc36169
Apply pre-commit formatting
PointKernel 30f1e95
Merge branch 'main' into enable-sum-with-overflow-sort-groupby
PointKernel 202c8ab
Merge branch 'main' into enable-sum-with-overflow-sort-groupby
PointKernel d3492a2
Merge branch 'main' into enable-sum-with-overflow-sort-groupby
PointKernel 8f4f889
Merge branch 'main' into enable-sum-with-overflow-sort-groupby
PointKernel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| #pragma once | ||
|
|
||
| #include <cudf/column/column_device_view.cuh> | ||
| #include <cudf/types.hpp> | ||
|
|
||
| #include <cuda/numeric> | ||
|
|
||
| namespace cudf { | ||
| namespace reduction::detail { | ||
|
|
||
| /** | ||
| * @brief Running accumulator for a sum that detects signed-integer overflow. | ||
| * | ||
| * `wraps` is the net number of times the running sum has stepped outside [MIN, MAX]. | ||
| * A final `wraps == 0` means the true sum fits in `DeviceType`, i.e. no overflow. | ||
| */ | ||
| template <typename DeviceType> | ||
| struct sum_overflow_result { | ||
| DeviceType sum; | ||
| cudf::size_type wraps; | ||
|
|
||
| CUDF_HOST_DEVICE sum_overflow_result() : sum{0}, wraps{0} {} | ||
| CUDF_HOST_DEVICE sum_overflow_result(DeviceType s, cudf::size_type w) : sum{s}, wraps{w} {} | ||
|
PointKernel marked this conversation as resolved.
|
||
| }; | ||
|
|
||
| /// @brief Associative combine: wrap the sums and track the net carry direction. | ||
| template <typename DeviceType> | ||
| struct overflow_sum_op { | ||
| __device__ sum_overflow_result<DeviceType> operator()( | ||
| sum_overflow_result<DeviceType> const& lhs, sum_overflow_result<DeviceType> const& rhs) const | ||
| { | ||
| auto const r = cuda::add_overflow<DeviceType>(lhs.sum, rhs.sum); | ||
|
PointKernel marked this conversation as resolved.
|
||
| auto const carry = r.overflow ? (rhs.sum > DeviceType{0} ? 1 : -1) : 0; | ||
| return sum_overflow_result<DeviceType>{r.value, lhs.wraps + rhs.wraps + carry}; | ||
| } | ||
| }; | ||
|
|
||
| /// @brief Maps a value to a zero-wrap accumulator. | ||
| template <typename DeviceType> | ||
| struct to_sum_overflow { | ||
| __device__ sum_overflow_result<DeviceType> operator()(DeviceType value) const | ||
| { | ||
| return sum_overflow_result<DeviceType>{value, 0}; | ||
| } | ||
| }; | ||
|
|
||
| /// @brief Maps a row index to an accumulator, treating nulls as a zero contribution. | ||
| template <typename DeviceType> | ||
| struct null_aware_to_sum_overflow { | ||
| cudf::column_device_view dcol; | ||
|
|
||
| CUDF_HOST_DEVICE null_aware_to_sum_overflow(cudf::column_device_view const& d) : dcol{d} {} | ||
|
|
||
| __device__ sum_overflow_result<DeviceType> operator()(cudf::size_type idx) const | ||
| { | ||
| return dcol.is_valid(idx) ? sum_overflow_result<DeviceType>{dcol.element<DeviceType>(idx), 0} | ||
| : sum_overflow_result<DeviceType>{DeviceType{0}, 0}; | ||
| } | ||
| }; | ||
|
|
||
| } // namespace reduction::detail | ||
| } // namespace cudf | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.