Skip to content

Add exhaustive config option to intmm kernel #1392

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

Merged
merged 5 commits into from
Dec 11, 2024

Conversation

jerryzh168
Copy link
Contributor

@jerryzh168 jerryzh168 commented Dec 9, 2024

Summary:
similar to pytorch/pytorch#126220 we added exhaustive option for int8mm and scaled_mm kernels in torchao

Note that there seems to be native int8mm and scaled_mm support in pytorch: https://github.com/pytorch/pytorch/blob/0610b9730e27d066e26396a2d655ba0d98c2012d/torch/_inductor/kernel/mm.py#L305 for int8mm and https://github.com/pytorch/pytorch/blob/0610b9730e27d066e26396a2d655ba0d98c2012d/torch/_inductor/kernel/mm_scaled.py#L575 for scaled mm maybe we should use that at some point. We can do this later as there are slight differences right now.

Also added all options for autoquant.

Test Plan:

cd benchmarks
TORCHAO_AUTOTUNER_ENABLE=1 python intmm.py --file_path intmm_shapes.csv
TORCHINDUCTOR_MAX_AUTOTUNE_GEMM_SEARCH_SPACE=EXHAUSTIVE TORCHAO_AUTOTUNER_ENABLE=1 python intmm.py --file_path intmm_shapes.csv

ran autoquant-all and TORCHAO_AUTOTUNER_ENABLE=1 on sam:

+cuda,vit_h,32,13646,16,21.97087307115583,45.51480484008789,0.5813941740455395,max-autotune,torch.bfloat16,None,False,True,True,32,154,4928,None,None
+cuda,vit_h,32,52727,65,22.11766063236711,45.2127382105047,0.5811011656545951,max-autotune,torch.bfloat16,autoquant-all,False,True,True,32,154,4928,None,None
+cuda,vit_h,32,52671,64,22.292370883752643,44.858395960423856,0.5626328873979952,max-autotune,torch.bfloat16,autoquant-all,False,True,True,32,154,4928,None,None

TORCHAO_AUTOTUNER_ENABLE=1 give a slight boost.
exhaustive mode is taking too long so it probably makes more sense to use it with https://github.com/pytorch/ao/tree/main/torchao/prototype/quantization/mixed_precision

Reviewers:

Subscribers:

Tasks:

Tags:

Summary:
similar to pytorch/pytorch#126220 we added exhaustive option for int8mm and scaled_mm kernels in torchao

Note that there seems to be native int8mm and scaled_mm support in pytorch:
https://github.com/pytorch/pytorch/blob/0610b9730e27d066e26396a2d655ba0d98c2012d/torch/_inductor/kernel/mm.py#L305 for int8mm and https://github.com/pytorch/pytorch/blob/0610b9730e27d066e26396a2d655ba0d98c2012d/torch/_inductor/kernel/mm_scaled.py#L575 for scaled mm
maybe we should use that at some point.

Test Plan:
```
cd benchmarks
TORCHAO_AUTOTUNER_ENABLE=1 python intmm.py --file_path intmm_shapes.csv
TORCHINDUCTOR_MAX_AUTOTUNE_GEMM_SEARCH_SPACE=EXHAUSTIVE TORCHAO_AUTOTUNER_ENABLE=1 python intmm.py --file_path intmm_shapes.csv
```
Reviewers:

Subscribers:

Tasks:

Tags:
Copy link

pytorch-bot bot commented Dec 9, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/1392

Note: Links to docs will display an error until the docs builds have been completed.

✅ You can merge normally! (1 Unrelated Failure)

As of commit 29d6032 with merge base 8a805d0 (image):

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 9, 2024
@jerryzh168 jerryzh168 added the topic: not user facing Use this tag if you don't want this PR to show up in release notes label Dec 10, 2024
@jerryzh168 jerryzh168 merged commit cac5261 into pytorch:main Dec 11, 2024
17 of 18 checks passed
amdfaa pushed a commit that referenced this pull request Jan 10, 2025
* Add exhaustive config option to intmm kernel

Summary:
similar to pytorch/pytorch#126220 we added exhaustive option for int8mm and scaled_mm kernels in torchao

Note that there seems to be native int8mm and scaled_mm support in pytorch:
https://github.com/pytorch/pytorch/blob/0610b9730e27d066e26396a2d655ba0d98c2012d/torch/_inductor/kernel/mm.py#L305 for int8mm and https://github.com/pytorch/pytorch/blob/0610b9730e27d066e26396a2d655ba0d98c2012d/torch/_inductor/kernel/mm_scaled.py#L575 for scaled mm
maybe we should use that at some point.

Test Plan:
```
cd benchmarks
TORCHAO_AUTOTUNER_ENABLE=1 python intmm.py --file_path intmm_shapes.csv
TORCHINDUCTOR_MAX_AUTOTUNE_GEMM_SEARCH_SPACE=EXHAUSTIVE TORCHAO_AUTOTUNER_ENABLE=1 python intmm.py --file_path intmm_shapes.csv
```
Reviewers:

Subscribers:

Tasks:

Tags:

* remove unused

* enable all autoquant qtensor

* guard float8 qtensor subclass

* guard exhaustive config torch version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. topic: not user facing Use this tag if you don't want this PR to show up in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants