AIMET ONNX quantization
Use this sub-skill for aimet_onnx, ONNX QuantizationSimModel, ONNX Runtime providers, input dictionaries, encodings import/export, QDQ conversion, tensor precision controls, graph passes, AdaRound, SeqMSE, and ONNX-side analysis utilities.
Read/run first
- Read API overview for verified
aimet_onnx signatures and utility entry points.
- Read workflows for the distilled ONNX QuantSim/PTQ loop.
- Read backend compatibility for CPU provider versus CUDAExecutionProvider evidence.
- Read troubleshooting for input-shape, provider, graph-pass, encoding-load, and QDQ/export issues.
- Run quick_smoke.py with
--framework onnx to prove the installed package can quantize a tiny ONNX model.
Core workflow
- Validate the ONNX graph. Start from a valid
onnx.ModelProto; simplify or clean the graph before QuantSim if the export is noisy.
- Choose precision. Use
param_type and activation_type (int8, int16, float16, or QSpec/granularity objects) based on target accuracy/performance constraints.
- Choose providers deliberately. Default CPU provider is sufficient for most graph work; CUDA provider requires
onnxruntime-gpu and a visible CUDA runtime.
- Create QuantSim. Pass the model, quant scheme, config file, dummy input if needed, custom op libraries if needed, and provider list.
- Calibrate with dictionaries. Calibration batches should be
{input_name: np_array} mappings with valid shapes and dtypes.
- Apply PTQ utilities when needed. Run SeqMSE, AdaRound, blockwise/LPBQ, or tensor-precision overrides before final calibration/export when the task calls for them.
- Export. Use
sim.export(...) for AIMET model + encodings, or sim.to_onnx_qdq(...) / from_onnx_qdq(...) when the downstream workflow needs QDQ graphs.
Decision points
- Plain encodings vs QDQ: Choose the artifact form required by the target toolchain; QDQ nodes are not the same as a separate encodings JSON.
- Strict encoding loads: Use strict behavior for deployment readiness; only use non-strict loading when explicitly inspecting graph differences.
- Dynamic shapes: Build calibration inputs that satisfy the symbolic shape constraints observed by ONNX Runtime.
- Custom ops: Provide
user_onnx_libs only when the model actually contains custom ops and the library is available.
Boundaries
- Route PyTorch model-preparation, QAT, and Torch export questions to torch-quantization.
- Route accuracy-debugging, visualization, compression, and target handoff to optimization-analysis-deployment.
- LLM topology/configurator and GenAILab automation are deferred unless a future skill extension adds that scope.
Expected answer shape
When answering an ONNX AIMET request, include:
- ONNX graph validation/simplification assumptions;
QuantizationSimModel constructor arguments and provider list;
- calibration input dictionary shape;
- whether PTQ utilities are applied before final calibration;
- export form and expected artifacts;
- provider/backend verification required before claiming CUDA behavior.
1---2name: onnx-quantization3description: "Use AIMET ONNX for QuantizationSimModel calibration, provider4 selection, encodings, QDQ export, graph passes, and ONNX PTQ utilities."5metadata:6 source: https://skillmd.com/skills/vectorspacelab/onnx-quantization7 disco-role: operating8disable-model-invocation: true9license: BSD 3-Clause10---1112# AIMET ONNX quantization1314Use this sub-skill for `aimet_onnx`, ONNX `QuantizationSimModel`, ONNX Runtime providers, input dictionaries, encodings import/export, QDQ conversion, tensor precision controls, graph passes, AdaRound, SeqMSE, and ONNX-side analysis utilities.1516## Read/run first1718- Read [API overview](../../references/api-overview.md) for verified `aimet_onnx` signatures and utility entry points.19- Read [workflows](../../references/workflows.md) for the distilled ONNX QuantSim/PTQ loop.20- Read [backend compatibility](../../references/backend-compatibility.md) for CPU provider versus CUDAExecutionProvider evidence.21- Read [troubleshooting](../../references/troubleshooting.md) for input-shape, provider, graph-pass, encoding-load, and QDQ/export issues.22- Run [quick_smoke.py](../../scripts/quick_smoke.py) with `--framework onnx` to prove the installed package can quantize a tiny ONNX model.2324## Core workflow25261. **Validate the ONNX graph.** Start from a valid `onnx.ModelProto`; simplify or clean the graph before QuantSim if the export is noisy.272. **Choose precision.** Use `param_type` and `activation_type` (`int8`, `int16`, `float16`, or `QSpec`/granularity objects) based on target accuracy/performance constraints.283. **Choose providers deliberately.** Default CPU provider is sufficient for most graph work; CUDA provider requires `onnxruntime-gpu` and a visible CUDA runtime.294. **Create QuantSim.** Pass the model, quant scheme, config file, dummy input if needed, custom op libraries if needed, and provider list.305. **Calibrate with dictionaries.** Calibration batches should be `{input_name: np_array}` mappings with valid shapes and dtypes.316. **Apply PTQ utilities when needed.** Run SeqMSE, AdaRound, blockwise/LPBQ, or tensor-precision overrides before final calibration/export when the task calls for them.327. **Export.** Use `sim.export(...)` for AIMET model + encodings, or `sim.to_onnx_qdq(...)` / `from_onnx_qdq(...)` when the downstream workflow needs QDQ graphs.3334## Decision points3536- **Plain encodings vs QDQ:** Choose the artifact form required by the target toolchain; QDQ nodes are not the same as a separate encodings JSON.37- **Strict encoding loads:** Use strict behavior for deployment readiness; only use non-strict loading when explicitly inspecting graph differences.38- **Dynamic shapes:** Build calibration inputs that satisfy the symbolic shape constraints observed by ONNX Runtime.39- **Custom ops:** Provide `user_onnx_libs` only when the model actually contains custom ops and the library is available.4041## Boundaries4243- Route PyTorch model-preparation, QAT, and Torch export questions to [torch-quantization](../torch-quantization/SKILL.md).44- Route accuracy-debugging, visualization, compression, and target handoff to [optimization-analysis-deployment](../optimization-analysis-deployment/SKILL.md).45- LLM topology/configurator and GenAILab automation are deferred unless a future skill extension adds that scope.4647## Expected answer shape4849When answering an ONNX AIMET request, include:5051- ONNX graph validation/simplification assumptions;52- `QuantizationSimModel` constructor arguments and provider list;53- calibration input dictionary shape;54- whether PTQ utilities are applied before final calibration;55- export form and expected artifacts;56- provider/backend verification required before claiming CUDA behavior.