Skip to content

Commit 1cbba5c

Browse files
feat: improve logging for torch.compile OpenVINO backend
- Add debug log when OpenVINO backend starts subgraph compilation - Add debug log when cached model is loaded from disk - Add debug log when subgraph is successfully compiled - Add debug log for fully/partially supported model status - Change fallback message to warning to notify users when model falls back to native PyTorch Fixes #33116
1 parent 6f57382 commit 1cbba5c

File tree

1 file changed

+11
-3
lines changed
  • src/bindings/python/src/openvino/frontend/pytorch/torchdynamo

1 file changed

+11
-3
lines changed

src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/backend.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
from openvino import Core, Type, PartialShape
3131

3232
logger = logging.getLogger(__name__)
33-
logger.setLevel(logging.WARNING)
3433

3534
"""
3635
This is a preview feature in OpenVINO. This feature
@@ -67,6 +66,8 @@ def openvino(subgraph, example_inputs, options=None):
6766

6867
def fx_openvino(subgraph, example_inputs, options=None):
6968
try:
69+
logger.debug("OpenVINO backend: Starting compilation of subgraph.")
70+
7071
if len(openvino_options) != 0:
7172
options = openvino_options
7273
executor_parameters = None
@@ -82,6 +83,7 @@ def fx_openvino(subgraph, example_inputs, options=None):
8283
maybe_fs_cached_name = cached_model_name(model_hash_str + "_fs", _get_device(options), example_inputs, _get_cache_dir(options))
8384
if os.path.isfile(maybe_fs_cached_name + ".xml") and os.path.isfile(maybe_fs_cached_name + ".bin"):
8485
# Model is fully supported and already cached. Run the cached OV model directly.
86+
logger.debug("OpenVINO backend: Loading fully cached model from: %s", maybe_fs_cached_name)
8587
compiled_model = openvino_compile_cached_model(maybe_fs_cached_name, options, *example_inputs)
8688

8789
def _call(*args):
@@ -113,12 +115,17 @@ def _call(*args):
113115
model.eval()
114116
partitioner = Partitioner(options)
115117
compiled_model = partitioner.make_partitions(model, options)
118+
logger.debug("OpenVINO backend: Subgraph successfully compiled with OpenVINO.")
116119

117120
if executor_parameters is not None and "model_hash_str" in executor_parameters:
118121
# Check if the model is fully supported.
119122
fully_supported = partitioner.check_fully_supported(compiled_model)
120123
if fully_supported:
121124
executor_parameters["model_hash_str"] += "_fs"
125+
logger.debug("OpenVINO backend: Model is fully supported by OpenVINO.")
126+
else:
127+
logger.debug("OpenVINO backend: Model is partially supported. "
128+
"Some subgraphs will run on OpenVINO, others on native PyTorch.")
122129

123130
def _call(*args):
124131
if _get_aot_autograd(options):
@@ -132,9 +139,10 @@ def _call(*args):
132139
_call._boxed_call = True # type: ignore[attr-defined]
133140
return _call
134141
except Exception as e:
135-
logger.debug(f"Failed in OpenVINO execution: {e}")
142+
logger.warning("OpenVINO backend: Failed to compile subgraph with OpenVINO. "
143+
"Falling back to native PyTorch. Reason: %s", e)
136144
return compile_fx(subgraph, example_inputs)
137145

138146

139147
def reset():
140-
clear_caches()
148+
clear_caches()

0 commit comments

Comments
 (0)