MMRazor is a model compression toolkit for model slimming, which includes 4 mainstream technologies:
Neural Architecture Search (NAS)
Knowledge Distillation (KD)
MMRazor can be easily applied to various projects in OpenMMLab, due to the similar architecture design of OpenMMLab as well as the decoupling of slimming algorithms and vision tasks.
Different algorithms, e.g., NAS, pruning and KD, can be incorporated in a plug-n-play manner to build a more powerful system.
With better modular design, developers can implement new model compression algorithms with only a few codes, or even by simply modifying config files.
Design and Implement¶
There are 3 layers (Application / Algorithm / Component) in overview design. MMRazor mainly includes both of Component and Algorithm, while Application consist of some OpenMMLab upstream repos, such as MMClassification, MMDetection, MMSegmentation and so on.
Component provides many useful functions for quickly implementing Algorithm. And thanks to OpenMMLab ‘s powerful and highly flexible config mode and registry mechanism, Algorithm can be conveniently applied to Application.
How to apply our lightweight algorithms to some upstream tasks? Please refer to the below.
In OpenMMLab, implementing vision tasks commonly includes 3 parts (model / dataset / schedule). And just like that, implementing lightweight model also includes 3 parts (algorithm / dataset / schedule) in MMRazor.
Algorithm consist of
Architecture is similar to
model of the upstream repos. You can chose to directly use the original
model or customize the new
model as your architecture according to different tasks. For example, you can directly use ResNet-34 and ResNet-18 of MMClassification to implement some KD algorithms, but in NAS, you may need to customize a searchable model.
Components consist of various special functions for supporting different lightweight algorithms. They can be directly used in config because of registered into MMEngine. Thus, you can pick some components you need to quickly implement your algorithm. For example, you may need
searchle backbone if you want to implement a NAS algorithm, and you can pick from
distill loss /
connector if you need a KD algorithm.
Please refer to the next section for more details about Implement.
The arg name of
algorithm in config is model rather than algorithm in order to get better supports of MMCV and MMEngine.
For better understanding and using MMRazor, it is highly recommended to read the following user documents according to your own needs.
NAS & Pruning
If you want to run mmrazor quickly, you can refer to as the follows.
We provide the following general tutorials according to some typical requirements. If you want to further use MMRazor, you can refer to our source code and API Reference.
Get support and contribute back¶
MMRazor is maintained on the MMRazor Github repository. We collect feedback and new proposals/ideas on Github. You can: