Skip to content
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

quantization aware training pass #3817

Merged
merged 92 commits into from
Jan 13, 2021
Merged

Conversation

daquexian
Copy link
Contributor

包含 quantization aware training 自动插入相关 op 的 pass

@daquexian daquexian marked this pull request as draft November 13, 2020 07:46
@daquexian daquexian added feature system WIP work in progress labels Nov 13, 2020

namespace {

void VerifyQATList(const QATList& amp_list) {
Copy link
Contributor

Choose a reason for hiding this comment

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

void VerifyQATList(const QATList& qat_list) {

@daquexian daquexian marked this pull request as ready for review December 21, 2020 03:03
Signed-off-by: daquexian <daquexian566@gmail.com>
Signed-off-by: daquexian <daquexian566@gmail.com>
Signed-off-by: daquexian <daquexian566@gmail.com>
@daquexian daquexian changed the title [WIP] quantization aware training pass quantization aware training pass Jan 13, 2021
Signed-off-by: daquexian <daquexian566@gmail.com>
@daquexian daquexian force-pushed the quant_aware_training_dqx branch from 047c9d6 to 3832433 Compare January 13, 2021 06:20
@daquexian daquexian requested review from oneflow-ci-bot and removed request for oneflow-ci-bot January 13, 2021 06:24
@daquexian daquexian removed the WIP work in progress label Jan 13, 2021
@oneflow-ci-bot oneflow-ci-bot removed their request for review January 13, 2021 06:27
Signed-off-by: daquexian <daquexian566@gmail.com>
@oneflow-ci-bot oneflow-ci-bot removed their request for review January 13, 2021 08:56
@oneflow-ci-bot oneflow-ci-bot requested review from oneflow-ci-bot and removed request for oneflow-ci-bot January 13, 2021 09:35
Signed-off-by: daquexian <daquexian566@gmail.com>
@oneflow-ci-bot oneflow-ci-bot removed their request for review January 13, 2021 14:54
@oneflow-ci-bot oneflow-ci-bot merged commit a48c6e4 into master Jan 13, 2021
@oneflow-ci-bot oneflow-ci-bot deleted the quant_aware_training_dqx branch January 13, 2021 14:54
liujuncheng pushed a commit that referenced this pull request Jun 3, 2021
* init qat pass

* fix bugs

* add calculate weight scale and zero_point op & unit tests

* clear batch axis of scale and zero_point

* add calculate activation scale and zero_point op & unit tests

* add fake quantization ops & unit tests

* add sbp signature to fake quantization op & improve code style

* imporve unit test speed

* update pass

* add QatConfig

* format

* code clean

* add calculate weight scale and zero_point op & unit tests

* clear batch axis of scale and zero_point

* add calculate activation scale and zero_point op & unit tests

* add fake quantization ops & unit tests

* add sbp signature to fake quantization op & improve code style

* imporve unit test speed

* make changes according to review comments

* rename quantize ops following the pytorch's naming scheme

* change the input zero_point of fake_quantize op to optional

* stop updating moving_min and moving_max after training iteration reaches the given point

* add calculate weight scale and zero_point op & unit tests

* clear batch axis of scale and zero_point

* add calculate activation scale and zero_point op & unit tests

* add fake quantization ops & unit tests

* add sbp signature to fake quantization op & improve code style

* imporve unit test speed

* make changes according to review comments

* rename quantize ops following the pytorch's naming scheme

* change the input zero_point of fake_quantize op to optional

* stop updating moving_min and moving_max after training iteration reaches the given point

* align with latest fake quant ops

Signed-off-by: daquexian <daquexian566@gmail.com>

* optimize CHECK

Signed-off-by: daquexian <daquexian566@gmail.com>

* add multiple devices tests && fix sbp infer error

* fix bugs on mobilenetv2

Signed-off-by: daquexian <daquexian566@gmail.com>

* align with latest fake quant ops

Signed-off-by: daquexian <daquexian566@gmail.com>

* format

Signed-off-by: daquexian <daquexian566@gmail.com>

* add calculate weight scale and zero_point op & unit tests

* clear batch axis of scale and zero_point

* add calculate activation scale and zero_point op & unit tests

* add fake quantization ops & unit tests

* add sbp signature to fake quantization op & improve code style

* imporve unit test speed

* make changes according to review comments

* rename quantize ops following the pytorch's naming scheme

* change the input zero_point of fake_quantize op to optional

* stop updating moving_min and moving_max after training iteration reaches the given point

* add multiple devices tests && fix sbp infer error

* stop udpating moving max and min during the prediction mode

* imporve ReduceMaxMinPerChannel cuda kernel slightly

* align with cfg job_conf

Signed-off-by: daquexian <daquexian566@gmail.com>

* amp_lsit -> op_list

Signed-off-by: daquexian <daquexian566@gmail.com>

* support conv op with bias input

Signed-off-by: daquexian <daquexian566@gmail.com>

* add calculate weight scale and zero_point op & unit tests

* clear batch axis of scale and zero_point

* add calculate activation scale and zero_point op & unit tests

* add fake quantization ops & unit tests

* add sbp signature to fake quantization op & improve code style

* imporve unit test speed

* make changes according to review comments

* rename quantize ops following the pytorch's naming scheme

* change the input zero_point of fake_quantize op to optional

* stop updating moving_min and moving_max after training iteration reaches the given point

* add multiple devices tests && fix sbp infer error

* stop udpating moving max and min during the prediction mode

* imporve ReduceMaxMinPerChannel cuda kernel slightly

* change quantize_to_bit to quantization_bit

* change quantize to quantization

* format

Signed-off-by: daquexian <daquexian566@gmail.com>

* fix bias zero point shape, add tests

Signed-off-by: daquexian <daquexian566@gmail.com>

* set 'training' attr according to job desc

Signed-off-by: daquexian <daquexian566@gmail.com>

* refine tests

Signed-off-by: daquexian <daquexian566@gmail.com>

* polish

Signed-off-by: daquexian <daquexian566@gmail.com>

* reformat

Signed-off-by: daquexian <daquexian566@gmail.com>

* fix cpu test

Signed-off-by: daquexian <daquexian566@gmail.com>

Co-authored-by: Ldpe2G <liangdepeng@gmail.com>
Co-authored-by: oneflow-ci-bot <69100618+oneflow-ci-bot@users.noreply.github.com>
Former-commit-id: a48c6e4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants