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

Merge model compression dev branch to master #1571

Merged
merged 5 commits into from
Oct 9, 2019
Merged

Merge model compression dev branch to master #1571

merged 5 commits into from
Oct 9, 2019

Conversation

liuzhe-lz
Copy link
Contributor

No description provided.

LeonardoWang and others added 4 commits August 28, 2019 16:34
* refactor compression sdk

* bugfix

* bugfix

* update ut
@microsoft microsoft deleted a comment from liuzhe-lz Sep 27, 2019
* update doc

* formatting

* bugfix

* add import to examples
|Name|Brief Introduction of Algorithm|
|---|---|
| [Level Pruner](./Pruner.md#level-pruner) | Pruning the specified ratio on each weight based on absolute values of weights |
| [AGP Pruner](./Pruner.md#agp-pruner) | To prune, or not to prune: exploring the efficacy of pruning for model compression. [Reference Paper](https://arxiv.org/abs/1710.01878)|
Copy link
Contributor

Choose a reason for hiding this comment

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

can you explain the AGP pruner in short sentence?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I dunno how the algorithms works... Maybe @tanglang96 can help?

Copy link
Contributor

Choose a reason for hiding this comment

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

AGP means Automated Gradual Pruning, prune with gradually increasing sparsity while training (given initial sparsity and final sparsity) until the final sparsity reached, the smallest magnitude weights are masked with zeros.

Copy link
Contributor

Choose a reason for hiding this comment

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

update to the doc?

Copy link
Contributor

Choose a reason for hiding this comment

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

@liuzhe-lz better to add this sentence

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems too long. I added "automated gradual pruning".

docs/en_US/Compressor/Overview.md Show resolved Hide resolved

### Usage of user customized compression algorithm

__[TODO]__ ...
Copy link
Contributor

Choose a reason for hiding this comment

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

And how?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In fact we have not considered customized compressor yet...


The interface for customizing quantization algorithm is similar to that of pruning algorithms. The only difference is that `calc_mask` is replaced with `quantize_weight`. `quantize_weight` directly returns the quantized weights rather than mask, because for quantization the quantized weights cannot be obtained by applying mask.

```
Copy link
Member

@squirrelsc squirrelsc Oct 8, 2019

Choose a reason for hiding this comment

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

change to ```python

### Other APIs

Some compression algorithms use epochs to control the progress of compression, and some algorithms need to do something after every minibatch. Therefore, we provide another two APIs for users to invoke. One is `update_epoch`, you can use it as follows:

Copy link
Contributor

Choose a reason for hiding this comment

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

could you explain when the user needs to use 'update_epoch'?

Copy link
Contributor Author

@liuzhe-lz liuzhe-lz Oct 8, 2019

Choose a reason for hiding this comment

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

Added a reference to example compressor using update_epoch. But failed to find an example using step.

>The binary weight masks are updated every ∆t steps as the network is trained to gradually increase the sparsity of the network while allowing the network training steps to recover from any pruning-induced loss in accuracy. In our experience, varying the pruning frequency ∆t between 100 and 1000 training steps had a negligible impact on the final model quality. Once the model achieves the target sparsity sf , the weight masks are no longer updated. The intuition behind this sparsity function in equation

### Usage
You can prune all weight from %0 to 80% sparsity in 10 epoch with the code below.
Copy link
Contributor

Choose a reason for hiding this comment

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

0%?

Copy link
Contributor Author

@liuzhe-lz liuzhe-lz Oct 8, 2019

Choose a reason for hiding this comment

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

Yes, seems that's how the algorithm work.

"""
def __init__(self, config_list):
"""
Configure Args
Copy link
Contributor

Choose a reason for hiding this comment

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

could you follow the docstring format in other tuner...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found compressors' docstring format is different from other modules (like tuner).
But I don't know what format we are using exactly.
@SparkSnail Any idea?

@liuzhe-lz
Copy link
Contributor Author

Updates are going to PR #1590

@liuzhe-lz
Copy link
Contributor Author

Due to failures in our pipeline, the patch PR #1590 is not able to merge in time.
I'll merge this PR first and redirect #1590 to master.

@liuzhe-lz liuzhe-lz merged commit e93d2c2 into master Oct 9, 2019
@liuzhe-lz liuzhe-lz deleted the dev-mc branch November 6, 2019 18:54
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.

7 participants