XQuant Configuration

class model_compression_toolkit.xquant.common.xquant_config.XQuantConfig(report_dir, custom_similarity_metrics=None, quantize_reported_dir=None, threshold_quantize_error={'mse': 0.1, 'cs': 0.1, 'sqnr': 0.1}, is_detect_under_threshold_quantize_error={'mse': False, 'cs': True, 'sqnr': True}, threshold_degrade_layer_ratio=0.5, threshold_zscore_outlier_removal=5.0, threshold_ratio_unbalanced_concatenation=16.0, threshold_bitwidth_mixed_precision_with_model_output_loss_objective=2)

Configuration for generating the report. It allows to set the log dir that the report will be saved in and to add similarity metrics to measure between tensors of the two models.

Initializes the configuration for explainable quantization.

Parameters:
  • report_dir (str) – Directory where the reports will be saved.

  • custom_similarity_metrics (Dict[str, Callable]) – Custom similarity metrics to be computed between tensors of the two models. The dictionary keys are similarity metric names and the values are callables that implement the similarity metric computation.

  • quantize_reported_dir (str) – Directory where the the quantization log will be saved.

  • threshold_quantize_error (Dict[str, float]) – Threshold values for detecting degradation in accuracy.

  • is_detect_under_threshold_quantize_error (Dict[str, bool]) – For each threshold specified in threshold_quantize_error, True: detect the layer as degraded when the error is below the threshold.; False: detect the layer as degraded when the error is above the threshold.

  • threshold_degrade_layer_ratio (float) – If the number of layers detected as degraded is large, skips the judge degradation causes Specify the ratio here.

  • threshold_zscore_outlier_removal (float) – Used in judge degradation causes (Outlier Removal). Threshold for z_score to detect outliers.

  • threshold_ratio_unbalanced_concatenation (float) – Used in judge degradation causes (unbalanced “concatnation”). Threshold for the multiplier of range width between concatenated layers.

  • threshold_bitwidth_mixed_precision_with_model_output_loss_objective (int) – Used in judge degradation causes (Mixed precision with model output loss objective). Bitwidth of the final layer to judge insufficient bitwidth.

Note

The following parameters are only used in the xquant_report_troubleshoot_pytorch_experimental function.

  • quantize_reported_dir

  • threshold_quantize_error

  • is_detect_under_threshold_quantize_error

  • threshold_degrade_layer_ratio

  • threshold_zscore_outlier_removal

  • threshold_ratio_unbalanced_concatenation

  • threshold_bitwidth_mixed_precision_with_model_output_loss_objective