-
Notifications
You must be signed in to change notification settings - Fork 100
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
sparse benchmarking numbers #303
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8f589a4
update sam script
jcaip 243479c
updated readme with results
jcaip 94c2ecb
fix formatting
jcaip a530f78
cr feedback
jcaip e555fca
more cr feedback
jcaip 6df5456
more cr feedback
jcaip de20761
more cr feedback
jcaip 1f265c4
add code ticks
jcaip 1fbea59
sigfigs
jcaip File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,44 @@ More concretely, we hope to provide tutorials and APIs for both sparse kernels ( | |
2. Recover accuracy loss of pruned model with custom pruning algorthim. | ||
3. Accelerate masked/pruned models on sparsity-supported hardware to realize performance improvements. | ||
|
||
## Success Stories | ||
|
||
#### segment-anything | ||
We applied 2:4 sparsity to accelerate segment-anything, as part of [segment-anything-fast](https://github.com/pytorch-labs/segment-anything-fast). | ||
The results mentioned in the README of the repo compose sparsity with a suite of other inference acceleration techniques. | ||
|
||
From our [benchmarking](https://github.com/pytorch/ao/blob/main/benchmarks/benchmark_sam.py), we see a 1.1x speedup when running with `SEGMENT_ANYTHING_FAST_USE_FLASH_4` enabled. | ||
To reproduce these benchmarks you can run the following command: | ||
|
||
The inference acceleration of semi-structured sparsity depends on the matmul shapes, which is why we don't see additional speedups when applying to all linear layers (attn + mlp) of segment-anything. | ||
We find that accelerating the MLP linear layers provied the most speedups (`lin1`, `lin2`). To repoduce our benchmarks you can run the following command: | ||
|
||
``` | ||
python benchmarks/benchmark_sam.py | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put a direct link to the benchmarks script |
||
``` | ||
|
||
The following benchmarks we run on an A100, with batch_size=32 and `bfloat16` dtype: | ||
|
||
| qkv | proj | lin1 | lin2 | time | memory | img/s | | ||
| ---- | ---- | ---- | ---- | ---- | ------ | ----- | | ||
| None | None | None | None | 1361.73 | 15.81 | 23.50 | | ||
| None | None | sparse (cusparselt) | sparse (cusparselt) | 1245.15 | 15.46 | 25.70 | | ||
| None | None | sparse (cutlass) | sparse (cutlass) | 1251.047651 | 15.41 | 25.59 | | ||
| sparse (cusparselt) | sparse (cusparselt) | sparse (cusparselt) | sparse (cusparselt) | 1265.43 | 12.71 | 25.29| | ||
| sparse (cutlass) | sparse (cutlass) | sparse (cutlass) | sparse (cutlass) | 1274.96 | 12.70 | 25.10 | | ||
|
||
#### BERT | ||
|
||
We were able to accelerate BERT 1.23x on an A100 with a negligible accuracy drop on SQuAD. | ||
For more information about accelerting BERT with semi-sturcutred sparsity, please see our [tutorial](https://pytorch.org/tutorials/advanced/semi_structured_sparse.html?highlight=beta). | ||
|
||
| Metrics | fp16 | 2:4 sparse | delta / speedup | | ||
| --- | --- | --- | --- | | ||
| Exact Match (%) | 78.53 | 78.44 | -0.09 | | ||
| F1 (%) | 86.93 | 86.49 | -0.44 | | ||
| Time (bs=16) | 19.35 | 15.74 | 1.23x | | ||
|
||
|
||
# Design | ||
|
||
Sparsity, like quantization, is an accuracy/performance trade-off, where we care not only about the speedup but also on the accuracy degradation of our architecture optimization technique. | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed that sam fast isn't included in our benchmarks - suggestion is maybe to put a sam folder under benchmarjs with a README on custom dependencies and how to install them or just add a comment above this line as to how people can install sam fast