--- id: optimum-quanto version: "0.2.7" license: Apache-2.0 license_treatment: permissive maintenance: active --- # optimum-quanto — A pytorch quantization backend for optimum. License: permissive · Maintenance: active · Downloads: 292.5K/mo ## What it is and what it does Optimum Quanto is a PyTorch quantization backend that converts trained models to lower-precision representations—int2, int4, int8, or float8 for weights and activations—to reduce memory footprint and accelerate inference. It integrates with the optimum framework, offering both high-level APIs and a low-level API for vanilla PyTorch models. The package supports a full workflow: quantize a model, optionally calibrate activations on representative data, fine-tune if needed, freeze weights to integer values, and serialize using safetensors or pickle. Designed for eager-mode execution (works with non-traceable models), Quanto automatically inserts quantization stubs and operations into the model graph. It supports mixed-precision matrix multiplications on CUDA (int8-int8, fp16-int4, bf16-int8, bf16-int4) and aims for accuracy comparable to full-precision models when using int8 or float8 weights with float8 activations. The package is actively maintained but still pre-alpha; torch.compiler compatibility and dynamic activation smoothing are listed as not yet implemented. Use it for: - Quantize large models to int4 or int8 to reduce memory requirements and fit models on resource-constrained devices. - Compress model transformers to float8 for faster inference while preserving accuracy. - Calibrate and fine-tune quantized models on representative data to recover accuracy lost during quantization. - Serialize quantized model weights to safetensors format for efficient storage and distribution. - Deploy quantized models by reducing memory footprint and leveraging accelerated kernels on CUDA. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. A PyTorch quantization backend that reduces model size and memory by converting weights and activations to lower-precision integer or float8 formats while maintaining inference accuracy. Yes, if you need to quantize PyTorch models for inference efficiency. The package is actively maintained, has no known vulnerabilities, and offers both high-level integration and low-level control. Install with caution if you depend on torch.compile or require production-grade stability—it is pre-alpha and some features remain unimplemented. ## Install pip install optimum-quanto uv add optimum-quanto poetry add optimum-quanto ## Installing optimum-quanto Before you install: Low friction installation as a pure Python wheel. Actively maintained with recent commits and a stable release cadence; marked pre-alpha but in active development with no known vulnerabilities. License in practice: Apache-2.0 permissive license allows commercial and private use with minimal restrictions; suitable for most projects. Quickstart: pip install optimum-quanto from optimum.quanto import quantize, qint8 import torch model = torch.nn.Linear(10, 10) quantize(model, weights=qint8, activations=qint8) Requires torch, ninja, numpy, safetensors, and huggingface_hub as runtime dependencies; Python 3.9 or later. Verify before relying: - Whether accelerated kernels are available for all target hardware (CUDA, MPS, CPU) or only a subset. - Actual inference latency overhead compared to full-precision models on different hardware. - Compatibility with torch.compile and whether that feature is production-ready. - Support for quantization-aware training workflows and convergence behavior. ## Package facts - License: Apache-2.0 (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 292.5K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags pytorch model quantization, reduce model size int8 int4, weight quantization pytorch, model compression quantization, float8 quantization pytorch, inference optimization quantization, quantized model serialization, model-compression, quantization, inference-optimization [View on SkillFed](https://skillfed.io/packages/optimum-quanto) · [View on PyPI](https://pypi.org/project/optimum-quanto/)