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

[WIP] Sparse pairwise semi-ring kernel #2861

Closed
wants to merge 121 commits into from

Conversation

cjnolet
Copy link
Member

@cjnolet cjnolet commented Sep 23, 2020

This PR implements Lp-style distances and their derivatives with a matrix-vector-operation-style mapping to warps and a semi-ring-style pluggability w/ accumulation and reduction functions. The initial version (in this PR) will only aim to provide an Lp distance primitive that shows a significant speedup over CPU.

Assuming it will be fast enough, future versions of this implementation could potentially have several benefits even over the existing dot product (and expanded euclidean) prims, which use cusparse csrgemm:

  1. The csrgemm in cusparse that accepts both sparse inputs outputs a sparse matrix, so we need to allocate double the memory and waste time converting it to dense.
  2. The B input to the csrgemm needs to be transposed. Unfortunately, CSC is not able to share any data w/ a CSR, so that's even more extra allocations.
  3. This pairwise distance kernel will enable more than just a matrix multiply, it can actually be used to implement all the Lp and inner-product-based variants. The cusparse GEMM is good at the one thing, and we're still left to our own implementations for any Lp variants aside from expanded euclidean.
  4. Today, we are still stuck supporting the 32-bit indexing API from cusparse, and even with the 64-bit indexing API, there are still many functions that only support 32-bit. This will allow us to support 64-bit natively, just through type templates.

…_knn

Conflicts:
	cpp/src_prims/sparse/cusparse_wrappers.h
…version seems super expensive, but maybe it's necessary.
@cjnolet cjnolet changed the title [WIP] Sparse pairwise accumulate & reduce kernel [WIP] Sparse pairwise semi-ring kernel Sep 24, 2020
@cjnolet cjnolet requested a review from a team as a code owner October 19, 2020 23:44
@cjnolet cjnolet changed the base branch from branch-0.16 to branch-0.17 October 19, 2020 23:45
@cjnolet cjnolet removed the request for review from a team October 19, 2020 23:45
@cjnolet cjnolet closed this Oct 27, 2020
rapids-bot bot pushed a commit that referenced this pull request Jan 30, 2021
Closes #1448 

I'm not sure why/how the original PR for this was closed but I'm opening up a new PR for this. 

Please refer to original PR for more info: #2861

If reviewing this prim, you can start with `cpp/src_prims/sparse/distance/coo_spmv.cuh` and `cpp/src_prims/sparse/csr_spmv.cuh` and associated Gtest. cc @teju85

As mentioned in comments throughout this PR, there are a few tasks which will be pushed off to the next PR. Here are a few tasks that remain in this PR to prep for release 0.18:
- [x] Add explicit distance gtests for coo_spmv and csr_spmv
- [x] Add gtest case for Hellinger distance in distance prim tests
- [x] Add a pytest for very wide but very sparse input (to test switch to csr kernel)

Authors:
  - Corey J. Nolet (@cjnolet)
  - Ray Douglass (@raydouglass)

Approvers:
  - Tamas Bela Feher (@tfeher)
  - John Zedlewski (@JohnZed)

URL: #3146
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants