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

Refactor Compression Doc #3371

Merged
merged 23 commits into from
Feb 25, 2021
Merged

Refactor Compression Doc #3371

merged 23 commits into from
Feb 25, 2021

Conversation

colorjam
Copy link
Contributor

@colorjam colorjam commented Feb 8, 2021

Done:

  1. Move Framework, Customize compressor and AutoTune to advanced.rst.
  2. Refactor Quick Start and Tutorial.
  3. Add Compression References.

@ghost
Copy link

ghost commented Feb 8, 2021

CLA assistant check
All CLA requirements met.

@J-shang J-shang mentioned this pull request Feb 19, 2021
94 tasks
* **op_names**\ : This is to specify by name what operations to be compressed. If this field is omitted, operations will not be filtered by it.
* **exclude**\ : Default is False. If this field is True, it means the operations with specified types and names will be excluded from the compression.

Some other keys are often specific to a certain algorithms, users can refer to `pruning algorithms <./Pruner.rst>`__ and `quantization algorithms <./Quantizer.rst>`__ for the keys allowed by each algorithm.
Copy link
Contributor

Choose a reason for hiding this comment

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

a certain algorithms -> a certain algorithm?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix it

.. code-block:: python

# Save quantized model which is generated by using NNI QAT algorithm
torch.save(model.state_dict(), "quantized_model.pkt")
Copy link
Contributor

Choose a reason for hiding this comment

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

just curious, what is .pkt mean, why not use .pth?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

.pkt means 'Packet Tracer Network Simulation Model'. The reason why I use '.pkt' here is that I think model generated from QAT is simulated model not the real model. Of course we can use .pth here.

Copy link
Contributor

Choose a reason for hiding this comment

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

.pth is be better

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix it

* **op_types**\ : This is to specify what types of operations to be compressed. 'default' means following the algorithm's default setting.
* **op_names**\ : This is to specify by name what operations to be compressed. If this field is omitted, operations will not be filtered by it.
* **exclude**\ : Default is False. If this field is True, it means the operations with specified types and names will be excluded from the compression.
Note that, ``pruner.compress`` simply adds masks on model weights, it does not include fine-tuning logic. If users want to fine tune the compressed model, they need to write the fine tune logic by themselves after ``pruner.compress``.
Copy link
Contributor

Choose a reason for hiding this comment

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

better to add a link to a simple example which fine-tunes the model

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add an example code below.


Then, you can train your model using traditional training approach (e.g., SGD), pruning is applied transparently during the training. Some pruners prune once at the beginning, the following training can be seen as fine-tune. Some pruners prune your model iteratively, the masks are adjusted epoch by epoch during training.
Copy link
Contributor

Choose a reason for hiding this comment

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

better add one or two pruners which are one-shot pruner and interative pruners respectively. Or to add link to allow user to find out by themselves.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I think this quick start just shows the basic usage of the pruning process. More pruners can be found in basic_pruners_torch, so I add the link below.

@QuanluZhang
Copy link
Contributor

@colorjam looks much better than our previous version :)

@colorjam
Copy link
Contributor Author

@quanlu Thanks~ Fix issues according to the comments, please review the latest version.

@@ -1,16 +1,121 @@
Python API Reference of Compression Utilities
=============================================
Compression Reference
Copy link
Contributor

Choose a reason for hiding this comment

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

Model Compression API Reference

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

Export compression result
-------------------------

Export the pruend model
Copy link
Contributor

Choose a reason for hiding this comment

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

pruend?

@J-shang J-shang closed this Feb 25, 2021
@J-shang J-shang reopened this Feb 25, 2021
@QuanluZhang QuanluZhang merged commit a8f0557 into microsoft:master Feb 25, 2021
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.

4 participants