{"id":27947,"library":"mct-quantizers","title":"MCT Quantizers","description":"MCT Quantizers is a Python library that provides infrastructure for supporting neural network compression through quantization-aware training and post-training quantization. It is part of the Model Compression Toolkit (MCT) ecosystem. Version 1.7.0 requires Python >=3.10. The library is actively maintained with regular releases.","status":"active","version":"1.7.0","language":"python","source_language":"en","source_url":"https://github.com/sony/model_optimization","tags":["quantization","model compression","neural networks","deep learning","pytorch","tensorflow"],"install":[{"cmd":"pip install mct-quantizers","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"MCT Quantizers uses underscore in package name, not dot.","wrong":"from mct.quantizers import QuantizationConfig","symbol":"QuantizationConfig","correct":"from mct_quantizers import QuantizationConfig"},{"note":"PostTrainingQuantization is under framework-specific submodule.","wrong":"from mct_quantizers import PostTrainingQuantization","symbol":"PostTrainingQuantization","correct":"from mct_quantizers.pytorch import PostTrainingQuantization"},{"note":"Logger is a class, must be imported explicitly.","wrong":"import mct_quantizers.logger","symbol":"Logger","correct":"from mct_quantizers.logger import Logger"}],"quickstart":{"code":"import torch\nfrom mct_quantizers.pytorch import QuantizationConfig, PostTrainingQuantization\n\n# Create a simple model\nmodel = torch.nn.Sequential(torch.nn.Linear(10, 5), torch.nn.ReLU())\n\n# Define quantization configuration\nconfig = QuantizationConfig(n_bits=8, per_channel=True)\n\n# Apply post-training quantization\nptq = PostTrainingQuantization(model, config)\nquantized_model = ptq.quantize()\n\n# Save the quantized model\ntorch.save(quantized_model.state_dict(), 'quantized_model.pth')","lang":"python","description":"Basic usage: quantize a PyTorch model with post-training quantization."},"warnings":[{"fix":"Update imports: replace 'from mct_quantizers.quantization import QuantizationConfig' with 'from mct_quantizers import QuantizationConfig'.","message":"In version 1.5.0, the import path for QuantizationConfig changed from mct_quantizers.quantization to mct_quantizers. Old code will break.","severity":"breaking","affected_versions":"<1.5.0"},{"fix":"If using TensorFlow, migrate your pipeline to PyTorch or use mct-quantizers with ONNX backend.","message":"PostTrainingQuantization for TensorFlow models is deprecated since version 1.6.0 and will be removed in future releases. Use PyTorch or ONNX variants instead.","severity":"deprecated","affected_versions":"≥1.6.0"},{"fix":"Wrap your model with torch.nn.DataParallel before passing to PostTrainingQuantization.","message":"When using multi-GPU, the quantization process may fail if the model is not properly wrapped with DataParallel. This is not automatically handled.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Install with 'pip install mct-quantizers' and import as 'mct_quantizers' (underscore).","cause":"The package is not installed or imported with wrong name.","error":"ModuleNotFoundError: No module named 'mct_quantizers'"},{"fix":"Use 'from mct_quantizers import QuantizationConfig' (for versions >=1.5.0) or 'from mct_quantizers.quantization import QuantizationConfig' (for older versions).","cause":"Trying to import QuantizationConfig directly from top-level while it was moved from a submodule in version 1.5.0.","error":"AttributeError: module 'mct_quantizers' has no attribute 'QuantizationConfig'"},{"fix":"Check the list of supported layers in the documentation. Consider replacing unsupported layers with supported alternatives or skip quantization for those layers.","cause":"The model contains an unsupported layer/operation for quantization.","error":"RuntimeError: Quantization not supported for operation type ..."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}