Aidge Quantization Module
You can find in this folder the library that implements the quantization algorithms. For the moment only Post Training Quantization (PTQ) is available. Its implementation does support multiple branch architectures.
Prerequisite:
aidge_core
aidge_backend_cpuaidge_onnx- [OPTIONAL]
aidge_backend_cuda
pip install aidge-quantization
pip install aidge-quantization[cuda]
🛠 Build from Source
Prerequisite (in addition to previous one):
- Please review the global installation instructions before proceeding.
- If using a virtual environment, use the same one for all Aidge modules.
1. Python or C++ installation using setup scripts
| Environment | C++ Development | Python Development |
|---|---|---|
| Windows | .\setup.ps1 -Modules quantization -Tests -CppOnly |
.\setup.ps1 -Modules quantization -Tests |
| Unix | ./setup.sh -m quantization --tests --cpp-only |
./setup.sh -m quantization --tests |
2. Python Installation using pip
Run these commands from the aidge_quantization/ directory:
# Standard install
pip install . -v
# Install with testing dependencies
pip install .[test] -v && pytest
# Install with cuda dependencies
pip install .[cuda] -v
Editable Install (Experimental)
Use this for real-time development without re-installing.
pip install --no-build-isolation -ve . --config-settings=editable.rebuild=true -Cbuild-dir=build
3. C++ Installation (CMake)
A CMakePresets.json is provided for standard configurations.
# Configure, Build, and Install
cmake --preset clang-debug
cmake --build --preset clang-debug
cmake --install
# Run C++ Tests
ctest --test-dir build/
User guide
In order to perform a quantization, you will need an AIDGE model (that can be loaded from an ONNX). Then, you will have to provide a calibration dataset consisting of AIDGE tensors (that can be loaded from some numpy arrays). And finally, you will have to specify the quantization number of bits.
Performing the PTQ on your model will look like so:
ptq = aidge_quantization.PTQ(
aidge_model,
activation_precision=aidge_core.dtype.int8,
accumulation_precision=aidge_core.dtype.int32,
inference_precision=aidge_core.dtype.float32,
)
quantized_model = ptq.process(calibration_set)
Technical insights
The PTQ algorithm consists of 5 main steps:
- Insertion of the Quantizer nodes in the GraphView
- Computation of the input and output value ranges of each node over a calibration set
- Refinement of the value ranges using a Clipping policy
- Calibration of the Quantizer nodes so that their dynamics fit the provided precisions
- Cast of the inputs and outputs of each computational node to integer precision
Further work
- add Quantization Aware Training (QAT)
Metadata
Release files for aidge-quantization 0.11.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 259.8 MB
Release files / aidge_quantization-0.11.0-cp313-cp313-win_amd64.whl
| Download URL | aidge_quantization-0.11.0-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 5.7 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
29db4a903ff54f7a7c9d8bc0682c90905848e0a1b8deb53723961d65889d80b7
|
|
BLAKE2b-256 checksum How to use checksums |
0fde2e4f550ba1c9338533edf02e49a2e1cda1280b729c71af37f6e9026a6323
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / aidge_quantization-0.11.0-cp313-cp313-manylinux_2_28_x86_64.whl
| Download URL | aidge_quantization-0.11.0-cp313-cp313-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 59.3 MB |
| Tags | CPython 3.13 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
67e6ce29ec6d38fbdcbfea89c9d7dc3bdd1cae27ca7dba295cf6852639fde611
|
|
BLAKE2b-256 checksum How to use checksums |
5b8ae4d44ee95cc5d29f272c55f4a8d6fe0e8b52facf35feaa776234f4dcf612
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / aidge_quantization-0.11.0-cp312-cp312-win_amd64.whl
| Download URL | aidge_quantization-0.11.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 5.7 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b59b0c813b553edcf1044f96e45393bdd51b393dfbdee49b4fe1704aabf82f83
|
|
BLAKE2b-256 checksum How to use checksums |
c17ddbbc0a33c66645978a816a704f4c5aa80e0416cdf38d78827d9ed05578c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / aidge_quantization-0.11.0-cp312-cp312-manylinux_2_28_x86_64.whl
| Download URL | aidge_quantization-0.11.0-cp312-cp312-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 59.3 MB |
| Tags | CPython 3.12 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
a099dffc963a886441677c5d506bf41df756837790a089209a1fcfe773370643
|
|
BLAKE2b-256 checksum How to use checksums |
27729c6f632d2c7db52c888e3b0cdd90831ed20ceb394edd38f17445b1c739a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / aidge_quantization-0.11.0-cp311-cp311-win_amd64.whl
| Download URL | aidge_quantization-0.11.0-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 5.7 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b5ed59a9e59c52855df5f2433bf40d796875ae05e02aa6a58f0338e92518848b
|
|
BLAKE2b-256 checksum How to use checksums |
f05cd0c5800a031e1e7f39fad5b5ce1fc887856153b30fa48adea1cff51abbd1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / aidge_quantization-0.11.0-cp311-cp311-manylinux_2_28_x86_64.whl
| Download URL | aidge_quantization-0.11.0-cp311-cp311-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 59.3 MB |
| Tags | CPython 3.11 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
fe1f59f383edfb09e22bf63d467a431e6ba74e128e9d66d93d9d0188b0425913
|
|
BLAKE2b-256 checksum How to use checksums |
604b6f5e5b34500e1a2f77a861e269edcde5bd7e86349c0e5ddf7ec5bac3f958
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / aidge_quantization-0.11.0-cp310-cp310-win_amd64.whl
| Download URL | aidge_quantization-0.11.0-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 5.7 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
d313decbc3a88c472364184fe94c8801651f1e934f0f175c06321ad428bcae9f
|
|
BLAKE2b-256 checksum How to use checksums |
e1175cfd0920c2fceb52fa3ec03c28e3cd7fc82912d92f1df436f722e777d914
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / aidge_quantization-0.11.0-cp310-cp310-manylinux_2_28_x86_64.whl
| Download URL | aidge_quantization-0.11.0-cp310-cp310-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 59.3 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
6f353cf9873893561f731ad739a8f22cf76d91b1450b6ba4db0c1cde969785da
|
|
BLAKE2b-256 checksum How to use checksums |
8948ad28a65a57c109e9e8c2c7ad711dd5439fa28705b45b02e1034d677182c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for aidge-quantization 0.11.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.