[Docs&Feature] Prepare for checkouting default branch and releasing new version (#518)
* prepare for checkout default branch * update README.md and model zoo * update installation.md and update dev-1.x links * update README_zh-CN * add changelog * update ci config * update some links in quantization readme * update quantization user guide * update calibrate_dataloader * add interface pop_rewriter_function_recordpull/521/head
parent
91663815fe
commit
d4764e714e
|
@ -26,7 +26,7 @@ workflows:
|
|||
tools/.* lint_only false
|
||||
configs/.* lint_only false
|
||||
.circleci/.* lint_only false
|
||||
base-revision: dev-1.x
|
||||
base-revision: main
|
||||
# this is the path of the configuration we should trigger once
|
||||
# path filtering and pipeline parameter value updates are
|
||||
# complete. In this case, we are using the parent dynamic
|
||||
|
|
|
@ -67,10 +67,10 @@ jobs:
|
|||
pip install git+https://github.com/open-mmlab/mmengine.git@main
|
||||
pip install -U openmim
|
||||
mim install 'mmcv >= 2.0.0rc1'
|
||||
pip install git+https://github.com/open-mmlab/mmclassification.git@dev-1.x
|
||||
pip install git+https://github.com/open-mmlab/mmdetection.git@dev-3.x
|
||||
pip install git+https://github.com/open-mmlab/mmsegmentation.git@dev-1.x
|
||||
python -m pip install git+ssh://git@github.com/open-mmlab/mmpose.git@dev-1.x
|
||||
pip install git+https://github.com/open-mmlab/mmpretrain.git@mmcls-1.x
|
||||
pip install git+https://github.com/open-mmlab/mmdetection.git@main
|
||||
pip install git+https://github.com/open-mmlab/mmsegmentation.git@main
|
||||
python -m pip install git+ssh://git@github.com/open-mmlab/mmpose.git@main
|
||||
pip install -r requirements.txt
|
||||
- run:
|
||||
name: Build and install
|
||||
|
@ -139,7 +139,7 @@ workflows:
|
|||
filters:
|
||||
branches:
|
||||
ignore:
|
||||
- dev-1.x
|
||||
- main
|
||||
- 1.x
|
||||
pr_stage_test:
|
||||
when:
|
||||
|
@ -150,7 +150,7 @@ workflows:
|
|||
filters:
|
||||
branches:
|
||||
ignore:
|
||||
- dev-1.x
|
||||
- main
|
||||
- build_cpu:
|
||||
name: minimum_version_cpu
|
||||
torch: 1.8.1
|
||||
|
@ -190,4 +190,4 @@ workflows:
|
|||
filters:
|
||||
branches:
|
||||
only:
|
||||
- dev-1.x
|
||||
- main
|
||||
|
|
50
README.md
50
README.md
|
@ -21,7 +21,7 @@
|
|||
<!--算法库 Badges-->
|
||||
|
||||
[](https://pypi.org/project/mmrazor)
|
||||
[](https://mmrazor.readthedocs.io/en/quantize/)
|
||||
[](https://mmrazor.readthedocs.io/en/main/)
|
||||
[](https://github.com/open-mmlab/mmrazor/actions)
|
||||
[](https://codecov.io/gh/open-mmlab/mmrazor)
|
||||
[](https://github.com/open-mmlab/mmrazor/blob/master/LICENSE)
|
||||
|
@ -32,9 +32,9 @@
|
|||
|
||||
<!--Note:请根据各算法库自身情况设置项目和链接-->
|
||||
|
||||
[📘Documentation](https://mmrazor.readthedocs.io/en/quantize/) |
|
||||
[🛠️Installation](https://mmrazor.readthedocs.io/en/quantize/get_started/installation.html) |
|
||||
[👀Model Zoo](https://mmrazor.readthedocs.io/en/quantize/get_started/model_zoo.html) |
|
||||
[📘Documentation](https://mmrazor.readthedocs.io/en/main/) |
|
||||
[🛠️Installation](https://mmrazor.readthedocs.io/en/main/get_started/installation.html) |
|
||||
[👀Model Zoo](https://mmrazor.readthedocs.io/en/main/get_started/model_zoo.html) |
|
||||
[🤔Reporting Issues](https://github.com/open-mmlab/mmrazor/issues/new/choose)
|
||||
|
||||
</div>
|
||||
|
@ -86,22 +86,23 @@ Major features:
|
|||
|
||||
With better modular design, developers can implement new model compression algorithms with only a few codes, or even by simply modifying config files.
|
||||
|
||||
Below is an overview of MMRazor's design and implementation, please refer to [tutorials](https://mmrazor.readthedocs.io/en/quantize/get_started/overview.html) for more details.
|
||||
About MMRazor's design and implementation, please refer to [tutorials](https://mmrazor.readthedocs.io/en/main/get_started/overview.html) for more details.
|
||||
|
||||
<div align="center">
|
||||
<img src="resources/design_and_implement.png" style="zoom:100%"/>
|
||||
</div>
|
||||
<br />
|
||||
## Latest Updates
|
||||
|
||||
## What's new
|
||||
**The default branch is now `main` and the code on the branch has been upgraded to v1.0.0. The old `master` branch code now exists on the 0.x branch**
|
||||
|
||||
MMRazor v1.0.0rc0 was released in 1/9/2022.
|
||||
MMRazor v1.0.0 was released in 2023-4-18, Major updates from 1.0.0rc2 include:
|
||||
|
||||
Please refer to [changelog.md](/docs/en/notes/changelog.md) for more details and other release history.
|
||||
1. MMRazor quantization is released.
|
||||
2. Add a new pruning algorithm named GroupFisher.
|
||||
3. Support distilling rtmdet with MMRazor.
|
||||
|
||||
To know more about the updates in MMRazor 1.0, please refer to [Changelog](https://mmrazor.readthedocs.io/en/main/notes/changelog.html) for more details!
|
||||
|
||||
## Benchmark and model zoo
|
||||
|
||||
Results and models are available in the [model zoo](/docs/en/get_started/model_zoo.md).
|
||||
Results and models are available in the [model zoo](https://mmrazor.readthedocs.io/en/main/get_started/model_zoo.html).
|
||||
|
||||
Supported algorithms:
|
||||
|
||||
|
@ -121,6 +122,12 @@ Supported algorithms:
|
|||
|
||||
- [x] [AutoSlim(NeurIPS'2019)](/configs/pruning/mmcls/autoslim)
|
||||
|
||||
- [x] [L1-norm](/configs/pruning/mmcls/l1-norm)
|
||||
|
||||
- [x] [Group Fisher](/configs/pruning/base/group_fisher)
|
||||
|
||||
- [x] [DMCP](/configs/pruning/mmcls/dmcp)
|
||||
|
||||
</details>
|
||||
|
||||
<details open>
|
||||
|
@ -156,20 +163,31 @@ Supported algorithms:
|
|||
|
||||
</details>
|
||||
|
||||
<details open>
|
||||
<summary>Quantization</summary>
|
||||
|
||||
- [x] [PTQ](/configs/quantization/ptq/base)
|
||||
|
||||
- [x] [QAT](/configs/quantization/qat/base)
|
||||
|
||||
- [x] [LSQ](/configs/quantization/qat/lsq)
|
||||
|
||||
</details>
|
||||
|
||||
## Installation
|
||||
|
||||
MMRazor depends on [PyTorch](https://pytorch.org/), [MMCV](https://github.com/open-mmlab/mmcv) and [MMEngine](https://github.com/open-mmlab/mmengine).
|
||||
|
||||
Please refer to [installation.md](/docs/en/get_started/installation.md) for more detailed instruction.
|
||||
Please refer to [installation.md](https://mmrazor.readthedocs.io/en/main/get_started/installation.html) for more detailed instruction.
|
||||
|
||||
## Getting Started
|
||||
|
||||
Please refer to [user guides](https://mmrazor.readthedocs.io/en/quantize/user_guides/index.html) for the basic usage of MMRazor. There are also [advanced guides](https://mmrazor.readthedocs.io/en/quantize/advanced_guides/index.html):
|
||||
Please refer to [user guides](https://mmrazor.readthedocs.io/en/main/user_guides/index.html) for the basic usage of MMRazor. There are also [advanced guides](https://mmrazor.readthedocs.io/en/main/advanced_guides/index.html):
|
||||
|
||||
## Contributing
|
||||
|
||||
We appreciate all contributions to improve MMRazor.
|
||||
Please refer to [CONTRUBUTING.md](/docs/en/notes/contribution_guide.md) for the contributing guideline.
|
||||
Please refer to [CONTRUBUTING.md](https://mmrazor.readthedocs.io/en/main/notes/contribution_guide.html) for the contributing guideline.
|
||||
|
||||
## Acknowledgement
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<!--算法库 Badges-->
|
||||
|
||||
[](https://pypi.org/project/mmrazor)
|
||||
[](https://mmrazor.readthedocs.io/en/latest/)
|
||||
[](https://mmrazor.readthedocs.io/en/main/)
|
||||
[](https://github.com/open-mmlab/mmrazor/actions)
|
||||
[](https://codecov.io/gh/open-mmlab/mmrazor)
|
||||
[](https://github.com/open-mmlab/mmrazor/blob/master/LICENSE)
|
||||
|
@ -32,9 +32,9 @@
|
|||
|
||||
<!--Note:请根据各算法库自身情况设置项目和链接-->
|
||||
|
||||
[📘使用文档](https://mmrazor.readthedocs.io/) |
|
||||
[🛠️安装教程](https://mmrazor.readthedocs.io/en/latest/get_started.html) |
|
||||
[👀模型库](https://mmrazor.readthedocs.io/en/latest/model_zoo.html) |
|
||||
[📘使用文档](https://mmrazor.readthedocs.io/en/main/) |
|
||||
[🛠️安装教程](https://mmrazor.readthedocs.io/en/main/get_started/installation.html) |
|
||||
[👀👀模型库](https://mmrazor.readthedocs.io/en/main/get_started/model_zoo.html) |
|
||||
[🤔报告问题](https://github.com/open-mmlab/mmrazor/issues/new/choose)
|
||||
|
||||
</div>
|
||||
|
@ -54,7 +54,7 @@ MMRazor是一个可用于模型瘦身和AutoML的模型压缩工具箱,包含
|
|||
- 网络结构搜索 (NAS)
|
||||
- 模型剪枝
|
||||
- 知识蒸馏 (KD)
|
||||
- 量化 (下个版本发布)
|
||||
- 量化
|
||||
|
||||
MMRazor是[OpenMMLab](https://openmmlab.com/)项目的一部分。
|
||||
|
||||
|
@ -72,12 +72,11 @@ MMRazor是[OpenMMLab](https://openmmlab.com/)项目的一部分。
|
|||
|
||||
得益于更好的模块化设计,开发者仅用修改少量代码,甚至只用修改配置文件即可实现新的轻量化算法。
|
||||
|
||||
下面是MMRazor设计和实现的概括图, 如果想了解更多的细节,请参考 [tutorials](/docs/en/tutorials/Tutorial_1_overview.md)。
|
||||
关于MMRazor设计和实现的概括图, 如果想了解更多的细节,请参考 [tutorials](/docs/en/tutorials/Tutorial_1_overview.md)。
|
||||
|
||||
<div align="center">
|
||||
<img src="resources/design_and_implement.png" style="zoom:100%"/>
|
||||
</div>
|
||||
<br />
|
||||
## 近期更新
|
||||
|
||||
**默认分支目前为 main,且分支上的代码已经切换到 v1.0.0 版本。旧版 master 分支的代码现存在 0.x 分支上**
|
||||
|
||||
## 更新日志
|
||||
|
||||
|
@ -85,7 +84,7 @@ MMRazor v0.3.1 版本已经在 2022.5.4 发布。
|
|||
|
||||
## 基准测试和模型库
|
||||
|
||||
测试结果可以在 [模型库](docs/en/model_zoo.md) 中找到.
|
||||
测试结果可以在 [模型库](https://mmrazor.readthedocs.io/en/main/get_started/model_zoo.html) 中找到.
|
||||
|
||||
已经支持的算法:
|
||||
|
||||
|
@ -99,37 +98,69 @@ Neural Architecture Search
|
|||
|
||||
Pruning
|
||||
|
||||
- [x] [AutoSlim(NeurIPS'2019)](/configs/pruning/autoslim)
|
||||
- [x] [AutoSlim(NeurIPS'2019)](/configs/pruning/mmcls/autoslim)
|
||||
|
||||
- [x] [L1-norm](/configs/pruning/mmcls/l1-norm)
|
||||
|
||||
- [x] [Group Fisher](/configs/pruning/base/group_fisher)
|
||||
|
||||
- [x] [DMCP](/configs/pruning/mmcls/dmcp)
|
||||
|
||||
Knowledge Distillation
|
||||
|
||||
- [x] [CWD(ICCV'2021)](/configs/distill/cwd)
|
||||
- [x] [CWD(ICCV'2021)](/configs/distill/mmdet/cwd)
|
||||
|
||||
- [x] [WSLD(ICLR'2021)](/configs/distill/wsld)
|
||||
- [x] [WSLD(ICLR'2021)](/configs/distill/mmcls/wsld)
|
||||
|
||||
- [x] [ABLoss](/configs/distill/mmcls/abloss)
|
||||
|
||||
- [x] [BYOT](/configs/distill/mmcls/byot)
|
||||
|
||||
- [x] [DAFL](/configs/distill/mmcls/dafl)
|
||||
|
||||
- [x] [DFAD](/configs/distill/mmcls/dfad)
|
||||
|
||||
- [x] [DKD](/configs/distill/mmcls/dkd)
|
||||
|
||||
- [x] [Factor Transfer](/configs/distill/mmcls/factor_transfer)
|
||||
|
||||
- [x] [FitNets](/configs/distill/mmcls/fitnets)
|
||||
|
||||
- [x] [KD](/configs/distill/mmcls/kd)
|
||||
|
||||
- [x] [OFD](/configs/distill/mmcls/ofd)
|
||||
|
||||
- [x] [RKD](/configs/distill/mmcls/rkd)
|
||||
|
||||
- [x] [ZSKT](/configs/distill/mmcls/zskt)
|
||||
|
||||
- [x] [FBKD](/configs/distill/mmdet/fbkd)
|
||||
|
||||
<details open>
|
||||
<summary>Quantization</summary>
|
||||
|
||||
- [x] [PTQ](/configs/quantization/ptq/base)
|
||||
|
||||
- [x] [QAT](/configs/quantization/qat/base)
|
||||
|
||||
- [x] [LSQ](/configs/quantization/qat/lsq)
|
||||
|
||||
</details>
|
||||
|
||||
## 安装
|
||||
|
||||
MMRazor 依赖 [PyTorch](https://pytorch.org/) 和 [MMCV](https://github.com/open-mmlab/mmcv)。
|
||||
|
||||
请参考[get_started.md](/docs/en/get_started.md)获取更详细的安装指南。
|
||||
请参考[安装教程](https://mmrazor.readthedocs.io/en/main/get_started/installation.html)获取更详细的安装指南。
|
||||
|
||||
## 快速入门
|
||||
|
||||
请参考 [get_started.md](/docs/en/get_started.md) 学习 MMRazor 的基本使用。 我们也提供了一些进阶教程:
|
||||
|
||||
- [overview](/docs/en/tutorials/Tutorial_1_overview.md)
|
||||
- [learn about configs](/docs/en/tutorials/Tutorial_2_learn_about_configs.md)
|
||||
- [customize architectures](/docs/en/tutorials/Tutorial_3_customize_architectures.md)
|
||||
- [customize nas algorithms](/docs/en/tutorials/Tutorial_4_customize_nas_algorithms.md)
|
||||
- [customize pruning algorithms](/docs/en/tutorials/Tutorial_5_customize_pruning_algorithms.md)
|
||||
- [customize kd algorithms](/docs/en/tutorials/Tutorial_6_customize_kd_algorithms.md)
|
||||
- [customize mixed algorithms with our algorithm_components](/docs/en/tutorials/Tutorial_7_customize_mixed_algorithms_with_out_algorithms_components.md)
|
||||
- [apply existing algorithms to other existing tasks](/docs/en/tutorials/Tutorial_8_apply_existing_algorithms_to_new_tasks.md)
|
||||
请参考 [用户指引](https://mmrazor.readthedocs.io/en/main/user_guides/index.html) 学习 MMRazor 的基本使用。 我们也提供了一些[进阶教程](https://mmrazor.readthedocs.io/en/main/advanced_guides/index.html):
|
||||
|
||||
## 贡献指南
|
||||
|
||||
我们感谢所有的贡献者为改进和提升 MMRazor 所作出的努力。
|
||||
请参考[贡献指南](/.github/CONTRIBUTING.md)来了解参与项目贡献的相关指引。
|
||||
请参考[贡献指南](https://mmrazor.readthedocs.io/en/main/notes/contribution_guide.html)来了解参与项目贡献的相关指引。
|
||||
|
||||
## 致谢
|
||||
|
||||
|
|
|
@ -34,6 +34,6 @@ deploy_cfg = dict(
|
|||
]),
|
||||
function_record_to_pop=[
|
||||
'mmcls.models.classifiers.ImageClassifier.forward',
|
||||
'mmcls.models.classifiers.BaseClassifier.forward'
|
||||
'mmcls.models.classifiers.BaseClassifier.forward', 'torch.cat'
|
||||
],
|
||||
)
|
||||
|
|
|
@ -53,5 +53,6 @@ deploy_cfg = dict(
|
|||
function_record_to_pop=[
|
||||
'mmdet.models.detectors.single_stage.SingleStageDetector.forward',
|
||||
'mmdet.models.detectors.two_stage.TwoStageDetector.forward',
|
||||
'mmdet.models.detectors.single_stage_instance_seg.SingleStageInstanceSegmentor.forward' # noqa: E501
|
||||
'mmdet.models.detectors.single_stage_instance_seg.SingleStageInstanceSegmentor.forward', # noqa: E501
|
||||
'torch.cat'
|
||||
])
|
||||
|
|
|
@ -56,4 +56,4 @@ python tools/ptq.py ${CONFIG}
|
|||
python tools/test.py ${CONFIG} ${CKPT}
|
||||
```
|
||||
|
||||
For more details, please refer to [Quantization User Guide](mmrazor/docs/en/user_guides/quantization_user_guide.md)
|
||||
For more details, please refer to [Quantization User Guide](https://mmrazor.readthedocs.io/en/main/user_guides/quantization_user_guide.html)
|
||||
|
|
|
@ -3,11 +3,11 @@ _base_ = [
|
|||
'../../deploy_cfgs/mmcls/classification_openvino_dynamic-224x224.py'
|
||||
]
|
||||
|
||||
val_dataloader = dict(batch_size=32)
|
||||
_base_.val_dataloader.batch_size = 32
|
||||
|
||||
test_cfg = dict(
|
||||
type='mmrazor.PTQLoop',
|
||||
calibrate_dataloader=val_dataloader,
|
||||
calibrate_dataloader=_base_.val_dataloader,
|
||||
calibrate_steps=32,
|
||||
)
|
||||
|
||||
|
|
|
@ -3,11 +3,11 @@ _base_ = [
|
|||
'../../deploy_cfgs/mmcls/classification_openvino_dynamic-224x224.py'
|
||||
]
|
||||
|
||||
val_dataloader = dict(batch_size=32)
|
||||
_base_.val_dataloader.batch_size = 32
|
||||
|
||||
test_cfg = dict(
|
||||
type='mmrazor.PTQLoop',
|
||||
calibrate_dataloader=val_dataloader,
|
||||
calibrate_dataloader=_base_.val_dataloader,
|
||||
calibrate_steps=32,
|
||||
)
|
||||
|
||||
|
|
|
@ -3,11 +3,11 @@ _base_ = [
|
|||
'../../deploy_cfgs/mmcls/classification_openvino_dynamic-224x224.py'
|
||||
]
|
||||
|
||||
val_dataloader = dict(batch_size=32)
|
||||
_base_.val_dataloader.batch_size = 32
|
||||
|
||||
test_cfg = dict(
|
||||
type='mmrazor.PTQLoop',
|
||||
calibrate_dataloader=val_dataloader,
|
||||
calibrate_dataloader=_base_.val_dataloader,
|
||||
calibrate_steps=32,
|
||||
)
|
||||
|
||||
|
|
|
@ -3,11 +3,11 @@ _base_ = [
|
|||
'../../deploy_cfgs/mmdet/detection_openvino_dynamic-800x1344.py'
|
||||
]
|
||||
|
||||
val_dataloader = dict(batch_size=32)
|
||||
_base_.val_dataloader.batch_size = 32
|
||||
|
||||
test_cfg = dict(
|
||||
type='mmrazor.PTQLoop',
|
||||
calibrate_dataloader=val_dataloader,
|
||||
calibrate_dataloader=_base_.val_dataloader,
|
||||
calibrate_steps=32,
|
||||
)
|
||||
|
||||
|
|
|
@ -3,11 +3,11 @@ _base_ = [
|
|||
'../../deploy_cfgs/mmdet/detection_openvino_dynamic-800x1344.py'
|
||||
]
|
||||
|
||||
val_dataloader = dict(batch_size=32)
|
||||
_base_.val_dataloader.batch_size = 32
|
||||
|
||||
test_cfg = dict(
|
||||
type='mmrazor.PTQLoop',
|
||||
calibrate_dataloader=val_dataloader,
|
||||
calibrate_dataloader=_base_.val_dataloader,
|
||||
calibrate_steps=32,
|
||||
)
|
||||
|
||||
|
|
|
@ -3,11 +3,11 @@ _base_ = [
|
|||
'../../deploy_cfgs/mmcls/classification_tensorrt-int8-explicit_dynamic-224x224.py' # noqa: E501
|
||||
]
|
||||
|
||||
val_dataloader = dict(batch_size=32)
|
||||
_base_.val_dataloader.batch_size = 32
|
||||
|
||||
test_cfg = dict(
|
||||
type='mmrazor.PTQLoop',
|
||||
calibrate_dataloader=val_dataloader,
|
||||
calibrate_dataloader=_base_.val_dataloader,
|
||||
calibrate_steps=32,
|
||||
)
|
||||
|
||||
|
|
|
@ -3,11 +3,11 @@ _base_ = [
|
|||
'../../deploy_cfgs/mmcls/classification_tensorrt-int8-explicit_dynamic-224x224.py' # noqa: E501
|
||||
]
|
||||
|
||||
val_dataloader = dict(batch_size=32)
|
||||
_base_.val_dataloader.batch_size = 32
|
||||
|
||||
test_cfg = dict(
|
||||
type='mmrazor.PTQLoop',
|
||||
calibrate_dataloader=val_dataloader,
|
||||
calibrate_dataloader=_base_.val_dataloader,
|
||||
calibrate_steps=32,
|
||||
)
|
||||
|
||||
|
|
|
@ -3,11 +3,11 @@ _base_ = [
|
|||
'../../deploy_cfgs/mmcls/classification_tensorrt-int8-explicit_dynamic-224x224.py' # noqa: E501
|
||||
]
|
||||
|
||||
val_dataloader = dict(batch_size=32)
|
||||
_base_.val_dataloader.batch_size = 32
|
||||
|
||||
test_cfg = dict(
|
||||
type='mmrazor.PTQLoop',
|
||||
calibrate_dataloader=val_dataloader,
|
||||
calibrate_dataloader=_base_.val_dataloader,
|
||||
calibrate_steps=32,
|
||||
)
|
||||
|
||||
|
|
|
@ -3,11 +3,11 @@ _base_ = [
|
|||
'../../deploy_cfgs/mmdet/detection_tensorrt-int8-explicit_dynamic-320x320-1344x1344.py' # noqa: E501
|
||||
]
|
||||
|
||||
val_dataloader = dict(batch_size=32)
|
||||
_base_.val_dataloader.batch_size = 32
|
||||
|
||||
test_cfg = dict(
|
||||
type='mmrazor.PTQLoop',
|
||||
calibrate_dataloader=val_dataloader,
|
||||
calibrate_dataloader=_base_.val_dataloader,
|
||||
calibrate_steps=32,
|
||||
)
|
||||
|
||||
|
|
|
@ -3,11 +3,11 @@ _base_ = [
|
|||
'../../deploy_cfgs/mmdet/detection_tensorrt-int8-explicit_dynamic-320x320-1344x1344.py' # noqa: E501
|
||||
]
|
||||
|
||||
val_dataloader = dict(batch_size=32)
|
||||
_base_.val_dataloader.batch_size = 32
|
||||
|
||||
test_cfg = dict(
|
||||
type='mmrazor.PTQLoop',
|
||||
calibrate_dataloader=val_dataloader,
|
||||
calibrate_dataloader=_base_.val_dataloader,
|
||||
calibrate_steps=32,
|
||||
)
|
||||
|
||||
|
|
|
@ -42,4 +42,4 @@ python tools/train.py ${CONFIG}
|
|||
python tools/test.py ${CONFIG} ${CKPT}
|
||||
```
|
||||
|
||||
For more details, please refer to [Quantization User Guide](mmrazor/docs/en/user_guides/quantization_user_guide.md)
|
||||
For more details, please refer to [Quantization User Guide](https://mmrazor.readthedocs.io/en/main/user_guides/quantization_user_guide.html)
|
||||
|
|
|
@ -43,4 +43,4 @@ python tools/train.py ${CONFIG}
|
|||
python tools/test.py ${CONFIG} ${CKPT}
|
||||
```
|
||||
|
||||
For more details, please refer to [Quantization User Guide](mmrazor/docs/en/user_guides/quantization_user_guide.md)
|
||||
For more details, please refer to [Quantization User Guide](https://mmrazor.readthedocs.io/en/main/user_guides/quantization_user_guide.html)
|
||||
|
|
|
@ -108,7 +108,7 @@ architecture = _base_.model
|
|||
- Use your customized model as below, which is an example of defining a VGG model as our architecture.
|
||||
|
||||
```{note}
|
||||
How to customize architectures can refer to our tutorial: [Customize Architectures](https://mmrazor.readthedocs.io/en/dev-1.x/advanced_guides/customize_architectures.html).
|
||||
How to customize architectures can refer to our tutorial: [Customize Architectures](https://mmrazor.readthedocs.io/en/main/advanced_guides/customize_architectures.html).
|
||||
```
|
||||
|
||||
```Python
|
||||
|
@ -262,12 +262,12 @@ Please refer to our tutorials about how to customize different algorithms for mo
|
|||
|
||||
1. NAS
|
||||
|
||||
[Customize NAS algorithms](https://mmrazor.readthedocs.io/en/dev-1.x/advanced_guides/customize_nas_algorithms.html)
|
||||
[Customize NAS algorithms](https://mmrazor.readthedocs.io/en/main/advanced_guides/customize_nas_algorithms.html)
|
||||
|
||||
2. Pruning
|
||||
|
||||
[Customize Pruning algorithms](https://mmrazor.readthedocs.io/en/dev-1.x/advanced_guides/customize_pruning_algorithms.html)
|
||||
[Customize Pruning algorithms](https://mmrazor.readthedocs.io/en/main/advanced_guides/customize_pruning_algorithms.html)
|
||||
|
||||
3. Distill
|
||||
|
||||
[Customize KD algorithms](https://mmrazor.readthedocs.io/en/dev-1.x/advanced_guides/customize_kd_algorithms.html)
|
||||
[Customize KD algorithms](https://mmrazor.readthedocs.io/en/main/advanced_guides/customize_kd_algorithms.html)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Apply existing algorithms to new tasks
|
||||
|
||||
Here we show how to apply existing algorithms to other tasks with an example of [SPOS ](https://github.com/open-mmlab/mmrazor/tree/dev-1.x/configs/nas/mmcls/spos)& [DetNAS](https://github.com/open-mmlab/mmrazor/tree/dev-1.x/configs/nas/mmdet/detnas).
|
||||
Here we show how to apply existing algorithms to other tasks with an example of [SPOS ](https://github.com/open-mmlab/mmrazor/tree/main/configs/nas/mmcls/spos)& [DetNAS](https://github.com/open-mmlab/mmrazor/tree/main/configs/nas/mmdet/detnas).
|
||||
|
||||
> SPOS: Single Path One-Shot NAS for classification
|
||||
>
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
# Customize mixed algorithms
|
||||
|
||||
Here we show how to customize mixed algorithms with our algorithm components. We take [AutoSlim ](https://github.com/open-mmlab/mmrazor/tree/dev-1.x/configs/pruning/mmcls/autoslim)as an example.
|
||||
Here we show how to customize mixed algorithms with our algorithm components. We take [AutoSlim ](https://github.com/open-mmlab/mmrazor/tree/main/configs/pruning/mmcls/autoslim)as an example.
|
||||
|
||||
```{note}
|
||||
**Why is AutoSlim a mixed algorithm?**
|
||||
|
||||
In [AutoSlim](https://github.com/open-mmlab/mmrazor/tree/dev-1.x/configs/pruning/mmcls/autoslim), the sandwich rule and the inplace distillation will be introduced to enhance the training process, which is called as the slimmable training. The sandwich rule means that we train the model at smallest width, largest width and (n − 2) random widths, instead of n random widths. And the inplace distillation means that we use the predicted label of the model at the largest width as the training label for other widths, while for the largest width we use ground truth. So both the KD algorithm and the pruning algorithm are used in [AutoSlim](https://github.com/open-mmlab/mmrazor/tree/dev-1.x/configs/pruning/mmcls/autoslim).
|
||||
In [AutoSlim](https://github.com/open-mmlab/mmrazor/tree/main/configs/pruning/mmcls/autoslim), the sandwich rule and the inplace distillation will be introduced to enhance the training process, which is called as the slimmable training. The sandwich rule means that we train the model at smallest width, largest width and (n − 2) random widths, instead of n random widths. And the inplace distillation means that we use the predicted label of the model at the largest width as the training label for other widths, while for the largest width we use ground truth. So both the KD algorithm and the pruning algorithm are used in [AutoSlim](https://github.com/open-mmlab/mmrazor/tree/main/configs/pruning/mmcls/autoslim).
|
||||
```
|
||||
|
||||
1. Register a new algorithm
|
||||
|
@ -21,9 +21,9 @@ You can choose existing algorithm components in MMRazor, such as `OneShotChannel
|
|||
|
||||
If these in MMRazor don't meet your needs, you can customize new algorithm components for your algorithm. Reference is as follows:
|
||||
|
||||
[Customize NAS algorithms](https://mmrazor.readthedocs.io/en/dev-1.x/advanced_guides/customize_nas_algorithms.html)
|
||||
[Customize Pruning algorithms](https://mmrazor.readthedocs.io/en/dev-1.x/advanced_guides/customize_pruning_algorithms.html)
|
||||
[Customize KD algorithms](https://mmrazor.readthedocs.io/en/dev-1.x/advanced_guides/customize_kd_algorithms.html)
|
||||
[Customize NAS algorithms](https://mmrazor.readthedocs.io/en/main/advanced_guides/customize_nas_algorithms.html)
|
||||
[Customize Pruning algorithms](https://mmrazor.readthedocs.io/en/main/advanced_guides/customize_pruning_algorithms.html)
|
||||
[Customize KD algorithms](https://mmrazor.readthedocs.io/en/main/advanced_guides/customize_kd_algorithms.html)
|
||||
```
|
||||
|
||||
```Python
|
||||
|
|
|
@ -41,7 +41,7 @@ If the existing `loop` does not meet your needs, you may need to make some chang
|
|||
|
||||
We recommend that you directly use the`MMArchitectureQuant` in `mmrazor/models/algorithms/quantization/mm_architecture.py`.The class `MMArchitectureQuant` inherits from class `BaseAlgorithm`.
|
||||
|
||||
This structure is built for the model in openmmlab. If you have other requirements, you can also refer to this [document](https://mmrazor.readthedocs.io/en/dev-1.x/advanced_guides/customize_architectures.html#develop-common-model-components) to design the overall framework.
|
||||
This structure is built for the model in openmmlab. If you have other requirements, you can also refer to this [document](https://mmrazor.readthedocs.io/en/main/advanced_guides/customize_architectures.html#develop-common-model-components) to design the overall framework.
|
||||
|
||||
2. Select quantizer
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ To understand it better, we take the mutable module as an example to explain as
|
|||
As shown in the figure above, `Mutable` is a container that holds some candidate operations, thus it can sample candidates to constitute the subnet. `Supernet` usually consists of multiple `Mutable`, therefore, `Supernet` will be searchable with the help of `Mutable`. And all candidate operations in `Mutable` constitute the search space of `SuperNet`.
|
||||
|
||||
```{note}
|
||||
If you want to know more about the relationship between Mutable and Mutator, please refer to [Mutator](https://mmrazor.readthedocs.io/en/dev-1.x/advanced_guides/mutator.html)
|
||||
If you want to know more about the relationship between Mutable and Mutator, please refer to [Mutator](https://mmrazor.readthedocs.io/en/main/advanced_guides/mutator.html)
|
||||
```
|
||||
|
||||
### Features
|
||||
|
|
|
@ -25,7 +25,7 @@ In MMRazor, we have implemented some mutators, their relationship is as below.
|
|||
`ModuleMuator`/ `ChannelMutator`: Two different types mutators are for handling mutable module and mutable channel respectively.
|
||||
|
||||
```{note}
|
||||
Please refer to [Mutable](https://mmrazor.readthedocs.io/en/dev-1.x/advanced_guides/mutable.html) for more details about different types of mutable.
|
||||
Please refer to [Mutable](https://mmrazor.readthedocs.io/en/main/advanced_guides/mutable.html) for more details about different types of mutable.
|
||||
```
|
||||
|
||||
`OneShotModuleMutator` / `DiffModuleMutator`: Inherit from `ModuleMuator`, they are for implementing different types algorithms, such as [SPOS](https://arxiv.org/abs/1904.00420), [Darts](https://arxiv.org/abs/1806.09055) and so on.
|
||||
|
|
|
@ -1,138 +1,66 @@
|
|||
# Installation
|
||||
|
||||
## Prepare Environment
|
||||
## Prerequisites
|
||||
|
||||
Create a conda virtual environment and activate it.
|
||||
In this section we demonstrate how to prepare an environment with PyTorch.
|
||||
|
||||
```Python
|
||||
conda create -n openmmlab python=3.7 -y
|
||||
MMRazor works on Linux, Windows and macOS. It requires Python 3.6+, CUDA 9.2+ and PyTorch 1.8+.
|
||||
|
||||
**Note:**
|
||||
If you are experienced with PyTorch and have already installed it, just skip this part and jump to the [next section](##installation). Otherwise, you can follow these steps for the preparation.
|
||||
|
||||
**Step 0.** Download and install Miniconda from the [official website](https://docs.conda.io/en/latest/miniconda.html).
|
||||
|
||||
**Step 1.** Create a conda environment and activate it.
|
||||
|
||||
```shell
|
||||
conda create --name openmmlab python=3.8 -y
|
||||
conda activate openmmlab
|
||||
```
|
||||
|
||||
Install PyTorch and torchvision following the [official instructions](https://pytorch.org/).
|
||||
**Step 2.** Install PyTorch following [official instructions](https://pytorch.org/get-started/locally/), e.g.
|
||||
|
||||
```{note}
|
||||
Make sure that your compilation CUDA version and runtime CUDA version match. You can check the supported CUDA version for precompiled packages on the [PyTorch website](https://pytorch.org/). If you build PyTorch from source instead of installing the prebuilt package, you can use more CUDA versions such as 9.0.
|
||||
On GPU platforms:
|
||||
|
||||
```shell
|
||||
conda install pytorch torchvision -c pytorch
|
||||
```
|
||||
|
||||
## Customize Installation
|
||||
On CPU platforms:
|
||||
|
||||
It is recommended to install MMRazor with [MIM](https://github.com/open-mmlab/mim), which automatically handles the dependencies of OpenMMLab projects, including mmcv and other python packages.
|
||||
|
||||
Or you can still install MMRazor manually
|
||||
|
||||
1. Install mmcv.
|
||||
|
||||
You can install mmcv with MIM, pip, or build it from source.
|
||||
|
||||
- Install mmcv with MIM (recommend).
|
||||
|
||||
```Python
|
||||
pip install openmim
|
||||
mim install 'mmcv>=2.0.0rc1'
|
||||
```shell
|
||||
conda install pytorch torchvision cpuonly -c pytorch
|
||||
```
|
||||
|
||||
- Install mmcv with pip.
|
||||
## Installation
|
||||
|
||||
```Python
|
||||
pip install 'mmcv>=2.0.0rc1' -f https://download.openmmlab.com/mmcv/dist/{cu_version}/{torch_version}/index.html
|
||||
```
|
||||
We recommend that users follow our best practices to install MMRazor.
|
||||
|
||||
Please replace `{cu_version}` and `{torch_version}` in the url to your desired one. For example, to install the latest `mmcv` with `CUDA 10.2` and `PyTorch 1.10.0`, use the following command:
|
||||
### Best Practices
|
||||
|
||||
```Python
|
||||
pip install 'mmcv>=2.0.0rc1' -f https://download.openmmlab.com/mmcv/dist/cu102/torch1.10.0/index.html
|
||||
```
|
||||
**Step 0.** Install [MMCV](https://github.com/open-mmlab/mmcv) using [MIM](https://github.com/open-mmlab/mim).
|
||||
|
||||
See [here](https://github.com/open-mmlab/mmcv#installation) for different versions of MMCV compatible to different PyTorch and CUDA versions.
|
||||
|
||||
- Build mmcv from source.
|
||||
|
||||
```bash
|
||||
MMCV_WITH_OPS=0 pip install -e . -v
|
||||
# install mmcv-lite, do not compile operators
|
||||
MMCV_WITH_OPS=1 pip install -e . -v
|
||||
# install mmcv (originally called mmcv-full), compile operators
|
||||
pip install -e . -v
|
||||
# install mmcv with compiled operators,
|
||||
```
|
||||
|
||||
- For windows platform, try `set MMCV_WITH_OPS=1` instead.
|
||||
|
||||
2. Install MMEngine.
|
||||
|
||||
You can install mmengine with MIM or build it from source.
|
||||
|
||||
- Install MMEngine with MIM.
|
||||
|
||||
```bash
|
||||
pip install openmim
|
||||
```shell
|
||||
pip install -U openmim
|
||||
mim install mmengine
|
||||
mim install "mmcv>=2.0.0"
|
||||
```
|
||||
|
||||
- Compile MMEngine from source.
|
||||
**Step 1.** Install MMRazor.
|
||||
|
||||
```Python
|
||||
git clone https://github.com/open-mmlab/mmengine.git
|
||||
cd mmengine
|
||||
pip install -v -e .
|
||||
```
|
||||
Case a: If you develop and run mmrazor directly, install it from source:
|
||||
|
||||
3. Install MMRazor.
|
||||
|
||||
If you would like to install MMRazor in `dev` mode, run following:
|
||||
|
||||
```Python
|
||||
git clone https://github.com/open-mmlab/mmrazor.git
|
||||
```shell
|
||||
git clone -b main https://github.com/open-mmlab/mmrazor.git
|
||||
cd mmrazor
|
||||
git fetch origin
|
||||
git checkout -b dev-1.x origin/dev-1.x
|
||||
# The new version is released in branch ``dev-1.x``
|
||||
pip install -v -e .
|
||||
# "-v" means verbose, or more output
|
||||
# "-e" means installing a project in editable mode,
|
||||
# '-v' means verbose, or more output
|
||||
# '-e' means installing a project in editable mode,
|
||||
# thus any local modifications made to the code will take effect without reinstallation.
|
||||
```
|
||||
|
||||
```{note}
|
||||
When MMRazor is installed on `dev` mode, any local modifications made to the code will take effect without the need to reinstall it.
|
||||
```
|
||||
|
||||
## A from-scratch Setup Script
|
||||
|
||||
```Python
|
||||
conda create -n openmmlab python=3.7 -y
|
||||
conda activate openmmlab
|
||||
|
||||
conda install pytorch torchvision cudatoolkit=10.2 -c pytorch
|
||||
# install the latest mmcv
|
||||
pip install 'mmcv>=2.0.0rc1' -f https://download.openmmlab.com/mmcv/dist/cu102/torch1.10.0/index.html
|
||||
# install mmrazor
|
||||
git clone https://github.com/open-mmlab/mmrazor.git
|
||||
cd mmrazor
|
||||
git fetch origin
|
||||
git checkout -b dev-1.x origin/dev-1.x
|
||||
pip install -v -e .
|
||||
```
|
||||
|
||||
## Install Other Libraries
|
||||
|
||||
MMRazor can easily collaborate with other OpenMMLab libraries. MMRazor requires the use of other libraries for different tasks. For example, `MMClassification` is required for image classification tasks, `MMDetection` for object detection, and `MMSegmentation` for semantic segmentation.
|
||||
|
||||
We provide the installation of the above three libraries using `MIM`.
|
||||
|
||||
```bash
|
||||
pip install openmim
|
||||
# mmcv is required for all libraries
|
||||
mim install 'mmcv>=2.0.0rc1'
|
||||
# install mmcls
|
||||
mim install 'mmcls>=1.0.0rc0'
|
||||
# install mmdet
|
||||
mim install 'mmdet>=3.0.0rc0'
|
||||
# install mmseg
|
||||
mim install 'mmseg>=1.0.0rc0'
|
||||
```
|
||||
|
||||
```{note}
|
||||
Not all of above libraries are required by MMRazor. Please install according to your requirements.
|
||||
Case b: If you use mmrazor as a dependency or third-party package, install it with pip:
|
||||
|
||||
```shell
|
||||
pip install "mmrazor>=1.0.0"
|
||||
```
|
||||
|
|
|
@ -2,23 +2,29 @@
|
|||
|
||||
## Baselines
|
||||
|
||||
| Type | Name | Link |
|
||||
| ------- | :-------------: | :---------------------------------------------------------------------------------------------------: |
|
||||
| nas | SPOS | [README.md](https://github.com/open-mmlab/mmrazor/tree/dev-1.x/configs/nas/mmcls/spos) |
|
||||
| nas | DARTS | [README.md](https://github.com/open-mmlab/mmrazor/tree/dev-1.x/configs/nas/mmcls/darts) |
|
||||
| nas | DetNAS | [README.md](https://github.com/open-mmlab/mmrazor/tree/dev-1.x/configs/nas/mmdet/detnas) |
|
||||
| pruning | AutoSlim | [README.md](https://github.com/open-mmlab/mmrazor/tree/dev-1.x/configs/pruning/mmcls/autoslim) |
|
||||
| ditill | ABLoss | [README.md](https://github.com/open-mmlab/mmrazor/tree/dev-1.x/configs/distill/mmcls/abloss) |
|
||||
| ditill | BYOT | [README.md](https://github.com/open-mmlab/mmrazor/tree/dev-1.x/configs/distill/mmcls/byot) |
|
||||
| ditill | DAFL | [README.md](https://github.com/open-mmlab/mmrazor/tree/dev-1.x/configs/distill/mmcls/dafl) |
|
||||
| ditill | DFAD | [README.md](https://github.com/open-mmlab/mmrazor/tree/dev-1.x/configs/distill/mmcls/dfad) |
|
||||
| ditill | DKD | [README.md](https://github.com/open-mmlab/mmrazor/tree/dev-1.x/configs/distill/mmcls/dkd) |
|
||||
| ditill | Factor Transfer | [README.md](https://github.com/open-mmlab/mmrazor/tree/dev-1.x/configs/distill/mmcls/factor_transfer) |
|
||||
| ditill | FitNets | [README.md](https://github.com/open-mmlab/mmrazor/tree/dev-1.x/configs/distill/mmcls/fitnets) |
|
||||
| ditill | KD | [README.md](https://github.com/open-mmlab/mmrazor/tree/dev-1.x/configs/distill/mmcls/kd) |
|
||||
| ditill | OFD | [README.md](https://github.com/open-mmlab/mmrazor/tree/dev-1.x/configs/distill/mmcls/ofd) |
|
||||
| ditill | RKD | [README.md](https://github.com/open-mmlab/mmrazor/tree/dev-1.x/configs/distill/mmcls/rkd) |
|
||||
| ditill | WSLD | [README.md](https://github.com/open-mmlab/mmrazor/tree/dev-1.x/configs/distill/mmcls/wsld) |
|
||||
| ditill | ZSKT | [README.md](https://github.com/open-mmlab/mmrazor/tree/dev-1.x/configs/distill/mmcls/zskt) |
|
||||
| ditill | CWD | [README.md](https://github.com/open-mmlab/mmrazor/tree/dev-1.x/configs/distill/mmdet/cwd) |
|
||||
| ditill | FBKD | [README.md](https://github.com/open-mmlab/mmrazor/tree/dev-1.x/configs/distill/mmdet/fbkd) |
|
||||
| Type | Name | Link |
|
||||
| ------------ | :-------------: | :------------------------------------------------------------------------------------------------: |
|
||||
| nas | SPOS | [README.md](https://github.com/open-mmlab/mmrazor/tree/main/configs/nas/mmcls/spos) |
|
||||
| nas | DARTS | [README.md](https://github.com/open-mmlab/mmrazor/tree/main/configs/nas/mmcls/darts) |
|
||||
| nas | DetNAS | [README.md](https://github.com/open-mmlab/mmrazor/tree/main/configs/nas/mmdet/detnas) |
|
||||
| pruning | AutoSlim | [README.md](https://github.com/open-mmlab/mmrazor/tree/main/configs/pruning/mmcls/autoslim) |
|
||||
| pruning | L1-norm | [README.md](https://github.com/open-mmlab/mmrazor/tree/main//configs/pruning/mmcls/l1-norm) |
|
||||
| pruning | Group Fisher | [README.md](https://github.com/open-mmlab/mmrazor/tree/main/configs/pruning/base/group_fisher) |
|
||||
| pruning | DMCP | [README.md](https://github.com/open-mmlab/mmrazor/tree/main/configs/pruning/mmcls/dmcp) |
|
||||
| ditill | ABLoss | [README.md](https://github.com/open-mmlab/mmrazor/tree/main/configs/distill/mmcls/abloss) |
|
||||
| ditill | BYOT | [README.md](https://github.com/open-mmlab/mmrazor/tree/main/configs/distill/mmcls/byot) |
|
||||
| ditill | DAFL | [README.md](https://github.com/open-mmlab/mmrazor/tree/main/configs/distill/mmcls/dafl) |
|
||||
| ditill | DFAD | [README.md](https://github.com/open-mmlab/mmrazor/tree/main/configs/distill/mmcls/dfad) |
|
||||
| ditill | DKD | [README.md](https://github.com/open-mmlab/mmrazor/tree/main/configs/distill/mmcls/dkd) |
|
||||
| ditill | Factor Transfer | [README.md](https://github.com/open-mmlab/mmrazor/tree/main/configs/distill/mmcls/factor_transfer) |
|
||||
| ditill | FitNets | [README.md](https://github.com/open-mmlab/mmrazor/tree/main/configs/distill/mmcls/fitnets) |
|
||||
| ditill | KD | [README.md](https://github.com/open-mmlab/mmrazor/tree/main/configs/distill/mmcls/kd) |
|
||||
| ditill | OFD | [README.md](https://github.com/open-mmlab/mmrazor/tree/main/configs/distill/mmcls/ofd) |
|
||||
| ditill | RKD | [README.md](https://github.com/open-mmlab/mmrazor/tree/main/configs/distill/mmcls/rkd) |
|
||||
| ditill | WSLD | [README.md](https://github.com/open-mmlab/mmrazor/tree/main/configs/distill/mmcls/wsld) |
|
||||
| ditill | ZSKT | [README.md](https://github.com/open-mmlab/mmrazor/tree/main/configs/distill/mmcls/zskt) |
|
||||
| ditill | CWD | [README.md](https://github.com/open-mmlab/mmrazor/tree/main/configs/distill/mmdet/cwd) |
|
||||
| ditill | FBKD | [README.md](https://github.com/open-mmlab/mmrazor/tree/main/configs/distill/mmdet/fbkd) |
|
||||
| quantization | PTQ | [README.md](https://github.com/open-mmlab/mmrazor/tree/main/configs/quantization/ptq/base) |
|
||||
| quantization | QAT | [README.md](https://github.com/open-mmlab/mmrazor/tree/main/configs/quantization/qat/base) |
|
||||
| quantization | LSQ | [README.md](https://github.com/open-mmlab/mmrazor/tree/main/configs/quantization/qat/lsq) |
|
||||
|
|
|
@ -7,9 +7,9 @@ MMRazor is a model compression toolkit for model slimming, which includes 4 main
|
|||
- Neural Architecture Search (NAS)
|
||||
- Pruning
|
||||
- Knowledge Distillation (KD)
|
||||
- Quantization (come soon)
|
||||
- Quantization
|
||||
|
||||
It is a part of the [OpenMMLab](https://openmmlab.com/) project. If you want to use it now, please refer to [Installation](https://mmrazor.readthedocs.io/en/dev-1.x/get_started/installation.html).
|
||||
It is a part of the [OpenMMLab](https://openmmlab.com/) project. If you want to use it now, please refer to [Installation](https://mmrazor.readthedocs.io/en/main/get_started/installation.html).
|
||||
|
||||
### Major features:
|
||||
|
||||
|
@ -59,26 +59,26 @@ For better understanding and using MMRazor, it is highly recommended to read the
|
|||
|
||||
**Global**
|
||||
|
||||
- [Algorithm](https://mmrazor.readthedocs.io/en/dev-1.x/advanced_guides/algorithm.html)
|
||||
- [Algorithm](https://mmrazor.readthedocs.io/en/main/advanced_guides/algorithm.html)
|
||||
|
||||
**NAS & Pruning**
|
||||
|
||||
- [Mutator](https://mmrazor.readthedocs.io/en/dev-1.x/advanced_guides/mutator.html)
|
||||
- [Mutable](https://mmrazor.readthedocs.io/en/dev-1.x/advanced_guides/mutable.html)
|
||||
- [Mutator](https://mmrazor.readthedocs.io/en/main/advanced_guides/mutator.html)
|
||||
- [Mutable](https://mmrazor.readthedocs.io/en/main/advanced_guides/mutable.html)
|
||||
|
||||
**KD**
|
||||
|
||||
- [Delivery](https://mmrazor.readthedocs.io/en/dev-1.x/advanced_guides/delivery.html)
|
||||
- [Recorder](https://mmrazor.readthedocs.io/en/dev-1.x/advanced_guides/recorder.html)
|
||||
- [Delivery](https://mmrazor.readthedocs.io/en/main/advanced_guides/delivery.html)
|
||||
- [Recorder](https://mmrazor.readthedocs.io/en/main/advanced_guides/recorder.html)
|
||||
|
||||
## User guide
|
||||
|
||||
If you want to run mmrazor quickly, you can refer to as the follows.
|
||||
|
||||
- [Learn about Configs](https://mmrazor.readthedocs.io/en/dev-1.x/user_guides/1_learn_about_config.html)
|
||||
- [Train different types algorithms](https://mmrazor.readthedocs.io/en/dev-1.x/user_guides/2_train_different_types_algorithms.html)
|
||||
- [Train with different devices](https://mmrazor.readthedocs.io/en/dev-1.x/user_guides/3_train_with_different_devices.html)
|
||||
- [Test a model](https://mmrazor.readthedocs.io/en/dev-1.x/user_guides/4_test_a_model.html)
|
||||
- [Learn about Configs](https://mmrazor.readthedocs.io/en/main/user_guides/1_learn_about_config.html)
|
||||
- [Train different types algorithms](https://mmrazor.readthedocs.io/en/main/user_guides/2_train_different_types_algorithms.html)
|
||||
- [Train with different devices](https://mmrazor.readthedocs.io/en/main/user_guides/3_train_with_different_devices.html)
|
||||
- [Test a model](https://mmrazor.readthedocs.io/en/main/user_guides/4_test_a_model.html)
|
||||
|
||||
## Tutorials
|
||||
|
||||
|
@ -86,20 +86,20 @@ We provide the following general tutorials according to some typical requirement
|
|||
|
||||
**Tutorial list**
|
||||
|
||||
- [Customize Architectures](https://mmrazor.readthedocs.io/en/dev-1.x/advanced_guides/customize_architectures.html)
|
||||
- [Customize NAS algorithms](https://mmrazor.readthedocs.io/en/dev-1.x/advanced_guides/customize_nas_algorithms.html)
|
||||
- [Customize Pruning algorithms](https://mmrazor.readthedocs.io/en/dev-1.x/advanced_guides/customize_pruning_algorithms.html)
|
||||
- [Customize KD algorithms](https://mmrazor.readthedocs.io/en/dev-1.x/advanced_guides/customize_kd_algorithms.html)
|
||||
- [Customize mixed algorithms](https://mmrazor.readthedocs.io/en/dev-1.x/advanced_guides/customize_mixed_algorithms.html)
|
||||
- [Apply existing algorithms to new tasks](https://mmrazor.readthedocs.io/en/dev-1.x/advanced_guides/apply_existing_algorithms_to_new_tasks.html)
|
||||
- [Customize Architectures](https://mmrazor.readthedocs.io/en/main/advanced_guides/customize_architectures.html)
|
||||
- [Customize NAS algorithms](https://mmrazor.readthedocs.io/en/main/advanced_guides/customize_nas_algorithms.html)
|
||||
- [Customize Pruning algorithms](https://mmrazor.readthedocs.io/en/main/advanced_guides/customize_pruning_algorithms.html)
|
||||
- [Customize KD algorithms](https://mmrazor.readthedocs.io/en/main/advanced_guides/customize_kd_algorithms.html)
|
||||
- [Customize mixed algorithms](https://mmrazor.readthedocs.io/en/main/advanced_guides/customize_mixed_algorithms.html)
|
||||
- [Apply existing algorithms to new tasks](https://mmrazor.readthedocs.io/en/main/advanced_guides/apply_existing_algorithms_to_new_tasks.html)
|
||||
|
||||
## F&Q
|
||||
|
||||
If you encounter some trouble using MMRazor, you can find whether your question has existed in [F&Q](https://mmrazor.readthedocs.io/en/dev-1.x/notes/faq.html). If not existed, welcome to open a [Github issue](https://github.com/open-mmlab/mmrazor/issues) for getting support, we will reply it as soon.
|
||||
If you encounter some trouble using MMRazor, you can find whether your question has existed in [F&Q](https://mmrazor.readthedocs.io/en/main/notes/faq.html). If not existed, welcome to open a [Github issue](https://github.com/open-mmlab/mmrazor/issues) for getting support, we will reply it as soon.
|
||||
|
||||
## Get support and contribute back
|
||||
|
||||
MMRazor is maintained on the [MMRazor Github repository](https://github.com/open-mmlab/mmrazor). We collect feedback and new proposals/ideas on Github. You can:
|
||||
|
||||
- Open a [GitHub issue](https://github.com/open-mmlab/mmrazor/issues) for bugs and feature requests.
|
||||
- Open a [pull request](https://github.com/open-mmlab/mmrazor/pulls) to contribute code (make sure to read the [contribution guide](https://mmrazor.readthedocs.io/en/dev-1.x/notes/contribution_guide.html) before doing this).
|
||||
- Open a [pull request](https://github.com/open-mmlab/mmrazor/pulls) to contribute code (make sure to read the [contribution guide](https://mmrazor.readthedocs.io/en/main/notes/contribution_guide.html) before doing this).
|
||||
|
|
|
@ -1 +1,278 @@
|
|||
# Changelog
|
||||
# Changelog of v1.x
|
||||
|
||||
## v1.0.0 (18/04/2023)
|
||||
|
||||
We are excited to announce the first official release of MMRazor 1.0.
|
||||
|
||||
### Highlights
|
||||
|
||||
- MMRazor quantization is released, which has got through task models and model deployment. With its help, we can quantize and deploy pre-trained models in OpenMMLab to specified backend quickly.
|
||||
|
||||
### New Features & Improvements
|
||||
|
||||
#### NAS
|
||||
|
||||
- Update searchable model. (https://github.com/open-mmlab/mmrazor/pull/438)
|
||||
- Update NasMutator to build search_space in NAS. (https://github.com/open-mmlab/mmrazor/pull/426)
|
||||
|
||||
#### Pruning
|
||||
|
||||
- Add a new pruning algorithm named GroupFisher. We support the full pipeline for GroupFisher, including pruning, finetuning and deployment.(https://github.com/open-mmlab/mmrazor/pull/459)
|
||||
|
||||
#### KD
|
||||
|
||||
- Support stopping distillation after a certain epoch. (https://github.com/open-mmlab/mmrazor/pull/455)
|
||||
- Support distilling rtmdet with mmrazor, refer to here. (https://github.com/open-mmlab/mmyolo/pull/544)
|
||||
- Add mask channel in MGD Loss. (https://github.com/open-mmlab/mmrazor/pull/461)
|
||||
|
||||
#### Quantization
|
||||
|
||||
- Support two quantization types: QAT and PTQ (https://github.com/open-mmlab/mmrazor/pull/513)
|
||||
- Support various quantization bits. (https://github.com/open-mmlab/mmrazor/pull/513)
|
||||
- Support various quantization methods, such as per_tensor / per_channel, symmetry / asymmetry and so on. (https://github.com/open-mmlab/mmrazor/pull/513)
|
||||
- Support deploy quantized models to multiple backends, such as OpenVINO, TensorRT and so on. (https://github.com/open-mmlab/mmrazor/pull/513)
|
||||
- Support applying quantization algorithms to multiple task repos directly, such as mmcls, mmdet and so on. (https://github.com/open-mmlab/mmrazor/pull/513)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- Fix split in Darts config. (https://github.com/open-mmlab/mmrazor/pull/451)
|
||||
- Fix a bug in Recorders. (https://github.com/open-mmlab/mmrazor/pull/446)
|
||||
- Fix a bug when using get_channel_unit.py. (https://github.com/open-mmlab/mmrazor/pull/432)
|
||||
- Fix a bug when deploying a pruned model to cuda. (https://github.com/open-mmlab/mmrazor/pull/495)
|
||||
|
||||
### Contributors
|
||||
|
||||
A total of 10 developers contributed to this release.
|
||||
Thanks @415905716 @gaoyang07 @humu789 @LKJacky @HIT-cwh @aptsunny @cape-zck @vansin @twmht @wm901115nwpu
|
||||
|
||||
## v1.0.0rc2 (06/01/2023)
|
||||
|
||||
We are excited to announce the release of MMRazor 1.0.0rc2.
|
||||
|
||||
### New Features
|
||||
|
||||
#### NAS
|
||||
|
||||
- Add Performance Predictor: Support 4 performance predictors with 4 basic machine learning algorithms, which can be used to directly predict model accuracy without evaluation.(https://github.com/open-mmlab/mmrazor/pull/306)
|
||||
|
||||
- Support [Autoformer](https://arxiv.org/pdf/2107.00651.pdf), a one-shot architecture search algorithm dedicated to vision transformer search.(https://github.com/open-mmlab/mmrazor/pull/315 )
|
||||
|
||||
- Support [BigNAS](https://arxiv.org/pdf/2003.11142), a NAS algorithm which searches the following items in MobileNetV3 with the one-shot paradigm: kernel_sizes, out_channels, expand_ratios, block_depth and input sizes. (https://github.com/open-mmlab/mmrazor/pull/219 )
|
||||
|
||||
#### Pruning
|
||||
|
||||
- Support [DCFF](https://arxiv.org/abs/2107.06916), a filter channel pruning algorithm dedicated to efficient image classification.(https://github.com/open-mmlab/mmrazor/pull/295)
|
||||
|
||||
- We release a powerful tool to automatically analyze channel dependency, named ChannelAnalyzer. Here is an example as shown below.(https://github.com/open-mmlab/mmrazor/pull/371)
|
||||
|
||||
Now, ChannelAnalyzer supports most of CNN models in torchvision, mmcls, mmseg and mmdet. We will continue to support more models.
|
||||
|
||||
```python
|
||||
from mmrazor.models.task_modules import ChannelAnalyzer
|
||||
from mmengine.hub import get_model
|
||||
import json
|
||||
|
||||
model = get_model('mmdet::retinanet/retinanet_r18_fpn_1x_coco.py')
|
||||
unit_configs: dict = ChannelAnalyzer().analyze(model)
|
||||
unit_config0 = list(unit_configs.values())[0]
|
||||
print(json.dumps(unit_config0, indent=4))
|
||||
# # short version of the config
|
||||
# {
|
||||
# "channels": {
|
||||
# "input_related": [
|
||||
# {"name": "backbone.layer2.0.bn1"},
|
||||
# {“name": "backbone.layer2.0.conv2"}
|
||||
# ],
|
||||
# "output_related": [
|
||||
# {"name": "backbone.layer2.0.conv1"},
|
||||
# {"name": "backbone.layer2.0.bn1"}
|
||||
# ]
|
||||
# },
|
||||
#}
|
||||
```
|
||||
|
||||
#### KD
|
||||
|
||||
- Support [MGD](https://arxiv.org/abs/2205.01529), a detection distillation algorithm.(https://github.com/open-mmlab/mmrazor/pull/381)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- Fix `FpnTeacherDistll` techer forward from `backbone + neck + head` to `backbone + neck`(#387 )
|
||||
- Fix some expire configs and checkpoints(#373 #372 #422 )
|
||||
|
||||
### Ongoing Changes
|
||||
|
||||
We will release Quantization in next version(1.0.0rc3)!
|
||||
|
||||
### Contributors
|
||||
|
||||
A total of 11 developers contributed to this release: @wutongshenqiu @sunnyxiaohu @aptsunny @humu789 @TinyTigerPan @FreakieHuang @LKJacky @wilxy @gaoyang07 @spynccat @yivona08.
|
||||
|
||||
## v1.0.0rc1 (27/10/2022)
|
||||
|
||||
We are excited to announce the release of MMRazor 1.0.0rc1.
|
||||
|
||||
### Highlights
|
||||
|
||||
- **New Pruning Framework**:We have systematically refactored the Pruning module. The new Pruning module can more automatically resolve the dependencies between channels and cover more corner cases.
|
||||
|
||||
### New Features
|
||||
|
||||
#### Pruning
|
||||
|
||||
- A new pruning framework is released in this release. (#311, #313)
|
||||
It consists of five core modules, including Algorithm, `ChannelMutator`, `MutableChannelUnit`, `MutableChannel` and `DynamicOp`.
|
||||
|
||||
- MutableChannelUnit is introduced for the first time. Each MutableChannelUnit manages all channels with channel dependency.
|
||||
|
||||
```python
|
||||
from mmrazor.registry import MODELS
|
||||
|
||||
ARCHITECTURE_CFG = dict(
|
||||
_scope_='mmcls',
|
||||
type='ImageClassifier',
|
||||
backbone=dict(type='MobileNetV2', widen_factor=1.5),
|
||||
neck=dict(type='GlobalAveragePooling'),
|
||||
head=dict(type='mmcls.LinearClsHead', num_classes=1000, in_channels=1920))
|
||||
model = MODELS.build(ARCHITECTURE_CFG)
|
||||
from mmrazor.models.mutators import ChannelMutator
|
||||
|
||||
channel_mutator = ChannelMutator()
|
||||
channel_mutator.prepare_from_supernet(model)
|
||||
units = channel_mutator.mutable_units
|
||||
print(units[0])
|
||||
# SequentialMutableChannelUnit(
|
||||
# name=backbone.conv1.conv_(0, 48)_48
|
||||
# (output_related): ModuleList(
|
||||
# (0): Channel(backbone.conv1.conv, index=(0, 48), is_output_channel=true, expand_ratio=1)
|
||||
# (1): Channel(backbone.conv1.bn, index=(0, 48), is_output_channel=true, expand_ratio=1)
|
||||
# (2): Channel(backbone.layer1.0.conv.0.conv, index=(0, 48), is_output_channel=true, expand_ratio=1)
|
||||
# (3): Channel(backbone.layer1.0.conv.0.bn, index=(0, 48), is_output_channel=true, expand_ratio=1)
|
||||
# )
|
||||
# (input_related): ModuleList(
|
||||
# (0): Channel(backbone.conv1.bn, index=(0, 48), is_output_channel=false, expand_ratio=1)
|
||||
# (1): Channel(backbone.layer1.0.conv.0.conv, index=(0, 48), is_output_channel=false, expand_ratio=1)
|
||||
# (2): Channel(backbone.layer1.0.conv.0.bn, index=(0, 48), is_output_channel=false, expand_ratio=1)
|
||||
# (3): Channel(backbone.layer1.0.conv.1.conv, index=(0, 48), is_output_channel=false, expand_ratio=1)
|
||||
# )
|
||||
# (mutable_channel): SquentialMutableChannel(num_channels=48, activated_channels=48)
|
||||
# )
|
||||
```
|
||||
|
||||
Our new pruning algorithm can help you develop pruning algorithm more fluently. Pelease refer to our documents [PruningUserGuide](<./docs/en/user_guides/../../pruning/%5Bpruning_user_guide.md%5D(http://pruning_user_guide.md/)>) for model detail.
|
||||
|
||||
#### Distillation
|
||||
|
||||
- Support [CRD](https://arxiv.org/abs/1910.10699), a distillation algorithm based on contrastive representation learning. (#281)
|
||||
|
||||
- Support [PKD](https://arxiv.org/abs/2207.02039), a distillation algorithm that can be used in `MMDetection` and `MMDetection3D`. #304
|
||||
|
||||
- Support [DEIT](https://arxiv.org/abs/2012.12877), a classic **Transformer** distillation algorithm.(#332)
|
||||
|
||||
- Add a more powerful baseline setting for [KD](https://arxiv.org/abs/1503.02531). (#305)
|
||||
|
||||
- Add `MethodInputsRecorder` and `FuncInputsRecorder` to record the input of a class method or a function.(#320)
|
||||
|
||||
#### NAS
|
||||
|
||||
- Support [DSNAS](https://arxiv.org/pdf/2002.09128.pdf), a nas algorithm that does not require retraining. (#226 )
|
||||
|
||||
#### Tools
|
||||
|
||||
- Support configurable immediate feature map visualization. (#293 )
|
||||
A useful tool is supported in this release to visualize the immediate features of a neural network. Please refer to our documents [VisualizationUserGuide](http://./docs/zh_cn/user_guides/visualization.md) for more details.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- Fix the bug that `FunctionXXRecorder` and `FunctionXXDelivery` can not be pickled. (#320)
|
||||
|
||||
### Ongoing changes
|
||||
|
||||
- Quantization: We are developing the basic interface of PTQ and QAT. RFC(Request for Comments) will be released soon.
|
||||
- AutoSlim: AutoSlim is not yet available and is being refactored.
|
||||
- Fx Pruning Tracer: Currently, the model topology can only be resolved through the backward tracer. In the future, both backward tracer and fx tracer will be supported.
|
||||
- More Algorithms: BigNAS、AutoFormer、GreedyNAS and Resrep will be released in the next few versions.
|
||||
- Documentation: we will add more design docs, tutorials, and migration guidance so that the community can deep dive into our new design, participate the future development, and smoothly migrate downstream libraries to MMRazor 1.x.
|
||||
|
||||
### Contributors
|
||||
|
||||
A total of 12 developers contributed to this release.
|
||||
Thanks @FreakieHuang @gaoyang07 @HIT-cwh @humu789 @LKJacky @pppppM @pprp @spynccat @sunnyxiaohu @wilxy @kitecats @SheffieldCao
|
||||
|
||||
## v1.0.0rc0 (31/8/2022)
|
||||
|
||||
We are excited to announce the release of MMRazor 1.0.0rc0.
|
||||
MMRazor 1.0.0rc0 is the first version of MMRazor 1.x, a part of the OpenMMLab 2.0 projects.
|
||||
Built upon the new [training engine](https://github.com/open-mmlab/mmengine),
|
||||
MMRazor 1.x simplified the interaction with other OpenMMLab repos, and upgraded the basic APIs of KD / Pruning / NAS.
|
||||
It also provides a series of knowledge distillation algorithms.
|
||||
|
||||
### Highlights
|
||||
|
||||
- **New engines**. MMRazor 1.x is based on [MMEngine](https://github.com/open-mmlab/mmengine), which provides a general and powerful runner that allows more flexible customizations and significantly simplifies the entrypoints of high-level interfaces.
|
||||
|
||||
- **Unified interfaces**. As a part of the OpenMMLab 2.0 projects, MMRazor 1.x unifies and refactors the interfaces and internal logic of train, testing, datasets, models, evaluation, and visualization. All the OpenMMLab 2.0 projects share the same design in those interfaces and logic to allow the emergence of multi-task/modality algorithms.
|
||||
|
||||
- **More configurable KD**. MMRazor 1.x add [Recorder](../advanced_guides/recorder.md) to get the data needed for KD more automatically,[Delivery ](../advanced_guides/delivery.md) to automatically pass the teacher's intermediate results to the student, and connector to handle feature dimension mismatches between teacher and student.
|
||||
|
||||
- **More kinds of KD algorithms**. Benefitting from the powerful APIs of KD, we have added several categories of KD algorithms, data-free distillation, self-distillation, and zero-shot distillation.
|
||||
|
||||
- **Unify the basic interface of NAS and Pruning**. We refactored [Mutable](../advanced_guides/mutable.md), adding mutable value and mutable channel. Both NAS and Pruning can be developed based on mutables.
|
||||
|
||||
- **More documentation and tutorials**. We add a bunch of documentation and tutorials to help users get started more smoothly. Read it [here](https://mmrazor.readthedocs.io/en/1.0.0rc0/).
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
#### Training and testing
|
||||
|
||||
- MMRazor 1.x runs on PyTorch>=1.6. We have deprecated the support of PyTorch 1.5 to embrace the mixed precision training and other new features since PyTorch 1.6. Some models can still run on PyTorch 1.5, but the full functionality of MMRazor 1.x is not guaranteed.
|
||||
- MMRazor 1.x uses Runner in [MMEngine](https://github.com/open-mmlab/mmengine) rather than that in MMCV. The new Runner implements and unifies the building logic of dataset, model, evaluation, and visualizer. Therefore, MMRazor 1.x no longer maintains the building logics of those modules in `mmdet.train.apis` and `tools/train.py`. Those code have been migrated into [MMEngine](https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/runner.py).
|
||||
- The Runner in MMEngine also supports testing and validation. The testing scripts are also simplified, which has similar logic as that in training scripts to build the runner.
|
||||
|
||||
#### Configs
|
||||
|
||||
- The [Runner in MMEngine](https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/runner.py) uses a different config structures
|
||||
- Config and model names
|
||||
|
||||
#### Components
|
||||
|
||||
- Algorithms
|
||||
- Distillers
|
||||
- Mutators
|
||||
- Mutables
|
||||
- Hooks
|
||||
|
||||
### Improvements
|
||||
|
||||
- Support mixed precision training of all the models. However, some models may got Nan results due to some numerical issues. We will update the documentation and list their results (accuracy of failure) of mixed precision training.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- AutoSlim: Models of different sizes will no longer have the same size checkpoint
|
||||
|
||||
### New Features
|
||||
|
||||
- Support [Activation Boundaries Loss](https://arxiv.org/pdf/1811.03233.pdf)
|
||||
- Support [Be Your Own Teacher](https://arxiv.org/abs/1905.08094)
|
||||
- Support [Data-Free Learning of Student Networks](https://doi.org/10.1109/ICCV.2019.00361)
|
||||
- Support [Data-Free Adversarial Distillation](https://arxiv.org/pdf/1912.11006.pdf)
|
||||
- Support [Decoupled Knowledge Distillation](https://arxiv.org/pdf/2203.08679.pdf)
|
||||
- Support [Factor Transfer](https://arxiv.org/abs/1802.04977)
|
||||
- Support [FitNets](https://arxiv.org/abs/1412.6550)
|
||||
- Support [Distilling the Knowledge in a Neural Network](https://arxiv.org/abs/1503.02531)
|
||||
- Support [Overhaul](https://arxiv.org/abs/1904.01866)
|
||||
- Support [Zero-shot Knowledge Transfer via Adversarial Belief Matching](https://arxiv.org/abs/1905.09768)
|
||||
|
||||
### Ongoing changes
|
||||
|
||||
- Quantization: We are developing the basic interface of PTQ and QAT. RFC(Request for Comments) will be released soon.
|
||||
- AutoSlim: AutoSlim is not yet available and is being refactored.
|
||||
- Fx Pruning Tracer: Currently, the model topology can only be resolved through the backward tracer. In the future, both backward tracer and fx tracer will be supported.
|
||||
- More Algorithms: BigNAS、AutoFormer、GreedyNAS and Resrep will be released in the next few versions.
|
||||
- Documentation: we will add more design docs, tutorials, and migration guidance so that the community can deep dive into our new design, participate the future development, and smoothly migrate downstream libraries to MMRazor 1.x.
|
||||
|
||||
### Contributors
|
||||
|
||||
A total of 13 developers contributed to this release.
|
||||
Thanks @FreakieHuang @gaoyang07 @HIT-cwh @humu789 @LKJacky @pppppM @pprp @spynccat @sunnyxiaohu @wilxy @wutongshenqiu @NickYangMin @Hiwyl
|
||||
Special thanks to @Davidgzx for his contribution to the data-free distillation algorithms
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
# Changelog of v1.x
|
||||
|
||||
## v1.0.0rc0 (31/8/2022)
|
||||
|
||||
We are excited to announce the release of MMRazor 1.0.0rc0.
|
||||
MMRazor 1.0.0rc0 is the first version of MMRazor 1.x, a part of the OpenMMLab 2.0 projects.
|
||||
Built upon the new [training engine](https://github.com/open-mmlab/mmengine),
|
||||
MMRazor 1.x simplified the interaction with other OpenMMLab repos, and upgraded the basic APIs of KD / Pruning / NAS.
|
||||
It also provides a series of knowledge distillation algorithms.
|
||||
|
||||
### Highlights
|
||||
|
||||
- **New engines**. MMRazor 1.x is based on [MMEngine](https://github.com/open-mmlab/mmengine), which provides a general and powerful runner that allows more flexible customizations and significantly simplifies the entrypoints of high-level interfaces.
|
||||
|
||||
- **Unified interfaces**. As a part of the OpenMMLab 2.0 projects, MMRazor 1.x unifies and refactors the interfaces and internal logic of train, testing, datasets, models, evaluation, and visualization. All the OpenMMLab 2.0 projects share the same design in those interfaces and logic to allow the emergence of multi-task/modality algorithms.
|
||||
|
||||
- **More configurable KD**. MMRazor 1.x add [Recorder](../advanced_guides/recorder.md) to get the data needed for KD more automatically,[Delivery ](../advanced_guides/delivery.md) to automatically pass the teacher's intermediate results to the student, and connector to handle feature dimension mismatches between teacher and student.
|
||||
|
||||
- **More kinds of KD algorithms**. Benefitting from the powerful APIs of KD, we have added several categories of KD algorithms, data-free distillation, self-distillation, and zero-shot distillation.
|
||||
|
||||
- **Unify the basic interface of NAS and Pruning**. We refactored [Mutable](../advanced_guides/mutable.md), adding mutable value and mutable channel. Both NAS and Pruning can be developed based on mutables.
|
||||
|
||||
- **More documentation and tutorials**. We add a bunch of documentation and tutorials to help users get started more smoothly. Read it [here](https://mmrazor.readthedocs.io/en/1.0.0rc0/).
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
#### Training and testing
|
||||
|
||||
- MMRazor 1.x runs on PyTorch>=1.6. We have deprecated the support of PyTorch 1.5 to embrace the mixed precision training and other new features since PyTorch 1.6. Some models can still run on PyTorch 1.5, but the full functionality of MMRazor 1.x is not guaranteed.
|
||||
- MMRazor 1.x uses Runner in [MMEngine](https://github.com/open-mmlab/mmengine) rather than that in MMCV. The new Runner implements and unifies the building logic of dataset, model, evaluation, and visualizer. Therefore, MMRazor 1.x no longer maintains the building logics of those modules in `mmdet.train.apis` and `tools/train.py`. Those code have been migrated into [MMEngine](https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/runner.py).
|
||||
- The Runner in MMEngine also supports testing and validation. The testing scripts are also simplified, which has similar logic as that in training scripts to build the runner.
|
||||
|
||||
#### Configs
|
||||
|
||||
- The [Runner in MMEngine](https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/runner.py) uses a different config structures
|
||||
- Config and model names
|
||||
|
||||
#### Components
|
||||
|
||||
- Algorithms
|
||||
- Distillers
|
||||
- Mutators
|
||||
- Mutables
|
||||
- Hooks
|
||||
|
||||
### Improvements
|
||||
|
||||
- Support mixed precision training of all the models. However, some models may got Nan results due to some numerical issues. We will update the documentation and list their results (accuracy of failure) of mixed precision training.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- AutoSlim: Models of different sizes will no longer have the same size checkpoint
|
||||
|
||||
### New Features
|
||||
|
||||
- Support [Activation Boundaries Loss](https://arxiv.org/pdf/1811.03233.pdf)
|
||||
- Support [Be Your Own Teacher](https://arxiv.org/abs/1905.08094)
|
||||
- Support [Data-Free Learning of Student Networks](https://doi.org/10.1109/ICCV.2019.00361)
|
||||
- Support [Data-Free Adversarial Distillation](https://arxiv.org/pdf/1912.11006.pdf)
|
||||
- Support [Decoupled Knowledge Distillation](https://arxiv.org/pdf/2203.08679.pdf)
|
||||
- Support [Factor Transfer](https://arxiv.org/abs/1802.04977)
|
||||
- Support [FitNets](https://arxiv.org/abs/1412.6550)
|
||||
- Support [Distilling the Knowledge in a Neural Network](https://arxiv.org/abs/1503.02531)
|
||||
- Support [Overhaul](https://arxiv.org/abs/1904.01866)
|
||||
- Support [Zero-shot Knowledge Transfer via Adversarial Belief Matching](https://arxiv.org/abs/1905.09768)
|
||||
|
||||
### Ongoing changes
|
||||
|
||||
- Quantization: We are developing the basic interface of PTQ and QAT. RFC(Request for Comments) will be released soon.
|
||||
- AutoSlim: AutoSlim is not yet available and is being refactored.
|
||||
- Fx Pruning Tracer: Currently, the model topology can only be resolved through the backward tracer. In the future, both backward tracer and fx tracer will be supported.
|
||||
- More Algorithms: BigNAS、AutoFormer、GreedyNAS and Resrep will be released in the next few versions.
|
||||
- Documentation: we will add more design docs, tutorials, and migration guidance so that the community can deep dive into our new design, participate the future development, and smoothly migrate downstream libraries to MMRazor 1.x.
|
||||
|
||||
### Contributors
|
||||
|
||||
A total of 13 developers contributed to this release.
|
||||
Thanks @FreakieHuang @gaoyang07 @HIT-cwh @humu789 @LKJacky @pppppM @pprp @spynccat @sunnyxiaohu @wilxy @wutongshenqiu @NickYangMin @Hiwyl
|
||||
Special thanks to @Davidgzx for his contribution to the data-free distillation algorithms
|
|
@ -21,6 +21,11 @@ Model quantization is in mmrazor, but quantized model deployment is in mmdeploy.
|
|||
|
||||
mmdeploy: https://github.com/open-mmlab/mmdeploy/tree/for_mmrazor
|
||||
|
||||
```{note}
|
||||
If you try to compress mmdet's models and have used `dense_heads`, you can use this branch:
|
||||
https://github.com/HIT-cwh/mmdetection/tree/for_mmrazor to avoid the problem that some code can not be traced by `torch.fx.tracer`.
|
||||
```
|
||||
|
||||
1. Quantize the float model in mmrazor.
|
||||
|
||||
```Shell
|
||||
|
|
|
@ -1,62 +1,18 @@
|
|||
# Copyright (c) OpenMMLab. All rights reserved.
|
||||
import warnings
|
||||
|
||||
import mmcv
|
||||
import mmengine
|
||||
from packaging.version import parse
|
||||
from mmengine.utils import digit_version
|
||||
|
||||
from .version import __version__
|
||||
|
||||
|
||||
def digit_version(version_str: str, length: int = 4):
|
||||
"""Convert a version string into a tuple of integers.
|
||||
|
||||
This method is usually used for comparing two versions. For pre-release
|
||||
versions: alpha < beta < rc.
|
||||
|
||||
Args:
|
||||
version_str (str): The version string.
|
||||
length (int): The maximum number of version levels. Default: 4.
|
||||
|
||||
Returns:
|
||||
tuple[int]: The version info in digits (integers).
|
||||
"""
|
||||
version = parse(version_str)
|
||||
assert version.release, f'failed to parse version {version_str}'
|
||||
release = list(version.release)
|
||||
release = release[:length]
|
||||
if len(release) < length:
|
||||
release = release + [0] * (length - len(release))
|
||||
if version.is_prerelease:
|
||||
mapping = {'a': -3, 'b': -2, 'rc': -1}
|
||||
val = -4
|
||||
# version.pre can be None
|
||||
if version.pre:
|
||||
if version.pre[0] not in mapping:
|
||||
warnings.warn(f'unknown prerelease version {version.pre[0]}, '
|
||||
'version checking may go wrong')
|
||||
else:
|
||||
val = mapping[version.pre[0]]
|
||||
release.extend([val, version.pre[-1]])
|
||||
else:
|
||||
release.extend([val, 0])
|
||||
|
||||
elif version.is_postrelease:
|
||||
release.extend([1, version.post]) # type: ignore
|
||||
else:
|
||||
release.extend([0, 0])
|
||||
return tuple(release)
|
||||
|
||||
|
||||
mmcv_minimum_version = '2.0.0rc3'
|
||||
mmcv_maximum_version = '2.0.0'
|
||||
mmcv_minimum_version = '2.0.0rc1'
|
||||
mmcv_maximum_version = '2.1.0'
|
||||
mmcv_version = digit_version(mmcv.__version__)
|
||||
|
||||
mmengine_minimum_version = '0.1.0'
|
||||
mmengine_maximum_version = '1.0.0'
|
||||
mmengine_version = digit_version(mmengine.__version__)
|
||||
|
||||
|
||||
assert (mmcv_version >= digit_version(mmcv_minimum_version)
|
||||
and mmcv_version <= digit_version(mmcv_maximum_version)), \
|
||||
f'MMCV=={mmcv.__version__} is used but incompatible. ' \
|
||||
|
|
|
@ -330,10 +330,12 @@ class PTQLoop(TestLoop):
|
|||
# Determine whether or not different ranks use different seed.
|
||||
diff_rank_seed = runner._randomness_cfg.get(
|
||||
'diff_rank_seed', False)
|
||||
self.dataloader = runner.build_dataloader(
|
||||
dataloader, seed=runner.seed, diff_rank_seed=diff_rank_seed)
|
||||
self.calibrate_dataloader = runner.build_dataloader(
|
||||
calibrate_dataloader,
|
||||
seed=runner.seed,
|
||||
diff_rank_seed=diff_rank_seed)
|
||||
else:
|
||||
self.dataloader = dataloader
|
||||
self.calibrate_dataloader = calibrate_dataloader
|
||||
|
||||
self.calibrate_steps = calibrate_steps
|
||||
self.only_val = only_val
|
||||
|
@ -350,7 +352,7 @@ class PTQLoop(TestLoop):
|
|||
self.runner.model.apply(enable_observer)
|
||||
|
||||
print_log('Star calibratiion...')
|
||||
for idx, data_batch in enumerate(self.dataloader):
|
||||
for idx, data_batch in enumerate(self.calibrate_dataloader):
|
||||
if idx == self.calibrate_steps:
|
||||
break
|
||||
self.run_iter(idx, data_batch)
|
||||
|
|
|
@ -10,6 +10,7 @@ from mmengine.runner import load_checkpoint
|
|||
from mmengine.structures import BaseDataElement
|
||||
from torch import nn
|
||||
|
||||
from mmrazor.models.utils import pop_rewriter_function_record
|
||||
from mmrazor.registry import MODEL_WRAPPERS, MODELS
|
||||
from mmrazor.structures.quantization import QConfigHandler
|
||||
from ..base import BaseAlgorithm, BaseModel
|
||||
|
@ -249,13 +250,8 @@ class MMArchitectureQuant(BaseAlgorithm):
|
|||
function_record_to_pop = self.deploy_cfg.get('function_record_to_pop',
|
||||
[])
|
||||
function_record_to_pop.extend(skipped_methods)
|
||||
function_record_backup = {}
|
||||
for record in function_record_to_pop:
|
||||
records = rewriter_context._rewriter_manager.function_rewriter. \
|
||||
_registry._rewrite_records
|
||||
if record in records:
|
||||
function_record_backup[record] = records.pop(record)
|
||||
return function_record_backup
|
||||
return pop_rewriter_function_record(rewriter_context,
|
||||
function_record_to_pop)
|
||||
|
||||
def _build_qmodels(self, model: BaseModel):
|
||||
"""Build quantized models from the given model.
|
||||
|
|
|
@ -3,10 +3,11 @@ from .make_divisible import make_divisible
|
|||
from .misc import add_prefix
|
||||
from .optim_wrapper import reinitialize_optim_wrapper_count_status
|
||||
from .parse_values import parse_values
|
||||
from .quantization_util import str2class
|
||||
from .quantization_util import pop_rewriter_function_record, str2class
|
||||
from .utils import get_module_device, set_requires_grad
|
||||
|
||||
__all__ = [
|
||||
'make_divisible', 'add_prefix', 'reinitialize_optim_wrapper_count_status',
|
||||
'str2class', 'get_module_device', 'set_requires_grad', 'parse_values'
|
||||
'str2class', 'get_module_device', 'set_requires_grad', 'parse_values',
|
||||
'pop_rewriter_function_record'
|
||||
]
|
||||
|
|
|
@ -2,6 +2,27 @@
|
|||
from mmengine.utils import import_modules_from_strings
|
||||
|
||||
|
||||
def pop_rewriter_function_record(rewriter_context, function_record_to_pop):
|
||||
"""Delete user-specific rewriters from `RewriterContext._rewriter_manager`.
|
||||
|
||||
We use the model which is rewritten by mmdeploy to build quantized models.
|
||||
However not all the functions rewritten by mmdeploy need to be rewritten in
|
||||
mmrazor. For example, mmdeploy rewrite
|
||||
`mmcls.models.classifiers.ImageClassifier.forward` and
|
||||
`mmcls.models.classifiers.BaseClassifier.forward` for deployment. But they
|
||||
can't be rewritten by mmrazor as ptq and qat are done in mmrazor. So to
|
||||
ensure ptq and qat proceed normally, we have to remove these record from
|
||||
`RewriterContext._rewriter_manager`.
|
||||
"""
|
||||
function_record_backup = {}
|
||||
for record in function_record_to_pop:
|
||||
records = rewriter_context._rewriter_manager.function_rewriter. \
|
||||
_registry._rewrite_records
|
||||
if record in records:
|
||||
function_record_backup[record] = records.pop(record)
|
||||
return function_record_backup
|
||||
|
||||
|
||||
def _check_valid_source(source):
|
||||
"""Check if the source's format is valid."""
|
||||
if not isinstance(source, str):
|
||||
|
|
|
@ -3,7 +3,6 @@ Import:
|
|||
- configs/distill/mmdet/cwd/metafile.yml
|
||||
- configs/distill/mmcls/wsld/metafile.yml
|
||||
- configs/distill/mmcls/rkd/metafile.yml
|
||||
- configs/nas/mmcls/spos/metafile.yml
|
||||
- configs/distill/mmcls/abloss/metafile.yml
|
||||
- configs/distill/mmcls/byot/metafile.yml
|
||||
- configs/distill/mmcls/dafl/metafile.yml
|
||||
|
@ -15,6 +14,7 @@ Import:
|
|||
- configs/distill/mmdet/fbkd/metafile.yml
|
||||
- configs/distill/mmcls/factor_transfer/metafile.yml
|
||||
- configs/distill/mmcls/ofd/metafile.yml
|
||||
- configs/nas/mmcls/spos/metafile.yml
|
||||
- configs/nas/mmcls/autoslim/metafile.yml
|
||||
- configs/nas/mmcls/darts/metafile.yml
|
||||
- configs/nas/mmdet/detnas/metafile.yml
|
||||
|
|
Loading…
Reference in New Issue