OpenMMLab Model Compression Toolbox and Benchmark.
We are excited to announce the first official release of MMRazor 1.0.
A total of 23 developers contributed to this release. Thanks @415905716 @gaoyang07 @humu789 @LKJacky @HIT-cwh @aptsunny @cape-zck @vansin @twmht @wm901115nwpu @Hiwyl @NickYangMin @spynccat @sunnyxiaohu @kitecats @TinyTigerPan @twmht @yivona08 @xinxinxinxu @cape-zck @Weiyun1025 @vansin @Lxtccc
Full Changelog: https://github.com/open-mmlab/mmrazor/compare/v0.3.1...v1.0.0
We are excited to announce the release of MMRazor 1.0.0rc2.
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, a one-shot architecture search algorithm dedicated to vision transformer search.(https://github.com/open-mmlab/mmrazor/pull/315 )
Support BigNAS, 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 )
Support DCFF, a filter channel pruning algorithm dedicated to efficient image classification.(https://github.com/open-mmlab/mmrazor/pull/295)
We release a powerfull 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.
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"}
# ]
# },
#}
FpnTeacherDistll
techer forward from backbone + neck + head
to backbone + neck
(#387 )We will release Quantization in next version(1.0.0rc3)!
A total of 11 developers contributed to this release: @wutongshenqiu @sunnyxiaohu @aptsunny @humu789 @TinyTigerPan @FreakieHuang @LKJacky @wilxy @gaoyang07 @spynccat @yivona08.
We are excited to announce the release of MMRazor 1.0.0rc1.
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.
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 for model detail.
Support CRD, a distillation algorithm based on contrastive representation learning. (#281)
Support PKD, a distillation algorithm that can be used in MMDetection
and MMDetection3D
. #304
Support DEIT, a classic Transformer distillation algorithm.(#332)
Add a more powerful baseline setting for KD. (#305)
Add MethodInputsRecorder
and FuncInputsRecorder
to record the input of a class method or a function.(#320)
FunctionXXRecorder
and FunctionXXDelivery
can not be pickled. (#320)A total of 12 developers contributed to this release. Thanks @FreakieHuang @gaoyang07 @HIT-cwh @humu789 @LKJacky @pppppM @pprp @spynccat @sunnyxiaohu @wilxy @kitecats @SheffieldCao
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, 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.
New engines. MMRazor 1.x is based on 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 to get the data needed for KD more automatically,Delivery 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, 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.
mmdet.train.apis
and tools/train.py
. Those code have been migrated into MMEngine.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
tools/mmseg/train_mmseg.py
cannot train properly (#152)mutable_cfg
, channel_cfg
and teacher_checkpoint
in configs to reduce the use of cfg-options
(#149)StructurePruner
supports trace models which contain Dilated Conv2d, such as YOLOF
(#113)StructurePruner
supports trace models which contain share modules, such as RetinaNet
(#113)requires_grad
is False (#113 )BatachNorm
(#81 )mmdet
and mmcls
latest version of apis
(#115)GET_STARTED
related docs(#133 )show_result
during the test(#52 )WSLD
(#26)DetNAS
(#103)slurm_train_mmcls.sh
(#90)MMRazor v0.1.0 is released.
Compatibility
MMRazor can be easily applied to various projects in OpenMMLab, due to similar architecture design of OpenMMLab as well as the decoupling of slimming algorithms and vision tasks.
Flexibility
Different algorithms, e.g., NAS, pruning and KD, can be incorporated in a plug-n-play manner to build a more powerful system.
Convenience
With better modular design, developers can implement new model compression algorithms with only a few codes, or even by simply modifying config files.