Handles the FuriosaAI quantization process for models shared on huggingface.co/models.
Computes the quantization ranges.
( dataset: Dataset calibration_config: CalibrationConfig batch_size: int = 1 )
Parameters
Dataset
) —
The dataset to use when performing the calibration step. int
, optional, defaults to 1) —
The batch size to use when collecting the quantization ranges values. Performs the calibration step and computes the quantization ranges.
( model_or_path: Union file_name: Optional = None )
Parameters
Union[FuriosaAIModel, str, Path]
) —
Can be either:FuriosaAIModelModelForXX
class, e.g., FuriosaAIModelModelForImageClassification
.Optional[str]
, optional) —
Overwrites the default model file name from "model.onnx"
to file_name
.
This allows you to load different model files from the same repository or directory. Instantiates a FuriosaAIQuantizer
from a model path.
( dataset_name: str num_samples: int = 100 dataset_config_name: Optional = None dataset_split: Optional = None preprocess_function: Optional = None preprocess_batch: bool = True seed: int = 2016 use_auth_token: bool = False )
Parameters
str
) —
The dataset repository name on the Hugging Face Hub or path to a local directory containing data files
to load to use for the calibration step. int
, optional, defaults to 100) —
The maximum number of samples composing the calibration dataset. Optional[str]
, optional) —
The name of the dataset configuration. Optional[str]
, optional) —
Which split of the dataset to use to perform the calibration step. Optional[Callable]
, optional) —
Processing function to apply to each example after loading dataset. bool
, optional, defaults to True
) —
Whether the preprocess_function
should be batched. int
, optional, defaults to 2016) —
The random seed to use when shuffling the calibration dataset. bool
, optional, defaults to False
) —
Whether to use the token generated when running transformers-cli login
(necessary for some datasets
like ImageNet). Creates the calibration datasets.Dataset
to use for the post-training static quantization calibration step.
( dataset: Dataset calibration_config: CalibrationConfig batch_size: int = 1 )
Parameters
Dataset
) —
The dataset to use when performing the calibration step. CalibrationConfig
) —
The configuration containing the parameters related to the calibration step. int
, optional, defaults to 1) —
The batch size to use when collecting the quantization ranges values. Performs the calibration step and collects the quantization ranges without computing them.
( quantization_config: QuantizationConfig save_dir: Union file_suffix: Optional = 'quantized' calibration_tensors_range: Optional = None )
Parameters
QuantizationConfig
) —
The configuration containing the parameters related to quantization. Union[str, Path]
) —
The directory where the quantized model should be saved. Optional[str]
, optional, defaults to "quantized"
) —
The file_suffix used to save the quantized model. Optional[Dict[NodeName, Tuple[float, float]]]
, optional) —
The dictionary mapping the nodes name to their quantization ranges, used and required only when applying
static quantization. Quantizes a model given the optimization specifications defined in quantization_config
.