1313import torch
1414from transformers import PreTrainedTokenizer , PreTrainedTokenizerFast
1515
16- import QEfficient
1716from QEfficient .base .common import AUTO_MODEL_MAP_TO_MODEL_TYPE_MAP , QEFF_MODEL_TYPE , QEFFCommonLoader
1817from QEfficient .base .modeling_qeff import QEFFBaseModel
1918from QEfficient .exporter .export_utils import export_onnx , fix_onnx_fp16 , generate_input_files , run_model_on_ort
@@ -168,11 +167,6 @@ def convert_to_cloud_kvstyle(
168167 Returns:
169168 :str: Path of exported ``ONNX`` file.
170169 """
171- warnings .warn (
172- "\033 [93mThis function will be deprecated soon, use QEfficient.export instead\033 [0m" ,
173- DeprecationWarning ,
174- stacklevel = 2 ,
175- )
176170 if os .path .exists (onnx_dir_path ):
177171 logger .warning (f"Overriding { onnx_dir_path } " )
178172 shutil .rmtree (onnx_dir_path )
@@ -323,7 +317,9 @@ def export_for_cloud(
323317 full_batch_size : Optional [int ] = None ,
324318) -> str :
325319 # Check if model architecture is supported for continuous batching.
326- if full_batch_size and qeff_model .model .config .architectures [0 ] not in get_lists_of_cb_qeff_models .architectures :
320+ if full_batch_size and qeff_model .model .config .architectures [0 ].lower () not in {
321+ x .lower () for x in get_lists_of_cb_qeff_models .architectures
322+ }:
327323 raise NotImplementedError (
328324 f"Continuous batching is not supported for { qeff_model .model .config .architectures [0 ]} "
329325 )
@@ -356,24 +352,14 @@ def export_lm_model_for_cloud(
356352 logger .warning (f"Overriding { onnx_dir_path } " )
357353 shutil .rmtree (onnx_dir_path )
358354
359- if qeff_model .is_transformed :
360- model_name = export_kvstyle_transformed_model_to_onnx (
361- model_name = model_name ,
362- transformed_model = qeff_model .model ,
363- tokenizer = tokenizer ,
364- onnx_dir_path = onnx_dir_path ,
365- seq_len = seq_length ,
366- full_batch_size = full_batch_size ,
367- ) # type: ignore
368-
369- else :
370- model_name = export_bertstyle_model_to_onnx (
371- model_name = model_name ,
372- model = qeff_model .model ,
373- tokenizer = tokenizer ,
374- onnx_dir_path = onnx_dir_path ,
375- seq_len = seq_length ,
376- ) # type: ignore
355+ model_name = export_kvstyle_transformed_model_to_onnx (
356+ model_name = model_name ,
357+ transformed_model = qeff_model .model ,
358+ tokenizer = tokenizer ,
359+ onnx_dir_path = onnx_dir_path ,
360+ seq_len = seq_length ,
361+ full_batch_size = full_batch_size ,
362+ )
377363 return os .path .join (onnx_dir_path , f"{ model_name } .onnx" )
378364
379365
@@ -398,7 +384,7 @@ def qualcomm_efficient_converter(
398384
399385 Usage 2: You can pass ``model_name`` and ``model_kv`` as an object of ``QEfficient.QEFFAutoModelForCausalLM``, In this case will directly export the ``model_kv.model`` to ``ONNX``
400386
401- We will be deprecating this function and it will be replaced by ``QEffAutoModelForCausalLM .export``.
387+ We will be deprecating this function and it will be replaced by ``QEFFAutoModelForCausalLM .export``.
402388
403389 ``Mandatory`` Args:
404390 :model_name (str): The name of the model to be used.
@@ -423,7 +409,7 @@ def qualcomm_efficient_converter(
423409
424410 """
425411 warnings .warn (
426- "\033 [93mmodel_kv argument will be replaced by qeff_model of type QEFFBaseModel \033 [0m" ,
412+ "\033 [93m`qualcomm_efficient_converter` method will be deprecated soon, use `QEFFAutoModelForCausalLM.export` instead \033 [0m" ,
427413 DeprecationWarning ,
428414 stacklevel = 2 ,
429415 )
@@ -440,13 +426,8 @@ def qualcomm_efficient_converter(
440426 )
441427 )
442428
443- # Transform if required
444- if model_kv .is_transformed and not kv :
445- raise AttributeError ("Transformed model is passed while requesting to convert non-transformed model" )
446- model_kv = model_kv if model_kv .is_transformed else QEfficient .transform (model_kv ) if kv else model_kv
447-
448429 if onnx_dir_path is None :
449- model_card_dir = os .path .join (QEFF_MODELS_DIR , str (model_kv . model_card_name ))
430+ model_card_dir = os .path .join (QEFF_MODELS_DIR , str (model_name ))
450431 onnx_dir_path = os .path .join (model_card_dir , "onnx" )
451432 os .makedirs (onnx_dir_path , exist_ok = True )
452433
0 commit comments