Repository navigation
Conversation
|
|
||
| auto reduction_accessor = reduction_.accessor<int32_t, 1>(); | ||
|
|
||
| rsplit_dim_ = reduction_accessor[reduction_.size(0)-1]; |
There was a problem hiding this comment.
this isn't going to work on CUDA (also I still have no idea what reduction is)
|
I'm looking for a description of GCS format in https://github.com/Quansight-Labs/rfcs/tree/pearu/rfc0005/RFC0003-sparse-roadmap but I cannot find it. For example, I search the README for "GCS" but I don't see any occurrence of this term anywhere in the README. I see there is a file https://github.com/Quansight-Labs/rfcs/blob/pearu/rfc0005/RFC0003-sparse-roadmap/GCS_index_inconversion.md but it seems to be a very specific subproblem of solving the GCS format and I am looking for a more generic description of GCS. |
I think it's Efficient storage scheme for n-dimensional sparse array: GCRS/GCCS. https://github.com/Quansight-Labs/rfcs/tree/pearu/rfc0005/RFC0003-sparse-roadmap also contains a description: https://github.com/Quansight-Labs/rfcs/blob/e2624b0bed1efdc2c27cba90ae4575489b60ac3b/RFC0003-sparse-roadmap/README.md#crsccs-sparse-array-storage-format GCS is shorthand for GCCS/GCRS, so that's why searching for GCS comes up empty. @v0dro if you have more references/notes, can you add them here? |
Huh, this has way less citations than I thought it would. https://scholar.google.com/scholar?cites=14217487981794327056&as_sdt=2005&sciodt=0,5&hl=en That's weird... |
| reduction() -> Tensor | ||
|
|
||
| Tensor which shows the demarcation between dimensions that will be | ||
| flattened from the N-D tensor. |
There was a problem hiding this comment.
This isn't enough description.
There was a problem hiding this comment.
For example, what is the dimensionality/size of this tensor, depending on the size of the sparse tensor? How exactly is the "Demarcation" represented? An example?
|
@ezyang based on your reviews, I am thinking of making the following changes to this PR:
One question about the indices being |
I don't know. While it is true we typically prefer to expose 64-bit indexing on the user side (e.g., torch.gather), swapping out the MKL version can have far reaching implications on PyTorch and (1) isn't obviously the right thing outside of the sparse project, and (2) is likely to require a bit of work to update all other MKL bindings. |
|
let me know when to look at the PR again |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
) Summary: Implement compressed sparse row format. Derived from the GCS implementation at pytorch#44190 Pull Request resolved: pytorch#50937 Reviewed By: mrshenli Differential Revision: D27439865 Pulled By: ezyang fbshipit-source-id: 3ba3dcb9679505b980ff6a5f513e913bbae2fb1d
Introduction
This PR introduces the GCS format for efficient storage and operations on multi-dimensional
tensors. The GCS format is special in that it drops down to the usual CSR format for 2D
tensors and supports multi-dimensional data using the same data structures used by CSR but
with a slightly augmented indexing scheme. While ready to be reviewed, the architecture and naming
scheme is still up for consideration, and it would be great if people familiar with sparse tensor support
in pytorch could have a look at the various changes that are being introduced as a result of this PR.
The GCS format is a N-D sparse array storage format that allows storing a sparse tensor using 3 1-D tensors. It is similar to the CSR format in terms of storage. What makes it particularly attractive over the current COO implementation is that 2-D tensors fall back to the traditional CSR format, which has been the preferred choice for fast SpMM and SpMV computation due to fast slicing operations and readily available support from various libraries such as MAGMA, MKL and cuSPARSE.
A detailed description of the GCS format implemented here can be found here: https://github.com/Quansight-Labs/rfcs/tree/pearu/rfc0005/RFC0003-sparse-roadmap
In particular, I have made the following additions:
torch.sparse_gcs.torch.sparse_gcs_tensor().SparseGCSTensorImplfor implementing the special methods needed for this tensor type. Inherits fromTensorImplsimilar toSparseTensorImpl.CUDA support will be added once the CPU changes are approved and merged. That way there will be a firm foundation to build the CUDA functionality upon.
Support for SpMV (with benchmarks)
It can support all the operations supported by COO, and is faster for many critical operations
such as SpMV and SpMM for 2D tensors. The graphs below show the performance using of SpMV
with and without MKL's CSR SpMV routines compared to the default COO implementation for a
variety of matrix and NNZ ratios.
Details
The following script was used for benchmarking the COO and GCS format SpMV:
Details
Support for SpMM (with benchmarks)
The GCS also supports with dense matrices with and without using MKL. The performance vs. COO can be seen in the following
graphs:
Details
The following functions were used for obtaining the above data:
Details
Support for fill values
The fill value is an important idea being introduced into the sparse COO format by Pearu and
the others, and the GCS format is ready for implementing various functions using the fill value
since it already supports creating the tensor by accepting a fill value.
Conclusion
The PR contains the following features:
floatanddouble.Note that multiplication only with dense matrix is supported for now.
In order to proceed with the implementation, I think it is important to finalize the code
structure of the constructor and other implementation details pertinent to GCS and only
then proceed with implementation of various operators. In that regard, IMO we should
first merge this PR and therefore would like to invite comments from @rgommers @pearu @ezyang @aocsa .
Particular RFC requests
SparseTensorImpl(same as master) and the GCS is calledSparseGCSTensorImpl. Should the COO class be changed toSparseCOOTensorImpl?TensorImplseparately. Should there be a commonSparseTensorImplclass that sits betweenSparseCOOTensorImplandSparseGCSTensorImpl? This way we can also add more sparse layouts in the future.SparseTensorUtils.hare not guaranteed to work with GCS tensors. Should we have templated variants of each of these functions for such support? It can be added on a as-needed basis.SparseTensorMath.cpphowever I have made a departure from that and made them available insidesparse/LinearAlgebra.cppfor better discoverability (has only matmul for now). Might I suggest a similar approach for all the other functions?SparseCPUfor CPU andSparseCUDAfor CUDA. How about change it toSparseCOO_CPUand similar for CUDA?