@@ -200,9 +200,15 @@ def quantize(
200200 use_xpu = device == torch .device ("xpu" ) or device == "xpu"
201201 calibration_dataloader = None
202202
203+ if save_onnx_model :
204+ logger .warning ("ONNX model export is deprecated and will be removed soon." )
205+
206+ if isinstance (self ._original_model , ORTModel ):
207+ logger .warning ("ONNX model quantization is deprecated and will be removed soon." )
208+
203209 if save_onnx_model and isinstance (self ._original_model , ORTModel ):
210+ logger .warning ("The model provided is already an ONNX model. Setting `save_onnx_model` to False." )
204211 save_onnx_model = False
205- logger .warning ("Model provided is an ONNX model, `save_onnx_model` is set to False" )
206212
207213 default_name = WEIGHTS_NAME if not isinstance (self ._original_model , ORTModel ) else ONNX_WEIGHTS_NAME
208214 self ._set_task ()
@@ -223,13 +229,16 @@ def quantize(
223229 f"but only version { IPEX_MINIMUM_VERSION } or higher is supported."
224230 )
225231
226- if save_onnx_model :
227- if (
228- not isinstance (quantization_config , PostTrainingQuantConfig )
229- or INCQuantizationMode (quantization_config .approach ) == INCQuantizationMode .DYNAMIC
230- ):
231- logger .warning ("ONNX export for dynamic and weight only quantized model is not supported." )
232- save_onnx_model = False
232+ if save_onnx_model and (
233+ not isinstance (quantization_config , PostTrainingQuantConfig )
234+ or INCQuantizationMode (quantization_config .approach ) == INCQuantizationMode .DYNAMIC
235+ ):
236+ logger .warning (
237+ "ONNX export for dynamic and weight only quantized model is not supported. "
238+ "Only static quantization model can be exported to ONNX format. "
239+ "Setting `save_onnx_model` to False."
240+ )
241+ save_onnx_model = False
233242
234243 # ITREX Weight Only Quantization
235244 if not isinstance (quantization_config , PostTrainingQuantConfig ):
@@ -296,9 +305,13 @@ def quantize(
296305 remove_unused_columns = remove_unused_columns ,
297306 data_collator = data_collator ,
298307 )
308+
299309 op_type_dict = getattr (quantization_config , "op_type_dict" , None )
300- if op_type_dict is None or "Embedding" not in op_type_dict :
301- logger .warning ("ONNX export is no supported for model with quantized embeddings" )
310+ if save_onnx_model and (op_type_dict is None or "Embedding" not in op_type_dict ):
311+ logger .warning (
312+ "ONNX export is no supported for model with quantized embeddings. "
313+ "Setting `save_onnx_model` to False."
314+ )
302315 save_onnx_model = False
303316
304317 if not isinstance (quantization_config , PostTrainingQuantConfig ):
0 commit comments