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

[MKLDNN]Enhance Quantization APIs and Tutorial #15448

Merged
merged 29 commits into from
Aug 1, 2019

Conversation

xinyu-intel
Copy link
Contributor

Description

  • Create a MKL-DNN specific user-level api quantize_model_mkldnn which combines fusion and quantization.

  • Enable resnet50_v1b quantized model.

  • Split quantize_model API into three parts to make it flexible for users to integrate quantization flow into their project:
    1)quantize_graph: quantize fp32 model to int8 model w/o calibration and return a collector for collecting calibration information in the next step.
    2)[outside api]: users need only add a few lines together with mod.forward for collecting calibration information.
    3)calib_graph: generate calibrated model based on filled collector.

  • Draft a tutorial to introduce How to quantize custom models for production-level inference with MKL-DNN backend.

@pengzhao-intel @TaoLv @ZhennanQin @ciyongch

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to the relevant JIRA issue created (except PRs with tiny changes)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
  • Code is well-documented:
  • For user-facing API changes, API doc string has been updated.
  • For new C++ functions in header files, their functionalities and arguments are documented.
  • For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
  • Check the API doc at http://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

  • Feature1, tests, (and when applicable, API doc)
  • Feature2, tests, (and when applicable, API doc)

Comments

  • If this change is a backward incompatible change, why must this change be made.
  • Interesting edge cases to note here

@xinyu-intel xinyu-intel requested a review from szha as a code owner July 3, 2019 01:45
@pengzhao-intel
Copy link
Contributor

@anirudh2290 @ThomasDelteil as we discussed in the forum, we post the developer guide for the user who wants to integrate quantization flow into their script.

CC @reminisce @ZhennanQin @ElaineBao

Any suggestion is highly appreciated :)

Update MKLDNN_QUANTIZATION.md
@xinyu-intel
Copy link
Contributor Author

xinyu-intel commented Jul 3, 2019

@pengzhao-intel
Copy link
Contributor

@KellenSunderland please help take a review too :)

@TaoLv
Copy link
Member

TaoLv commented Jul 3, 2019

nit: use lower case in the name of document.

docs/tutorials/mkldnn/mkldnn_quantization.md Outdated Show resolved Hide resolved
docs/tutorials/mkldnn/mkldnn_quantization.md Outdated Show resolved Hide resolved
docs/tutorials/mkldnn/mkldnn_quantization.md Outdated Show resolved Hide resolved
docs/tutorials/mkldnn/mkldnn_quantization.md Outdated Show resolved Hide resolved
docs/tutorials/mkldnn/mkldnn_quantization.md Show resolved Hide resolved
docs/tutorials/mkldnn/mkldnn_quantization.md Show resolved Hide resolved
docs/tutorials/mkldnn/mkldnn_quantization.md Outdated Show resolved Hide resolved
docs/tutorials/mkldnn/mkldnn_quantization.md Outdated Show resolved Hide resolved
docs/tutorials/mkldnn/mkldnn_quantization.md Outdated Show resolved Hide resolved
docs/tutorials/mkldnn/mkldnn_quantization.md Show resolved Hide resolved
@xinyu-intel
Copy link
Contributor Author

@ThomasDelteil Comments addressed, Please take a look at again:)

@roywei
Copy link
Member

roywei commented Jul 8, 2019

@mxnet-label-bot add [MKLDNN, Doc]

@pengzhao-intel
Copy link
Contributor

@aaronmarkham could you help take a review for the new document?

@pengzhao-intel
Copy link
Contributor

@ThomasDelteil Would you mind to take a review again?

@ThomasDelteil
Copy link
Contributor

Will do, at a conference this week, limited bandwidth but next week I'll have some availability to look into quantization again and get back to you on the different email threads as well, apologies for the delay!

@pengzhao-intel
Copy link
Contributor

Will do, at a conference this week, limited bandwidth but next week I'll have some availability to look into quantization again and get back to you on the different email threads as well, apologies for the delay!

Sure :) Have a good trip on AMLC.
Maybe you can bring more amazing ideas to improve the API and usability of quantization flow from the conference :) We're highly appreciated for the inputs and feedbacks.

Thanks in advance.

@karan6181
Copy link
Contributor

@ThomasDelteil Could you please review this PR once you have time? Thanks!

@pengzhao-intel
Copy link
Contributor

@ThomasDelteil do you have a chance to review this week?
We have other improvements in GluonCV which depends on this PR.

@pengzhao-intel
Copy link
Contributor

@ciyongch @ZhennanQin @ElaineBao please take a review and test in local.

@ElaineBao
Copy link
Contributor

docs look good to me.

@pengzhao-intel
Copy link
Contributor

@ThomasDelteil we are going to merge this PR in 24 hours if no further comments since other improvements depend on this.

Copy link
Contributor

@pengzhao-intel pengzhao-intel left a comment

Choose a reason for hiding this comment

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

LGTM

@pengzhao-intel
Copy link
Contributor

Merging now. We're continually improving the quantization flow so any suggestions and feedbacks are highly appreciated.

@pengzhao-intel pengzhao-intel merged commit b3064c5 into apache:master Aug 1, 2019
anirudhacharya pushed a commit to anirudhacharya/mxnet that referenced this pull request Aug 20, 2019
* enhance api and new tutorial

* Update MKLDNN_QUANTIZATION.md

update

* fix lint

* modify pics

* skip test

* add quantize layer in graph

* update

* remove center css flag

* change requantize color

* fix markdown pics

* change to use png

* Update MKLDNN_QUANTIZATION.md

update

* enable ipython script

* fix png

* fix lint

* Update MKLDNN_QUANTIZATION.md

* change title

* trigger

* use lower case

* some typo

* some typo

* use dmlc web data

* trigger

* trigger
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants