Skip to content
This repository was archived by the owner on Sep 18, 2024. It is now read-only.

[Compression] Add quantization tutorial #5454

Merged
merged 13 commits into from
Apr 23, 2023
Merged

Conversation

Bonytu
Copy link
Contributor

@Bonytu Bonytu commented Mar 16, 2023

Description

Test Options

  • fast test
  • full test - HPO
  • full test - NAS
  • full test - compression

Checklist

  • test case
  • doc

How to test

@liuzhe-lz
Copy link
Contributor

@liuzhe-lz liuzhe-lz requested a review from ultmaster March 21, 2023 09:00
@liuzhe-lz liuzhe-lz requested a review from J-shang March 31, 2023 02:39
@@ -21,3 +21,4 @@ matplotlib
git+https://github.com/microsoft/nn-Meter.git#egg=nn_meter
sympy
timm >= 0.5.4
datasets == 2.10.1

Choose a reason for hiding this comment

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

Any particular reason to freeze the version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good suggestion, there is no need to freeze the version. I will modify it.

@Bonytu Bonytu requested review from J-shang and matluster April 13, 2023 06:52

.. cardlinkitem::
:header: Quantize Bert on Task MNLI
:description: An end to end example for how to using NNI to quantize transformer and show the real speedup number
Copy link
Contributor

Choose a reason for hiding this comment

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

can we real speedup?😂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no no no

Quantize BERT on Task GLUE
==========================

Here we show an effective transformer simulated quantization process that NNI team has tried, and users can use NNI to discover better process
Copy link
Contributor

Choose a reason for hiding this comment

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

.


Here we show an effective transformer simulated quantization process that NNI team has tried, and users can use NNI to discover better process

we use the BERT model and the trainer pipeline in the Transformers to do some experiments.
Copy link
Contributor

Choose a reason for hiding this comment

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

We

# .. note::

# Please set ``is_trace`` to ``False`` to fine-tune the BERT model and set ``is_trace`` to ``True``
# When you need to create a traced trainer for model quantization.
Copy link
Contributor

Choose a reason for hiding this comment

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

, when

Copy link
Contributor

Choose a reason for hiding this comment

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

and fine-tuning model can also use a traced trainer.

config_list = [{
'op_types': ['Linear'],
'op_names_re': ['bert.encoder.layer.{}'.format(i) for i in range(12)],
'target_names': ['weight', '_output_'],
Copy link
Contributor

Choose a reason for hiding this comment

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

why not quant input?


if __name__ == "__main__":
fake_quantize()
evaluate()
Copy link
Contributor

Choose a reason for hiding this comment

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

remove if __name__ == "__main__":, this is a ipython style script.

@Bonytu Bonytu requested a review from J-shang April 18, 2023 08:36
Copy link
Contributor

@J-shang J-shang left a comment

Choose a reason for hiding this comment

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

will review this doc after merge

@J-shang J-shang merged commit 0f0d145 into microsoft:master Apr 23, 2023
super-dainiu pushed a commit to super-dainiu/nni that referenced this pull request May 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants