Examples

AIMET end-to-end examples are Jupyter Notebooks that are intended to:

  • Familiarize you with the AIMET APIs,

  • Demonstrate how to apply AIMET to a pre-trained model from PyTorch, TensorFlow and ONNX frameworks,

  • Teach you how to use AIMET quantization and compression techniques.

For a discussion of quantization and compression techniques, see Optimization User Guide.

For the API reference, see API reference

Browse the notebooks

The following tables provide links to viewable HTML versions of the jupyter notebooks for AIMET quantization and compression features. Instructions after the tables describe how to run the notebooks.

Model Quantization Examples

Features

PyTorch

TensorFlow

ONNX

Quantization simulation (QuantSim)

Link

Link

Link

Quantization-aware training (QAT)

Link

Link

Not implemented.

Cross-layer equalization (CLE)

Link

Link

Link

Adaptive rounding (AdaRound)

Link

Link

Link

Automatic quantization (AutoQuant)

Link

Link

Not implemented.

Automatic mixed precision (AMP)

Link

Link

Link

BatchNorm re-estimation

Link

Link

Not implemented.

Quant analyzer

Link

Link

Not implemented.

Model Compression Examples

Features

PyTorch

Channel Pruning

Link

Spatial SVD

Link

Spatial SVD + Channel Pruning

Link

Running the notebooks

To run the notebooks, follow the instructions below.

1. Run the notebook server

  1. Install the Jupyter metapackage using the following command. (Prepend the command with sudo -H if necessary to grant admin privilege.)

    python3 -m pip install jupyter
    
  2. Start the notebook server as follows:

    jupyter notebook --ip=* --no-browser &
    

    The command generates and displays a URL in the terminal.

  3. Copy and paste the URL into your browser.

  4. Install AIMET and its dependencies using the instructions in AIMET installation.

3. Run the notebooks

  1. Navigate to one of the following paths in your local repository directory and launch your chosen jupyter notebook (.ipynb extension):

Model quantization notebooks

  • Examples/torch/quantization/

  • Examples/tensorflow/quantization/keras/

  • Examples/onnx/quantization/

Model compression notebooks

  • Examples/torch/compression/

  1. Follow the instructions in the notebook to execute the code.