Torch quantization

From VectorSpaceLab/AREX-Skill · View interactive version

Torch quantization is an AI agent skill from the GitHub repository VectorSpaceLab/AREX-Skill. Use AIMET Torch for model preparation, QuantizationSimModel calibration, PTQ/QAT, encodings, and Torch export workflows.

How to use this skill

Skill file

AIMET Torch quantization

Use this sub-skill for aimet_torch, PyTorch QuantizationSimModel, model preparation, BatchNorm folding, calibration callbacks, QAT, Torch PTQ utilities, quantizer inspection, and exporting Torch QuantSim results.

Read/run first

Core workflow

  1. Stabilize the PyTorch model. Use eval() for PTQ and a representative dummy_input on the same device as the model.
  2. Prepare the graph when needed. If forward uses torch.nn.functional ops, reused modules, or FX-trace-sensitive code, run aimet_torch.model_preparer.prepare_model and compare outputs.
  3. Fold BatchNorm when deployment expects it. Use aimet_torch.batch_norm_fold.fold_all_batch_norms before QuantSim when appropriate.
  4. Create QuantSim. Configure default_output_bw, default_param_bw, quant_scheme, optional config_file, in_place, and default_data_type.
  5. Compute encodings. The callback should run representative data through the QuantSim model without labels or optimizer updates.
  6. Evaluate and iterate. Compare FP32, high-bit-width, and target-bit-width accuracy before adding QAT or advanced PTQ.
  7. Export. Use the AIMET export path that creates a model plus encodings; keep artifacts together for downstream deployment.

Decision points

Boundaries

Expected answer shape

When answering a Torch 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.