Mono Quant
Ultra-lightweight, model-agnostic quantization for PyTorch
What is Mono Quant?
Mono Quant is a simple, reliable model quantization package for PyTorch with minimal dependencies. Just torch and numpy, no bloat.
Key Features
- Model-Agnostic - Works with any PyTorch model: HuggingFace, local, or custom
- Multiple Modes - INT8, INT4, and FP16 quantization
- Flexible Calibration - Dynamic (no data) or static (with calibration data)
- Robust Validation - SQNR metrics, size comparison, and accuracy warnings
- Dual Interface - Python API for automation, CLI for CI/CD
- Build-Phase Only - Quantize during build, deploy lightweight models
Installation
pip install mono-quant
Requirements
- Python 3.11 or higher
- PyTorch 2.0 or higher
- NumPy 1.24 or higher
Quick Start
Python API
from mono_quant import quantize
# Dynamic INT8 quantization (no calibration data needed)
result = quantize(model, bits=8, dynamic=True)
# Save the quantized model
result.save("model_quantized.pt")
# Check metrics
print(f"Compression: {result.info.compression_ratio:.2f}x")
print(f"SQNR: {result.info.sqnr_db:.2f} dB")
CLI
# Dynamic quantization
monoquant quantize --model model.pt --bits 8 --dynamic
# With custom output path
monoquant quantize --model model.pt --bits 8 --output model_quantized.pt
Quantization Modes
Dynamic Quantization (Fastest, No Data)
result = quantize(model, bits=8, dynamic=True)
Static Quantization (Best Accuracy, Requires Data)
calibration_data = [torch.randn(1, 3, 224, 224) for _ in range(150)]
result = quantize(
model,
bits=8,
dynamic=False,
calibration_data=calibration_data
)
INT4 Quantization (Maximum Compression)
result = quantize(
model,
bits=4,
dynamic=False,
calibration_data=calibration_data,
group_size=128 # Default
)
Documentation
Full documentation available at https://thataverageguy.github.io/mono-quant
Why Mono Quant?
Most quantization tools are tied to specific frameworks (HuggingFace, TFLite) or require heavy dependencies. Mono Quant fills the niche of "just quantize the weights, nothing else."
Design Philosophy
| Aspect | Approach |
|---|---|
| Model Loading | You load the model, we quantize it |
| Dependencies | Only torch and numpy required |
| Use Case | Build-phase (CI/CD, local development) |
| Scope | Quantization only, no runtime or serving |
License
MIT License - see LICENSE for details.
Contributing
Contributions welcome! Please see CONTRIBUTING.md for guidelines.
Links
Metadata
Release files for mono-quant 1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mono_quant-1.1.tar.gz | 64.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mono_quant-1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 138.6 kB
Release files / mono_quant-1.1.tar.gz
| Download URL | mono_quant-1.1.tar.gz |
|---|---|
| Size | 64.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bba481db3e0d7b11d5db3ce8b3da3c7125e458b6921229e0ad8bfd02e2dad1c1
|
|
BLAKE2b-256 checksum How to use checksums |
5ece5eb103cf92188c9d1276789a2e148ecae21bec44982f62b022c4a91998cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / mono_quant-1.1-py3-none-any.whl
| Download URL | mono_quant-1.1-py3-none-any.whl |
|---|---|
| Size | 74.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d2279c98645fcaa03211369b8d65dcc5727a7f2df604ed0c8cdf8914f77785ff
|
|
BLAKE2b-256 checksum How to use checksums |
da29d898c39b62f7a4f0afd3963956dd42b88fabec35d2d0db99d07feee8ab49
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|