-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[Performance] Improve COO to CSR, and sort columns of CSR only when necessary. #2391
Merged
Conversation
This file contains 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
nv-dlasalle
changed the title
[Performance] Only sort CSR columns when necessary, take sorting status to be correct.
[WIP] Only sort CSR columns when necessary, take sorting status to be correct.
Dec 3, 2020
nv-dlasalle
force-pushed
the
lazy_sort
branch
from
January 11, 2021 14:59
ac4d556
to
2bcfc6b
Compare
nv-dlasalle
changed the title
[WIP] Only sort CSR columns when necessary, take sorting status to be correct.
[WIP] Improve COO to CSR, and sort columns of CSR only when necessary.
Jan 11, 2021
nv-dlasalle
changed the title
[WIP] Improve COO to CSR, and sort columns of CSR only when necessary.
[Performance] Improve COO to CSR, and sort columns of CSR only when necessary.
Jan 12, 2021
6 tasks
jermainewang
requested changes
Jan 26, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR is mostly in good shape. Some comments.
nv-dlasalle
force-pushed
the
lazy_sort
branch
from
January 26, 2021 20:09
c3136f6
to
d95a08d
Compare
jermainewang
approved these changes
Jan 27, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
6 tasks
5 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Avoid unnecessarily sort CSR columns, reduces the amount of work done when rows are sorted, and avoids synchronizing to double check if a COO is not sorted. It also parallelizes the conversion of an unsorted COO to CSR on the CPU, which can significantly reduce startup time (when the formats are generated for the global graph).
On
examples/pytorch/rgcn/entity_classify_mp.py
with theogb-mag
dataset, using the master branch with the PyTorch allocator, sorting on the GPU looks like:And here it is with this PR:
With this PR, you can see, the check for if the matrix is sorted is removed, and the number of radix sort iterations is significantly reduced.
Checklist
Please feel free to remove inapplicable items for your PR.
or have been fixed to be compatible with this change
Changes
Changes UnitGraph to return unsorted CSRs for
GetInCSR()
andGetOutCSR()
Changes COOToCSR to not check if the matrix is sorted, if it claims to be unsorted. This eliminates a D2H copy, which forces synchronization between the CPU and GPU.
Changes
COOSort()
to respect thesort_columns
flag, and merges the separate int32_t and int64_t version into a single one which uses CUB and takes advantage of the small number of rows relative to the width of IdType. That is, if we have 100,000 nodes in our block, we will only perform a radix sort of width 17, rather than the full 32 or 64 bits of the IdType.Changes the CPU version of COOToCSR to generate the CSR in parallel, by doing two passes over the graph, one to count the number of edges per vertex, and the second to insert the edges in the correct positions.
This also expands the unit tests in
tests/cpp/test_spmat_csr.cc
to ensure unsorted CSRs are not problematic.