Skip to content

matmul performance benchmarks - #51647

Closed
aocsa wants to merge 7 commits into
pytorch:masterfrom
Quansight:aocsa/sparse_mm_bench
Closed

aocsa wants to merge 7 commits into
pytorch:masterfrom
Quansight:aocsa/sparse_mm_bench

Conversation

@aocsa

@aocsa aocsa commented Feb 3, 2021 •

Copy link
Copy Markdown
Contributor

Minor PR following up the previous PR about sparse benchmarking utils #48397

Fixes #44634: Performance benchmarks for matrix-matrix and matrix-vector ops (dense-sparse, sparse-sparse, and compare to dense-dense)

I ran all benchmarks on an 2xRTX8000 machine with AMD 2970WX 24-cores for DLMC/magnitude_pruning dataset with different sparsity levels.


forward tests (expand for details).
  • sparse@sparse
[------------------------------- cpu:matmul-forward -------------------------------]
                           |   0.5   |   0.7   |   0.8   |   0.9   |  0.95  |   0.98
1 threads: -------------------------------------------------------------------------
      torch:dense@dense    |  108.1  |  100.5  |  101.3  |  108.4  |  98.4  |  187.4
      torch:sparse@sparse  |  659.1  |  368.8  |  156.5  |   53.3  |  26.8  |   14.9
      scipy:sparse@sparse  |  565.1  |  233.9  |  130.2  |   23.1  |  21.6  |   15.2

Times are in milliseconds (ms).

[----------------------------------- cuda:matmul-forward -----------------------------------]
                           |    0.5    |    0.7    |   0.8    |   0.9    |   0.95   |   0.98 
1 threads: ----------------------------------------------------------------------------------
      torch:dense@dense    |   2243.5  |   4392.5  |  4419.8  |  2272.3  |  4433.9  |  8920.1
      torch:sparse@sparse  |  21369.2  |  11877.6  |  7339.2  |  1787.2  |  1335.1  |   845.7

Times are in microseconds (us).

  • sparse@dense
[------------------------------- cpu:matmul-forward -------------------------------]
                          |   0.5   |   0.7   |   0.8   |   0.9   |   0.95  |   0.98
1 threads: -------------------------------------------------------------------------
      torch:dense@dense   |  105.8  |  103.8  |  103.0  |  104.4  |  104.4  |  197.0
      torch:sparse@dense  |  119.9  |  102.4  |   84.0  |   19.7  |   16.8  |   11.6
      scipy:sparse@dense  |  906.5  |  799.6  |  697.8  |  182.2  |  165.5  |  135.4

Times are in milliseconds (ms).

[------------------------- cuda:matmul-forward --------------------------]
                          |  0.5  |  0.7  |  0.8  |  0.9  |  0.95  |  0.98
1 threads: ---------------------------------------------------------------
      torch:dense@dense   |  2.2  |  4.4  |  4.4  |  2.3  |  4.5   |  2.3 
      torch:sparse@dense  |  5.7  |  6.6  |  4.5  |  1.4  |  1.4   |  1.3 

Times are in milliseconds (ms).

  • sparse@vector
[----------------------------------- cpu:matmul-forward ----------------------------------]
                           |    0.5    |   0.7    |   0.8    |   0.9    |   0.95   |   0.98
1 threads: --------------------------------------------------------------------------------
      torch:dense@vector   |    510.6  |   505.8  |   759.6  |   782.1  |   682.4  |  764.6
      torch:sparse@vector  |  10122.8  |  6241.1  |  7935.6  |  2076.3  |  1049.5  |  826.3
      scipy:sparse@vector  |   1756.7  |  1033.9  |   678.2  |   343.5  |   168.5  |   65.4

Times are in microseconds (us).

[-------------------------------- cuda:matmul-forward --------------------------------]
                           |   0.5    |   0.7    |   0.8   |   0.9   |   0.95  |   0.98
1 threads: ----------------------------------------------------------------------------
      torch:dense@vector   |    36.1  |    21.5  |   21.6  |   21.5  |   21.6  |   21.5
      torch:sparse@vector  |  1099.2  |  1289.4  |  775.7  |  327.1  |  285.4  |  274.0

Times are in microseconds (us).


backward tests (expand for details).
  • sparse@sparse
[--------------------------------- cpu:matmul-backward ---------------------------------]
                           |   0.5    |   0.7    |   0.8    |   0.9    |   0.95  |   0.98
1 threads: ------------------------------------------------------------------------------
      torch:dense@dense    |   246.1  |   315.0  |   306.9  |   168.6  |  290.6  |  146.9
      torch:sparse@sparse  |  6417.5  |  4393.7  |  3012.7  |  1029.4  |  908.0  |  650.7

Times are in microseconds (us).

[----------------------------- cuda:matmul-backward -----------------------------]
                           |   0.5   |   0.7   |   0.8   |  0.9   |  0.95  |  0.98
1 threads: -----------------------------------------------------------------------
      torch:dense@dense    |    6.7  |   13.3  |   13.3  |   6.9  |  13.5  |   6.9
      torch:sparse@sparse  |  143.7  |  143.4  |  119.6  |  29.5  |  29.1  |  10.9

Times are in microseconds (us).

  • sparse@dense
 [------------------------------ cpu:matmul-backward -------------------------------]
                          |   0.5   |   0.7   |   0.8   |   0.9   |   0.95  |   0.98
1 threads: -------------------------------------------------------------------------
      torch:dense@dense   |  185.9  |  304.8  |  305.8  |  169.9  |  308.7  |  168.4
      torch:sparse@dense  |  407.9  |  345.8  |  274.6  |  114.2  |  163.6  |  230.5

Times are in milliseconds (ms).

[--------------------------- cuda:matmul-backward --------------------------]
                          |  0.5   |  0.7   |  0.8   |  0.9  |  0.95  |  0.98
1 threads: ------------------------------------------------------------------
      torch:dense@dense   |   6.7  |  13.3  |  13.3  |  6.9  |  13.4  |   6.9
      torch:sparse@dense  |  16.7  |  19.0  |  15.1  |  6.3  |   8.2  |  12.7

Times are in milliseconds (ms).

Kindly review this PR. cc @mruberry, @ngimel

@facebook-github-bot

facebook-github-bot commented Feb 3, 2021 •

Copy link
Copy Markdown
Contributor

💊 CI failures summary and remediations

As of commit b000c5a (more details on the Dr. CI page):


✅ None of the CI failures appear to be your fault 💚



🚧 2 fixed upstream failures:

These were probably caused by upstream breakages that were already fixed.

Please rebase on the viable/strict branch (expand for instructions)

If your commit is older than viable/strict, run these commands:

git fetch https://github.com/pytorch/pytorch viable/strict
git rebase FETCH_HEAD

This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

@aocsa
aocsa force-pushed the aocsa/sparse_mm_bench branch from a7aa982 to fb37a87 Compare February 8, 2021 16:04
@aocsa
aocsa marked this pull request as ready for review February 8, 2021 16:05
@aocsa
aocsa force-pushed the aocsa/sparse_mm_bench branch from 985c08d to 3a2f8ec Compare February 9, 2021 17:58
@VitalyFedyunin VitalyFedyunin added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Feb 10, 2021

@robieta robieta left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

At a high level it seems like spmm.py and spmv.py could be merged by having a central definition of tasks

_TASKS = {
    "mm": (
        ("torch", "torch.mm(dx, dy)"),
        ("torch.sparse", "torch.sparse.mm(x, y)"),
        ("scipy", "scipy_coo_matmul(sx, sy)"),
    ),
    "mv": (
        ("torch", "torch.matmul(dx, vector)"),
        ("torch.sparse", "torch.matmul(x, vector)"),
        ("scipy", "scipy_coo_matmul(sx, vector)"),
    ),
    "backward": (
        ("torch", "torch_backward(dx, dy)"),
        ("torch.sparse", "sparse_torch_backward(x, y)"),
    )
}

and some switching code at the start:

tasks = _TASKS[operation]
if device != "cpu":
    # SciPy is CPU only.
    tasks = tuple(t for t in tasks if t[0] != "scipy")

loader = (
    load_spmv_dataset if operation == "mv" else
    functools.partial(load_spmm_dataset, spmm_type=spmm_type)
)

There's also a bit of logic for globals, but it doesn't seem insurmountable. WDYT?

Comment thread benchmarks/sparse/dlmc/spmm.py Resolved
Comment thread benchmarks/sparse/dlmc/spmm.py Resolved
Comment thread benchmarks/sparse/dlmc/spmm.py Resolved
Comment thread benchmarks/sparse/dlmc/spmv.py Resolved
Comment thread benchmarks/sparse/dlmc/README.md Resolved
Comment thread benchmarks/sparse/dlmc/utils.py Resolved
Comment thread benchmarks/sparse/dlmc/utils.py Resolved
Comment thread benchmarks/sparse/dlmc/spmm.py Resolved
Comment thread benchmarks/sparse/dlmc/spmm.py Resolved
Comment thread benchmarks/sparse/dlmc/spmm.py Resolved
Comment thread benchmarks/sparse/dlmc/spmv.py Resolved
Comment thread benchmarks/sparse/dlmc/spmv.py Resolved
Comment thread benchmarks/sparse/dlmc/spmv.py Resolved
Comment thread benchmarks/sparse/dlmc/spmv.py Resolved
Comment thread benchmarks/sparse/dlmc/utils.py Resolved
Comment thread benchmarks/sparse/dlmc/utils.py Resolved
@ngimel

ngimel commented Feb 12, 2021

Copy link
Copy Markdown
Collaborator

Do you have results from running this benchmark?

@aocsa aocsa self-assigned this Feb 17, 2021
@aocsa

aocsa commented Feb 18, 2021 •

Copy link
Copy Markdown
Contributor Author

At a high level it seems like spmm.py and spmv.py could be merged by having a central definition of tasks

_TASKS = {
    "mm": (
        ("torch", "torch.mm(dx, dy)"),
        ("torch.sparse", "torch.sparse.mm(x, y)"),
        ("scipy", "scipy_coo_matmul(sx, sy)"),
    ),
    "mv": (
        ("torch", "torch.matmul(dx, vector)"),
        ("torch.sparse", "torch.matmul(x, vector)"),
        ("scipy", "scipy_coo_matmul(sx, vector)"),
    ),
    "backward": (
        ("torch", "torch_backward(dx, dy)"),
        ("torch.sparse", "sparse_torch_backward(x, y)"),
    )
}

and some switching code at the start:

tasks = _TASKS[operation]
if device != "cpu":
    # SciPy is CPU only.
    tasks = tuple(t for t in tasks if t[0] != "scipy")

loader = (
    load_spmv_dataset if operation == "mv" else
    functools.partial(load_spmm_dataset, spmm_type=spmm_type)
)

There's also a bit of logic for globals, but it doesn't seem insurmountable. WDYT?

Indeed, it was surmountable. Now spmm.py and spmv.py are merged :)

@aocsa
aocsa force-pushed the aocsa/sparse_mm_bench branch from 5125648 to d24d081 Compare February 18, 2021 05:22
@codecov

codecov Bot commented Feb 18, 2021 •

Copy link
Copy Markdown

Codecov Report

Merging #51647 (5f4b689) into master (5563248) will increase coverage by 3.57%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master   #51647      +/-   ##
==========================================
+ Coverage   73.77%   77.35%   +3.57%     
==========================================
  Files        1879     1879              
  Lines      183186   183186              
==========================================
+ Hits       135147   141701    +6554     
+ Misses      48039    41485    -6554     

@aocsa

aocsa commented Feb 19, 2021 •

Copy link
Copy Markdown
Contributor Author

Do you have results from running this benchmark?

I addressed the feedback comments. Moreover, I ran all benchmarks on an 2xRTX8000 machine with AMD 2970WX 24-cores for DLMC/magnitude_pruning dataset with different sparsity levels.


forward tests (expand for details).
  • sparse@sparse
[------------------------------- cpu:matmul-forward -------------------------------]
                           |   0.5   |   0.7   |   0.8   |   0.9   |  0.95  |   0.98
1 threads: -------------------------------------------------------------------------
      torch:dense@dense    |  108.1  |  100.5  |  101.3  |  108.4  |  98.4  |  187.4
      torch:sparse@sparse  |  659.1  |  368.8  |  156.5  |   53.3  |  26.8  |   14.9
      scipy:sparse@sparse  |  565.1  |  233.9  |  130.2  |   23.1  |  21.6  |   15.2
Times are in milliseconds (ms).

[----------------------------------- cuda:matmul-forward -----------------------------------]
                           |    0.5    |    0.7    |   0.8    |   0.9    |   0.95   |   0.98 
1 threads: ----------------------------------------------------------------------------------
      torch:dense@dense    |   2243.5  |   4392.5  |  4419.8  |  2272.3  |  4433.9  |  8920.1
      torch:sparse@sparse  |  21369.2  |  11877.6  |  7339.2  |  1787.2  |  1335.1  |   845.7

Times are in microseconds (us).

  • sparse@dense
[------------------------------- cpu:matmul-forward -------------------------------]
                          |   0.5   |   0.7   |   0.8   |   0.9   |   0.95  |   0.98
1 threads: -------------------------------------------------------------------------
      torch:dense@dense   |  105.8  |  103.8  |  103.0  |  104.4  |  104.4  |  197.0
      torch:sparse@dense  |  119.9  |  102.4  |   84.0  |   19.7  |   16.8  |   11.6
      scipy:sparse@dense  |  906.5  |  799.6  |  697.8  |  182.2  |  165.5  |  135.4

Times are in milliseconds (ms).

[------------------------- cuda:matmul-forward --------------------------]
                          |  0.5  |  0.7  |  0.8  |  0.9  |  0.95  |  0.98
1 threads: ---------------------------------------------------------------
      torch:dense@dense   |  2.2  |  4.4  |  4.4  |  2.3  |  4.5   |  2.3 
      torch:sparse@dense  |  5.7  |  6.6  |  4.5  |  1.4  |  1.4   |  1.3 

Times are in milliseconds (ms).

  • sparse@vector
[----------------------------------- cpu:matmul-forward ----------------------------------]
                           |    0.5    |   0.7    |   0.8    |   0.9    |   0.95   |   0.98
1 threads: --------------------------------------------------------------------------------
      torch:dense@vector   |    510.6  |   505.8  |   759.6  |   782.1  |   682.4  |  764.6
      torch:sparse@vector  |  10122.8  |  6241.1  |  7935.6  |  2076.3  |  1049.5  |  826.3
      scipy:sparse@vector  |   1756.7  |  1033.9  |   678.2  |   343.5  |   168.5  |   65.4

Times are in microseconds (us).

[-------------------------------- cuda:matmul-forward --------------------------------]
                           |   0.5    |   0.7    |   0.8   |   0.9   |   0.95  |   0.98
1 threads: ----------------------------------------------------------------------------
      torch:dense@vector   |    36.1  |    21.5  |   21.6  |   21.5  |   21.6  |   21.5
      torch:sparse@vector  |  1099.2  |  1289.4  |  775.7  |  327.1  |  285.4  |  274.0

Times are in microseconds (us).


backward tests (expand for details).
  • sparse@sparse
[--------------------------------- cpu:matmul-backward ---------------------------------]
                           |   0.5    |   0.7    |   0.8    |   0.9    |   0.95  |   0.98
1 threads: ------------------------------------------------------------------------------
      torch:dense@dense    |   246.1  |   315.0  |   306.9  |   168.6  |  290.6  |  146.9
      torch:sparse@sparse  |  6417.5  |  4393.7  |  3012.7  |  1029.4  |  908.0  |  650.7

Times are in microseconds (us).

[----------------------------- cuda:matmul-backward -----------------------------]
                           |   0.5   |   0.7   |   0.8   |  0.9   |  0.95  |  0.98
1 threads: -----------------------------------------------------------------------
      torch:dense@dense    |    6.7  |   13.3  |   13.3  |   6.9  |  13.5  |   6.9
      torch:sparse@sparse  |  143.7  |  143.4  |  119.6  |  29.5  |  29.1  |  10.9

Times are in microseconds (us).

  • sparse@dense
 [------------------------------ cpu:matmul-backward -------------------------------]
                          |   0.5   |   0.7   |   0.8   |   0.9   |   0.95  |   0.98
1 threads: -------------------------------------------------------------------------
      torch:dense@dense   |  185.9  |  304.8  |  305.8  |  169.9  |  308.7  |  168.4
      torch:sparse@dense  |  407.9  |  345.8  |  274.6  |  114.2  |  163.6  |  230.5

Times are in milliseconds (ms).

[--------------------------- cuda:matmul-backward --------------------------]
                          |  0.5   |  0.7   |  0.8   |  0.9  |  0.95  |  0.98
1 threads: ------------------------------------------------------------------
      torch:dense@dense   |   6.7  |  13.3  |  13.3  |  6.9  |  13.4  |   6.9
      torch:sparse@dense  |  16.7  |  19.0  |  15.1  |  6.3  |   8.2  |  12.7

Times are in milliseconds (ms).

cc @robieta, @ngimel, @mruberry

@aocsa
aocsa force-pushed the aocsa/sparse_mm_bench branch from dfe3167 to 4c3ae8e Compare February 19, 2021 17:18
@mruberry
mruberry self-requested a review February 26, 2021 01:16

@mruberry mruberry left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Cool! Thanks @aocsa. I wonder if we can close the gap with SciPy in the scenarios we're slower on CPU?

@robieta would you like to take another look before this is merged?

@aocsa

aocsa commented Feb 26, 2021 •

Copy link
Copy Markdown
Contributor Author

Cool! Thanks @aocsa. I wonder if we can close the gap with SciPy in the scenarios we're slower on CPU?

@robieta would you like to take another look before this is merged?

Thanks @mruberry, the current implementation of sparse-sparse matmul has almost the same performance as SciPy. I forgot to considering the overhead of converting the csr output of the x.dot(y) scipy operation to coo which is part of the process of torch.sparse.mm operation. I've updated the results with this change.

[------------------------------- cpu:matmul-forward -------------------------------]
                           |   0.5   |   0.7   |   0.8   |   0.9   |  0.95  |   0.98
1 threads: -------------------------------------------------------------------------
      torch:dense@dense    |  108.1  |  100.5  |  101.3  |  108.4  |  98.4  |  187.4
      torch:sparse@sparse  |  659.1  |  368.8  |  156.5  |   53.3  |  26.8  |   14.9
      scipy:sparse@sparse  |  565.1  |  233.9  |  130.2  |   23.1  |  21.6  |   15.2
Times are in milliseconds (ms).

I moved main comment and benchmark results into the PR description.

@aocsa
aocsa force-pushed the aocsa/sparse_mm_bench branch 2 times, most recently from ab4359b to d2868ce Compare February 26, 2021 02:35
@mruberry

mruberry commented Mar 1, 2021

Copy link
Copy Markdown
Collaborator

Let's give @robieta a chance to review.

@robieta robieta left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I had a single nitpick, but overall looks great. Thanks!

Comment thread benchmarks/sparse/dlmc/matmul_bench.py Resolved
@aocsa
aocsa force-pushed the aocsa/sparse_mm_bench branch from d2868ce to fc2554f Compare March 2, 2021 22:19
@aocsa aocsa mentioned this pull request Mar 2, 2021
8 of 26 tasks
@aocsa
aocsa force-pushed the aocsa/sparse_mm_bench branch from fc2554f to 5f4b689 Compare March 10, 2021 22:52
@aocsa

aocsa commented Mar 10, 2021

Copy link
Copy Markdown
Contributor Author

I rebased this PR and I think this PR is ready to be merged.
Thanks cc @mruberry

@aocsa
aocsa force-pushed the aocsa/sparse_mm_bench branch from 24f8665 to 870de27 Compare March 11, 2021 14:15

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@mruberry has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Comment thread test/jit/test_remove_mutation.py Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm trying to land this but the internal tools are struggling to reconcile these whitespace changes. Would you revert these changes and/or rebase this PR, @aocsa?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, it's done cc @mruberry

aocsa added 7 commits March 12, 2021 15:22
first commit

bench matmul
docs updated
update


update


update 2
update default timer_min_run_time


update


update


update repeats
@aocsa
aocsa force-pushed the aocsa/sparse_mm_bench branch from 870de27 to b000c5a Compare March 12, 2021 20:25

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@mruberry has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@mruberry merged this pull request in 39f50f4.

xsacha pushed a commit to xsacha/pytorch that referenced this pull request Mar 31, 2021
Summary:
Minor PR following up the previous PR about sparse benchmarking utils pytorch#48397

Fixes pytorch#44634:  Performance benchmarks for matrix-matrix and matrix-vector ops (dense-sparse, sparse-sparse, and compare to dense-dense)

I ran  all benchmarks on an 2xRTX8000 machine with AMD 2970WX 24-cores for `DLMC/magnitude_pruning` dataset with different sparsity levels.

 ---
<details><summary> forward tests (expand for details).
</summary>

- `sparse@sparse`
```
[------------------------------- cpu:matmul-forward -------------------------------]
                           |   0.5   |   0.7   |   0.8   |   0.9   |  0.95  |   0.98
1 threads: -------------------------------------------------------------------------
      torch:dense@dense    |  108.1  |  100.5  |  101.3  |  108.4  |  98.4  |  187.4
      torch:sparse@sparse  |  659.1  |  368.8  |  156.5  |   53.3  |  26.8  |   14.9
      scipy:sparse@sparse  |  565.1  |  233.9  |  130.2  |   23.1  |  21.6  |   15.2

Times are in milliseconds (ms).

[----------------------------------- cuda:matmul-forward -----------------------------------]
                           |    0.5    |    0.7    |   0.8    |   0.9    |   0.95   |   0.98
1 threads: ----------------------------------------------------------------------------------
      torch:dense@dense    |   2243.5  |   4392.5  |  4419.8  |  2272.3  |  4433.9  |  8920.1
      torch:sparse@sparse  |  21369.2  |  11877.6  |  7339.2  |  1787.2  |  1335.1  |   845.7

Times are in microseconds (us).

```
- `sparse@dense`
```
[------------------------------- cpu:matmul-forward -------------------------------]
                          |   0.5   |   0.7   |   0.8   |   0.9   |   0.95  |   0.98
1 threads: -------------------------------------------------------------------------
      torch:dense@dense   |  105.8  |  103.8  |  103.0  |  104.4  |  104.4  |  197.0
      torch:sparse@dense  |  119.9  |  102.4  |   84.0  |   19.7  |   16.8  |   11.6
      scipy:sparse@dense  |  906.5  |  799.6  |  697.8  |  182.2  |  165.5  |  135.4

Times are in milliseconds (ms).

[------------------------- cuda:matmul-forward --------------------------]
                          |  0.5  |  0.7  |  0.8  |  0.9  |  0.95  |  0.98
1 threads: ---------------------------------------------------------------
      torch:dense@dense   |  2.2  |  4.4  |  4.4  |  2.3  |  4.5   |  2.3
      torch:sparse@dense  |  5.7  |  6.6  |  4.5  |  1.4  |  1.4   |  1.3

Times are in milliseconds (ms).

```
- `sparse@vector`
```
[----------------------------------- cpu:matmul-forward ----------------------------------]
                           |    0.5    |   0.7    |   0.8    |   0.9    |   0.95   |   0.98
1 threads: --------------------------------------------------------------------------------
      torch:dense@vector   |    510.6  |   505.8  |   759.6  |   782.1  |   682.4  |  764.6
      torch:sparse@vector  |  10122.8  |  6241.1  |  7935.6  |  2076.3  |  1049.5  |  826.3
      scipy:sparse@vector  |   1756.7  |  1033.9  |   678.2  |   343.5  |   168.5  |   65.4

Times are in microseconds (us).

[-------------------------------- cuda:matmul-forward --------------------------------]
                           |   0.5    |   0.7    |   0.8   |   0.9   |   0.95  |   0.98
1 threads: ----------------------------------------------------------------------------
      torch:dense@vector   |    36.1  |    21.5  |   21.6  |   21.5  |   21.6  |   21.5
      torch:sparse@vector  |  1099.2  |  1289.4  |  775.7  |  327.1  |  285.4  |  274.0

Times are in microseconds (us).

```
</details>

 ---
<details><summary> backward tests (expand for details).
</summary>

- `sparse@sparse`
```
[--------------------------------- cpu:matmul-backward ---------------------------------]
                           |   0.5    |   0.7    |   0.8    |   0.9    |   0.95  |   0.98
1 threads: ------------------------------------------------------------------------------
      torch:dense@dense    |   246.1  |   315.0  |   306.9  |   168.6  |  290.6  |  146.9
      torch:sparse@sparse  |  6417.5  |  4393.7  |  3012.7  |  1029.4  |  908.0  |  650.7

Times are in microseconds (us).

[----------------------------- cuda:matmul-backward -----------------------------]
                           |   0.5   |   0.7   |   0.8   |  0.9   |  0.95  |  0.98
1 threads: -----------------------------------------------------------------------
      torch:dense@dense    |    6.7  |   13.3  |   13.3  |   6.9  |  13.5  |   6.9
      torch:sparse@sparse  |  143.7  |  143.4  |  119.6  |  29.5  |  29.1  |  10.9

Times are in microseconds (us).

```
- `sparse@dense`
```
 [------------------------------ cpu:matmul-backward -------------------------------]
                          |   0.5   |   0.7   |   0.8   |   0.9   |   0.95  |   0.98
1 threads: -------------------------------------------------------------------------
      torch:dense@dense   |  185.9  |  304.8  |  305.8  |  169.9  |  308.7  |  168.4
      torch:sparse@dense  |  407.9  |  345.8  |  274.6  |  114.2  |  163.6  |  230.5

Times are in milliseconds (ms).

[--------------------------- cuda:matmul-backward --------------------------]
                          |  0.5   |  0.7   |  0.8   |  0.9  |  0.95  |  0.98
1 threads: ------------------------------------------------------------------
      torch:dense@dense   |   6.7  |  13.3  |  13.3  |  6.9  |  13.4  |   6.9
      torch:sparse@dense  |  16.7  |  19.0  |  15.1  |  6.3  |   8.2  |  12.7

Times are in milliseconds (ms).

```
</details>

Kindly review this  PR. cc mruberry, ngimel

Pull Request resolved: pytorch#51647

Reviewed By: albanD

Differential Revision: D27007809

Pulled By: mruberry

fbshipit-source-id: 8c1922cb3280027ca5e3eef31bfa20500c548cfd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed Merged open source triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

torch.sparse improvements - tracking issue

7 participants