Why MMRazor

MMRazor is a model compression toolkit for model slimming, which includes 4 mainstream technologies:

  • Neural Architecture Search (NAS)

  • Pruning

  • Knowledge Distillation (KD)

  • Quantization (come soon)

It is a part of the OpenMMLab project. If you want to use it now, please refer to Installation.

Major features:

  • Compatibility

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.

  • 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.

Design and Implement

overview - 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 and components.

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 mutator / mutable / searchle backbone if you want to implement a NAS algorithm, and you can pick from distill loss / recorder / delivery / 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.

Key concepts

For better understanding and using MMRazor, it is highly recommended to read the following user documents according to your own needs.


NAS & Pruning


User guide

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.

Tutorial list


If you encounter some trouble using MMRazor, you can find whether your question has existed in F&Q. If not existed, welcome to open a Github issue for getting support, we will reply it as soon.

Get support and contribute back

MMRazor is maintained on the MMRazor Github repository. We collect feedback and new proposals/ideas on Github. You can:

Read the Docs v: v1.0.0rc0
On Read the Docs
Project Home

Free document hosting provided by Read the Docs.