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

Faster sparse_dense on GPUs #6580

Merged
merged 14 commits into from
Oct 9, 2020
Merged

Conversation

tkonolige
Copy link
Contributor

I've written a faster sparse_dense for GPUs using tir. This sparse_dense requires a padded matrix, so I've added a new op sparse_dense_padded. AlterOpLayout should transform sparse_dense to sparse_dense_padded when using a gpu.

This new sparse_dense improves prunebert performance from 155.41ms mean to 7.75ms mean. In general, this implementation is faster than cublas dense on matrices with density < 0.05 and is often faster than cusparse for machine learning workloads.

@tkonolige tkonolige changed the title Faster sparse_dense on GPUs. Faster sparse_dense on GPUs Sep 28, 2020
This new sparse_dense requires a padded matrix, so a new op
`sparse_dense_padded` has been added. AlterOpLayout should transform
`sparse_dense` to `sparse_dense_padded` when possible on the gpu.
@ANSHUMAN87
Copy link
Contributor

I've written a faster sparse_dense for GPUs using tir. This sparse_dense requires a padded matrix, so I've added a new op sparse_dense_padded. AlterOpLayout should transform sparse_dense to sparse_dense_padded when using a gpu.

This new sparse_dense improves prunebert performance from 155.41ms mean to 7.75ms mean. In general, this implementation is faster than cublas dense on matrices with density < 0.05 and is often faster than cusparse for machine learning workloads.

@tkonolige : Thanks for the PR! The data looks quite impressive 👍
I was wondering whether we can add some sort of benchmark testcase here , tuned to your shared data?

@tkonolige
Copy link
Contributor Author

@ANSHUMAN87 Right now TVM does not do any testing for performance regressions. The hard part in setting up performance testing is that is varies from run to run and machine to machine.

@ANSHUMAN87
Copy link
Contributor

@tkonolige : I understand your concern clearly. However it was just a thought. Even if run to run or machine to machine difference, the relative reference would be same. But may be we don't have to do as part of this PR :)
I will go through deep into your PR, will share my comment if any. Thanks!

@ghost
Copy link

ghost commented Sep 30, 2020

Have you considered your syntax errors?

@tkonolige
Copy link
Contributor Author

@vinx13 @antinucleon @Laurawly @jwfromm @ajtulloch I think this is ready for review.

tests/python/topi/python/test_topi_sparse.py Show resolved Hide resolved
src/relay/op/nn/sparse.cc Outdated Show resolved Hide resolved
Copy link
Contributor

@ANSHUMAN87 ANSHUMAN87 left a comment

Choose a reason for hiding this comment

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

Thanks @tkonolige !

Copy link
Contributor

@electriclilies electriclilies left a comment

Choose a reason for hiding this comment

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

LGTM!

@jroesch jroesch merged commit 6d0351a into apache:master Oct 9, 2020
@merrymercy
Copy link
Member

merrymercy commented Oct 10, 2020

@tkonolige @tqchen This commits fails in the master branch. see the CI: https:/apache/incubator-tvm/commits/master

It introduces a flaky test that blocks two of my PRs.

@ANSHUMAN87
Copy link
Contributor

@tkonolige @tqchen This commits fails in the master branch. see the CI: https:/apache/incubator-tvm/commits/master

It introduces a flaky test that blocks two of my PRs.

#6658 has resolved the issue i think.

@tkonolige
Copy link
Contributor Author

@merrymercy I think that was the diagnostics

TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Oct 13, 2020
* Faster sparse_dense on GPUs.

This new sparse_dense requires a padded matrix, so a new op
`sparse_dense_padded` has been added. AlterOpLayout should transform
`sparse_dense` to `sparse_dense_padded` when possible on the gpu.

* formatting

* more formatting

* Check that alteroplayout is definedbefore using it

* check if FTVMAlterOpLayout exists before using it

* formatting

* restore message passing

* Fix sparse_dense and sparse_dense_padded docs

* Fix old sparse_dense, autotvm and sparse_dense dont play well together

* Remove unused imports

* clarify warp count in cuda_transpose

* Document multidimensional access

* Warn users not to use sparse_dense_padded

* rename nn.sparse_dense_padded to nn.internal.sparse_dense_padded
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Oct 14, 2020
* Faster sparse_dense on GPUs.

This new sparse_dense requires a padded matrix, so a new op
`sparse_dense_padded` has been added. AlterOpLayout should transform
`sparse_dense` to `sparse_dense_padded` when possible on the gpu.

* formatting

* more formatting

* Check that alteroplayout is definedbefore using it

* check if FTVMAlterOpLayout exists before using it

* formatting

* restore message passing

* Fix sparse_dense and sparse_dense_padded docs

* Fix old sparse_dense, autotvm and sparse_dense dont play well together

* Remove unused imports

* clarify warp count in cuda_transpose

* Document multidimensional access

* Warn users not to use sparse_dense_padded

* rename nn.sparse_dense_padded to nn.internal.sparse_dense_padded
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Oct 15, 2020
* Faster sparse_dense on GPUs.

This new sparse_dense requires a padded matrix, so a new op
`sparse_dense_padded` has been added. AlterOpLayout should transform
`sparse_dense` to `sparse_dense_padded` when possible on the gpu.

* formatting

* more formatting

* Check that alteroplayout is definedbefore using it

* check if FTVMAlterOpLayout exists before using it

* formatting

* restore message passing

* Fix sparse_dense and sparse_dense_padded docs

* Fix old sparse_dense, autotvm and sparse_dense dont play well together

* Remove unused imports

* clarify warp count in cuda_transpose

* Document multidimensional access

* Warn users not to use sparse_dense_padded

* rename nn.sparse_dense_padded to nn.internal.sparse_dense_padded
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Oct 15, 2020
* Faster sparse_dense on GPUs.

This new sparse_dense requires a padded matrix, so a new op
`sparse_dense_padded` has been added. AlterOpLayout should transform
`sparse_dense` to `sparse_dense_padded` when possible on the gpu.

* formatting

* more formatting

* Check that alteroplayout is definedbefore using it

* check if FTVMAlterOpLayout exists before using it

* formatting

* restore message passing

* Fix sparse_dense and sparse_dense_padded docs

* Fix old sparse_dense, autotvm and sparse_dense dont play well together

* Remove unused imports

* clarify warp count in cuda_transpose

* Document multidimensional access

* Warn users not to use sparse_dense_padded

* rename nn.sparse_dense_padded to nn.internal.sparse_dense_padded
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Oct 16, 2020
* Faster sparse_dense on GPUs.

This new sparse_dense requires a padded matrix, so a new op
`sparse_dense_padded` has been added. AlterOpLayout should transform
`sparse_dense` to `sparse_dense_padded` when possible on the gpu.

* formatting

* more formatting

* Check that alteroplayout is definedbefore using it

* check if FTVMAlterOpLayout exists before using it

* formatting

* restore message passing

* Fix sparse_dense and sparse_dense_padded docs

* Fix old sparse_dense, autotvm and sparse_dense dont play well together

* Remove unused imports

* clarify warp count in cuda_transpose

* Document multidimensional access

* Warn users not to use sparse_dense_padded

* rename nn.sparse_dense_padded to nn.internal.sparse_dense_padded
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Oct 19, 2020
* Faster sparse_dense on GPUs.

This new sparse_dense requires a padded matrix, so a new op
`sparse_dense_padded` has been added. AlterOpLayout should transform
`sparse_dense` to `sparse_dense_padded` when possible on the gpu.

* formatting

* more formatting

* Check that alteroplayout is definedbefore using it

* check if FTVMAlterOpLayout exists before using it

* formatting

* restore message passing

* Fix sparse_dense and sparse_dense_padded docs

* Fix old sparse_dense, autotvm and sparse_dense dont play well together

* Remove unused imports

* clarify warp count in cuda_transpose

* Document multidimensional access

* Warn users not to use sparse_dense_padded

* rename nn.sparse_dense_padded to nn.internal.sparse_dense_padded
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.

7 participants