Onnx quantization

From VectorSpaceLab/AREX-Skill · View interactive version

Onnx quantization is an AI agent skill from the GitHub repository VectorSpaceLab/AREX-Skill. Use AIMET ONNX for QuantizationSimModel calibration, provider selection, encodings, QDQ export, graph passes, and ONNX PTQ utilities.

How to use this skill

Skill file

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

Core workflow

  1. Validate the ONNX graph. Start from a valid onnx.ModelProto; simplify or clean the graph before QuantSim if the export is noisy.
  2. Choose precision. Use param_type and activation_type (int8, int16, float16, or QSpec/granularity objects) based on target accuracy/performance constraints.
  3. Choose providers deliberately. Default CPU provider is sufficient for most graph work; CUDA provider requires onnxruntime-gpu and a visible CUDA runtime.
  4. Create QuantSim. Pass the model, quant scheme, config file, dummy input if needed, custom op libraries if needed, and provider list.
  5. Calibrate with dictionaries. Calibration batches should be {input_name: np_array} mappings with valid shapes and dtypes.
  6. Apply PTQ utilities when needed. Run SeqMSE, AdaRound, blockwise/LPBQ, or tensor-precision overrides before final calibration/export when the task calls for them.
  7. 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

Boundaries

Expected answer shape

When answering an ONNX AIMET request, include:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.