Example Notebooks

AIMET’s end-to-end examples are provided as Jupyter Notebooks designed to help you:

  • Get familiar with the AIMET APIs

  • Learn how to apply AIMET to pre-trained models from PyTorch, ONNX, and TensorFlow frameworks

  • Understand and implement AIMET’s quantization and compression techniques

For a deeper dive into these techniques, refer to the Optimization User Guide. For detailed API documentation, see the API Reference, see API reference

Browse the notebooks

The tables below provide links to viewable HTML versions of Jupyter Notebooks that showcase AIMET’s quantization and compression features.

Following the tables, you’ll find step-by-step instructions on how to run these notebooks locally or in your preferred environment.

Model Quantization Examples

Features

ONNX

PyTorch

TensorFlow

Quantization simulation (QuantSim)

Link

Link

Link

Quantization-aware training (QAT)

Not implemented.

Link

Link

Cross-layer equalization (CLE)

Link

Link

Link

Adaptive rounding (AdaRound)

Link

Link

Link

Automatic quantization (AutoQuant)

Not implemented.

Link

Link

Automatic mixed precision (AMP)

Link

Link

Link

BatchNorm re-estimation

Not implemented.

Link

Link

Quant analyzer

Not implemented.

Link

Link

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/onnx/quantization/

  • Examples/torch/quantization/

  • Examples/tensorflow/quantization/keras/

Model compression notebooks

  • Examples/torch/compression/

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