@@ -88,7 +88,7 @@ def __exit__(self, type, value, traceback):
8888class OVSeq2SeqTestMixin (unittest .TestCase ):
8989 SUPPORTED_ARCHITECTURES = None
9090
91- def check_openvino_model_attributes (self , openvino_model , use_cache : bool = True , stateful : bool = True ):
91+ def _check_openvino_model_attributes (self , openvino_model , use_cache : bool = True , stateful : bool = True ):
9292 self .assertIsInstance (openvino_model , self .OVMODEL_CLASS )
9393 self .assertIsInstance (openvino_model .config , PretrainedConfig )
9494 self .assertIsInstance (openvino_model .generation_config , GenerationConfig )
@@ -171,8 +171,8 @@ def test_compare_to_transformers(self, model_arch):
171171 model_id , use_cache = False , stateful = False , ov_config = F32_CONFIG
172172 )
173173 expected_stateful = is_transformers_version (">" , "4.46" ) and model_arch in self .SUPPORT_STATEFUL
174- self .check_openvino_model_attributes (ov_model , use_cache = True , stateful = expected_stateful )
175- self .check_openvino_model_attributes (ov_stateless_model , use_cache = False , stateful = False )
174+ self ._check_openvino_model_attributes (ov_model , use_cache = True , stateful = expected_stateful )
175+ self ._check_openvino_model_attributes (ov_stateless_model , use_cache = False , stateful = False )
176176
177177 transformers_model = self .AUTOMODEL_CLASS .from_pretrained (model_id )
178178 tokenizer = AutoTokenizer .from_pretrained (model_id )
@@ -329,8 +329,8 @@ def test_compare_to_transformers(self, model_arch):
329329 transformers_model = self .AUTOMODEL_CLASS .from_pretrained (model_id )
330330 ov_model = self .OVMODEL_CLASS .from_pretrained (model_id , ov_config = F32_CONFIG )
331331 ov_model_stateless = self .OVMODEL_CLASS .from_pretrained (model_id , ov_config = F32_CONFIG , stateful = False )
332- self .check_openvino_model_attributes (ov_model , use_cache = True , stateful = True )
333- self .check_openvino_model_attributes (ov_model_stateless , use_cache = True , stateful = False )
332+ self ._check_openvino_model_attributes (ov_model , use_cache = True , stateful = True )
333+ self ._check_openvino_model_attributes (ov_model_stateless , use_cache = True , stateful = False )
334334 processor = get_preprocessor (model_id )
335335 data = self ._generate_random_audio_data ()
336336 pt_features = processor .feature_extractor (data , return_tensors = "pt" )
@@ -456,7 +456,7 @@ def test_compare_to_transformers(self, model_arch: str):
456456 model_id = MODEL_NAMES [model_arch ]
457457 ov_model = self .OVMODEL_CLASS .from_pretrained (model_id )
458458
459- self .check_openvino_model_attributes (ov_model , use_cache = True , stateful = False )
459+ self ._check_openvino_model_attributes (ov_model , use_cache = True , stateful = False )
460460
461461 set_seed (SEED )
462462 transformers_model = self .AUTOMODEL_CLASS .from_pretrained (model_id )
@@ -600,8 +600,22 @@ def _check_device_and_request(self, ov_model, expected_device, has_request):
600600 self .assertEqual (component ._device , expected_device )
601601 request_check_fn (component .request is None )
602602
603+ def _check_openvino_model_attributes (self , openvino_model , use_cache : bool = True , stateful : bool = True ):
604+ self .assertIsInstance (openvino_model , self .OVMODEL_CLASS )
605+ self .assertIsInstance (openvino_model .config , PretrainedConfig )
606+ self .assertIsInstance (openvino_model .generation_config , GenerationConfig )
607+ self .assertIsInstance (openvino_model , MODEL_TYPE_TO_CLS_MAPPING [openvino_model .config .model_type ])
608+
609+ for component_name , component in openvino_model .components .items ():
610+ self .assertIsInstance (component , MODEL_PARTS_CLS_MAPPING [component_name ])
611+ self .assertIsInstance (component .model , openvino .Model )
612+
613+ self .assertEqual (openvino_model .use_cache , use_cache )
614+ self .assertEqual (openvino_model .language_model .stateful , stateful )
615+ self .assertEqual (model_has_state (openvino_model .language_model .model ), stateful )
616+
603617 @parameterized .expand (SUPPORTED_ARCHITECTURES )
604- def test_compare_to_transformers (self , model_arch ):
618+ def test_compare_to_transformers_yo (self , model_arch ):
605619 prompt = "What is shown in this image?"
606620 model_id = MODEL_NAMES [model_arch ]
607621 set_seed (SEED )
@@ -623,13 +637,10 @@ def test_compare_to_transformers(self, model_arch):
623637 preprocessors = self .get_preprocessors (model_arch )
624638 set_seed (SEED )
625639 ov_model = self .OVMODEL_CLASS .from_pretrained (model_id , trust_remote_code = trust_remote_code , compile = False )
626- self .assertIsInstance (ov_model , MODEL_TYPE_TO_CLS_MAPPING [ov_model .config .model_type ])
627- for component_name , component in ov_model .components .items ():
628- self .assertIsInstance (component , MODEL_PARTS_CLS_MAPPING [component_name ])
629640
630- self .check_openvino_model_attributes (ov_model , use_cache = True , stateful = True )
641+ self ._check_openvino_model_attributes (ov_model , use_cache = True , stateful = True )
631642
632- inputs = ov_model .preprocess_inputs (** preprocessors , text = prompt , image = self .IMAGE .resize ((600 , 600 )))
643+ inputs = ov_model .preprocess_inputs (** preprocessors , text = prompt , image = self .IMAGE .resize ((100 , 100 )))
633644 transformers_inputs = copy .deepcopy (inputs )
634645 # llama4 preprocessing force bf16 dtype for pixel_values, that does not work on CPU with fp32 model
635646 # if past key values are not initialized, llama4 creates HybridCache with bf16 precision
@@ -949,7 +960,7 @@ def _get_vocoder(self, vocoder_id, model_arch):
949960 else :
950961 raise Exception ("{} unknown model for text-to-speech" .format (model_arch ))
951962
952- def check_openvino_model_attributes (self , openvino_model , use_cache : bool = True ):
963+ def _check_openvino_model_attributes (self , openvino_model , use_cache : bool = True ):
953964 self .assertIsInstance (openvino_model , self .OVMODEL_CLASS )
954965 self .assertIsInstance (openvino_model .config , PretrainedConfig )
955966 self .assertIsInstance (openvino_model .generation_config , GenerationConfig )
@@ -986,7 +997,7 @@ def test_compare_to_transformers(self, model_arch):
986997
987998 ov_model = self .OVMODEL_CLASS .from_pretrained (model_id , vocoder = vocoder_id )
988999 ov_speech = ov_model .generate (input_ids = inputs ["input_ids" ], speaker_embeddings = speaker_embeddings )
989- self .check_openvino_model_attributes (ov_model , use_cache = True )
1000+ self ._check_openvino_model_attributes (ov_model , use_cache = True )
9901001 self .assertTrue (torch .allclose (ov_speech , ref_speech , atol = 1e-3 ))
9911002
9921003 del vocoder
@@ -1016,7 +1027,7 @@ def test_compare_to_transformers(self, model_arch):
10161027 set_seed (SEED )
10171028 ov_model = self .OVMODEL_CLASS .from_pretrained (model_id , export = True , ov_config = F32_CONFIG )
10181029
1019- self .check_openvino_model_attributes (ov_model , use_cache = True , stateful = False )
1030+ self ._check_openvino_model_attributes (ov_model , use_cache = True , stateful = False )
10201031
10211032 question = "Who am I?"
10221033 transformers_model = self .AUTOMODEL_CLASS .from_pretrained (model_id )
0 commit comments