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

Implement stable version of cudf::sort #15066

Merged
merged 15 commits into from
Feb 29, 2024

Conversation

wence-
Copy link
Contributor

@wence- wence- commented Feb 15, 2024

Description

Adds an implementation of cudf::stable_sort. While here, cleans up a few small issues around stream-passing and memory resource usage in the detail APIs of some of the sort functions.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@wence- wence- requested a review from a team as a code owner February 15, 2024 10:50
@github-actions github-actions bot added the libcudf Affects libcudf (C++/CUDA) code. label Feb 15, 2024
@wence- wence- added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change libcudf Affects libcudf (C++/CUDA) code. and removed libcudf Affects libcudf (C++/CUDA) code. labels Feb 15, 2024
@wence-
Copy link
Contributor Author

wence- commented Feb 15, 2024

I suppose I should add some tests. I can write ones that check that the result is correct, but is there any way to check that the non-stable sort would not have produced that result?

@wence- wence- changed the title Implement stable version of cudf::sort` Implement stable version of cudf::sort Feb 15, 2024
@wence-
Copy link
Contributor Author

wence- commented Feb 15, 2024

A single round of the cudf-python tests failed due to not raising pandas warnings where we expect to. But I would have thought this should also happen on different CTK versions, so no idea what is going on.

@davidwendt
Copy link
Contributor

I suppose I should add some tests. I can write ones that check that the result is correct, but is there any way to check that the non-stable sort would not have produced that result?

Although you cannot really verify the results are stable, tests are helpful in case this diverges in the future and we want to make sure it doesn't just fail sorting in general.

cpp/include/cudf/detail/sorting.hpp Outdated Show resolved Hide resolved
cpp/src/sort/stable_sort.cu Outdated Show resolved Hide resolved
@wence- wence- force-pushed the wence/fea/15065 branch 2 times, most recently from 3709f57 to 8eee62c Compare February 26, 2024 15:44
cpp/src/sort/sort.cu Outdated Show resolved Hide resolved
@wence- wence- force-pushed the wence/fea/15065 branch 3 times, most recently from c136426 to 809cca1 Compare February 26, 2024 17:34
@wence-
Copy link
Contributor Author

wence- commented Feb 27, 2024

Thanks @davidwendt, I think this is ready for another look when you have the time.

cpp/tests/sort/stable_sort_tests.cpp Show resolved Hide resolved
cpp/tests/sort/stable_sort_tests.cpp Show resolved Hide resolved
cpp/tests/sort/stable_sort_tests.cpp Show resolved Hide resolved
cpp/tests/sort/stable_sort_tests.cpp Show resolved Hide resolved
cpp/src/sort/segmented_sort_impl.cuh Show resolved Hide resolved
cpp/src/sort/segmented_sort_impl.cuh Show resolved Hide resolved
cpp/src/sort/sort.cu Show resolved Hide resolved
@wence-
Copy link
Contributor Author

wence- commented Feb 27, 2024

Although you cannot really verify the results are stable, tests are helpful in case this diverges in the future and we want to make sure it doesn't just fail sorting in general.

Added tests, and fixed a two-year-old bug that meant that we weren't testing stable_sort_by_key in a bunch of the stable_sort tests.

Copy link
Contributor

@davidwendt davidwendt left a comment

Choose a reason for hiding this comment

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

This looks great. Thanks for fixing the tests too.

cpp/src/sort/common_sort_impl.cuh Outdated Show resolved Hide resolved
cpp/tests/sort/stable_sort_tests.cpp Show resolved Hide resolved
In the stable sort case, we do have guarantees on the order of the
resulting table, so additionally remove the misleading comments that
were carried over from when the tests were of unstable sorting.
Previously we were testing sort_by_key.
Additionally add tests of single column stable sorts which exercise
fast-path code.
Copy link
Contributor

@davidwendt davidwendt left a comment

Choose a reason for hiding this comment

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

I'm good with the names of the enums and the is_usable() as well.

cpp/src/sort/common_sort_impl.cuh Outdated Show resolved Hide resolved
@wence-
Copy link
Contributor Author

wence- commented Feb 28, 2024

/merge

@rapids-bot rapids-bot bot merged commit 50630b2 into rapidsai:branch-24.04 Feb 29, 2024
76 checks passed
@wence- wence- deleted the wence/fea/15065 branch February 29, 2024 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improvement / enhancement to an existing function libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEA] Implement cudf::stable_sort
3 participants