Skip to main content

Graph Quantizer

Graph Quantizer (GQ) reduces model precision at the intermediate representation (NPIR) level using calibration data. It converts floating-point weights and activations to integers with lower bit widths. This process enables faster inference and smaller model size while keeping accuracy degradation within acceptable bounds.

Overview​

Graph Quantize runs after Graph Optimize and operates on the optimized NPIR. It uses calibration data to measure activation ranges for each layer. It then assigns quantization parameters (scale, zero-point) to each operator.

Pipeline position​

GQ supports standard quantization and Automatic Mixed Precision (AMP). AMP automatically assigns different bit widths to different layers.

Configuration​

Parameters​

ParameterRequiredDescriptionAccepted values
schemeYesWeight and activation bit widthW8-A8, W8-A8_dynamic, W4-A8_dynamic

Hardware availability​

Supported schemes vary by target hardware backend. The device that you configure at project creation determines the available options.

BackendSupported schemes
XNNPACKW8-A8, W8-A8_dynamic, W4-A8_dynamic
Ethos-UW8-A8, W8-A16

Choosing a scheme​

  • Start with W8-A8; it is the most stable and widely tested combination.
  • Use W8-A8_dynamic when you need dynamic activation quantization.
  • Use W4-A8_dynamic for aggressive INT4 weight compression. This scheme is recommended for large language models (LLMs).

YAML configuration​

steps:
- graph_optimize: null
- graph_quantize:
- scheme: W8-A8 # Available (XNNPACK): W8-A8, W8-A8_dynamic, W4-A8_dynamic / (Ethos-U): W8-A8, W8-A16
automatic_mixed_precision: null # Available: GREEDY

Advanced overrides (run.detail.yaml)​

For fine-grained control over calibration behavior, create a run.detail.yaml file in the same experiment directory.

run.detail.yaml
detail:
graph_quantize[0]:
weight:
granularity: CHANNEL # Available: CHANNEL, TENSOR
calibration_method: MINMAX # Available: MINMAX, PERCENTILE
activation:
granularity: TENSOR # Available: TENSOR
calibration_method: PERCENTILE # Available: MINMAX, PERCENTILE
percentile: 99.9
parameters:
calibration:
num_samples: -1
note

parameters.calibration is not available when using W8-A8_dynamic or W4-A8_dynamic schemes. Dynamic activation quantization determines activation ranges at runtime and does not use a separate calibration pass.

Calibration methods​

MethodBehaviorWhen to use
MINMAXMaps the absolute max float value to the max integerDefault: safe for most models
PERCENTILEClips top and bottom outliers before mappingUse when activations have occasional spikes

See run.detail.yaml for the full Mixed Precision configuration reference.

Calibration data​

GQ requires calibration data to measure activation ranges for each layer. Use a preset dataset selected during np projects create.

Log output​

============================================================
[2/4] Graph Quantize
============================================================
2026-08-21 16:08.22 [INFO ] [Workflow] Graph Quantize started

2026-08-21 16:10.15 [DONE ] [Workflow] Graph Quantize completed (1m 52s)

Performance benefits​

  • Reduced model size: INT8 weights are approximately 4 times smaller than FP32, and INT4 weights are approximately 8 times smaller
  • Faster inference: Integer arithmetic executes significantly faster than float on most hardware
  • Controlled accuracy trade-off: Calibration and AMP enable fine-grained control over the balance between accuracy and performance