Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[Feature] Add oneDNN support for interleaved_matmul_selfatt_* operators (fp32/int8) #20163

Merged
merged 13 commits into from
Apr 20, 2021

Conversation

bgawrych
Copy link
Contributor

Description

This change adds oneDNN support for two operators:

  • _contrib_interleaved_matmul_selfatt_qk
  • _contrib_interleaved_matmul_selfatt_valatt

Both operators will be used when backend MKLDNN/MKLDNN_QUANTIZE will be chosen - there is no change in terms of performance between MKL fp32 vs. oneDNN fp32, but the main advantage is utilizing int8 data type

10 iterations of BERT-Large (gluon-nlp v0.10.x) [Intel(R) Core(TM) i9-9940X CPU @ 3.30GHz]:

MKL implementation (fp32 as int8 is not supported):
image

oneDNN implementation (int8):
image

_contrib_interleaved_matmul_selfatt_qk => _sg_mkldnn_selfatt_qk
_contrib_interleaved_matmul_selfatt_qk => _sg_mkldnn_selfatt_valatt

We can observe that this change positively influenced other operators as there is less dequantization/quantization overhead and memory reorders

Great contribution of @grygielski to this change

Checklist

Essentials

  • PR's title starts with a category (e.g. [BUGFIX], [MODEL], [TUTORIAL], [FEATURE], [DOC], etc)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage

@mxnet-bot
Copy link

Hey @bgawrych , Thanks for submitting the PR
All tests are already queued to run once. If tests fail, you can trigger one or more tests again with the following commands:

  • To trigger all jobs: @mxnet-bot run ci [all]
  • To trigger specific jobs: @mxnet-bot run ci [job1, job2]

CI supported jobs: [unix-cpu, clang, unix-gpu, windows-cpu, centos-gpu, website, centos-cpu, sanity, miscellaneous, windows-gpu, edge]


Note:
Only following 3 categories can trigger CI :PR Author, MXNet Committer, Jenkins Admin.
All CI tests must pass before the PR can be merged.

@lanking520 lanking520 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-awaiting-testing PR is reviewed and waiting CI build and test labels Apr 14, 2021
@lanking520 lanking520 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels Apr 15, 2021
@lanking520 lanking520 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels Apr 15, 2021
@bgawrych
Copy link
Contributor Author

@mxnet-bot run ci [windows-cpu]

@mxnet-bot
Copy link

Jenkins CI successfully triggered : [windows-cpu]

@lanking520 lanking520 added pr-awaiting-testing PR is reviewed and waiting CI build and test and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels Apr 15, 2021
@lanking520 lanking520 added the pr-awaiting-review PR is waiting for code review label Apr 15, 2021
Copy link
Contributor

@sfraczek sfraczek left a comment

Choose a reason for hiding this comment

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

lgtm

@bgawrych
Copy link
Contributor Author

@szha Can we merge it?

@szha szha merged commit 16d1da9 into apache:v1.x Apr 20, 2021
@szha
Copy link
Member

szha commented Apr 20, 2021

@bgawrych thanks for the contribution

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pr-awaiting-review PR is waiting for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants