On this page

Quantization recipes for LLMs (AIMET Torch)

This page is a companion to the Quantization recipes for LLMs tutorial. The primary tutorial reports results using aimet-onnx. For completeness, this page reports the equivalent results obtained by quantizing with aimet-torch.

The same two reference recipes are applied (INT4 weights, INT16 activations):

  1. PCQ + SpinQuant + AdaScale

  2. LPBQ + SeqMSE

Refer to the primary tutorial for the recipe descriptions, system requirements, and FAQs.

Note

Due to PyTorch limitations, certain functional operations (torch.nn.functional) cannot have quantizers inserted, which makes a mixed-precision profile (e.g., INT8 KV Cache) challenging to apply directly. To address this, models quantized with aimet-torch are evaluated on aimet-onnx, which provides a static graph that ensures correct quantizer insertion for all activations and a more accurate quantization simulation.

Accuracy Results

We report accuracy using two key metrics, alongside the cost of running each recipe:

  • Perplexity (PPL) on WikiText (English)

  • MMLU

  • End-to-end runtime for each quantization recipe

  • Peak CUDA memory usage during quantization

Models are quantized with aimet-torch and evaluated on aimet-onnx, using a sequence length of 2048 tokens (AR-2048) and a context length of 4096 tokens.

The FP32 row for each model is the unquantized baseline. The following settings are common across all models:

  • Embedding: INT16

  • LM Head weights: INT8

  • Calibration: num_iterations=20

  • SeqMSE: num_iterations=20

The KV Cache precision varies per model and is shown on the second line of the Acts column.

AdaScale num_batches and num_iterations vary per model and are noted inline in the Recipe column as AdaScale (b=<num_batches>, i=<num_iterations>).

The Config column links the GenAI Lab YAML config for each quantized row. To reproduce an FP32 baseline, take any config for that model, remove its precision and recipe sections, and run it with --framework onnx (the FP32 baseline is evaluated on aimet-onnx).

ModelWeightsActsRecipe PPLMMLUTime (min)CUDA (GB)Config
LLaMA 3.2 1B Instruct FP32FP32—12.1446.06<16—
INT4 PCQINT16
KV=INT8
SpinQuant
AdaScale (b=128, i=2048)
13.6742.2515121YAML
INT4 LPBQINT16
KV=INT8
SeqMSE 14.0743.094529YAML
LLaMA 3.2 3B Instruct FP32FP32—10.1360.74<114—
INT4 PCQINT16
KV=INT8
SpinQuant
AdaScale (b=128, i=1024)
11.0158.0939541YAML
INT4 LPBQINT16
KV=INT8
SeqMSE 10.6959.0816251YAML
Qwen 2.5 0.5B Instruct FP32FP32—13.1446.30<14—
INT4 PCQINT16
KV=INT16
SpinQuant
AdaScale (b=128, i=2048)
13.8944.1920013YAML
INT4 LPBQINT16
KV=INT16
SeqMSE 15.3242.332314YAML
Qwen 2.5 1.5B Instruct FP32FP32—12.4154.65<18—
INT4 PCQINT16
KV=INT16
SpinQuant
AdaScale (b=128, i=1024)
13.5749.8118323YAML
INT4 LPBQINT16
KV=INT16
SeqMSE 14.8649.256826YAML
Qwen 3 4B FP32FP32—12.4170.06<117—
INT4 PCQINT16
KV=INT8
SpinQuant
AdaScale (b=128, i=512)
13.8565.0740248YAML
INT4 LPBQINT16
KV=INT8
SeqMSE 13.1065.6616239YAML
Phi 3.5 mini instruct FP32FP32—5.7768.89<116—
INT4 PCQINT16
KV=INT8
SpinQuant
AdaScale (b=32, i=256)
6.5862.6225748YAML
INT4 LPBQINT16
KV=INT8
SeqMSE 6.4564.6312438YAML

Reproduce the results

Set up GenAI Lab as described in Reproduce the results, with both aimet-torch and aimet-onnx installed. Add a top-level eval_in_onnx: true line to the config linked in the results table, then run it with aimet-torch:

echo "eval_in_onnx: true" >> GenAILab/configs/recipes/llama-3.2-1b-instruct/lpbq_seqmse.yaml
python -m GenAILab --framework torch \
    --config GenAILab/configs/recipes/llama-3.2-1b-instruct/lpbq_seqmse.yaml

This exports the quantized model and an onnx_eval_config.yaml to GenAILab/artifacts/exports/<model>_<timestamp>/, where <model> is the Hugging Face model name without the organization (e.g. Llama-3.2-1B-Instruct). The metrics this run prints are evaluated in aimet-torch and are not the reported numbers. Evaluate the export on aimet-onnx to get the reported numbers:

python -m GenAILab --framework onnx \
    --config GenAILab/artifacts/exports/<model>_<timestamp>/onnx_eval_config.yaml

Contact Us

Please reach out to us if you encounter any issue with this tutorial or applying recipes to similar models.