Skip to content

Commit a64aa72

Browse files
committed
Disable graph check while tracing
1 parent bb1c68a commit a64aa72

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

optimum/exporters/openvino/convert.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from transformers.generation import GenerationMixin
2424
from transformers.utils import is_tf_available, is_torch_available
2525

26+
from openvino.frontend.pytorch.ts_decoder import TorchScriptPythonDecoder
2627
from openvino.runtime import Model, save_model
2728
from openvino.runtime.exceptions import OVTypeError
2829
from openvino.tools.ovc import convert_model
@@ -46,6 +47,7 @@
4647
is_openvino_tokenizers_version,
4748
is_tokenizers_version,
4849
is_transformers_version,
50+
is_openvino_version,
4951
)
5052
from optimum.utils import DEFAULT_DUMMY_SHAPES, is_diffusers_available
5153

@@ -427,15 +429,20 @@ def ts_patched_forward(*args, **kwargs):
427429

428430
patcher.patched_forward = ts_patched_forward
429431

432+
decoder_kwargs = {}
433+
if library_name == "diffusers" and is_openvino_version(">=", "2025.0"):
434+
decoder_kwargs["trace_kwargs"] = {"check_trace": False}
435+
430436
with patcher:
431437
if patch_16bit_model:
432438
from openvino.frontend.pytorch.patch_model import __make_16bit_traceable
433439

434440
__make_16bit_traceable(model)
435441
check_dummy_inputs_are_allowed(model, dummy_inputs)
436442
input_info = _get_input_info(model, config, dummy_inputs)
443+
decoder = TorchScriptPythonDecoder(model, example_input=dummy_inputs, **decoder_kwargs)
437444
ov_model = convert_model(
438-
model,
445+
decoder,
439446
example_input=dummy_inputs,
440447
input=[(item.shape, item.type) for item in input_info],
441448
)

0 commit comments

Comments
 (0)