Skip to content

Commit 3da5328

Browse files
committed
fix loading decoder_with_past
1 parent 27b30ac commit 3da5328

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

optimum/intel/openvino/modeling_base_seq2seq.py

+15
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ def _from_pretrained(
272272
subfolder=subfolder,
273273
)
274274
file_names[name] = model_cache_path
275+
decoder_with_past = cls.load_model(file_names["decoder_with_past"], quantization_config)
275276
else:
276277
encoder = cls._compile_model(
277278
file_names["encoder"], kwargs.get("device", "CPU"), kwargs.get("ov_config"), model_save_dir
@@ -280,6 +281,20 @@ def _from_pretrained(
280281
file_names["decoder"], kwargs.get("device", "CPU"), kwargs.get("ov_config"), model_save_dir
281282
)
282283
if use_cache and not model_has_state(decoder):
284+
model_file_names["decoder_with_past"] = decoder_with_past_file_name
285+
model_file_names["decoder_with_past_bin"] = decoder_with_past_file_name.replace(".xml", ".bin")
286+
for name in ["decoder_with_past", "decoder_with_past_bin"]:
287+
model_cache_path = hf_hub_download(
288+
repo_id=model_id,
289+
filename=model_file_names[name],
290+
token=token,
291+
revision=revision,
292+
cache_dir=cache_dir,
293+
force_download=force_download,
294+
local_files_only=local_files_only,
295+
subfolder=subfolder,
296+
)
297+
file_names[name] = model_cache_path
283298
decoder_with_past = cls._compile_model(
284299
file_names["decoder_with_past"],
285300
kwargs.get("device", "CPU"),

0 commit comments

Comments
 (0)