Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable graph check while tracing #1103

Merged
merged 4 commits into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion optimum/exporters/openvino/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
_transformers_version,
compare_versions,
is_openvino_tokenizers_version,
is_openvino_version,
is_tokenizers_version,
is_transformers_version,
)
Expand Down Expand Up @@ -365,6 +366,7 @@ def export_pytorch(
import torch
from torch.utils._pytree import tree_map

from openvino.frontend.pytorch.ts_decoder import TorchScriptPythonDecoder
from optimum.exporters.utils import check_dummy_inputs_are_allowed

logger.info(f"Using framework PyTorch: {torch.__version__}")
Expand Down Expand Up @@ -427,15 +429,20 @@ def ts_patched_forward(*args, **kwargs):

patcher.patched_forward = ts_patched_forward

ts_decoder_kwargs = {}
if library_name == "diffusers" and is_openvino_version(">=", "2025.0"):
ts_decoder_kwargs["trace_kwargs"] = {"check_trace": False}

with patcher:
if patch_16bit_model:
from openvino.frontend.pytorch.patch_model import __make_16bit_traceable

__make_16bit_traceable(model)
check_dummy_inputs_are_allowed(model, dummy_inputs)
input_info = _get_input_info(model, config, dummy_inputs)
ts_decoder = TorchScriptPythonDecoder(model, example_input=dummy_inputs, **ts_decoder_kwargs)
ov_model = convert_model(
model,
ts_decoder,
example_input=dummy_inputs,
input=[(item.shape, item.type) for item in input_info],
)
Expand Down