Unified LLM quantization with automated benchmarking and comparison.
Quantize models with multiple methods (GPTQ, AWQ, BitsAndBytes, GGUF), benchmark them automatically, and get comparison reports with hardware-aware recommendations.
Existing tools like auto-gptq, autoawq, and llama.cpp each handle a single quantization method. Blog posts and papers compare methods manually. No tool combines:
- Quantization with multiple methods in one command
- Automated benchmarking (perplexity, latency, memory, task accuracy)
- Comparison reports that tell you which method is best for your hardware
llm-quanta fills this gap.
Note: This package is not yet published to PyPI. Install directly from source.
git clone https://github.com/T9ner/llm-quanta.git
cd llm-quanta
# Core install (editable)
pip install -e .
# With specific quantization backends
pip install -e ".[gptq]" # auto-gptq
pip install -e ".[awq]" # autoawq
pip install -e ".[bitsandbytes]"
pip install -e ".[gguf]" # llama-cpp-python
# Everything
pip install -e ".[all]"llm-quanta quantize meta-llama/Llama-2-7b-hf \
--methods gptq awq bnb-nf4 \
--output-dir ./quantizedllm-quanta benchmark ./quantized/gptq \
--benchmarks perplexity latency memoryllm-quanta compare meta-llama/Llama-2-7b-hf \
--methods gptq awq bnb-nf4 \
--output-dir ./comparison \
--recommendThis generates:
./comparison/report.html- Visual comparison with charts./comparison/report.md- Markdown summary./comparison/results.csv- Raw benchmark data./comparison/results.json- Machine-readable results
| Method | Description | Best For |
|---|---|---|
gptq |
Gradient Post-Training Quantization | GPU inference, good quality |
awq |
Activation-aware Weight Quantization | GPU inference, best quality |
bnb-nf4 |
BitsAndBytes 4-bit NF4 | Quick tests, QLoRA fine-tuning |
bnb-int8 |
BitsAndBytes 8-bit | Higher quality, more memory |
gguf-q4 |
GGUF 4-bit K-quant | CPU inference, llama.cpp |
gguf-q8 |
GGUF 8-bit | CPU inference, best quality |
from llm_quanta.quantizers import QuantizerRegistry
from llm_quanta.benchmarks import BenchmarkRunner
from llm_quanta.reports import ReportGenerator
# Quantize with a specific method
quantizer = QuantizerRegistry.get("awq")
result = quantizer.quantize("meta-llama/Llama-2-7b-hf", output_dir="./quantized")
# Run benchmarks
runner = BenchmarkRunner()
benchmarks = runner.run_all("./quantized/awq")
# Generate comparison report
generator = ReportGenerator()
report = generator.generate(
model_id="meta-llama/Llama-2-7b-hf",
quantization_results=[result],
benchmark_results={"awq": benchmarks},
)
report.save("./output")- Not just quantization: Benchmarking and comparison are first-class features
- Hardware recommendations: "Given your 16GB GPU, use AWQ-4bit" - not blog posts
- Calibration dataset comparison: Test how calibration data affects quality
- Unified interface: Same CLI for all methods, same output format
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest tests/ -v
# Type check
mypy src/llm_quanta
# Format
ruff format src/MIT