@@ -85,7 +85,7 @@ def from_pretrained(cls, pretrained_model_name_or_path: str, *args, **kwargs):
85
85
kwargs .update ({"attn_implementation" : "eager" , "low_cpu_mem_usage" : False })
86
86
87
87
model = cls ._hf_auto_class .from_pretrained (pretrained_model_name_or_path , * args , ** kwargs )
88
- return cls (model )
88
+ return cls (model , pretrained_model_name_or_path = pretrained_model_name_or_path )
89
89
90
90
@property
91
91
def model_name (self ) -> str :
@@ -160,6 +160,7 @@ def __init__(self, model: nn.Module, **kwargs):
160
160
super ().__init__ (model )
161
161
self .model .config .use_cache = True
162
162
self .num_layers = model .config .num_hidden_layers
163
+ self .pretrained_model_name_or_path = kwargs .get ("pretrained_model_name_or_path" , None )
163
164
164
165
@classmethod
165
166
@with_replaced_quantizers
@@ -212,7 +213,7 @@ def from_pretrained(cls, pretrained_model_name_or_path, *args, **kwargs):
212
213
model , kv_offload = kv_offload
213
214
)
214
215
215
- return cls (model )
216
+ return cls (model , pretrained_model_name_or_path = pretrained_model_name_or_path )
216
217
217
218
@property
218
219
def model_hash (self ) -> str :
@@ -226,6 +227,9 @@ def model_hash(self) -> str:
226
227
mhash = hashlib .sha256 ()
227
228
mhash .update (to_hashable (self .model .config .to_diff_dict ()))
228
229
mhash .update (to_hashable (self ._transform_names ()))
230
+
231
+ mhash .update (to_hashable (self .pretrained_model_name_or_path ))
232
+
229
233
mhash = mhash .hexdigest ()[:16 ]
230
234
return mhash
231
235
@@ -441,6 +445,7 @@ def model_hash(self) -> str:
441
445
mhash .update (to_hashable (self .model .model .config .to_diff_dict ()))
442
446
mhash .update (to_hashable (self ._transform_names ()))
443
447
mhash .update (to_hashable ({"QEffVisionEncoderForTextImageToTextModel" : True }))
448
+ mhash .update (to_hashable (self .model .model .pretrained_model_name_or_path ))
444
449
mhash = mhash .hexdigest ()[:16 ]
445
450
return mhash
446
451
@@ -504,6 +509,7 @@ def model_hash(self) -> str:
504
509
mhash .update (to_hashable (self .model .config .to_diff_dict ()))
505
510
mhash .update (to_hashable (self ._transform_names ()))
506
511
mhash .update (to_hashable ({"QEffCausalLMForTextImageToTextModel" : True }))
512
+ mhash .update (to_hashable (self .model .model .pretrained_model_name_or_path ))
507
513
mhash = mhash .hexdigest ()[:16 ]
508
514
return mhash
509
515
@@ -531,9 +537,9 @@ def __init__(
531
537
raise NotImplementedError ("Continuous batching is not supported for image-text-to-text models yet." )
532
538
self .model = model
533
539
self .config = model .config
540
+ self .model .pretrained_model_name_or_path = kwargs .get ("pretrained_model_name_or_path" , None )
534
541
self .vision_model = QEffVisionEncoderForTextImageToTextModel (model )
535
542
self .lang_model = QEffCausalLMForTextImageToTextModel (model )
536
-
537
543
self .input_shapes , self .output_names = None , None
538
544
539
545
@property
@@ -553,7 +559,7 @@ def from_pretrained(cls, pretrained_model_name_or_path: str, **kwargs):
553
559
554
560
kwargs .update ({"attn_implementation" : "eager" , "low_cpu_mem_usage" : False })
555
561
model = cls ._hf_auto_class .from_pretrained (pretrained_model_name_or_path , ** kwargs )
556
- return cls (model , ** kwargs )
562
+ return cls (model , pretrained_model_name_or_path = pretrained_model_name_or_path , ** kwargs )
557
563
558
564
@property
559
565
def onnx_path (self ):
@@ -878,6 +884,7 @@ def __init__(
878
884
self .model .config .vision_config .use_flash_attn = "false"
879
885
else :
880
886
self .model .config .text_config .use_cache = True
887
+ self .pretrained_model_name_or_path = kwargs .get ("pretrained_model_name_or_path" , None )
881
888
882
889
@classmethod
883
890
def from_pretrained (
@@ -900,7 +907,7 @@ def from_pretrained(
900
907
config .vision_config .use_flash_attn = "false"
901
908
model = cls ._hf_auto_class .from_pretrained (pretrained_model_name_or_path , config , * args , ** kwargs )
902
909
903
- return cls (model , ** kwargs )
910
+ return cls (model , pretrained_model_name_or_path = pretrained_model_name_or_path , ** kwargs )
904
911
905
912
def export (
906
913
self ,
@@ -1139,6 +1146,7 @@ def model_hash(self) -> str:
1139
1146
mhash .update (to_hashable (self .model .config .to_diff_dict ()))
1140
1147
mhash .update (to_hashable (self ._transform_names ()))
1141
1148
mhash .update (to_hashable ({"QEFFAutoModelForImageTextToText1QPC" : True }))
1149
+ mhash .update (to_hashable (self .pretrained_model_name_or_path ))
1142
1150
mhash = mhash .hexdigest ()[:16 ]
1143
1151
return mhash
1144
1152
@@ -1254,7 +1262,7 @@ def from_pretrained(cls, pretrained_model_name_or_path: str, kv_offload: Optiona
1254
1262
1255
1263
kwargs .update ({"attn_implementation" : "eager" , "low_cpu_mem_usage" : False })
1256
1264
model = cls ._hf_auto_class .from_pretrained (pretrained_model_name_or_path , ** kwargs )
1257
- return cls (model , kv_offload = kv_offload , ** kwargs )
1265
+ return cls (model , kv_offload = kv_offload , pretrained_model_name_or_path = pretrained_model_name_or_path , ** kwargs )
1258
1266
1259
1267
1260
1268
MISCLASSIFIED_CAUSAL_LM_TO_QEFF_AUTO_CLASS_MAP = {"InternVLChatModel" : QEFFAutoModelForImageTextToText }
@@ -1319,13 +1327,13 @@ def __init__(
1319
1327
)
1320
1328
1321
1329
super ().__init__ (model )
1322
-
1323
1330
# Set use_cache=True to get KV values as output during ONNX export
1324
1331
self .model .config .use_cache = True
1325
1332
self .num_layers = model .config .num_hidden_layers
1326
1333
self .continuous_batching = continuous_batching
1327
1334
self .model , transformed = SpDTransform .apply (self .model , qaic_config , ** kwargs )
1328
1335
self .is_tlm = transformed
1336
+ self .pretrained_model_name_or_path = kwargs .get ("pretrained_model_name_or_path" , None )
1329
1337
1330
1338
@property
1331
1339
def model_name (self ) -> str :
@@ -1400,11 +1408,11 @@ def from_pretrained(
1400
1408
return MISCLASSIFIED_CAUSAL_LM_TO_QEFF_AUTO_CLASS_MAP [model .__class__ .__name__ ](
1401
1409
model , kv_offload = kv_offload
1402
1410
)
1403
-
1404
1411
return cls (
1405
1412
model ,
1406
1413
continuous_batching = continuous_batching ,
1407
1414
qaic_config = qaic_config ,
1415
+ pretrained_model_name_or_path = pretrained_model_name_or_path ,
1408
1416
** kwargs ,
1409
1417
)
1410
1418
@@ -1416,6 +1424,7 @@ def model_hash(self) -> str:
1416
1424
mhash .update (to_hashable ({"continuous_batching" : self .continuous_batching }))
1417
1425
mhash .update (to_hashable ({"is_tlm" : self .is_tlm }))
1418
1426
mhash .update (to_hashable (self ._transform_names ()))
1427
+ mhash .update (to_hashable (self .pretrained_model_name_or_path ))
1419
1428
mhash = mhash .hexdigest ()[:16 ]
1420
1429
return mhash
1421
1430
@@ -1756,6 +1765,7 @@ def __init__(self, model: nn.Module, **kwargs):
1756
1765
super ().__init__ (model )
1757
1766
self .model .config .use_cache = True
1758
1767
self .num_layers = model .config .num_hidden_layers
1768
+ self .pretrained_model_name_or_path = kwargs .get ("pretrained_model_name_or_path" , None )
1759
1769
1760
1770
@property
1761
1771
def model_hash (self ) -> str :
@@ -1769,6 +1779,7 @@ def model_hash(self) -> str:
1769
1779
mhash = hashlib .sha256 ()
1770
1780
mhash .update (to_hashable (self .model .config .to_diff_dict ()))
1771
1781
mhash .update (to_hashable (self ._transform_names ()))
1782
+ mhash .update (to_hashable (self .pretrained_model_name_or_path ))
1772
1783
mhash = mhash .hexdigest ()[:16 ]
1773
1784
return mhash
1774
1785
0 commit comments