KEMBAR78
Improve the Sparse matrix multiplication computational speed #16187 by musikisomorphie · Pull Request #16905 · pytorch/pytorch · GitHub
Skip to content

Conversation

@musikisomorphie
Copy link
Contributor

Instead of converting coo to csr format of the sparse matrix in the original implementation, in my revision I directly use coo format for sparse dense matrix mutliplication.
On my linux machine it is 5 times faster than the original code:

(original code)
SIZE: 15000 DENSITY: 0.01 DEVICE: cpu
torch: 0.39403 seconds
np:    0.00496674 seconds
torch/np: 79.3338

----------------------------------------

(my update)
SIZE: 15000 DENSITY: 0.01 DEVICE: cpu
torch: 0.0812583 seconds
np:    0.00501871 seconds
torch/np: 16.1911

Further code feedback and running time tests are highly welcomed. I will keep revise my code if needed.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@ezyang is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

zdevito pushed a commit to zdevito/ATen that referenced this pull request Feb 11, 2019
…#16905)

Summary:
Instead of converting coo to csr format of the sparse matrix in the original implementation, in my revision I directly use coo format for sparse dense matrix mutliplication.
On my linux machine it is 5 times faster than the original code:

```
(original code)
SIZE: 15000 DENSITY: 0.01 DEVICE: cpu
torch: 0.39403 seconds
np:    0.00496674 seconds
torch/np: 79.3338

----------------------------------------

(my update)
SIZE: 15000 DENSITY: 0.01 DEVICE: cpu
torch: 0.0812583 seconds
np:    0.00501871 seconds
torch/np: 16.1911

```

Further code feedback and running time tests are highly welcomed. I will keep revise my code if needed.
Pull Request resolved: pytorch/pytorch#16905

Differential Revision: D14020095

Pulled By: ezyang

fbshipit-source-id: 4ab94075344a55b375f22421e97a690e682baed5
@musikisomorphie
Copy link
Contributor Author

musikisomorphie commented Feb 11, 2019

Hi @ezyang, @yf225 @fmassa, my PR is automatically closed.
I checked the error report of the internal tests, which doesn't seem to have anything to do with my changes. I would like to keep working on it as I said. Should I reopen a new PR? Or maybe you guys provide some further code reviews? Thank you.

@soumith
Copy link
Member

soumith commented Feb 11, 2019

yes the current commit has landed to master. for more work / changes, open a new PR. thanks!

@musikisomorphie
Copy link
Contributor Author

yes the current commit has landed to master. for more work / changes, open a new PR. thanks!

Hi @soumith, thank you for your reply. Is it possible that I can have more feedback on my code? both of the error reports of internal tests involve cuda, but I only change the cpu part implementation. I didn't get very useful feedback from the internal tests.

@ezyang
Copy link
Contributor

ezyang commented Feb 11, 2019

Hi @musikisomorphie; our CI is a bit flaky, so one of the things I do before merging is check the failure and see if they are valid or not. In your case, the CUDA errors were flaky and not related to your PR, so I merged.

@musikisomorphie
Copy link
Contributor Author

Hi @musikisomorphie; our CI is a bit flaky, so one of the things I do before merging is check the failure and see if they are valid or not. In your case, the CUDA errors were flaky and not related to your PR, so I merged.

Thanks @ezyang, I am glad my code is merged. I misunderstood what @soumith said, I will keep contributing to pytorch. it is quite fun.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants