Catalog PyPI
Back to packageRELEASE DETAILS

0.10.1

PyPI

aidge-quantization

Quantization algorithms to compress aidge networks.

Published17 Sept 2026
Direct dependencies6
Transitive dependenciesNot calculated

README

Version 0.10.1 documentation

Aidge logo

EPL 2.0 Examples PyPi Examples Documentation Status GitLab Contributors Open GitLab Issues Closed GitLab Issues

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_cpu
  • aidge_onnx
  • [OPTIONAL] aidge_backend_cuda
pip install aidge-quantization
pip install aidge-quantization[cuda]

🛠 Build from Source

Prerequisite (in addition to previous one):

1. Python or C++ installation using setup scripts

EnvironmentC++ DevelopmentPython 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

[!TIP] Use Get-Help setup.ps1 (Windows) or ./setup.sh -h (Unix) for full documentation.

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/

[!TIP] Create a CMakeUserPresets.json to define your own local build configurations.

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 then be a one liner:

aidge_quantization.quantize_network(aidge_model, nb_of_bits, calibration_set)

Technical insights

The PTQ algorithm consists of 3 main steps:

- Normalization of the parameters, so that each node set of weights fits in the [-1:1] range.
- Normalization of the activations, so that each node output value fits in the [-1:1] range.
- Quantization of the scaling nodes previously inserted

To achieve those steps, one must propagate the scaling factors inside the network. One should also balance the different branches when they are merging. A particular care is needed for the biases rescaling at each step.

Doing quantization step by step

It is possible to perform the PTQ step by step, thanks to the exposed functions of the API. In that case, here is the standard pipeline:

- Prepare the network for the PTQ (remove the flatten nodes, fuse the BatchNorms ...)
- Insert the scaling nodes that will allow the model calibration
- Perform the Cross Layer Equalization if possible
- Perform the parameter normalization
- Compute the node output ranges over an input calibration dataset
- Adjust the output ranges using a specified error metric (MSE, KL, ...)
- Perform the activation normalization
- Quantize the normalized network
- Convert the scaling factors to bit-shifting operations if needed

Further work

  • add Quantization Aware Training (QAT)

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 6

Native requirements
6 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
numpy
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
numpy>=1.21.6runtime
aidge_core
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
aidge_coreruntime
aidge_backend_cpu
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
aidge_backend_cpuruntime
pytest
Environment
{
  "extras": "",
  "marker": "extra == \"test\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
pytest; extra == "test"runtime
aidge_onnx
Environment
{
  "extras": "",
  "marker": "extra == \"test\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
aidge_onnx; extra == "test"runtime
aidge_backend_cuda
Environment
{
  "extras": "",
  "marker": "extra == \"cuda\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
aidge_backend_cuda; extra == "cuda"runtime

Distribution files

8 collected
aidge_quantization-0.10.1-cp310-cp310-manylinux_2_28_x86_64.whl

bdist_wheel · 57,770.01 KB · Python cp310

Source file
aidge_quantization-0.10.1-cp310-cp310-win_amd64.whl

bdist_wheel · 5,209.84 KB · Python cp310

Source file
aidge_quantization-0.10.1-cp311-cp311-manylinux_2_28_x86_64.whl

bdist_wheel · 57,784.33 KB · Python cp311

Source file
aidge_quantization-0.10.1-cp311-cp311-win_amd64.whl

bdist_wheel · 5,213.87 KB · Python cp311

Source file
aidge_quantization-0.10.1-cp312-cp312-manylinux_2_28_x86_64.whl

bdist_wheel · 57,775.63 KB · Python cp312

Source file
aidge_quantization-0.10.1-cp312-cp312-win_amd64.whl

bdist_wheel · 5,220.92 KB · Python cp312

Source file
aidge_quantization-0.10.1-cp313-cp313-manylinux_2_28_x86_64.whl

bdist_wheel · 57,775.67 KB · Python cp313

Source file
aidge_quantization-0.10.1-cp313-cp313-win_amd64.whl

bdist_wheel · 5,221.83 KB · Python cp313

Source file

Metadata history

Meaningful changes
Current collected state Current

Observed since 21 Oct, 10:28 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:efcad76bc1a7bee4d5f75b14ec6a78ebf7139d35dcee59699d509e0356a318c5

Other collected versions

View all collected versions →