mct-model-optimization

SonySemiconductorSolutionsApache-2.0活跃维护

面向边缘受限硬件的神经网络压缩工具包,提供量化感知训练和训练后量化等高级量化压缩能力,帮研究者把模型高效部署到资源紧张的设备上。

Model Compression Toolkit (MCT) is an open source project for neural network model optimization under efficient, constrained hardware. This project provides researchers, developers, and engineers advanced quantization and compression tools for deploying state-of-the-art neural networks.

v2.6.1发布于 2026-09-17 07:19 UTC450star81fork同步于 2026-11-10 11:59 UTC

怎么上手

由 README 提炼,执行前请确认
pip install model-compression-toolkit
硬件要求按 README 说明

README 未说明具体显存或 GPU 型号要求;仅给出各量化流程的计算开销参考:PTQ 约 1-10 CPU 分钟,GPTQ 约 1-3 GPU 小时,QAT 约 12-36 GPU 小时。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

索尼开源的神经网络量化与压缩工具包,帮你在受限硬件上高效部署模型

面向边缘受限硬件的神经网络压缩工具包,提供量化感知训练和训练后量化等高级量化压缩能力,帮研究者把模型高效部署到资源紧张的设备上。

核心能力

  • 支持 PTQ、GPTQ、QAT 三种量化流程
  • 按层搜索最优权重量化位宽的混合精度搜索
  • 用 TPC 描述目标硬件约束做硬件感知优化
  • 无数据时用 BN 统计生成合成图做量化
  • 结构化剪枝移除冗余输入通道并重建权重

容易踩的坑

需自备预训练浮点模型(PyTorch/Keras)作为输入,工具不提供模型;Python 需 >=3.10,PyTorch 需 2.3-2.6 或 TensorFlow 2.14/2.15;QAT 流程计算开销大,需预留数十 GPU 小时。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v2.6.1
  1. v2.6.1Release 2.6.1最新正式版2026-09-17 · 2026-09-17 07:19 UTC

    What's Changed

    Bug Fixes

    • Resolved Mixed Precision crash issue (Issue #1682)

      • Mixed Precision: Filter non-finite candidates Excludes candidates with non-finite (NaN/Inf) sensitivity scores from the LP solver before optimization.
      • Mixed Precision: Handle non-finite sensitivity metrics in search manager Hardens the mixed-precision search manager so NaN/Inf sensitivity metrics don't corrupt metric normalization, max-bit correction, or final distance-metric scaling.
    • Support scalar and 1D tensors in statistics collection in PyTorch (Issue #1451) Fixed an issue in PyTorch statistics collection for activation tensors with fewer than two dimensions.

    Documentation and Others

    • Clarify resource utilization data is an estimate (Issue #1293)
    • Corrected quantization description in PTQ/GPTQ/QAT docstrings (Issue #1556)
    • Updated IMX500 link in TPC README
  2. v2.6.0Release 2.6.02026-03-03 · 2026-03-03 08:06 UTC
    查看更新说明

    What's Changed

    Breaking Change: TPC Settings (https://github.com/SonySemiconductorSolutions/mct-model-optimization/pull/1635)

    • Changed the existing get_target_platform_capabilities API (Breaking Change). Read more.
    tpc = mct.get_target_platform_capabilities(tpc_version='1.0', 
                                               device_type='imx500')
    
    • Added a new get_target_platform_capabilities_sdsp API to get TPC based on SDSP Converter version. Read more.
    tpc = mct.get_target_platform_capabilities_sdsp(sdsp_version='3.14')
    
    • Migrated features from the EdgeMDT-TPC repository.

    Added TPC v6.0

    New API : MCTWrapper (https://github.com/SonySemiconductorSolutions/mct-model-optimization/pull/1578)

    • Developed a new API that allows you to set parameters, perform quantization, and export model all at once. Read more.
    wrapper = mct.MCTWrapper()
    _, quantized_model = wrapper.quantize_and_export(float_model=float_model,
                                                     representative_dataset=representative_dataset,
                                                     method='PTQ',
                                                     framework='pytorch',
                                                     use_mixed_precision=False)
    
    • Added tutorials of MCTWrapper. Try it!

    Log Output Correction

    Bug Fixes

    Tutorials

    We've added new tutorials for various task. Try it!

  3. v2.5.1Release 2.5.12026-01-05 · 2026-01-05 08:02 UTC
    查看更新说明

    What's Changed

    Bug Fixes

    • Support NumPy 2.4.0
      • Fixed implementation due to the removal of "conversion of an array with ndim > 0 to a scalar" in NumPy 2.4.0
  4. v2.5.0Release 2.5.02025-12-01 · 2025-12-01 04:58 UTC
    查看更新说明

    What's Changed

    XQuant Extension Tool (experimental) (#1502)

    • Calculates the error for each layer by comparing the float model and quantized model, using both models along with the quantization log. The results are presented in reports. It identifies the causes of the detected errors and recommends appropriate improvement measures for each cause. Read more Troubleshoot Manual

    New CustomLayer: MulticlassNMSOBB (for PyTorch) (#1508)

    • Implemented a new CustomLayer: MulticlassNMSOBB, the Non-Maximum Suppression layer for the Object Detection (Oriented Bounding Box) task.

    Bug Fixes

    • Modify the Stack Layer settings in TPC (v1.0) (#1523)

    Tutorials

    • Add PyTorch Tutorial of PoseNet: We've added a new PyTorch tutorial of PoseNet model for the Human Pose Estimation task. Try it! (#1524)

    Supported Python versions

    • Python(>=3.10).(#1551 )
  5. v2.4.5Release 2.4.52025-12-01 · 2025-12-01 00:15 UTC
    查看更新说明

    What's Changed

    Bug Fixes

    • Limit networkx version(<3.6)
      • Additional restrictions have been added to the MCT requirements due to the lack of support for certain functions in networkx 3.6 (Released in 2025/11/24).

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译


    Getting Started

    Quick Installation

    Pip install the model compression toolkit package in a Python>=3.10 environment with PyTorch>=2.3 or Tensorflow>=2.14.

    pip install model-compression-toolkit
    

    For installing from source, refer to the installation guide.

    Important note: In order to use MCT, you’ll need to provide a pre-trained floating point model (PyTorch/Keras) as an input.

    Tutorials and Examples

    Our tutorials section will walk you through the basics of the MCT tool, covering various compression techniques for both Keras and PyTorch models. Access interactive notebooks for hands-on learning with popular models/tasks or move on to Resources section.

    Supported Quantization Methods

    MCT supports various quantization methods as appears below.

    Quantization MethodComplexityComputational CostAPITutorial
    PTQ (Post Training Quantization)LowLow (~1-10 CPU minutes)PyTorch API / Keras API
    GPTQ (parameters fine-tuning using gradients)ModerateModerate (~1-3 GPU hours)PyTorch API / Keras API
    QAT (Quantization Aware Training)HighHigh (~12-36 GPU hours)QAT API

    For each flow, Quantization core utilizes various algorithms and hyper-parameters for optimal hardware-aware quantization results. For further details, please see Supported features and algorithms.

    Required input: Pre-trained floating point model (PyTorch/Keras)

    Optional input: Representative dataset - can be either provided by the user, or generated utilizing the Data Generation capability

    High level features and techniques

    MCT offers a range of powerful features to optimize models for efficient edge deployment. These supported features include:

    Quantization Core Features

    🏆 Mixed-precision search Open In Colab. Assigning optimal quantization bit-width per layer (for weights/activations)

    📈 Graph optimizations. Transforming the model to be best fitted for quantization process.

    🔎 Quantization parameter search Open In Colab. Minimizing expected quantization-noise during thresholds search using methods such as MSE, No-Clipping and MAE.

    🧮 Advanced quantization algorithms Open In Colab. Enhancing quantization performance for advanced cases is available with some algorithms that can be applied, such as Shift negative correction, Outliers filtering and clustering.


    Hardware-aware optimization

    🎯 TPC (Target Platform Capabilities). Describes the target hardware’s constrains, for which the model optimization is targeted. See TPC Readme for more information.


    Data-free quantization (Data Generation) Open In Colab

    Generates synthetic images based on the statistics stored in the model's batch normalization layers, according to your specific needs, for when image data isn’t available. See Data Generation Library for more. The specifications of the method are detailed in the paper: "Data Generation for Hardware-Friendly Post-Training Quantization" [5].


    Structured Pruning Open In Colab

    Reduces model size/complexity and ensures better channels utilization by removing redundant input channels from layers and reconstruction of layer weights. Read more (Pytorch API / Keras API).


    Debugging and Visualization

    🎛️ Network Editor (Modify Quantization Configurations) Open In Colab. Modify your model's quantization configuration for specific layers or apply a custom edit rule (e.g adjust layer's bit-width) using MCT’s network editor.

    🖥️ Visualization. Observe useful information for troubleshooting the quantized model's performance using TensorBoard. Read more.

    🔑 XQuant (Explainable Quantization) Open In Colab. Get valuable insights regarding the quality and success of the quantization process of your model. The report includes histograms and similarity metrics between the original float model and the quantized model in key points of the model. The report can be visualized using TensorBoard.

    🔑 XQuant Extension Tool. Open In Colab. Calculates the error for each layer by comparing the float model and quantized model, using both models along with the quantization log. The results are presented in reports. It identifies the causes of the detected errors and recommends appropriate improvement measures for each cause. Read more Troubleshoot Manual


    Enhanced Post-Training Quantization (EPTQ)

    As part of the GPTQ capability, we provide an advanced optimization algorithm called EPTQ. The specifications of the algorithm are detailed in the paper: "EPTQ: Enhanced Post-Training Quantization via Hessian-guided Network-wise Optimization" [4]. More details on how to use EPTQ via MCT can be found in the GPTQ guidelines.

    Resources

    Supported Versions

    Currently, MCT is being tested on various Python, PyTorch and TensorFlow versions:

    PyTorch 2.3PyTorch 2.4PyTorch 2.5PyTorch 2.6
    Python 3.10Run TestsRun TestsRun TestsRun Tests
    Python 3.11Run TestsRun TestsRun TestsRun Tests
    Python 3.12Run TestsRun TestsRun TestsRun Tests
    TensorFlow 2.14TensorFlow 2.15
    Python 3.10Run TestsRun Tests
    Python 3.11Run TestsRun Tests

    It is also being tested with IMX500 Converter and TPC versions:

    PyTorch
    TPC 1.0TPC 4.0TPC 5.0TPC 6.0
    IMX500 Converter 3.14Run Tests Not supported Not supported Not supported
    IMX500 Converter 3.16Run TestsRun Tests Not supported Not supported
    IMX500 Converter 3.17Run TestsRun TestsRun Tests Not supported
    IMX500 Converter 3.18Run TestsRun TestsRun Tests Not supported
    IMX500 Converter 3.19Run TestsRun TestsRun TestsRun Tests
    TensorFlow
    TPC 1.0TPC 4.0TPC 5.0TPC 6.0
    IMX500 Converter 3.14Run Tests Not supported Not supported Not supported
    IMX500 Converter 3.16Run TestsRun Tests Not supported Not supported
    IMX500 Converter 3.17Run TestsRun TestsRun Tests Not supported
    IMX500 Converter 3.18Run TestsRun TestsRun Tests Not supported
    IMX500 Converter 3.19Run TestsRun TestsRun TestsRun Tests

    Results

    MCT can quantize an existing 32-bit floating-point model to an 8-bit fixed-point (or less) model without compromising accuracy. Below is a graph of MobileNetV2 accuracy on ImageNet vs average bit-width of weights (X-axis), using single-precision quantization, mixed-precision quantization, and mixed-precision quantization with GPTQ.

    For more results, please see [1]

    Pruning Results

    Results for applying pruning to reduce the parameters of the following models by 50%:

    ModelDense Model AccuracyPruned Model Accuracy
    ResNet50 [2]75.172.4
    DenseNet121 [3]74.4471.71

    Troubleshooting and Community

    If you encountered a large accuracy degradation with MCT, check out the Quantization Troubleshooting for common pitfalls and some tools to improve the quantized model's accuracy.

    Check out the FAQ for common issues.

    You are welcome to ask questions and get support on our issues section and manage community discussions under the discussions section.

    Contributions

    We'd love your input! MCT would not be possible without help from our community, and welcomes contributions from anyone!

    *Checkout our Contribution guide for more details.

    Thank you 🙏 to all our contributors!

    License

    MCT is licensed under Apache License Version 2.0. By contributing to the project, you agree to the license and copyright terms therein and release your contribution under these terms.

    References

    [1] Habi, H.V., Peretz, R., Cohen, E., Dikstein, L., Dror, O., Diamant, I., Jennings, R.H. and Netzer, A., 2021. HPTQ: Hardware-Friendly Post Training Quantization. arXiv preprint.

    [2] Keras Applications

    [3] TORCHVISION.MODELS

    [4] Gordon, O., Cohen, E., Habi, H.V., Netzer, A. (2025). EPTQ: Enhanced Post-Training Quantization via Hessian-guided Network-wise Optimization – ECCV 2024 Workshops

    [5] Dikstein, L., Lapid, A., Netzer, A., & Habi, H. V., 2024. Data Generation for Hardware-Friendly Post-Training Quantization, Accepted to IEEE/CVF Winter Conference on Applications of Computer Vision (WACV) 2025