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

Optionally nullify out-of-bounds indices in segmented_gather(). #9318

Merged
merged 5 commits into from
Sep 30, 2021

Conversation

mythrocks
Copy link
Contributor

The behaviour of cudf::lists::segmented_gather() is currently undefined for any
index value i that falls outside the range [-n, n), where n is the number of
elements in the list row.

This commit adds support to explicitly specify an out_of_bounds_policy, like in
cudf::gather(). The erstwhile behaviour is retained when the bounds policy is set
to DONT_CHECK. If the bounds policy is specified as NULLIFY, then for any
index falling outside the range [-n, n), the list element is set to null.

E.g.

auto source_column = [{"a", "b", "c", "d"}, {"1", "2", "3", "4"}, {"x", "y", "z"}];
auto gather_map    = [{0, -1, 4, -5}, {1, 3, 5}, {}];
auto result = segmented_gather(source_column, gather_map, NULLIFY);
result == [{"a", "d", null, null}, {"2", "4", null}, {}];

The behaviour of `cudf::lists::segmented_gather()` is currently undefined for any
index value `i` that falls outside the range `[-n, n)`, where `n` is the number of
elements in the list row.

This commit adds support to explicitly specify an `out_of_bounds_policy`, like in
`cudf::gather()`. The erstwhile behaviour is retained when the bounds policy is set
to `DONT_CHECK`. If the bounds policy is specified as `NULLIFY`, then for any
index falling outside the range `[-n, n)`, the list element is set to `null`.

E.g.
```c++
auto source_column = [{"a", "b", "c", "d"}, {"1", "2", "3", "4"}, {"x", "y", "z"}];
auto gather_map    = [{0, -1, 4, -5}, {1, 3, 5}, {}];
auto result = segmented_gather(source_column, gather_map, NULLIFY);
result == [{"a", "d", null, null}, {"2", "4", null}, {}];
```
@mythrocks mythrocks requested a review from a team as a code owner September 28, 2021 07:57
@mythrocks mythrocks self-assigned this Sep 28, 2021
@github-actions github-actions bot added the libcudf Affects libcudf (C++/CUDA) code. label Sep 28, 2021
@mythrocks mythrocks added 3 - Ready for Review Ready for review by team breaking Breaking change feature request New feature or request and removed libcudf Affects libcudf (C++/CUDA) code. labels Sep 28, 2021
@codecov
Copy link

codecov bot commented Sep 28, 2021

Codecov Report

❗ No coverage uploaded for pull request base (branch-21.12@eab2486). Click here to learn what that means.
The diff coverage is n/a.

❗ Current head 4e3fc11 differs from pull request most recent head 38680d0. Consider uploading reports for the commit 38680d0 to get more accurate results
Impacted file tree graph

@@               Coverage Diff               @@
##             branch-21.12    #9318   +/-   ##
===============================================
  Coverage                ?   10.77%           
===============================================
  Files                   ?      116           
  Lines                   ?    19360           
  Branches                ?        0           
===============================================
  Hits                    ?     2087           
  Misses                  ?    17273           
  Partials                ?        0           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eab2486...38680d0. Read the comment docs.

@mythrocks
Copy link
Contributor Author

I'll investigate the Java failure shortly. I'm so glad the JNI builds are now integrated into CI.

@mythrocks
Copy link
Contributor Author

I'll investigate the Java failure shortly.

This is baffling. Here are the failing JNI tests, as per CI logs:

Test Result (5 failures / +5)
ai.rapids.cudf.TableTest.testPartition
ai.rapids.cudf.nvcomp.NvcompTest.testBatchedLZ4CompressRoundTrip
ai.rapids.cudf.nvcomp.NvcompTest.testBatchedLZ4RoundTripAsync
ai.rapids.cudf.nvcomp.NvcompTest.testLZ4RoundTripAsync
ai.rapids.cudf.nvcomp.NvcompTest.testLZ4RoundTripSync

I cannot reproduce the failures locally:

✗ mvn test -Dtest=TableTest,NvcompTest
...
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running ai.rapids.cudf.nvcomp.NvcompTest
[INFO] Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.537 s - in ai.rapids.cudf.nvcomp.NvcompTest
[INFO] Running ai.rapids.cudf.TableTest
[INFO] Tests run: 222, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.859 s - in ai.rapids.cudf.TableTest
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 228, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  8.291 s
[INFO] Finished at: 2021-09-28T14:14:51-07:00
[INFO] ------------------------------------------------------------------------

I'll kick the tests off again, after rectifying the modulo calculation.

Copy link
Contributor

@codereport codereport left a comment

Choose a reason for hiding this comment

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

lgtm

Also, corrected test cases to accommodate.
@github-actions github-actions bot added the libcudf Affects libcudf (C++/CUDA) code. label Sep 28, 2021
@mythrocks
Copy link
Contributor Author

Rerun tests

@codereport
Copy link
Contributor

I'll investigate the Java failure shortly.

This is baffling. Here are the failing JNI tests, as per CI logs:

Test Result (5 failures / +5)
ai.rapids.cudf.TableTest.testPartition
ai.rapids.cudf.nvcomp.NvcompTest.testBatchedLZ4CompressRoundTrip
ai.rapids.cudf.nvcomp.NvcompTest.testBatchedLZ4RoundTripAsync
ai.rapids.cudf.nvcomp.NvcompTest.testLZ4RoundTripAsync
ai.rapids.cudf.nvcomp.NvcompTest.testLZ4RoundTripSync

I cannot reproduce the failures locally:

✗ mvn test -Dtest=TableTest,NvcompTest
...
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running ai.rapids.cudf.nvcomp.NvcompTest
[INFO] Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.537 s - in ai.rapids.cudf.nvcomp.NvcompTest
[INFO] Running ai.rapids.cudf.TableTest
[INFO] Tests run: 222, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.859 s - in ai.rapids.cudf.TableTest
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 228, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  8.291 s
[INFO] Finished at: 2021-09-28T14:14:51-07:00
[INFO] ------------------------------------------------------------------------

I'll kick the tests off again, after rectifying the modulo calculation.

This is interesting. nvcomp is the thing that was causing me compilation issues on my other PR as well.

@mythrocks mythrocks requested a review from ttnghia September 29, 2021 18:46
@mythrocks
Copy link
Contributor Author

This is interesting. nvcomp is the thing that was causing me compilation issues on my other PR as well.

@codereport, that is indeed interesting. I didn't run into compilation issues with nvcomp in CI. I did see this on my workstation, but was because of an unscrubbed target/ director. Running mvn clean first helped.

Copy link
Contributor

@ttnghia ttnghia left a comment

Choose a reason for hiding this comment

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

Some nit in the tests: Please don't leave too many blank lines as that makes the code looks discrete.

@mythrocks
Copy link
Contributor Author

Some nit in the tests: Please don't leave too many blank lines as that makes the code looks discrete.

The whitespace in the old code hasn't been changed. The new code follows that preexisting format.
I can do a reformatting pass, if that satisfies the reviewer's preference.

@mythrocks
Copy link
Contributor Author

@ttnghia: I refrained from reformatting the existing test code on the first pass. Per your suggestion, I have reformatted most of the tests. Let me know if this works better.

@mythrocks mythrocks requested a review from ttnghia September 30, 2021 07:01
Copy link
Contributor

@ttnghia ttnghia left a comment

Choose a reason for hiding this comment

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

@ttnghia: I refrained from reformatting the existing test code on the first pass. Per your suggestion, I have reformatted most of the tests. Let me know if this works better.

Absolutely it's better. Thanks Mithun.

@mythrocks
Copy link
Contributor Author

@gpucibot merge

@rapids-bot rapids-bot bot merged commit 5cea6b5 into rapidsai:branch-21.12 Sep 30, 2021
@mythrocks mythrocks deleted the segmented-gather-nullify branch September 30, 2021 17:19
@mythrocks
Copy link
Contributor Author

Thank you all for the reviews and advice. This change has now been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 - Ready for Review Ready for review by team breaking Breaking change feature request New feature or request libcudf Affects libcudf (C++/CUDA) code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants