-
Notifications
You must be signed in to change notification settings - Fork 4.4k
support multiheadattention int8 #3940
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
Closed
Closed
Conversation
This file contains hidden or 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
…nto ncnn-int8-toml
…nto ncnn-int8-toml
…into support-mha-int8
…into support-mha-int8
Codecov Report
@@ Coverage Diff @@
## master #3940 +/- ##
==========================================
- Coverage 93.84% 93.65% -0.19%
==========================================
Files 721 728 +7
Lines 175071 177009 +1938
==========================================
+ Hits 164291 165778 +1487
- Misses 10780 11231 +451
Continue to review full report at Codecov.
|
…into support-mha-int8
Member
Member
|
close as mha dynamic int8 quantization now supported |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
这是在干啥
支持 mha int8 kernel
速度对比 (wsl2 虚拟机)
1 线程
8 线程
softmax 数值结果对比
备注
需要先处理 PR 3911,我 rebase 一下。
或者直接 review 这个,也是一样的。
精度测试
pytorch fp32 原始模型,完整的 5w 张图
top-1 84.01%
top-5 97.08%
基线:ncnn fp32 原始模型,CPU 推理太慢了只能跑 2000 张
2022-06-28 17:49:46,793 - test - INFO - accuracy_top-1 : 83.55
2022-06-28 17:49:46,799 - test - INFO - accuracy_top-5 : 97.55
量化 conv+mha
2022-06-28 14:26:39,188 - test - INFO - accuracy_top-1 : 83.25
2022-06-28 14:26:39,194 - test - INFO - accuracy_top-5 : 97.65
量化 conv+mha+gemm
2022-06-27 21:05:06,841 - test - INFO - accuracy_top-1 : 82.55
2022-06-27 21:05:06,844 - test - INFO - accuracy_top-5 : 97.45
量化 conv+mha+gemm+bias 校准
2022-06-29 12:31:18,982 - test - INFO - accuracy_top-1 : 82.80
2022-06-29 12:31:18,984 - test - INFO - accuracy_top-5 : 97.55
结论:mha +conv 直接量化会影响 -0.3%; gemm 直接量化会影响 -0.7%,用 bias 校准可以救回来 +0.25%。
naive 整体加速 20%,掉点 -0.75%,模型大小 337MB->86MB