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):
PCQ + SpinQuant + AdaScale
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)
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=20SeqMSE:
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).
| Model | Weights | Acts | Recipe | PPL | MMLU | Time (min) | CUDA (GB) | Config |
|---|---|---|---|---|---|---|---|---|
| LLaMA 3.2 1B Instruct | FP32 | FP32 | — | 12.14 | 46.06 | <1 | 6 | — |
| INT4 PCQ | INT16 KV=INT8 | SpinQuant AdaScale (b=128, i=2048) |
13.67 | 42.25 | 151 | 21 | YAML | |
| INT4 LPBQ | INT16 KV=INT8 | SeqMSE | 14.07 | 43.09 | 45 | 29 | YAML | |
| LLaMA 3.2 3B Instruct | FP32 | FP32 | — | 10.13 | 60.74 | <1 | 14 | — |
| INT4 PCQ | INT16 KV=INT8 | SpinQuant AdaScale (b=128, i=1024) |
11.01 | 58.09 | 395 | 41 | YAML | |
| INT4 LPBQ | INT16 KV=INT8 | SeqMSE | 10.69 | 59.08 | 162 | 51 | YAML | |
| Qwen 2.5 0.5B Instruct | FP32 | FP32 | — | 13.14 | 46.30 | <1 | 4 | — |
| INT4 PCQ | INT16 KV=INT16 | SpinQuant AdaScale (b=128, i=2048) |
13.89 | 44.19 | 200 | 13 | YAML | |
| INT4 LPBQ | INT16 KV=INT16 | SeqMSE | 15.32 | 42.33 | 23 | 14 | YAML | |
| Qwen 2.5 1.5B Instruct | FP32 | FP32 | — | 12.41 | 54.65 | <1 | 8 | — |
| INT4 PCQ | INT16 KV=INT16 | SpinQuant AdaScale (b=128, i=1024) |
13.57 | 49.81 | 183 | 23 | YAML | |
| INT4 LPBQ | INT16 KV=INT16 | SeqMSE | 14.86 | 49.25 | 68 | 26 | YAML | |
| Qwen 3 4B | FP32 | FP32 | — | 12.41 | 70.06 | <1 | 17 | — |
| INT4 PCQ | INT16 KV=INT8 | SpinQuant AdaScale (b=128, i=512) |
13.85 | 65.07 | 402 | 48 | YAML | |
| INT4 LPBQ | INT16 KV=INT8 | SeqMSE | 13.10 | 65.66 | 162 | 39 | YAML | |
| Phi 3.5 mini instruct | FP32 | FP32 | — | 5.77 | 68.89 | <1 | 16 | — |
| INT4 PCQ | INT16 KV=INT8 | SpinQuant AdaScale (b=32, i=256) |
6.58 | 62.62 | 257 | 48 | YAML | |
| INT4 LPBQ | INT16 KV=INT8 | SeqMSE | 6.45 | 64.63 | 124 | 38 | YAML |
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.