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

[QUANTIZE] Refactor quantization codebase and fix model accuracy #3543

Merged
merged 8 commits into from
Aug 15, 2019

Conversation

ZihengJiang
Copy link
Contributor

@ZihengJiang ZihengJiang commented Jul 14, 2019

  • Separate quantization code base into different files: partition.cc, annotate.cc, realize.cc
  • Change rewrite_for_vta to extra partition pass and enable it by default
  • Change annotation.force_cast(x) to annotation.cast_hint(x, dtype)
  • Remove qconfig.store_lowbit_output and enable it by default
  • Fixed accuracy of models like mobilenet:
    • resnet18_v1(8-16bit): 69.29%
    • resnet18_v1(8-32bit): 69.29%
    • resnet34_v1: 73.33%
    • resnet50_v1: 74.78%
    • resnet101_v1: 75.66%
    • mobilenetv2_1.0: 66.64%

cc @tqchen @eqy @vinx13 @tmoreau89

@ZihengJiang ZihengJiang changed the title [WIP] Add nightly quantization regression tests [QUANTIZE] Refactor codebase, fix accuracy, add nightly regression tests Jul 19, 2019
@ZihengJiang ZihengJiang changed the title [QUANTIZE] Refactor codebase, fix accuracy, add nightly regression tests [QUANTIZE] Refactor codebase and fix accuracy Jul 19, 2019
@ZihengJiang
Copy link
Contributor Author

After discussing offline with Tianqi, we decide to build the nightly regression tests in another repo.

@ZihengJiang ZihengJiang changed the title [QUANTIZE] Refactor codebase and fix accuracy [QUANTIZE] Refactor quantization codebase and fix model accuracy Jul 19, 2019
@ZihengJiang
Copy link
Contributor Author

@tqchen @eqy @vinx13 @tmoreau89 Could you please help to review this change?

python/tvm/relay/quantize/quantize.py Outdated Show resolved Hide resolved
python/tvm/relay/quantize/quantize.py Outdated Show resolved Hide resolved
python/tvm/relay/quantize/_annotate.py Outdated Show resolved Hide resolved
python/tvm/relay/quantize/_partition.py Show resolved Hide resolved
python/tvm/relay/quantize/_partition.py Show resolved Hide resolved
@eqy
Copy link
Contributor

eqy commented Jul 19, 2019

@ZihengJiang Do you think we we could try to get the calibration PR first? I have to port it over to the new pass infra and I think this is likely more easy to replay on top of calibration than vice-versa.

@ZihengJiang
Copy link
Contributor Author

ZihengJiang commented Jul 19, 2019

@eqy Do you mean this one? #3294
Sure if you have time recently

Copy link
Contributor

@tmoreau89 tmoreau89 left a comment

Choose a reason for hiding this comment

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

LGTM

src/relay/pass/quantize/quantize.h Outdated Show resolved Hide resolved
@tqchen
Copy link
Member

tqchen commented Aug 2, 2019

@ZihengJiang please followup now that #3538 is merged

@tmoreau89
Copy link
Contributor

What is the status on this PR? @tqchen @ZihengJiang

def add_partition_function(ref_call, new_args, ctx):
"""Rewrite function for ewise add for partition"""
if 'cuda' in _target.current_target().keys:
#TODO(wuwei/ziheng) cuda specific rules
Copy link
Contributor Author

@ZihengJiang ZihengJiang Aug 12, 2019

Choose a reason for hiding this comment

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

@vinx13 Since general devices and VTA are okay/required to insert stop_fusion in both side, let's use different rewrite rules for specific target here,

@ZihengJiang ZihengJiang merged commit 7eb1f35 into apache:master Aug 15, 2019
@ZihengJiang ZihengJiang deleted the quantize-lr branch August 15, 2019 09:31
wweic pushed a commit to neo-ai/tvm that referenced this pull request Aug 16, 2019
…che#3543)

* Refactor.

* update

* update

* update

* update

* update

* update
anijain2305 pushed a commit to anijain2305/tvm that referenced this pull request Aug 22, 2019
…che#3543)

* Refactor.

* update

* update

* update

* update

* update

* update
wweic pushed a commit to neo-ai/tvm that referenced this pull request Sep 6, 2019
…che#3543)

* Refactor.

* update

* update

* update

* update

* update

* update
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.

6 participants