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

Improvements in matrix::gather: test coverage, compilation errors, performance #1126

Merged
merged 13 commits into from
Jan 21, 2023

Conversation

Nyrio
Copy link
Contributor

@Nyrio Nyrio commented Jan 10, 2023

In order to deprecate copy_selected from ann_utils.cuh, I wanted to make sure that the performance of matrix::gather was on par. But in the process I discovered that:

  • Map transforms and conditional copy were not tested at all.
  • In fact, most of the API in gather.cuh wasn't covered in tests and some of the functions didn't even compile.
  • The same type MatrixIteratorT was used for the input and output iterators, which made it impossible to take advantage of custom iterators, as is needed in kmeans_balanced to convert the dataset from T to float and gather in a single step.
  • The performance was really poor when D is small because the kernel assigns one block per row (so a block could be working on only 2 or 3 elements...)

This PR addresses all the aforementioned issues.

@Nyrio Nyrio requested review from a team as code owners January 10, 2023 16:07
@Nyrio
Copy link
Contributor Author

Nyrio commented Jan 10, 2023

Below is a comparison of before/after performance. The speedups range from 1x to 7x in my benchmark (possibly more with an even smaller out_cols).

2023-01-10_gather_if_perf

@Nyrio Nyrio added 3 - Ready for Review improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Jan 10, 2023
@Nyrio Nyrio requested review from tfeher and cjnolet January 10, 2023 16:11
@codecov-commenter
Copy link

codecov-commenter commented Jan 11, 2023

Codecov Report

Base: 87.99% // Head: 87.99% // No change to project coverage 👍

Coverage data is based on head (029724f) compared to base (187ff9e).
Patch has no changes to coverable lines.

Additional details and impacted files
@@              Coverage Diff              @@
##           branch-23.02    #1126   +/-   ##
=============================================
  Coverage         87.99%   87.99%           
=============================================
  Files                21       21           
  Lines               483      483           
=============================================
  Hits                425      425           
  Misses               58       58           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@tfeher tfeher left a comment

Choose a reason for hiding this comment

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

Hi Louis, thanks for the PR, it looks good! While we are here, could you improve a little bit the docstring of gather, I have left a few questions.

cpp/include/raft/matrix/gather.cuh Outdated Show resolved Hide resolved
@Nyrio
Copy link
Contributor Author

Nyrio commented Jan 19, 2023

I'm not sure what's up with CI but it doesn't seem to be a compiler nor test error.

Copy link
Contributor

@tfeher tfeher left a comment

Choose a reason for hiding this comment

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

Thanks Louis for updating the doc. The PR looks good to me.

@cjnolet
Copy link
Member

cjnolet commented Jan 19, 2023

@Nyrio the changes look good here. Before we merge this, can you verify that the changes to the template params don't break cuml downstream?

@Nyrio
Copy link
Contributor Author

Nyrio commented Jan 19, 2023

@cjnolet There is one call to gather_if in cuML and it shouldn't break (actually, the only thing that can potentially break with my change is the mdspan overload if all the template args are explicitly specified).

Copy link
Member

@cjnolet cjnolet left a comment

Choose a reason for hiding this comment

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

LGTM

@cjnolet
Copy link
Member

cjnolet commented Jan 21, 2023

/merge

@rapids-bot rapids-bot bot merged commit 0e96662 into rapidsai:branch-23.02 Jan 21, 2023
ahendriksen pushed a commit to ahendriksen/raft that referenced this pull request Jan 23, 2023
…performance (rapidsai#1126)

In order to deprecate `copy_selected` from `ann_utils.cuh`, I wanted to make sure that the performance of `matrix::gather` was on par. But in the process I discovered that:

- Map transforms and conditional copy were not tested at all.
- In fact, most of the API in `gather.cuh` wasn't covered in tests and some of the functions didn't even compile.
- The same type `MatrixIteratorT` was used for the input and output iterators, which made it impossible to take advantage of custom iterators, as is needed in `kmeans_balanced` to convert the dataset from `T` to `float` and gather in a single step.
- The performance was really poor when `D` is small because the kernel assigns one block per row (so a block could be working on only 2 or 3 elements...)

This PR addresses all the aforementioned issues.

Authors:
  - Louis Sugy (https://github.com/Nyrio)

Approvers:
  - Tamas Bela Feher (https://github.com/tfeher)
  - Corey J. Nolet (https://github.com/cjnolet)

URL: rapidsai#1126
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 - Ready for Review CMake cpp improvement Improvement / enhancement to an existing function non-breaking Non-breaking change
Projects
Development

Successfully merging this pull request may close these issues.

4 participants