Skip to content

Commit

Permalink
update quantization tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eaidova committed Jul 4, 2024
1 parent a7058e3 commit 5a717fc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 9 additions & 0 deletions optimum/intel/openvino/modeling_base_seq2seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,15 @@ def _from_pretrained(
force_download=force_download,
local_files_only=local_files_only,
)
_ = hf_hub_download(
repo_id=model_id,
filename=decoder_with_past_file_name.replace(".xml", ".bin"),
token=token,
revision=revision,
cache_dir=cache_dir,
force_download=force_download,
local_files_only=local_files_only,
)

decoder_with_past = cls.load_model(decoder_with_past_path, quantization_config)

Expand Down
9 changes: 5 additions & 4 deletions tests/openvino/test_quantization.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def test_ovmodel_load_with_compressed_weights(self, model_cls, model_type):
self.assertEqual(model._openvino_config.dtype, "int8")

if model.export_feature.startswith("text2text-generation"):
models = [model.encoder, model.decoder, model.decoder_with_past]
models = [model.encoder, model.decoder]
elif model.export_feature.startswith("stable-diffusion"):
models = [model.unet, model.vae_encoder, model.vae_decoder]
models.append(model.text_encoder if model.export_feature == "stable-diffusion" else model.text_encoder_2)
Expand Down Expand Up @@ -488,7 +488,7 @@ def test_ovmodel_load_with_uncompressed_weights(self, model_cls, model_type):
model = model_cls.from_pretrained(MODEL_NAMES[model_type], export=True, load_in_8bit=False)

if model.export_feature.startswith("text2text-generation"):
models = [model.encoder, model.decoder, model.decoder_with_past]
models = [model.encoder, model.decoder]
elif model.export_feature.startswith("stable-diffusion"):
models = [model.unet, model.vae_encoder, model.vae_decoder]
models.append(model.text_encoder if model.export_feature == "stable-diffusion" else model.text_encoder_2)
Expand Down Expand Up @@ -855,11 +855,12 @@ def _generate_random_audio_data(processor):
@parameterized.expand(itertools.product(MODEL_ID, APPLY_CACHING))
def test_calibration_data_uniqueness(self, model_id, apply_caching):
ov_model = OVModelForSpeechSeq2Seq.from_pretrained(model_id, export=True, compile=True)
self.assertTrue(ov_model.decoder_with_past is None)
processor = AutoProcessor.from_pretrained(model_id)

calibration_data = []
ov_model.decoder_with_past.request = InferRequestWrapper(
ov_model.decoder_with_past.request, calibration_data, apply_caching=apply_caching
ov_model.decoder.request = InferRequestWrapper(
ov_model.decoder.request, calibration_data, apply_caching=apply_caching
)
for _ in range(2):
input_features = self._generate_random_audio_data(processor)
Expand Down

0 comments on commit 5a717fc

Please sign in to comment.